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
|
@@ -5,7 +5,7 @@ const crypto_1 = require("crypto");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const fs_extra_1 = require("fs-extra");
|
|
7
7
|
const http = require("http");
|
|
8
|
-
const
|
|
8
|
+
const minimatch_1 = require("minimatch");
|
|
9
9
|
const node_url_1 = require("node:url");
|
|
10
10
|
const open = require("open");
|
|
11
11
|
const path_1 = require("path");
|
|
@@ -15,7 +15,6 @@ const fileutils_1 = require("../../utils/fileutils");
|
|
|
15
15
|
const output_1 = require("../../utils/output");
|
|
16
16
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
17
17
|
const client_1 = require("../../daemon/client/client");
|
|
18
|
-
const task_hasher_1 = require("../../hasher/task-hasher");
|
|
19
18
|
const typescript_1 = require("../../plugins/js/utils/typescript");
|
|
20
19
|
const operators_1 = require("../../project-graph/operators");
|
|
21
20
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
@@ -26,6 +25,8 @@ const native_1 = require("../../native");
|
|
|
26
25
|
const transform_objects_1 = require("../../native/transform-objects");
|
|
27
26
|
const affected_1 = require("../affected/affected");
|
|
28
27
|
const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
|
|
28
|
+
const task_hasher_1 = require("../../hasher/task-hasher");
|
|
29
|
+
const create_task_hasher_1 = require("../../hasher/create-task-hasher");
|
|
29
30
|
// maps file extention to MIME types
|
|
30
31
|
const mimeType = {
|
|
31
32
|
'.ico': 'image/x-icon',
|
|
@@ -43,7 +44,7 @@ const mimeType = {
|
|
|
43
44
|
'.eot': 'appliaction/vnd.ms-fontobject',
|
|
44
45
|
'.ttf': 'aplication/font-sfnt',
|
|
45
46
|
};
|
|
46
|
-
function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientResponse, taskGraphClientResponse, expandedTaskInputsReponse) {
|
|
47
|
+
function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientResponse, taskGraphClientResponse, expandedTaskInputsReponse, sourceMapsResponse) {
|
|
47
48
|
let environmentJs = `window.exclude = ${JSON.stringify(exclude)};
|
|
48
49
|
window.watch = ${!!watchMode};
|
|
49
50
|
window.environment = 'release';
|
|
@@ -59,6 +60,7 @@ function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientRespons
|
|
|
59
60
|
projectGraphUrl: 'project-graph.json',
|
|
60
61
|
taskGraphUrl: 'task-graph.json',
|
|
61
62
|
taskInputsUrl: 'task-inputs.json',
|
|
63
|
+
sourceMapsUrl: 'source-maps.json'
|
|
62
64
|
}
|
|
63
65
|
],
|
|
64
66
|
defaultWorkspaceId: 'local',
|
|
@@ -70,11 +72,13 @@ function buildEnvironmentJs(exclude, watchMode, localMode, depGraphClientRespons
|
|
|
70
72
|
environmentJs += `window.taskGraphResponse = ${JSON.stringify(taskGraphClientResponse)};
|
|
71
73
|
`;
|
|
72
74
|
environmentJs += `window.expandedTaskInputsResponse = ${JSON.stringify(expandedTaskInputsReponse)};`;
|
|
75
|
+
environmentJs += `window.sourceMapsResponse = ${JSON.stringify(sourceMapsResponse)};`;
|
|
73
76
|
}
|
|
74
77
|
else {
|
|
75
78
|
environmentJs += `window.projectGraphResponse = null;`;
|
|
76
79
|
environmentJs += `window.taskGraphResponse = null;`;
|
|
77
80
|
environmentJs += `window.expandedTaskInputsResponse = null;`;
|
|
81
|
+
environmentJs += `window.sourceMapsResponse = null;`;
|
|
78
82
|
}
|
|
79
83
|
return environmentJs;
|
|
80
84
|
}
|
|
@@ -133,11 +137,28 @@ async function generateGraph(args, affectedProjects) {
|
|
|
133
137
|
],
|
|
134
138
|
});
|
|
135
139
|
}
|
|
140
|
+
if (args.view === 'project-details' && !args.focus) {
|
|
141
|
+
output_1.output.error({
|
|
142
|
+
title: `The project details view requires the --focus option.`,
|
|
143
|
+
});
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
if (args.view === 'project-details' && (args.targets || args.affected)) {
|
|
147
|
+
output_1.output.error({
|
|
148
|
+
title: `The project details view can only be used with the --focus option.`,
|
|
149
|
+
bodyLines: [
|
|
150
|
+
`You passed ${args.targets ? '--targets ' : ''}${args.affected ? '--affected ' : ''}`,
|
|
151
|
+
],
|
|
152
|
+
});
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
136
155
|
// TODO: Graph Client should support multiple targets
|
|
137
156
|
const target = Array.isArray(args.targets && args.targets.length >= 1)
|
|
138
157
|
? args.targets[0]
|
|
139
158
|
: args.targets;
|
|
140
|
-
const rawGraph = await (0, project_graph_1.
|
|
159
|
+
const { projectGraph: rawGraph, sourceMaps } = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({
|
|
160
|
+
exitOnError: true,
|
|
161
|
+
});
|
|
141
162
|
let prunedGraph = (0, operators_1.pruneExternalNodes)(rawGraph);
|
|
142
163
|
const projects = Object.values(prunedGraph.nodes);
|
|
143
164
|
projects.sort((a, b) => {
|
|
@@ -175,7 +196,7 @@ async function generateGraph(args, affectedProjects) {
|
|
|
175
196
|
if (args.file) {
|
|
176
197
|
// stdout is a magical constant that doesn't actually write a file
|
|
177
198
|
if (args.file === 'stdout') {
|
|
178
|
-
console.log(JSON.stringify(createJsonOutput(prunedGraph, args.projects, args.targets), null, 2));
|
|
199
|
+
console.log(JSON.stringify(await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets), null, 2));
|
|
179
200
|
process.exit(0);
|
|
180
201
|
}
|
|
181
202
|
const workspaceFolder = workspace_root_1.workspaceRoot;
|
|
@@ -196,10 +217,10 @@ async function generateGraph(args, affectedProjects) {
|
|
|
196
217
|
return isntHtml;
|
|
197
218
|
},
|
|
198
219
|
});
|
|
199
|
-
const
|
|
220
|
+
const { projectGraphClientResponse } = await createProjectGraphAndSourceMapClientResponse(affectedProjects);
|
|
200
221
|
const taskGraphClientResponse = await createTaskGraphClientResponse();
|
|
201
|
-
const taskInputsReponse = await createExpandedTaskInputResponse(taskGraphClientResponse,
|
|
202
|
-
const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve',
|
|
222
|
+
const taskInputsReponse = await createExpandedTaskInputResponse(taskGraphClientResponse, projectGraphClientResponse);
|
|
223
|
+
const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve', projectGraphClientResponse, taskGraphClientResponse, taskInputsReponse, sourceMaps);
|
|
203
224
|
html = html.replace(/src="/g, 'src="static/');
|
|
204
225
|
html = html.replace(/href="styles/g, 'href="static/styles');
|
|
205
226
|
html = html.replace('<base href="/" />', '');
|
|
@@ -213,7 +234,7 @@ async function generateGraph(args, affectedProjects) {
|
|
|
213
234
|
}
|
|
214
235
|
else if (ext === '.json') {
|
|
215
236
|
(0, fs_extra_1.ensureDirSync)((0, path_1.dirname)(fullFilePath));
|
|
216
|
-
const json = createJsonOutput(prunedGraph, args.projects, args.targets);
|
|
237
|
+
const json = await createJsonOutput(prunedGraph, rawGraph, args.projects, args.targets);
|
|
217
238
|
json.affectedProjects = affectedProjects;
|
|
218
239
|
json.criticalPath = affectedProjects;
|
|
219
240
|
(0, fileutils_1.writeJsonFile)(fullFilePath, json);
|
|
@@ -223,7 +244,7 @@ async function generateGraph(args, affectedProjects) {
|
|
|
223
244
|
'- affectedProjects',
|
|
224
245
|
'- criticalPath',
|
|
225
246
|
'',
|
|
226
|
-
'These fields will be removed in Nx
|
|
247
|
+
'These fields will be removed in Nx 19. If you need to see which projects were affected, use `nx show projects --affected`.',
|
|
227
248
|
],
|
|
228
249
|
});
|
|
229
250
|
output_1.output.success({
|
|
@@ -245,7 +266,7 @@ async function generateGraph(args, affectedProjects) {
|
|
|
245
266
|
const { app, url } = await startServer(html, environmentJs, args.host || '127.0.0.1', args.port || 4211, args.watch, affectedProjects, args.focus, args.groupByFolder, args.exclude);
|
|
246
267
|
url.pathname = args.view;
|
|
247
268
|
if (args.focus) {
|
|
248
|
-
url.pathname += '/' + args.focus;
|
|
269
|
+
url.pathname += '/' + encodeURIComponent(args.focus);
|
|
249
270
|
}
|
|
250
271
|
if (target) {
|
|
251
272
|
url.pathname += '/' + target;
|
|
@@ -279,10 +300,12 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
|
|
|
279
300
|
if (watchForchanges) {
|
|
280
301
|
unregisterFileWatcher = await createFileWatcher();
|
|
281
302
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
303
|
+
const { projectGraphClientResponse, sourceMapResponse } = await createProjectGraphAndSourceMapClientResponse(affected);
|
|
304
|
+
currentProjectGraphClientResponse = projectGraphClientResponse;
|
|
305
|
+
currentProjectGraphClientResponse.focus = focus;
|
|
306
|
+
currentProjectGraphClientResponse.groupByFolder = groupByFolder;
|
|
307
|
+
currentProjectGraphClientResponse.exclude = exclude;
|
|
308
|
+
currentSourceMapsClientResponse = sourceMapResponse;
|
|
286
309
|
const app = http.createServer(async (req, res) => {
|
|
287
310
|
// parse URL
|
|
288
311
|
const parsedUrl = new node_url_1.URL(req.url, `http://${host}:${port}`);
|
|
@@ -290,10 +313,11 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
|
|
|
290
313
|
// Avoid https://en.wikipedia.org/wiki/Directory_traversal_attack
|
|
291
314
|
// e.g curl --path-as-is http://localhost:9000/../fileInDanger.txt
|
|
292
315
|
// by limiting the path to current directory only
|
|
316
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
293
317
|
const sanitizePath = (0, path_1.basename)(parsedUrl.pathname);
|
|
294
318
|
if (sanitizePath === 'project-graph.json') {
|
|
295
319
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
296
|
-
res.end(JSON.stringify(
|
|
320
|
+
res.end(JSON.stringify(currentProjectGraphClientResponse));
|
|
297
321
|
return;
|
|
298
322
|
}
|
|
299
323
|
if (sanitizePath === 'task-graph.json') {
|
|
@@ -311,9 +335,14 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
|
|
|
311
335
|
perf_hooks_1.performance.measure('task input generation', 'task input generation:start', 'task input generation:end');
|
|
312
336
|
return;
|
|
313
337
|
}
|
|
338
|
+
if (sanitizePath === 'source-maps.json') {
|
|
339
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
340
|
+
res.end(JSON.stringify(currentSourceMapsClientResponse));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
314
343
|
if (sanitizePath === 'currentHash') {
|
|
315
344
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
316
|
-
res.end(JSON.stringify({ hash:
|
|
345
|
+
res.end(JSON.stringify({ hash: currentProjectGraphClientResponse.hash }));
|
|
317
346
|
return;
|
|
318
347
|
}
|
|
319
348
|
if (sanitizePath === 'environment.js') {
|
|
@@ -353,7 +382,7 @@ async function startServer(html, environmentJs, host, port = 4211, watchForchang
|
|
|
353
382
|
});
|
|
354
383
|
});
|
|
355
384
|
}
|
|
356
|
-
let
|
|
385
|
+
let currentProjectGraphClientResponse = {
|
|
357
386
|
hash: null,
|
|
358
387
|
projects: [],
|
|
359
388
|
dependencies: {},
|
|
@@ -367,6 +396,7 @@ let currentDepGraphClientResponse = {
|
|
|
367
396
|
groupByFolder: false,
|
|
368
397
|
exclude: [],
|
|
369
398
|
};
|
|
399
|
+
let currentSourceMapsClientResponse = {};
|
|
370
400
|
function debounce(fn, time) {
|
|
371
401
|
let timeout;
|
|
372
402
|
return (...args) => {
|
|
@@ -387,10 +417,13 @@ function createFileWatcher() {
|
|
|
387
417
|
}
|
|
388
418
|
else if (changes !== null && changes.changedFiles.length > 0) {
|
|
389
419
|
output_1.output.note({ title: 'Recalculating project graph...' });
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
420
|
+
const { projectGraphClientResponse, sourceMapResponse } = await createProjectGraphAndSourceMapClientResponse();
|
|
421
|
+
if (projectGraphClientResponse.hash !==
|
|
422
|
+
currentProjectGraphClientResponse.hash &&
|
|
423
|
+
sourceMapResponse) {
|
|
392
424
|
output_1.output.note({ title: 'Graph changes updated.' });
|
|
393
|
-
|
|
425
|
+
currentProjectGraphClientResponse = projectGraphClientResponse;
|
|
426
|
+
currentSourceMapsClientResponse = sourceMapResponse;
|
|
394
427
|
}
|
|
395
428
|
else {
|
|
396
429
|
output_1.output.note({ title: 'No graph changes found.' });
|
|
@@ -398,9 +431,10 @@ function createFileWatcher() {
|
|
|
398
431
|
}
|
|
399
432
|
}, 500));
|
|
400
433
|
}
|
|
401
|
-
async function
|
|
434
|
+
async function createProjectGraphAndSourceMapClientResponse(affected = []) {
|
|
402
435
|
perf_hooks_1.performance.mark('project graph watch calculation:start');
|
|
403
|
-
|
|
436
|
+
const { projectGraph, sourceMaps } = await (0, project_graph_1.createProjectGraphAndSourceMapsAsync)({ exitOnError: true });
|
|
437
|
+
let graph = (0, operators_1.pruneExternalNodes)(projectGraph);
|
|
404
438
|
let fileMap = (0, nx_deps_cache_1.readFileMapCache)().fileMap.projectFileMap;
|
|
405
439
|
perf_hooks_1.performance.mark('project graph watch calculation:end');
|
|
406
440
|
perf_hooks_1.performance.mark('project graph response generation:start');
|
|
@@ -408,19 +442,22 @@ async function createDepGraphClientResponse(affected = []) {
|
|
|
408
442
|
const projects = Object.values(graph.nodes);
|
|
409
443
|
const dependencies = graph.dependencies;
|
|
410
444
|
const hasher = (0, crypto_1.createHash)('sha256');
|
|
411
|
-
hasher.update(JSON.stringify({ layout, projects, dependencies }));
|
|
445
|
+
hasher.update(JSON.stringify({ layout, projects, dependencies, sourceMaps }));
|
|
412
446
|
const hash = hasher.digest('hex');
|
|
413
447
|
perf_hooks_1.performance.mark('project graph response generation:end');
|
|
414
448
|
perf_hooks_1.performance.measure('project graph watch calculation', 'project graph watch calculation:start', 'project graph watch calculation:end');
|
|
415
449
|
perf_hooks_1.performance.measure('project graph response generation', 'project graph response generation:start', 'project graph response generation:end');
|
|
416
450
|
return {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
451
|
+
projectGraphClientResponse: {
|
|
452
|
+
...currentProjectGraphClientResponse,
|
|
453
|
+
hash,
|
|
454
|
+
layout,
|
|
455
|
+
projects,
|
|
456
|
+
dependencies,
|
|
457
|
+
affected,
|
|
458
|
+
fileMap,
|
|
459
|
+
},
|
|
460
|
+
sourceMapResponse: sourceMaps,
|
|
424
461
|
};
|
|
425
462
|
}
|
|
426
463
|
async function createTaskGraphClientResponse(pruneExternal = false) {
|
|
@@ -435,7 +472,7 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
|
|
|
435
472
|
perf_hooks_1.performance.mark('task graph generation:start');
|
|
436
473
|
const taskGraphs = getAllTaskGraphsForWorkspace(nxJson, graph);
|
|
437
474
|
perf_hooks_1.performance.mark('task graph generation:end');
|
|
438
|
-
const planner = new native_1.HashPlanner(
|
|
475
|
+
const planner = new native_1.HashPlanner(nxJson, (0, native_1.transferProjectGraph)((0, transform_objects_1.transformProjectGraphForRust)(graph)));
|
|
439
476
|
perf_hooks_1.performance.mark('task hash plan generation:start');
|
|
440
477
|
const plans = {};
|
|
441
478
|
for (const individualTaskGraph of Object.values(taskGraphs.taskGraphs)) {
|
|
@@ -523,7 +560,7 @@ async function getExpandedTaskInputs(taskId) {
|
|
|
523
560
|
const allWorkspaceFiles = await (0, all_file_data_1.allFileData)();
|
|
524
561
|
const inputs = taskGraphResponse.plans[taskId];
|
|
525
562
|
if (inputs) {
|
|
526
|
-
return expandInputs(inputs,
|
|
563
|
+
return expandInputs(inputs, currentProjectGraphClientResponse.projects.find((p) => p.name === project), allWorkspaceFiles, currentProjectGraphClientResponse);
|
|
527
564
|
}
|
|
528
565
|
return {};
|
|
529
566
|
}
|
|
@@ -564,7 +601,7 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
|
|
|
564
601
|
}
|
|
565
602
|
else {
|
|
566
603
|
allWorkspaceFiles
|
|
567
|
-
.filter((f) => minimatch(f.file, withoutWorkspaceRoot))
|
|
604
|
+
.filter((f) => (0, minimatch_1.minimatch)(f.file, withoutWorkspaceRoot))
|
|
568
605
|
.forEach((f) => {
|
|
569
606
|
matches.push(f.file);
|
|
570
607
|
});
|
|
@@ -603,14 +640,22 @@ function expandInputs(inputs, project, allWorkspaceFiles, depGraphClientResponse
|
|
|
603
640
|
external: externalInputs,
|
|
604
641
|
};
|
|
605
642
|
}
|
|
606
|
-
function createJsonOutput(
|
|
643
|
+
async function createJsonOutput(prunedGraph, rawGraph, projects, targets) {
|
|
607
644
|
const response = {
|
|
608
|
-
graph,
|
|
645
|
+
graph: prunedGraph,
|
|
609
646
|
};
|
|
610
647
|
if (targets?.length) {
|
|
611
648
|
const nxJson = (0, configuration_1.readNxJson)();
|
|
612
649
|
const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
|
|
613
|
-
|
|
650
|
+
const taskGraph = (0, create_task_graph_1.createTaskGraph)(rawGraph, defaultDependencyConfigs, projects, targets, undefined, {});
|
|
651
|
+
const hasher = (0, create_task_hasher_1.createTaskHasher)(rawGraph, (0, configuration_1.readNxJson)());
|
|
652
|
+
let tasks = Object.values(taskGraph.tasks);
|
|
653
|
+
const hashes = await hasher.hashTasks(tasks, taskGraph);
|
|
654
|
+
response.tasks = taskGraph;
|
|
655
|
+
response.taskPlans = tasks.reduce((acc, task, index) => {
|
|
656
|
+
acc[task.id] = Object.keys(hashes[index].details.nodes).sort();
|
|
657
|
+
return acc;
|
|
658
|
+
}, {});
|
|
614
659
|
}
|
|
615
660
|
return response;
|
|
616
661
|
}
|
|
@@ -2,55 +2,82 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.yargsInitCommand = void 0;
|
|
4
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
|
5
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
6
|
+
const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
|
7
|
+
(0, nx_json_1.readNxJson)().useInferencePlugins !== false;
|
|
5
8
|
exports.yargsInitCommand = {
|
|
6
9
|
command: 'init',
|
|
7
|
-
describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up
|
|
10
|
+
describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
|
|
8
11
|
builder: (yargs) => withInitOptions(yargs),
|
|
9
12
|
handler: async (args) => {
|
|
10
|
-
|
|
13
|
+
if (useV2) {
|
|
14
|
+
await require('./init-v2').initHandler(args);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
await require('./init-v1').initHandler(args);
|
|
18
|
+
}
|
|
11
19
|
process.exit(0);
|
|
12
20
|
},
|
|
13
21
|
};
|
|
14
22
|
function withInitOptions(yargs) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
23
|
+
if (useV2) {
|
|
24
|
+
return yargs
|
|
25
|
+
.option('nxCloud', {
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
description: 'Set up distributed caching with Nx Cloud.',
|
|
28
|
+
})
|
|
29
|
+
.option('interactive', {
|
|
30
|
+
describe: 'When false disables interactive input prompts for options.',
|
|
31
|
+
type: 'boolean',
|
|
32
|
+
default: true,
|
|
33
|
+
})
|
|
34
|
+
.option('useDotNxInstallation', {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
|
|
37
|
+
default: false,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return yargs
|
|
42
|
+
.option('nxCloud', {
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
description: 'Set up remote caching with Nx Cloud.',
|
|
45
|
+
})
|
|
46
|
+
.option('interactive', {
|
|
47
|
+
describe: 'When false disables interactive input prompts for options.',
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
default: true,
|
|
50
|
+
})
|
|
51
|
+
.option('integrated', {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
description: 'Migrate to an Nx integrated layout workspace. Only for Angular CLI workspaces and CRA projects.',
|
|
54
|
+
default: false,
|
|
55
|
+
})
|
|
56
|
+
.option('addE2e', {
|
|
57
|
+
describe: 'Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.',
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
default: false,
|
|
60
|
+
})
|
|
61
|
+
.option('useDotNxInstallation', {
|
|
62
|
+
type: 'boolean',
|
|
63
|
+
description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
|
|
64
|
+
default: false,
|
|
65
|
+
})
|
|
66
|
+
.option('force', {
|
|
67
|
+
describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
|
|
68
|
+
type: 'boolean',
|
|
69
|
+
default: false,
|
|
70
|
+
})
|
|
71
|
+
.option('vite', {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
description: 'Use Vite as the bundler. Only for CRA projects.',
|
|
74
|
+
default: true,
|
|
75
|
+
})
|
|
76
|
+
.option('cacheable', {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'Comma-separated list of cacheable operations. Only used for internal testing.',
|
|
79
|
+
coerce: shared_options_1.parseCSV,
|
|
80
|
+
hidden: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
56
83
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { InitArgs } from '../init';
|
|
2
|
-
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'
|
|
1
|
+
import { InitArgs } from '../init-v1';
|
|
2
|
+
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
|
3
|
+
legacy?: boolean;
|
|
4
|
+
};
|
|
3
5
|
export declare function addNxToMonorepo(options: Options): Promise<void>;
|
|
4
6
|
export {};
|
|
@@ -9,6 +9,7 @@ const fileutils_1 = require("../../../utils/fileutils");
|
|
|
9
9
|
const output_1 = require("../../../utils/output");
|
|
10
10
|
const package_manager_1 = require("../../../utils/package-manager");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
|
|
12
13
|
async function addNxToMonorepo(options) {
|
|
13
14
|
const repoRoot = process.cwd();
|
|
14
15
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
|
@@ -47,16 +48,24 @@ async function addNxToMonorepo(options) {
|
|
|
47
48
|
},
|
|
48
49
|
]))[scriptName];
|
|
49
50
|
}
|
|
50
|
-
useNxCloud =
|
|
51
|
+
useNxCloud =
|
|
52
|
+
options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
|
|
51
53
|
}
|
|
52
54
|
else {
|
|
53
55
|
targetDefaults = [];
|
|
54
56
|
cacheableOperations = options.cacheable ?? [];
|
|
55
57
|
useNxCloud =
|
|
56
58
|
options.nxCloud ??
|
|
57
|
-
(options.interactive
|
|
59
|
+
(options.interactive
|
|
60
|
+
? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
|
|
61
|
+
: false);
|
|
58
62
|
}
|
|
59
63
|
(0, utils_1.createNxJsonFile)(repoRoot, targetDefaults, cacheableOperations, scriptOutputs);
|
|
64
|
+
if (!options.legacy) {
|
|
65
|
+
packageJsonFiles.forEach((packageJsonPath) => {
|
|
66
|
+
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, packageJsonPath), cacheableOperations);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
60
69
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
61
70
|
(0, utils_1.addDepsToPackageJson)(repoRoot);
|
|
62
71
|
output_1.output.log({ title: '📦 Installing dependencies' });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InitArgs } from '../init';
|
|
1
|
+
import { InitArgs } from '../init-v1';
|
|
2
2
|
import { PackageJson } from '../../../utils/package-json';
|
|
3
3
|
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'>;
|
|
4
4
|
export declare function addNxToNest(options: Options, packageJson: PackageJson): Promise<void>;
|
|
@@ -9,6 +9,7 @@ const output_1 = require("../../../utils/output");
|
|
|
9
9
|
const package_manager_1 = require("../../../utils/package-manager");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
const versions_1 = require("../../../utils/versions");
|
|
12
|
+
const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
|
|
12
13
|
async function addNxToNest(options, packageJson) {
|
|
13
14
|
const repoRoot = process.cwd();
|
|
14
15
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
|
@@ -61,20 +62,23 @@ async function addNxToNest(options, packageJson) {
|
|
|
61
62
|
},
|
|
62
63
|
]))[scriptName];
|
|
63
64
|
}
|
|
64
|
-
useNxCloud =
|
|
65
|
+
useNxCloud =
|
|
66
|
+
options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
|
|
65
67
|
}
|
|
66
68
|
else {
|
|
67
69
|
cacheableOperations = options.cacheable ?? [];
|
|
68
70
|
useNxCloud =
|
|
69
71
|
options.nxCloud ??
|
|
70
|
-
(options.interactive
|
|
72
|
+
(options.interactive
|
|
73
|
+
? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
|
|
74
|
+
: false);
|
|
71
75
|
}
|
|
72
|
-
(0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts],
|
|
76
|
+
(0, utils_1.createNxJsonFile)(repoRoot, [], [...cacheableOperations, ...nestCacheableScripts], scriptOutputs);
|
|
73
77
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
|
74
78
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
75
79
|
(0, utils_1.addDepsToPackageJson)(repoRoot);
|
|
76
80
|
addNestPluginToPackageJson(repoRoot);
|
|
77
|
-
(0, utils_1.
|
|
81
|
+
(0, utils_1.markRootPackageJsonAsNxProjectLegacy)(repoRoot, cacheableOperations, pmc);
|
|
78
82
|
createProjectJson(repoRoot, packageJson, nestCLIConfiguration);
|
|
79
83
|
removeFile(repoRoot, 'nest-cli.json');
|
|
80
84
|
updatePackageJsonScripts(repoRoot, isJS);
|
|
@@ -171,9 +175,8 @@ function createProjectJson(repoRoot, packageJson, nestCLIOptions) {
|
|
|
171
175
|
// lint
|
|
172
176
|
json.targets['lint'] = {
|
|
173
177
|
executor: '@nx/eslint:lint',
|
|
174
|
-
outputs: ['{options.outputFile}'],
|
|
175
178
|
options: {
|
|
176
|
-
lintFilePatterns: ['src
|
|
179
|
+
lintFilePatterns: ['./src', './test'],
|
|
177
180
|
},
|
|
178
181
|
};
|
|
179
182
|
// test and e2e
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { InitArgs } from '../init';
|
|
2
|
-
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'
|
|
1
|
+
import { InitArgs } from '../init-v1';
|
|
2
|
+
type Options = Pick<InitArgs, 'nxCloud' | 'interactive' | 'cacheable'> & {
|
|
3
|
+
legacy?: boolean;
|
|
4
|
+
};
|
|
3
5
|
export declare function addNxToNpmRepo(options: Options): Promise<void>;
|
|
4
6
|
export {};
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addNxToNpmRepo = void 0;
|
|
4
4
|
const enquirer = require("enquirer");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
6
7
|
const output_1 = require("../../../utils/output");
|
|
7
8
|
const package_manager_1 = require("../../../utils/package-manager");
|
|
8
9
|
const utils_1 = require("./utils");
|
|
10
|
+
const connect_to_nx_cloud_1 = require("../../connect/connect-to-nx-cloud");
|
|
9
11
|
async function addNxToNpmRepo(options) {
|
|
10
12
|
const repoRoot = process.cwd();
|
|
11
13
|
output_1.output.log({ title: '🐳 Nx initialization' });
|
|
@@ -36,19 +38,27 @@ async function addNxToNpmRepo(options) {
|
|
|
36
38
|
},
|
|
37
39
|
]))[scriptName];
|
|
38
40
|
}
|
|
39
|
-
useNxCloud =
|
|
41
|
+
useNxCloud =
|
|
42
|
+
options.nxCloud ?? (await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)());
|
|
40
43
|
}
|
|
41
44
|
else {
|
|
42
45
|
cacheableOperations = options.cacheable ?? [];
|
|
43
46
|
useNxCloud =
|
|
44
47
|
options.nxCloud ??
|
|
45
|
-
(options.interactive
|
|
48
|
+
(options.interactive
|
|
49
|
+
? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)()
|
|
50
|
+
: false);
|
|
46
51
|
}
|
|
47
|
-
(0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations,
|
|
52
|
+
(0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, scriptOutputs);
|
|
48
53
|
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
|
49
54
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
50
55
|
(0, utils_1.addDepsToPackageJson)(repoRoot);
|
|
51
|
-
(
|
|
56
|
+
if (options.legacy) {
|
|
57
|
+
(0, utils_1.markRootPackageJsonAsNxProjectLegacy)(repoRoot, cacheableOperations, pmc);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, 'package.json'), cacheableOperations);
|
|
61
|
+
}
|
|
52
62
|
output_1.output.log({ title: '📦 Installing dependencies' });
|
|
53
63
|
(0, utils_1.runInstall)(repoRoot, pmc);
|
|
54
64
|
if (useNxCloud) {
|
|
@@ -11,6 +11,7 @@ const utils_1 = require("../utils");
|
|
|
11
11
|
const integrated_workspace_1 = require("./integrated-workspace");
|
|
12
12
|
const legacy_angular_versions_1 = require("./legacy-angular-versions");
|
|
13
13
|
const standalone_workspace_1 = require("./standalone-workspace");
|
|
14
|
+
const connect_to_nx_cloud_1 = require("../../../connect/connect-to-nx-cloud");
|
|
14
15
|
const defaultCacheableOperations = [
|
|
15
16
|
'build',
|
|
16
17
|
'server',
|
|
@@ -35,7 +36,8 @@ async function addNxToAngularCliRepo(options) {
|
|
|
35
36
|
const cacheableOperations = !options.integrated
|
|
36
37
|
? await collectCacheableOperations(options)
|
|
37
38
|
: [];
|
|
38
|
-
const useNxCloud = options.nxCloud ??
|
|
39
|
+
const useNxCloud = options.nxCloud ??
|
|
40
|
+
(options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
|
|
39
41
|
output_1.output.log({ title: '📦 Installing dependencies' });
|
|
40
42
|
installDependencies();
|
|
41
43
|
output_1.output.log({ title: '📝 Setting up workspace' });
|
|
@@ -106,6 +108,7 @@ function addPluginDependencies() {
|
|
|
106
108
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
107
109
|
}
|
|
108
110
|
async function setupWorkspace(cacheableOperations, isIntegratedMigration) {
|
|
111
|
+
(0, utils_1.updateGitIgnore)(repoRoot);
|
|
109
112
|
if (isIntegratedMigration) {
|
|
110
113
|
(0, integrated_workspace_1.setupIntegratedWorkspace)();
|
|
111
114
|
}
|