@ohos-ports/nx 23.3.0-beta.3 → 24.0.2-beta.0
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/README.md +3 -6
- package/dist/bin/nx.js +2 -2
- package/dist/bin/post-install.js +5 -3
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +7 -1
- package/dist/src/adapter/ngcli-adapter.js +2 -2
- package/dist/src/ai/clone-ai-config-repo.js +49 -12
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +24 -6
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +1 -13
- package/dist/src/command-line/graph/graph.js +38 -10
- package/dist/src/command-line/init/command-object.js +0 -12
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/init/init-v2.js +1 -3
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -45
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -51
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -49
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +86 -24
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +38 -8
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +6 -8
- package/dist/src/command-line/migrate/command-object.js +6 -10
- package/dist/src/command-line/migrate/execute-migration.d.ts +6 -6
- package/dist/src/command-line/migrate/execute-migration.js +25 -15
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +18 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +38 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +29 -17
- package/dist/src/command-line/migrate/migrate-commits.js +86 -32
- package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
- package/dist/src/command-line/migrate/migrate-config.js +12 -6
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.d.ts +6 -30
- package/dist/src/command-line/migrate/migrate.js +257 -255
- package/dist/src/command-line/migrate/resolve-package-version.d.ts +2 -4
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -35
- package/dist/src/command-line/migrate/run/agent-output.d.ts +2 -0
- package/dist/src/command-line/migrate/run/agent-output.js +9 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
- package/dist/src/command-line/migrate/run/broker.js +69 -21
- package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
- package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +7 -5
- package/dist/src/command-line/migrate/run/index.js +16 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +61 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +397 -133
- package/dist/src/command-line/migrate/run/run-state.d.ts +17 -1
- package/dist/src/command-line/migrate/run/run-state.js +41 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +115 -18
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/state-machine.js +4 -1
- package/dist/src/command-line/migrate/run/util.d.ts +7 -2
- package/dist/src/command-line/migrate/run/util.js +30 -3
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
- package/dist/src/command-line/migrate/sort-migrations.js +1 -12
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -6
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +5 -6
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/repair/repair.js +1 -1
- package/dist/src/command-line/report/report.js +1 -1
- package/dist/src/command-line/reset/reset.js +58 -62
- package/dist/src/command-line/run/executor-utils.js +1 -0
- package/dist/src/command-line/run/run-one.d.ts +20 -1
- package/dist/src/command-line/run/run-one.js +153 -5
- package/dist/src/command-line/run/run.js +2 -1
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/show/show-target/info.d.ts +10 -1
- package/dist/src/command-line/show/show-target/info.js +100 -15
- package/dist/src/command-line/show/show-target/inputs.js +10 -2
- package/dist/src/command-line/show/show-target/utils.js +1 -0
- package/dist/src/command-line/watch/command-object.js +3 -22
- package/dist/src/command-line/watch/watch.d.ts +0 -7
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/misc-interfaces.d.ts +18 -0
- package/dist/src/config/nx-json.d.ts +22 -11
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +88 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +15 -0
- package/dist/src/daemon/client/client.js +181 -71
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
- package/dist/src/daemon/client/daemon-socket-messenger.js +2 -2
- package/dist/src/daemon/server/client-socket-context.js +1 -1
- package/dist/src/daemon/server/handle-configure-ai-agents.js +2 -2
- package/dist/src/daemon/server/handle-process-in-background.js +21 -9
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +2 -1
- package/dist/src/daemon/server/handle-select-affected-tasks.js +21 -13
- package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
- package/dist/src/daemon/server/native-js-loader.js +21 -0
- package/dist/src/daemon/server/nx-console-operations.js +2 -2
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
- package/dist/src/daemon/server/server.d.ts +2 -1
- package/dist/src/daemon/server/server.js +17 -4
- package/dist/src/daemon/server/shutdown-utils.js +1 -4
- package/dist/src/daemon/server/start.d.ts +1 -0
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/daemon/socket-utils.d.ts +11 -9
- package/dist/src/daemon/socket-utils.js +31 -61
- package/dist/src/daemon/tmp-dir.d.ts +19 -14
- package/dist/src/daemon/tmp-dir.js +142 -354
- package/dist/src/devkit-exports.d.ts +9 -1
- package/dist/src/devkit-exports.js +12 -1
- package/dist/src/devkit-internals.d.ts +6 -5
- package/dist/src/devkit-internals.js +13 -4
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +4 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +53 -27
- package/dist/src/executors/run-commands/running-tasks.d.ts +13 -4
- package/dist/src/executors/run-commands/running-tasks.js +148 -95
- package/dist/src/executors/run-commands/schema.json +1 -1
- package/dist/src/hasher/check-task-files.js +5 -8
- package/dist/src/hasher/file-hasher.js +9 -7
- package/dist/src/hasher/hash-task.js +4 -0
- package/dist/src/hasher/native-task-hasher-impl.js +3 -1
- package/dist/src/hasher/task-hasher.d.ts +2 -0
- package/dist/src/hasher/task-hasher.js +4 -1
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.js +100 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.md +63 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +146 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/assert-supported-platform.js +1 -1
- package/dist/src/native/index.d.ts +238 -18
- package/dist/src/native/index.js +6 -1
- package/dist/src/native/native-bindings.js +15 -6
- package/dist/src/native/nx.openharmony-arm64.node +0 -0
- package/dist/src/native/nx.wasi-browser.js +1 -0
- package/dist/src/native/nx.wasi.cjs +1 -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/nx-cloud/update-manager.d.ts +14 -0
- package/dist/src/nx-cloud/update-manager.js +237 -50
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +3 -4
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/plugins/js/utils/register.js +9 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +9 -6
- package/dist/src/project-graph/affected/affected-tasks.js +31 -7
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +12 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
- package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
- package/dist/src/tasks-runner/create-task-graph.js +50 -27
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/init-tasks-runner.js +116 -59
- package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
- package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
- package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
- package/dist/src/tasks-runner/readiness/executor-ready-signal.d.ts +7 -0
- package/dist/src/tasks-runner/readiness/executor-ready-signal.js +43 -0
- package/dist/src/tasks-runner/readiness/probes.d.ts +14 -0
- package/dist/src/tasks-runner/readiness/probes.js +101 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.js +72 -0
- package/dist/src/tasks-runner/readiness/ready-signal.d.ts +33 -0
- package/dist/src/tasks-runner/readiness/ready-signal.js +92 -0
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +84 -0
- package/dist/src/tasks-runner/readiness/ready-when.js +371 -0
- package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
- package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
- package/dist/src/tasks-runner/run-command.d.ts +6 -2
- package/dist/src/tasks-runner/run-command.js +21 -31
- package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
- package/dist/src/tasks-runner/run-outcome.js +39 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
- package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
- package/dist/src/tasks-runner/task-env.d.ts +10 -0
- package/dist/src/tasks-runner/task-env.js +37 -5
- package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
- package/dist/src/tasks-runner/task-graph-utils.js +17 -12
- package/dist/src/tasks-runner/task-orchestrator.d.ts +62 -18
- package/dist/src/tasks-runner/task-orchestrator.js +750 -150
- package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
- package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
- package/dist/src/tasks-runner/tasks-schedule.js +63 -6
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +35 -6
- package/dist/src/tasks-runner/utils.js +149 -68
- package/dist/src/ultracache/ci-status.d.ts +24 -0
- package/dist/src/ultracache/ci-status.js +87 -0
- package/dist/src/ultracache/config.d.ts +3 -3
- package/dist/src/ultracache/config.js +4 -4
- package/dist/src/ultracache/fetch.d.ts +2 -0
- package/dist/src/ultracache/fetch.js +1 -0
- package/dist/src/ultracache/overrides.js +4 -0
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/child-process.js +2 -1
- package/dist/src/utils/find-matching-projects.js +9 -6
- package/dist/src/utils/git-utils.d.ts +12 -5
- package/dist/src/utils/git-utils.js +69 -11
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/dist/src/utils/nx-package-group.js +1 -1
- package/dist/src/utils/output.d.ts +4 -3
- package/dist/src/utils/output.js +4 -3
- package/dist/src/utils/owned-private-dir.d.ts +1 -17
- package/dist/src/utils/owned-private-dir.js +10 -62
- package/dist/src/utils/package-json.js +1 -1
- package/dist/src/utils/package-manager.d.ts +8 -0
- package/dist/src/utils/package-manager.js +65 -8
- package/dist/src/utils/perf-hooks.d.ts +1 -0
- package/dist/src/utils/plugins/core-plugins.js +5 -1
- package/dist/src/utils/progress-topics.d.ts +1 -0
- package/dist/src/utils/progress-topics.js +1 -0
- package/dist/src/utils/safe-spawn.js +1 -5
- package/dist/src/utils/shell-quoting.d.ts +8 -1
- package/dist/src/utils/shell-quoting.js +12 -1
- package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
- package/dist/src/utils/spawn-without-terminal.js +110 -0
- package/dist/src/utils/string-similarity.d.ts +38 -0
- package/dist/src/utils/string-similarity.js +108 -0
- package/dist/src/utils/versions.js +1 -1
- package/migrations.json +20 -6
- package/package.json +15 -24
- package/schemas/migrations-schema.json +11 -0
- package/schemas/nx-schema.json +133 -11
- package/schemas/project-schema.json +114 -4
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +0 -109
|
@@ -8,9 +8,9 @@ This migration copies `cache` onto each executor key that applies to a target wh
|
|
|
8
8
|
|
|
9
9
|
An executor key applies to every target that resolves through it, so the migration updates a key only when it can establish that caching is right for all of them. It leaves the key unchanged when the key already declares `cache`, when it declares `continuous: true`, when every entry on the key is filtered so none of them always applies, when a target through it is continuous or is a long-running target such as `serve`, `dev`, or `start`, when the executor's own schema marks its targets continuous, or when a target through it has no target name key enabling `cache`. It never updates the `nx:run-commands` or `nx:run-script` keys, because targets written with `command` and targets derived from `package.json` scripts resolve through those keys without naming them.
|
|
10
10
|
|
|
11
|
-
Where the migration makes no change,
|
|
11
|
+
Where the migration makes no change, the targets resolving through that key are not cached. Nx 24 reads `cache` from the key that wins resolution and nothing else, so `cache` on a target name key has no effect once an executor key applies. That leaves the keys the migration skips, the keys whose only `cache` declaration is filtered, the targets passed over because a sibling target through the same key does not opt in, and the targets reaching the `nx:run-commands` and `nx:run-script` keys. Set `cache` on the key those targets resolve through, or on the targets themselves.
|
|
12
12
|
|
|
13
|
-
Targets are read from each project's `project.json` and from the `nx.targets` block of its `package.json`. Targets inferred by a plugin, and targets derived from `package.json` scripts, are not visible to the migration — the latter is why the `nx:run-script` key is never updated. A key that looks safe here may still serve an inferred target. Set `cache` on the executor key by hand only after checking that no target reaching it is continuous; Nx rejects a target that is both cacheable and continuous.
|
|
13
|
+
Targets are read from each project's `project.json` and from the `nx.targets` block of its `package.json`. Targets inferred by a plugin, and targets derived from `package.json` scripts, are not visible to the migration — the latter is why the `nx:run-script` key is never updated. A key that looks safe here may still serve an inferred target. Set `cache` on the executor key by hand only after checking that no target reaching it is continuous; Nx rejects a target that is both cacheable and continuous.
|
|
14
14
|
|
|
15
15
|
#### Sample code changes
|
|
16
16
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = enableLegacyAffected;
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
|
+
const nx_json_1 = require("../../generators/utils/nx-json");
|
|
6
|
+
async function enableLegacyAffected(tree) {
|
|
7
|
+
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
|
8
|
+
if (!nxJson || nxJson.affected?.legacy !== undefined) {
|
|
9
|
+
return { skipAgentic: true };
|
|
10
|
+
}
|
|
11
|
+
nxJson.affected = { ...nxJson.affected, legacy: true };
|
|
12
|
+
(0, nx_json_1.updateNxJson)(tree, nxJson);
|
|
13
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
14
|
+
return { skipAgentic: true };
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#### Keep legacy `nx affected` selection
|
|
2
|
+
|
|
3
|
+
In Nx 24, `nx affected -t` selects only the tasks whose inputs a change reaches, instead of every task of each affected project.
|
|
4
|
+
This migration sets `affected.legacy` to `true` in `nx.json`, so existing workspaces keep selecting whole projects after upgrading.
|
|
5
|
+
|
|
6
|
+
To switch to task selection, remove the setting or set it to `false`.
|
|
7
|
+
The `NX_LEGACY_AFFECTED` environment variable overrides the setting for a single run: `false` selects tasks and `true` selects projects.
|
|
8
|
+
|
|
9
|
+
The migration skips workspaces that already set `affected.legacy`.
|
|
10
|
+
|
|
11
|
+
#### Sample code changes
|
|
12
|
+
|
|
13
|
+
##### Before
|
|
14
|
+
|
|
15
|
+
```json title="nx.json"
|
|
16
|
+
{
|
|
17
|
+
"defaultBase": "main"
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
##### After
|
|
22
|
+
|
|
23
|
+
```json title="nx.json"
|
|
24
|
+
{
|
|
25
|
+
"defaultBase": "main",
|
|
26
|
+
"affected": {
|
|
27
|
+
"legacy": true
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = findCustomHashers;
|
|
4
|
+
const glob_1 = require("../../generators/utils/glob");
|
|
5
|
+
const json_1 = require("../../utils/json");
|
|
6
|
+
const path_1 = require("../../utils/path");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const DOCS_URL = 'https://nx.dev/docs/kb/local-executors#replace-a-custom-hasher-with-inputs';
|
|
9
|
+
async function findCustomHashers(tree) {
|
|
10
|
+
const hits = new Set();
|
|
11
|
+
const malformed = new Set();
|
|
12
|
+
const unparseable = [];
|
|
13
|
+
const visited = new Set();
|
|
14
|
+
for (const packageJsonPath of await (0, glob_1.globAsync)(tree, ['**/package.json'])) {
|
|
15
|
+
if (packageJsonPath.split('/').includes('node_modules')) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const content = tree.read(packageJsonPath, 'utf-8');
|
|
19
|
+
if (!content.includes('"executors"') && !content.includes('"builders"')) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const packageJson = tryParse(content);
|
|
23
|
+
if (!packageJson) {
|
|
24
|
+
unparseable.push(packageJsonPath);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const packageRoot = node_path_1.posix.dirname(packageJsonPath);
|
|
28
|
+
// A nameless local plugin is referenced by its relative path.
|
|
29
|
+
const pluginName = packageJson.name ?? (packageRoot === '.' ? '.' : `./${packageRoot}`);
|
|
30
|
+
for (const field of [packageJson.executors, packageJson.builders]) {
|
|
31
|
+
if (typeof field !== 'string') {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const executorsJsonPath = (0, path_1.joinPathFragments)(packageRoot, field);
|
|
35
|
+
if (visited.has(executorsJsonPath) || !tree.exists(executorsJsonPath)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
visited.add(executorsJsonPath);
|
|
39
|
+
const executorsJson = tryParse(tree.read(executorsJsonPath, 'utf-8'));
|
|
40
|
+
if (!executorsJson) {
|
|
41
|
+
unparseable.push(executorsJsonPath);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const entries = [];
|
|
45
|
+
for (const map of [executorsJson.executors, executorsJson.builders]) {
|
|
46
|
+
if (map === undefined) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!isPlainObject(map)) {
|
|
50
|
+
unparseable.push(executorsJsonPath);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
entries.push(...Object.entries(map));
|
|
54
|
+
}
|
|
55
|
+
for (const [name, entry] of entries) {
|
|
56
|
+
if (typeof entry === 'string') {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!isPlainObject(entry) || !isValidHasher(entry.hasher)) {
|
|
60
|
+
malformed.add(`Entry "${name}" in "${executorsJsonPath}" is not a valid executor entry. Check it by hand for a "hasher".`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (entry.hasher === undefined) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const hasherPath = (0, path_1.joinPathFragments)(node_path_1.posix.dirname(executorsJsonPath), entry.hasher);
|
|
67
|
+
hits.add(`Executor "${pluginName}:${name}" declares a custom hasher at "${hasherPath}" in "${executorsJsonPath}".`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (hits.size === 0 && malformed.size === 0 && unparseable.length === 0) {
|
|
72
|
+
return { skipAgentic: true };
|
|
73
|
+
}
|
|
74
|
+
const manualNotes = [
|
|
75
|
+
...malformed,
|
|
76
|
+
...unparseable.map((path) => `Could not parse "${path}". Check it by hand for executors that declare a "hasher".`),
|
|
77
|
+
];
|
|
78
|
+
return {
|
|
79
|
+
nextSteps: [
|
|
80
|
+
`Custom hashers are deprecated and will be removed in Nx 25. Replace each one with target inputs, then remove "hasher" from executors.json. See ${DOCS_URL}`,
|
|
81
|
+
...hits,
|
|
82
|
+
...manualNotes,
|
|
83
|
+
],
|
|
84
|
+
agentContext: [...hits, ...manualNotes],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function isPlainObject(value) {
|
|
88
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
89
|
+
}
|
|
90
|
+
function isValidHasher(hasher) {
|
|
91
|
+
return hasher === undefined || typeof hasher === 'string';
|
|
92
|
+
}
|
|
93
|
+
function tryParse(content) {
|
|
94
|
+
try {
|
|
95
|
+
return (0, json_1.parseJson)(content);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#### Move custom executor hashers to target inputs
|
|
2
|
+
|
|
3
|
+
Custom hashers are deprecated in Nx 24 and will be removed in Nx 25.
|
|
4
|
+
A custom hasher is the `hasher` property of an executor in `executors.json`, pointing at a module that computes the task hash in code.
|
|
5
|
+
Target `inputs` replace them.
|
|
6
|
+
|
|
7
|
+
This migration finds every local plugin in the workspace whose `executors.json` (or `builders.json`) declares a `hasher`.
|
|
8
|
+
It doesn't edit any files.
|
|
9
|
+
When it finds one, it lists the executor, the hasher module, and the `executors.json` file in the migration's next steps.
|
|
10
|
+
It also lists files and executor entries it can't read, so you can check those by hand.
|
|
11
|
+
Under `nx migrate` with an AI agent, the agent reads each hasher and writes `inputs` that hash the same things.
|
|
12
|
+
A target that declares its own `inputs` doesn't inherit them from `targetDefaults`, so the agent checks every target that uses the executor and adds the inputs where they're missing.
|
|
13
|
+
It removes the `hasher` only once every one of those targets is covered.
|
|
14
|
+
If something the hasher hashes can't be expressed as an input, the agent leaves the hasher in place and tells you why.
|
|
15
|
+
|
|
16
|
+
Packages installed in `node_modules` aren't scanned.
|
|
17
|
+
If a third-party plugin you use declares a hasher, Nx warns about it when it hashes one of its tasks.
|
|
18
|
+
|
|
19
|
+
#### Sample code changes
|
|
20
|
+
|
|
21
|
+
Given a local plugin whose `echo` executor hashes the project, its dependencies, and the `API_URL` environment variable:
|
|
22
|
+
|
|
23
|
+
##### Before
|
|
24
|
+
|
|
25
|
+
```json title="tools/my-plugin/executors.json"
|
|
26
|
+
{
|
|
27
|
+
"executors": {
|
|
28
|
+
"echo": {
|
|
29
|
+
"implementation": "./src/executors/echo/executor",
|
|
30
|
+
"hasher": "./src/executors/echo/hasher",
|
|
31
|
+
"schema": "./src/executors/echo/schema.json"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
##### After
|
|
38
|
+
|
|
39
|
+
```json title="nx.json"
|
|
40
|
+
{
|
|
41
|
+
"targetDefaults": {
|
|
42
|
+
"@acme/my-plugin:echo": {
|
|
43
|
+
"inputs": ["default", "^default", { "env": "API_URL" }]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```json title="tools/my-plugin/executors.json"
|
|
50
|
+
{
|
|
51
|
+
"executors": {
|
|
52
|
+
"echo": {
|
|
53
|
+
"implementation": "./src/executors/echo/executor",
|
|
54
|
+
"schema": "./src/executors/echo/schema.json"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Reference
|
|
61
|
+
|
|
62
|
+
- [Replace a custom hasher with inputs](https://nx.dev/docs/kb/local-executors#replace-a-custom-hasher-with-inputs)
|
|
63
|
+
- [Inputs reference](https://nx.dev/docs/reference/inputs)
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Move custom executor hashers to target inputs
|
|
2
|
+
|
|
3
|
+
Custom hashers (the `hasher` property of an executor in `executors.json`) are
|
|
4
|
+
deprecated in Nx 24 and removed in Nx 25. Each one should become target `inputs`
|
|
5
|
+
that hash the same things, so the targets keep caching correctly once the hasher
|
|
6
|
+
is gone.
|
|
7
|
+
|
|
8
|
+
The generator half of this migration only scans. It edits no files, and it lists
|
|
9
|
+
every executor that declares a hasher in the `impl.agentContext` field of the
|
|
10
|
+
step's `nx_migrate_prompt` block, one line each, with the executor name, the
|
|
11
|
+
hasher path, and the `executors.json` path. Lines starting with
|
|
12
|
+
`Could not parse` name files the scan skipped, and lines starting with `Entry`
|
|
13
|
+
name executor entries it could not read.
|
|
14
|
+
|
|
15
|
+
Do not touch executors that declare no hasher, executors installed from
|
|
16
|
+
`node_modules`, or any other caching configuration.
|
|
17
|
+
|
|
18
|
+
## First, check whether there is anything to do
|
|
19
|
+
|
|
20
|
+
Confirm this before changing anything. If it fails, make no changes and stop:
|
|
21
|
+
|
|
22
|
+
1. `impl.agentContext` lists at least one executor that declares a custom
|
|
23
|
+
hasher, or at least one file or entry it could not read. Read each of those
|
|
24
|
+
yourself; if it declares no `hasher`, drop it from the list.
|
|
25
|
+
|
|
26
|
+
## Step 1: Read what each hasher hashes
|
|
27
|
+
|
|
28
|
+
Open the hasher module named in `impl.agentContext`. Work out every value it
|
|
29
|
+
feeds into the hash it returns:
|
|
30
|
+
|
|
31
|
+
- `context.hasher.hashTask(task, ...)` alone is Nx default hashing.
|
|
32
|
+
- Files it reads, globs it walks, or other projects it hashes.
|
|
33
|
+
- Environment variables it reads.
|
|
34
|
+
- Commands it runs, or data it fetches (a remote API, a registry lookup).
|
|
35
|
+
|
|
36
|
+
## Step 2: Write equivalent inputs
|
|
37
|
+
|
|
38
|
+
Map each value to an input:
|
|
39
|
+
|
|
40
|
+
| What the hasher hashes | Input |
|
|
41
|
+
| ----------------------------------------------------- | ------------------------------------------------------- |
|
|
42
|
+
| The project and its dependencies (Nx default hashing) | `"default"` and `"^default"` |
|
|
43
|
+
| Files of specific other projects | `{ "input": "default", "projects": ["shared-config"] }` |
|
|
44
|
+
| A subset of the files in the project | `{ "fileset": "{projectRoot}/src/**/*.graphql" }` |
|
|
45
|
+
| A file outside any project | `{ "fileset": "{workspaceRoot}/schema.json" }` |
|
|
46
|
+
| An environment variable | `{ "env": "API_URL" }` |
|
|
47
|
+
| The output of a command, such as a tool version | `{ "runtime": "node --version" }` |
|
|
48
|
+
|
|
49
|
+
If the workspace defines named inputs such as `production`, prefer them over
|
|
50
|
+
`default` where the hasher excluded test files.
|
|
51
|
+
|
|
52
|
+
### Find every target that uses the executor
|
|
53
|
+
|
|
54
|
+
Write the resolved project graph and list every target whose `executor` is the
|
|
55
|
+
executor name (`"@acme/my-plugin:echo"`):
|
|
56
|
+
|
|
57
|
+
```shell
|
|
58
|
+
npx nx graph --file=tmp/custom-hashers-graph.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Each target in `graph.nodes.<project>.data.targets` there is fully resolved: it
|
|
62
|
+
already reflects `targetDefaults` (including filtered array entries), inferred
|
|
63
|
+
targets, and project-level overrides. Record each consuming target's resolved
|
|
64
|
+
`inputs`. Every one of them must end up covered.
|
|
65
|
+
|
|
66
|
+
### Place the inputs
|
|
67
|
+
|
|
68
|
+
A target that declares its own `inputs` replaces the `inputs` from
|
|
69
|
+
`targetDefaults` rather than merging with them. So a `targetDefaults` edit alone
|
|
70
|
+
does not reach a target that already declares `inputs`.
|
|
71
|
+
|
|
72
|
+
1. Set the inputs in `nx.json` `targetDefaults` under the executor name. If that
|
|
73
|
+
key already exists, add `inputs` to it, and merge with any `inputs` it already
|
|
74
|
+
declares rather than replacing them. If its value is an array of filtered
|
|
75
|
+
entries, add the inputs to every entry that applies to a consuming target.
|
|
76
|
+
2. For every consuming target that declares its own `inputs`, add the
|
|
77
|
+
replacement inputs to that target as well, keeping the inputs it already has.
|
|
78
|
+
It is declared in `project.json`, in the `nx.targets` block of
|
|
79
|
+
`package.json`, or by the plugin that infers the target. For an inferred
|
|
80
|
+
target, set `inputs` in `project.json` to the full resolved list plus the
|
|
81
|
+
replacement inputs.
|
|
82
|
+
3. Write the graph again and confirm that every consuming target's resolved
|
|
83
|
+
`inputs` now contains every replacement input. Fix any that do not.
|
|
84
|
+
|
|
85
|
+
**Before:**
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
// tools/my-plugin/executors.json
|
|
89
|
+
{
|
|
90
|
+
"executors": {
|
|
91
|
+
"echo": {
|
|
92
|
+
"implementation": "./src/executors/echo/executor",
|
|
93
|
+
"hasher": "./src/executors/echo/hasher",
|
|
94
|
+
"schema": "./src/executors/echo/schema.json"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**After:**
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
// nx.json
|
|
104
|
+
{
|
|
105
|
+
"targetDefaults": {
|
|
106
|
+
"@acme/my-plugin:echo": {
|
|
107
|
+
"inputs": ["default", "^default", { "env": "API_URL" }]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
// tools/my-plugin/executors.json
|
|
115
|
+
{
|
|
116
|
+
"executors": {
|
|
117
|
+
"echo": {
|
|
118
|
+
"implementation": "./src/executors/echo/executor",
|
|
119
|
+
"schema": "./src/executors/echo/schema.json"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Step 3: Remove the hasher only when the inputs cover it
|
|
126
|
+
|
|
127
|
+
Remove `hasher` from `executors.json` and delete the hasher module (and its
|
|
128
|
+
spec) only once the resolved inputs of every consuming target cover everything
|
|
129
|
+
the hasher hashed.
|
|
130
|
+
|
|
131
|
+
If a value has no file, environment variable, or project to point at, such as
|
|
132
|
+
data fetched from a remote service, use a `runtime` input whose command prints
|
|
133
|
+
that value. If no command can reproduce it, leave the hasher in place and tell
|
|
134
|
+
the user which value blocks the move and why.
|
|
135
|
+
|
|
136
|
+
## Post-Migration Validation
|
|
137
|
+
|
|
138
|
+
1. `npx nx show target <project>:<target>` for every consuming target found in
|
|
139
|
+
Step 2. Confirm each one lists the replacement inputs. After the hasher is
|
|
140
|
+
removed, `npx nx show target <project>:<target> inputs` also shows the files
|
|
141
|
+
and values those inputs resolve to.
|
|
142
|
+
2. `npx nx run-many -t <target>` twice for the targets that used the executor.
|
|
143
|
+
The second run should be a cache hit. Change a file the hasher used to hash
|
|
144
|
+
and confirm the next run is a cache miss.
|
|
145
|
+
3. `npx nx run-many -t build,test,lint -p <plugin project>` if you deleted hasher
|
|
146
|
+
files. Fix failures caused by this migration and re-run until green.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
|
+
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
6
|
+
const RENAMED_ULTRACACHE_KEYS = new Map([
|
|
7
|
+
['ignoredReads', 'ignoreReads'],
|
|
8
|
+
['ignoredWrites', 'ignoreWrites'],
|
|
9
|
+
]);
|
|
10
|
+
const WORKFLOWS_DIR = '.nx/workflows';
|
|
11
|
+
const CONFIG_EXTENSIONS = ['yaml', 'yml'];
|
|
12
|
+
const OLD_CONFIG_PATH = /(\.nx\/workflows\/)sandboxing-config\.(ya?ml)/g;
|
|
13
|
+
// Matches a block-style key at the start of a line or after a sequence dash,
|
|
14
|
+
// optionally quoted. Comments and values are left alone.
|
|
15
|
+
const OLD_YAML_KEY = /^(\s*(?:-\s+)?)(['"]?)exclude-(reads|writes)\2(\s*:)/gm;
|
|
16
|
+
async function update(tree) {
|
|
17
|
+
const manual = [];
|
|
18
|
+
for (const [name, project] of (0, project_configuration_1.getProjects)(tree)) {
|
|
19
|
+
let changed = false;
|
|
20
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
21
|
+
changed = renameUltracacheKeys(target) || changed;
|
|
22
|
+
}
|
|
23
|
+
const rewritten = rewriteConfigPaths(project);
|
|
24
|
+
if (changed || rewritten !== project) {
|
|
25
|
+
(0, project_configuration_1.updateProjectConfiguration)(tree, name, rewritten);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const nxJson = (0, project_configuration_1.readNxJson)(tree);
|
|
29
|
+
if (nxJson) {
|
|
30
|
+
let changed = false;
|
|
31
|
+
for (const value of Object.values(nxJson.targetDefaults ?? {})) {
|
|
32
|
+
for (const entry of targetDefaultEntries(value)) {
|
|
33
|
+
changed = renameUltracacheKeys(entry) || changed;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const rewritten = rewriteConfigPaths(nxJson);
|
|
37
|
+
if (changed || rewritten !== nxJson) {
|
|
38
|
+
(0, project_configuration_1.updateNxJson)(tree, rewritten);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
manual.push(...renameWorkspaceConfig(tree));
|
|
42
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
43
|
+
if (manual.length === 0) {
|
|
44
|
+
return { skipAgentic: true };
|
|
45
|
+
}
|
|
46
|
+
return { nextSteps: manual, agentContext: manual };
|
|
47
|
+
}
|
|
48
|
+
function targetDefaultEntries(value) {
|
|
49
|
+
return Array.isArray(value) ? value : [value];
|
|
50
|
+
}
|
|
51
|
+
function renameUltracacheKeys(target) {
|
|
52
|
+
const ultracache = target?.ultracache;
|
|
53
|
+
if (!ultracache ||
|
|
54
|
+
typeof ultracache !== 'object' ||
|
|
55
|
+
!Object.keys(ultracache).some((key) => RENAMED_ULTRACACHE_KEYS.has(key))) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const renamed = {};
|
|
59
|
+
for (const [key, value] of Object.entries(ultracache)) {
|
|
60
|
+
const newKey = RENAMED_ULTRACACHE_KEYS.get(key) ?? key;
|
|
61
|
+
renamed[newKey] = mergePatterns(renamed[newKey], value);
|
|
62
|
+
}
|
|
63
|
+
target.ultracache = renamed;
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
// A target may already declare the new key beside the old one; keep both sets.
|
|
67
|
+
function mergePatterns(existing, incoming) {
|
|
68
|
+
if (existing === undefined) {
|
|
69
|
+
return incoming;
|
|
70
|
+
}
|
|
71
|
+
if (!Array.isArray(existing) || !Array.isArray(incoming)) {
|
|
72
|
+
return incoming;
|
|
73
|
+
}
|
|
74
|
+
return [...existing, ...incoming.filter((p) => !existing.includes(p))];
|
|
75
|
+
}
|
|
76
|
+
// Returns the same reference when nothing changed.
|
|
77
|
+
function rewriteConfigPaths(value) {
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
const replaced = value.replace(OLD_CONFIG_PATH, '$1ultracache-config.$2');
|
|
80
|
+
return (replaced === value ? value : replaced);
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
const mapped = value.map(rewriteConfigPaths);
|
|
84
|
+
return (mapped.some((v, i) => v !== value[i]) ? mapped : value);
|
|
85
|
+
}
|
|
86
|
+
if (value && typeof value === 'object') {
|
|
87
|
+
let changed = false;
|
|
88
|
+
const mapped = {};
|
|
89
|
+
for (const [key, v] of Object.entries(value)) {
|
|
90
|
+
mapped[key] = rewriteConfigPaths(v);
|
|
91
|
+
changed ||= mapped[key] !== v;
|
|
92
|
+
}
|
|
93
|
+
return (changed ? mapped : value);
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
function renameWorkspaceConfig(tree) {
|
|
98
|
+
const existingNew = CONFIG_EXTENSIONS.map((ext) => `${WORKFLOWS_DIR}/ultracache-config.${ext}`).filter((path) => tree.exists(path));
|
|
99
|
+
const manual = [];
|
|
100
|
+
for (const ext of CONFIG_EXTENSIONS) {
|
|
101
|
+
const oldPath = `${WORKFLOWS_DIR}/sandboxing-config.${ext}`;
|
|
102
|
+
if (!tree.exists(oldPath)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (existingNew.length > 0) {
|
|
106
|
+
manual.push(`Both "${oldPath}" and "${existingNew[0]}" exist. Nx Cloud reads only "${existingNew[0]}", so merge the patterns from "${oldPath}" into it and delete "${oldPath}".`);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const newPath = `${WORKFLOWS_DIR}/ultracache-config.${ext}`;
|
|
110
|
+
tree.rename(oldPath, newPath);
|
|
111
|
+
existingNew.push(newPath);
|
|
112
|
+
}
|
|
113
|
+
for (const path of existingNew) {
|
|
114
|
+
const content = tree.read(path, 'utf-8') ?? '';
|
|
115
|
+
const updated = content.replace(OLD_YAML_KEY, '$1$2ignore-$3$2$4');
|
|
116
|
+
if (updated !== content) {
|
|
117
|
+
tree.write(path, updated);
|
|
118
|
+
}
|
|
119
|
+
if (hasOldYamlKey(updated)) {
|
|
120
|
+
manual.push(`"${path}" still uses "exclude-reads" or "exclude-writes" in a form the migration could not rewrite. Rename them to "ignore-reads" and "ignore-writes".`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return manual;
|
|
124
|
+
}
|
|
125
|
+
function hasOldYamlKey(content) {
|
|
126
|
+
return content
|
|
127
|
+
.split('\n')
|
|
128
|
+
.map((line) => line.replace(/#.*$/, ''))
|
|
129
|
+
.some((line) => /['"]?exclude-(reads|writes)['"]?\s*:/.test(line));
|
|
130
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#### Rename ultracache ignore options
|
|
2
|
+
|
|
3
|
+
Nx 24 renames the `ultracache` target options `ignoredReads` and `ignoredWrites` to `ignoreReads` and `ignoreWrites`.
|
|
4
|
+
The workspace-wide exclusions file moves from `.nx/workflows/sandboxing-config.yaml` to `.nx/workflows/ultracache-config.yaml`, and its `exclude-reads` and `exclude-writes` keys become `ignore-reads` and `ignore-writes`.
|
|
5
|
+
|
|
6
|
+
This migration renames the options in every target in `project.json` files, in the `nx` block of `package.json` files, and in `targetDefaults` in `nx.json`.
|
|
7
|
+
When a target sets both the old and the new option, it combines their patterns under the new one.
|
|
8
|
+
It renames `.nx/workflows/sandboxing-config.yaml` (or `.yml`) and the keys inside it, including those in `task-exclusions` entries.
|
|
9
|
+
It also updates any `inputs` or `namedInputs` entry that points at the old file.
|
|
10
|
+
|
|
11
|
+
If `.nx/workflows/ultracache-config.yaml` already exists, the migration leaves both files in place and lists them in its next steps so you can merge them by hand.
|
|
12
|
+
It does the same when the file writes those keys in a form it can't rewrite, such as an inline `{ }` map.
|
|
13
|
+
|
|
14
|
+
#### Sample code changes
|
|
15
|
+
|
|
16
|
+
##### Before
|
|
17
|
+
|
|
18
|
+
```json title="apps/app/project.json"
|
|
19
|
+
{
|
|
20
|
+
"targets": {
|
|
21
|
+
"build": {
|
|
22
|
+
"ultracache": {
|
|
23
|
+
"ignoredReads": ["tmp/**"],
|
|
24
|
+
"ignoredWrites": ["**/.cache/**"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```yaml title=".nx/workflows/sandboxing-config.yaml"
|
|
32
|
+
exclude-reads:
|
|
33
|
+
- 'dist/**'
|
|
34
|
+
task-exclusions:
|
|
35
|
+
- target: lint
|
|
36
|
+
exclude-writes:
|
|
37
|
+
- .eslintcache/**
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
##### After
|
|
41
|
+
|
|
42
|
+
```json title="apps/app/project.json"
|
|
43
|
+
{
|
|
44
|
+
"targets": {
|
|
45
|
+
"build": {
|
|
46
|
+
"ultracache": {
|
|
47
|
+
"ignoreReads": ["tmp/**"],
|
|
48
|
+
"ignoreWrites": ["**/.cache/**"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```yaml title=".nx/workflows/ultracache-config.yaml"
|
|
56
|
+
ignore-reads:
|
|
57
|
+
- 'dist/**'
|
|
58
|
+
task-exclusions:
|
|
59
|
+
- target: lint
|
|
60
|
+
ignore-writes:
|
|
61
|
+
- .eslintcache/**
|
|
62
|
+
```
|
|
@@ -12,7 +12,7 @@ function assertSupportedPlatform() {
|
|
|
12
12
|
if (process.platform == 'win32' ||
|
|
13
13
|
process.platform == 'darwin' ||
|
|
14
14
|
process.platform == 'linux' ||
|
|
15
|
-
process.platform == 'freebsd'
|
|
15
|
+
process.platform == 'freebsd') {
|
|
16
16
|
title = 'Missing Platform Dependency';
|
|
17
17
|
bodyLines = [
|
|
18
18
|
`The Nx CLI could not find or load the native binary for your supported platform (${process.platform}-${process.arch}).`,
|