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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
###-begin-nx-completions-###
|
|
2
|
+
#
|
|
3
|
+
# nx command completion script
|
|
4
|
+
#
|
|
5
|
+
# Installation: nx completion zsh >> ~/.zshrc
|
|
6
|
+
# or: nx completion zsh > /usr/local/share/zsh/site-functions/_nx
|
|
7
|
+
#
|
|
8
|
+
if type compdef &>/dev/null; then
|
|
9
|
+
_nx_completions () {
|
|
10
|
+
local reply nx_cmd dir
|
|
11
|
+
local si=$IFS
|
|
12
|
+
|
|
13
|
+
# Walk up for a workspace-local nx; fall back to PATH outside a workspace.
|
|
14
|
+
nx_cmd="nx"
|
|
15
|
+
dir="$PWD"
|
|
16
|
+
while [[ "$dir" != "/" ]]; do
|
|
17
|
+
if [[ -x "$dir/node_modules/.bin/nx" ]]; then
|
|
18
|
+
nx_cmd="$dir/node_modules/.bin/nx"
|
|
19
|
+
break
|
|
20
|
+
fi
|
|
21
|
+
if [[ -x "$dir/.nx/installation/node_modules/.bin/nx" ]]; then
|
|
22
|
+
nx_cmd="$dir/.nx/installation/node_modules/.bin/nx"
|
|
23
|
+
break
|
|
24
|
+
fi
|
|
25
|
+
dir="${dir:h}"
|
|
26
|
+
done
|
|
27
|
+
|
|
28
|
+
# Hide stderr so stray warnings don't land in the buffer; NX_VERBOSE_LOGGING surfaces it.
|
|
29
|
+
if [[ -n "$NX_VERBOSE_LOGGING" ]]; then
|
|
30
|
+
IFS=$'\n' reply=($(NX_COMPLETE=zsh "$nx_cmd" "${words[@]}"))
|
|
31
|
+
else
|
|
32
|
+
IFS=$'\n' reply=($(NX_COMPLETE=zsh "$nx_cmd" "${words[@]}" 2>/dev/null))
|
|
33
|
+
fi
|
|
34
|
+
IFS=$si
|
|
35
|
+
|
|
36
|
+
# Split `value\tdescription` into parallel arrays for compadd -d. Don't
|
|
37
|
+
# use _describe: it splits on ':', mangling values like `my-app:build`.
|
|
38
|
+
local -a values displays
|
|
39
|
+
local r value nospace=0
|
|
40
|
+
for r in $reply; do
|
|
41
|
+
value="${r%%$'\t'*}"
|
|
42
|
+
values+=("$value")
|
|
43
|
+
if [[ "$r" == *$'\t'* ]]; then
|
|
44
|
+
displays+=("$value -- ${r#*$'\t'}")
|
|
45
|
+
else
|
|
46
|
+
displays+=("$value")
|
|
47
|
+
fi
|
|
48
|
+
[[ "$value" == *: ]] && nospace=1 # trailing ':' → nospace
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
if (( ${#values} == 0 )); then
|
|
52
|
+
# Nothing to suggest — fall back to filename completion (covers
|
|
53
|
+
# `nx g app --directory <TAB>` and similar unknown-flag values).
|
|
54
|
+
_files
|
|
55
|
+
return
|
|
56
|
+
fi
|
|
57
|
+
if (( nospace )); then
|
|
58
|
+
compadd -S '' -d displays -a values
|
|
59
|
+
else
|
|
60
|
+
compadd -d displays -a values
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
compdef _nx_completions nx
|
|
64
|
+
else
|
|
65
|
+
echo "nx: shell completion requires zsh's completion system to be loaded." >&2
|
|
66
|
+
echo " Add the following line to your ~/.zshrc above this block:" >&2
|
|
67
|
+
echo " autoload -U compinit && compinit" >&2
|
|
68
|
+
fi
|
|
69
|
+
###-end-nx-completions-###
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Shell = 'bash' | 'zsh' | 'fish' | 'powershell';
|
|
2
|
+
export declare const SHELLS: readonly Shell[];
|
|
3
|
+
/** Print the raw wrapper script to stdout — for scripting / custom rc paths. */
|
|
4
|
+
export declare function printCompletionScript(shell: Shell): void;
|
|
5
|
+
/**
|
|
6
|
+
* Write the wrapper to the shell's default rc location, replacing any prior
|
|
7
|
+
* nx-completion block (idempotent via the begin/end markers). Logs the
|
|
8
|
+
* resolved path and a one-line "open a new shell" hint.
|
|
9
|
+
*/
|
|
10
|
+
export declare function installCompletionScript(shell: Shell): void;
|
|
11
|
+
/**
|
|
12
|
+
* Stderr advisory when `nx` is not on PATH — the wrappers walk up for a
|
|
13
|
+
* workspace-local nx, but the outside-workspace fallback needs `nx`
|
|
14
|
+
* reachable by name. Callers fire this ONCE per invocation even when
|
|
15
|
+
* installing for multiple shells.
|
|
16
|
+
*/
|
|
17
|
+
export declare function maybeWarnNxNotOnPath(): void;
|
|
18
|
+
export declare function generateScript(shell: Shell): string;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHELLS = void 0;
|
|
4
|
+
exports.printCompletionScript = printCompletionScript;
|
|
5
|
+
exports.installCompletionScript = installCompletionScript;
|
|
6
|
+
exports.maybeWarnNxNotOnPath = maybeWarnNxNotOnPath;
|
|
7
|
+
exports.generateScript = generateScript;
|
|
8
|
+
const child_process_1 = require("child_process");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const os_1 = require("os");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
exports.SHELLS = ['bash', 'zsh', 'fish', 'powershell'];
|
|
13
|
+
/** Print the raw wrapper script to stdout — for scripting / custom rc paths. */
|
|
14
|
+
function printCompletionScript(shell) {
|
|
15
|
+
process.stdout.write(generateScript(shell));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Write the wrapper to the shell's default rc location, replacing any prior
|
|
19
|
+
* nx-completion block (idempotent via the begin/end markers). Logs the
|
|
20
|
+
* resolved path and a one-line "open a new shell" hint.
|
|
21
|
+
*/
|
|
22
|
+
function installCompletionScript(shell) {
|
|
23
|
+
writeScriptToRcFile(shell);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Stderr advisory when `nx` is not on PATH — the wrappers walk up for a
|
|
27
|
+
* workspace-local nx, but the outside-workspace fallback needs `nx`
|
|
28
|
+
* reachable by name. Callers fire this ONCE per invocation even when
|
|
29
|
+
* installing for multiple shells.
|
|
30
|
+
*/
|
|
31
|
+
function maybeWarnNxNotOnPath() {
|
|
32
|
+
if (isNxOnPath())
|
|
33
|
+
return;
|
|
34
|
+
console.warn([
|
|
35
|
+
`nx: \`nx\` is not on your PATH.`,
|
|
36
|
+
` The generated wrappers resolve a workspace-local nx when you`,
|
|
37
|
+
` tab-complete inside a project, but outside any workspace they`,
|
|
38
|
+
` fall back to a bare \`nx\`. Install nx globally so completion`,
|
|
39
|
+
` works everywhere (e.g. \`pnpm add -g nx\` or \`npm i -g nx\`).`,
|
|
40
|
+
` Continuing — pass --force to skip this notice.`,
|
|
41
|
+
].join('\n'));
|
|
42
|
+
}
|
|
43
|
+
function writeScriptToRcFile(shell) {
|
|
44
|
+
const script = generateScript(shell);
|
|
45
|
+
const paths = installPathsFor(shell);
|
|
46
|
+
if (paths.length === 0) {
|
|
47
|
+
console.warn(`nx: automatic install isn't supported for ${shell} yet — run with --stdout and redirect manually.`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (const path of paths) {
|
|
51
|
+
writeOneRcFile(shell, path, script);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function writeOneRcFile(shell, path, script) {
|
|
55
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
|
|
56
|
+
// Fish keeps each completion in its own file (a full overwrite is correct).
|
|
57
|
+
// bash/zsh/powershell append to a shared rc file: skip if an nx-completion
|
|
58
|
+
// block is already present so re-runs are no-ops, and never modify
|
|
59
|
+
// existing content — the user may have customized around the block.
|
|
60
|
+
if (shell === 'fish') {
|
|
61
|
+
(0, fs_1.writeFileSync)(path, script);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const existing = (0, fs_1.existsSync)(path) ? (0, fs_1.readFileSync)(path, 'utf8') : '';
|
|
65
|
+
if (existing.includes('###-begin-nx-completions-###')) {
|
|
66
|
+
console.warn(`nx: ${shell} completion already present in ${path} — skipping.\n` +
|
|
67
|
+
` Remove the existing block manually if you need to reinstall.`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const sep = existing && !existing.endsWith('\n') ? '\n' : '';
|
|
71
|
+
(0, fs_1.writeFileSync)(path, existing + sep + script);
|
|
72
|
+
}
|
|
73
|
+
console.warn(`nx: ${shell} completion installed at ${path}.\n` +
|
|
74
|
+
` Open a new shell (or re-source the rc file) to activate.`);
|
|
75
|
+
}
|
|
76
|
+
function installPathsFor(shell) {
|
|
77
|
+
const home = (0, os_1.homedir)();
|
|
78
|
+
switch (shell) {
|
|
79
|
+
case 'bash':
|
|
80
|
+
return [(0, path_1.join)(home, '.bashrc')];
|
|
81
|
+
case 'zsh':
|
|
82
|
+
return [(0, path_1.join)(home, '.zshrc')];
|
|
83
|
+
case 'fish':
|
|
84
|
+
return [(0, path_1.join)(home, '.config', 'fish', 'completions', 'nx.fish')];
|
|
85
|
+
case 'powershell':
|
|
86
|
+
return resolvePowerShellProfiles();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Shell out to each available PowerShell to expand $PROFILE. The variable's
|
|
91
|
+
* resolution depends on the PS version (5.1 vs 7), $PSVersionTable, and
|
|
92
|
+
* Windows Documents-folder redirection (OneDrive etc.), so asking PS itself
|
|
93
|
+
* is the only reliable way. Returns every distinct profile path we find —
|
|
94
|
+
* PS 5.1 and PS 7 keep separate profile files, so a user with both
|
|
95
|
+
* installed needs the wrapper written to both.
|
|
96
|
+
*/
|
|
97
|
+
function resolvePowerShellProfiles() {
|
|
98
|
+
const candidates = process.platform === 'win32' ? ['pwsh.exe', 'powershell.exe'] : ['pwsh'];
|
|
99
|
+
const paths = [];
|
|
100
|
+
for (const exe of candidates) {
|
|
101
|
+
const result = (0, child_process_1.spawnSync)(exe, ['-NoProfile', '-Command', '$PROFILE'], {
|
|
102
|
+
encoding: 'utf8',
|
|
103
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
104
|
+
windowsHide: true,
|
|
105
|
+
});
|
|
106
|
+
if (result.status !== 0 || !result.stdout)
|
|
107
|
+
continue;
|
|
108
|
+
const path = result.stdout.trim();
|
|
109
|
+
if (path && !paths.includes(path))
|
|
110
|
+
paths.push(path);
|
|
111
|
+
}
|
|
112
|
+
return paths;
|
|
113
|
+
}
|
|
114
|
+
function isNxOnPath() {
|
|
115
|
+
const pathEnv = process.env.PATH;
|
|
116
|
+
if (!pathEnv)
|
|
117
|
+
return false;
|
|
118
|
+
const names = process.platform === 'win32' ? ['nx.cmd', 'nx.exe', 'nx'] : ['nx'];
|
|
119
|
+
for (const dir of pathEnv.split(path_1.delimiter)) {
|
|
120
|
+
if (!dir)
|
|
121
|
+
continue;
|
|
122
|
+
for (const name of names) {
|
|
123
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, name)))
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
// Wrappers live as plain files in ./scripts/ for syntax highlighting and
|
|
130
|
+
// shellcheck. Read at call time — each invocation needs each shell's
|
|
131
|
+
// wrapper at most once.
|
|
132
|
+
const WRAPPER_FILES = {
|
|
133
|
+
bash: 'bash.sh',
|
|
134
|
+
zsh: 'zsh.zsh',
|
|
135
|
+
fish: 'fish.fish',
|
|
136
|
+
powershell: 'powershell.ps1',
|
|
137
|
+
};
|
|
138
|
+
function generateScript(shell) {
|
|
139
|
+
return (0, fs_1.readFileSync)((0, path_1.join)(__dirname, 'scripts', WRAPPER_FILES[shell]), 'utf-8');
|
|
140
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Shell detection via NX_COMPLETE env var (set by the wrappers).
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isCompletionRequest = isCompletionRequest;
|
|
5
|
+
exports.getCompletionShell = getCompletionShell;
|
|
6
|
+
const KNOWN_SHELLS = new Set([
|
|
7
|
+
'bash',
|
|
8
|
+
'zsh',
|
|
9
|
+
'fish',
|
|
10
|
+
'powershell',
|
|
11
|
+
]);
|
|
12
|
+
function isCompletionRequest() {
|
|
13
|
+
return Boolean(process.env.NX_COMPLETE);
|
|
14
|
+
}
|
|
15
|
+
function getCompletionShell() {
|
|
16
|
+
const raw = process.env.NX_COMPLETE;
|
|
17
|
+
if (raw && KNOWN_SHELLS.has(raw)) {
|
|
18
|
+
return raw;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Fast-path completion: project/target/generator/flag values, served from
|
|
3
|
+
// registered metadata without loading the yargs command surface.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.tryValueCompletion = tryValueCompletion;
|
|
6
|
+
require("./registrations");
|
|
7
|
+
const metadata_1 = require("./metadata");
|
|
8
|
+
const argv_layout_1 = require("./argv-layout");
|
|
9
|
+
/** Returns true if handled — caller should not fall through. */
|
|
10
|
+
function tryValueCompletion(argv = process.argv) {
|
|
11
|
+
const parsed = (0, argv_layout_1.parseCompletionArgs)(argv);
|
|
12
|
+
if (parsed === null)
|
|
13
|
+
return false;
|
|
14
|
+
const completions = (0, metadata_1.resolveCompletion)(parsed.tokens, parsed.current, parsed.previousToken);
|
|
15
|
+
if (completions === null)
|
|
16
|
+
return false;
|
|
17
|
+
for (const line of completions) {
|
|
18
|
+
console.log(line);
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
@@ -378,7 +378,7 @@ exports.examples = {
|
|
|
378
378
|
description: 'Watch the "app" project and echo the project name and the files that changed',
|
|
379
379
|
},
|
|
380
380
|
{
|
|
381
|
-
command: 'watch --projects=app1,app2 --
|
|
381
|
+
command: 'watch --projects=app1,app2 --includeDependencies -- echo \\$NX_PROJECT_NAME',
|
|
382
382
|
description: 'Watch "app1" and "app2" and echo the project name whenever a specified project or its dependencies change',
|
|
383
383
|
},
|
|
384
384
|
{
|
|
@@ -34,10 +34,15 @@ async function format(command, args) {
|
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', { printWarnings: false }, (0, configuration_1.readNxJson)());
|
|
37
|
-
const patterns = (await getPatterns(prettier, { ...args, ...nxArgs })).map(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
const patterns = (await getPatterns(prettier, { ...args, ...nxArgs })).map((p) => {
|
|
38
|
+
// On non-Windows, escape $ to prevent shell variable interpolation
|
|
39
|
+
// (the shell consumes one \, so \\$ becomes \$ which the shell treats as literal $)
|
|
40
|
+
// On Windows (cmd.exe), $ is not a special character, so escaping it would
|
|
41
|
+
// cause prettier to look for a file with a literal \$ in the name
|
|
42
|
+
// prettier-ignore
|
|
43
|
+
const escaped = process.platform !== 'win32' ? p.replace(/\$/g, '\\\$') : p;
|
|
44
|
+
return `"${escaped}"`;
|
|
45
|
+
});
|
|
41
46
|
// Chunkify the patterns array to prevent crashing the windows terminal
|
|
42
47
|
const chunkList = (0, chunkify_1.chunkify)(patterns);
|
|
43
48
|
switch (command) {
|
|
@@ -204,7 +209,12 @@ function getPrettierPath() {
|
|
|
204
209
|
return prettierPath;
|
|
205
210
|
}
|
|
206
211
|
const { packageJson, path: packageJsonPath } = (0, package_json_1.readModulePackageJson)('prettier');
|
|
207
|
-
|
|
212
|
+
const bin = packageJson.bin;
|
|
213
|
+
const binPath = typeof bin === 'string' ? bin : bin?.['prettier'];
|
|
214
|
+
if (!binPath) {
|
|
215
|
+
throw new Error(`Could not find prettier binary in ${packageJsonPath}`);
|
|
216
|
+
}
|
|
217
|
+
prettierPath = path.resolve(path.dirname(packageJsonPath), binPath);
|
|
208
218
|
return prettierPath;
|
|
209
219
|
}
|
|
210
220
|
let useListDifferent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
const generateCompletion = {
|
|
6
|
+
positionals: [{ complete: completion_providers_1.completeGenerator }],
|
|
7
|
+
};
|
|
8
|
+
(0, metadata_1.registerCompletion)('generate', generateCompletion);
|
|
9
|
+
(0, metadata_1.registerCompletion)('g', generateCompletion); // alias
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
(0, metadata_1.registerCompletion)('graph', {
|
|
6
|
+
flags: {
|
|
7
|
+
focus: completion_providers_1.getProjectNameCompletions,
|
|
8
|
+
exclude: completion_providers_1.getProjectNameCompletions,
|
|
9
|
+
targets: completion_providers_1.getTargetNameCompletions,
|
|
10
|
+
target: completion_providers_1.getTargetNameCompletions,
|
|
11
|
+
t: completion_providers_1.getTargetNameCompletions,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -54,29 +54,26 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
54
54
|
: []),
|
|
55
55
|
].filter(Boolean),
|
|
56
56
|
};
|
|
57
|
-
nxJson.targetDefaults
|
|
57
|
+
const defaults = Array.isArray(nxJson.targetDefaults)
|
|
58
|
+
? [...nxJson.targetDefaults]
|
|
59
|
+
: [];
|
|
58
60
|
if (workspaceTargets.includes('build')) {
|
|
59
|
-
|
|
60
|
-
...nxJson.targetDefaults.build,
|
|
61
|
+
(0, utils_1.upsertTargetDefaultEntry)(defaults, 'build', {
|
|
61
62
|
dependsOn: ['^build'],
|
|
62
63
|
inputs: ['production', '^production'],
|
|
63
|
-
};
|
|
64
|
+
});
|
|
64
65
|
}
|
|
65
66
|
if (workspaceTargets.includes('server')) {
|
|
66
|
-
|
|
67
|
-
...nxJson.targetDefaults.server,
|
|
67
|
+
(0, utils_1.upsertTargetDefaultEntry)(defaults, 'server', {
|
|
68
68
|
inputs: ['production', '^production'],
|
|
69
|
-
};
|
|
69
|
+
});
|
|
70
70
|
}
|
|
71
71
|
if (workspaceTargets.includes('test')) {
|
|
72
72
|
const inputs = ['default', '^production'];
|
|
73
73
|
if ((0, fileutils_1.fileExists)((0, node_path_1.join)(repoRoot, 'karma.conf.js'))) {
|
|
74
74
|
inputs.push('{workspaceRoot}/karma.conf.js');
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
...nxJson.targetDefaults.test,
|
|
78
|
-
inputs,
|
|
79
|
-
};
|
|
76
|
+
(0, utils_1.upsertTargetDefaultEntry)(defaults, 'test', { inputs });
|
|
80
77
|
}
|
|
81
78
|
if (workspaceTargets.includes('lint')) {
|
|
82
79
|
const inputs = ['default'];
|
|
@@ -86,16 +83,15 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
86
83
|
if ((0, fileutils_1.fileExists)((0, node_path_1.join)(repoRoot, 'eslint.config.cjs'))) {
|
|
87
84
|
inputs.push('{workspaceRoot}/eslint.config.cjs');
|
|
88
85
|
}
|
|
89
|
-
|
|
90
|
-
...nxJson.targetDefaults.lint,
|
|
91
|
-
inputs,
|
|
92
|
-
};
|
|
86
|
+
(0, utils_1.upsertTargetDefaultEntry)(defaults, 'lint', { inputs });
|
|
93
87
|
}
|
|
94
88
|
if (workspaceTargets.includes('e2e')) {
|
|
95
|
-
|
|
96
|
-
...nxJson.targetDefaults.e2e,
|
|
89
|
+
(0, utils_1.upsertTargetDefaultEntry)(defaults, 'e2e', {
|
|
97
90
|
inputs: ['default', '^production'],
|
|
98
|
-
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (defaults.length > 0) {
|
|
94
|
+
nxJson.targetDefaults = defaults;
|
|
99
95
|
}
|
|
100
96
|
(0, fileutils_1.writeJsonFile)((0, node_path_1.join)(repoRoot, 'nx.json'), nxJson);
|
|
101
97
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { NxJsonConfiguration } from '../../../config/nx-json';
|
|
1
|
+
import { NxJsonConfiguration, TargetDefaultEntry } from '../../../config/nx-json';
|
|
2
2
|
import { PackageJson } from '../../../utils/package-json';
|
|
3
3
|
import { PackageManagerCommands } from '../../../utils/package-manager';
|
|
4
4
|
export declare function createNxJsonFile(repoRoot: string, topologicalTargets: string[], cacheableOperations: string[], scriptOutputs: {
|
|
5
5
|
[name: string]: string;
|
|
6
6
|
}): void;
|
|
7
|
+
/**
|
|
8
|
+
* Locate-by-target upsert against an in-memory `targetDefaults` array.
|
|
9
|
+
* Used by `nx init` code paths that operate on raw JSON before a Tree
|
|
10
|
+
* exists — generators should use `upsertTargetDefault` from devkit instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function upsertTargetDefaultEntry(entries: TargetDefaultEntry[], target: string, patch: Partial<TargetDefaultEntry>): void;
|
|
7
13
|
export declare function createNxJsonFromTurboJson(turboJson: Record<string, any>): NxJsonConfiguration;
|
|
8
14
|
export declare function addDepsToPackageJson(repoRoot: string, additionalPackages?: string[]): void;
|
|
9
15
|
export declare function updateGitIgnore(root: string): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNxJsonFile = createNxJsonFile;
|
|
4
|
+
exports.upsertTargetDefaultEntry = upsertTargetDefaultEntry;
|
|
4
5
|
exports.createNxJsonFromTurboJson = createNxJsonFromTurboJson;
|
|
5
6
|
exports.addDepsToPackageJson = addDepsToPackageJson;
|
|
6
7
|
exports.updateGitIgnore = updateGitIgnore;
|
|
@@ -34,27 +35,37 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
|
|
|
34
35
|
}
|
|
35
36
|
catch { }
|
|
36
37
|
nxJson.$schema = './node_modules/nx/schemas/nx-schema.json';
|
|
37
|
-
nxJson.targetDefaults
|
|
38
|
+
const entries = Array.isArray(nxJson.targetDefaults)
|
|
39
|
+
? [...nxJson.targetDefaults]
|
|
40
|
+
: [];
|
|
38
41
|
if (topologicalTargets.length > 0) {
|
|
39
42
|
for (const scriptName of topologicalTargets) {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
upsertTargetDefaultEntry(entries, scriptName, {
|
|
44
|
+
dependsOn: [`^${scriptName}`],
|
|
45
|
+
});
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
for (const [scriptName, output] of Object.entries(scriptOutputs)) {
|
|
45
49
|
if (!output) {
|
|
46
50
|
continue;
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
upsertTargetDefaultEntry(entries, scriptName, {
|
|
53
|
+
outputs: [`{projectRoot}/${output}`],
|
|
54
|
+
});
|
|
50
55
|
}
|
|
51
56
|
for (const target of cacheableOperations) {
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const existing = findUnfilteredTargetEntry(entries, target);
|
|
58
|
+
if (existing)
|
|
59
|
+
existing.cache ??= true;
|
|
60
|
+
else
|
|
61
|
+
entries.push({ target, cache: true });
|
|
54
62
|
}
|
|
55
|
-
if (
|
|
63
|
+
if (entries.length === 0) {
|
|
56
64
|
delete nxJson.targetDefaults;
|
|
57
65
|
}
|
|
66
|
+
else {
|
|
67
|
+
nxJson.targetDefaults = entries;
|
|
68
|
+
}
|
|
58
69
|
const defaultBase = (0, deduce_default_base_1.deduceDefaultBase)();
|
|
59
70
|
// Do not add defaultBase if it is inferred to be the Nx default value of main
|
|
60
71
|
if (defaultBase !== 'main') {
|
|
@@ -62,6 +73,21 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
|
|
|
62
73
|
}
|
|
63
74
|
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
64
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Locate-by-target upsert against an in-memory `targetDefaults` array.
|
|
78
|
+
* Used by `nx init` code paths that operate on raw JSON before a Tree
|
|
79
|
+
* exists — generators should use `upsertTargetDefault` from devkit instead.
|
|
80
|
+
*/
|
|
81
|
+
function upsertTargetDefaultEntry(entries, target, patch) {
|
|
82
|
+
const existing = findUnfilteredTargetEntry(entries, target);
|
|
83
|
+
if (existing)
|
|
84
|
+
Object.assign(existing, patch, { target });
|
|
85
|
+
else
|
|
86
|
+
entries.push({ ...patch, target });
|
|
87
|
+
}
|
|
88
|
+
function findUnfilteredTargetEntry(entries, target) {
|
|
89
|
+
return entries.find((e) => e.target === target && e.projects === undefined && e.plugin === undefined);
|
|
90
|
+
}
|
|
65
91
|
function createNxJsonFromTurboJson(turboJson) {
|
|
66
92
|
const nxJson = {
|
|
67
93
|
$schema: './node_modules/nx/schemas/nx-schema.json',
|
|
@@ -88,20 +114,20 @@ function createNxJsonFromTurboJson(turboJson) {
|
|
|
88
114
|
}
|
|
89
115
|
// Handle task configurations
|
|
90
116
|
if (turboJson.tasks) {
|
|
91
|
-
|
|
117
|
+
const entries = [];
|
|
92
118
|
for (const [taskName, taskConfig] of Object.entries(turboJson.tasks)) {
|
|
93
119
|
// Skip project-specific tasks (containing #)
|
|
94
120
|
if (taskName.includes('#'))
|
|
95
121
|
continue;
|
|
96
122
|
const config = taskConfig;
|
|
97
|
-
|
|
123
|
+
const entry = { target: taskName };
|
|
98
124
|
// Handle dependsOn
|
|
99
125
|
if (config.dependsOn?.length > 0) {
|
|
100
|
-
|
|
126
|
+
entry.dependsOn = config.dependsOn;
|
|
101
127
|
}
|
|
102
128
|
// Handle inputs
|
|
103
129
|
if (config.inputs?.length > 0) {
|
|
104
|
-
|
|
130
|
+
entry.inputs = config.inputs
|
|
105
131
|
.map((input) => {
|
|
106
132
|
if (input === '$TURBO_DEFAULT$') {
|
|
107
133
|
return '{projectRoot}/**/*';
|
|
@@ -124,7 +150,7 @@ function createNxJsonFromTurboJson(turboJson) {
|
|
|
124
150
|
}
|
|
125
151
|
// Handle outputs
|
|
126
152
|
if (config.outputs?.length > 0) {
|
|
127
|
-
|
|
153
|
+
entry.outputs = config.outputs.map((output) => {
|
|
128
154
|
// Don't add projectRoot if it's already there
|
|
129
155
|
if (output.startsWith('{projectRoot}/'))
|
|
130
156
|
return output;
|
|
@@ -136,7 +162,11 @@ function createNxJsonFromTurboJson(turboJson) {
|
|
|
136
162
|
});
|
|
137
163
|
}
|
|
138
164
|
// Handle cache setting - true by default in Turbo
|
|
139
|
-
|
|
165
|
+
entry.cache = config.cache !== false;
|
|
166
|
+
entries.push(entry);
|
|
167
|
+
}
|
|
168
|
+
if (entries.length > 0) {
|
|
169
|
+
nxJson.targetDefaults = entries;
|
|
140
170
|
}
|
|
141
171
|
}
|
|
142
172
|
/**
|
|
@@ -187,6 +217,13 @@ function updateGitIgnore(root) {
|
|
|
187
217
|
}
|
|
188
218
|
lines.push('.nx/workspace-data');
|
|
189
219
|
}
|
|
220
|
+
if (!contents.includes('.nx/migrate-runs')) {
|
|
221
|
+
if (!sepIncluded) {
|
|
222
|
+
lines.push('\n');
|
|
223
|
+
sepIncluded = true;
|
|
224
|
+
}
|
|
225
|
+
lines.push('.nx/migrate-runs');
|
|
226
|
+
}
|
|
190
227
|
(0, fs_1.writeFileSync)(ignorePath, lines.join('\n'), 'utf-8');
|
|
191
228
|
}
|
|
192
229
|
catch { }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tees `console.{log,warn,error,info,debug}` into an internal buffer while
|
|
3
|
+
* preserving the original behavior. Does not intercept
|
|
4
|
+
* `process.{stdout,stderr}.write` — those bypass `console` and would also
|
|
5
|
+
* pick up unrelated framework output. Restoration is idempotent.
|
|
6
|
+
*/
|
|
7
|
+
export interface GeneratorOutputCapture {
|
|
8
|
+
flush(): string;
|
|
9
|
+
restore(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function installGeneratorOutputCapture(): GeneratorOutputCapture;
|
|
12
|
+
/**
|
|
13
|
+
* Convenience wrapper that installs the capture, runs `fn`, restores on
|
|
14
|
+
* completion or throw, and returns the captured logs alongside `fn`'s value.
|
|
15
|
+
* Throws from `fn` propagate with the captured logs attached as
|
|
16
|
+
* `(err as any).capturedLogs` — the most useful diagnostic when a generator
|
|
17
|
+
* crashes mid-output.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withGeneratorOutputCapture<T>(fn: () => Promise<T> | T): Promise<{
|
|
20
|
+
result: T;
|
|
21
|
+
logs: string;
|
|
22
|
+
}>;
|