nx 17.0.3 → 17.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -4
- package/bin/init-local.js +10 -60
- package/bin/nx-cloud.js +6 -0
- package/bin/nx.js +1 -9
- package/bin/post-install.js +5 -1
- package/bin/run-executor.js +1 -1
- package/migrations.json +18 -0
- package/package.json +21 -18
- package/plugins/package-json.js +1 -1
- package/{changelog-renderer → release/changelog-renderer}/index.d.ts +18 -3
- package/{changelog-renderer → release/changelog-renderer}/index.js +78 -34
- package/release/index.d.ts +4 -0
- package/release/index.js +11 -0
- package/schemas/nx-schema.json +203 -19
- package/schemas/project-schema.json +20 -0
- package/src/adapter/angular-json.js +28 -18
- package/src/adapter/compat.d.ts +2 -2
- package/src/adapter/compat.js +6 -1
- package/src/adapter/ngcli-adapter.d.ts +16 -4
- package/src/adapter/ngcli-adapter.js +85 -28
- package/src/command-line/add/add.d.ts +2 -0
- package/src/command-line/add/add.js +169 -0
- package/src/command-line/add/command-object.d.ts +7 -0
- package/src/command-line/add/command-object.js +24 -0
- package/src/command-line/affected/affected.js +0 -3
- package/src/command-line/affected/command-object.d.ts +4 -4
- package/src/command-line/affected/command-object.js +53 -26
- package/src/command-line/affected/print-affected.js +10 -1
- package/src/command-line/connect/command-object.d.ts +1 -2
- package/src/command-line/connect/command-object.js +3 -7
- package/src/command-line/connect/connect-to-nx-cloud.d.ts +4 -5
- package/src/command-line/connect/connect-to-nx-cloud.js +43 -31
- package/src/command-line/connect/view-logs.js +5 -21
- package/src/command-line/examples.js +18 -0
- package/src/command-line/exec/command-object.js +2 -1
- package/src/command-line/exec/exec.d.ts +1 -1
- package/src/command-line/exec/exec.js +78 -35
- package/src/command-line/format/format.js +13 -4
- package/src/command-line/generate/generate.js +9 -9
- package/src/command-line/generate/generator-utils.d.ts +3 -2
- package/src/command-line/generate/generator-utils.js +5 -5
- package/src/command-line/graph/graph.d.ts +1 -1
- package/src/command-line/graph/graph.js +82 -37
- package/src/command-line/init/command-object.js +70 -43
- package/src/command-line/init/implementation/add-nx-to-monorepo.d.ts +4 -2
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +11 -2
- package/src/command-line/init/implementation/add-nx-to-nest.d.ts +1 -1
- package/src/command-line/init/implementation/add-nx-to-nest.js +9 -6
- package/src/command-line/init/implementation/add-nx-to-npm-repo.d.ts +4 -2
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +14 -4
- package/src/command-line/init/implementation/angular/index.js +4 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +10 -5
- package/src/command-line/init/implementation/angular/standalone-workspace.js +1 -1
- package/src/command-line/init/implementation/angular/types.d.ts +1 -1
- package/src/command-line/init/implementation/dot-nx/nxw.js +47 -16
- package/src/command-line/init/implementation/react/index.d.ts +1 -1
- package/src/command-line/init/implementation/react/index.js +4 -2
- package/src/command-line/init/implementation/react/rename-js-to-jsx.js +4 -2
- package/src/command-line/init/implementation/utils.d.ts +5 -5
- package/src/command-line/init/implementation/utils.js +46 -44
- package/src/command-line/init/{init.js → init-v1.js} +5 -13
- package/src/command-line/init/init-v2.d.ts +7 -0
- package/src/command-line/init/init-v2.js +201 -0
- package/src/command-line/list/list.js +6 -5
- package/src/command-line/migrate/command-object.js +19 -4
- package/src/command-line/migrate/migrate.js +21 -17
- package/src/command-line/new/new.js +1 -1
- package/src/command-line/nx-commands.js +4 -1
- package/src/command-line/release/changelog.d.ts +22 -1
- package/src/command-line/release/changelog.js +459 -257
- package/src/command-line/release/command-object.d.ts +29 -7
- package/src/command-line/release/command-object.js +120 -20
- package/src/command-line/release/config/config.d.ts +26 -21
- package/src/command-line/release/config/config.js +416 -59
- package/src/command-line/release/config/conventional-commits.d.ts +2 -0
- package/src/command-line/release/config/conventional-commits.js +98 -0
- package/src/command-line/release/config/filter-release-groups.d.ts +1 -2
- package/src/command-line/release/config/filter-release-groups.js +38 -1
- package/src/command-line/release/index.d.ts +16 -0
- package/src/command-line/release/index.js +23 -0
- package/src/command-line/release/publish.d.ts +7 -3
- package/src/command-line/release/publish.js +89 -37
- package/src/command-line/release/release.d.ts +4 -0
- package/src/command-line/release/release.js +176 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.d.ts +7 -0
- package/src/command-line/release/utils/batch-projects-by-generator-config.js +37 -0
- package/src/command-line/release/utils/exec-command.d.ts +1 -0
- package/src/command-line/release/utils/exec-command.js +34 -0
- package/src/command-line/release/utils/git.d.ts +34 -1
- package/src/command-line/release/utils/git.js +238 -34
- package/src/command-line/release/utils/github.d.ts +5 -5
- package/src/command-line/release/utils/github.js +155 -8
- package/src/command-line/release/utils/markdown.js +6 -1
- package/src/command-line/release/utils/print-changes.d.ts +1 -1
- package/src/command-line/release/utils/print-changes.js +3 -3
- package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -1
- package/src/command-line/release/utils/resolve-semver-specifier.d.ts +4 -0
- package/src/command-line/release/utils/resolve-semver-specifier.js +58 -0
- package/src/command-line/release/utils/semver.d.ts +8 -0
- package/src/command-line/release/utils/semver.js +30 -1
- package/src/command-line/release/utils/shared.d.ts +39 -0
- package/src/command-line/release/utils/shared.js +213 -0
- package/src/command-line/release/version.d.ts +37 -3
- package/src/command-line/release/version.js +312 -117
- package/src/command-line/repair/repair.js +13 -9
- package/src/command-line/report/report.d.ts +3 -0
- package/src/command-line/report/report.js +22 -5
- package/src/command-line/run/command-object.d.ts +4 -0
- package/src/command-line/run/command-object.js +18 -2
- package/src/command-line/run/executor-utils.d.ts +2 -1
- package/src/command-line/run/executor-utils.js +4 -4
- package/src/command-line/run/run-one.js +3 -6
- package/src/command-line/run/run.js +34 -9
- package/src/command-line/run-many/command-object.js +4 -1
- package/src/command-line/run-many/run-many.js +0 -3
- package/src/command-line/show/command-object.d.ts +3 -0
- package/src/command-line/show/command-object.js +29 -2
- package/src/command-line/show/show.js +9 -0
- package/src/command-line/yargs-utils/shared-options.d.ts +4 -1
- package/src/command-line/yargs-utils/shared-options.js +23 -9
- package/src/commands-runner/command-graph.d.ts +13 -0
- package/src/commands-runner/command-graph.js +2 -0
- package/src/commands-runner/create-command-graph.d.ts +4 -0
- package/src/commands-runner/create-command-graph.js +44 -0
- package/src/commands-runner/get-command-projects.d.ts +3 -0
- package/src/commands-runner/get-command-projects.js +19 -0
- package/src/config/nx-json.d.ts +160 -25
- package/src/config/project-graph.d.ts +3 -3
- package/src/config/workspace-json-project-json.d.ts +23 -1
- package/src/config/workspaces.d.ts +1 -1
- package/src/config/workspaces.js +4 -6
- package/src/core/graph/3rdpartylicenses.txt +144 -74
- package/src/core/graph/environment.js +1 -1
- package/src/core/graph/index.html +4 -6
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.css +3 -3
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/client/client.d.ts +5 -1
- package/src/daemon/client/client.js +27 -8
- package/src/daemon/client/{socket-messenger.d.ts → daemon-socket-messenger.d.ts} +1 -1
- package/src/daemon/client/{socket-messenger.js → daemon-socket-messenger.js} +3 -3
- package/src/daemon/daemon-project-graph-error.d.ts +8 -0
- package/src/daemon/daemon-project-graph-error.js +13 -0
- package/src/daemon/server/handle-hash-tasks.js +12 -2
- package/src/daemon/server/handle-request-project-graph.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.d.ts +14 -13
- package/src/daemon/server/project-graph-incremental-recomputation.js +98 -33
- package/src/daemon/server/shutdown-utils.js +2 -4
- package/src/daemon/server/watcher.js +0 -3
- package/src/daemon/socket-utils.d.ts +2 -1
- package/src/daemon/socket-utils.js +15 -4
- package/src/daemon/tmp-dir.d.ts +1 -0
- package/src/daemon/tmp-dir.js +4 -4
- package/src/devkit-exports.d.ts +2 -2
- package/src/devkit-exports.js +3 -2
- package/src/devkit-internals.d.ts +3 -0
- package/src/devkit-internals.js +7 -1
- package/src/executors/noop/schema.json +1 -1
- package/src/executors/run-commands/run-commands.impl.d.ts +10 -2
- package/src/executors/run-commands/run-commands.impl.js +152 -48
- package/src/executors/run-commands/schema.json +11 -1
- package/src/executors/run-script/run-script.impl.js +43 -11
- package/src/executors/utils/convert-nx-executor.js +1 -1
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +3 -1
- package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +4 -2
- package/src/generators/testing-utils/create-tree-with-empty-workspace.js +0 -6
- package/src/generators/tree.d.ts +1 -0
- package/src/generators/utils/glob.js +2 -2
- package/src/generators/utils/project-configuration.js +28 -9
- package/src/hasher/create-task-hasher.d.ts +4 -0
- package/src/hasher/create-task-hasher.js +16 -0
- package/src/hasher/hash-task.js +9 -3
- package/src/hasher/native-task-hasher-impl.d.ts +19 -0
- package/src/hasher/native-task-hasher-impl.js +37 -0
- package/src/hasher/node-task-hasher-impl.d.ts +49 -0
- package/src/hasher/node-task-hasher-impl.js +431 -0
- package/src/hasher/task-hasher.d.ts +33 -21
- package/src/hasher/task-hasher.js +30 -428
- package/src/migrations/update-15-0-0/migrate-to-inputs.js +5 -5
- package/src/migrations/update-15-1-0/set-project-names.js +2 -1
- package/src/migrations/update-15-8-2/update-nxw.js +2 -6
- package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +3 -3
- package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +49 -13
- package/src/migrations/update-17-2-0/move-default-base.d.ts +5 -0
- package/src/migrations/update-17-2-0/move-default-base.js +21 -0
- package/src/migrations/update-17-3-0/nx-release-path.d.ts +3 -0
- package/src/migrations/update-17-3-0/nx-release-path.js +48 -0
- package/src/migrations/update-17-3-0/update-nxw.d.ts +2 -0
- package/src/migrations/update-17-3-0/update-nxw.js +7 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +2 -0
- package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +9 -0
- package/src/native/index.d.ts +65 -15
- package/src/native/index.js +6 -2
- package/src/native/transform-objects.js +2 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.d.ts +1 -0
- package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +13 -12
- package/src/nx-cloud/generators/connect-to-nx-cloud/schema.json +6 -1
- package/src/nx-cloud/update-manager.js +2 -1
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/index.js +3 -3
- package/src/plugins/js/lock-file/lock-file.d.ts +2 -2
- package/src/plugins/js/lock-file/lock-file.js +15 -3
- package/src/plugins/js/package-json/create-package-json.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +1 -1
- package/src/plugins/js/utils/register.d.ts +1 -1
- package/src/plugins/js/utils/register.js +28 -8
- package/src/plugins/js/versions.d.ts +1 -1
- package/src/plugins/js/versions.js +1 -1
- package/{plugins/package-json-workspaces.d.ts → src/plugins/package-json-workspaces/create-nodes.d.ts} +4 -4
- package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js} +34 -12
- package/src/plugins/package-json-workspaces/index.d.ts +1 -0
- package/src/plugins/package-json-workspaces/index.js +4 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +47 -0
- package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -5
- package/src/plugins/project-json/build-nodes/project-json.js +6 -44
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +66 -0
- package/src/plugins/target-defaults/target-defaults-plugin.js +182 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/affected/locators/workspace-projects.d.ts +0 -2
- package/src/project-graph/affected/locators/workspace-projects.js +16 -29
- package/src/project-graph/build-project-graph.d.ts +20 -1
- package/src/project-graph/build-project-graph.js +91 -33
- package/src/project-graph/file-map-utils.d.ts +9 -5
- package/src/project-graph/file-map-utils.js +16 -63
- package/src/project-graph/file-utils.d.ts +1 -1
- package/src/project-graph/file-utils.js +44 -2
- package/src/project-graph/nx-deps-cache.js +1 -1
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph-builder.js +1 -1
- package/src/project-graph/project-graph.d.ts +32 -1
- package/src/project-graph/project-graph.js +147 -23
- package/src/project-graph/utils/build-all-workspace-files.d.ts +2 -0
- package/src/project-graph/utils/build-all-workspace-files.js +15 -0
- package/src/project-graph/utils/normalize-project-nodes.d.ts +2 -3
- package/src/project-graph/utils/normalize-project-nodes.js +7 -33
- package/src/project-graph/utils/project-configuration-utils.d.ts +66 -4
- package/src/project-graph/utils/project-configuration-utils.js +509 -62
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +12 -31
- package/src/project-graph/utils/retrieve-workspace-files.js +27 -90
- package/src/tasks-runner/batch/run-batch.js +3 -3
- package/src/tasks-runner/cache.js +6 -3
- package/src/tasks-runner/create-task-graph.js +1 -1
- package/src/tasks-runner/fork.d.ts +1 -0
- package/src/tasks-runner/fork.js +23 -0
- package/src/tasks-runner/forked-process-task-runner.d.ts +13 -5
- package/src/tasks-runner/forked-process-task-runner.js +112 -21
- package/src/tasks-runner/init-tasks-runner.js +1 -1
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +28 -28
- package/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +19 -22
- package/src/tasks-runner/life-cycles/empty-terminal-output-life-cycle.js +1 -3
- package/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +1 -3
- package/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +2 -4
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +1 -0
- package/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +11 -5
- package/src/tasks-runner/life-cycles/view-logs-utils.js +1 -1
- package/src/tasks-runner/pseudo-ipc.d.ts +49 -0
- package/src/tasks-runner/pseudo-ipc.js +140 -0
- package/src/tasks-runner/pseudo-terminal.d.ts +43 -0
- package/src/tasks-runner/pseudo-terminal.js +159 -0
- package/src/tasks-runner/run-command.d.ts +1 -1
- package/src/tasks-runner/run-command.js +13 -19
- package/src/tasks-runner/task-env.js +1 -2
- package/src/tasks-runner/task-graph-utils.d.ts +7 -3
- package/src/tasks-runner/task-graph-utils.js +15 -15
- package/src/tasks-runner/task-orchestrator.js +68 -12
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +16 -7
- package/src/tasks-runner/utils.js +30 -16
- package/src/utils/ab-testing.d.ts +36 -2
- package/src/utils/ab-testing.js +34 -16
- package/src/utils/assert-workspace-validity.js +1 -1
- package/src/utils/cache-directory.d.ts +1 -0
- package/src/utils/cache-directory.js +5 -1
- package/src/utils/child-process.d.ts +15 -1
- package/src/utils/child-process.js +91 -1
- package/src/utils/command-line-utils.js +2 -1
- package/src/utils/exit-codes.d.ts +6 -0
- package/src/utils/exit-codes.js +20 -0
- package/src/utils/fileutils.d.ts +1 -0
- package/src/utils/find-matching-projects.js +5 -5
- package/src/utils/find-workspace-root.js +1 -0
- package/src/utils/ignore.js +8 -1
- package/src/utils/json-diff.d.ts +1 -0
- package/src/utils/json-diff.js +2 -1
- package/src/utils/json.js +3 -1
- package/src/utils/logger.js +1 -1
- package/src/utils/nx-cloud-utils.d.ts +1 -1
- package/src/utils/nx-cloud-utils.js +9 -4
- package/src/utils/nx-plugin.d.ts +32 -15
- package/src/utils/nx-plugin.deprecated.d.ts +10 -5
- package/src/utils/nx-plugin.deprecated.js +23 -0
- package/src/utils/nx-plugin.js +71 -80
- package/src/utils/output.d.ts +4 -2
- package/src/utils/output.js +44 -9
- package/src/utils/package-json.d.ts +4 -4
- package/src/utils/package-json.js +18 -12
- package/src/utils/package-manager.d.ts +7 -0
- package/src/utils/package-manager.js +24 -4
- package/src/utils/params.d.ts +12 -4
- package/src/utils/params.js +37 -4
- package/src/utils/plugins/core-plugins.js +8 -0
- package/src/utils/plugins/installed-plugins.d.ts +2 -1
- package/src/utils/plugins/installed-plugins.js +2 -2
- package/src/utils/plugins/local-plugins.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +3 -2
- package/src/utils/plugins/plugin-capabilities.js +7 -7
- package/src/utils/typescript.js +1 -1
- package/src/utils/update-nxw.d.ts +2 -0
- package/src/utils/update-nxw.js +12 -0
- package/src/utils/workspace-configuration-check.js +1 -1
- package/src/utils/workspace-context.d.ts +6 -4
- package/src/utils/workspace-context.js +19 -9
- package/src/core/graph/polyfills.js +0 -1
- /package/src/command-line/init/{init.d.ts → init-v1.d.ts} +0 -0
|
@@ -3,11 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTsNodeCompilerOptions = exports.registerTsConfigPaths = exports.registerTranspiler = exports.getTranspiler = exports.getTsNodeTranspiler = exports.getSwcTranspiler = exports.registerTsProject = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const logger_1 = require("../../../utils/logger");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
8
6
|
const swcNodeInstalled = packageIsInstalled('@swc-node/register');
|
|
9
7
|
const tsNodeInstalled = packageIsInstalled('ts-node/register');
|
|
10
8
|
let ts;
|
|
9
|
+
let isTsEsmLoaderRegistered = false;
|
|
11
10
|
function registerTsProject(path, configFilename) {
|
|
12
11
|
const tsConfigPath = configFilename ? (0, path_1.join)(path, configFilename) : path;
|
|
13
12
|
const compilerOptions = readCompilerOptions(tsConfigPath);
|
|
@@ -15,6 +14,18 @@ function registerTsProject(path, configFilename) {
|
|
|
15
14
|
registerTsConfigPaths(tsConfigPath),
|
|
16
15
|
registerTranspiler(compilerOptions),
|
|
17
16
|
];
|
|
17
|
+
// Add ESM support for `.ts` files.
|
|
18
|
+
// NOTE: There is no cleanup function for this, as it's not possible to unregister the loader.
|
|
19
|
+
// Based on limited testing, it doesn't seem to matter if we register it multiple times, but just in
|
|
20
|
+
// case let's keep a flag to prevent it.
|
|
21
|
+
if (!isTsEsmLoaderRegistered) {
|
|
22
|
+
const module = require('node:module');
|
|
23
|
+
if (module.register && packageIsInstalled('ts-node/esm')) {
|
|
24
|
+
const url = require('node:url');
|
|
25
|
+
module.register(url.pathToFileURL(require.resolve('ts-node/esm')));
|
|
26
|
+
}
|
|
27
|
+
isTsEsmLoaderRegistered = true;
|
|
28
|
+
}
|
|
18
29
|
return () => {
|
|
19
30
|
for (const fn of cleanupFunctions) {
|
|
20
31
|
fn();
|
|
@@ -26,10 +37,6 @@ function getSwcTranspiler(compilerOptions) {
|
|
|
26
37
|
// These are requires to prevent it from registering when it shouldn't
|
|
27
38
|
const register = require('@swc-node/register/register')
|
|
28
39
|
.register;
|
|
29
|
-
let rootTsConfig = (0, path_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json');
|
|
30
|
-
if ((0, fs_1.existsSync)(rootTsConfig)) {
|
|
31
|
-
process.env.SWC_NODE_PROJECT = rootTsConfig;
|
|
32
|
-
}
|
|
33
40
|
const cleanupFn = register(compilerOptions);
|
|
34
41
|
return typeof cleanupFn === 'function' ? cleanupFn : () => { };
|
|
35
42
|
}
|
|
@@ -40,6 +47,8 @@ function getTsNodeTranspiler(compilerOptions) {
|
|
|
40
47
|
const service = register({
|
|
41
48
|
transpileOnly: true,
|
|
42
49
|
compilerOptions: getTsNodeCompilerOptions(compilerOptions),
|
|
50
|
+
// we already read and provide the compiler options, so prevent ts-node from reading them again
|
|
51
|
+
skipProject: true,
|
|
43
52
|
});
|
|
44
53
|
const { transpiler, swc } = service.options;
|
|
45
54
|
// Don't warn if a faster transpiler is enabled
|
|
@@ -58,6 +67,9 @@ function getTranspiler(compilerOptions) {
|
|
|
58
67
|
}
|
|
59
68
|
compilerOptions.lib = ['es2021'];
|
|
60
69
|
compilerOptions.module = ts.ModuleKind.CommonJS;
|
|
70
|
+
// use NodeJs module resolution until support for TS 4.x is dropped and then
|
|
71
|
+
// we can switch to Node10
|
|
72
|
+
compilerOptions.moduleResolution = ts.ModuleResolutionKind.NodeJs;
|
|
61
73
|
compilerOptions.target = ts.ScriptTarget.ES2021;
|
|
62
74
|
compilerOptions.inlineSourceMap = true;
|
|
63
75
|
compilerOptions.skipLibCheck = true;
|
|
@@ -121,13 +133,21 @@ exports.registerTsConfigPaths = registerTsConfigPaths;
|
|
|
121
133
|
function readCompilerOptions(tsConfigPath) {
|
|
122
134
|
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
|
|
123
135
|
if (swcNodeInstalled && !preferTsNode) {
|
|
124
|
-
|
|
125
|
-
return readDefaultTsConfig(tsConfigPath);
|
|
136
|
+
return readCompilerOptionsWithSwc(tsConfigPath);
|
|
126
137
|
}
|
|
127
138
|
else {
|
|
128
139
|
return readCompilerOptionsWithTypescript(tsConfigPath);
|
|
129
140
|
}
|
|
130
141
|
}
|
|
142
|
+
function readCompilerOptionsWithSwc(tsConfigPath) {
|
|
143
|
+
const { readDefaultTsConfig, } = require('@swc-node/register/read-default-tsconfig');
|
|
144
|
+
const compilerOptions = readDefaultTsConfig(tsConfigPath);
|
|
145
|
+
// This is returned in compiler options for some reason, but not part of the typings.
|
|
146
|
+
// @swc-node/register filters the files to transpile based on it, but it can be limiting when processing
|
|
147
|
+
// files not part of the received tsconfig included files (e.g. shared helpers, or config files not in source, etc.).
|
|
148
|
+
delete compilerOptions.files;
|
|
149
|
+
return compilerOptions;
|
|
150
|
+
}
|
|
131
151
|
function readCompilerOptionsWithTypescript(tsConfigPath) {
|
|
132
152
|
if (!ts) {
|
|
133
153
|
ts = require('typescript');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const typescriptVersion = "~5.
|
|
1
|
+
export declare const typescriptVersion = "~5.4.2";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NxJsonConfiguration } from '
|
|
2
|
-
import { ProjectConfiguration } from '
|
|
3
|
-
import { NxPluginV2 } from '
|
|
4
|
-
import { PackageJson } from '
|
|
1
|
+
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
2
|
+
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
|
3
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
|
4
|
+
import { PackageJson } from '../../utils/package-json';
|
|
5
5
|
export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
|
|
6
6
|
export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
|
|
7
7
|
projects: {
|
package/{plugins/package-json-workspaces.js → src/plugins/package-json-workspaces/create-nodes.js}
RENAMED
|
@@ -1,32 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
4
5
|
const node_fs_1 = require("node:fs");
|
|
5
6
|
const node_path_1 = require("node:path");
|
|
6
|
-
const nx_json_1 = require("
|
|
7
|
-
const workspaces_1 = require("
|
|
8
|
-
const fileutils_1 = require("
|
|
9
|
-
const globs_1 = require("
|
|
10
|
-
const logger_1 = require("
|
|
11
|
-
const output_1 = require("
|
|
12
|
-
const package_json_1 = require("
|
|
13
|
-
const path_1 = require("
|
|
7
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
8
|
+
const workspaces_1 = require("../../config/workspaces");
|
|
9
|
+
const fileutils_1 = require("../../utils/fileutils");
|
|
10
|
+
const globs_1 = require("../../utils/globs");
|
|
11
|
+
const logger_1 = require("../../utils/logger");
|
|
12
|
+
const output_1 = require("../../utils/output");
|
|
13
|
+
const package_json_1 = require("../../utils/package-json");
|
|
14
|
+
const path_1 = require("../../utils/path");
|
|
14
15
|
function getNxPackageJsonWorkspacesPlugin(root) {
|
|
15
16
|
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
|
|
17
|
+
const patterns = getGlobPatternsFromPackageManagerWorkspaces(root, readJson);
|
|
18
|
+
// If the user only specified a negative pattern, we should find all package.json
|
|
19
|
+
// files and only return those that don't match a negative pattern.
|
|
20
|
+
const negativePatterns = patterns.filter((p) => p.startsWith('!'));
|
|
21
|
+
let positivePatterns = patterns.filter((p) => !p.startsWith('!'));
|
|
22
|
+
if (
|
|
23
|
+
// There are some negative patterns
|
|
24
|
+
negativePatterns.length > 0 &&
|
|
25
|
+
// No positive patterns
|
|
26
|
+
(positivePatterns.length === 0 ||
|
|
27
|
+
// Or only a single positive pattern that is the default coming from root package
|
|
28
|
+
(positivePatterns.length === 1 && positivePatterns[0] === 'package.json'))) {
|
|
29
|
+
positivePatterns.push('**/package.json');
|
|
30
|
+
}
|
|
16
31
|
return {
|
|
17
|
-
name: 'nx
|
|
32
|
+
name: 'nx/core/package-json-workspaces',
|
|
18
33
|
createNodes: [
|
|
19
|
-
(0, globs_1.combineGlobPatterns)(
|
|
20
|
-
(p) =>
|
|
34
|
+
(0, globs_1.combineGlobPatterns)(positivePatterns),
|
|
35
|
+
(p) => {
|
|
36
|
+
if (!negativePatterns.some((negative) => (0, minimatch_1.minimatch)(p, negative))) {
|
|
37
|
+
return createNodeFromPackageJson(p, root);
|
|
38
|
+
}
|
|
39
|
+
// A negative pattern matched, so we should not create a node for this package.json
|
|
40
|
+
return {};
|
|
41
|
+
},
|
|
21
42
|
],
|
|
22
43
|
};
|
|
23
44
|
}
|
|
24
45
|
exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
|
|
25
46
|
function createNodeFromPackageJson(pkgJsonPath, root) {
|
|
26
47
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
|
|
48
|
+
const project = buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root));
|
|
27
49
|
return {
|
|
28
50
|
projects: {
|
|
29
|
-
[
|
|
51
|
+
[project.root]: project,
|
|
30
52
|
},
|
|
31
53
|
};
|
|
32
54
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-nodes';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PackageJsonProjectsNextToProjectJsonPlugin = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const fileutils_1 = require("../../../utils/fileutils");
|
|
7
|
+
const package_json_1 = require("../../../utils/package-json");
|
|
8
|
+
// TODO: Remove this one day, this should not need to be done.
|
|
9
|
+
exports.PackageJsonProjectsNextToProjectJsonPlugin = {
|
|
10
|
+
// Its not a problem if plugins happen to have same name, and this
|
|
11
|
+
// will look least confusing in the source map.
|
|
12
|
+
name: 'nx/core/package-json',
|
|
13
|
+
createNodes: [
|
|
14
|
+
'{project.json,**/project.json}',
|
|
15
|
+
(file, _, { workspaceRoot }) => {
|
|
16
|
+
const project = createProjectFromPackageJsonNextToProjectJson(file, workspaceRoot);
|
|
17
|
+
return project
|
|
18
|
+
? {
|
|
19
|
+
projects: {
|
|
20
|
+
[project.name]: project,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
: {};
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
|
|
28
|
+
const root = (0, path_1.dirname)(projectJsonPath);
|
|
29
|
+
const packageJsonPath = (0, path_1.join)(workspaceRoot, root, 'package.json');
|
|
30
|
+
if (!(0, fs_1.existsSync)(packageJsonPath)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
35
|
+
let { nx, name } = packageJson;
|
|
36
|
+
return {
|
|
37
|
+
...nx,
|
|
38
|
+
name,
|
|
39
|
+
root,
|
|
40
|
+
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
console.log(e);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { ProjectConfiguration
|
|
1
|
+
import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
|
|
2
2
|
import { NxPluginV2 } from '../../../utils/nx-plugin';
|
|
3
|
-
|
|
4
|
-
export declare const CreateProjectJsonProjectsPlugin: NxPluginV2;
|
|
3
|
+
export declare const ProjectJsonProjectsPlugin: NxPluginV2;
|
|
5
4
|
export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
|
|
6
|
-
export declare function mergePackageJsonConfigurationWithProjectJson(p: ProjectConfiguration, root: string): void;
|
|
7
|
-
export declare function mergeNpmScriptsWithTargets(packageJson: PackageJson, targets: Record<string, TargetConfiguration>): Record<string, TargetConfiguration>;
|
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.buildProjectFromProjectJson = exports.ProjectJsonProjectsPlugin = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
-
const node_fs_1 = require("node:fs");
|
|
6
5
|
const workspaces_1 = require("../../../config/workspaces");
|
|
7
6
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
name: 'nx-core-build-project-json-nodes',
|
|
7
|
+
exports.ProjectJsonProjectsPlugin = {
|
|
8
|
+
name: 'nx/core/project-json',
|
|
11
9
|
createNodes: [
|
|
12
10
|
'{project.json,**/project.json}',
|
|
13
|
-
(file, _,
|
|
14
|
-
const
|
|
15
|
-
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, file));
|
|
11
|
+
(file, _, { workspaceRoot }) => {
|
|
12
|
+
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, file));
|
|
16
13
|
const project = buildProjectFromProjectJson(json, file);
|
|
17
|
-
mergePackageJsonConfigurationWithProjectJson(project, root);
|
|
18
14
|
return {
|
|
19
15
|
projects: {
|
|
20
|
-
[project.
|
|
16
|
+
[project.root]: project,
|
|
21
17
|
},
|
|
22
18
|
};
|
|
23
19
|
},
|
|
@@ -31,37 +27,3 @@ function buildProjectFromProjectJson(json, path) {
|
|
|
31
27
|
};
|
|
32
28
|
}
|
|
33
29
|
exports.buildProjectFromProjectJson = buildProjectFromProjectJson;
|
|
34
|
-
function mergePackageJsonConfigurationWithProjectJson(p, root) {
|
|
35
|
-
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, p.root, 'package.json'))) {
|
|
36
|
-
try {
|
|
37
|
-
const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, p.root, 'package.json'));
|
|
38
|
-
p.targets = mergeNpmScriptsWithTargets(packageJson, p.targets);
|
|
39
|
-
const { nx } = packageJson;
|
|
40
|
-
if (nx?.tags) {
|
|
41
|
-
p.tags = [...(p.tags || []), ...nx.tags];
|
|
42
|
-
}
|
|
43
|
-
if (nx?.implicitDependencies) {
|
|
44
|
-
p.implicitDependencies = [
|
|
45
|
-
...(p.implicitDependencies || []),
|
|
46
|
-
...nx.implicitDependencies,
|
|
47
|
-
];
|
|
48
|
-
}
|
|
49
|
-
if (nx?.namedInputs) {
|
|
50
|
-
p.namedInputs = { ...(p.namedInputs || {}), ...nx.namedInputs };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
// ignore json parser errors
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.mergePackageJsonConfigurationWithProjectJson = mergePackageJsonConfigurationWithProjectJson;
|
|
59
|
-
function mergeNpmScriptsWithTargets(packageJson, targets) {
|
|
60
|
-
try {
|
|
61
|
-
return { ...(0, package_json_1.readTargetsFromPackageJson)(packageJson), ...(targets || {}) };
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
return targets;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.mergeNpmScriptsWithTargets = mergeNpmScriptsWithTargets;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TargetConfiguration } from '../../config/workspace-json-project-json';
|
|
2
|
+
import { NxPluginV2 } from '../../utils/nx-plugin';
|
|
3
|
+
/**
|
|
4
|
+
* This marks that a target provides information which should modify a target already registered
|
|
5
|
+
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
|
6
|
+
* the information provided by it will be discarded.
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
9
|
+
* between the plugin-worker and the main process.
|
|
10
|
+
*/
|
|
11
|
+
export declare const ONLY_MODIFIES_EXISTING_TARGET = "NX_ONLY_MODIFIES_EXISTING_TARGET";
|
|
12
|
+
/**
|
|
13
|
+
* This is used to override the source file for the target defaults plugin.
|
|
14
|
+
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
17
|
+
* between the plugin-worker and the main process.
|
|
18
|
+
*/
|
|
19
|
+
export declare const OVERRIDE_SOURCE_FILE = "NX_OVERRIDE_SOURCE_FILE";
|
|
20
|
+
export declare const TargetDefaultsPlugin: NxPluginV2;
|
|
21
|
+
/**
|
|
22
|
+
* This fn gets target info that would make a target uniquely compatible
|
|
23
|
+
* with what is described by project.json or package.json. As the merge process
|
|
24
|
+
* for config happens, without this, the target defaults may be compatible
|
|
25
|
+
* with a config from a plugin and then that combined target be incompatible
|
|
26
|
+
* with the project json configuration resulting in the target default values
|
|
27
|
+
* being scrapped. By adding enough information from the project.json / package.json,
|
|
28
|
+
* we can make sure that the target after merging is compatible with the defined target.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getTargetInfo(target: string, projectJsonTargets: Record<string, TargetConfiguration>, packageJsonTargets: Record<string, TargetConfiguration>): {
|
|
31
|
+
command: string;
|
|
32
|
+
executor?: undefined;
|
|
33
|
+
options?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
executor: string;
|
|
36
|
+
options: {
|
|
37
|
+
command: any;
|
|
38
|
+
commands?: undefined;
|
|
39
|
+
script?: undefined;
|
|
40
|
+
};
|
|
41
|
+
command?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
executor: string;
|
|
44
|
+
options: {
|
|
45
|
+
commands: any;
|
|
46
|
+
command?: undefined;
|
|
47
|
+
script?: undefined;
|
|
48
|
+
};
|
|
49
|
+
command?: undefined;
|
|
50
|
+
} | {
|
|
51
|
+
executor: string;
|
|
52
|
+
command?: undefined;
|
|
53
|
+
options?: undefined;
|
|
54
|
+
} | {
|
|
55
|
+
executor: string;
|
|
56
|
+
options: {
|
|
57
|
+
script: any;
|
|
58
|
+
command?: undefined;
|
|
59
|
+
commands?: undefined;
|
|
60
|
+
};
|
|
61
|
+
command?: undefined;
|
|
62
|
+
} | {
|
|
63
|
+
command?: undefined;
|
|
64
|
+
executor?: undefined;
|
|
65
|
+
options?: undefined;
|
|
66
|
+
};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTargetInfo = exports.TargetDefaultsPlugin = exports.OVERRIDE_SOURCE_FILE = exports.ONLY_MODIFIES_EXISTING_TARGET = void 0;
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const fileutils_1 = require("../../utils/fileutils");
|
|
8
|
+
const globs_1 = require("../../utils/globs");
|
|
9
|
+
const package_json_1 = require("../../utils/package-json");
|
|
10
|
+
const package_json_workspaces_1 = require("../package-json-workspaces");
|
|
11
|
+
/**
|
|
12
|
+
* This marks that a target provides information which should modify a target already registered
|
|
13
|
+
* on the project via other plugins. If the target has not already been registered, and this symbol is true,
|
|
14
|
+
* the information provided by it will be discarded.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
17
|
+
* between the plugin-worker and the main process.
|
|
18
|
+
*/
|
|
19
|
+
exports.ONLY_MODIFIES_EXISTING_TARGET = 'NX_ONLY_MODIFIES_EXISTING_TARGET';
|
|
20
|
+
/**
|
|
21
|
+
* This is used to override the source file for the target defaults plugin.
|
|
22
|
+
* This allows the plugin to use the project files as the context, but point to nx.json as the source file.
|
|
23
|
+
*
|
|
24
|
+
* NOTE: This cannot be a symbol, as they are not serialized in JSON the communication
|
|
25
|
+
* between the plugin-worker and the main process.
|
|
26
|
+
*/
|
|
27
|
+
exports.OVERRIDE_SOURCE_FILE = 'NX_OVERRIDE_SOURCE_FILE';
|
|
28
|
+
exports.TargetDefaultsPlugin = {
|
|
29
|
+
name: 'nx/core/target-defaults',
|
|
30
|
+
createNodes: [
|
|
31
|
+
'{package.json,**/package.json,project.json,**/project.json}',
|
|
32
|
+
(configFile, _, ctx) => {
|
|
33
|
+
const fileName = (0, node_path_1.basename)(configFile);
|
|
34
|
+
const root = (0, node_path_1.dirname)(configFile);
|
|
35
|
+
const packageManagerWorkspacesGlob = (0, globs_1.combineGlobPatterns)((0, package_json_workspaces_1.getGlobPatternsFromPackageManagerWorkspaces)(ctx.workspaceRoot));
|
|
36
|
+
// Only process once if package.json + project.json both exist
|
|
37
|
+
if (fileName === 'package.json' &&
|
|
38
|
+
(0, node_fs_1.existsSync)((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'))) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
else if (fileName === 'package.json' &&
|
|
42
|
+
!(0, minimatch_1.minimatch)(configFile, packageManagerWorkspacesGlob)) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
// If no target defaults, this does nothing
|
|
46
|
+
const targetDefaults = ctx.nxJsonConfiguration?.targetDefaults;
|
|
47
|
+
if (!targetDefaults) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
const projectJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'project.json'));
|
|
51
|
+
const packageJson = readJsonOrNull((0, node_path_1.join)(ctx.workspaceRoot, root, 'package.json'));
|
|
52
|
+
const packageJsonTargets = (0, package_json_1.readTargetsFromPackageJson)(packageJson);
|
|
53
|
+
const projectDefinedTargets = new Set([
|
|
54
|
+
...Object.keys(projectJson?.targets ?? {}),
|
|
55
|
+
...(packageJson ? Object.keys(packageJsonTargets) : []),
|
|
56
|
+
]);
|
|
57
|
+
const executorToTargetMap = getExecutorToTargetMap(packageJsonTargets, projectJson?.targets);
|
|
58
|
+
const modifiedTargets = {};
|
|
59
|
+
for (const defaultSpecifier in targetDefaults) {
|
|
60
|
+
const targetNames = executorToTargetMap.get(defaultSpecifier) ?? new Set();
|
|
61
|
+
targetNames.add(defaultSpecifier);
|
|
62
|
+
for (const targetName of targetNames) {
|
|
63
|
+
// Prevents `build` from overwriting `@nx/js:tsc` if both are present
|
|
64
|
+
// and build is specified later in the ordering.
|
|
65
|
+
if (!modifiedTargets[targetName] || targetName !== defaultSpecifier) {
|
|
66
|
+
const defaults = JSON.parse(JSON.stringify(targetDefaults[defaultSpecifier]));
|
|
67
|
+
modifiedTargets[targetName] = {
|
|
68
|
+
...getTargetInfo(targetName, projectJson?.targets, packageJsonTargets),
|
|
69
|
+
...defaults,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// TODO: Remove this after we figure out a way to define new targets
|
|
73
|
+
// in target defaults
|
|
74
|
+
if (!projectDefinedTargets.has(targetName)) {
|
|
75
|
+
modifiedTargets[targetName][exports.ONLY_MODIFIES_EXISTING_TARGET] = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
projects: {
|
|
81
|
+
[root]: {
|
|
82
|
+
targets: modifiedTargets,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
[exports.OVERRIDE_SOURCE_FILE]: 'nx.json',
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
};
|
|
90
|
+
function getExecutorToTargetMap(packageJsonTargets, projectJsonTargets) {
|
|
91
|
+
const executorToTargetMap = new Map();
|
|
92
|
+
const targets = Object.keys({
|
|
93
|
+
...projectJsonTargets,
|
|
94
|
+
...packageJsonTargets,
|
|
95
|
+
});
|
|
96
|
+
for (const target of targets) {
|
|
97
|
+
const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
|
|
98
|
+
const targetsForExecutor = executorToTargetMap.get(executor) ?? new Set();
|
|
99
|
+
targetsForExecutor.add(target);
|
|
100
|
+
executorToTargetMap.set(executor, targetsForExecutor);
|
|
101
|
+
}
|
|
102
|
+
return executorToTargetMap;
|
|
103
|
+
}
|
|
104
|
+
function readJsonOrNull(path) {
|
|
105
|
+
if ((0, node_fs_1.existsSync)(path)) {
|
|
106
|
+
return (0, fileutils_1.readJsonFile)(path);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* This fn gets target info that would make a target uniquely compatible
|
|
114
|
+
* with what is described by project.json or package.json. As the merge process
|
|
115
|
+
* for config happens, without this, the target defaults may be compatible
|
|
116
|
+
* with a config from a plugin and then that combined target be incompatible
|
|
117
|
+
* with the project json configuration resulting in the target default values
|
|
118
|
+
* being scrapped. By adding enough information from the project.json / package.json,
|
|
119
|
+
* we can make sure that the target after merging is compatible with the defined target.
|
|
120
|
+
*/
|
|
121
|
+
function getTargetInfo(target, projectJsonTargets, packageJsonTargets) {
|
|
122
|
+
const projectJsonTarget = projectJsonTargets?.[target];
|
|
123
|
+
const packageJsonTarget = packageJsonTargets?.[target];
|
|
124
|
+
const executor = getTargetExecutor(target, projectJsonTargets, packageJsonTargets);
|
|
125
|
+
const targetOptions = {
|
|
126
|
+
...packageJsonTarget?.options,
|
|
127
|
+
...projectJsonTarget?.options,
|
|
128
|
+
};
|
|
129
|
+
if (projectJsonTarget?.command) {
|
|
130
|
+
return {
|
|
131
|
+
command: projectJsonTarget?.command,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
if (executor === 'nx:run-commands') {
|
|
135
|
+
if (targetOptions?.command) {
|
|
136
|
+
return {
|
|
137
|
+
executor: 'nx:run-commands',
|
|
138
|
+
options: {
|
|
139
|
+
command: targetOptions?.command,
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
else if (targetOptions?.commands) {
|
|
144
|
+
return {
|
|
145
|
+
executor: 'nx:run-commands',
|
|
146
|
+
options: {
|
|
147
|
+
commands: targetOptions.commands,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
executor: 'nx:run-commands',
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (executor === 'nx:run-script') {
|
|
156
|
+
return {
|
|
157
|
+
executor: 'nx:run-script',
|
|
158
|
+
options: {
|
|
159
|
+
script: targetOptions?.script ?? target,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (executor) {
|
|
164
|
+
return { executor };
|
|
165
|
+
}
|
|
166
|
+
return {};
|
|
167
|
+
}
|
|
168
|
+
exports.getTargetInfo = getTargetInfo;
|
|
169
|
+
function getTargetExecutor(target, projectJsonTargets, packageJsonTargets) {
|
|
170
|
+
const projectJsonTargetConfiguration = projectJsonTargets?.[target];
|
|
171
|
+
const packageJsonTargetConfiguration = packageJsonTargets?.[target];
|
|
172
|
+
if (!projectJsonTargetConfiguration && packageJsonTargetConfiguration) {
|
|
173
|
+
return packageJsonTargetConfiguration?.executor;
|
|
174
|
+
}
|
|
175
|
+
if (projectJsonTargetConfiguration?.executor) {
|
|
176
|
+
return projectJsonTargetConfiguration.executor;
|
|
177
|
+
}
|
|
178
|
+
if (projectJsonTargetConfiguration?.command) {
|
|
179
|
+
return 'nx:run-commands';
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTouchedProjectsFromProjectGlobChanges = void 0;
|
|
4
|
-
const
|
|
4
|
+
const minimatch_1 = require("minimatch");
|
|
5
5
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
6
6
|
const installation_directory_1 = require("../../../utils/installation-directory");
|
|
7
7
|
const path_1 = require("path");
|
|
@@ -10,10 +10,10 @@ const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files
|
|
|
10
10
|
const nx_plugin_1 = require("../../../utils/nx-plugin");
|
|
11
11
|
const globs_1 = require("../../../utils/globs");
|
|
12
12
|
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes, nxJson) => {
|
|
13
|
-
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(
|
|
13
|
+
const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot)));
|
|
14
14
|
const touchedProjects = new Set();
|
|
15
15
|
for (const touchedFile of touchedFiles) {
|
|
16
|
-
const isProjectFile = minimatch(touchedFile.file, globPattern, {
|
|
16
|
+
const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
|
|
17
17
|
dot: true,
|
|
18
18
|
});
|
|
19
19
|
if (isProjectFile) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { TouchedProjectLocator } from '../affected-project-graph-models';
|
|
2
|
-
import { NxJsonConfiguration } from '../../../config/nx-json';
|
|
3
2
|
export declare const getTouchedProjects: TouchedProjectLocator;
|
|
4
3
|
export declare const getImplicitlyTouchedProjects: TouchedProjectLocator;
|
|
5
|
-
export declare function extractGlobalFilesFromInputs(nxJson: NxJsonConfiguration): any[];
|