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
package/src/utils/nx-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unregisterPluginTSTranspiler = exports.registerPluginTSTranspiler = exports.resolveLocalNxPlugin = exports.readPluginPackageJson = exports.isNxPluginV1 = exports.isNxPluginV2 = exports.
|
|
3
|
+
exports.getDefaultPlugins = exports.unregisterPluginTSTranspiler = exports.registerPluginTSTranspiler = exports.resolveLocalNxPlugin = exports.readPluginPackageJson = exports.isNxPluginV1 = exports.isNxPluginV2 = exports.ensurePluginIsV2 = exports.loadNxPlugins = exports.loadNxPluginAsync = exports.getPluginPathAndName = exports.nxPluginCache = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -15,18 +15,21 @@ const path_1 = require("./path");
|
|
|
15
15
|
const path_2 = require("path");
|
|
16
16
|
const installation_directory_1 = require("./installation-directory");
|
|
17
17
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
|
18
|
-
const
|
|
18
|
+
const nx_json_1 = require("../config/nx-json");
|
|
19
19
|
const globs_1 = require("./globs");
|
|
20
20
|
const angular_json_1 = require("../adapter/angular-json");
|
|
21
|
-
const package_json_workspaces_1 = require("
|
|
21
|
+
const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
|
|
22
22
|
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
|
23
|
+
const package_json_next_to_project_json_1 = require("../plugins/project-json/build-nodes/package-json-next-to-project-json");
|
|
24
|
+
const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
|
|
25
|
+
const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
|
|
23
26
|
tslib_1.__exportStar(require("./nx-plugin.deprecated"), exports);
|
|
24
27
|
// Short lived cache (cleared between cmd runs)
|
|
25
28
|
// holding resolved nx plugin objects.
|
|
26
29
|
// Allows loadNxPlugins to be called multiple times w/o
|
|
27
30
|
// executing resolution mulitple times.
|
|
28
|
-
|
|
29
|
-
function getPluginPathAndName(moduleName, paths, root) {
|
|
31
|
+
exports.nxPluginCache = new Map();
|
|
32
|
+
function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
30
33
|
let pluginPath;
|
|
31
34
|
try {
|
|
32
35
|
pluginPath = require.resolve(moduleName, {
|
|
@@ -35,7 +38,7 @@ function getPluginPathAndName(moduleName, paths, root) {
|
|
|
35
38
|
}
|
|
36
39
|
catch (e) {
|
|
37
40
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
38
|
-
const plugin = resolveLocalNxPlugin(moduleName, root);
|
|
41
|
+
const plugin = resolveLocalNxPlugin(moduleName, (0, nx_json_1.readNxJson)(root), projects, root);
|
|
39
42
|
if (plugin) {
|
|
40
43
|
const main = readPluginMainFromProjectConfiguration(plugin.projectConfig);
|
|
41
44
|
pluginPath = main ? path.join(root, main) : plugin.path;
|
|
@@ -62,75 +65,63 @@ function getPluginPathAndName(moduleName, paths, root) {
|
|
|
62
65
|
: { name: moduleName };
|
|
63
66
|
return { pluginPath, name };
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
exports.getPluginPathAndName = getPluginPathAndName;
|
|
69
|
+
async function loadNxPluginAsync(pluginConfiguration, paths, projects, root) {
|
|
66
70
|
const { plugin: moduleName, options } = typeof pluginConfiguration === 'object'
|
|
67
71
|
? pluginConfiguration
|
|
68
72
|
: { plugin: pluginConfiguration, options: undefined };
|
|
69
|
-
let pluginModule = nxPluginCache.get(moduleName);
|
|
73
|
+
let pluginModule = exports.nxPluginCache.get(moduleName);
|
|
74
|
+
const include = typeof pluginConfiguration === 'object'
|
|
75
|
+
? pluginConfiguration.include
|
|
76
|
+
: undefined;
|
|
77
|
+
const exclude = typeof pluginConfiguration === 'object'
|
|
78
|
+
? pluginConfiguration.exclude
|
|
79
|
+
: undefined;
|
|
70
80
|
if (pluginModule) {
|
|
71
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
plugin: pluginModule,
|
|
83
|
+
options,
|
|
84
|
+
include,
|
|
85
|
+
exclude,
|
|
86
|
+
};
|
|
72
87
|
}
|
|
73
|
-
|
|
88
|
+
performance.mark(`Load Nx Plugin: ${moduleName} - start`);
|
|
89
|
+
let { pluginPath, name } = await getPluginPathAndName(moduleName, paths, projects, root);
|
|
74
90
|
const plugin = ensurePluginIsV2((await Promise.resolve(`${pluginPath}`).then(s => require(s))));
|
|
75
91
|
plugin.name ??= name;
|
|
76
|
-
nxPluginCache.set(moduleName, plugin);
|
|
77
|
-
|
|
92
|
+
exports.nxPluginCache.set(moduleName, plugin);
|
|
93
|
+
performance.mark(`Load Nx Plugin: ${moduleName} - end`);
|
|
94
|
+
performance.measure(`Load Nx Plugin: ${moduleName}`, `Load Nx Plugin: ${moduleName} - start`, `Load Nx Plugin: ${moduleName} - end`);
|
|
95
|
+
return {
|
|
96
|
+
plugin,
|
|
97
|
+
options,
|
|
98
|
+
include,
|
|
99
|
+
exclude,
|
|
100
|
+
};
|
|
78
101
|
}
|
|
79
102
|
exports.loadNxPluginAsync = loadNxPluginAsync;
|
|
80
|
-
function
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let pluginModule = nxPluginCache.get(moduleName);
|
|
85
|
-
if (pluginModule) {
|
|
86
|
-
return { plugin: pluginModule, options };
|
|
87
|
-
}
|
|
88
|
-
let { pluginPath, name } = getPluginPathAndName(moduleName, paths, root);
|
|
89
|
-
const plugin = ensurePluginIsV2(require(pluginPath));
|
|
90
|
-
plugin.name ??= name;
|
|
91
|
-
nxPluginCache.set(moduleName, plugin);
|
|
92
|
-
return { plugin, options };
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated Use loadNxPlugins instead.
|
|
96
|
-
*/
|
|
97
|
-
function loadNxPluginsSync(plugins, paths = (0, installation_directory_1.getNxRequirePaths)(), root = workspace_root_1.workspaceRoot) {
|
|
98
|
-
// TODO: This should be specified in nx.json
|
|
99
|
-
// Temporarily load js as if it were a plugin which is built into nx
|
|
100
|
-
// In the future, this will be optional and need to be specified in nx.json
|
|
101
|
-
const result = [...getDefaultPluginsSync(root)];
|
|
102
|
-
if ((0, angular_json_1.shouldMergeAngularProjects)(root, false)) {
|
|
103
|
-
result.push({ plugin: angular_json_1.NxAngularJsonPlugin, options: undefined });
|
|
104
|
-
}
|
|
103
|
+
async function loadNxPlugins(plugins, paths = (0, installation_directory_1.getNxRequirePaths)(), root = workspace_root_1.workspaceRoot, projects) {
|
|
104
|
+
const result = [
|
|
105
|
+
{ plugin: package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin },
|
|
106
|
+
];
|
|
105
107
|
plugins ??= [];
|
|
108
|
+
// When loading plugins for `createNodes`, we don't know what projects exist yet.
|
|
109
|
+
// Try resolving plugins
|
|
106
110
|
for (const plugin of plugins) {
|
|
107
111
|
try {
|
|
108
|
-
|
|
112
|
+
require.resolve(typeof plugin === 'string' ? plugin : plugin.plugin);
|
|
109
113
|
}
|
|
110
|
-
catch
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
throw e;
|
|
114
|
+
catch {
|
|
115
|
+
// If a plugin cannot be resolved, we will need projects to resolve it
|
|
116
|
+
projects ??= await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
|
117
|
+
break;
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
// We push the nx core node plugins onto the end, s.t. it overwrites any other plugins
|
|
118
|
-
result.push({ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) }, { plugin: project_json_1.CreateProjectJsonProjectsPlugin });
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
exports.loadNxPluginsSync = loadNxPluginsSync;
|
|
122
|
-
async function loadNxPlugins(plugins, paths = (0, installation_directory_1.getNxRequirePaths)(), root = workspace_root_1.workspaceRoot) {
|
|
123
|
-
const result = [...(await getDefaultPlugins(root))];
|
|
124
|
-
// TODO: These should be specified in nx.json
|
|
125
|
-
// Temporarily load js as if it were a plugin which is built into nx
|
|
126
|
-
// In the future, this will be optional and need to be specified in nx.json
|
|
127
|
-
result.push();
|
|
128
|
-
plugins ??= [];
|
|
129
120
|
for (const plugin of plugins) {
|
|
130
|
-
result.push(await loadNxPluginAsync(plugin, paths, root));
|
|
121
|
+
result.push(await loadNxPluginAsync(plugin, paths, projects, root));
|
|
131
122
|
}
|
|
132
123
|
// We push the nx core node plugins onto the end, s.t. it overwrites any other plugins
|
|
133
|
-
result.push(
|
|
124
|
+
result.push(...(await getDefaultPlugins(root)));
|
|
134
125
|
return result;
|
|
135
126
|
}
|
|
136
127
|
exports.loadNxPlugins = loadNxPlugins;
|
|
@@ -144,12 +135,12 @@ function ensurePluginIsV2(plugin) {
|
|
|
144
135
|
createNodes: [
|
|
145
136
|
`*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
|
|
146
137
|
(configFilePath) => {
|
|
147
|
-
const
|
|
138
|
+
const root = (0, path_2.dirname)(configFilePath);
|
|
148
139
|
return {
|
|
149
140
|
projects: {
|
|
150
|
-
[
|
|
151
|
-
name,
|
|
152
|
-
root
|
|
141
|
+
[root]: {
|
|
142
|
+
name: (0, workspaces_1.toProjectName)(configFilePath),
|
|
143
|
+
root,
|
|
153
144
|
targets: plugin.registerProjectTargets?.(configFilePath),
|
|
154
145
|
},
|
|
155
146
|
},
|
|
@@ -160,6 +151,7 @@ function ensurePluginIsV2(plugin) {
|
|
|
160
151
|
}
|
|
161
152
|
return plugin;
|
|
162
153
|
}
|
|
154
|
+
exports.ensurePluginIsV2 = ensurePluginIsV2;
|
|
163
155
|
function isNxPluginV2(plugin) {
|
|
164
156
|
return 'createNodes' in plugin || 'createDependencies' in plugin;
|
|
165
157
|
}
|
|
@@ -168,7 +160,7 @@ function isNxPluginV1(plugin) {
|
|
|
168
160
|
return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
|
|
169
161
|
}
|
|
170
162
|
exports.isNxPluginV1 = isNxPluginV1;
|
|
171
|
-
function readPluginPackageJson(pluginName, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
|
163
|
+
function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
|
172
164
|
try {
|
|
173
165
|
const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
|
|
174
166
|
return {
|
|
@@ -178,7 +170,8 @@ function readPluginPackageJson(pluginName, paths = (0, installation_directory_1.
|
|
|
178
170
|
}
|
|
179
171
|
catch (e) {
|
|
180
172
|
if (e.code === 'MODULE_NOT_FOUND') {
|
|
181
|
-
const
|
|
173
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
174
|
+
const localPluginPath = resolveLocalNxPlugin(pluginName, nxJson, projects);
|
|
182
175
|
if (localPluginPath) {
|
|
183
176
|
const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
|
|
184
177
|
return {
|
|
@@ -197,8 +190,8 @@ exports.readPluginPackageJson = readPluginPackageJson;
|
|
|
197
190
|
* @returns The path to the built plugin, or null if it doesn't exist
|
|
198
191
|
*/
|
|
199
192
|
const localPluginCache = {};
|
|
200
|
-
function resolveLocalNxPlugin(importPath, root = workspace_root_1.workspaceRoot) {
|
|
201
|
-
localPluginCache[importPath] ??= lookupLocalPlugin(importPath, root);
|
|
193
|
+
function resolveLocalNxPlugin(importPath, nxJsonConfiguration, projects, root = workspace_root_1.workspaceRoot) {
|
|
194
|
+
localPluginCache[importPath] ??= lookupLocalPlugin(importPath, nxJsonConfiguration, projects, root);
|
|
202
195
|
return localPluginCache[importPath];
|
|
203
196
|
}
|
|
204
197
|
exports.resolveLocalNxPlugin = resolveLocalNxPlugin;
|
|
@@ -242,8 +235,7 @@ function unregisterPluginTSTranspiler() {
|
|
|
242
235
|
}
|
|
243
236
|
}
|
|
244
237
|
exports.unregisterPluginTSTranspiler = unregisterPluginTSTranspiler;
|
|
245
|
-
function lookupLocalPlugin(importPath, root = workspace_root_1.workspaceRoot) {
|
|
246
|
-
const projects = (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
|
238
|
+
function lookupLocalPlugin(importPath, nxJsonConfiguration, projects, root = workspace_root_1.workspaceRoot) {
|
|
247
239
|
const plugin = findNxProjectForImportPath(importPath, projects, root);
|
|
248
240
|
if (!plugin) {
|
|
249
241
|
return null;
|
|
@@ -299,20 +291,19 @@ function readPluginMainFromProjectConfiguration(plugin) {
|
|
|
299
291
|
return main;
|
|
300
292
|
}
|
|
301
293
|
async function getDefaultPlugins(root) {
|
|
302
|
-
const plugins = [
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
plugins.push(require('../adapter/angular-json').NxAngularJsonPlugin);
|
|
314
|
-
}
|
|
294
|
+
const plugins = [
|
|
295
|
+
await Promise.resolve().then(() => require('../plugins/js')),
|
|
296
|
+
target_defaults_plugin_1.TargetDefaultsPlugin,
|
|
297
|
+
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
|
298
|
+
? [
|
|
299
|
+
await Promise.resolve().then(() => require('../adapter/angular-json')).then((m) => m.NxAngularJsonPlugin),
|
|
300
|
+
]
|
|
301
|
+
: []),
|
|
302
|
+
(0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root),
|
|
303
|
+
project_json_1.ProjectJsonProjectsPlugin,
|
|
304
|
+
];
|
|
315
305
|
return plugins.map((p) => ({
|
|
316
306
|
plugin: p,
|
|
317
307
|
}));
|
|
318
308
|
}
|
|
309
|
+
exports.getDefaultPlugins = getDefaultPlugins;
|
package/src/utils/output.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as chalk from 'chalk';
|
|
2
|
-
import { TaskStatus } from '../tasks-runner/tasks-runner';
|
|
2
|
+
import type { TaskStatus } from '../tasks-runner/tasks-runner';
|
|
3
3
|
export interface CLIErrorMessageConfig {
|
|
4
4
|
title: string;
|
|
5
5
|
bodyLines?: string[];
|
|
@@ -19,7 +19,6 @@ export interface CLISuccessMessageConfig {
|
|
|
19
19
|
bodyLines?: string[];
|
|
20
20
|
}
|
|
21
21
|
declare class CLIOutput {
|
|
22
|
-
readonly X_PADDING = " ";
|
|
23
22
|
cliName: string;
|
|
24
23
|
formatCommand: (taskId: string) => string;
|
|
25
24
|
/**
|
|
@@ -58,6 +57,9 @@ declare class CLIOutput {
|
|
|
58
57
|
success({ title, bodyLines }: CLISuccessMessageConfig): void;
|
|
59
58
|
logSingleLine(message: string): void;
|
|
60
59
|
logCommand(message: string, taskStatus?: TaskStatus): void;
|
|
60
|
+
logCommandOutput(message: string, taskStatus: TaskStatus, output: string): void;
|
|
61
|
+
private getCommandWithStatus;
|
|
62
|
+
private getStatusIcon;
|
|
61
63
|
private normalizeMessage;
|
|
62
64
|
private addTaskStatus;
|
|
63
65
|
log({ title, bodyLines, color }: CLIWarnMessageConfig & {
|
package/src/utils/output.js
CHANGED
|
@@ -5,6 +5,8 @@ const chalk = require("chalk");
|
|
|
5
5
|
const os_1 = require("os");
|
|
6
6
|
const readline = require("readline");
|
|
7
7
|
const is_ci_1 = require("./is-ci");
|
|
8
|
+
const GH_GROUP_PREFIX = '::group::';
|
|
9
|
+
const GH_GROUP_SUFFIX = '::endgroup::';
|
|
8
10
|
/**
|
|
9
11
|
* Automatically disable styling applied by chalk if CI=true
|
|
10
12
|
*/
|
|
@@ -14,7 +16,6 @@ if ((0, is_ci_1.isCI)() && !forceColor) {
|
|
|
14
16
|
}
|
|
15
17
|
class CLIOutput {
|
|
16
18
|
constructor() {
|
|
17
|
-
this.X_PADDING = ' ';
|
|
18
19
|
this.cliName = 'NX';
|
|
19
20
|
this.formatCommand = (taskId) => `${chalk.dim('nx run')} ${taskId}`;
|
|
20
21
|
/**
|
|
@@ -39,7 +40,7 @@ class CLIOutput {
|
|
|
39
40
|
*/
|
|
40
41
|
get VERTICAL_SEPARATOR() {
|
|
41
42
|
let divider = '';
|
|
42
|
-
for (let i = 0; i < process.stdout.columns -
|
|
43
|
+
for (let i = 0; i < process.stdout.columns - 1; i++) {
|
|
43
44
|
divider += '\u2014';
|
|
44
45
|
}
|
|
45
46
|
return divider;
|
|
@@ -56,22 +57,22 @@ class CLIOutput {
|
|
|
56
57
|
process.stdout.write(os_1.EOL);
|
|
57
58
|
}
|
|
58
59
|
writeOutputTitle({ color, title, }) {
|
|
59
|
-
this.writeToStdOut(
|
|
60
|
+
this.writeToStdOut(`${this.applyNxPrefix(color, title)}${os_1.EOL}`);
|
|
60
61
|
}
|
|
61
62
|
writeOptionalOutputBody(bodyLines) {
|
|
62
63
|
if (!bodyLines) {
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
this.addNewline();
|
|
66
|
-
bodyLines.forEach((bodyLine) => this.writeToStdOut(
|
|
67
|
+
bodyLines.forEach((bodyLine) => this.writeToStdOut(`${bodyLine}${os_1.EOL}`));
|
|
67
68
|
}
|
|
68
69
|
applyNxPrefix(color = 'cyan', text) {
|
|
69
70
|
let nxPrefix = '';
|
|
70
71
|
if (chalk[color]) {
|
|
71
|
-
nxPrefix =
|
|
72
|
+
nxPrefix = chalk.reset.inverse.bold[color](` ${this.cliName} `);
|
|
72
73
|
}
|
|
73
74
|
else {
|
|
74
|
-
nxPrefix =
|
|
75
|
+
nxPrefix = chalk.reset.inverse.bold.keyword(color)(` ${this.cliName} `);
|
|
75
76
|
}
|
|
76
77
|
return `${nxPrefix} ${text}`;
|
|
77
78
|
}
|
|
@@ -90,7 +91,7 @@ class CLIOutput {
|
|
|
90
91
|
return ['', this.getVerticalSeparator(color), ''];
|
|
91
92
|
}
|
|
92
93
|
getVerticalSeparator(color) {
|
|
93
|
-
return
|
|
94
|
+
return chalk.dim[color](this.VERTICAL_SEPARATOR);
|
|
94
95
|
}
|
|
95
96
|
error({ title, slug, bodyLines }) {
|
|
96
97
|
this.addNewline();
|
|
@@ -152,10 +153,44 @@ class CLIOutput {
|
|
|
152
153
|
}
|
|
153
154
|
logCommand(message, taskStatus) {
|
|
154
155
|
this.addNewline();
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
this.writeToStdOut(this.getCommandWithStatus(message, taskStatus));
|
|
157
|
+
this.addNewline();
|
|
158
|
+
this.addNewline();
|
|
159
|
+
}
|
|
160
|
+
logCommandOutput(message, taskStatus, output) {
|
|
161
|
+
let commandOutputWithStatus = this.getCommandWithStatus(message, taskStatus);
|
|
162
|
+
if (process.env.NX_SKIP_LOG_GROUPING !== 'true' &&
|
|
163
|
+
process.env.GITHUB_ACTIONS) {
|
|
164
|
+
const icon = this.getStatusIcon(taskStatus);
|
|
165
|
+
commandOutputWithStatus = `${GH_GROUP_PREFIX}${icon} ${commandOutputWithStatus}`;
|
|
166
|
+
}
|
|
167
|
+
this.addNewline();
|
|
157
168
|
this.writeToStdOut(commandOutputWithStatus);
|
|
158
169
|
this.addNewline();
|
|
170
|
+
this.addNewline();
|
|
171
|
+
this.writeToStdOut(output);
|
|
172
|
+
if (process.env.NX_SKIP_LOG_GROUPING !== 'true' &&
|
|
173
|
+
process.env.GITHUB_ACTIONS) {
|
|
174
|
+
this.writeToStdOut(GH_GROUP_SUFFIX);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
getCommandWithStatus(message, taskStatus) {
|
|
178
|
+
const commandOutput = chalk.dim('> ') + this.formatCommand(this.normalizeMessage(message));
|
|
179
|
+
return this.addTaskStatus(taskStatus, commandOutput);
|
|
180
|
+
}
|
|
181
|
+
getStatusIcon(taskStatus) {
|
|
182
|
+
switch (taskStatus) {
|
|
183
|
+
case 'success':
|
|
184
|
+
return '✅';
|
|
185
|
+
case 'failure':
|
|
186
|
+
return '❌';
|
|
187
|
+
case 'skipped':
|
|
188
|
+
case 'local-cache-kept-existing':
|
|
189
|
+
return '⏩';
|
|
190
|
+
case 'local-cache':
|
|
191
|
+
case 'remote-cache':
|
|
192
|
+
return '🔁';
|
|
193
|
+
}
|
|
159
194
|
}
|
|
160
195
|
normalizeMessage(message) {
|
|
161
196
|
if (message.startsWith('nx run ')) {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { InputDefinition, TargetConfiguration } from '../config/workspace-json-project-json';
|
|
2
|
-
export type PackageJsonTargetConfiguration = Omit<TargetConfiguration, 'executor'>;
|
|
3
2
|
export interface NxProjectPackageJsonConfiguration {
|
|
4
3
|
implicitDependencies?: string[];
|
|
5
4
|
tags?: string[];
|
|
6
5
|
namedInputs?: {
|
|
7
6
|
[inputName: string]: (string | InputDefinition)[];
|
|
8
7
|
};
|
|
9
|
-
targets?: Record<string,
|
|
8
|
+
targets?: Record<string, TargetConfiguration>;
|
|
10
9
|
includedScripts?: string[];
|
|
11
10
|
}
|
|
12
11
|
export type ArrayPackageGroup = {
|
|
@@ -53,6 +52,7 @@ export interface PackageJson {
|
|
|
53
52
|
workspaces?: string[] | {
|
|
54
53
|
packages: string[];
|
|
55
54
|
};
|
|
55
|
+
publishConfig?: Record<string, string>;
|
|
56
56
|
nx?: NxProjectPackageJsonConfiguration;
|
|
57
57
|
generators?: string;
|
|
58
58
|
schematics?: string;
|
|
@@ -65,8 +65,8 @@ export declare function normalizePackageGroup(packageGroup: PackageGroup): Array
|
|
|
65
65
|
export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
|
|
66
66
|
packageGroup?: ArrayPackageGroup;
|
|
67
67
|
};
|
|
68
|
-
export declare function buildTargetFromScript(script: string
|
|
69
|
-
export declare function readTargetsFromPackageJson(
|
|
68
|
+
export declare function buildTargetFromScript(script: string): TargetConfiguration;
|
|
69
|
+
export declare function readTargetsFromPackageJson(packageJson: PackageJson): Record<string, TargetConfiguration<any>>;
|
|
70
70
|
/**
|
|
71
71
|
* Uses `require.resolve` to read the package.json for a module.
|
|
72
72
|
*
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.readModulePackageJson = exports.readModulePackageJsonWithoutFallbacks = exports.readTargetsFromPackageJson = exports.buildTargetFromScript = exports.readNxMigrateConfig = exports.normalizePackageGroup = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
+
const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
|
|
6
7
|
const fileutils_1 = require("./fileutils");
|
|
7
8
|
const installation_directory_1 = require("./installation-directory");
|
|
8
9
|
function normalizePackageGroup(packageGroup) {
|
|
@@ -37,27 +38,32 @@ function readNxMigrateConfig(json) {
|
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
exports.readNxMigrateConfig = readNxMigrateConfig;
|
|
40
|
-
function buildTargetFromScript(script
|
|
41
|
-
const nxTargetConfiguration = nx?.targets?.[script] || {};
|
|
41
|
+
function buildTargetFromScript(script) {
|
|
42
42
|
return {
|
|
43
|
-
...nxTargetConfiguration,
|
|
44
43
|
executor: 'nx:run-script',
|
|
45
44
|
options: {
|
|
46
|
-
...(nxTargetConfiguration.options || {}),
|
|
47
45
|
script,
|
|
48
46
|
},
|
|
49
47
|
};
|
|
50
48
|
}
|
|
51
49
|
exports.buildTargetFromScript = buildTargetFromScript;
|
|
52
|
-
function readTargetsFromPackageJson(
|
|
50
|
+
function readTargetsFromPackageJson(packageJson) {
|
|
51
|
+
const { scripts, nx, private: isPrivate } = packageJson ?? {};
|
|
53
52
|
const res = {};
|
|
54
|
-
Object.keys(scripts
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
|
54
|
+
//
|
|
55
|
+
for (const script of includedScripts) {
|
|
56
|
+
res[script] = buildTargetFromScript(script);
|
|
57
|
+
}
|
|
58
|
+
for (const targetName in nx?.targets) {
|
|
59
|
+
res[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(nx?.targets[targetName], res[targetName]);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Add implicit nx-release-publish target for all package.json files that are
|
|
63
|
+
* not marked as `"private": true` to allow for lightweight configuration for
|
|
64
|
+
* package based repos.
|
|
65
|
+
*/
|
|
66
|
+
if (!isPrivate && !res['nx-release-publish']) {
|
|
61
67
|
res['nx-release-publish'] = {
|
|
62
68
|
dependsOn: ['^nx-release-publish'],
|
|
63
69
|
executor: '@nx/js:release-publish',
|
|
@@ -3,6 +3,7 @@ export interface PackageManagerCommands {
|
|
|
3
3
|
preInstall?: string;
|
|
4
4
|
install: string;
|
|
5
5
|
ciInstall: string;
|
|
6
|
+
updateLockFile: string;
|
|
6
7
|
add: string;
|
|
7
8
|
addDev: string;
|
|
8
9
|
rm: string;
|
|
@@ -15,6 +16,12 @@ export interface PackageManagerCommands {
|
|
|
15
16
|
* Detects which package manager is used in the workspace based on the lock file.
|
|
16
17
|
*/
|
|
17
18
|
export declare function detectPackageManager(dir?: string): PackageManager;
|
|
19
|
+
/**
|
|
20
|
+
* Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
|
|
21
|
+
* @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
|
|
22
|
+
* @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isWorkspacesEnabled(packageManager?: PackageManager, root?: string): boolean;
|
|
18
25
|
/**
|
|
19
26
|
* Returns commands for the package manager used in the workspace.
|
|
20
27
|
* By default, the package manager is derived based on the lock file,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.detectPackageManager = void 0;
|
|
3
|
+
exports.packageRegistryPack = exports.packageRegistryView = exports.resolvePackageVersionUsingInstallation = exports.resolvePackageVersionUsingRegistry = exports.createTempNpmDirectory = exports.copyPackageManagerConfigurationFiles = exports.modifyYarnRcToFitNewDirectory = exports.modifyYarnRcYmlToFitNewDirectory = exports.findFileInPackageJsonDirectory = exports.getPackageManagerVersion = exports.getPackageManagerCommand = exports.isWorkspacesEnabled = exports.detectPackageManager = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
+
const semver_1 = require("semver");
|
|
8
9
|
const tmp_1 = require("tmp");
|
|
9
10
|
const util_1 = require("util");
|
|
11
|
+
const configuration_1 = require("../config/configuration");
|
|
12
|
+
const file_utils_1 = require("../project-graph/file-utils");
|
|
10
13
|
const fileutils_1 = require("./fileutils");
|
|
11
14
|
const package_json_1 = require("./package-json");
|
|
12
|
-
const semver_1 = require("semver");
|
|
13
15
|
const workspace_root_1 = require("./workspace-root");
|
|
14
|
-
const configuration_1 = require("../config/configuration");
|
|
15
16
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
16
17
|
/**
|
|
17
18
|
* Detects which package manager is used in the workspace based on the lock file.
|
|
@@ -26,6 +27,20 @@ function detectPackageManager(dir = '') {
|
|
|
26
27
|
: 'npm'));
|
|
27
28
|
}
|
|
28
29
|
exports.detectPackageManager = detectPackageManager;
|
|
30
|
+
/**
|
|
31
|
+
* Returns true if the workspace is using npm workspaces, yarn workspaces, or pnpm workspaces.
|
|
32
|
+
* @param packageManager The package manager to use. If not provided, it will be detected based on the lock file.
|
|
33
|
+
* @param root The directory the commands will be ran inside of. Defaults to the current workspace's root.
|
|
34
|
+
*/
|
|
35
|
+
function isWorkspacesEnabled(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
|
|
36
|
+
if (packageManager === 'pnpm') {
|
|
37
|
+
return (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
|
|
38
|
+
}
|
|
39
|
+
// yarn and pnpm both use the same 'workspaces' property in package.json
|
|
40
|
+
const packageJson = (0, file_utils_1.readPackageJson)();
|
|
41
|
+
return !!packageJson?.workspaces;
|
|
42
|
+
}
|
|
43
|
+
exports.isWorkspacesEnabled = isWorkspacesEnabled;
|
|
29
44
|
/**
|
|
30
45
|
* Returns commands for the package manager used in the workspace.
|
|
31
46
|
* By default, the package manager is derived based on the lock file,
|
|
@@ -51,6 +66,9 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
51
66
|
ciInstall: useBerry
|
|
52
67
|
? 'yarn install --immutable'
|
|
53
68
|
: 'yarn install --frozen-lockfile',
|
|
69
|
+
updateLockFile: useBerry
|
|
70
|
+
? 'yarn install --mode update-lockfile'
|
|
71
|
+
: 'yarn install',
|
|
54
72
|
add: useBerry ? 'yarn add' : 'yarn add -W',
|
|
55
73
|
addDev: useBerry ? 'yarn add -D' : 'yarn add -D -W',
|
|
56
74
|
rm: 'yarn remove',
|
|
@@ -66,8 +84,9 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
66
84
|
const includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
|
|
67
85
|
const isPnpmWorkspace = (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
|
|
68
86
|
return {
|
|
69
|
-
install: 'pnpm install --no-frozen-lockfile',
|
|
87
|
+
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
|
|
70
88
|
ciInstall: 'pnpm install --frozen-lockfile',
|
|
89
|
+
updateLockFile: 'pnpm install --lockfile-only',
|
|
71
90
|
add: isPnpmWorkspace ? 'pnpm add -w' : 'pnpm add',
|
|
72
91
|
addDev: isPnpmWorkspace ? 'pnpm add -Dw' : 'pnpm add -D',
|
|
73
92
|
rm: 'pnpm rm',
|
|
@@ -85,6 +104,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
85
104
|
return {
|
|
86
105
|
install: 'npm install',
|
|
87
106
|
ciInstall: 'npm ci',
|
|
107
|
+
updateLockFile: 'npm install --package-lock-only',
|
|
88
108
|
add: 'npm install',
|
|
89
109
|
addDev: 'npm install -D',
|
|
90
110
|
rm: 'npm rm',
|
package/src/utils/params.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NxJsonConfiguration } from '../config/nx-json';
|
|
2
|
-
import { TargetConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
|
1
|
+
import type { NxJsonConfiguration } from '../config/nx-json';
|
|
2
|
+
import type { TargetConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
|
3
3
|
type PropertyDescription = {
|
|
4
4
|
type?: string | string[];
|
|
5
5
|
required?: string[];
|
|
@@ -26,8 +26,10 @@ type PropertyDescription = {
|
|
|
26
26
|
$source: 'projectName';
|
|
27
27
|
} | {
|
|
28
28
|
$source: 'unparsed';
|
|
29
|
+
} | {
|
|
30
|
+
$source: 'workingDirectory';
|
|
29
31
|
};
|
|
30
|
-
additionalProperties?: boolean;
|
|
32
|
+
additionalProperties?: boolean | PropertyDescription;
|
|
31
33
|
const?: any;
|
|
32
34
|
'x-prompt'?: string | {
|
|
33
35
|
message: string;
|
|
@@ -46,6 +48,9 @@ type PropertyDescription = {
|
|
|
46
48
|
pattern?: string;
|
|
47
49
|
minLength?: number;
|
|
48
50
|
maxLength?: number;
|
|
51
|
+
patternProperties?: {
|
|
52
|
+
[pattern: string]: PropertyDescription;
|
|
53
|
+
};
|
|
49
54
|
};
|
|
50
55
|
type Properties = {
|
|
51
56
|
[p: string]: PropertyDescription;
|
|
@@ -57,11 +62,14 @@ export type Schema = {
|
|
|
57
62
|
oneOf?: Partial<Schema>[];
|
|
58
63
|
description?: string;
|
|
59
64
|
definitions?: Properties;
|
|
60
|
-
additionalProperties?: boolean;
|
|
65
|
+
additionalProperties?: boolean | PropertyDescription;
|
|
61
66
|
examples?: {
|
|
62
67
|
command: string;
|
|
63
68
|
description?: string;
|
|
64
69
|
}[];
|
|
70
|
+
patternProperties?: {
|
|
71
|
+
[pattern: string]: PropertyDescription;
|
|
72
|
+
};
|
|
65
73
|
};
|
|
66
74
|
export type Unmatched = {
|
|
67
75
|
name: string;
|