@ohos-ports/nx 23.2.1-beta.1 → 23.3.0-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 +1 -1
- package/dist/bin/init-local.js +7 -1
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +9 -0
- package/dist/plugins/package-json.js +1 -1
- package/dist/src/command-line/add/add.js +5 -1
- package/dist/src/command-line/affected/affected.js +70 -9
- package/dist/src/command-line/affected/command-object.js +1 -1
- package/dist/src/command-line/format/format.js +2 -18
- package/dist/src/command-line/graph/graph.d.ts +31 -0
- package/dist/src/command-line/graph/graph.js +113 -20
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +0 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/index.js +0 -3
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +0 -3
- package/dist/src/command-line/init/implementation/format.js +2 -3
- package/dist/src/command-line/init/implementation/utils.d.ts +0 -1
- package/dist/src/command-line/init/implementation/utils.js +6 -9
- package/dist/src/command-line/init/init-v2.js +0 -3
- package/dist/src/command-line/migrate/agentic/capture-generator-output.d.ts +25 -0
- package/dist/src/command-line/migrate/agentic/capture-generator-output.js +121 -5
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +21 -0
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +126 -0
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +24 -0
- package/dist/src/command-line/migrate/agentic/definitions.js +79 -20
- package/dist/src/command-line/migrate/agentic/format-command.d.ts +14 -0
- package/dist/src/command-line/migrate/agentic/format-command.js +44 -0
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +3 -3
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +3 -3
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +50 -17
- package/dist/src/command-line/migrate/agentic/handoff.js +166 -24
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +23 -0
- package/dist/src/command-line/migrate/agentic/instruction-files.js +41 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.d.ts +12 -0
- package/dist/src/command-line/migrate/agentic/master/invocations.js +54 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +16 -0
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +175 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +31 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +222 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.d.ts +13 -0
- package/dist/src/command-line/migrate/agentic/prompts/final-validation.js +41 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +17 -0
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +90 -0
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +4 -3
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +25 -1
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +57 -34
- package/dist/src/command-line/migrate/agentic/run-step.js +28 -4
- package/dist/src/command-line/migrate/agentic/runner.d.ts +3 -15
- package/dist/src/command-line/migrate/agentic/runner.js +57 -239
- package/dist/src/command-line/migrate/agentic/terminal-repair.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/terminal-repair.js +27 -0
- package/dist/src/command-line/migrate/agentic/types.d.ts +23 -8
- package/dist/src/command-line/migrate/agentic/types.js +10 -7
- package/dist/src/command-line/migrate/agentic/windows-cmd.d.ts +33 -0
- package/dist/src/command-line/migrate/agentic/windows-cmd.js +88 -0
- package/dist/src/command-line/migrate/command-object.d.ts +2 -0
- package/dist/src/command-line/migrate/command-object.js +11 -1
- package/dist/src/command-line/migrate/deferred-output.d.ts +44 -0
- package/dist/src/command-line/migrate/deferred-output.js +92 -0
- package/dist/src/command-line/migrate/execute-migration.d.ts +9 -3
- package/dist/src/command-line/migrate/execute-migration.js +53 -16
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +34 -9
- package/dist/src/command-line/migrate/migrate-analytics.js +71 -10
- package/dist/src/command-line/migrate/migrate-commits.d.ts +5 -4
- package/dist/src/command-line/migrate/migrate-commits.js +16 -6
- package/dist/src/command-line/migrate/migrate-config.d.ts +5 -2
- package/dist/src/command-line/migrate/migrate-config.js +19 -11
- package/dist/src/command-line/migrate/migrate-output.d.ts +3 -7
- package/dist/src/command-line/migrate/migrate-output.js +3 -7
- package/dist/src/command-line/migrate/migrate.d.ts +3 -0
- package/dist/src/command-line/migrate/migrate.js +183 -46
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -19
- package/dist/src/command-line/migrate/run/agent-output.d.ts +11 -0
- package/dist/src/command-line/migrate/run/agent-output.js +21 -2
- package/dist/src/command-line/migrate/run/agent-work-payload.d.ts +37 -0
- package/dist/src/command-line/migrate/run/agent-work-payload.js +156 -0
- package/dist/src/command-line/migrate/run/atomic-write.d.ts +8 -0
- package/dist/src/command-line/migrate/run/atomic-write.js +17 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +150 -0
- package/dist/src/command-line/migrate/run/broker.js +568 -0
- package/dist/src/command-line/migrate/run/clean-retry.d.ts +12 -0
- package/dist/src/command-line/migrate/run/clean-retry.js +99 -0
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +55 -0
- package/dist/src/command-line/migrate/run/existing-run-report.js +227 -0
- package/dist/src/command-line/migrate/run/give-up.d.ts +41 -0
- package/dist/src/command-line/migrate/run/give-up.js +148 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -6
- package/dist/src/command-line/migrate/run/index.js +21 -2
- package/dist/src/command-line/migrate/run/issues.d.ts +127 -0
- package/dist/src/command-line/migrate/run/issues.js +1121 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +59 -1
- package/dist/src/command-line/migrate/run/orchestrator.js +1529 -457
- package/dist/src/command-line/migrate/run/run-id.d.ts +0 -8
- package/dist/src/command-line/migrate/run/run-id.js +0 -30
- package/dist/src/command-line/migrate/run/run-state.d.ts +77 -17
- package/dist/src/command-line/migrate/run/run-state.js +263 -32
- package/dist/src/command-line/migrate/run/runbook.d.ts +18 -0
- package/dist/src/command-line/migrate/run/runbook.js +118 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +33 -2
- package/dist/src/command-line/migrate/run/state-lock.js +128 -2
- package/dist/src/command-line/migrate/run/state-machine.d.ts +50 -1
- package/dist/src/command-line/migrate/run/state-machine.js +339 -26
- package/dist/src/command-line/migrate/run/util.d.ts +3 -1
- package/dist/src/command-line/migrate/run/util.js +24 -3
- package/dist/src/command-line/migrate/run/worker.js +290 -129
- package/dist/src/command-line/migrate/step-actions.d.ts +1 -1
- package/dist/src/command-line/migrate/step-actions.js +7 -1
- package/dist/src/command-line/migrate/text.d.ts +6 -0
- package/dist/src/command-line/migrate/text.js +25 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +2 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +5 -11
- package/dist/src/command-line/release/publish.js +11 -8
- package/dist/src/command-line/release/utils/get-touched-projects-for-group.js +3 -3
- package/dist/src/command-line/release/utils/release-graph.js +1 -1
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -8
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -3
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.d.ts +4 -2
- package/dist/src/command-line/release/utils/remote-release-clients/remote-release-client.js +37 -3
- package/dist/src/command-line/release/version/version-actions.d.ts +3 -0
- package/dist/src/command-line/reset/reset.js +10 -4
- package/dist/src/command-line/run/run-one.js +5 -1
- package/dist/src/command-line/run-many/run-many.js +6 -12
- package/dist/src/command-line/show/command-object.js +1 -1
- package/dist/src/command-line/show/projects.js +52 -1
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +5 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +38 -4
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +23 -1
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +14 -8
- package/dist/src/daemon/client/client.js +41 -12
- package/dist/src/daemon/message-types/get-plugin-capabilities.d.ts +5 -0
- package/dist/src/daemon/message-types/get-plugin-capabilities.js +11 -0
- package/dist/src/daemon/message-types/run-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/message-types/select-affected-tasks.d.ts +21 -0
- package/dist/src/daemon/message-types/select-affected-tasks.js +11 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.d.ts +8 -0
- package/dist/src/daemon/message-types/ultracache-configuration-version.js +2 -0
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +1 -1
- package/dist/src/daemon/server/dotenv-graph-changes.js +2 -2
- package/dist/src/daemon/server/handle-get-plugin-capabilities.d.ts +2 -0
- package/dist/src/daemon/server/handle-get-plugin-capabilities.js +13 -0
- package/dist/src/daemon/server/handle-hash-tasks.d.ts +10 -2
- package/dist/src/daemon/server/handle-hash-tasks.js +18 -3
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +3 -0
- package/dist/src/daemon/server/handle-select-affected-tasks.js +26 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +3 -2
- package/dist/src/daemon/server/{handle-outputs-changes.d.ts → handle-watch-events.d.ts} +4 -4
- package/dist/src/daemon/server/{handle-outputs-changes.js → handle-watch-events.js} +36 -37
- package/dist/src/daemon/server/outputs-tracking.d.ts +7 -19
- package/dist/src/daemon/server/outputs-tracking.js +7 -107
- package/dist/src/daemon/server/planning-context.d.ts +8 -0
- package/dist/src/daemon/server/planning-context.js +18 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +22 -7
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +104 -74
- package/dist/src/daemon/server/restart-checks.d.ts +22 -0
- package/dist/src/daemon/server/restart-checks.js +77 -0
- package/dist/src/daemon/server/server.d.ts +1 -0
- package/dist/src/daemon/server/server.js +54 -30
- package/dist/src/daemon/server/shutdown-utils.d.ts +0 -5
- package/dist/src/daemon/server/shutdown-utils.js +3 -26
- package/dist/src/daemon/server/ultracache-configuration-state.d.ts +7 -0
- package/dist/src/daemon/server/ultracache-configuration-state.js +36 -0
- package/dist/src/devkit-internals.d.ts +3 -1
- package/dist/src/devkit-internals.js +8 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -1
- package/dist/src/executors/run-commands/run-commands.impl.js +19 -5
- package/dist/src/executors/run-commands/running-tasks.d.ts +5 -4
- package/dist/src/executors/run-commands/running-tasks.js +13 -13
- package/dist/src/hasher/create-task-hasher.d.ts +8 -1
- package/dist/src/hasher/create-task-hasher.js +13 -3
- package/dist/src/hasher/hash-plan-inspector.js +2 -2
- package/dist/src/hasher/hash-task.d.ts +2 -2
- package/dist/src/hasher/hash-task.js +28 -17
- package/dist/src/hasher/native-task-hasher-impl.d.ts +20 -4
- package/dist/src/hasher/native-task-hasher-impl.js +75 -9
- package/dist/src/hasher/task-hasher.d.ts +24 -7
- package/dist/src/hasher/task-hasher.js +27 -8
- package/dist/src/hasher/task-planning-context.d.ts +13 -0
- package/dist/src/hasher/task-planning-context.js +12 -0
- package/dist/src/native/index.d.ts +582 -21
- package/dist/src/native/index.js +3 -5
- package/dist/src/native/native-bindings.js +13 -1
- package/dist/src/native/nx.openharmony-arm64.node +0 -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/native/transform-objects.d.ts +11 -2
- package/dist/src/native/transform-objects.js +46 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +15 -8
- package/dist/src/nx-cloud/update-manager.d.ts +3 -0
- package/dist/src/nx-cloud/update-manager.js +19 -13
- package/dist/src/nx-cloud/utilities/client.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/client.js +1 -1
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +2 -1
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.d.ts +5 -0
- package/dist/src/nx-cloud/utilities/nx-cloud-http-client.js +16 -0
- package/dist/src/nx-cloud/utilities/url-shorten.js +17 -10
- package/dist/src/plugins/js/index.js +45 -64
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +4 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +6 -7
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -1
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +2 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +22 -0
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/lock-file-changes.js +51 -29
- package/dist/src/plugins/js/project-graph/affected/npm-packages.d.ts +10 -2
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +32 -11
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +22 -18
- package/dist/src/plugins/js/utils/register.js +13 -4
- package/dist/src/plugins/package-json/create-nodes.d.ts +2 -2
- package/dist/src/plugins/package-json/create-nodes.js +13 -13
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +14 -0
- package/dist/src/project-graph/affected/affected-project-graph.js +5 -18
- package/dist/src/project-graph/affected/affected-projects.d.ts +7 -0
- package/dist/src/project-graph/affected/affected-projects.js +42 -0
- package/dist/src/project-graph/affected/affected-reasons.d.ts +116 -0
- package/dist/src/project-graph/affected/affected-reasons.js +459 -0
- package/dist/src/project-graph/affected/affected-tasks.d.ts +103 -0
- package/dist/src/project-graph/affected/affected-tasks.js +386 -0
- package/dist/src/project-graph/affected/print-explanation.d.ts +11 -0
- package/dist/src/project-graph/affected/print-explanation.js +44 -0
- package/dist/src/project-graph/error-types.d.ts +5 -0
- package/dist/src/project-graph/error-types.js +44 -5
- package/dist/src/project-graph/file-utils.d.ts +2 -0
- package/dist/src/project-graph/file-utils.js +12 -3
- package/dist/src/project-graph/nx-deps-cache.d.ts +5 -2
- package/dist/src/project-graph/nx-deps-cache.js +4 -4
- package/dist/src/project-graph/plugins/get-plugins.d.ts +3 -1
- package/dist/src/project-graph/plugins/get-plugins.js +60 -82
- package/dist/src/project-graph/plugins/in-process-loader.d.ts +1 -1
- package/dist/src/project-graph/plugins/in-process-loader.js +1 -4
- package/dist/src/project-graph/plugins/isolation/index.d.ts +1 -1
- package/dist/src/project-graph/plugins/isolation/index.js +3 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +8 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +42 -6
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.d.ts +10 -1
- package/dist/src/project-graph/plugins/isolation/load-isolated-plugin.js +67 -17
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +3 -2
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +5 -1
- package/dist/src/project-graph/plugins/loaded-nx-plugin.d.ts +5 -2
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +14 -1
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.d.ts +6 -0
- package/dist/src/project-graph/plugins/nx-plugin-capabilities.js +28 -0
- package/dist/src/project-graph/plugins/task-results-stub.d.ts +50 -0
- package/dist/src/project-graph/plugins/task-results-stub.js +111 -0
- package/dist/src/project-graph/plugins/tasks-execution-hooks.d.ts +3 -2
- package/dist/src/project-graph/plugins/tasks-execution-hooks.js +14 -1
- package/dist/src/project-graph/project-graph.js +43 -42
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +67 -0
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +83 -0
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +1 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +1 -0
- package/dist/src/tasks-runner/batch/run-batch.js +15 -0
- package/dist/src/tasks-runner/cache.d.ts +37 -2
- package/dist/src/tasks-runner/cache.js +42 -1
- package/dist/src/tasks-runner/create-task-graph.d.ts +24 -1
- package/dist/src/tasks-runner/create-task-graph.js +57 -2
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.d.ts +1 -1
- package/dist/src/tasks-runner/forked-process-task-runner.js +11 -10
- package/dist/src/tasks-runner/init-tasks-runner.d.ts +7 -2
- package/dist/src/tasks-runner/init-tasks-runner.js +15 -7
- package/dist/src/tasks-runner/is-tui-enabled.js +4 -3
- package/dist/src/tasks-runner/life-cycle.d.ts +7 -0
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.d.ts +35 -0
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +146 -0
- package/dist/src/tasks-runner/prune-task-graph.d.ts +17 -0
- package/dist/src/tasks-runner/prune-task-graph.js +45 -0
- package/dist/src/tasks-runner/run-command.d.ts +41 -5
- package/dist/src/tasks-runner/run-command.js +98 -22
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +93 -19
- package/dist/src/tasks-runner/running-tasks/batch-process.js +184 -88
- package/dist/src/tasks-runner/task-io-service.d.ts +11 -3
- package/dist/src/tasks-runner/task-io-service.js +14 -5
- package/dist/src/tasks-runner/task-orchestrator.d.ts +71 -4
- package/dist/src/tasks-runner/task-orchestrator.js +266 -66
- package/dist/src/tasks-runner/tasks-runner.d.ts +2 -0
- package/dist/src/tasks-runner/terminal-output-path.d.ts +11 -0
- package/dist/src/tasks-runner/terminal-output-path.js +18 -0
- package/dist/src/tasks-runner/utils.d.ts +5 -0
- package/dist/src/tasks-runner/utils.js +14 -2
- package/dist/src/ultracache/config.d.ts +21 -0
- package/dist/src/ultracache/config.js +29 -0
- package/dist/src/ultracache/fetch.d.ts +21 -0
- package/dist/src/ultracache/fetch.js +43 -0
- package/dist/src/ultracache/overrides.d.ts +17 -0
- package/dist/src/ultracache/overrides.js +61 -0
- package/dist/src/ultracache/report.d.ts +13 -0
- package/dist/src/ultracache/report.js +62 -0
- package/dist/src/ultracache/store.d.ts +41 -0
- package/dist/src/ultracache/store.js +158 -0
- package/dist/src/utils/ab-testing.d.ts +4 -1
- package/dist/src/utils/ab-testing.js +22 -19
- package/dist/src/utils/chunkify.d.ts +1 -7
- package/dist/src/utils/chunkify.js +2 -8
- package/dist/src/utils/command-line-utils.d.ts +20 -0
- package/dist/src/utils/command-line-utils.js +10 -3
- package/dist/src/utils/create-cli-options.d.ts +6 -0
- package/dist/src/utils/create-cli-options.js +29 -0
- package/dist/src/utils/db-connection.d.ts +2 -0
- package/dist/src/utils/db-connection.js +2 -0
- package/dist/src/utils/formatters/index.d.ts +6 -0
- package/dist/src/utils/formatters/index.js +5 -0
- package/dist/src/utils/formatters/prettier.d.ts +0 -8
- package/dist/src/utils/formatters/prettier.js +4 -26
- package/dist/src/utils/git-utils.d.ts +19 -0
- package/dist/src/utils/git-utils.js +97 -39
- package/dist/src/utils/handle-errors.js +5 -43
- package/dist/src/utils/http-client.d.ts +27 -0
- package/dist/src/utils/http-client.js +193 -0
- package/dist/src/utils/installed-nx-version.js +2 -48
- package/dist/src/utils/json-diff.d.ts +4 -2
- package/dist/src/utils/json-diff.js +6 -94
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-cloud-utils.d.ts +2 -0
- package/dist/src/utils/nx-cloud-utils.js +6 -1
- package/dist/src/utils/output.d.ts +22 -3
- package/dist/src/utils/output.js +28 -5
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +49 -6
- package/dist/src/utils/package-manager.d.ts +6 -0
- package/dist/src/utils/package-manager.js +10 -0
- package/dist/src/utils/plugins/plugin-capabilities.js +7 -2
- package/dist/src/utils/project-graph-utils.d.ts +2 -0
- package/dist/src/utils/project-graph-utils.js +12 -0
- package/dist/src/utils/provenance.js +20 -4
- package/dist/src/utils/serialize-overrides-into-command-line.js +2 -4
- package/dist/src/utils/workspace-context.d.ts +51 -3
- package/dist/src/utils/workspace-context.js +174 -10
- package/package.json +31 -48
- package/readme-template.md +16 -0
- package/schemas/nx-schema.json +38 -0
- package/schemas/project-schema.json +35 -0
- package/dist/src/daemon/server/file-watching/route-workspace-changes.d.ts +0 -9
- package/dist/src/daemon/server/file-watching/route-workspace-changes.js +0 -76
- package/dist/src/daemon/server/watcher.d.ts +0 -18
- package/dist/src/daemon/server/watcher.js +0 -126
- package/dist/src/nx-cloud/utilities/axios.d.ts +0 -4
- package/dist/src/nx-cloud/utilities/axios.js +0 -17
- package/dist/src/project-graph/affected/locators/project-glob-changes.d.ts +0 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-json-changes.d.ts +0 -4
- package/dist/src/project-graph/affected/locators/workspace-json-changes.js +0 -47
- package/dist/src/project-graph/affected/locators/workspace-projects.d.ts +0 -3
- package/dist/src/project-graph/affected/locators/workspace-projects.js +0 -74
- package/dist/src/utils/collapse-expanded-outputs.d.ts +0 -10
- package/dist/src/utils/collapse-expanded-outputs.js +0 -72
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.restoreTermiosAfterAgent = restoreTermiosAfterAgent;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
function restoreTermiosAfterAgent() {
|
|
6
|
+
if (process.platform === 'win32')
|
|
7
|
+
return;
|
|
8
|
+
if (!process.stdin.isTTY)
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
// Not setRawMode(false): it short-circuits when libuv's per-handle mode
|
|
12
|
+
// is already NORMAL, even after the agent changed termios out-of-band.
|
|
13
|
+
// `stty sane` goes through the kernel instead.
|
|
14
|
+
(0, child_process_1.execSync)('stty sane < /dev/tty', {
|
|
15
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
|
16
|
+
windowsHide: true,
|
|
17
|
+
});
|
|
18
|
+
// Carriage-return + clear to end of screen, to wipe any agent TUI
|
|
19
|
+
// cells below our row that subsequent log lines won't overwrite
|
|
20
|
+
// (e.g. a status footer past where our text wraps).
|
|
21
|
+
process.stdout.write('\r\x1B[J');
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
// Best-effort: if stty isn't on PATH or /dev/tty isn't accessible, the
|
|
25
|
+
// worst case is the pre-existing staircase + cell-bleed output.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -10,14 +10,17 @@ export type { AgentId };
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const MIGRATE_RUNS_RELATIVE_DIR = ".nx/migrate-runs";
|
|
12
12
|
/**
|
|
13
|
-
* The one subtree of a run directory an agent writes
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* so without it they would occupy the run directory's top level and leave Nx
|
|
18
|
-
* no name it could add there safely.
|
|
13
|
+
* The one subtree of a run directory an agent writes; everything beside it is
|
|
14
|
+
* state Nx owns, so the pre-authorized write scope stops here. Handoff names
|
|
15
|
+
* derive from step ids or package and migration names, so flattening them into
|
|
16
|
+
* the run dir would leave Nx no name it could safely add.
|
|
19
17
|
*/
|
|
20
18
|
export declare const HANDOFFS_DIR_NAME = "handoffs";
|
|
19
|
+
/**
|
|
20
|
+
* Sibling subtree holding the per-step prompt files Nx writes for the agent
|
|
21
|
+
* to read. They stay out of `handoffs/`, which is the agent's to write.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PROMPTS_DIR_NAME = "prompts";
|
|
21
24
|
export declare function isHandoffGitignoreMigration(m: {
|
|
22
25
|
package: string;
|
|
23
26
|
name: string;
|
|
@@ -38,10 +41,22 @@ export interface DetectedInstalledAgent {
|
|
|
38
41
|
* Inputs the runner provides when asking an agent definition to build its
|
|
39
42
|
* spawn arguments. Kept minimal — agent-specific quirks (e.g. transient agent
|
|
40
43
|
* name for OpenCode) are encoded inside the definition, not here.
|
|
44
|
+
*
|
|
45
|
+
* Both prompts are written to disk (see `instruction-files.ts`) and reached
|
|
46
|
+
* through `systemPromptFilePath` / `instructionsPointer`. The inline fields
|
|
47
|
+
* below are the exception, for agents that cannot be pointed at a file.
|
|
41
48
|
*/
|
|
42
49
|
export interface InvocationContext {
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
/** Absolute path of the file holding the step's system prompt. */
|
|
51
|
+
systemPromptFilePath: string;
|
|
52
|
+
/** Verbatim system prompt, only for a step with no file-loading path. */
|
|
53
|
+
systemPrompt: string;
|
|
54
|
+
/** Single-line command-line text pointing the agent at its instructions. */
|
|
55
|
+
instructionsPointer: string;
|
|
56
|
+
/** Inline handoff contract and pointer to `systemPromptFilePath`. */
|
|
57
|
+
inlineSystemContext: string;
|
|
58
|
+
/** Shorter `inlineSystemContext`, substituted on Windows shim overflow. */
|
|
59
|
+
inlineSystemContextFallback: string;
|
|
45
60
|
workspaceRoot: string;
|
|
46
61
|
/**
|
|
47
62
|
* Name of the run directory under `MIGRATE_RUNS_RELATIVE_DIR` holding this
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
|
|
3
|
+
exports.PROMPTS_DIR_NAME = exports.HANDOFFS_DIR_NAME = exports.MIGRATE_RUNS_RELATIVE_DIR = void 0;
|
|
4
4
|
exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
|
|
5
5
|
/**
|
|
6
6
|
* Workspace-relative directory holding all migrate-run scratch: a run
|
|
@@ -12,14 +12,17 @@ exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
|
|
|
12
12
|
*/
|
|
13
13
|
exports.MIGRATE_RUNS_RELATIVE_DIR = '.nx/migrate-runs';
|
|
14
14
|
/**
|
|
15
|
-
* The one subtree of a run directory an agent writes
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* so without it they would occupy the run directory's top level and leave Nx
|
|
20
|
-
* no name it could add there safely.
|
|
15
|
+
* The one subtree of a run directory an agent writes; everything beside it is
|
|
16
|
+
* state Nx owns, so the pre-authorized write scope stops here. Handoff names
|
|
17
|
+
* derive from step ids or package and migration names, so flattening them into
|
|
18
|
+
* the run dir would leave Nx no name it could safely add.
|
|
21
19
|
*/
|
|
22
20
|
exports.HANDOFFS_DIR_NAME = 'handoffs';
|
|
21
|
+
/**
|
|
22
|
+
* Sibling subtree holding the per-step prompt files Nx writes for the agent
|
|
23
|
+
* to read. They stay out of `handoffs/`, which is the agent's to write.
|
|
24
|
+
*/
|
|
25
|
+
exports.PROMPTS_DIR_NAME = 'prompts';
|
|
23
26
|
/**
|
|
24
27
|
* Composite identity of the v23 migration that adds `.nx/migrate-runs` to
|
|
25
28
|
* `.gitignore`. Hard-coded because the agentic preflight is a deliberate
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { SpawnOptions } from 'child_process';
|
|
2
|
+
export declare function quoteCmdArg(arg: string): string;
|
|
3
|
+
export declare function caretEscape(quoted: string): string;
|
|
4
|
+
/**
|
|
5
|
+
* Stops cmd.exe expanding `%VAR%` inside an argument. A caret cannot escape
|
|
6
|
+
* `%`, since expansion runs before caret processing, so each `%` becomes
|
|
7
|
+
* `%%cd:~,%`: `%cd:~,%` is a zero-length substring of a built-in and expands to
|
|
8
|
+
* nothing, leaving the leading `%`. Runs after the caret passes so the `,` it
|
|
9
|
+
* introduces stays uncareted, which the substring syntax requires.
|
|
10
|
+
*/
|
|
11
|
+
export declare function neutralizePercent(escaped: string): string;
|
|
12
|
+
export declare const WINDOWS_COMMAND_LINE_LIMIT = 8191;
|
|
13
|
+
export declare const WINDOWS_COMMAND_LINE_BUDGET: number;
|
|
14
|
+
export interface AdaptedSpawn {
|
|
15
|
+
binary: string;
|
|
16
|
+
args: string[];
|
|
17
|
+
options: SpawnOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Length of the command line Windows will receive. Set only on the `cmd.exe`
|
|
20
|
+
* wrapper path.
|
|
21
|
+
*/
|
|
22
|
+
commandLineLength?: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function withinCommandLineBudget(adapted: AdaptedSpawn): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Node's `spawn` cannot directly execute `.cmd` / `.bat` shims on Windows;
|
|
27
|
+
* `which` resolves to those when an agent was installed via npm. Wrap them in
|
|
28
|
+
* a `cmd.exe /c` invocation with `windowsVerbatimArguments` so quoting follows
|
|
29
|
+
* the cmd.exe convention rather than Node's default cooking.
|
|
30
|
+
*
|
|
31
|
+
* On non-Windows or for non-shim binaries this is a passthrough.
|
|
32
|
+
*/
|
|
33
|
+
export declare function adaptSpawnForWindowsShim(binary: string, args: readonly string[], options: SpawnOptions): AdaptedSpawn;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WINDOWS_COMMAND_LINE_BUDGET = exports.WINDOWS_COMMAND_LINE_LIMIT = void 0;
|
|
4
|
+
exports.quoteCmdArg = quoteCmdArg;
|
|
5
|
+
exports.caretEscape = caretEscape;
|
|
6
|
+
exports.neutralizePercent = neutralizePercent;
|
|
7
|
+
exports.withinCommandLineBudget = withinCommandLineBudget;
|
|
8
|
+
exports.adaptSpawnForWindowsShim = adaptSpawnForWindowsShim;
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
// Backslash-escape embedded quotes per MS C runtime convention, then wrap in
|
|
11
|
+
// quotes. Callers caret-escape cmd.exe metacharacters on top.
|
|
12
|
+
function quoteCmdArg(arg) {
|
|
13
|
+
return `"${arg.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\*)$/, '$1$1')}"`;
|
|
14
|
+
}
|
|
15
|
+
const CMD_META_CHARS = /([()\][!^"`<>&|;, ])/g;
|
|
16
|
+
function caretEscape(quoted) {
|
|
17
|
+
return quoted.replace(CMD_META_CHARS, '^$1');
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Stops cmd.exe expanding `%VAR%` inside an argument. A caret cannot escape
|
|
21
|
+
* `%`, since expansion runs before caret processing, so each `%` becomes
|
|
22
|
+
* `%%cd:~,%`: `%cd:~,%` is a zero-length substring of a built-in and expands to
|
|
23
|
+
* nothing, leaving the leading `%`. Runs after the caret passes so the `,` it
|
|
24
|
+
* introduces stays uncareted, which the substring syntax requires.
|
|
25
|
+
*/
|
|
26
|
+
function neutralizePercent(escaped) {
|
|
27
|
+
return escaped.replace(/%/g, '%%cd:~,%');
|
|
28
|
+
}
|
|
29
|
+
// "The maximum length of the string that you can use at the command prompt is
|
|
30
|
+
// 8191 characters".
|
|
31
|
+
// https://learn.microsoft.com/troubleshoot/windows-client/shell-experience/command-line-string-limitation
|
|
32
|
+
exports.WINDOWS_COMMAND_LINE_LIMIT = 8191;
|
|
33
|
+
// Absorbs cmd.exe's own accounting of the string, which cannot be measured
|
|
34
|
+
// from here.
|
|
35
|
+
const WINDOWS_COMMAND_LINE_RESERVE = 1000;
|
|
36
|
+
exports.WINDOWS_COMMAND_LINE_BUDGET = exports.WINDOWS_COMMAND_LINE_LIMIT - WINDOWS_COMMAND_LINE_RESERVE;
|
|
37
|
+
function withinCommandLineBudget(adapted) {
|
|
38
|
+
return (adapted.commandLineLength === undefined ||
|
|
39
|
+
adapted.commandLineLength <= exports.WINDOWS_COMMAND_LINE_BUDGET);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Node's `spawn` cannot directly execute `.cmd` / `.bat` shims on Windows;
|
|
43
|
+
* `which` resolves to those when an agent was installed via npm. Wrap them in
|
|
44
|
+
* a `cmd.exe /c` invocation with `windowsVerbatimArguments` so quoting follows
|
|
45
|
+
* the cmd.exe convention rather than Node's default cooking.
|
|
46
|
+
*
|
|
47
|
+
* On non-Windows or for non-shim binaries this is a passthrough.
|
|
48
|
+
*/
|
|
49
|
+
function adaptSpawnForWindowsShim(binary, args, options) {
|
|
50
|
+
if (process.platform !== 'win32') {
|
|
51
|
+
return { binary, args: [...args], options };
|
|
52
|
+
}
|
|
53
|
+
const ext = (0, path_1.extname)(binary).toLowerCase();
|
|
54
|
+
if (ext !== '.cmd' && ext !== '.bat') {
|
|
55
|
+
return { binary, args: [...args], options };
|
|
56
|
+
}
|
|
57
|
+
assertNoLineBreaks(binary, args);
|
|
58
|
+
const cmdLine = [escapeCmdCommand(binary), ...args.map(escapeCmdArg)].join(' ');
|
|
59
|
+
const comspec = process.env.comspec || 'cmd.exe';
|
|
60
|
+
// Both modes are set rather than inherited, since a machine-wide registry
|
|
61
|
+
// setting can flip either: `/e:on` for the `%cd:~,%` substring, `/v:off` so a
|
|
62
|
+
// `!` stays literal. The outer quotes stop `cmd.exe /c` stripping the inner
|
|
63
|
+
// ones around the binary path.
|
|
64
|
+
const cmdArgs = ['/e:on', '/v:off', '/d', '/s', '/c', `"${cmdLine}"`];
|
|
65
|
+
return {
|
|
66
|
+
binary: comspec,
|
|
67
|
+
args: cmdArgs,
|
|
68
|
+
options: { ...options, windowsVerbatimArguments: true },
|
|
69
|
+
// `windowsVerbatimArguments` makes the command line the argv joined by
|
|
70
|
+
// single spaces, so this is what CreateProcess and then cmd.exe see.
|
|
71
|
+
commandLineLength: [comspec, ...cmdArgs].join(' ').length,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
// No escaping reproduces a line break on the other side, and cmd.exe truncates
|
|
75
|
+
// the command line at it, so the call is refused.
|
|
76
|
+
function assertNoLineBreaks(binary, args) {
|
|
77
|
+
const offending = [binary, ...args].find((value) => /[\r\n]/.test(value));
|
|
78
|
+
if (offending !== undefined) {
|
|
79
|
+
throw new Error(`Cannot pass a multi-line argument to "${binary}" on Windows: cmd.exe truncates the command line at the line break. Offending argument: ${JSON.stringify(offending.slice(0, 120))}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function escapeCmdArg(arg) {
|
|
83
|
+
return neutralizePercent(caretEscape(quoteCmdArg(arg)));
|
|
84
|
+
}
|
|
85
|
+
// cmd.exe parses the command portion twice, so it is caret-escaped twice.
|
|
86
|
+
function escapeCmdCommand(arg) {
|
|
87
|
+
return neutralizePercent(caretEscape(caretEscape(quoteCmdArg(arg))));
|
|
88
|
+
}
|
|
@@ -21,6 +21,7 @@ export interface MigrateArgs {
|
|
|
21
21
|
runMigration?: string;
|
|
22
22
|
runId?: string;
|
|
23
23
|
stepAction?: StepAction;
|
|
24
|
+
startFresh?: boolean;
|
|
24
25
|
include?: MigrateInclude;
|
|
25
26
|
/**
|
|
26
27
|
* nx.json `migrate.include` default. Consumed by `resolveInclude` only when the
|
|
@@ -34,6 +35,7 @@ export interface MigrateArgs {
|
|
|
34
35
|
commitPrefix?: string;
|
|
35
36
|
agentic?: AgenticArg;
|
|
36
37
|
validate?: boolean;
|
|
38
|
+
finalValidation?: boolean;
|
|
37
39
|
ifExists?: boolean;
|
|
38
40
|
interactive?: boolean;
|
|
39
41
|
[key: string]: any;
|
|
@@ -60,7 +60,7 @@ function withMigrationOptions(yargs) {
|
|
|
60
60
|
})
|
|
61
61
|
.option('runId', {
|
|
62
62
|
// Hidden with the orchestrator itself.
|
|
63
|
-
describe: 'The orchestrated migrate run to record a single migration into, or to reconcile when given
|
|
63
|
+
describe: 'The orchestrated migrate run to record a single migration into, to continue with --run-migrations, or to reconcile when given alone.',
|
|
64
64
|
type: 'string',
|
|
65
65
|
hidden: true,
|
|
66
66
|
})
|
|
@@ -69,6 +69,11 @@ function withMigrationOptions(yargs) {
|
|
|
69
69
|
choices: step_actions_1.STEP_ACTIONS,
|
|
70
70
|
type: 'string',
|
|
71
71
|
hidden: true,
|
|
72
|
+
})
|
|
73
|
+
.option('startFresh', {
|
|
74
|
+
describe: 'With --run-migrations and --run-id=<id> under the orchestrator: delete the record of the active migrate run the id names and start a new run over the whole plan. Migrations the deleted run applied stay applied.',
|
|
75
|
+
type: 'boolean',
|
|
76
|
+
hidden: true,
|
|
72
77
|
})
|
|
73
78
|
.option('ifExists', {
|
|
74
79
|
describe: `Run migrations only if the migrations file exists, if not continues successfully.`,
|
|
@@ -124,6 +129,11 @@ function withMigrationOptions(yargs) {
|
|
|
124
129
|
.option('validate', {
|
|
125
130
|
describe: 'When `--agentic` resolves to an enabled agent, run agent-driven validation after generator-only migrations that have no `prompt:` field. Defaults to on; pass `--no-validate` to opt out. Has no effect when `--agentic` is disabled, when running inside an outer agent, or when running non-interactively without an explicit agent.',
|
|
126
131
|
type: 'boolean',
|
|
132
|
+
})
|
|
133
|
+
.option('finalValidation', {
|
|
134
|
+
describe: 'With --run-migrations under the orchestrator: end the run with an agent validation pass over the whole workspace once every migration has run. On by default; pass --no-final-validation to opt out.',
|
|
135
|
+
type: 'boolean',
|
|
136
|
+
hidden: true,
|
|
127
137
|
})
|
|
128
138
|
.check(({ createCommits, commitPrefix, from, excludeAppliedMigrations, include, agentic, }) => {
|
|
129
139
|
// Only an explicit `--no-create-commits` is decidable here, before the
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type NoticeLevel = 'log' | 'warn' | 'error';
|
|
2
|
+
export type LineColor = 'dim' | 'yellow' | 'red';
|
|
3
|
+
export interface MigrateOutputSink {
|
|
4
|
+
notice(level: NoticeLevel, message: {
|
|
5
|
+
title: string;
|
|
6
|
+
bodyLines?: string[];
|
|
7
|
+
}): void;
|
|
8
|
+
line(color: LineColor, text: string): void;
|
|
9
|
+
/** A chunk of a package manager's own output. */
|
|
10
|
+
raw(chunk: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare const terminalOutput: MigrateOutputSink;
|
|
13
|
+
export type DeferredOutputRecord = {
|
|
14
|
+
kind: 'notice';
|
|
15
|
+
level: NoticeLevel;
|
|
16
|
+
title: string;
|
|
17
|
+
bodyLines?: string[];
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'line';
|
|
20
|
+
color: LineColor;
|
|
21
|
+
text: string;
|
|
22
|
+
} | {
|
|
23
|
+
kind: 'raw';
|
|
24
|
+
text: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Collects the output as records that `replayDeferredOutput` prints later.
|
|
28
|
+
* The notices and lines are always kept; package manager output is bounded
|
|
29
|
+
* like generator output and rendered only on request. Render once the output
|
|
30
|
+
* is complete: a rendered collector accepts nothing more.
|
|
31
|
+
*/
|
|
32
|
+
export declare class DeferredOutputCollector implements MigrateOutputSink {
|
|
33
|
+
private readonly records;
|
|
34
|
+
private rendered;
|
|
35
|
+
private assertOpen;
|
|
36
|
+
notice(level: NoticeLevel, message: {
|
|
37
|
+
title: string;
|
|
38
|
+
bodyLines?: string[];
|
|
39
|
+
}): void;
|
|
40
|
+
line(color: LineColor, text: string): void;
|
|
41
|
+
raw(chunk: string): void;
|
|
42
|
+
render(rawOutput: 'keep' | 'drop'): DeferredOutputRecord[];
|
|
43
|
+
}
|
|
44
|
+
export declare function replayDeferredOutput(records: DeferredOutputRecord[], to?: MigrateOutputSink): void;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeferredOutputCollector = exports.terminalOutput = void 0;
|
|
4
|
+
exports.replayDeferredOutput = replayDeferredOutput;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const pc = tslib_1.__importStar(require("picocolors"));
|
|
7
|
+
const logger_1 = require("../../utils/logger");
|
|
8
|
+
const output_1 = require("../../utils/output");
|
|
9
|
+
exports.terminalOutput = {
|
|
10
|
+
notice: (level, message) => output_1.output[level](message),
|
|
11
|
+
line: (color, text) => logger_1.logger.info(pc[color](text)),
|
|
12
|
+
raw: (chunk) => process.stdout.write(chunk),
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Collects the output as records that `replayDeferredOutput` prints later.
|
|
16
|
+
* The notices and lines are always kept; package manager output is bounded
|
|
17
|
+
* like generator output and rendered only on request. Render once the output
|
|
18
|
+
* is complete: a rendered collector accepts nothing more.
|
|
19
|
+
*/
|
|
20
|
+
class DeferredOutputCollector {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.records = [];
|
|
23
|
+
this.rendered = false;
|
|
24
|
+
}
|
|
25
|
+
assertOpen() {
|
|
26
|
+
if (this.rendered) {
|
|
27
|
+
throw new Error('The deferred output was already rendered.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
notice(level, message) {
|
|
31
|
+
this.assertOpen();
|
|
32
|
+
this.records.push({ kind: 'notice', level, ...message });
|
|
33
|
+
}
|
|
34
|
+
line(color, text) {
|
|
35
|
+
this.assertOpen();
|
|
36
|
+
this.records.push({ kind: 'line', color, text });
|
|
37
|
+
}
|
|
38
|
+
raw(chunk) {
|
|
39
|
+
this.assertOpen();
|
|
40
|
+
let block = this.records[this.records.length - 1];
|
|
41
|
+
if (block?.kind !== 'raw-block') {
|
|
42
|
+
// Lazy: the non-agentic migrate path must not load the agentic chain.
|
|
43
|
+
const { BoundedChunks } = require('./agentic/capture-generator-output');
|
|
44
|
+
block = { kind: 'raw-block', buffer: new BoundedChunks() };
|
|
45
|
+
this.records.push(block);
|
|
46
|
+
}
|
|
47
|
+
block.buffer.append(chunk);
|
|
48
|
+
}
|
|
49
|
+
render(rawOutput) {
|
|
50
|
+
this.rendered = true;
|
|
51
|
+
const records = [];
|
|
52
|
+
for (const record of this.records) {
|
|
53
|
+
if (record.kind !== 'raw-block') {
|
|
54
|
+
records.push(record);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (rawOutput === 'drop')
|
|
58
|
+
continue;
|
|
59
|
+
// The replay adds the final newline back.
|
|
60
|
+
const text = record.buffer.render();
|
|
61
|
+
records.push({
|
|
62
|
+
kind: 'raw',
|
|
63
|
+
text: text.endsWith('\n') ? text.slice(0, -1) : text,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return records;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.DeferredOutputCollector = DeferredOutputCollector;
|
|
70
|
+
function replayDeferredOutput(records, to = exports.terminalOutput) {
|
|
71
|
+
for (const record of records) {
|
|
72
|
+
switch (record.kind) {
|
|
73
|
+
case 'notice':
|
|
74
|
+
to.notice(record.level, {
|
|
75
|
+
title: record.title,
|
|
76
|
+
bodyLines: record.bodyLines,
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
case 'line':
|
|
80
|
+
to.line(record.color, record.text);
|
|
81
|
+
break;
|
|
82
|
+
case 'raw':
|
|
83
|
+
if (record.text)
|
|
84
|
+
to.raw(`${record.text}\n`);
|
|
85
|
+
break;
|
|
86
|
+
default: {
|
|
87
|
+
const exhaustive = record;
|
|
88
|
+
throw new Error(`Unhandled output record: ${JSON.stringify(exhaustive)}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { MigrationsJson } from '../../config/misc-interfaces';
|
|
2
2
|
import { FileChange } from '../../generators/tree';
|
|
3
3
|
import { ArrayPackageGroup, NxMigrationsConfiguration, PackageJson } from '../../utils/package-json';
|
|
4
|
+
import { type MigrateOutputSink } from './deferred-output';
|
|
4
5
|
interface PackageMigrationConfig extends NxMigrationsConfiguration {
|
|
5
6
|
packageJson: PackageJson;
|
|
6
7
|
packageGroup: ArrayPackageGroup;
|
|
7
8
|
}
|
|
8
9
|
export declare function readPackageMigrationConfig(packageName: string, dir: string): PackageMigrationConfig;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* With a `sink`, stdin is ignored and stdout and stderr are collected for a
|
|
12
|
+
* caller sharing the terminal. On POSIX the child stays in nx's process
|
|
13
|
+
* group. Without a sink, the install owns the terminal.
|
|
14
|
+
*/
|
|
15
|
+
export declare function runInstall(nxWorkspaceRoot?: string, phase?: MigrationInstallPhase, rerunCommand?: string, sink?: MigrateOutputSink): Promise<void>;
|
|
10
16
|
export type MigrationInstallPhase = 'pre-migration' | 'post-migration';
|
|
11
17
|
export declare class NpmPeerDepsInstallError extends Error {
|
|
12
18
|
constructor();
|
|
@@ -20,8 +26,8 @@ export declare class NpmPeerDepsInstallError extends Error {
|
|
|
20
26
|
*/
|
|
21
27
|
export declare function isNpmPeerDepsError(stderr: string): boolean;
|
|
22
28
|
export declare function formatSingleMigrationRerunCommand(migrationId: string): string;
|
|
23
|
-
export declare function logNpmPeerDepsError(phase: MigrationInstallPhase, rerunCommand?: string): void;
|
|
24
|
-
export declare function logSkippedPostMigrationInstall(root: string): void;
|
|
29
|
+
export declare function logNpmPeerDepsError(phase: MigrationInstallPhase, rerunCommand?: string, out?: MigrateOutputSink): void;
|
|
30
|
+
export declare function logSkippedPostMigrationInstall(root: string, out?: MigrateOutputSink): void;
|
|
25
31
|
export declare class ChangedDepInstaller {
|
|
26
32
|
private readonly root;
|
|
27
33
|
private readonly shouldSkipInstall;
|
|
@@ -20,6 +20,7 @@ exports.isAngularMigration = isAngularMigration;
|
|
|
20
20
|
const tslib_1 = require("tslib");
|
|
21
21
|
const pc = tslib_1.__importStar(require("picocolors"));
|
|
22
22
|
const child_process_1 = require("child_process");
|
|
23
|
+
const string_decoder_1 = require("string_decoder");
|
|
23
24
|
const path_1 = require("path");
|
|
24
25
|
const semver_1 = require("semver");
|
|
25
26
|
const handle_import_1 = require("../../utils/handle-import");
|
|
@@ -29,12 +30,12 @@ const logger_1 = require("../../utils/logger");
|
|
|
29
30
|
const text_1 = require("./text");
|
|
30
31
|
const package_json_1 = require("../../utils/package-json");
|
|
31
32
|
const package_manager_1 = require("../../utils/package-manager");
|
|
32
|
-
const output_1 = require("../../utils/output");
|
|
33
33
|
const fs_1 = require("fs");
|
|
34
34
|
const installation_directory_1 = require("../../utils/installation-directory");
|
|
35
35
|
const shell_quoting_1 = require("../../utils/shell-quoting");
|
|
36
36
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
37
37
|
const version_utils_1 = require("./version-utils");
|
|
38
|
+
const deferred_output_1 = require("./deferred-output");
|
|
38
39
|
function readPackageMigrationConfig(packageName, dir) {
|
|
39
40
|
const { path: packageJsonPath, packageJson: json } = (0, package_json_1.readModulePackageJson)(packageName, (0, installation_directory_1.getNxRequirePaths)(dir));
|
|
40
41
|
const config = (0, package_json_1.readNxMigrateConfig)(json);
|
|
@@ -61,32 +62,68 @@ function readPackageMigrationConfig(packageName, dir) {
|
|
|
61
62
|
};
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
/**
|
|
66
|
+
* With a `sink`, stdin is ignored and stdout and stderr are collected for a
|
|
67
|
+
* caller sharing the terminal. On POSIX the child stays in nx's process
|
|
68
|
+
* group. Without a sink, the install owns the terminal.
|
|
69
|
+
*/
|
|
70
|
+
function runInstall(nxWorkspaceRoot, phase = 'pre-migration', rerunCommand, sink) {
|
|
65
71
|
const cwd = nxWorkspaceRoot ?? process.cwd();
|
|
66
72
|
const packageManager = (0, package_manager_1.detectPackageManager)(cwd);
|
|
67
73
|
const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager, cwd);
|
|
74
|
+
const out = sink ?? deferred_output_1.terminalOutput;
|
|
68
75
|
const installCommand = `${pmCommands.install} ${pmCommands.ignoreScriptsFlag ?? ''}`;
|
|
69
|
-
|
|
76
|
+
out.notice('log', {
|
|
70
77
|
title: `Running '${installCommand}' to make sure necessary packages are installed`,
|
|
71
78
|
});
|
|
72
79
|
return new Promise((resolve, reject) => {
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
// stderr directly since
|
|
80
|
+
// npm's stderr is piped so peer dependency errors can be detected in it.
|
|
81
|
+
// Without a sink it is mirrored live and other package managers inherit
|
|
82
|
+
// stderr directly, since their output is not inspected.
|
|
76
83
|
const shouldCaptureStderr = packageManager === 'npm';
|
|
77
84
|
const child = (0, child_process_1.spawn)(installCommand, {
|
|
78
85
|
shell: true,
|
|
79
|
-
stdio:
|
|
86
|
+
stdio: sink
|
|
87
|
+
? ['ignore', 'pipe', 'pipe']
|
|
88
|
+
: ['inherit', 'inherit', shouldCaptureStderr ? 'pipe' : 'inherit'],
|
|
80
89
|
windowsHide: true,
|
|
81
90
|
cwd,
|
|
82
91
|
});
|
|
92
|
+
// Decoded per stream: a chunk boundary can split a multi-byte character,
|
|
93
|
+
// and a sequence still incomplete at the end is what `end()` returns.
|
|
94
|
+
const stdoutText = new string_decoder_1.StringDecoder('utf8');
|
|
95
|
+
const stderrText = new string_decoder_1.StringDecoder('utf8');
|
|
96
|
+
child.stdout?.on('data', (chunk) => out.raw(stdoutText.write(chunk)));
|
|
97
|
+
child.stdout?.on('end', () => out.raw(stdoutText.end()));
|
|
83
98
|
const stderrChunks = [];
|
|
84
99
|
child.stderr?.on('data', (chunk) => {
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
if (sink) {
|
|
101
|
+
out.raw(stderrText.write(chunk));
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
process.stderr.write(chunk);
|
|
105
|
+
}
|
|
106
|
+
if (shouldCaptureStderr)
|
|
107
|
+
stderrChunks.push(chunk);
|
|
108
|
+
});
|
|
109
|
+
if (sink)
|
|
110
|
+
child.stderr.on('end', () => out.raw(stderrText.end()));
|
|
111
|
+
// With a sink the rejection waits for `close`, which follows the streams'
|
|
112
|
+
// `end`: a caller must be able to render what it collected on rejection.
|
|
113
|
+
let spawnError = null;
|
|
114
|
+
child.on('error', (error) => {
|
|
115
|
+
if (sink) {
|
|
116
|
+
spawnError = error;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
reject(error);
|
|
120
|
+
}
|
|
87
121
|
});
|
|
88
|
-
child.on('error', reject);
|
|
89
122
|
child.on('close', (code) => {
|
|
123
|
+
if (spawnError) {
|
|
124
|
+
reject(spawnError);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
90
127
|
if (code === 0) {
|
|
91
128
|
resolve();
|
|
92
129
|
return;
|
|
@@ -98,7 +135,7 @@ function runInstall(nxWorkspaceRoot, phase = 'pre-migration', rerunCommand) {
|
|
|
98
135
|
// (CLI migrate, `nx repair`, single-migration runner, etc.) surfaces
|
|
99
136
|
// it consistently. Top-level callers catch `NpmPeerDepsInstallError`
|
|
100
137
|
// and return a non-zero exit code without re-logging.
|
|
101
|
-
logNpmPeerDepsError(phase, rerunCommand);
|
|
138
|
+
logNpmPeerDepsError(phase, rerunCommand, out);
|
|
102
139
|
reject(new NpmPeerDepsInstallError());
|
|
103
140
|
return;
|
|
104
141
|
}
|
|
@@ -143,7 +180,7 @@ function formatSingleMigrationRerunCommand(migrationId) {
|
|
|
143
180
|
: migrationId;
|
|
144
181
|
return `nx migrate --run-migration=${id}`;
|
|
145
182
|
}
|
|
146
|
-
function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations') {
|
|
183
|
+
function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations', out = deferred_output_1.terminalOutput) {
|
|
147
184
|
const peerDepsResolutionSteps = [
|
|
148
185
|
'Recommended approaches (in order of preference):',
|
|
149
186
|
'',
|
|
@@ -160,7 +197,7 @@ function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations'
|
|
|
160
197
|
` ${rerunCommand} --skip-install`,
|
|
161
198
|
];
|
|
162
199
|
if (phase === 'pre-migration') {
|
|
163
|
-
|
|
200
|
+
out.notice('error', {
|
|
164
201
|
title: 'You need to resolve the peer dependency conflicts before the migration can continue',
|
|
165
202
|
bodyLines: [
|
|
166
203
|
...peerDepsResolutionSteps,
|
|
@@ -173,7 +210,7 @@ function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations'
|
|
|
173
210
|
});
|
|
174
211
|
}
|
|
175
212
|
else {
|
|
176
|
-
|
|
213
|
+
out.notice('error', {
|
|
177
214
|
title: 'Some migrations have been applied, but installing the updated dependencies failed',
|
|
178
215
|
bodyLines: [
|
|
179
216
|
...peerDepsResolutionSteps,
|
|
@@ -187,10 +224,10 @@ function logNpmPeerDepsError(phase, rerunCommand = 'nx migrate --run-migrations'
|
|
|
187
224
|
});
|
|
188
225
|
}
|
|
189
226
|
}
|
|
190
|
-
function logSkippedPostMigrationInstall(root) {
|
|
227
|
+
function logSkippedPostMigrationInstall(root, out = deferred_output_1.terminalOutput) {
|
|
191
228
|
const packageManager = (0, package_manager_1.detectPackageManager)(root);
|
|
192
229
|
const installCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager, root).install;
|
|
193
|
-
|
|
230
|
+
out.notice('warn', {
|
|
194
231
|
title: 'Migrations updated your dependencies, but the install was skipped',
|
|
195
232
|
bodyLines: [`Run "${installCommand}" to install the updated dependencies.`],
|
|
196
233
|
});
|
|
@@ -72,23 +72,48 @@ export declare function reportMigrateOrchestratorInit(opts: {
|
|
|
72
72
|
createCommits: boolean;
|
|
73
73
|
}): void;
|
|
74
74
|
/**
|
|
75
|
-
* One event per
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* `attempt` rides the
|
|
75
|
+
* One event per dispense response, repeated on every reconcile until the
|
|
76
|
+
* step moves. The `action` (dispense case) is a closed enum carried on a
|
|
77
|
+
* reused dimension, read conditioned on the event name (the same
|
|
78
|
+
* multiplexing pattern as {@link reportMigratePrompt}); `attempt` rides the
|
|
79
|
+
* migration-count dimension and `ordinal` (the run's dispense count) the
|
|
80
|
+
* task-count one.
|
|
79
81
|
*/
|
|
80
82
|
export declare function reportMigrateOrchestratorDispense(opts: {
|
|
81
83
|
action: string;
|
|
82
84
|
attempt: number;
|
|
85
|
+
ordinal?: number;
|
|
83
86
|
}): void;
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
/** Once per durable dispense transition. */
|
|
88
|
+
export declare function reportMigrateOrchestratorStepDispensed(opts: {
|
|
89
|
+
attempt: number;
|
|
90
|
+
ordinal: number;
|
|
91
|
+
}): void;
|
|
92
|
+
export interface MigrateOrchestratorTallies {
|
|
89
93
|
completed: number;
|
|
90
94
|
skipped: number;
|
|
95
|
+
unresolved: number;
|
|
91
96
|
dispenseCount: number;
|
|
97
|
+
}
|
|
98
|
+
export declare function reportMigrateOrchestratorComplete(opts: MigrateOrchestratorTallies): void;
|
|
99
|
+
/** The agent session nx spawned ended with the run still active. */
|
|
100
|
+
export declare function reportMigrateOrchestratorAbandoned(opts: MigrateOrchestratorTallies & {
|
|
101
|
+
agentUsed: string;
|
|
102
|
+
}): void;
|
|
103
|
+
/**
|
|
104
|
+
* An explicit continue (`--run-migrations --run-id`, or "continue" at the
|
|
105
|
+
* master prompt) took up an active run; every resume reports. A bare
|
|
106
|
+
* `--run-id` reconcile is not a resume: nothing in run state marks the first
|
|
107
|
+
* call after a lost session.
|
|
108
|
+
*/
|
|
109
|
+
export declare function reportMigrateOrchestratorResume(opts: MigrateOrchestratorTallies): void;
|
|
110
|
+
/**
|
|
111
|
+
* An invocation found an active run and started nothing. `activity` says
|
|
112
|
+
* whether another nx migrate process held the run; 'unknown' where nx cannot
|
|
113
|
+
* tell.
|
|
114
|
+
*/
|
|
115
|
+
export declare function reportMigrateOrchestratorExistingRun(opts: MigrateOrchestratorTallies & {
|
|
116
|
+
activity: 'idle' | 'held' | 'unknown';
|
|
92
117
|
}): void;
|
|
93
118
|
/**
|
|
94
119
|
* Counts invocations, not completions: emitted as soon as the migration id
|