diff --git a/.github/actions/lint/action.yaml b/.github/actions/lint/action.yaml index dfa8ff92..ad134f3f 100644 --- a/.github/actions/lint/action.yaml +++ b/.github/actions/lint/action.yaml @@ -10,4 +10,4 @@ runs: run: npm i - name: Lint affected shell: bash - run: npx nx affected -t lint + run: npx nx affected -t lint --exclude=@redhat-cloud-services/CLIENTNAME-client diff --git a/.github/actions/release/action.yaml b/.github/actions/release/action.yaml index 54805358..3a634492 100644 --- a/.github/actions/release/action.yaml +++ b/.github/actions/release/action.yaml @@ -31,7 +31,7 @@ runs: git config user.email "${{ inputs.gh_email }}" - name: Build shell: bash - run: npx nx run-many -t build + run: npx nx run-many -t build --exclude=@redhat-cloud-services/CLIENTNAME-client - name: Set publish config env: NPM_TOKEN: ${{ inputs.npm_token }} @@ -42,7 +42,7 @@ runs: env: GH_TOKEN: ${{ inputs.gh_token }} GITHUB_TOKEN: ${{ inputs.gh_token }} - run: npx nx affected --base=last-release --parallel=1 --target=version --postTargets=syncDependencies,build,npm,github --trackDeps + run: npx nx affected --base=last-release --parallel=1 --target=version --postTargets=syncDependencies,build,npm,github --trackDeps --exclude=@redhat-cloud-services/CLIENTNAME-client - name: Tag last-release shell: bash run: | diff --git a/.github/actions/test-unit/action.yaml b/.github/actions/test-unit/action.yaml index b9c104cb..84d1124b 100644 --- a/.github/actions/test-unit/action.yaml +++ b/.github/actions/test-unit/action.yaml @@ -10,4 +10,4 @@ runs: run: npm i - name: Test affected shell: bash - run: npx nx affected -t test --configuration=ci + run: npx nx affected -t test --configuration=ci --exclude=@redhat-cloud-services/CLIENTNAME-client diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 868a0877..e378dc7a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: - name: Install deps run: npm i - name: Build affected - run: npx nx affected -t build + run: npx nx affected -t build --exclude=@redhat-cloud-services/CLIENTNAME-client release: runs-on: ubuntu-latest needs: [install, lint, test, build] diff --git a/package.json b/package.json index da253ecf..1ff3e0c6 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "scripts": { "install": "mvn install -q -DskipTests", "build:generator": "mvn clean package -q -DskipTests", + "create-client": "utils/create-client.sh", "generate": "npm run generate:prod --workspaces && npm run doc --workspaces && npm run build --workspaces", "doc": "npm run doc --workspaces", "generate:prod": "npm run generate:prod --workspaces", @@ -18,13 +19,13 @@ "nx": "nx", "prepare": "husky install", "dev": "nx run test-app:serve", - "test:unit": "nx run-many -t test", - "test:unit:affected": "nx affected -t test", - "test": "npm-run-all --parallel test:*", - "build": "nx run-many -t build", - "lint": "nx run-many -t lint", - "lint:fix": "nx run-many -t lint --fix", - "version": "nx run-many -t version" + "test:unit": "nx run-many -t test --exclude=@redhat-cloud-services/CLIENTNAME-client", + "test:unit:affected": "nx affected -t test --exclude=@redhat-cloud-services/CLIENTNAME-client", + "test": "npm-run-all --parallel test:* --exclude=@redhat-cloud-services/CLIENTNAME-client", + "build": "nx run-many -t build --exclude=@redhat-cloud-services/CLIENTNAME-client", + "lint": "nx run-many -t lint --exclude=@redhat-cloud-services/CLIENTNAME-client", + "lint:fix": "nx run-many -t lint --fix --exclude=@redhat-cloud-services/CLIENTNAME-client", + "version": "nx run-many -t version --exclude=@redhat-cloud-services/CLIENTNAME-client" }, "workspaces": [ "packages/*" diff --git a/utils/create-client.sh b/utils/create-client.sh new file mode 100755 index 00000000..b42bac7e --- /dev/null +++ b/utils/create-client.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "Enter the name for the new client" +read client + +mkdir packages/$client +cp utils/nx-base/.* utils/nx-base/* packages/$client + +sed -i '' "s/CLIENTNAME/$client/g" packages/$client/package.json +sed -i '' "s/CLIENTNAME/$client/g" packages/$client/project.json +sed -i '' "s/CLIENTNAME/$client/g" packages/$client/jest.config.ts diff --git a/utils/nx-base/.eslintrc.json b/utils/nx-base/.eslintrc.json new file mode 100644 index 00000000..0190330a --- /dev/null +++ b/utils/nx-base/.eslintrc.json @@ -0,0 +1,35 @@ +{ + "extends": ["../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": { + "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/ban-types": [ + "error", + { + "types": { + "{}": false + }, + "extendDefaults": true + } + ]} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.json"], + "parser": "jsonc-eslint-parser", + "rules": { + "@nx/dependency-checks": "off" + } + } + ] +} diff --git a/utils/nx-base/.gitignore b/utils/nx-base/.gitignore new file mode 100644 index 00000000..149b5765 --- /dev/null +++ b/utils/nx-base/.gitignore @@ -0,0 +1,4 @@ +wwwroot/*.js +node_modules +typings +dist diff --git a/utils/nx-base/.npmignore b/utils/nx-base/.npmignore new file mode 100644 index 00000000..849dbba8 --- /dev/null +++ b/utils/nx-base/.npmignore @@ -0,0 +1 @@ +# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm diff --git a/utils/nx-base/jest.config.ts b/utils/nx-base/jest.config.ts new file mode 100644 index 00000000..a2351499 --- /dev/null +++ b/utils/nx-base/jest.config.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +export default { + displayName: 'CLIENTNAME-client', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], + }, + moduleFileExtensions: ['ts', 'js', 'html'], + coverageDirectory: '../../coverage/packages/CLIENTNAME', +}; diff --git a/utils/nx-base/package.json b/utils/nx-base/package.json new file mode 100644 index 00000000..0b95b9ee --- /dev/null +++ b/utils/nx-base/package.json @@ -0,0 +1,30 @@ +{ + "name": "@redhat-cloud-services/CLIENTNAME-client", + "version": "1.3.0", + "description": "", + "main": "./index.js", + "module": "./esm/index.js", + "typings": "./index.d.ts", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/RedHatInsights/javascript-clients.git" + }, + "author": "", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/RedHatInsights/javascript-clients/issues" + }, + "homepage": "https://github.com/RedHatInsights/javascript-clients#readme", + "scripts": { + "doc": "typedoc --theme markdown --out doc --gitRevision master index.ts", + "generate": "TS_POST_PROCESS_FILE='../../postProcess.sh' openapi-generator-cli generate -i $SPEC -g typescript-axios -o . --skip-validate-spec --enable-post-process-file", + "generate:prod": "SPEC='https://raw.githubusercontent.com/RedHatInsights/CLIENTNAME-api/master/swagger/api.spec.json' npm run generate" + }, + "dependencies": { + "axios": "^0.27.2", + "tslib": "^2.6.2" + } +} diff --git a/utils/nx-base/project.json b/utils/nx-base/project.json new file mode 100644 index 00000000..9cc63e06 --- /dev/null +++ b/utils/nx-base/project.json @@ -0,0 +1,59 @@ +{ + "name": "@redhat-cloud-services/CLIENTNAME-client", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "packages/CLIENTNAME", + "projectType": "library", + "targets": { + "build": { + "executor": "@redhat-cloud-services/build-utils:builder", + "options": { + "outputPath": "packages/CLIENTNAME/dist", + "main": "packages/CLIENTNAME/index.ts", + "esmTsConfig": "packages/CLIENTNAME/tsconfig.esm.json", + "cjsTsConfig": "packages/CLIENTNAME/tsconfig.cjs.json" + } + }, + "publish": { + "command": "node tools/scripts/publish.mjs @redhat-cloud-services/CLIENTNAME-client {args.ver} {args.tag}", + "dependsOn": ["build"] + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["packages/CLIENTNAME/**/*.ts", "packages/CLIENTNAME/package.json"] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], + "options": { + "jestConfig": "packages/CLIENTNAME/jest.config.ts" + } + }, + "version": { + "executor": "@jscutlery/semver:version", + "options": { + "push": true, + "preset": "conventionalcommits" + } + }, + "github": { + "executor": "@jscutlery/semver:github", + "options": { + "tag": "{tag}", + "notes": "{notes}" + } + }, + "npm": { + "executor": "ngx-deploy-npm:deploy", + "options": { + "access": "public" + } + }, + "syncDependencies": { + "executor": "@redhat-cloud-services/build-utils:sync-dependencies" + } + }, + "tags": [] +} diff --git a/utils/nx-base/tsconfig.cjs.json b/utils/nx-base/tsconfig.cjs.json new file mode 100644 index 00000000..d29a1ef4 --- /dev/null +++ b/utils/nx-base/tsconfig.cjs.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.esm.json", + "compilerOptions": { + "module": "CommonJS", + }, +} diff --git a/utils/nx-base/tsconfig.esm.json b/utils/nx-base/tsconfig.esm.json new file mode 100644 index 00000000..37a46ec9 --- /dev/null +++ b/utils/nx-base/tsconfig.esm.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": ["node"], + "module": "ES2015", + "target": "ES5", + "rootDir": "./", + }, + "include": ["*.ts"], + "exclude": ["jest.config.ts"] +} diff --git a/utils/nx-base/tsconfig.json b/utils/nx-base/tsconfig.json new file mode 100644 index 00000000..57cb4c05 --- /dev/null +++ b/utils/nx-base/tsconfig.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": false, + "noPropertyAccessFromIndexSignature": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + }, + "files": [], + "references": [ + { + "path": "./tsconfig.esm.json" + } + ] +}