nx 23.0.0-beta.2 → 23.0.0-beta.21
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/dist/bin/init-local.js +11 -20
- package/dist/bin/nx.d.ts +1 -0
- package/dist/bin/nx.js +28 -2
- package/dist/plugins/package-json.js +4 -2
- package/dist/src/adapter/ngcli-adapter.d.ts +2 -1
- package/dist/src/adapter/ngcli-adapter.js +25 -2
- package/dist/src/ai/clone-ai-config-repo.js +20 -3
- package/dist/src/analytics/analytics.js +10 -1
- package/dist/src/command-line/add/completion.d.ts +1 -0
- package/dist/src/command-line/add/completion.js +15 -0
- package/dist/src/command-line/affected/completion.d.ts +1 -0
- package/dist/src/command-line/affected/completion.js +15 -0
- package/dist/src/command-line/completion/argv-layout.d.ts +6 -0
- package/dist/src/command-line/completion/argv-layout.js +19 -0
- package/dist/src/command-line/completion/command-completions.d.ts +19 -0
- package/dist/src/command-line/completion/command-completions.js +120 -0
- package/dist/src/command-line/completion/command-handlers.d.ts +30 -0
- package/dist/src/command-line/completion/command-handlers.js +69 -0
- package/dist/src/command-line/completion/command-object.d.ts +10 -0
- package/dist/src/command-line/completion/command-object.js +95 -0
- package/dist/src/command-line/completion/completion-providers.d.ts +21 -0
- package/dist/src/command-line/completion/completion-providers.js +194 -0
- package/dist/src/command-line/completion/infix-targets.d.ts +1 -0
- package/dist/src/command-line/completion/infix-targets.js +48 -0
- package/dist/src/command-line/completion/metadata.d.ts +22 -0
- package/dist/src/command-line/completion/metadata.js +71 -0
- package/dist/src/command-line/completion/registrations.d.ts +9 -0
- package/dist/src/command-line/completion/registrations.js +16 -0
- package/dist/src/command-line/completion/scripts/bash.sh +51 -0
- package/dist/src/command-line/completion/scripts/fish.fish +47 -0
- package/dist/src/command-line/completion/scripts/powershell.ps1 +52 -0
- package/dist/src/command-line/completion/scripts/zsh.zsh +69 -0
- package/dist/src/command-line/completion/scripts.d.ts +18 -0
- package/dist/src/command-line/completion/scripts.js +140 -0
- package/dist/src/command-line/completion/trigger.d.ts +3 -0
- package/dist/src/command-line/completion/trigger.js +21 -0
- package/dist/src/command-line/completion/value-completions.d.ts +3 -0
- package/dist/src/command-line/completion/value-completions.js +21 -0
- package/dist/src/command-line/examples.js +1 -1
- package/dist/src/command-line/format/format.js +15 -5
- package/dist/src/command-line/generate/completion.d.ts +1 -0
- package/dist/src/command-line/generate/completion.js +9 -0
- package/dist/src/command-line/graph/completion.d.ts +1 -0
- package/dist/src/command-line/graph/completion.js +13 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +14 -18
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +1 -0
- package/dist/src/command-line/init/implementation/utils.d.ts +7 -1
- package/dist/src/command-line/init/implementation/utils.js +51 -14
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +22 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +100 -0
- package/dist/src/command-line/migrate/agentic/cli-args.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/cli-args.js +38 -0
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +6 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +98 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/detect-installed.js +68 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +46 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +87 -0
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +63 -0
- package/dist/src/command-line/migrate/agentic/handoff.js +183 -0
- package/dist/src/command-line/migrate/agentic/inception.d.ts +9 -0
- package/dist/src/command-line/migrate/agentic/inception.js +15 -0
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +22 -0
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +50 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +51 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +65 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +44 -0
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +52 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +26 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +18 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +130 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +46 -0
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +88 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +51 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +121 -0
- package/dist/src/command-line/migrate/agentic/runner.d.ts +33 -0
- package/dist/src/command-line/migrate/agentic/runner.js +442 -0
- package/dist/src/command-line/migrate/agentic/select.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/select.js +150 -0
- package/dist/src/command-line/migrate/agentic/types.d.ts +102 -0
- package/dist/src/command-line/migrate/agentic/types.js +2 -0
- package/dist/src/command-line/migrate/command-object.d.ts +1 -0
- package/dist/src/command-line/migrate/command-object.js +32 -7
- package/dist/src/command-line/migrate/migrate-commits.d.ts +50 -0
- package/dist/src/command-line/migrate/migrate-commits.js +102 -0
- package/dist/src/command-line/migrate/migrate-output.d.ts +180 -0
- package/dist/src/command-line/migrate/migrate-output.js +258 -0
- package/dist/src/command-line/migrate/migrate.d.ts +122 -12
- package/dist/src/command-line/migrate/migrate.js +1036 -217
- package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
- package/dist/src/command-line/migrate/migration-shape.js +13 -0
- package/dist/src/command-line/migrate/multi-major.d.ts +30 -0
- package/dist/src/command-line/migrate/multi-major.js +185 -0
- package/dist/src/command-line/migrate/prompt-files.d.ts +31 -0
- package/dist/src/command-line/migrate/prompt-files.js +141 -0
- package/dist/src/command-line/migrate/run-migration-process.js +28 -6
- package/dist/src/command-line/migrate/safe-prompt.d.ts +28 -0
- package/dist/src/command-line/migrate/safe-prompt.js +49 -0
- package/dist/src/command-line/migrate/update-filters.d.ts +11 -0
- package/dist/src/command-line/migrate/update-filters.js +44 -0
- package/dist/src/command-line/migrate/version-utils.d.ts +6 -0
- package/dist/src/command-line/migrate/version-utils.js +59 -0
- package/dist/src/command-line/nx-commands.js +9 -0
- package/dist/src/command-line/release/config/config.d.ts +3 -6
- package/dist/src/command-line/release/config/config.js +77 -45
- package/dist/src/command-line/release/config/use-legacy-versioning.d.ts +2 -0
- package/dist/src/command-line/release/config/use-legacy-versioning.js +8 -0
- package/dist/src/command-line/release/utils/release-graph.js +2 -3
- package/dist/src/command-line/release/utils/repository-git-tags.js +1 -1
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +7 -19
- package/dist/src/command-line/release/version/resolve-current-version.js +1 -1
- package/dist/src/command-line/release/version/version-actions.js +3 -7
- package/dist/src/command-line/report/report.js +2 -2
- package/dist/src/command-line/run/completion.d.ts +1 -0
- package/dist/src/command-line/run/completion.js +7 -0
- package/dist/src/command-line/run-many/completion.d.ts +1 -0
- package/dist/src/command-line/run-many/completion.js +13 -0
- package/dist/src/command-line/show/completion.d.ts +1 -0
- package/dist/src/command-line/show/completion.js +27 -0
- package/dist/src/command-line/show/show-target/info.d.ts +1 -0
- package/dist/src/command-line/show/show-target/info.js +100 -19
- package/dist/src/command-line/watch/command-object.js +24 -4
- package/dist/src/command-line/watch/completion.d.ts +1 -0
- package/dist/src/command-line/watch/completion.js +10 -0
- package/dist/src/command-line/watch/watch.d.ts +7 -0
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/config/misc-interfaces.d.ts +25 -2
- package/dist/src/config/nx-json.d.ts +43 -56
- package/dist/src/config/schema-utils.d.ts +21 -0
- package/dist/src/config/schema-utils.js +92 -18
- package/dist/src/config/task-graph.d.ts +4 -107
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.css +2 -3
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +1 -1
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +1 -1
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +1 -1
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +9 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +76 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +45 -11
- package/dist/src/daemon/server/server.js +4 -43
- package/dist/src/daemon/server/start.d.ts +1 -1
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/devkit-exports.d.ts +2 -2
- package/dist/src/devkit-internals.d.ts +5 -1
- package/dist/src/devkit-internals.js +17 -1
- package/dist/src/executors/run-commands/running-tasks.d.ts +7 -0
- package/dist/src/executors/run-commands/running-tasks.js +178 -105
- package/dist/src/executors/run-script/run-script.impl.js +3 -10
- package/dist/src/executors/utils/convert-nx-executor.js +1 -1
- package/dist/src/hasher/hash-plan-inspector.d.ts +1 -1
- package/dist/src/hasher/task-hasher.js +6 -4
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +0 -3
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +6 -2
- package/dist/src/migrations/update-17-0-0/move-cache-directory.md +31 -0
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +20 -4
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.md +27 -0
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.md +24 -0
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.md +49 -0
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.md +54 -0
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.md +28 -0
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.md +22 -0
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.md +11 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.d.ts +2 -0
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +16 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +9 -0
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +18 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.d.ts +35 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.js +139 -0
- package/dist/src/migrations/update-23-0-0/convert-target-defaults-to-array.md +66 -0
- package/dist/src/native/index.d.ts +79 -2
- package/dist/src/native/native-bindings.js +3 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/npm-parser.js +37 -19
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +51 -4
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +12 -4
- package/dist/src/plugins/js/utils/packages.js +1 -1
- package/dist/src/plugins/js/utils/register.d.ts +103 -14
- package/dist/src/plugins/js/utils/register.js +434 -39
- package/dist/src/plugins/js/utils/typescript.d.ts +7 -0
- package/dist/src/plugins/js/utils/typescript.js +39 -0
- package/dist/src/plugins/package-json/create-nodes.d.ts +3 -2
- package/dist/src/plugins/package-json/create-nodes.js +7 -5
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +2 -1
- package/dist/src/project-graph/build-project-graph.d.ts +5 -0
- package/dist/src/project-graph/build-project-graph.js +6 -2
- package/dist/src/project-graph/file-map-utils.d.ts +5 -0
- package/dist/src/project-graph/file-map-utils.js +10 -1
- package/dist/src/project-graph/plugins/get-plugins.d.ts +7 -2
- package/dist/src/project-graph/plugins/get-plugins.js +8 -5
- package/dist/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +2 -0
- package/dist/src/project-graph/plugins/resolve-plugin.d.ts +7 -4
- package/dist/src/project-graph/plugins/resolve-plugin.js +152 -33
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +4 -2
- package/dist/src/project-graph/plugins/transpiler.d.ts +12 -0
- package/dist/src/project-graph/plugins/transpiler.js +37 -0
- package/dist/src/project-graph/plugins/utils.js +13 -7
- package/dist/src/project-graph/project-graph.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +95 -4
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +515 -68
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +13 -5
- package/dist/src/project-graph/utils/project-configuration-utils.js +14 -6
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +1 -1
- package/dist/src/tasks-runner/create-task-graph.d.ts +4 -4
- package/dist/src/tasks-runner/create-task-graph.js +1 -1
- package/dist/src/tasks-runner/default-tasks-runner.d.ts +0 -2
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +11 -6
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +0 -15
- package/dist/src/tasks-runner/init-tasks-runner.js +0 -63
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +18 -0
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +109 -0
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -8
- package/dist/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.js +6 -6
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle-old.js +13 -2
- package/dist/src/tasks-runner/life-cycles/task-history-life-cycle.js +16 -5
- package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +11 -2
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
- package/dist/src/tasks-runner/run-command.js +8 -11
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +1 -1
- package/dist/src/tasks-runner/running-tasks/batch-process.js +3 -5
- package/dist/src/tasks-runner/running-tasks/node-child-process.d.ts +2 -2
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -7
- package/dist/src/tasks-runner/task-env.d.ts +1 -1
- package/dist/src/tasks-runner/task-env.js +6 -1
- package/dist/src/tasks-runner/task-orchestrator.d.ts +11 -1
- package/dist/src/tasks-runner/task-orchestrator.js +112 -38
- package/dist/src/tasks-runner/tasks-schedule.js +3 -3
- package/dist/src/tasks-runner/utils.d.ts +7 -8
- package/dist/src/tasks-runner/utils.js +23 -27
- package/dist/src/utils/child-process.js +2 -2
- package/dist/src/utils/compile-cache.d.ts +24 -0
- package/dist/src/utils/compile-cache.js +49 -0
- package/dist/src/utils/enable-compile-cache.d.ts +1 -0
- package/dist/src/utils/enable-compile-cache.js +7 -0
- package/dist/src/utils/fileutils.d.ts +0 -8
- package/dist/src/utils/fileutils.js +0 -40
- package/dist/src/utils/git-utils.d.ts +15 -0
- package/dist/src/utils/git-utils.js +138 -0
- package/dist/src/utils/handle-import.d.ts +4 -1
- package/dist/src/utils/handle-import.js +56 -2
- package/dist/src/utils/has-nx-js-plugin.d.ts +9 -0
- package/dist/src/utils/has-nx-js-plugin.js +24 -0
- package/dist/src/utils/installed-nx-version.d.ts +14 -4
- package/dist/src/utils/installed-nx-version.js +54 -7
- package/dist/src/utils/logger.d.ts +12 -1
- package/dist/src/utils/logger.js +57 -36
- package/dist/src/utils/nx-key.d.ts +0 -1
- package/dist/src/utils/nx-key.js +20 -23
- package/dist/src/utils/nx-package-group.d.ts +8 -0
- package/dist/src/utils/nx-package-group.js +15 -0
- package/dist/src/utils/output.d.ts +3 -2
- package/dist/src/utils/output.js +29 -28
- package/dist/src/utils/package-json.d.ts +14 -1
- package/dist/src/utils/package-json.js +20 -21
- package/dist/src/utils/perf-logging.js +3 -1
- package/dist/src/utils/plugin-cache-utils.d.ts +13 -4
- package/dist/src/utils/plugin-cache-utils.js +23 -13
- package/dist/src/utils/plugins/local-plugins.d.ts +18 -0
- package/dist/src/utils/plugins/local-plugins.js +30 -0
- package/dist/src/utils/tar.d.ts +8 -0
- package/dist/src/utils/tar.js +44 -0
- package/migrations.json +16 -0
- package/package.json +28 -28
- package/schemas/nx-schema.json +114 -80
- package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.d.ts +0 -7
- package/dist/src/plugins/js/project-graph/build-dependencies/strip-source-code.js +0 -155
- package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.d.ts +0 -16
- package/dist/src/plugins/js/project-graph/build-dependencies/typescript-import-locator.js +0 -121
|
@@ -13,8 +13,8 @@ const exit_codes_1 = require("./exit-codes");
|
|
|
13
13
|
function getRunNxBaseCommand(packageManagerCommand, cwd = process.cwd()) {
|
|
14
14
|
if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'))) {
|
|
15
15
|
if (!packageManagerCommand) {
|
|
16
|
-
const pm = (0, package_manager_1.detectPackageManager)();
|
|
17
|
-
packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)(pm);
|
|
16
|
+
const pm = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
|
|
17
|
+
packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)(pm, workspace_root_1.workspaceRoot);
|
|
18
18
|
}
|
|
19
19
|
return `${packageManagerCommand.exec} nx`;
|
|
20
20
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enables V8's on-disk bytecode cache for the current process.
|
|
3
|
+
*
|
|
4
|
+
* Calls `module.enableCompileCache()` with no arguments and lets Node pick
|
|
5
|
+
* the location, which means Node's standard env vars work transparently:
|
|
6
|
+
* - `NODE_COMPILE_CACHE=<dir>` — override the cache directory.
|
|
7
|
+
* - `NODE_DISABLE_COMPILE_CACHE=1` — disable entirely.
|
|
8
|
+
*
|
|
9
|
+
* The default location lives under the OS temp dir keyed by V8 version, so
|
|
10
|
+
* the cache is shared across workspaces and self-invalidates on Node
|
|
11
|
+
* upgrades — no nx-specific cleanup needed.
|
|
12
|
+
*
|
|
13
|
+
* Called at the entry point of every long-lived nx process (main CLI,
|
|
14
|
+
* daemon, plugin workers) via `enable-compile-cache.ts`, which side-effects
|
|
15
|
+
* this on import.
|
|
16
|
+
*
|
|
17
|
+
* Set `NX_COMPILE_CACHE=false` to opt out without disabling the cache for
|
|
18
|
+
* non-nx Node processes the way `NODE_DISABLE_COMPILE_CACHE` would.
|
|
19
|
+
*
|
|
20
|
+
* No-op on Node versions without the `module.enableCompileCache` API.
|
|
21
|
+
* Errors are swallowed — the compile cache is a pure performance
|
|
22
|
+
* optimization and must never break the CLI.
|
|
23
|
+
*/
|
|
24
|
+
export declare function enableCompileCache(...override: [unknown?]): boolean;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableCompileCache = enableCompileCache;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const nodeModule = tslib_1.__importStar(require("node:module"));
|
|
6
|
+
/**
|
|
7
|
+
* Enables V8's on-disk bytecode cache for the current process.
|
|
8
|
+
*
|
|
9
|
+
* Calls `module.enableCompileCache()` with no arguments and lets Node pick
|
|
10
|
+
* the location, which means Node's standard env vars work transparently:
|
|
11
|
+
* - `NODE_COMPILE_CACHE=<dir>` — override the cache directory.
|
|
12
|
+
* - `NODE_DISABLE_COMPILE_CACHE=1` — disable entirely.
|
|
13
|
+
*
|
|
14
|
+
* The default location lives under the OS temp dir keyed by V8 version, so
|
|
15
|
+
* the cache is shared across workspaces and self-invalidates on Node
|
|
16
|
+
* upgrades — no nx-specific cleanup needed.
|
|
17
|
+
*
|
|
18
|
+
* Called at the entry point of every long-lived nx process (main CLI,
|
|
19
|
+
* daemon, plugin workers) via `enable-compile-cache.ts`, which side-effects
|
|
20
|
+
* this on import.
|
|
21
|
+
*
|
|
22
|
+
* Set `NX_COMPILE_CACHE=false` to opt out without disabling the cache for
|
|
23
|
+
* non-nx Node processes the way `NODE_DISABLE_COMPILE_CACHE` would.
|
|
24
|
+
*
|
|
25
|
+
* No-op on Node versions without the `module.enableCompileCache` API.
|
|
26
|
+
* Errors are swallowed — the compile cache is a pure performance
|
|
27
|
+
* optimization and must never break the CLI.
|
|
28
|
+
*/
|
|
29
|
+
function enableCompileCache(
|
|
30
|
+
// Test seam: production callers omit this. `unknown` (rather than
|
|
31
|
+
// `EnableCompileCacheFn | undefined`) lets tests pass a non-function to
|
|
32
|
+
// simulate pre-22.8 Node where `module.enableCompileCache` is missing. We
|
|
33
|
+
// read `arguments.length` so callers can *explicitly* pass `undefined`.
|
|
34
|
+
...override) {
|
|
35
|
+
if (process.env.NX_COMPILE_CACHE === 'false')
|
|
36
|
+
return false;
|
|
37
|
+
const impl = override.length === 0
|
|
38
|
+
? nodeModule.enableCompileCache
|
|
39
|
+
: override[0];
|
|
40
|
+
if (typeof impl !== 'function')
|
|
41
|
+
return false;
|
|
42
|
+
try {
|
|
43
|
+
impl();
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// Side-effect-only module: import this as the *first* import in any nx
|
|
4
|
+
// process entry point so V8's compile cache is enabled before the rest of
|
|
5
|
+
// the import chain (which is what we actually want to cache) starts loading.
|
|
6
|
+
const compile_cache_1 = require("./compile-cache");
|
|
7
|
+
(0, compile_cache_1.enableCompileCache)();
|
|
@@ -63,13 +63,5 @@ export declare function directoryExists(path: PathLike): boolean;
|
|
|
63
63
|
export declare function fileExists(path: PathLike): boolean;
|
|
64
64
|
export declare function createDirectory(path: PathLike): void;
|
|
65
65
|
export declare function isRelativePath(path: string): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Extracts a file from a given tarball to the specified destination.
|
|
68
|
-
* @param tarballPath The path to the tarball from where the file should be extracted.
|
|
69
|
-
* @param file The path to the file inside the tarball.
|
|
70
|
-
* @param destinationFilePath The destination file path.
|
|
71
|
-
* @returns True if the file was extracted successfully, false otherwise.
|
|
72
|
-
*/
|
|
73
|
-
export declare function extractFileFromTarball(tarballPath: string, file: string, destinationFilePath: string): Promise<string>;
|
|
74
66
|
export declare function readFileIfExisting(path: string): string;
|
|
75
67
|
export {};
|
|
@@ -8,15 +8,11 @@ exports.directoryExists = directoryExists;
|
|
|
8
8
|
exports.fileExists = fileExists;
|
|
9
9
|
exports.createDirectory = createDirectory;
|
|
10
10
|
exports.isRelativePath = isRelativePath;
|
|
11
|
-
exports.extractFileFromTarball = extractFileFromTarball;
|
|
12
11
|
exports.readFileIfExisting = readFileIfExisting;
|
|
13
|
-
const tslib_1 = require("tslib");
|
|
14
12
|
const json_1 = require("./json");
|
|
15
13
|
const node_fs_1 = require("node:fs");
|
|
16
14
|
const promises_1 = require("node:fs/promises");
|
|
17
15
|
const path_1 = require("path");
|
|
18
|
-
const tar = tslib_1.__importStar(require("tar-stream"));
|
|
19
|
-
const zlib_1 = require("zlib");
|
|
20
16
|
/**
|
|
21
17
|
* Reads a JSON file and returns the object the JSON content represents.
|
|
22
18
|
*
|
|
@@ -111,42 +107,6 @@ function isRelativePath(path) {
|
|
|
111
107
|
path.startsWith('./') ||
|
|
112
108
|
path.startsWith('../'));
|
|
113
109
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Extracts a file from a given tarball to the specified destination.
|
|
116
|
-
* @param tarballPath The path to the tarball from where the file should be extracted.
|
|
117
|
-
* @param file The path to the file inside the tarball.
|
|
118
|
-
* @param destinationFilePath The destination file path.
|
|
119
|
-
* @returns True if the file was extracted successfully, false otherwise.
|
|
120
|
-
*/
|
|
121
|
-
async function extractFileFromTarball(tarballPath, file, destinationFilePath) {
|
|
122
|
-
return new Promise((resolve, reject) => {
|
|
123
|
-
(0, node_fs_1.mkdirSync)((0, path_1.dirname)(destinationFilePath), { recursive: true });
|
|
124
|
-
var tarExtractStream = tar.extract();
|
|
125
|
-
const destinationFileStream = (0, node_fs_1.createWriteStream)(destinationFilePath);
|
|
126
|
-
let isFileExtracted = false;
|
|
127
|
-
tarExtractStream.on('entry', function (header, stream, next) {
|
|
128
|
-
if (header.name === file) {
|
|
129
|
-
stream.pipe(destinationFileStream);
|
|
130
|
-
stream.on('end', () => {
|
|
131
|
-
isFileExtracted = true;
|
|
132
|
-
});
|
|
133
|
-
destinationFileStream.on('close', () => {
|
|
134
|
-
resolve(destinationFilePath);
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
stream.on('end', function () {
|
|
138
|
-
next();
|
|
139
|
-
});
|
|
140
|
-
stream.resume();
|
|
141
|
-
});
|
|
142
|
-
tarExtractStream.on('finish', function () {
|
|
143
|
-
if (!isFileExtracted) {
|
|
144
|
-
reject();
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
(0, node_fs_1.createReadStream)(tarballPath).pipe((0, zlib_1.createGunzip)()).pipe(tarExtractStream);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
110
|
function readFileIfExisting(path) {
|
|
151
111
|
return (0, node_fs_1.existsSync)(path) ? (0, node_fs_1.readFileSync)(path, 'utf-8') : '';
|
|
152
112
|
}
|
|
@@ -38,5 +38,20 @@ export interface VcsRemoteInfo {
|
|
|
38
38
|
}
|
|
39
39
|
export declare function parseVcsRemoteUrl(url: string): VcsRemoteInfo | null;
|
|
40
40
|
export declare function getVcsRemoteInfo(directory?: string): VcsRemoteInfo | null;
|
|
41
|
+
export declare function isGitRepository(directory?: string): boolean;
|
|
42
|
+
export declare function hasUncommittedChanges(directory?: string): boolean;
|
|
43
|
+
export declare function getUncommittedChangesSnapshot(directory?: string): string;
|
|
41
44
|
export declare function commitChanges(commitMessage: string, directory?: string): string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Throws on git failure with the real stderr attached. Use this when the
|
|
47
|
+
* caller needs to distinguish hook rejection / GPG signing failures / LFS
|
|
48
|
+
* lock errors from a successful no-op. Callers should pre-check
|
|
49
|
+
* `hasUncommittedChanges` to avoid the "nothing to commit" rejection
|
|
50
|
+
* (which `git commit` exits non-zero for).
|
|
51
|
+
*
|
|
52
|
+
* Returns `null` (rather than throwing) when the commit itself succeeded
|
|
53
|
+
* but `git rev-parse HEAD` failed transiently — by contract the diff is
|
|
54
|
+
* no longer in the working tree, so callers must NOT report it as such.
|
|
55
|
+
*/
|
|
56
|
+
export declare function tryCommitChanges(commitMessage: string, directory: string): string | null;
|
|
42
57
|
export declare function getLatestCommitSha(directory?: string): string | null;
|
|
@@ -4,9 +4,16 @@ exports.GitRepository = void 0;
|
|
|
4
4
|
exports.cloneFromUpstream = cloneFromUpstream;
|
|
5
5
|
exports.parseVcsRemoteUrl = parseVcsRemoteUrl;
|
|
6
6
|
exports.getVcsRemoteInfo = getVcsRemoteInfo;
|
|
7
|
+
exports.isGitRepository = isGitRepository;
|
|
8
|
+
exports.hasUncommittedChanges = hasUncommittedChanges;
|
|
9
|
+
exports.getUncommittedChangesSnapshot = getUncommittedChangesSnapshot;
|
|
7
10
|
exports.commitChanges = commitChanges;
|
|
11
|
+
exports.tryCommitChanges = tryCommitChanges;
|
|
8
12
|
exports.getLatestCommitSha = getLatestCommitSha;
|
|
13
|
+
const tslib_1 = require("tslib");
|
|
9
14
|
const child_process_1 = require("child_process");
|
|
15
|
+
const crypto = tslib_1.__importStar(require("crypto"));
|
|
16
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
10
17
|
const path_1 = require("path");
|
|
11
18
|
const logger_1 = require("./logger");
|
|
12
19
|
function execAsync(command, execOptions) {
|
|
@@ -253,6 +260,97 @@ function getVcsRemoteInfo(directory) {
|
|
|
253
260
|
return null;
|
|
254
261
|
}
|
|
255
262
|
}
|
|
263
|
+
function isGitRepository(directory) {
|
|
264
|
+
try {
|
|
265
|
+
(0, child_process_1.execSync)('git rev-parse --is-inside-work-tree', {
|
|
266
|
+
stdio: 'ignore',
|
|
267
|
+
cwd: directory,
|
|
268
|
+
windowsHide: true,
|
|
269
|
+
});
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Sync companion to `GitRepository.hasUncommittedChanges` for callers that
|
|
277
|
+
// can't drop into the async class (e.g. the migrate orchestrator, which
|
|
278
|
+
// branches on this before spawning subprocesses synchronously).
|
|
279
|
+
function hasUncommittedChanges(directory) {
|
|
280
|
+
try {
|
|
281
|
+
const out = (0, child_process_1.execSync)('git status --porcelain', {
|
|
282
|
+
encoding: 'utf8',
|
|
283
|
+
cwd: directory,
|
|
284
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
285
|
+
windowsHide: true,
|
|
286
|
+
});
|
|
287
|
+
return out.trim() !== '';
|
|
288
|
+
}
|
|
289
|
+
catch {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// Returns a content-sensitive sha1 snapshot of the working tree state for
|
|
294
|
+
// before/after comparison. Hashes three probes:
|
|
295
|
+
// 1. `git diff HEAD` with defensive flags — every byte of tracked-file
|
|
296
|
+
// changes. `--no-ext-diff` / `--no-textconv` neuter user/repo driver
|
|
297
|
+
// overrides so output is deterministic; `--binary` keeps binary
|
|
298
|
+
// edits from collapsing to "Binary files differ".
|
|
299
|
+
// 2. `git status --porcelain=v1 -uall` — untracked paths the diff
|
|
300
|
+
// omits. `-uall` expands untracked directories per-file.
|
|
301
|
+
// 3. Untracked file content bytes — so a same-path content edit on an
|
|
302
|
+
// already-untracked file does not collapse against the baseline.
|
|
303
|
+
//
|
|
304
|
+
// Each probe is wrapped independently with a failure sentinel so a
|
|
305
|
+
// single-sided git error (e.g. `git diff HEAD` on an initial-commit-less
|
|
306
|
+
// repo) cannot mask surviving signal from the others.
|
|
307
|
+
function getUncommittedChangesSnapshot(directory) {
|
|
308
|
+
const hasher = crypto.createHash('sha1');
|
|
309
|
+
const cwd = directory ?? process.cwd();
|
|
310
|
+
const execOpts = {
|
|
311
|
+
encoding: 'utf8',
|
|
312
|
+
cwd,
|
|
313
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
314
|
+
windowsHide: true,
|
|
315
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
316
|
+
};
|
|
317
|
+
let diffOutput;
|
|
318
|
+
try {
|
|
319
|
+
diffOutput = (0, child_process_1.execSync)('git diff HEAD --no-color --no-ext-diff --no-textconv --binary', execOpts);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
diffOutput = '<diff-unavailable>';
|
|
323
|
+
}
|
|
324
|
+
hasher.update('diff:').update(diffOutput).update('\0');
|
|
325
|
+
let statusOutput;
|
|
326
|
+
try {
|
|
327
|
+
statusOutput = (0, child_process_1.execSync)('git status --porcelain=v1 -uall', execOpts);
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
statusOutput = '<status-unavailable>';
|
|
331
|
+
}
|
|
332
|
+
hasher.update('status:').update(statusOutput).update('\0');
|
|
333
|
+
let untrackedRaw;
|
|
334
|
+
try {
|
|
335
|
+
untrackedRaw = (0, child_process_1.execSync)('git ls-files --others --exclude-standard -z', execOpts);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
untrackedRaw = '';
|
|
339
|
+
}
|
|
340
|
+
const untrackedPaths = untrackedRaw.split('\0').filter(Boolean).sort();
|
|
341
|
+
hasher.update('untracked:');
|
|
342
|
+
for (const p of untrackedPaths) {
|
|
343
|
+
hasher.update(p).update('\0');
|
|
344
|
+
try {
|
|
345
|
+
hasher.update(fs.readFileSync((0, path_1.join)(cwd, p)));
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
hasher.update('<file-unreadable>');
|
|
349
|
+
}
|
|
350
|
+
hasher.update('\0');
|
|
351
|
+
}
|
|
352
|
+
return hasher.digest('hex');
|
|
353
|
+
}
|
|
256
354
|
function commitChanges(commitMessage, directory) {
|
|
257
355
|
try {
|
|
258
356
|
(0, child_process_1.execSync)('git add -A', {
|
|
@@ -283,6 +381,46 @@ function commitChanges(commitMessage, directory) {
|
|
|
283
381
|
}
|
|
284
382
|
return getLatestCommitSha(directory);
|
|
285
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Throws on git failure with the real stderr attached. Use this when the
|
|
386
|
+
* caller needs to distinguish hook rejection / GPG signing failures / LFS
|
|
387
|
+
* lock errors from a successful no-op. Callers should pre-check
|
|
388
|
+
* `hasUncommittedChanges` to avoid the "nothing to commit" rejection
|
|
389
|
+
* (which `git commit` exits non-zero for).
|
|
390
|
+
*
|
|
391
|
+
* Returns `null` (rather than throwing) when the commit itself succeeded
|
|
392
|
+
* but `git rev-parse HEAD` failed transiently — by contract the diff is
|
|
393
|
+
* no longer in the working tree, so callers must NOT report it as such.
|
|
394
|
+
*/
|
|
395
|
+
function tryCommitChanges(commitMessage, directory) {
|
|
396
|
+
try {
|
|
397
|
+
(0, child_process_1.execSync)('git add -A', {
|
|
398
|
+
encoding: 'utf8',
|
|
399
|
+
stdio: 'pipe',
|
|
400
|
+
cwd: directory,
|
|
401
|
+
windowsHide: true,
|
|
402
|
+
});
|
|
403
|
+
(0, child_process_1.execSync)('git commit --no-verify -F -', {
|
|
404
|
+
encoding: 'utf8',
|
|
405
|
+
stdio: 'pipe',
|
|
406
|
+
input: commitMessage,
|
|
407
|
+
cwd: directory,
|
|
408
|
+
windowsHide: true,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
catch (err) {
|
|
412
|
+
const stderr = err?.stderr?.toString();
|
|
413
|
+
const stdout = err?.stdout?.toString();
|
|
414
|
+
const detail = [stderr, stdout]
|
|
415
|
+
.map((s) => s?.trim())
|
|
416
|
+
.filter(Boolean)
|
|
417
|
+
.join('\n');
|
|
418
|
+
// `{ cause }` preserves structured fields (.signal, .status, .code)
|
|
419
|
+
// for callers to inspect; otherwise only stderr/stdout text survives.
|
|
420
|
+
throw new Error(detail || (err instanceof Error ? err.message : String(err)), { cause: err });
|
|
421
|
+
}
|
|
422
|
+
return getLatestCommitSha(directory);
|
|
423
|
+
}
|
|
286
424
|
function getLatestCommitSha(directory) {
|
|
287
425
|
try {
|
|
288
426
|
return (0, child_process_1.execSync)('git rev-parse HEAD', {
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* Provides a single point of change for future ESM migration.
|
|
4
4
|
*
|
|
5
5
|
* Falls back to real import() for ESM-only packages that
|
|
6
|
-
* throw ERR_REQUIRE_ESM.
|
|
6
|
+
* throw ERR_REQUIRE_ESM. When loading a workspace plugin's `.ts` entry
|
|
7
|
+
* under native TypeScript stripping, also falls back to swc/ts-node if
|
|
8
|
+
* the file uses constructs Node can't strip (enum, runtime namespace,
|
|
9
|
+
* legacy decorators, etc.).
|
|
7
10
|
*
|
|
8
11
|
* @param modulePath - The module specifier (relative, absolute, or package name)
|
|
9
12
|
* @param relativeTo - The directory to resolve relative paths against.
|
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleImport = handleImport;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
+
const STRIP_TYPES_DOCS_URL = 'https://nx.dev/docs/reference/environment-variables#nx-prefer-node-strip-types';
|
|
5
6
|
/**
|
|
6
7
|
* Dynamically imports a module using CJS require().
|
|
7
8
|
* Provides a single point of change for future ESM migration.
|
|
8
9
|
*
|
|
9
10
|
* Falls back to real import() for ESM-only packages that
|
|
10
|
-
* throw ERR_REQUIRE_ESM.
|
|
11
|
+
* throw ERR_REQUIRE_ESM. When loading a workspace plugin's `.ts` entry
|
|
12
|
+
* under native TypeScript stripping, also falls back to swc/ts-node if
|
|
13
|
+
* the file uses constructs Node can't strip (enum, runtime namespace,
|
|
14
|
+
* legacy decorators, etc.).
|
|
11
15
|
*
|
|
12
16
|
* @param modulePath - The module specifier (relative, absolute, or package name)
|
|
13
17
|
* @param relativeTo - The directory to resolve relative paths against.
|
|
@@ -24,9 +28,59 @@ async function handleImport(modulePath, relativeTo) {
|
|
|
24
28
|
return require(normalizedPath);
|
|
25
29
|
}
|
|
26
30
|
catch (e) {
|
|
27
|
-
|
|
31
|
+
// ERR_REQUIRE_ESM (legacy) and ERR_REQUIRE_ASYNC_MODULE (Node 22.12+,
|
|
32
|
+
// ESM with top-level await) both indicate the module must be loaded via
|
|
33
|
+
// dynamic import(). Native strip handles `.ts` extension resolution on
|
|
34
|
+
// the import() path, so this recovers TLA plugin entry points without
|
|
35
|
+
// requiring swc-node or ts-node to be installed.
|
|
36
|
+
if (e.code === 'ERR_REQUIRE_ESM' || e.code === 'ERR_REQUIRE_ASYNC_MODULE') {
|
|
28
37
|
return import(resolvedPath);
|
|
29
38
|
}
|
|
39
|
+
// Mirror `loadTsFile`'s fallback set (register.ts). Plugin loads hit a
|
|
40
|
+
// wider failure surface than .ts config loads because plugin sources are
|
|
41
|
+
// often ESM and import type-only symbols from `@nx/devkit` as runtime
|
|
42
|
+
// named exports. Lazy-require the matchers to keep register/transpiler
|
|
43
|
+
// (and their daemon/logger deps) out of module-eval-time graphs.
|
|
44
|
+
const matchers = require('../plugins/js/utils/register');
|
|
45
|
+
if (e?.code === 'ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX' ||
|
|
46
|
+
e?.code === 'MODULE_NOT_FOUND' ||
|
|
47
|
+
e?.code === 'ERR_MODULE_NOT_FOUND' ||
|
|
48
|
+
matchers.isTsEsmSyntaxError(e, resolvedPath) ||
|
|
49
|
+
matchers.isTsEsmNamedExportLinkageError(e, resolvedPath) ||
|
|
50
|
+
matchers.isCjsSyntaxError(e, resolvedPath) ||
|
|
51
|
+
matchers.isRequireInEsmScopeError(e, resolvedPath)) {
|
|
52
|
+
// Lazy-require to avoid pulling register/transpiler (and their
|
|
53
|
+
// daemon/logger transitive deps) into module-eval-time graphs.
|
|
54
|
+
const { forceRegisterPluginTSTranspiler } = require('../project-graph/plugins/transpiler');
|
|
55
|
+
forceRegisterPluginTSTranspiler();
|
|
56
|
+
try {
|
|
57
|
+
delete require.cache[require.resolve(normalizedPath)];
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// require.resolve may throw if the failed load never reached cache
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return require(normalizedPath);
|
|
64
|
+
}
|
|
65
|
+
catch (retryErr) {
|
|
66
|
+
// Mirror the initial-catch behavior: if the compiled output surfaces
|
|
67
|
+
// TLA or ESM-only-as-CJS, dispatch to dynamic import() instead of
|
|
68
|
+
// re-throwing. Without this, a plugin whose source needed the
|
|
69
|
+
// transpiler fallback AND emits top-level await fails here instead of
|
|
70
|
+
// loading.
|
|
71
|
+
if (retryErr?.code === 'ERR_REQUIRE_ESM' ||
|
|
72
|
+
retryErr?.code === 'ERR_REQUIRE_ASYNC_MODULE') {
|
|
73
|
+
return import(resolvedPath);
|
|
74
|
+
}
|
|
75
|
+
if (retryErr instanceof Error) {
|
|
76
|
+
// Lazy-require NX_PREFIX so we don't pull logger -> daemon into
|
|
77
|
+
// module-eval-time graphs.
|
|
78
|
+
const { NX_PREFIX } = require('./logger');
|
|
79
|
+
retryErr.message = `${retryErr.message}\n\n${NX_PREFIX} Failed to load ${normalizedPath} under Node's native TypeScript stripping. Set NX_PREFER_NODE_STRIP_TYPES=false to opt out and use swc/ts-node instead. See ${STRIP_TYPES_DOCS_URL}`;
|
|
80
|
+
}
|
|
81
|
+
throw retryErr;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
30
84
|
throw e;
|
|
31
85
|
}
|
|
32
86
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if `@nx/js` is installed by attempting to resolve its `package.json`.
|
|
3
|
+
*
|
|
4
|
+
* Lives in its own module so unit tests can `jest.doMock` it without having to
|
|
5
|
+
* intercept Node's resolver at the global level. The previous in-`package-json`
|
|
6
|
+
* definition was unreachable to mocks because callers in the same module
|
|
7
|
+
* referenced it via the local lexical binding rather than `module.exports`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function hasNxJsPlugin(projectRoot: string, workspaceRoot: string): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasNxJsPlugin = hasNxJsPlugin;
|
|
4
|
+
const installation_directory_1 = require("./installation-directory");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if `@nx/js` is installed by attempting to resolve its `package.json`.
|
|
7
|
+
*
|
|
8
|
+
* Lives in its own module so unit tests can `jest.doMock` it without having to
|
|
9
|
+
* intercept Node's resolver at the global level. The previous in-`package-json`
|
|
10
|
+
* definition was unreachable to mocks because callers in the same module
|
|
11
|
+
* referenced it via the local lexical binding rather than `module.exports`.
|
|
12
|
+
*/
|
|
13
|
+
function hasNxJsPlugin(projectRoot, workspaceRoot) {
|
|
14
|
+
try {
|
|
15
|
+
// nx-ignore-next-line
|
|
16
|
+
require.resolve('@nx/js/package.json', {
|
|
17
|
+
paths: [projectRoot, ...(0, installation_directory_1.getNxRequirePaths)(workspaceRoot), __dirname],
|
|
18
|
+
});
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resolve the workspace's installed `nx` version, or `null` if no installed
|
|
3
|
-
* `nx` can be located.
|
|
4
|
-
* `require.resolve` so the answer always reflects the workspace's
|
|
5
|
-
* `node_modules`/PnP store rather than whichever `nx` package happens to be
|
|
6
|
-
* loaded in the current process. See nrwl/nx#35444.
|
|
3
|
+
* `nx` can be located.
|
|
7
4
|
*/
|
|
8
5
|
export declare function getInstalledNxVersion(): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Return the package names declared in the installed `nx` package's
|
|
8
|
+
* `ng-update.packageGroup` (or `nx-migrations.packageGroup`), plus `'nx'`
|
|
9
|
+
* itself. Returns a set containing only `'nx'` when nx isn't installed or
|
|
10
|
+
* the metadata is missing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInstalledNxPackageGroup(): Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve the workspace's installed `@nrwl/workspace` version (legacy-era
|
|
15
|
+
* fallback for `nx migrate --mode=third-party` targeting `< 14.0.0-beta.0`),
|
|
16
|
+
* or `null` if it cannot be resolved from the workspace require paths.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getInstalledLegacyNrwlWorkspaceVersion(): string | null;
|
|
@@ -1,25 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInstalledNxVersion = getInstalledNxVersion;
|
|
4
|
+
exports.getInstalledNxPackageGroup = getInstalledNxPackageGroup;
|
|
5
|
+
exports.getInstalledLegacyNrwlWorkspaceVersion = getInstalledLegacyNrwlWorkspaceVersion;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
7
|
const node_module_1 = tslib_1.__importStar(require("node:module"));
|
|
6
8
|
const fileutils_1 = require("./fileutils");
|
|
9
|
+
const package_json_1 = require("./package-json");
|
|
7
10
|
const workspace_root_1 = require("./workspace-root");
|
|
8
11
|
const installation_directory_1 = require("./installation-directory");
|
|
12
|
+
/**
|
|
13
|
+
* Read the installed `nx` package.json via the cache-shielded resolver. The
|
|
14
|
+
* resolver always reflects the workspace's `node_modules`/PnP store rather
|
|
15
|
+
* than whichever `nx` package happens to be loaded in the current process
|
|
16
|
+
* (e.g. the temp `nx@latest` install used by the migrate bootstrap). See
|
|
17
|
+
* nrwl/nx#35444 and `resolvePackageJsonWithoutCachePollution` below.
|
|
18
|
+
*/
|
|
19
|
+
function readInstalledNxPackageJson() {
|
|
20
|
+
const path = resolvePackageJsonWithoutCachePollution('nx', (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot));
|
|
21
|
+
if (!path) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
return (0, fileutils_1.readJsonFile)(path);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
9
31
|
/**
|
|
10
32
|
* Resolve the workspace's installed `nx` version, or `null` if no installed
|
|
11
|
-
* `nx` can be located.
|
|
12
|
-
* `require.resolve` so the answer always reflects the workspace's
|
|
13
|
-
* `node_modules`/PnP store rather than whichever `nx` package happens to be
|
|
14
|
-
* loaded in the current process. See nrwl/nx#35444.
|
|
33
|
+
* `nx` can be located.
|
|
15
34
|
*/
|
|
16
35
|
function getInstalledNxVersion() {
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
return readInstalledNxPackageJson()?.version ?? null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Return the package names declared in the installed `nx` package's
|
|
40
|
+
* `ng-update.packageGroup` (or `nx-migrations.packageGroup`), plus `'nx'`
|
|
41
|
+
* itself. Returns a set containing only `'nx'` when nx isn't installed or
|
|
42
|
+
* the metadata is missing.
|
|
43
|
+
*/
|
|
44
|
+
function getInstalledNxPackageGroup() {
|
|
45
|
+
const set = new Set(['nx']);
|
|
46
|
+
const pkg = readInstalledNxPackageJson();
|
|
47
|
+
if (!pkg) {
|
|
48
|
+
return set;
|
|
49
|
+
}
|
|
50
|
+
const declared = pkg['ng-update']?.packageGroup ?? pkg['nx-migrations']?.packageGroup;
|
|
51
|
+
if (declared) {
|
|
52
|
+
for (const entry of (0, package_json_1.normalizePackageGroup)(declared)) {
|
|
53
|
+
set.add(entry.package);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return set;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the workspace's installed `@nrwl/workspace` version (legacy-era
|
|
60
|
+
* fallback for `nx migrate --mode=third-party` targeting `< 14.0.0-beta.0`),
|
|
61
|
+
* or `null` if it cannot be resolved from the workspace require paths.
|
|
62
|
+
*/
|
|
63
|
+
function getInstalledLegacyNrwlWorkspaceVersion() {
|
|
64
|
+
const path = resolvePackageJsonWithoutCachePollution('@nrwl/workspace', (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot));
|
|
65
|
+
if (!path) {
|
|
19
66
|
return null;
|
|
20
67
|
}
|
|
21
68
|
try {
|
|
22
|
-
return (0, fileutils_1.readJsonFile)(
|
|
69
|
+
return (0, fileutils_1.readJsonFile)(path).version ?? null;
|
|
23
70
|
}
|
|
24
71
|
catch {
|
|
25
72
|
return null;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export declare const NX_PREFIX: string;
|
|
2
2
|
export declare const NX_ERROR: string;
|
|
3
|
+
type LogDriver = Pick<Console, 'warn' | 'error' | 'info' | 'log' | 'debug'>;
|
|
4
|
+
export declare function createLogger(driver: LogDriver): {
|
|
5
|
+
warn: (...v: any[]) => void;
|
|
6
|
+
error: (s: any) => void;
|
|
7
|
+
info: (s: any) => void;
|
|
8
|
+
log: (...s: any[]) => void;
|
|
9
|
+
debug: (...s: any[]) => void;
|
|
10
|
+
fatal: (...s: any[]) => void;
|
|
11
|
+
verbose: (...s: any[]) => void;
|
|
12
|
+
};
|
|
3
13
|
export declare const logger: {
|
|
4
|
-
warn: (
|
|
14
|
+
warn: (...v: any[]) => void;
|
|
5
15
|
error: (s: any) => void;
|
|
6
16
|
info: (s: any) => void;
|
|
7
17
|
log: (...s: any[]) => void;
|
|
@@ -10,3 +20,4 @@ export declare const logger: {
|
|
|
10
20
|
verbose: (...s: any[]) => void;
|
|
11
21
|
};
|
|
12
22
|
export declare function stripIndent(str: string): string;
|
|
23
|
+
export {};
|