Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial create-client functionality #224

Merged
merged 3 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/lint/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-unit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
"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",
"release:bot": "node config/release.js",
"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/*"
Expand Down
11 changes: 11 additions & 0 deletions utils/create-client.sh
Original file line number Diff line number Diff line change
@@ -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
35 changes: 35 additions & 0 deletions utils/nx-base/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
}
4 changes: 4 additions & 0 deletions utils/nx-base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist
1 change: 1 addition & 0 deletions utils/nx-base/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
10 changes: 10 additions & 0 deletions utils/nx-base/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable */
export default {
displayName: 'CLIENTNAME-client',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/packages/CLIENTNAME',
};
30 changes: 30 additions & 0 deletions utils/nx-base/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
59 changes: 59 additions & 0 deletions utils/nx-base/project.json
Original file line number Diff line number Diff line change
@@ -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": []
}
6 changes: 6 additions & 0 deletions utils/nx-base/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.esm.json",
"compilerOptions": {
"module": "CommonJS",
},
}
13 changes: 13 additions & 0 deletions utils/nx-base/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -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"]
}
18 changes: 18 additions & 0 deletions utils/nx-base/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Loading