Skip to content

Commit

Permalink
Merge branch 'master' of github.com:affinityproject/client-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
djvs committed Jul 3, 2020
2 parents 0fb18d3 + 2101b5f commit 32ef811
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 43 deletions.
17 changes: 10 additions & 7 deletions generate
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CLIENT_NAME="$SERVICE_NAME-client"
CLIENT_DIR="$OUTPUT_DIR/$CLIENT_NAME"
GENERATOR_DIR="./"
OPENAPI_GENERATOR_JAR_PATH="$GENERATOR_DIR/openapi-generator-cli.jar"
if [[ ! -v DOCUMENTATION_URL ]]; then
if [[ ! -v DOCUMENTATION_URL ]]; then
DOCUMENTATION_URL="http://localhost:3000/documentation/json"
fi

Expand All @@ -16,7 +16,7 @@ echo "Service name: $SERVICE_NAME"
echo "Client name: $CLIENT_NAME"
echo "Client dir: $CLIENT_DIR"

if [[ -d "$CLIENT_DIR" ]]; then
if [[ -d "$CLIENT_DIR" ]]; then
if [[ -v FORCE_OVERWRITE ]]; then
echo 'Overwriting existing client...'
else
Expand All @@ -31,14 +31,14 @@ if [[ -d "$CLIENT_DIR" ]]; then
fi

# Get the OpenAPI generator CLI tool and save to ./generators/client/
if [[ ! -f "$OPENAPI_GENERATOR_JAR_PATH" ]]; then
if [[ ! -f "$OPENAPI_GENERATOR_JAR_PATH" ]]; then
wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar -O "$OPENAPI_GENERATOR_JAR_PATH"
fi

# Create project from TSDX template in OUTPUT_DIR
pushd "$OUTPUT_DIR";
tsdx create --template basic "$CLIENT_NAME"
popd;
npx tsdx create --template basic "$CLIENT_NAME"
popd;

# Pull API JSON from the (hopefully running) service
# mkdir -p "$CLIENT_DIR/src"
Expand All @@ -51,7 +51,7 @@ perl -pi -e "s/\@/PLACEHOLDERATSIGNPLACEHOLDER/g" "$CLIENT_DIR/api.json"
java -jar "$OPENAPI_GENERATOR_JAR_PATH" generate -o "$CLIENT_DIR/src/" -i "$CLIENT_DIR/api.json" -g typescript-axios -c ./config.yaml --package-name "$CLIENT_NAME"

# And then add the @ signs back in...
perl -pi -e "s/PLACEHOLDERATSIGNPLACEHOLDER/\@/g" $CLIENT_DIR/api.json
perl -pi -e "s/PLACEHOLDERATSIGNPLACEHOLDER/\@/g" $CLIENT_DIR/api.json
perl -pi -e "s/ PLACEHOLDERATSIGNPLACEHOLDER([^:]*): / '\@\1': /g" $CLIENT_DIR/src/**/*
perl -pi -e "s/PLACEHOLDERATSIGNPLACEHOLDER/\@/g" $CLIENT_DIR/src/**/*

Expand All @@ -68,6 +68,9 @@ mv "$CLIENT_DIR/blah.test.ts" "$CLIENT_DIR/test/blah.test.ts"

pushd "$CLIENT_DIR"
npm install --save axios '@types/axios'
npm install --save-dev '@affinityproject/eslint-config' '@affinityproject/prettier-config' '@typescript-eslint/eslint-plugin' '@typescript-eslint/parser' eslint eslint-config-prettier eslint-plugin-prettier prettier
npx prettier --write ./src/**/*.ts
tsdx lint src test --fix
npm run lint -- src test --fix
rm -f yarn.lock
rm -rf test
npm run build
14 changes: 4 additions & 10 deletions template/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
module.exports = {
extends: ['@affinityproject/eslint-config'],
rules: {
'@typescript-eslint/no-unused-vars': ['off'],
'@typescript-eslint/consistent-type-assertions': ['off'],
'@typescript-eslint/consistent-type-assertions': ['off'],
'@typescript-eslint/interface-name-prefix': [
'off',
{
prefixWithI: 'always',
},
],
'@typescript-eslint/no-namespace': ['off', {allowDeclarations: false, allowDefinitionFiles: false}],
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'no-unused-vars': 'off',
},
}
2 changes: 1 addition & 1 deletion template/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@bloomprotocol/prettier-config')
module.exports = require('@affinityproject/prettier-config')
9 changes: 0 additions & 9 deletions template/tsconfig-paths.js

This file was deleted.

7 changes: 0 additions & 7 deletions template/tsconfig.build.json

This file was deleted.

12 changes: 3 additions & 9 deletions template/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"include": ["src", "types", "test"],
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": ["dom", "esnext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"outDir": "build",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
Expand All @@ -20,14 +19,9 @@
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": ["node_modules/*"],
".*": ["src/*"],
"@src/*": ["src/*"]
},
"jsx": "react",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
},
"include": ["src"]
}

0 comments on commit 32ef811

Please sign in to comment.