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
package/dist/src/utils/logger.js
CHANGED
|
@@ -1,47 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.logger = exports.NX_ERROR = exports.NX_PREFIX = void 0;
|
|
4
|
+
exports.createLogger = createLogger;
|
|
4
5
|
exports.stripIndent = stripIndent;
|
|
5
6
|
const tslib_1 = require("tslib");
|
|
6
7
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
8
|
+
const is_on_daemon_1 = require("../daemon/is-on-daemon");
|
|
9
|
+
const logger_1 = require("../daemon/logger");
|
|
7
10
|
exports.NX_PREFIX = pc.inverse(pc.bold(pc.cyan(' NX ')));
|
|
8
11
|
exports.NX_ERROR = pc.inverse(pc.bold(pc.red(' ERROR ')));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
12
|
+
function createLogger(driver) {
|
|
13
|
+
return {
|
|
14
|
+
warn: (...v) => driver.warn(...v.map((s) => pc.bold(pc.yellow(s)))),
|
|
15
|
+
error: (s) => {
|
|
16
|
+
if (typeof s === 'string' && s.startsWith('NX ')) {
|
|
17
|
+
driver.error(`\n${exports.NX_ERROR} ${pc.bold(pc.red(s.slice(3)))}\n`);
|
|
18
|
+
}
|
|
19
|
+
else if (s instanceof Error && s.stack) {
|
|
20
|
+
driver.error(pc.bold(pc.red(s.stack)));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
driver.error(pc.bold(pc.red(s)));
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
info: (s) => {
|
|
27
|
+
if (typeof s === 'string' && s.startsWith('NX ')) {
|
|
28
|
+
driver.info(`\n${exports.NX_PREFIX} ${pc.bold(s.slice(3))}\n`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
driver.info(s);
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
log: (...s) => {
|
|
35
|
+
driver.log(...s);
|
|
36
|
+
},
|
|
37
|
+
debug: (...s) => {
|
|
38
|
+
driver.debug(...s);
|
|
39
|
+
},
|
|
40
|
+
fatal: (...s) => {
|
|
41
|
+
driver.error(...s);
|
|
42
|
+
},
|
|
43
|
+
verbose: (...s) => {
|
|
44
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
45
|
+
// verbose logs go to stderr to prevent things like `nx show projects | grep`
|
|
46
|
+
// breaking when you enable verbose logging. The only potential breakage from
|
|
47
|
+
// this would be if a tool counts any output on stderr as being an issue, but
|
|
48
|
+
// there are likely other places that would trigger those same issues.
|
|
49
|
+
driver.warn(...s);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.logger = createLogger((0, is_on_daemon_1.isOnDaemon)()
|
|
55
|
+
? (() => {
|
|
56
|
+
const log = logger_1.serverLogger.log.bind(logger_1.serverLogger);
|
|
57
|
+
return {
|
|
58
|
+
warn: log,
|
|
59
|
+
error: log,
|
|
60
|
+
debug: log,
|
|
61
|
+
info: log,
|
|
62
|
+
log: log,
|
|
63
|
+
};
|
|
64
|
+
})()
|
|
65
|
+
: console);
|
|
45
66
|
function stripIndent(str) {
|
|
46
67
|
const match = str.match(/^[ \t]*(?=\S)/gm);
|
|
47
68
|
if (!match) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { NxKey } from '@nx/key';
|
|
2
2
|
export declare function createNxKeyLicenseeInformation(nxKey: NxKey): string;
|
|
3
|
-
export declare function printNxKey(): Promise<void>;
|
|
4
3
|
export declare function getNxKeyInformation(): Promise<NxKey | null>;
|
|
5
4
|
export declare class NxKeyNotInstalledError extends Error {
|
|
6
5
|
constructor(e: Error);
|
package/dist/src/utils/nx-key.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NxKeyNotInstalledError = void 0;
|
|
4
4
|
exports.createNxKeyLicenseeInformation = createNxKeyLicenseeInformation;
|
|
5
|
-
exports.printNxKey = printNxKey;
|
|
6
5
|
exports.getNxKeyInformation = getNxKeyInformation;
|
|
7
|
-
const
|
|
6
|
+
const installation_directory_1 = require("./installation-directory");
|
|
8
7
|
const package_manager_1 = require("./package-manager");
|
|
9
8
|
const workspace_root_1 = require("./workspace-root");
|
|
10
|
-
const handle_import_1 = require("./handle-import");
|
|
11
9
|
function createNxKeyLicenseeInformation(nxKey) {
|
|
12
10
|
if ('isPowerpack' in nxKey && nxKey.isPowerpack) {
|
|
13
11
|
return `Licensed to ${nxKey.organizationName} for ${nxKey.seatCount} user${nxKey.seatCount > 1 ? 's' : ''} in ${nxKey.workspaceCount === 9999
|
|
@@ -18,32 +16,31 @@ function createNxKeyLicenseeInformation(nxKey) {
|
|
|
18
16
|
return `Licensed to ${nxKey.organizationName}.`;
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
|
|
19
|
+
// `await handleImport` walks node_modules and pays ~25ms per miss; `resolve`
|
|
20
|
+
// is just the filesystem lookup and is microseconds when the package is absent.
|
|
21
|
+
// Only treat MODULE_NOT_FOUND as "not installed" so unrelated errors (permission,
|
|
22
|
+
// corrupt package.json, etc.) still surface instead of being silently hidden.
|
|
23
|
+
function packageInstalled(name) {
|
|
22
24
|
try {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
require.resolve(name, { paths: (0, installation_directory_1.getNxRequirePaths)() });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
if (e?.code === 'MODULE_NOT_FOUND')
|
|
30
|
+
return false;
|
|
31
|
+
throw e;
|
|
27
32
|
}
|
|
28
|
-
catch { }
|
|
29
33
|
}
|
|
30
34
|
async function getNxKeyInformation() {
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
return (
|
|
35
|
+
if (packageInstalled('@nx/key')) {
|
|
36
|
+
const { getNxKeyInformationAsync } = await import('@nx/key');
|
|
37
|
+
return getNxKeyInformationAsync(workspace_root_1.workspaceRoot);
|
|
34
38
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return getNxKeyInformationAsync(workspace_root_1.workspaceRoot);
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
if ('code' in e && e.code === 'MODULE_NOT_FOUND') {
|
|
42
|
-
throw new NxKeyNotInstalledError(e);
|
|
43
|
-
}
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
39
|
+
if (packageInstalled('@nx/powerpack-license')) {
|
|
40
|
+
const { getPowerpackLicenseInformation, getPowerpackLicenseInformationAsync, } = await import('@nx/powerpack-license');
|
|
41
|
+
return (getPowerpackLicenseInformationAsync ?? getPowerpackLicenseInformation)(workspace_root_1.workspaceRoot);
|
|
46
42
|
}
|
|
43
|
+
throw new NxKeyNotInstalledError(new Error('MODULE_NOT_FOUND'));
|
|
47
44
|
}
|
|
48
45
|
class NxKeyNotInstalledError extends Error {
|
|
49
46
|
constructor(e) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first-party Nx package set declared in nx's own
|
|
3
|
+
* `nx-migrations.packageGroup`. Used by `nx report` (to know which
|
|
4
|
+
* package versions to print) and by `nx add` shell completion (to
|
|
5
|
+
* suggest first-party plugins). Auto-updates as new plugins land in
|
|
6
|
+
* the package group — no hand-maintained list.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readNxPackageGroup(): string[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readNxPackageGroup = readNxPackageGroup;
|
|
4
|
+
const fileutils_1 = require("./fileutils");
|
|
5
|
+
/**
|
|
6
|
+
* The first-party Nx package set declared in nx's own
|
|
7
|
+
* `nx-migrations.packageGroup`. Used by `nx report` (to know which
|
|
8
|
+
* package versions to print) and by `nx add` shell completion (to
|
|
9
|
+
* suggest first-party plugins). Auto-updates as new plugins land in
|
|
10
|
+
* the package group — no hand-maintained list.
|
|
11
|
+
*/
|
|
12
|
+
function readNxPackageGroup() {
|
|
13
|
+
const nxPkg = (0, fileutils_1.readJsonFile)(require.resolve('nx/package.json'));
|
|
14
|
+
return (nxPkg['nx-migrations']?.packageGroup ?? []).map((e) => typeof e === 'string' ? e : e.package);
|
|
15
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WriteStream } from 'tty';
|
|
1
2
|
import type { TaskStatus } from '../tasks-runner/tasks-runner';
|
|
2
3
|
export interface CLIErrorMessageConfig {
|
|
3
4
|
title: string;
|
|
@@ -47,12 +48,12 @@ declare class CLIOutput {
|
|
|
47
48
|
bold: import("picocolors/types").Formatter;
|
|
48
49
|
underline: import("picocolors/types").Formatter;
|
|
49
50
|
dim: import("picocolors/types").Formatter;
|
|
50
|
-
private
|
|
51
|
+
private writeToStream;
|
|
51
52
|
overwriteLine(lineText?: string): void;
|
|
52
53
|
private writeOutputTitle;
|
|
53
54
|
private writeOptionalOutputBody;
|
|
54
55
|
applyNxPrefix(color: string, text: string): string;
|
|
55
|
-
addNewline(): void;
|
|
56
|
+
addNewline(stream?: WriteStream): void;
|
|
56
57
|
addVerticalSeparator(color?: string): void;
|
|
57
58
|
addVerticalSeparatorWithoutNewLines(color?: string): void;
|
|
58
59
|
getVerticalSeparatorLines(color?: string): string[];
|
package/dist/src/utils/output.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.output = void 0;
|
|
4
4
|
exports.orange = orange;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const pc = tslib_1.__importStar(require("picocolors"));
|
|
7
6
|
const os_1 = require("os");
|
|
7
|
+
const pc = tslib_1.__importStar(require("picocolors"));
|
|
8
8
|
const readline = tslib_1.__importStar(require("readline"));
|
|
9
9
|
const GH_GROUP_PREFIX = '::group::';
|
|
10
10
|
const GH_GROUP_SUFFIX = '::endgroup::';
|
|
@@ -62,8 +62,8 @@ class CLIOutput {
|
|
|
62
62
|
}
|
|
63
63
|
return divider;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
writeToStream(str, stream = process.stdout) {
|
|
66
|
+
stream.write(str);
|
|
67
67
|
}
|
|
68
68
|
overwriteLine(lineText = '') {
|
|
69
69
|
// Ensure we always start writing from column 0.
|
|
@@ -78,23 +78,23 @@ class CLIOutput {
|
|
|
78
78
|
process.stdout.write('\n');
|
|
79
79
|
readline.cursorTo(process.stdout, 0);
|
|
80
80
|
}
|
|
81
|
-
writeOutputTitle({ color, title, }) {
|
|
82
|
-
this.
|
|
81
|
+
writeOutputTitle({ color, title, }, stream = process.stdout) {
|
|
82
|
+
this.writeToStream(`${this.applyNxPrefix(color, title)}${os_1.EOL}`, stream);
|
|
83
83
|
}
|
|
84
|
-
writeOptionalOutputBody(bodyLines) {
|
|
84
|
+
writeOptionalOutputBody(bodyLines, stream = process.stdout) {
|
|
85
85
|
if (!bodyLines) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
this.addNewline();
|
|
89
|
-
bodyLines.forEach((bodyLine) => this.
|
|
88
|
+
this.addNewline(stream);
|
|
89
|
+
bodyLines.forEach((bodyLine) => this.writeToStream(`${bodyLine}${os_1.EOL}`, stream));
|
|
90
90
|
}
|
|
91
91
|
applyNxPrefix(color = 'cyan', text) {
|
|
92
92
|
const colorFn = pcColors[color] || ((t) => t);
|
|
93
93
|
const nxPrefix = pc.inverse(pc.bold(colorFn(` ${this.cliName} `)));
|
|
94
94
|
return `${nxPrefix} ${text}`;
|
|
95
95
|
}
|
|
96
|
-
addNewline() {
|
|
97
|
-
this.
|
|
96
|
+
addNewline(stream = process.stdout) {
|
|
97
|
+
this.writeToStream(os_1.EOL, stream);
|
|
98
98
|
}
|
|
99
99
|
addVerticalSeparator(color = 'gray') {
|
|
100
100
|
this.addNewline();
|
|
@@ -102,7 +102,7 @@ class CLIOutput {
|
|
|
102
102
|
this.addNewline();
|
|
103
103
|
}
|
|
104
104
|
addVerticalSeparatorWithoutNewLines(color = 'gray') {
|
|
105
|
-
this.
|
|
105
|
+
this.writeToStream(`${this.getVerticalSeparator(color)}${os_1.EOL}`);
|
|
106
106
|
}
|
|
107
107
|
getVerticalSeparatorLines(color = 'gray') {
|
|
108
108
|
return ['', this.getVerticalSeparator(color), ''];
|
|
@@ -112,36 +112,37 @@ class CLIOutput {
|
|
|
112
112
|
return pc.dim(colorFn(this.VERTICAL_SEPARATOR));
|
|
113
113
|
}
|
|
114
114
|
error({ title, slug, bodyLines }) {
|
|
115
|
-
|
|
115
|
+
const stream = process.stderr;
|
|
116
|
+
this.addNewline(stream);
|
|
116
117
|
this.writeOutputTitle({
|
|
117
118
|
color: 'red',
|
|
118
119
|
title: pc.red(title),
|
|
119
|
-
});
|
|
120
|
-
this.writeOptionalOutputBody(bodyLines);
|
|
120
|
+
}, stream);
|
|
121
|
+
this.writeOptionalOutputBody(bodyLines, stream);
|
|
121
122
|
/**
|
|
122
123
|
* Optional slug to be used in an Nx error message redirect URL
|
|
123
124
|
*/
|
|
124
125
|
if (slug && typeof slug === 'string') {
|
|
125
|
-
this.addNewline();
|
|
126
|
-
this.
|
|
126
|
+
this.addNewline(stream);
|
|
127
|
+
this.writeToStream(`${pc.gray(' Learn more about this error: ')}https://errors.nx.dev/${slug}${os_1.EOL}`, stream);
|
|
127
128
|
}
|
|
128
|
-
this.addNewline();
|
|
129
|
+
this.addNewline(stream);
|
|
129
130
|
}
|
|
130
131
|
warn({ title, slug, bodyLines }) {
|
|
131
|
-
this.addNewline();
|
|
132
|
+
this.addNewline(process.stderr);
|
|
132
133
|
this.writeOutputTitle({
|
|
133
134
|
color: 'yellow',
|
|
134
135
|
title: pc.yellow(title),
|
|
135
|
-
});
|
|
136
|
-
this.writeOptionalOutputBody(bodyLines);
|
|
136
|
+
}, process.stderr);
|
|
137
|
+
this.writeOptionalOutputBody(bodyLines, process.stderr);
|
|
137
138
|
/**
|
|
138
139
|
* Optional slug to be used in an Nx warning message redirect URL
|
|
139
140
|
*/
|
|
140
141
|
if (slug && typeof slug === 'string') {
|
|
141
|
-
this.addNewline();
|
|
142
|
-
this.
|
|
142
|
+
this.addNewline(process.stderr);
|
|
143
|
+
this.writeToStream(`${pc.gray(' Learn more about this warning: ')}https://errors.nx.dev/${slug}${os_1.EOL}`, process.stderr);
|
|
143
144
|
}
|
|
144
|
-
this.addNewline();
|
|
145
|
+
this.addNewline(process.stderr);
|
|
145
146
|
}
|
|
146
147
|
note({ title, bodyLines }) {
|
|
147
148
|
this.addNewline();
|
|
@@ -170,12 +171,12 @@ class CLIOutput {
|
|
|
170
171
|
this.addNewline();
|
|
171
172
|
}
|
|
172
173
|
logRawLine(message) {
|
|
173
|
-
this.
|
|
174
|
+
this.writeToStream(`${message}${os_1.EOL}`);
|
|
174
175
|
this.addNewline();
|
|
175
176
|
}
|
|
176
177
|
logCommand(message, taskStatus) {
|
|
177
178
|
this.addNewline();
|
|
178
|
-
this.
|
|
179
|
+
this.writeToStream(this.getCommandWithStatus(message, taskStatus));
|
|
179
180
|
this.addNewline();
|
|
180
181
|
this.addNewline();
|
|
181
182
|
}
|
|
@@ -187,13 +188,13 @@ class CLIOutput {
|
|
|
187
188
|
commandOutputWithStatus = `${GH_GROUP_PREFIX}${icon} ${commandOutputWithStatus}`;
|
|
188
189
|
}
|
|
189
190
|
this.addNewline();
|
|
190
|
-
this.
|
|
191
|
+
this.writeToStream(commandOutputWithStatus);
|
|
191
192
|
this.addNewline();
|
|
192
193
|
this.addNewline();
|
|
193
|
-
this.
|
|
194
|
+
this.writeToStream(output);
|
|
194
195
|
if (process.env.NX_SKIP_LOG_GROUPING !== 'true' &&
|
|
195
196
|
process.env.GITHUB_ACTIONS) {
|
|
196
|
-
this.
|
|
197
|
+
this.writeToStream(GH_GROUP_SUFFIX);
|
|
197
198
|
}
|
|
198
199
|
}
|
|
199
200
|
getCommandWithStatus(message, taskStatus) {
|
|
@@ -92,9 +92,22 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
|
|
|
92
92
|
packageGroup?: ArrayPackageGroup;
|
|
93
93
|
};
|
|
94
94
|
export declare function buildTargetFromScript(script: string, scripts: Record<string, string>, packageManagerCommand: PackageManagerCommands): TargetConfiguration;
|
|
95
|
+
export type PackageJsonProjectMetadata = {
|
|
96
|
+
targetGroups: {
|
|
97
|
+
'NPM Scripts'?: Array<string>;
|
|
98
|
+
};
|
|
99
|
+
description: string;
|
|
100
|
+
js: {
|
|
101
|
+
packageName: PackageJson['name'];
|
|
102
|
+
packageVersion: PackageJson['version'];
|
|
103
|
+
packageExports: PackageJson['exports'];
|
|
104
|
+
packageMain: PackageJson['main'];
|
|
105
|
+
isInPackageManagerWorkspaces: boolean;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
95
108
|
export declare function getMetadataFromPackageJson(packageJson: PackageJson, isInPackageManagerWorkspaces: boolean): ProjectMetadata;
|
|
96
109
|
export declare function getTagsFromPackageJson(packageJson: PackageJson): string[];
|
|
97
|
-
export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration, projectRoot: string, workspaceRoot: string): Record<string, TargetConfiguration<any>>;
|
|
110
|
+
export declare function readTargetsFromPackageJson(packageJson: PackageJson, nxJson: NxJsonConfiguration, projectRoot: string, workspaceRoot: string, packageManagerCommand: PackageManagerCommands): Record<string, TargetConfiguration<any>>;
|
|
98
111
|
/**
|
|
99
112
|
* Uses `require.resolve` to read the package.json for a module.
|
|
100
113
|
*
|
|
@@ -18,9 +18,11 @@ const path_1 = require("path");
|
|
|
18
18
|
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
19
19
|
const tmp_1 = require("tmp");
|
|
20
20
|
const json_1 = require("../generators/utils/json");
|
|
21
|
+
const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
|
|
21
22
|
const target_merging_1 = require("../project-graph/utils/project-configuration/target-merging");
|
|
22
23
|
const catalog_1 = require("./catalog");
|
|
23
24
|
const fileutils_1 = require("./fileutils");
|
|
25
|
+
const has_nx_js_plugin_1 = require("./has-nx-js-plugin");
|
|
24
26
|
const installation_directory_1 = require("./installation-directory");
|
|
25
27
|
const package_manager_1 = require("./package-manager");
|
|
26
28
|
const workspace_root_1 = require("./workspace-root");
|
|
@@ -66,14 +68,15 @@ function buildTargetFromScript(script, scripts = {}, packageManagerCommand) {
|
|
|
66
68
|
},
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
|
-
let packageManagerCommand;
|
|
70
71
|
function getMetadataFromPackageJson(packageJson, isInPackageManagerWorkspaces) {
|
|
71
72
|
const { scripts, nx, description, name, exports, main, version } = packageJson;
|
|
72
73
|
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
|
73
|
-
|
|
74
|
-
targetGroups:
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const metadata = {
|
|
75
|
+
targetGroups: includedScripts.length
|
|
76
|
+
? {
|
|
77
|
+
'NPM Scripts': includedScripts,
|
|
78
|
+
}
|
|
79
|
+
: {},
|
|
77
80
|
description,
|
|
78
81
|
js: {
|
|
79
82
|
packageName: name,
|
|
@@ -83,6 +86,7 @@ function getMetadataFromPackageJson(packageJson, isInPackageManagerWorkspaces) {
|
|
|
83
86
|
isInPackageManagerWorkspaces,
|
|
84
87
|
},
|
|
85
88
|
};
|
|
89
|
+
return metadata;
|
|
86
90
|
}
|
|
87
91
|
function getTagsFromPackageJson(packageJson) {
|
|
88
92
|
const tags = packageJson.private ? ['npm:private'] : ['npm:public'];
|
|
@@ -94,12 +98,11 @@ function getTagsFromPackageJson(packageJson) {
|
|
|
94
98
|
}
|
|
95
99
|
return tags;
|
|
96
100
|
}
|
|
97
|
-
function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceRoot) {
|
|
101
|
+
function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceRoot, packageManagerCommand) {
|
|
98
102
|
const { scripts, nx, private: isPrivate } = packageJson ?? {};
|
|
99
103
|
const res = {};
|
|
100
104
|
const includedScripts = nx?.includedScripts || Object.keys(scripts ?? {});
|
|
101
105
|
for (const script of includedScripts) {
|
|
102
|
-
packageManagerCommand ??= (0, package_manager_1.getPackageManagerCommand)();
|
|
103
106
|
res[script] = buildTargetFromScript(script, scripts, packageManagerCommand);
|
|
104
107
|
}
|
|
105
108
|
for (const targetName in nx?.targets) {
|
|
@@ -124,8 +127,8 @@ function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceR
|
|
|
124
127
|
*/
|
|
125
128
|
if (!isPrivate &&
|
|
126
129
|
!res['nx-release-publish'] &&
|
|
127
|
-
hasNxJsPlugin(projectRoot, workspaceRoot)) {
|
|
128
|
-
const nxReleasePublishTargetDefaults = nxJson?.targetDefaults
|
|
130
|
+
(0, has_nx_js_plugin_1.hasNxJsPlugin)(projectRoot, workspaceRoot)) {
|
|
131
|
+
const nxReleasePublishTargetDefaults = readCompatibleTargetDefaultsForTarget('nx-release-publish', nxJson?.targetDefaults, '@nx/js:release-publish') ?? {};
|
|
129
132
|
res['nx-release-publish'] = {
|
|
130
133
|
executor: '@nx/js:release-publish',
|
|
131
134
|
...nxReleasePublishTargetDefaults,
|
|
@@ -141,17 +144,13 @@ function readTargetsFromPackageJson(packageJson, nxJson, projectRoot, workspaceR
|
|
|
141
144
|
}
|
|
142
145
|
return res;
|
|
143
146
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
});
|
|
150
|
-
return true;
|
|
151
|
-
}
|
|
152
|
-
catch {
|
|
153
|
-
return false;
|
|
147
|
+
function readCompatibleTargetDefaultsForTarget(targetName, targetDefaults, executor) {
|
|
148
|
+
if (targetDefaults &&
|
|
149
|
+
!Array.isArray(targetDefaults) &&
|
|
150
|
+
Object.prototype.hasOwnProperty.call(targetDefaults, targetName)) {
|
|
151
|
+
return targetDefaults[targetName] ?? null;
|
|
154
152
|
}
|
|
153
|
+
return (0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, targetDefaults, executor);
|
|
155
154
|
}
|
|
156
155
|
/**
|
|
157
156
|
* Uses `require.resolve` to read the package.json for a module.
|
|
@@ -221,11 +220,11 @@ function preparePackageInstallation(pkg, requiredVersion) {
|
|
|
221
220
|
cleanup: () => { },
|
|
222
221
|
};
|
|
223
222
|
console.log(`Fetching ${pkg}...`);
|
|
224
|
-
const packageManager = (0, package_manager_1.detectPackageManager)();
|
|
223
|
+
const packageManager = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
|
|
225
224
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
226
225
|
generatePackageManagerFiles(tempDir, packageManager);
|
|
227
|
-
const preInstallCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager).preInstall;
|
|
228
226
|
const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
227
|
+
const preInstallCommand = pmCommands.preInstall;
|
|
229
228
|
let addCommand = pmCommands.addDev;
|
|
230
229
|
if (packageManager === 'pnpm') {
|
|
231
230
|
addCommand = 'pnpm add -D'; // we need to ensure that we are not using workspace command
|
|
@@ -7,6 +7,7 @@ function isTrackedDetail(detail) {
|
|
|
7
7
|
detail.track === true);
|
|
8
8
|
}
|
|
9
9
|
new perf_hooks_1.PerformanceObserver((list) => {
|
|
10
|
+
// observer is configured for 'measure' entries only (see .observe call below)
|
|
10
11
|
const entries = list.getEntries();
|
|
11
12
|
const logEnabled = process.env.NX_PERF_LOGGING === 'true';
|
|
12
13
|
const tracked = entries.filter((e) => isTrackedDetail(e.detail));
|
|
@@ -17,9 +18,10 @@ new perf_hooks_1.PerformanceObserver((list) => {
|
|
|
17
18
|
if (logEnabled) {
|
|
18
19
|
const { isOnDaemon } = require('../daemon/is-on-daemon');
|
|
19
20
|
const { serverLogger } = require('../daemon/logger');
|
|
21
|
+
const { logger } = require('./logger');
|
|
20
22
|
const log = isOnDaemon()
|
|
21
23
|
? (msg) => serverLogger.log(msg)
|
|
22
|
-
:
|
|
24
|
+
: (msg) => logger.warn(msg);
|
|
23
25
|
for (const entry of entries) {
|
|
24
26
|
log(`Time taken for '${entry.name}' ${entry.duration}ms`);
|
|
25
27
|
}
|
|
@@ -21,8 +21,17 @@ interface PluginCacheData<T> {
|
|
|
21
21
|
export declare class PluginCache<T> {
|
|
22
22
|
private entries;
|
|
23
23
|
private accessOrder;
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
private cachePath;
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a `PluginCache`. The `cachePath` is the single source of truth
|
|
27
|
+
* for both reading and writing — `writeToDisk()` writes to it.
|
|
28
|
+
*
|
|
29
|
+
* If `entries` is omitted, the cache is loaded from `cachePath` on disk.
|
|
30
|
+
* If `entries` is provided, those entries are used as the in-memory state
|
|
31
|
+
* and the on-disk file is not read (useful for tests or for seeding the
|
|
32
|
+
* cache with known state).
|
|
33
|
+
*/
|
|
34
|
+
constructor(cachePath: string, entries?: Record<string, T>, accessOrder?: string[] | Set<string>);
|
|
26
35
|
private touch;
|
|
27
36
|
/**
|
|
28
37
|
* Returns the value for `key`, or `undefined` if not present.
|
|
@@ -44,7 +53,7 @@ export declare class PluginCache<T> {
|
|
|
44
53
|
*/
|
|
45
54
|
toSerializable(): PluginCacheData<T>;
|
|
46
55
|
/**
|
|
47
|
-
* Safely writes this cache to
|
|
56
|
+
* Safely writes this cache to the path it was constructed with.
|
|
48
57
|
*
|
|
49
58
|
* Strategy:
|
|
50
59
|
* 1. Serialize to JSON
|
|
@@ -55,7 +64,7 @@ export declare class PluginCache<T> {
|
|
|
55
64
|
* 3. On total serialization failure (even after eviction),
|
|
56
65
|
* write an empty cache so the file is valid
|
|
57
66
|
*/
|
|
58
|
-
writeToDisk(
|
|
67
|
+
writeToDisk(): void;
|
|
59
68
|
/**
|
|
60
69
|
* Evicts the oldest 50% of entries (front of the access-order queue)
|
|
61
70
|
* and returns the remaining entries + accessOrder as a plain object.
|
|
@@ -20,17 +20,27 @@ const logger_1 = require("./logger");
|
|
|
20
20
|
* least recently used keys.
|
|
21
21
|
*/
|
|
22
22
|
class PluginCache {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Constructs a `PluginCache`. The `cachePath` is the single source of truth
|
|
25
|
+
* for both reading and writing — `writeToDisk()` writes to it.
|
|
26
|
+
*
|
|
27
|
+
* If `entries` is omitted, the cache is loaded from `cachePath` on disk.
|
|
28
|
+
* If `entries` is provided, those entries are used as the in-memory state
|
|
29
|
+
* and the on-disk file is not read (useful for tests or for seeding the
|
|
30
|
+
* cache with known state).
|
|
31
|
+
*/
|
|
32
|
+
constructor(cachePath, entries, accessOrder) {
|
|
33
|
+
this.cachePath = cachePath;
|
|
34
|
+
if (entries !== undefined) {
|
|
35
|
+
this.entries = entries;
|
|
31
36
|
this.accessOrder =
|
|
32
37
|
accessOrder instanceof Set ? accessOrder : new Set(accessOrder ?? []);
|
|
33
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
const loaded = loadFromDisk(cachePath);
|
|
41
|
+
this.entries = loaded.entries;
|
|
42
|
+
this.accessOrder = loaded.accessOrder;
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
45
|
touch(key) {
|
|
36
46
|
// Sets are guaranteed to maintain insertion order, so we can delete and re-add to move it to the end.
|
|
@@ -73,7 +83,7 @@ class PluginCache {
|
|
|
73
83
|
};
|
|
74
84
|
}
|
|
75
85
|
/**
|
|
76
|
-
* Safely writes this cache to
|
|
86
|
+
* Safely writes this cache to the path it was constructed with.
|
|
77
87
|
*
|
|
78
88
|
* Strategy:
|
|
79
89
|
* 1. Serialize to JSON
|
|
@@ -84,8 +94,8 @@ class PluginCache {
|
|
|
84
94
|
* 3. On total serialization failure (even after eviction),
|
|
85
95
|
* write an empty cache so the file is valid
|
|
86
96
|
*/
|
|
87
|
-
writeToDisk(
|
|
88
|
-
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(cachePath), { recursive: true });
|
|
97
|
+
writeToDisk() {
|
|
98
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.cachePath), { recursive: true });
|
|
89
99
|
let content;
|
|
90
100
|
try {
|
|
91
101
|
content = JSON.stringify({
|
|
@@ -115,11 +125,11 @@ class PluginCache {
|
|
|
115
125
|
}
|
|
116
126
|
// Attempt to write the serialized content to disk
|
|
117
127
|
try {
|
|
118
|
-
(0, node_fs_1.writeFileSync)(cachePath, content);
|
|
128
|
+
(0, node_fs_1.writeFileSync)(this.cachePath, content);
|
|
119
129
|
}
|
|
120
130
|
catch {
|
|
121
131
|
// Filesystem error — wipe cache so a corrupted file doesn't persist
|
|
122
|
-
tryRemoveFile(cachePath);
|
|
132
|
+
tryRemoveFile(this.cachePath);
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
135
|
/**
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
2
2
|
import { ProjectsConfigurations } from '../../config/workspace-json-project-json';
|
|
3
3
|
import { PluginCapabilities } from './plugin-capabilities';
|
|
4
|
+
/** A workspace-local plugin discovered cheaply (no JS load). */
|
|
5
|
+
export interface LocalPluginWithGenerators {
|
|
6
|
+
/** Absolute path to the project root that hosts the plugin. */
|
|
7
|
+
dir: string;
|
|
8
|
+
/** The `generators` or `schematics` field value from the plugin's
|
|
9
|
+
* package.json (a relative path to the collection JSON). */
|
|
10
|
+
field: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sync, lightweight scan: for each given project root, read its package.json
|
|
14
|
+
* and yield it as a plugin if it declares a `generators`/`schematics`
|
|
15
|
+
* collection. Used by tab completion which cannot afford the heavier
|
|
16
|
+
* {@link getLocalWorkspacePlugins} (that one loads each plugin's JS to
|
|
17
|
+
* walk its capabilities).
|
|
18
|
+
*
|
|
19
|
+
* `projectRoots` are paths relative to `workspaceRoot`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function findLocalPluginsWithGenerators(projectRoots: Iterable<string>): Map<string, LocalPluginWithGenerators>;
|
|
4
22
|
export declare function getLocalWorkspacePlugins(projectsConfiguration: ProjectsConfigurations, nxJson: NxJsonConfiguration): Promise<Map<string, PluginCapabilities>>;
|