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
|
@@ -1,109 +1,294 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.releaseVersion = exports.releaseVersionCLIHandler = exports.validReleaseVersionPrefixes = exports.deriveNewSemverVersion = void 0;
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
-
const
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
|
-
const semver_1 = require("semver");
|
|
9
8
|
const nx_json_1 = require("../../config/nx-json");
|
|
10
|
-
const devkit_exports_1 = require("../../devkit-exports");
|
|
11
9
|
const tree_1 = require("../../generators/tree");
|
|
10
|
+
const file_map_utils_1 = require("../../project-graph/file-map-utils");
|
|
12
11
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
12
|
+
const output_1 = require("../../utils/output");
|
|
13
13
|
const params_1 = require("../../utils/params");
|
|
14
|
+
const path_1 = require("../../utils/path");
|
|
15
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
14
16
|
const generate_1 = require("../generate/generate");
|
|
15
17
|
const generator_utils_1 = require("../generate/generator-utils");
|
|
16
18
|
const config_1 = require("./config/config");
|
|
17
19
|
const filter_release_groups_1 = require("./config/filter-release-groups");
|
|
20
|
+
const batch_projects_by_generator_config_1 = require("./utils/batch-projects-by-generator-config");
|
|
21
|
+
const git_1 = require("./utils/git");
|
|
18
22
|
const print_changes_1 = require("./utils/print-changes");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
|
|
24
|
+
const shared_1 = require("./utils/shared");
|
|
25
|
+
const LARGE_BUFFER = 1024 * 1000000;
|
|
26
|
+
// Reexport some utils for use in plugin release-version generator implementations
|
|
27
|
+
var semver_1 = require("./utils/semver");
|
|
28
|
+
Object.defineProperty(exports, "deriveNewSemverVersion", { enumerable: true, get: function () { return semver_1.deriveNewSemverVersion; } });
|
|
29
|
+
exports.validReleaseVersionPrefixes = ['auto', '', '~', '^', '='];
|
|
30
|
+
const releaseVersionCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => releaseVersion(args));
|
|
31
|
+
exports.releaseVersionCLIHandler = releaseVersionCLIHandler;
|
|
32
|
+
/**
|
|
33
|
+
* NOTE: This function is also exported for programmatic usage and forms part of the public API
|
|
34
|
+
* of Nx. We intentionally do not wrap the implementation with handleErrors because users need
|
|
35
|
+
* to have control over their own error handling when using the API.
|
|
36
|
+
*/
|
|
37
|
+
async function releaseVersion(args) {
|
|
24
38
|
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
39
|
+
const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
25
40
|
const nxJson = (0, nx_json_1.readNxJson)();
|
|
26
41
|
if (args.verbose) {
|
|
27
42
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
|
28
43
|
}
|
|
29
44
|
// Apply default configuration to any optional user configuration
|
|
30
|
-
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph,
|
|
45
|
+
const { error: configError, nxReleaseConfig } = await (0, config_1.createNxReleaseConfig)(projectGraph, await (0, file_map_utils_1.createProjectFileMapUsingProjectGraph)(projectGraph), nxJson.release);
|
|
31
46
|
if (configError) {
|
|
32
47
|
return await (0, config_1.handleNxReleaseConfigError)(configError);
|
|
33
48
|
}
|
|
49
|
+
// The nx release top level command will always override these three git args. This is how we can tell
|
|
50
|
+
// if the top level release command was used or if the user is using the changelog subcommand.
|
|
51
|
+
// If the user explicitly overrides these args, then it doesn't matter if the top level config is set,
|
|
52
|
+
// as all of the git options would be overridden anyway.
|
|
53
|
+
if ((args.gitCommit === undefined ||
|
|
54
|
+
args.gitTag === undefined ||
|
|
55
|
+
args.stageChanges === undefined) &&
|
|
56
|
+
nxJson.release?.git) {
|
|
57
|
+
const nxJsonMessage = await (0, resolve_nx_json_error_message_1.resolveNxJsonConfigErrorMessage)([
|
|
58
|
+
'release',
|
|
59
|
+
'git',
|
|
60
|
+
]);
|
|
61
|
+
output_1.output.error({
|
|
62
|
+
title: `The "release.git" property in nx.json may not be used with the "nx release version" subcommand or programmatic API. Instead, configure git options for subcommands directly with "release.version.git" and "release.changelog.git".`,
|
|
63
|
+
bodyLines: [nxJsonMessage],
|
|
64
|
+
});
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
34
67
|
const { error: filterError, releaseGroups, releaseGroupToFilteredProjects, } = (0, filter_release_groups_1.filterReleaseGroups)(projectGraph, nxReleaseConfig, args.projects, args.groups);
|
|
35
68
|
if (filterError) {
|
|
36
|
-
|
|
69
|
+
output_1.output.error(filterError);
|
|
37
70
|
process.exit(1);
|
|
38
71
|
}
|
|
39
|
-
|
|
72
|
+
runPreVersionCommand(nxReleaseConfig.version.preVersionCommand, {
|
|
73
|
+
dryRun: args.dryRun,
|
|
74
|
+
verbose: args.verbose,
|
|
75
|
+
});
|
|
76
|
+
const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose);
|
|
77
|
+
const versionData = {};
|
|
78
|
+
const commitMessage = args.gitCommitMessage || nxReleaseConfig.version.git.commitMessage;
|
|
79
|
+
const additionalChangedFiles = new Set();
|
|
80
|
+
const generatorCallbacks = [];
|
|
40
81
|
if (args.projects?.length) {
|
|
41
82
|
/**
|
|
42
|
-
* Run
|
|
83
|
+
* Run versioning for all remaining release groups and filtered projects within them
|
|
43
84
|
*/
|
|
44
85
|
for (const releaseGroup of releaseGroups) {
|
|
45
86
|
const releaseGroupName = releaseGroup.name;
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
|
88
|
+
const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
|
|
89
|
+
// Only batch based on the filtered projects within the release group
|
|
90
|
+
releaseGroupProjectNames);
|
|
91
|
+
for (const [generatorConfigString, projectNames,] of projectBatches.entries()) {
|
|
92
|
+
const [generatorName, generatorOptions] = JSON.parse(generatorConfigString);
|
|
93
|
+
// Resolve the generator for the batch and run versioning on the projects within the batch
|
|
94
|
+
const generatorData = resolveGeneratorData({
|
|
95
|
+
...extractGeneratorCollectionAndName(`batch "${JSON.stringify(projectNames)}" for release-group "${releaseGroupName}"`, generatorName),
|
|
96
|
+
configGeneratorOptions: generatorOptions,
|
|
97
|
+
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
|
98
|
+
projects,
|
|
99
|
+
});
|
|
100
|
+
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData, nxReleaseConfig.conventionalCommits);
|
|
101
|
+
// Capture the callback so that we can run it after flushing the changes to disk
|
|
102
|
+
generatorCallbacks.push(async () => {
|
|
103
|
+
const changedFiles = await generatorCallback(tree, {
|
|
104
|
+
dryRun: !!args.dryRun,
|
|
105
|
+
verbose: !!args.verbose,
|
|
106
|
+
generatorOptions: {
|
|
107
|
+
...generatorOptions,
|
|
108
|
+
...args.generatorOptionsOverrides,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
|
|
116
|
+
const gitTagValues = args.gitTag ?? nxReleaseConfig.version.git.tag
|
|
117
|
+
? (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionData)
|
|
118
|
+
: [];
|
|
119
|
+
(0, shared_1.handleDuplicateGitTags)(gitTagValues);
|
|
120
|
+
printAndFlushChanges(tree, !!args.dryRun);
|
|
121
|
+
for (const generatorCallback of generatorCallbacks) {
|
|
122
|
+
await generatorCallback();
|
|
123
|
+
}
|
|
124
|
+
const changedFiles = [
|
|
125
|
+
...tree.listChanges().map((f) => f.path),
|
|
126
|
+
...additionalChangedFiles,
|
|
127
|
+
];
|
|
128
|
+
// No further actions are necessary in this scenario (e.g. if conventional commits detected no changes)
|
|
129
|
+
if (!changedFiles.length) {
|
|
130
|
+
return {
|
|
131
|
+
// An overall workspace version cannot be relevant when filtering to independent projects
|
|
132
|
+
workspaceVersion: undefined,
|
|
133
|
+
projectsVersionData: versionData,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
|
|
137
|
+
await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
|
|
138
|
+
}
|
|
139
|
+
else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
|
|
140
|
+
output_1.output.logSingleLine(`Staging changed files with git`);
|
|
141
|
+
await (0, git_1.gitAdd)({
|
|
142
|
+
changedFiles,
|
|
143
|
+
dryRun: args.dryRun,
|
|
144
|
+
verbose: args.verbose,
|
|
50
145
|
});
|
|
51
|
-
const semverSpecifier = await resolveSemverSpecifier(args.specifier, `What kind of change is this for the ${releaseGroupToFilteredProjects.get(releaseGroup).size} matched project(s) within release group "${releaseGroupName}"?`, `What is the exact version for the ${releaseGroupToFilteredProjects.get(releaseGroup).size} matched project(s) within release group "${releaseGroupName}"?`);
|
|
52
|
-
await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), semverSpecifier);
|
|
53
146
|
}
|
|
54
|
-
|
|
55
|
-
|
|
147
|
+
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
|
148
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
|
149
|
+
for (const tag of gitTagValues) {
|
|
150
|
+
await (0, git_1.gitTag)({
|
|
151
|
+
tag,
|
|
152
|
+
message: args.gitTagMessage || nxReleaseConfig.version.git.tagMessage,
|
|
153
|
+
additionalArgs: args.gitTagArgs || nxReleaseConfig.version.git.tagArgs,
|
|
154
|
+
dryRun: args.dryRun,
|
|
155
|
+
verbose: args.verbose,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
// An overall workspace version cannot be relevant when filtering to independent projects
|
|
161
|
+
workspaceVersion: undefined,
|
|
162
|
+
projectsVersionData: versionData,
|
|
163
|
+
};
|
|
56
164
|
}
|
|
57
165
|
/**
|
|
58
|
-
* Run
|
|
166
|
+
* Run versioning for all remaining release groups
|
|
59
167
|
*/
|
|
60
168
|
for (const releaseGroup of releaseGroups) {
|
|
61
169
|
const releaseGroupName = releaseGroup.name;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
170
|
+
const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
|
|
171
|
+
// Batch based on all projects within the release group
|
|
172
|
+
releaseGroup.projects);
|
|
173
|
+
for (const [generatorConfigString, projectNames,] of projectBatches.entries()) {
|
|
174
|
+
const [generatorName, generatorOptions] = JSON.parse(generatorConfigString);
|
|
175
|
+
// Resolve the generator for the batch and run versioning on the projects within the batch
|
|
176
|
+
const generatorData = resolveGeneratorData({
|
|
177
|
+
...extractGeneratorCollectionAndName(`batch "${JSON.stringify(projectNames)}" for release-group "${releaseGroupName}"`, generatorName),
|
|
178
|
+
configGeneratorOptions: generatorOptions,
|
|
179
|
+
// all project data from the project graph (not to be confused with projectNamesToRunVersionOn)
|
|
180
|
+
projects,
|
|
181
|
+
});
|
|
182
|
+
const generatorCallback = await runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, args.generatorOptionsOverrides, projectNames, releaseGroup, versionData, nxReleaseConfig.conventionalCommits);
|
|
183
|
+
// Capture the callback so that we can run it after flushing the changes to disk
|
|
184
|
+
generatorCallbacks.push(async () => {
|
|
185
|
+
const changedFiles = await generatorCallback(tree, {
|
|
186
|
+
dryRun: !!args.dryRun,
|
|
187
|
+
verbose: !!args.verbose,
|
|
188
|
+
generatorOptions: {
|
|
189
|
+
...generatorOptions,
|
|
190
|
+
...args.generatorOptionsOverrides,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
changedFiles.forEach((f) => additionalChangedFiles.add(f));
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Resolve any git tags as early as possible so that we can hard error in case of any duplicates before reaching the actual git command
|
|
198
|
+
const gitTagValues = args.gitTag ?? nxReleaseConfig.version.git.tag
|
|
199
|
+
? (0, shared_1.createGitTagValues)(releaseGroups, releaseGroupToFilteredProjects, versionData)
|
|
200
|
+
: [];
|
|
201
|
+
(0, shared_1.handleDuplicateGitTags)(gitTagValues);
|
|
202
|
+
printAndFlushChanges(tree, !!args.dryRun);
|
|
203
|
+
for (const generatorCallback of generatorCallbacks) {
|
|
204
|
+
await generatorCallback();
|
|
205
|
+
}
|
|
206
|
+
// Only applicable when there is a single release group with a fixed relationship
|
|
207
|
+
let workspaceVersion = undefined;
|
|
208
|
+
if (releaseGroups.length === 1) {
|
|
209
|
+
const releaseGroup = releaseGroups[0];
|
|
210
|
+
if (releaseGroup.projectsRelationship === 'fixed') {
|
|
211
|
+
const releaseGroupProjectNames = Array.from(releaseGroupToFilteredProjects.get(releaseGroup));
|
|
212
|
+
workspaceVersion = versionData[releaseGroupProjectNames[0]].newVersion; // all projects have the same version so we can just grab the first
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const changedFiles = [
|
|
216
|
+
...tree.listChanges().map((f) => f.path),
|
|
217
|
+
...additionalChangedFiles,
|
|
218
|
+
];
|
|
219
|
+
// No further actions are necessary in this scenario (e.g. if conventional commits detected no changes)
|
|
220
|
+
if (!changedFiles.length) {
|
|
221
|
+
return {
|
|
222
|
+
workspaceVersion,
|
|
223
|
+
projectsVersionData: versionData,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
if (args.gitCommit ?? nxReleaseConfig.version.git.commit) {
|
|
227
|
+
await (0, shared_1.commitChanges)(changedFiles, !!args.dryRun, !!args.verbose, (0, shared_1.createCommitMessageValues)(releaseGroups, releaseGroupToFilteredProjects, versionData, commitMessage), args.gitCommitArgs || nxReleaseConfig.version.git.commitArgs);
|
|
85
228
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
229
|
+
else if (args.stageChanges ?? nxReleaseConfig.version.git.stageChanges) {
|
|
230
|
+
output_1.output.logSingleLine(`Staging changed files with git`);
|
|
231
|
+
await (0, git_1.gitAdd)({
|
|
232
|
+
changedFiles,
|
|
233
|
+
dryRun: args.dryRun,
|
|
234
|
+
verbose: args.verbose,
|
|
91
235
|
});
|
|
92
|
-
process.exit(1);
|
|
93
236
|
}
|
|
237
|
+
if (args.gitTag ?? nxReleaseConfig.version.git.tag) {
|
|
238
|
+
output_1.output.logSingleLine(`Tagging commit with git`);
|
|
239
|
+
for (const tag of gitTagValues) {
|
|
240
|
+
await (0, git_1.gitTag)({
|
|
241
|
+
tag,
|
|
242
|
+
message: args.gitTagMessage || nxReleaseConfig.version.git.tagMessage,
|
|
243
|
+
additionalArgs: args.gitTagArgs || nxReleaseConfig.version.git.tagArgs,
|
|
244
|
+
dryRun: args.dryRun,
|
|
245
|
+
verbose: args.verbose,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
workspaceVersion,
|
|
251
|
+
projectsVersionData: versionData,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
exports.releaseVersion = releaseVersion;
|
|
255
|
+
function appendVersionData(existingVersionData, newVersionData) {
|
|
256
|
+
// Mutate the existing version data
|
|
257
|
+
for (const [key, value] of Object.entries(newVersionData)) {
|
|
258
|
+
if (existingVersionData[key]) {
|
|
259
|
+
throw new Error(`Version data key "${key}" already exists in version data. This is likely a bug.`);
|
|
260
|
+
}
|
|
261
|
+
existingVersionData[key] = value;
|
|
262
|
+
}
|
|
263
|
+
return existingVersionData;
|
|
264
|
+
}
|
|
265
|
+
async function runVersionOnProjects(projectGraph, nxJson, args, tree, generatorData, generatorOverrides, projectNames, releaseGroup, versionData, conventionalCommitsConfig) {
|
|
94
266
|
const generatorOptions = {
|
|
267
|
+
// Always ensure a string to avoid generator schema validation errors
|
|
268
|
+
specifier: args.specifier ?? '',
|
|
269
|
+
preid: args.preid ?? '',
|
|
270
|
+
...generatorData.configGeneratorOptions,
|
|
271
|
+
...(generatorOverrides ?? {}),
|
|
272
|
+
// The following are not overridable by user config
|
|
95
273
|
projects: projectNames.map((p) => projectGraph.nodes[p]),
|
|
96
274
|
projectGraph,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
275
|
+
releaseGroup,
|
|
276
|
+
firstRelease: args.firstRelease ?? false,
|
|
277
|
+
conventionalCommitsConfig,
|
|
100
278
|
};
|
|
101
279
|
// Apply generator defaults from schema.json file etc
|
|
102
|
-
const combinedOpts = await (0, params_1.combineOptionsForGenerator)(generatorOptions, generatorData.collectionName, generatorData.normalizedGeneratorName, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson, generatorData.schema, false, null, (0, node_path_1.relative)(process.cwd(),
|
|
280
|
+
const combinedOpts = await (0, params_1.combineOptionsForGenerator)(generatorOptions, generatorData.collectionName, generatorData.normalizedGeneratorName, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson, generatorData.schema, false, null, (0, node_path_1.relative)(process.cwd(), workspace_root_1.workspaceRoot), args.verbose);
|
|
103
281
|
const releaseVersionGenerator = generatorData.implementationFactory();
|
|
104
|
-
|
|
282
|
+
// We expect all version generator implementations to return a ReleaseVersionGeneratorResult object, rather than a GeneratorCallback
|
|
283
|
+
const versionResult = (await releaseVersionGenerator(tree, combinedOpts));
|
|
284
|
+
if (typeof versionResult === 'function') {
|
|
285
|
+
throw new Error(`The version generator ${generatorData.collectionName}:${generatorData.normalizedGeneratorName} returned a function instead of an expected ReleaseVersionGeneratorResult`);
|
|
286
|
+
}
|
|
287
|
+
// Merge the extra version data into the existing
|
|
288
|
+
appendVersionData(versionData, versionResult.data);
|
|
289
|
+
return versionResult.callback;
|
|
105
290
|
}
|
|
106
|
-
function
|
|
291
|
+
function printAndFlushChanges(tree, isDryRun) {
|
|
107
292
|
const changes = tree.listChanges();
|
|
108
293
|
console.log('');
|
|
109
294
|
// Print the changes
|
|
@@ -114,7 +299,7 @@ function printChanges(tree, isDryRun) {
|
|
|
114
299
|
}
|
|
115
300
|
else if (f.type === 'UPDATE') {
|
|
116
301
|
console.error(`${chalk.white('UPDATE')} ${f.path}${isDryRun ? chalk.keyword('orange')(' [dry-run]') : ''}`);
|
|
117
|
-
const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0,
|
|
302
|
+
const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0, path_1.joinPathFragments)(tree.root, f.path)).toString();
|
|
118
303
|
(0, print_changes_1.printDiff)(currentContentsOnDisk, f.content?.toString() || '');
|
|
119
304
|
}
|
|
120
305
|
else if (f.type === 'DELETE') {
|
|
@@ -122,56 +307,7 @@ function printChanges(tree, isDryRun) {
|
|
|
122
307
|
}
|
|
123
308
|
});
|
|
124
309
|
if (!isDryRun) {
|
|
125
|
-
(0, tree_1.flushChanges)(
|
|
126
|
-
}
|
|
127
|
-
if (isDryRun) {
|
|
128
|
-
devkit_exports_1.logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
async function resolveSemverSpecifier(cliArgSpecifier, selectionMessage, customVersionMessage) {
|
|
132
|
-
try {
|
|
133
|
-
let newVersionSpecifier = cliArgSpecifier;
|
|
134
|
-
// If the user didn't provide a new version specifier directly on the CLI, prompt for one
|
|
135
|
-
if (!newVersionSpecifier) {
|
|
136
|
-
const reply = await enquirer.prompt([
|
|
137
|
-
{
|
|
138
|
-
name: 'specifier',
|
|
139
|
-
message: selectionMessage,
|
|
140
|
-
type: 'select',
|
|
141
|
-
choices: [
|
|
142
|
-
...semver_1.RELEASE_TYPES.map((t) => ({ name: t, message: t })),
|
|
143
|
-
{
|
|
144
|
-
name: 'custom',
|
|
145
|
-
message: 'Custom exact version',
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
]);
|
|
150
|
-
if (reply.specifier !== 'custom') {
|
|
151
|
-
newVersionSpecifier = reply.specifier;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
const reply = await enquirer.prompt([
|
|
155
|
-
{
|
|
156
|
-
name: 'specifier',
|
|
157
|
-
message: customVersionMessage,
|
|
158
|
-
type: 'input',
|
|
159
|
-
validate: (input) => {
|
|
160
|
-
if ((0, semver_1.valid)(input)) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
return 'Please enter a valid semver version';
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
]);
|
|
167
|
-
newVersionSpecifier = reply.specifier;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return newVersionSpecifier;
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
// We need to catch the error from enquirer prompt, otherwise yargs will print its help
|
|
174
|
-
process.exit(1);
|
|
310
|
+
(0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, changes);
|
|
175
311
|
}
|
|
176
312
|
}
|
|
177
313
|
function extractGeneratorCollectionAndName(description, generatorString) {
|
|
@@ -185,14 +321,73 @@ function extractGeneratorCollectionAndName(description, generatorString) {
|
|
|
185
321
|
}
|
|
186
322
|
return { collectionName, generatorName };
|
|
187
323
|
}
|
|
188
|
-
function resolveGeneratorData({ collectionName, generatorName, configGeneratorOptions, }) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
324
|
+
function resolveGeneratorData({ collectionName, generatorName, configGeneratorOptions, projects, }) {
|
|
325
|
+
try {
|
|
326
|
+
const { normalizedGeneratorName, schema, implementationFactory } = (0, generator_utils_1.getGeneratorInformation)(collectionName, generatorName, workspace_root_1.workspaceRoot, projects);
|
|
327
|
+
return {
|
|
328
|
+
collectionName,
|
|
329
|
+
generatorName,
|
|
330
|
+
configGeneratorOptions,
|
|
331
|
+
normalizedGeneratorName,
|
|
332
|
+
schema,
|
|
333
|
+
implementationFactory,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
catch (err) {
|
|
337
|
+
if (err.message.startsWith('Unable to resolve')) {
|
|
338
|
+
// See if it is because the plugin is not installed
|
|
339
|
+
try {
|
|
340
|
+
require.resolve(collectionName);
|
|
341
|
+
// is installed
|
|
342
|
+
throw new Error(`Unable to resolve the generator called "${generatorName}" within the "${collectionName}" package`);
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
/**
|
|
346
|
+
* Special messaging for the most common case (especially as the user is unlikely to explicitly have
|
|
347
|
+
* the @nx/js generator config in their nx.json so we need to be clear about what the problem is)
|
|
348
|
+
*/
|
|
349
|
+
if (collectionName === '@nx/js') {
|
|
350
|
+
throw new Error('The @nx/js plugin is required in order to version your JavaScript packages. Please install it and try again.');
|
|
351
|
+
}
|
|
352
|
+
throw new Error(`Unable to resolve the package ${collectionName} in order to load the generator called ${generatorName}. Is the package installed?`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
// Unexpected error, rethrow
|
|
356
|
+
throw err;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function runPreVersionCommand(preVersionCommand, { dryRun, verbose }) {
|
|
360
|
+
if (!preVersionCommand) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
output_1.output.logSingleLine(`Executing pre-version command`);
|
|
364
|
+
if (verbose) {
|
|
365
|
+
console.log(`Executing the following pre-version command:`);
|
|
366
|
+
console.log(preVersionCommand);
|
|
367
|
+
}
|
|
368
|
+
let env = {
|
|
369
|
+
...process.env,
|
|
197
370
|
};
|
|
371
|
+
if (dryRun) {
|
|
372
|
+
env.NX_DRY_RUN = 'true';
|
|
373
|
+
}
|
|
374
|
+
const stdio = verbose ? 'inherit' : 'pipe';
|
|
375
|
+
try {
|
|
376
|
+
(0, node_child_process_1.execSync)(preVersionCommand, {
|
|
377
|
+
encoding: 'utf-8',
|
|
378
|
+
maxBuffer: LARGE_BUFFER,
|
|
379
|
+
stdio,
|
|
380
|
+
env,
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
catch (e) {
|
|
384
|
+
const title = verbose
|
|
385
|
+
? `The pre-version command failed. See the full output above.`
|
|
386
|
+
: `The pre-version command failed. Retry with --verbose to see the full output of the pre-version command.`;
|
|
387
|
+
output_1.output.error({
|
|
388
|
+
title,
|
|
389
|
+
bodyLines: [preVersionCommand, e],
|
|
390
|
+
});
|
|
391
|
+
process.exit(1);
|
|
392
|
+
}
|
|
198
393
|
}
|
|
@@ -11,15 +11,19 @@ async function repair(args, extraMigrations = []) {
|
|
|
11
11
|
}
|
|
12
12
|
const verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
13
13
|
return (0, params_1.handleErrors)(verbose, async () => {
|
|
14
|
-
const nxMigrations = Object.entries(migrationsJson.generators).
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const nxMigrations = Object.entries(migrationsJson.generators).reduce((agg, [name, migration]) => {
|
|
15
|
+
const skip = migration['x-repair-skip'];
|
|
16
|
+
if (!skip) {
|
|
17
|
+
agg.push({
|
|
18
|
+
package: 'nx',
|
|
19
|
+
cli: 'nx',
|
|
20
|
+
name,
|
|
21
|
+
description: migration.description,
|
|
22
|
+
version: migration.version,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return agg;
|
|
26
|
+
}, []);
|
|
23
27
|
const migrations = [...nxMigrations, ...extraMigrations];
|
|
24
28
|
const migrationsThatMadeNoChanges = await (0, migrate_1.executeMigrations)(process.cwd(), migrations, verbose, false, '');
|
|
25
29
|
if (migrationsThatMadeNoChanges.length < migrations.length) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PackageManager } from '../../utils/package-manager';
|
|
2
2
|
import { PackageJson } from '../../utils/package-json';
|
|
3
|
+
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
3
4
|
export declare const packagesWeCareAbout: string[];
|
|
4
5
|
export declare const patternsWeIgnoreInCommunityReport: Array<string | RegExp>;
|
|
5
6
|
/**
|
|
@@ -16,6 +17,7 @@ export interface ReportData {
|
|
|
16
17
|
pmVersion: string;
|
|
17
18
|
localPlugins: string[];
|
|
18
19
|
communityPlugins: PackageJson[];
|
|
20
|
+
registeredPlugins: string[];
|
|
19
21
|
packageVersionsWeCareAbout: {
|
|
20
22
|
package: string;
|
|
21
23
|
version: string;
|
|
@@ -41,6 +43,7 @@ interface OutOfSyncPackageGroup {
|
|
|
41
43
|
}
|
|
42
44
|
export declare function findMisalignedPackagesForPackage(base: PackageJson): undefined | OutOfSyncPackageGroup;
|
|
43
45
|
export declare function findInstalledCommunityPlugins(): PackageJson[];
|
|
46
|
+
export declare function findRegisteredPluginsBeingUsed(nxJson: NxJsonConfiguration): string[];
|
|
44
47
|
export declare function findInstalledPackagesWeCareAbout(): {
|
|
45
48
|
package: string;
|
|
46
49
|
version: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findInstalledPackagesWeCareAbout = exports.findInstalledCommunityPlugins = exports.findMisalignedPackagesForPackage = exports.getReportData = exports.reportHandler = exports.patternsWeIgnoreInCommunityReport = exports.packagesWeCareAbout = void 0;
|
|
3
|
+
exports.findInstalledPackagesWeCareAbout = exports.findRegisteredPluginsBeingUsed = exports.findInstalledCommunityPlugins = exports.findMisalignedPackagesForPackage = exports.getReportData = exports.reportHandler = exports.patternsWeIgnoreInCommunityReport = exports.packagesWeCareAbout = void 0;
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const output_1 = require("../../utils/output");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -17,7 +17,7 @@ const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname,
|
|
|
17
17
|
exports.packagesWeCareAbout = [
|
|
18
18
|
'lerna',
|
|
19
19
|
...nxPackageJson['nx-migrations'].packageGroup.map((x) => typeof x === 'string' ? x : x.package),
|
|
20
|
-
'@nrwl/schematics',
|
|
20
|
+
'@nrwl/schematics', // manually added since we don't publish it anymore.
|
|
21
21
|
'typescript',
|
|
22
22
|
];
|
|
23
23
|
exports.patternsWeIgnoreInCommunityReport = [
|
|
@@ -36,7 +36,7 @@ const LINE_SEPARATOR = '---------------------------------------';
|
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
38
|
async function reportHandler() {
|
|
39
|
-
const { pm, pmVersion, localPlugins, communityPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, } = await getReportData();
|
|
39
|
+
const { pm, pmVersion, localPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, } = await getReportData();
|
|
40
40
|
const bodyLines = [
|
|
41
41
|
`Node : ${process.versions.node}`,
|
|
42
42
|
`OS : ${process.platform}-${process.arch}`,
|
|
@@ -47,6 +47,13 @@ async function reportHandler() {
|
|
|
47
47
|
packageVersionsWeCareAbout.forEach((p) => {
|
|
48
48
|
bodyLines.push(`${chalk.green(p.package.padEnd(padding))} : ${chalk.bold(p.version)}`);
|
|
49
49
|
});
|
|
50
|
+
if (registeredPlugins.length) {
|
|
51
|
+
bodyLines.push(LINE_SEPARATOR);
|
|
52
|
+
bodyLines.push('Registered Plugins:');
|
|
53
|
+
for (const plugin of registeredPlugins) {
|
|
54
|
+
bodyLines.push(`${chalk.green(plugin)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
50
57
|
if (communityPlugins.length) {
|
|
51
58
|
bodyLines.push(LINE_SEPARATOR);
|
|
52
59
|
padding = Math.max(...communityPlugins.map((x) => x.name.length)) + 1;
|
|
@@ -86,8 +93,10 @@ exports.reportHandler = reportHandler;
|
|
|
86
93
|
async function getReportData() {
|
|
87
94
|
const pm = (0, package_manager_1.detectPackageManager)();
|
|
88
95
|
const pmVersion = (0, package_manager_1.getPackageManagerVersion)(pm);
|
|
89
|
-
const
|
|
96
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
97
|
+
const localPlugins = await findLocalPlugins(nxJson);
|
|
90
98
|
const communityPlugins = findInstalledCommunityPlugins();
|
|
99
|
+
const registeredPlugins = findRegisteredPluginsBeingUsed(nxJson);
|
|
91
100
|
let projectGraphError = null;
|
|
92
101
|
if (isNativeAvailable()) {
|
|
93
102
|
try {
|
|
@@ -114,6 +123,7 @@ async function getReportData() {
|
|
|
114
123
|
pmVersion,
|
|
115
124
|
localPlugins,
|
|
116
125
|
communityPlugins,
|
|
126
|
+
registeredPlugins,
|
|
117
127
|
packageVersionsWeCareAbout,
|
|
118
128
|
outOfSyncPackageGroup,
|
|
119
129
|
projectGraphError,
|
|
@@ -178,9 +188,16 @@ function findInstalledCommunityPlugins() {
|
|
|
178
188
|
: pattern.test(dep.name)));
|
|
179
189
|
}
|
|
180
190
|
exports.findInstalledCommunityPlugins = findInstalledCommunityPlugins;
|
|
191
|
+
function findRegisteredPluginsBeingUsed(nxJson) {
|
|
192
|
+
if (!nxJson.plugins) {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
return nxJson.plugins.map((plugin) => typeof plugin === 'object' ? plugin.plugin : plugin);
|
|
196
|
+
}
|
|
197
|
+
exports.findRegisteredPluginsBeingUsed = findRegisteredPluginsBeingUsed;
|
|
181
198
|
function findInstalledPackagesWeCareAbout() {
|
|
182
199
|
const packagesWeMayCareAbout = {};
|
|
183
|
-
// TODO (
|
|
200
|
+
// TODO (v19): Remove workaround for hiding @nrwl packages when matching @nx package is found.
|
|
184
201
|
const packageChangeMap = {
|
|
185
202
|
'@nrwl/nx-plugin': '@nx/plugin',
|
|
186
203
|
'@nx/plugin': '@nrwl/nx-plugin',
|