nx 23.0.0-beta.2 → 23.0.0-beta.20
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 +73 -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 +60 -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 +29 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +9 -0
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +87 -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 +439 -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 +121 -0
- package/dist/src/command-line/migrate/migrate-output.js +241 -0
- package/dist/src/command-line/migrate/migrate.d.ts +122 -12
- package/dist/src/command-line/migrate/migrate.js +1033 -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 +20 -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 +14 -0
- package/dist/src/utils/git-utils.js +73 -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 +27 -27
- 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/bin/init-local.js
CHANGED
|
@@ -30,13 +30,18 @@ async function initLocal(workspace) {
|
|
|
30
30
|
handleAngularCLIFallbacks(workspace);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// Skip per-TAB shell completion calls — those must not spawn the daemon.
|
|
34
|
+
if (!process.env.NX_COMPLETE) {
|
|
35
|
+
try {
|
|
36
|
+
await ensureNxConsoleInstalledViaDaemon();
|
|
37
|
+
}
|
|
38
|
+
catch { }
|
|
36
39
|
}
|
|
37
|
-
catch { }
|
|
38
40
|
const command = process.argv[2];
|
|
39
|
-
if (command === '
|
|
41
|
+
if (command === 'completion' ||
|
|
42
|
+
command === 'run' ||
|
|
43
|
+
command === 'g' ||
|
|
44
|
+
command === 'generate') {
|
|
40
45
|
nx_commands_1.commandsObject.parse(process.argv.slice(2));
|
|
41
46
|
}
|
|
42
47
|
else if (isKnownCommand(command)) {
|
|
@@ -110,14 +115,7 @@ function isKnownCommand(command) {
|
|
|
110
115
|
}
|
|
111
116
|
function shouldDelegateToAngularCLI() {
|
|
112
117
|
const command = process.argv[2];
|
|
113
|
-
const commands = [
|
|
114
|
-
'analytics',
|
|
115
|
-
'cache',
|
|
116
|
-
'completion',
|
|
117
|
-
'config',
|
|
118
|
-
'doc',
|
|
119
|
-
'update',
|
|
120
|
-
];
|
|
118
|
+
const commands = ['analytics', 'cache', 'config', 'doc', 'update'];
|
|
121
119
|
return commands.indexOf(command) > -1;
|
|
122
120
|
}
|
|
123
121
|
async function ensureNxConsoleInstalledViaDaemon() {
|
|
@@ -169,13 +167,6 @@ function handleAngularCLIFallbacks(workspace) {
|
|
|
169
167
|
console.log(`Running "ng update" can still be useful in some dev workflows, so we aren't planning to remove it.`);
|
|
170
168
|
console.log(`If you need to use it, run "FORCE_NG_UPDATE=true ng update".`);
|
|
171
169
|
}
|
|
172
|
-
else if (process.argv[2] === 'completion') {
|
|
173
|
-
if (!process.argv[3]) {
|
|
174
|
-
console.log(`"ng completion" is not natively supported by Nx.
|
|
175
|
-
Instead, you could try an Nx Editor Plugin for a visual tool to run Nx commands. If you're using VSCode, you can use the Nx Console plugin, or if you're using WebStorm, you could use one of the available community plugins.
|
|
176
|
-
For more information, see https://nx.dev/getting-started/editor-setup`);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
170
|
else if (process.argv[2] === 'cache') {
|
|
180
171
|
console.log(`"ng cache" is not natively supported by Nx.
|
|
181
172
|
To clear the cache, you can delete the ".angular/cache" directory (or the directory configured by "cli.cache.path" in the "nx.json" file).
|
package/dist/bin/nx.d.ts
CHANGED
package/dist/bin/nx.js
CHANGED
|
@@ -8,6 +8,8 @@ if (process.env.FORCE_COLOR === '0') {
|
|
|
8
8
|
process.env.NO_COLOR = '1';
|
|
9
9
|
delete process.env.FORCE_COLOR;
|
|
10
10
|
}
|
|
11
|
+
// Must be the first import — see enable-compile-cache.ts.
|
|
12
|
+
require("../src/utils/enable-compile-cache");
|
|
11
13
|
const find_workspace_root_1 = require("../src/utils/find-workspace-root");
|
|
12
14
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
13
15
|
const output_1 = require("../src/utils/output");
|
|
@@ -27,10 +29,32 @@ require("../src/utils/perf-logging");
|
|
|
27
29
|
const isTsExt = (0, path_1.extname)(__filename).endsWith('.ts');
|
|
28
30
|
const pathToPkgJson = isTsExt ? '../package.json' : '../../package.json';
|
|
29
31
|
async function main() {
|
|
32
|
+
// Tab-completion fast path. Bare env-var read so nothing runs before
|
|
33
|
+
// the try/catch — a throw here would splice a stack trace into the
|
|
34
|
+
// user's command line.
|
|
35
|
+
if (process.env.NX_COMPLETE) {
|
|
36
|
+
try {
|
|
37
|
+
perf_hooks_1.performance.mark('init-local');
|
|
38
|
+
const { tryValueCompletion } = await import('nx/src/command-line/completion/value-completions');
|
|
39
|
+
if (tryValueCompletion())
|
|
40
|
+
return;
|
|
41
|
+
const { tryCommandSurfaceCompletion } = await import('nx/src/command-line/completion/command-completions');
|
|
42
|
+
tryCommandSurfaceCompletion();
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
// Swallow: a broken completion must produce no suggestions, not a
|
|
46
|
+
// stack trace. NX_VERBOSE_LOGGING surfaces the cause to stderr.
|
|
47
|
+
if (process.env.NX_VERBOSE_LOGGING) {
|
|
48
|
+
console.error(e);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
30
53
|
if (process.argv[2] !== 'report' &&
|
|
31
54
|
process.argv[2] !== '--version' &&
|
|
32
55
|
process.argv[2] !== '--help' &&
|
|
33
|
-
process.argv[2] !== 'reset'
|
|
56
|
+
process.argv[2] !== 'reset' &&
|
|
57
|
+
process.argv[2] !== 'completion') {
|
|
34
58
|
const { assertSupportedPlatform } = await import('../src/native/assert-supported-platform.js');
|
|
35
59
|
assertSupportedPlatform();
|
|
36
60
|
}
|
|
@@ -52,6 +76,8 @@ async function main() {
|
|
|
52
76
|
process.argv[2] === '_migrate' ||
|
|
53
77
|
process.argv[2] === 'init' ||
|
|
54
78
|
process.argv[2] === 'configure-ai-agents' ||
|
|
79
|
+
process.argv[2] === 'mcp' ||
|
|
80
|
+
process.argv[2] === 'completion' ||
|
|
55
81
|
(process.argv[2] === 'graph' && !workspace)) {
|
|
56
82
|
process.env.NX_DAEMON = 'false';
|
|
57
83
|
(await import('nx/src/command-line/nx-commands')).commandsObject.argv;
|
|
@@ -210,7 +236,7 @@ function handleMissingLocalInstallation(detectedWorkspaceRoot) {
|
|
|
210
236
|
* Warns if out of date by 1 major version or more.
|
|
211
237
|
*/
|
|
212
238
|
function warnIfUsingOutdatedGlobalInstall(globalNxVersion, localNxVersion) {
|
|
213
|
-
//
|
|
239
|
+
// Skip when Nx is recursively invoking itself.
|
|
214
240
|
if (process.env.NX_CLI_SET) {
|
|
215
241
|
return;
|
|
216
242
|
}
|
|
@@ -8,6 +8,7 @@ const cache_directory_1 = require("../src/utils/cache-directory");
|
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const fileutils_1 = require("../src/utils/fileutils");
|
|
10
10
|
const plugin_cache_utils_1 = require("../src/utils/plugin-cache-utils");
|
|
11
|
+
const package_manager_1 = require("../src/utils/package-manager");
|
|
11
12
|
const cachePath = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'package-json.hash');
|
|
12
13
|
let packageJsonPluginCache = null;
|
|
13
14
|
function readPackageJsonConfigurationCache() {
|
|
@@ -16,7 +17,7 @@ function readPackageJsonConfigurationCache() {
|
|
|
16
17
|
}
|
|
17
18
|
function writeCache() {
|
|
18
19
|
if (packageJsonPluginCache) {
|
|
19
|
-
packageJsonPluginCache.writeToDisk(
|
|
20
|
+
packageJsonPluginCache.writeToDisk();
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
const plugin = {
|
|
@@ -27,7 +28,8 @@ const plugin = {
|
|
|
27
28
|
const cache = readPackageJsonConfigurationCache();
|
|
28
29
|
const patterns = (0, package_json_1.buildPackageJsonPatterns)(context.workspaceRoot, (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(context.workspaceRoot, f)));
|
|
29
30
|
const isInPackageJsonWorkspaces = (0, package_json_1.buildPackageJsonWorkspacesMatcher)(patterns);
|
|
30
|
-
const
|
|
31
|
+
const packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)((0, package_manager_1.detectPackageManager)(context.workspaceRoot), context.workspaceRoot);
|
|
32
|
+
const result = (0, plugins_1.createNodesFromFiles)((packageJsonPath) => (0, package_json_1.createNodeFromPackageJson)(packageJsonPath, workspace_root_1.workspaceRoot, cache, isInPackageJsonWorkspaces(packageJsonPath), packageManagerCommand), configFiles, options, context);
|
|
31
33
|
writeCache();
|
|
32
34
|
return result;
|
|
33
35
|
},
|
|
@@ -3,7 +3,7 @@ import { FileBuffer } from '@angular-devkit/core/src/virtual-fs/host/interface';
|
|
|
3
3
|
import { Observable } from 'rxjs';
|
|
4
4
|
import type { GenerateOptions } from '../command-line/generate/generate';
|
|
5
5
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
|
6
|
-
import { Tree } from '../generators/tree';
|
|
6
|
+
import { FileChange, Tree } from '../generators/tree';
|
|
7
7
|
import type { ProjectGraph } from '../config/project-graph';
|
|
8
8
|
import { ExecutorContext, GeneratorCallback } from '../config/misc-interfaces';
|
|
9
9
|
export declare function createBuilderContext(builderInfo: {
|
|
@@ -59,6 +59,7 @@ export declare class NxScopeHostUsedForWrappedSchematics extends NxScopedHost {
|
|
|
59
59
|
export declare function generate(root: string, opts: GenerateOptions, projects: Record<string, ProjectConfiguration>, verbose: boolean, projectGraph: ProjectGraph): Promise<number>;
|
|
60
60
|
export declare function runMigration(root: string, packageName: string, migrationName: string, projects: Record<string, ProjectConfiguration>, isVerbose: boolean, projectGraph: ProjectGraph): Promise<{
|
|
61
61
|
loggingQueue: string[];
|
|
62
|
+
changes: FileChange[];
|
|
62
63
|
madeChanges: boolean;
|
|
63
64
|
}>;
|
|
64
65
|
/**
|
|
@@ -239,20 +239,38 @@ async function createRecorder(host, record, logger) {
|
|
|
239
239
|
}
|
|
240
240
|
else if (event.kind === 'update') {
|
|
241
241
|
record.loggingQueue.push(core_1.tags.oneLine `${pc.white('UPDATE')} ${eventPath}`);
|
|
242
|
+
record.changes?.push(emptyFileChange('UPDATE', eventPath));
|
|
242
243
|
}
|
|
243
244
|
else if (event.kind === 'create') {
|
|
244
245
|
record.loggingQueue.push(core_1.tags.oneLine `${pc.green('CREATE')} ${eventPath}`);
|
|
246
|
+
record.changes?.push(emptyFileChange('CREATE', eventPath));
|
|
245
247
|
}
|
|
246
248
|
else if (event.kind === 'delete') {
|
|
247
249
|
record.loggingQueue.push(`${pc.yellow('DELETE')} ${eventPath}`);
|
|
250
|
+
record.changes?.push({ type: 'DELETE', path: eventPath, content: null });
|
|
248
251
|
}
|
|
249
252
|
else if (event.kind === 'rename') {
|
|
250
253
|
record.loggingQueue.push(`${pc.blue('RENAME')} ${eventPath} => ${event.to}`);
|
|
254
|
+
// Surface as DELETE source + CREATE destination so downstream consumers
|
|
255
|
+
// (e.g. the agentic validation prompt's `<files_changed>` block) see
|
|
256
|
+
// both endpoints.
|
|
257
|
+
const toPath = event.to.startsWith('/') ? event.to.slice(1) : event.to;
|
|
258
|
+
record.changes?.push({ type: 'DELETE', path: eventPath, content: null });
|
|
259
|
+
record.changes?.push(emptyFileChange('CREATE', toPath));
|
|
251
260
|
}
|
|
252
261
|
};
|
|
253
262
|
}
|
|
263
|
+
// Empty content for non-DELETE FileChange entries: the Angular workflow has
|
|
264
|
+
// already flushed bytes to disk, and our only downstream consumer (agentic
|
|
265
|
+
// prompt builders) reads `path` + `type` only. `null` is reserved for DELETE.
|
|
266
|
+
function emptyFileChange(type, path) {
|
|
267
|
+
return { type, path, content: Buffer.alloc(0) };
|
|
268
|
+
}
|
|
254
269
|
async function runSchematic(host, root, workflow, logger, opts, schematic, printDryRunMessage = true, recorder = null) {
|
|
255
|
-
const record = {
|
|
270
|
+
const record = {
|
|
271
|
+
loggingQueue: [],
|
|
272
|
+
error: false,
|
|
273
|
+
};
|
|
256
274
|
workflow.reporter.subscribe(recorder || (await createRecorder(host, record, logger)));
|
|
257
275
|
try {
|
|
258
276
|
await workflow
|
|
@@ -643,7 +661,11 @@ async function runMigration(root, packageName, migrationName, projects, isVerbos
|
|
|
643
661
|
const fsHost = new NxScopeHostUsedForWrappedSchematics(root, new tree_1.FsTree(root, isVerbose, `ng-cli migration: ${packageName}:${migrationName}`), projectGraph);
|
|
644
662
|
const workflow = createWorkflow(fsHost, root, {}, projects);
|
|
645
663
|
const collection = resolveMigrationsCollection(packageName);
|
|
646
|
-
const record = {
|
|
664
|
+
const record = {
|
|
665
|
+
loggingQueue: [],
|
|
666
|
+
changes: [],
|
|
667
|
+
error: false,
|
|
668
|
+
};
|
|
647
669
|
workflow.reporter.subscribe(await createRecorder(fsHost, record, logger));
|
|
648
670
|
await workflow
|
|
649
671
|
.execute({
|
|
@@ -656,6 +678,7 @@ async function runMigration(root, packageName, migrationName, projects, isVerbos
|
|
|
656
678
|
.toPromise();
|
|
657
679
|
return {
|
|
658
680
|
loggingQueue: record.loggingQueue,
|
|
681
|
+
changes: record.changes,
|
|
659
682
|
madeChanges: record.loggingQueue.length > 0,
|
|
660
683
|
};
|
|
661
684
|
}
|
|
@@ -125,14 +125,31 @@ function cleanupOldCaches(currentCommitHash) {
|
|
|
125
125
|
function getAiConfigRepoPath() {
|
|
126
126
|
// 1. Get latest commit hash (first 10 chars)
|
|
127
127
|
const commitHash = getLatestCommitHash();
|
|
128
|
-
// 2.
|
|
128
|
+
// 2. Reuse cached version if it still has content (macOS may have
|
|
129
|
+
// swept its files but left the directory tree).
|
|
129
130
|
const cachedPath = (0, path_1.join)(CACHE_DIR, commitHash);
|
|
130
|
-
if ((
|
|
131
|
+
if (hasRootFile(cachedPath)) {
|
|
131
132
|
return cachedPath;
|
|
132
133
|
}
|
|
133
|
-
// 3.
|
|
134
|
+
// 3. Wipe any empty skeleton, then clone fresh
|
|
135
|
+
if ((0, fs_1.existsSync)(cachedPath)) {
|
|
136
|
+
(0, fs_1.rmSync)(cachedPath, { recursive: true, force: true });
|
|
137
|
+
}
|
|
134
138
|
cloneRepo(cachedPath);
|
|
135
139
|
// 4. Clean up old cached versions
|
|
136
140
|
cleanupOldCaches(commitHash);
|
|
137
141
|
return cachedPath;
|
|
138
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* The repo always has at least one regular file at its root (e.g. README).
|
|
145
|
+
* If everything at the root is a directory, the cache was swept by macOS
|
|
146
|
+
* tmp cleanup and we should re-clone.
|
|
147
|
+
*/
|
|
148
|
+
function hasRootFile(dir) {
|
|
149
|
+
try {
|
|
150
|
+
return (0, fs_1.readdirSync)(dir, { withFileTypes: true }).some((e) => e.isFile());
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -16,6 +16,7 @@ const native_1 = require("../native");
|
|
|
16
16
|
const package_manager_1 = require("../utils/package-manager");
|
|
17
17
|
const semver_1 = require("semver");
|
|
18
18
|
const os = tslib_1.__importStar(require("os"));
|
|
19
|
+
const crypto_1 = require("crypto");
|
|
19
20
|
const machine_id_cache_1 = require("../utils/machine-id-cache");
|
|
20
21
|
const is_ci_1 = require("../utils/is-ci");
|
|
21
22
|
const analytics_prompt_1 = require("../utils/analytics-prompt");
|
|
@@ -56,7 +57,7 @@ async function startAnalytics() {
|
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
58
59
|
const isNxCloud = !!(nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken);
|
|
59
|
-
const userId = await (
|
|
60
|
+
const userId = await getTelemetryUserId(workspaceId);
|
|
60
61
|
const packageManagerInfo = getPackageManagerInfo();
|
|
61
62
|
const nodeVersion = (0, semver_1.parse)(process.version);
|
|
62
63
|
const nodeVersionString = nodeVersion
|
|
@@ -225,3 +226,11 @@ function isAnalyticsEnabled() {
|
|
|
225
226
|
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
|
226
227
|
return nxJson?.analytics === true;
|
|
227
228
|
}
|
|
229
|
+
// Mix workspace id in: shared Docker images (Gitpod, Cypress, etc.) bake
|
|
230
|
+
// in /etc/machine-id, so machine-id alone collapses many users into one.
|
|
231
|
+
async function getTelemetryUserId(workspaceId) {
|
|
232
|
+
const machineId = await (0, machine_id_cache_1.getCurrentMachineId)();
|
|
233
|
+
return (0, crypto_1.createHash)('sha256')
|
|
234
|
+
.update(`${machineId}|${workspaceId}`)
|
|
235
|
+
.digest('hex');
|
|
236
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadata_1 = require("../completion/metadata");
|
|
4
|
+
const nx_package_group_1 = require("../../utils/nx-package-group");
|
|
5
|
+
// Same list `nx report` uses. Filter to first-party plugins and sort.
|
|
6
|
+
const FIRST_PARTY_PLUGINS = (0, nx_package_group_1.readNxPackageGroup)()
|
|
7
|
+
.filter((p) => p.startsWith('@nx/'))
|
|
8
|
+
.sort();
|
|
9
|
+
(0, metadata_1.registerCompletion)('add', {
|
|
10
|
+
positionals: [
|
|
11
|
+
{
|
|
12
|
+
complete: (current) => FIRST_PARTY_PLUGINS.filter((p) => p.startsWith(current)),
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const metadata_1 = require("../completion/metadata");
|
|
4
|
+
const completion_providers_1 = require("../completion/completion-providers");
|
|
5
|
+
// Aliases are written out; the fast path runs before yargs can resolve them.
|
|
6
|
+
(0, metadata_1.registerCompletion)('affected', {
|
|
7
|
+
flags: {
|
|
8
|
+
projects: completion_providers_1.getProjectNameCompletions,
|
|
9
|
+
p: completion_providers_1.getProjectNameCompletions,
|
|
10
|
+
exclude: completion_providers_1.getProjectNameCompletions,
|
|
11
|
+
targets: completion_providers_1.getTargetNameCompletions,
|
|
12
|
+
target: completion_providers_1.getTargetNameCompletions,
|
|
13
|
+
t: completion_providers_1.getTargetNameCompletions,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Wrappers must invoke nx with argv: [node, nx-bin, ...tokens, currentPartial].
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.parseCompletionArgs = parseCompletionArgs;
|
|
5
|
+
function parseCompletionArgs(argv = process.argv) {
|
|
6
|
+
const tail = argv.slice(2);
|
|
7
|
+
// Wrappers usually prepend the literal 'nx' (from COMP_WORDS /
|
|
8
|
+
// commandline -cop / etc.). They sometimes don't — most notably the
|
|
9
|
+
// `.nx/installation` wrapper invokes the real bin directly without the
|
|
10
|
+
// 'nx' token, and manual invocations like `NX_COMPLETE=fish nx show
|
|
11
|
+
// target in` for dev testing skip it too. Strip when present, otherwise
|
|
12
|
+
// take the args as-is.
|
|
13
|
+
const tokens = tail[0] === 'nx' ? tail.slice(1) : tail;
|
|
14
|
+
if (tokens.length === 0)
|
|
15
|
+
return null;
|
|
16
|
+
const current = tokens[tokens.length - 1] ?? '';
|
|
17
|
+
const previousToken = tokens.length >= 2 ? tokens[tokens.length - 2] : '';
|
|
18
|
+
return { tokens, current, previousToken };
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Slow-path entry point. Returns true if anything was emitted. */
|
|
2
|
+
export declare function tryCommandSurfaceCompletion(argv?: readonly string[]): boolean;
|
|
3
|
+
/** Top-level command names. Unions yargs handlers with the completion
|
|
4
|
+
* registry's single-token paths (infix targets). */
|
|
5
|
+
export declare function getTopLevelCommands(current: string, withDesc: boolean): string[] | null;
|
|
6
|
+
/**
|
|
7
|
+
* Enumerates subcommands + options of a matched top-level command. Returns
|
|
8
|
+
* null when no top-level command name is matched in `args`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getCommandCompletions(current: string, args: string[]): string[] | null;
|
|
11
|
+
/** value\tdescription separator. TAB because completion values can contain
|
|
12
|
+
* colons (`my-app:build`); descriptions get TABs collapsed. */
|
|
13
|
+
export declare const DESC_SEPARATOR = "\t";
|
|
14
|
+
/** Strip the y18n marker yargs prepends to its built-in --help / --version
|
|
15
|
+
* descriptions, and collapse stray TABs so they can't forge the
|
|
16
|
+
* value/description separator. */
|
|
17
|
+
export declare function formatDescription(raw: string | undefined): string;
|
|
18
|
+
/** zsh (compadd -d) and fish (complete -a) parse `value\tdescription`. */
|
|
19
|
+
export declare function shellRendersDescriptions(): boolean;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Slow-path completion: command/subcommand/flag names. Runs after
|
|
3
|
+
// tryValueCompletion has nothing to offer.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.DESC_SEPARATOR = void 0;
|
|
6
|
+
exports.tryCommandSurfaceCompletion = tryCommandSurfaceCompletion;
|
|
7
|
+
exports.getTopLevelCommands = getTopLevelCommands;
|
|
8
|
+
exports.getCommandCompletions = getCommandCompletions;
|
|
9
|
+
exports.formatDescription = formatDescription;
|
|
10
|
+
exports.shellRendersDescriptions = shellRendersDescriptions;
|
|
11
|
+
const trigger_1 = require("./trigger");
|
|
12
|
+
const argv_layout_1 = require("./argv-layout");
|
|
13
|
+
const metadata_1 = require("./metadata");
|
|
14
|
+
const command_handlers_1 = require("./command-handlers");
|
|
15
|
+
/** Slow-path entry point. Returns true if anything was emitted. */
|
|
16
|
+
function tryCommandSurfaceCompletion(argv = process.argv) {
|
|
17
|
+
const parsed = (0, argv_layout_1.parseCompletionArgs)(argv);
|
|
18
|
+
if (parsed === null)
|
|
19
|
+
return false;
|
|
20
|
+
const matched = getCommandCompletions(parsed.current, parsed.tokens);
|
|
21
|
+
const completions = matched !== null
|
|
22
|
+
? matched
|
|
23
|
+
: getTopLevelCommands(parsed.current, shellRendersDescriptions());
|
|
24
|
+
if (completions === null || completions.length === 0)
|
|
25
|
+
return false;
|
|
26
|
+
for (const line of completions) {
|
|
27
|
+
console.log(line);
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/** Top-level command names. Unions yargs handlers with the completion
|
|
32
|
+
* registry's single-token paths (infix targets). */
|
|
33
|
+
function getTopLevelCommands(current, withDesc) {
|
|
34
|
+
const handlers = (0, command_handlers_1.getNxCommandHandlers)();
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const completions = [];
|
|
37
|
+
for (const name of Object.keys(handlers)) {
|
|
38
|
+
if (name === '$0' || name.startsWith('_'))
|
|
39
|
+
continue;
|
|
40
|
+
if (current && !name.startsWith(current))
|
|
41
|
+
continue;
|
|
42
|
+
const handler = handlers[name];
|
|
43
|
+
if (handler?.description === false)
|
|
44
|
+
continue; // hidden
|
|
45
|
+
seen.add(name);
|
|
46
|
+
const desc = withDesc ? formatDescription(handler?.description) : '';
|
|
47
|
+
completions.push(desc ? `${name}${exports.DESC_SEPARATOR}${desc}` : name);
|
|
48
|
+
}
|
|
49
|
+
// Infix targets + any other top-level completion-only paths.
|
|
50
|
+
for (const name of (0, metadata_1.getRegisteredTopLevelPaths)()) {
|
|
51
|
+
if (seen.has(name))
|
|
52
|
+
continue;
|
|
53
|
+
if (current && !name.startsWith(current))
|
|
54
|
+
continue;
|
|
55
|
+
seen.add(name);
|
|
56
|
+
completions.push(name);
|
|
57
|
+
}
|
|
58
|
+
return completions;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Enumerates subcommands + options of a matched top-level command. Returns
|
|
62
|
+
* null when no top-level command name is matched in `args`.
|
|
63
|
+
*/
|
|
64
|
+
function getCommandCompletions(current, args) {
|
|
65
|
+
const handlers = (0, command_handlers_1.getNxCommandHandlers)();
|
|
66
|
+
const cmdName = args.find((a) => handlers[a]);
|
|
67
|
+
if (!cmdName) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
const handler = handlers[cmdName];
|
|
71
|
+
// Once we recognize a top-level command in `args`, we own the slot —
|
|
72
|
+
// return [] (not null) for the "found a command but can't enumerate its
|
|
73
|
+
// surface" case so the caller doesn't fall back to top-level commands
|
|
74
|
+
// (which would mis-offer e.g. `exec` for `nx g c ex`).
|
|
75
|
+
if (typeof handler.builder !== 'function') {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
const intro = (0, command_handlers_1.introspectBuilder)(handler.builder);
|
|
79
|
+
if (!intro)
|
|
80
|
+
return [];
|
|
81
|
+
const completions = [];
|
|
82
|
+
const isFlagPrefix = current.startsWith('-');
|
|
83
|
+
const withDesc = shellRendersDescriptions();
|
|
84
|
+
if (!isFlagPrefix) {
|
|
85
|
+
for (const [name, desc] of intro.subcommands) {
|
|
86
|
+
const formatted = withDesc ? formatDescription(desc) : '';
|
|
87
|
+
completions.push(formatted ? `${name}${exports.DESC_SEPARATOR}${formatted}` : name);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const [name, desc] of intro.options) {
|
|
91
|
+
const formatted = withDesc ? formatDescription(desc) : '';
|
|
92
|
+
completions.push(formatted ? `--${name}${exports.DESC_SEPARATOR}${formatted}` : `--${name}`);
|
|
93
|
+
}
|
|
94
|
+
if (!current) {
|
|
95
|
+
return completions;
|
|
96
|
+
}
|
|
97
|
+
const flagName = current.replace(/^-+/, '');
|
|
98
|
+
return completions.filter((c) => {
|
|
99
|
+
if (isFlagPrefix) {
|
|
100
|
+
return c.startsWith(`--${flagName}`);
|
|
101
|
+
}
|
|
102
|
+
return c.startsWith(current);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/** value\tdescription separator. TAB because completion values can contain
|
|
106
|
+
* colons (`my-app:build`); descriptions get TABs collapsed. */
|
|
107
|
+
exports.DESC_SEPARATOR = '\t';
|
|
108
|
+
/** Strip the y18n marker yargs prepends to its built-in --help / --version
|
|
109
|
+
* descriptions, and collapse stray TABs so they can't forge the
|
|
110
|
+
* value/description separator. */
|
|
111
|
+
function formatDescription(raw) {
|
|
112
|
+
if (!raw)
|
|
113
|
+
return '';
|
|
114
|
+
return raw.replace(/^__yargsString__:/, '').replace(/\t/g, ' ');
|
|
115
|
+
}
|
|
116
|
+
/** zsh (compadd -d) and fish (complete -a) parse `value\tdescription`. */
|
|
117
|
+
function shellRendersDescriptions() {
|
|
118
|
+
const shell = (0, trigger_1.getCompletionShell)();
|
|
119
|
+
return shell === 'zsh' || shell === 'fish';
|
|
120
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** A single entry from yargs' `getCommandHandlers()`. */
|
|
2
|
+
export interface CommandHandler {
|
|
3
|
+
description?: string | false;
|
|
4
|
+
builder?: (yargs: any) => any;
|
|
5
|
+
}
|
|
6
|
+
export type CommandHandlers = Record<string, CommandHandler>;
|
|
7
|
+
/**
|
|
8
|
+
* Reach into the yargs commandsObject to enumerate registered command
|
|
9
|
+
* handlers. Lazy-required: nx-commands pulls in the full command tree
|
|
10
|
+
* and is only needed on the slow path.
|
|
11
|
+
*
|
|
12
|
+
* Yargs only keys handlers by canonical name. We mirror each alias to its
|
|
13
|
+
* canonical handler reference so lookups like `handlers['g']` resolve to
|
|
14
|
+
* the same entry as `handlers['generate']`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getNxCommandHandlers(): CommandHandlers;
|
|
17
|
+
/** Subcommand name → description, visible-option name → description, and
|
|
18
|
+
* canonical option name → its yargs-declared aliases (e.g. projects → [p]). */
|
|
19
|
+
export interface BuilderIntrospection {
|
|
20
|
+
subcommands: Map<string, string | undefined>;
|
|
21
|
+
options: Map<string, string | undefined>;
|
|
22
|
+
aliases: Map<string, string[]>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Run a yargs builder against a throwaway instance and return its declared
|
|
26
|
+
* subcommands, visible options, and option-alias groups. Returns null if
|
|
27
|
+
* the builder throws. Does NOT call `.argv` — would trigger parse and the
|
|
28
|
+
* help-printing path we're avoiding.
|
|
29
|
+
*/
|
|
30
|
+
export declare function introspectBuilder(builder: (yargs: any) => any): BuilderIntrospection | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNxCommandHandlers = getNxCommandHandlers;
|
|
4
|
+
exports.introspectBuilder = introspectBuilder;
|
|
5
|
+
/**
|
|
6
|
+
* Reach into the yargs commandsObject to enumerate registered command
|
|
7
|
+
* handlers. Lazy-required: nx-commands pulls in the full command tree
|
|
8
|
+
* and is only needed on the slow path.
|
|
9
|
+
*
|
|
10
|
+
* Yargs only keys handlers by canonical name. We mirror each alias to its
|
|
11
|
+
* canonical handler reference so lookups like `handlers['g']` resolve to
|
|
12
|
+
* the same entry as `handlers['generate']`.
|
|
13
|
+
*/
|
|
14
|
+
function getNxCommandHandlers() {
|
|
15
|
+
const { commandsObject } = require('../nx-commands');
|
|
16
|
+
const internal = commandsObject.getInternalMethods();
|
|
17
|
+
const handlers = { ...internal.getCommandInstance().getCommandHandlers() };
|
|
18
|
+
for (const row of internal.getUsageInstance().getCommands()) {
|
|
19
|
+
// usage.getCommands() rows: [usagePattern, description, isDefault, aliases, deprecated]
|
|
20
|
+
const usagePattern = String(row[0] ?? '');
|
|
21
|
+
const aliases = Array.isArray(row[3]) ? row[3] : [];
|
|
22
|
+
const canonical = usagePattern.split(/\s+/)[0];
|
|
23
|
+
const handler = handlers[canonical];
|
|
24
|
+
if (!handler)
|
|
25
|
+
continue;
|
|
26
|
+
for (const alias of aliases) {
|
|
27
|
+
if (!handlers[alias])
|
|
28
|
+
handlers[alias] = handler;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return handlers;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Run a yargs builder against a throwaway instance and return its declared
|
|
35
|
+
* subcommands, visible options, and option-alias groups. Returns null if
|
|
36
|
+
* the builder throws. Does NOT call `.argv` — would trigger parse and the
|
|
37
|
+
* help-printing path we're avoiding.
|
|
38
|
+
*/
|
|
39
|
+
function introspectBuilder(builder) {
|
|
40
|
+
const yargs = require('yargs');
|
|
41
|
+
const temp = yargs();
|
|
42
|
+
try {
|
|
43
|
+
builder(temp);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const usage = temp.getInternalMethods().getUsageInstance();
|
|
49
|
+
const subcommands = new Map();
|
|
50
|
+
for (const [usagePattern, desc] of usage.getCommands()) {
|
|
51
|
+
const name = String(usagePattern).split(/\s+/)[0];
|
|
52
|
+
if (name === '$0')
|
|
53
|
+
continue;
|
|
54
|
+
subcommands.set(name, desc);
|
|
55
|
+
}
|
|
56
|
+
const opts = temp.getOptions();
|
|
57
|
+
const descriptions = usage.getDescriptions();
|
|
58
|
+
const options = new Map();
|
|
59
|
+
for (const k of Object.keys(opts.key ?? {})) {
|
|
60
|
+
if ((opts.hiddenOptions ?? []).includes(k))
|
|
61
|
+
continue;
|
|
62
|
+
options.set(k, descriptions[k]);
|
|
63
|
+
}
|
|
64
|
+
const aliases = new Map();
|
|
65
|
+
for (const [canonical, list] of Object.entries(opts.alias ?? {})) {
|
|
66
|
+
aliases.set(canonical, list);
|
|
67
|
+
}
|
|
68
|
+
return { subcommands, options, aliases };
|
|
69
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandModule } from 'yargs';
|
|
2
|
+
declare const SHELL_CHOICES: readonly ["bash", "zsh", "fish", "powershell"];
|
|
3
|
+
type Shell = (typeof SHELL_CHOICES)[number];
|
|
4
|
+
interface CompletionArgs {
|
|
5
|
+
shell?: Shell;
|
|
6
|
+
force?: boolean;
|
|
7
|
+
stdout?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const yargsCompletionCommand: CommandModule<{}, CompletionArgs>;
|
|
10
|
+
export {};
|