From 232063d554d953f35932bfd3f5ecdfab1a496cf2 Mon Sep 17 00:00:00 2001 From: Mike Brocchi Date: Fri, 24 May 2024 09:14:24 -0400 Subject: [PATCH] revert to tsc build and add lint rules to set cli dependencies --- .github/workflows/composite/verify/action.yml | 5 ++++ CONTRIBUTING.md | 14 +++++++++++ apps/cli/.eslintrc.json | 18 ++++++++++++++- apps/cli/package.json | 15 +++++++++--- apps/cli/project.json | 23 ++++++++++--------- apps/cli/src/hd-cli.js | 1 - apps/cli/src/main.ts | 3 +++ package.json | 4 +++- 8 files changed, 66 insertions(+), 17 deletions(-) delete mode 100644 apps/cli/src/hd-cli.js create mode 100644 apps/cli/src/main.ts diff --git a/.github/workflows/composite/verify/action.yml b/.github/workflows/composite/verify/action.yml index fd3181ed..1ef136f5 100644 --- a/.github/workflows/composite/verify/action.yml +++ b/.github/workflows/composite/verify/action.yml @@ -10,7 +10,12 @@ runs: registry-url: 'https://registry.npmjs.org' - run: npm install --force shell: bash + + - run: npm run lint:cli + shell: bash + - run: npm run build shell: bash + - run: npm run test shell: bash diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0e6ba9e..e412b1d8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,3 +18,17 @@ npx nx generate @nx/js:library --name=libs/[topic]/[command] --projectNameAndRoo ``` npx nx generate @nx/js:library --name=libs/[command] --projectNameAndRootFormat=as-provided --no-interactive ``` + +## Adding a library + +When adding a library to the monorepo, remember to update the CLI's lint rules to ignore the new library. + +path to the cli lint rules: apps/cli/.eslintrc.json + +## Lint Failures + +To fix lint failures run: + +``` +npm run lint:cli:fix +``` diff --git a/apps/cli/.eslintrc.json b/apps/cli/.eslintrc.json index fdc2e11c..c95699ef 100644 --- a/apps/cli/.eslintrc.json +++ b/apps/cli/.eslintrc.json @@ -18,7 +18,23 @@ "files": ["*.json"], "parser": "jsonc-eslint-parser", "rules": { - "@nx/dependency-checks": "error" + "@nx/dependency-checks": [ + "error", + { + "includeTransitiveDependencies": true, + "useLocalPathsForWorkspaceDependencies": true, + "ignoredDependencies": [ + "@herodevs/report-committers", + "@herodevs/report-diagnostics", + "@herodevs/tracker-init", + "@herodevs/tracker-run", + "@herodevs/nes-init", + "@herodevs/utility", + "@herodevs/core-types", + "@herodevs/tracker-shared" + ] + } + ] } } ] diff --git a/apps/cli/package.json b/apps/cli/package.json index 77c7d2bb..1dad2822 100644 --- a/apps/cli/package.json +++ b/apps/cli/package.json @@ -1,10 +1,19 @@ { "name": "@herodevs/cli", "version": "0.0.0", - "bin": "./hd-cli.js", + "bin": "./src/main.js", "dependencies": { - "tslib": "^2.3.0" + "tslib": "^2.3.0", + "yargs": "^17.7.2", + "get-json": "^1.0.1", + "date-fns": "^3.6.0", + "@inquirer/prompts": "^5.0.2", + "git-last-commit": "^1.0.1", + "sloc": "^0.3.2", + "@apollo/client": "^3.10.1", + "ora": "5.3.0" }, "type": "commonjs", - "main": "./hd-cli.js" + "main": "./src/main.js", + "typings": "./src/main.d.ts" } diff --git a/apps/cli/project.json b/apps/cli/project.json index 2a156100..42f20773 100644 --- a/apps/cli/project.json +++ b/apps/cli/project.json @@ -14,20 +14,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "executor": "@nx/js:tsc", + "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/apps/cli", - "main": "apps/cli/src/lib/cli.ts", + "main": "apps/cli/src/main.ts", "tsConfig": "apps/cli/tsconfig.lib.json", - "format": ["cjs"], - "generatePackageJson": true, - "assets": [ - { - "input": "apps/cli/src/", - "glob": "hd-cli.js", - "output": "/" - } - ] + "assets": ["apps/cli/*.md"], + "external": "none" + } + }, + "lint": { + "executor": "@nx/eslint:lint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/cli/**/*.{ts,tsx,js,jsx}", "apps/cli/package.json"] } }, "nx-release-publish": { diff --git a/apps/cli/src/hd-cli.js b/apps/cli/src/hd-cli.js deleted file mode 100644 index 41b681b7..00000000 --- a/apps/cli/src/hd-cli.js +++ /dev/null @@ -1 +0,0 @@ -require('./cli.cjs').cli(); diff --git a/apps/cli/src/main.ts b/apps/cli/src/main.ts new file mode 100644 index 00000000..3890ef7d --- /dev/null +++ b/apps/cli/src/main.ts @@ -0,0 +1,3 @@ +import { cli } from './lib/cli'; + +cli(); diff --git a/package.json b/package.json index 1495dcd9..8d4b6858 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "build": "nx run-many --target=build --all", "test": "nx run-many --target=test --all", "x": "nx affected:test --watch", - "lint": "nx run-many --target=lint --all" + "lint": "nx run-many --target=lint --all", + "lint:cli": "nx lint cli", + "lint:cli:fix": "nx lint cli --fix" }, "private": true, "dependencies": {