From 18b6997db9058171222cded644942f906f081513 Mon Sep 17 00:00:00 2001 From: Ryan Richards Date: Thu, 6 Jun 2024 16:49:36 +0930 Subject: [PATCH 1/2] MO-322 adding check-types command to base monorepo targets as well as the service generator. changing the readme to inform users of library generator limitations --- README.md | 13 +++++++++++++ nx.json | 9 +++++++++ tools/serverless-plugin/project.json | 9 +++++++++ .../src/generators/service/generator.ts | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/README.md b/README.md index 484144aa..68cd0325 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,19 @@ Libraries are generated by `@nx/js` plugin. For more information, check out thei `npx nx g library ` +Shared library will need to have the `check-types` command added manually to ensure proper type checking. This is because the the `@nx/js` plugin does not add it by default. +```json +"check-types": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "color": true, + "command": "tsc --noEmit --pretty" + }, + "cache": true +} +``` + ### General Nx. commands Below are some example of general Nx. commands. For more information, check out their [document](https://nx.dev/packages/nx/documents). diff --git a/nx.json b/nx.json index 54c480ee..9c1d070f 100644 --- a/nx.json +++ b/nx.json @@ -20,6 +20,15 @@ "outputs": ["{projectRoot}/.serverless"], "cache": true }, + "check-types": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "color": true, + "command": "tsc --noEmit --pretty" + }, + "cache": true + }, "lint": { "inputs": [ "default", diff --git a/tools/serverless-plugin/project.json b/tools/serverless-plugin/project.json index 6425f67b..b5c2aed4 100644 --- a/tools/serverless-plugin/project.json +++ b/tools/serverless-plugin/project.json @@ -15,6 +15,15 @@ "generatePackageJson": true } }, + "check-types": { + "executor": "nx:run-commands", + "options": { + "cwd": "{projectRoot}", + "color": true, + "command": "tsc --noEmit --pretty" + }, + "cache": true + }, "lint": { "executor": "@nx/linter:eslint", "outputs": ["{options.outputFile}"], diff --git a/tools/serverless-plugin/src/generators/service/generator.ts b/tools/serverless-plugin/src/generators/service/generator.ts index b1c5d26d..12d26fc0 100644 --- a/tools/serverless-plugin/src/generators/service/generator.ts +++ b/tools/serverless-plugin/src/generators/service/generator.ts @@ -35,6 +35,14 @@ export async function serviceGenerator( remove: { ...buildRunCommandConfig(projectRoot, 'sls remove'), }, + 'check-types': { + 'executor': 'nx:run-commands', + 'options': { + 'cwd': '{projectRoot}', + 'color': true, + 'command': 'tsc --noEmit --pretty' + } + }, lint: { executor: '@nx/linter:eslint', outputs: ['{options.outputFile}'], From e6569a9fba9068784d1d29a9090c307f99c08507 Mon Sep 17 00:00:00 2001 From: Ryan Richards Date: Fri, 7 Jun 2024 09:56:51 +0930 Subject: [PATCH 2/2] MO-322 making requested changes. Removing caching from project since it is handled on nx.json level, and removing command details from nx.json --- README.md | 1 - nx.json | 6 ------ tools/serverless-plugin/project.json | 3 +-- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 68cd0325..8321d868 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,6 @@ Shared library will need to have the `check-types` command added manually to ens "color": true, "command": "tsc --noEmit --pretty" }, - "cache": true } ``` diff --git a/nx.json b/nx.json index 9c1d070f..dd4f1807 100644 --- a/nx.json +++ b/nx.json @@ -21,12 +21,6 @@ "cache": true }, "check-types": { - "executor": "nx:run-commands", - "options": { - "cwd": "{projectRoot}", - "color": true, - "command": "tsc --noEmit --pretty" - }, "cache": true }, "lint": { diff --git a/tools/serverless-plugin/project.json b/tools/serverless-plugin/project.json index b5c2aed4..9fd11566 100644 --- a/tools/serverless-plugin/project.json +++ b/tools/serverless-plugin/project.json @@ -21,8 +21,7 @@ "cwd": "{projectRoot}", "color": true, "command": "tsc --noEmit --pretty" - }, - "cache": true + } }, "lint": { "executor": "@nx/linter:eslint",