nx 23.2.0-beta.1 → 23.2.0-beta.11
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 +2 -2
- package/dist/bin/init-local.js +3 -5
- package/dist/bin/nx.js +2 -0
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/release/index.d.ts +1 -1
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +35 -15
- package/dist/src/analytics/analytics.d.ts +6 -0
- package/dist/src/analytics/analytics.js +16 -10
- package/dist/src/analytics/index.d.ts +1 -1
- package/dist/src/analytics/index.js +2 -1
- package/dist/src/command-line/add/add.js +5 -0
- package/dist/src/command-line/affected/affected.js +1 -0
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +19 -25
- package/dist/src/command-line/format/format.js +84 -101
- package/dist/src/command-line/generate/generate.js +35 -35
- package/dist/src/command-line/graph/graph.d.ts +1 -0
- package/dist/src/command-line/graph/graph.js +15 -6
- package/dist/src/command-line/import/import.js +30 -40
- package/dist/src/command-line/init/ai-agent-prompts.js +5 -11
- package/dist/src/command-line/init/command-object.js +4 -2
- package/dist/src/command-line/init/configure-plugins.js +4 -1
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +12 -32
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +17 -21
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +8 -21
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +3 -17
- package/dist/src/command-line/init/implementation/angular/index.js +10 -15
- package/dist/src/command-line/init/implementation/angular/integrated-workspace.js +2 -5
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +5 -0
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +8 -2
- package/dist/src/command-line/init/implementation/check-compatible-with-plugins.js +2 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +9 -1
- package/dist/src/command-line/init/implementation/format.d.ts +18 -0
- package/dist/src/command-line/init/implementation/format.js +114 -0
- package/dist/src/command-line/init/implementation/utils.js +8 -0
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +40 -57
- package/dist/src/command-line/migrate/agentic/definitions.js +36 -9
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +37 -22
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +30 -39
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +7 -7
- package/dist/src/command-line/migrate/agentic/handoff.js +13 -10
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +7 -12
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +7 -0
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +10 -0
- package/dist/src/command-line/migrate/agentic/run-step.js +1 -0
- package/dist/src/command-line/migrate/agentic/runner.js +24 -24
- package/dist/src/command-line/migrate/agentic/select.d.ts +10 -2
- package/dist/src/command-line/migrate/agentic/select.js +30 -32
- package/dist/src/command-line/migrate/agentic/types.d.ts +33 -3
- package/dist/src/command-line/migrate/agentic/types.js +35 -0
- package/dist/src/command-line/migrate/command-object.d.ts +6 -0
- package/dist/src/command-line/migrate/command-object.js +19 -1
- package/dist/src/command-line/migrate/execute-migration.d.ts +28 -9
- package/dist/src/command-line/migrate/execute-migration.js +112 -27
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +35 -0
- package/dist/src/command-line/migrate/migrate-analytics.js +64 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +38 -8
- package/dist/src/command-line/migrate/migrate-commits.js +130 -15
- package/dist/src/command-line/migrate/migrate-config.d.ts +13 -12
- package/dist/src/command-line/migrate/migrate-config.js +22 -14
- package/dist/src/command-line/migrate/migrate-output.d.ts +45 -7
- package/dist/src/command-line/migrate/migrate-output.js +52 -8
- package/dist/src/command-line/migrate/migrate-ui-api.d.ts +2 -1
- package/dist/src/command-line/migrate/migrate-ui-api.js +16 -7
- package/dist/src/command-line/migrate/migrate.d.ts +28 -68
- package/dist/src/command-line/migrate/migrate.js +657 -293
- package/dist/src/command-line/migrate/migration-shape.d.ts +8 -0
- package/dist/src/command-line/migrate/multi-major.js +7 -10
- package/dist/src/command-line/migrate/resolve-package-version.js +4 -8
- package/dist/src/command-line/migrate/run/agent-output.d.ts +20 -0
- package/dist/src/command-line/migrate/run/agent-output.js +65 -0
- package/dist/src/command-line/migrate/run/index.d.ts +9 -0
- package/dist/src/command-line/migrate/run/index.js +23 -0
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +20 -0
- package/dist/src/command-line/migrate/run/orchestrator.js +1200 -0
- package/dist/src/command-line/migrate/run/run-id.d.ts +16 -0
- package/dist/src/command-line/migrate/run/run-id.js +56 -0
- package/dist/src/command-line/migrate/run/run-state.d.ts +157 -0
- package/dist/src/command-line/migrate/run/run-state.js +438 -0
- package/dist/src/command-line/migrate/run/state-lock.d.ts +25 -0
- package/dist/src/command-line/migrate/run/state-lock.js +76 -0
- package/dist/src/command-line/migrate/run/state-machine.d.ts +84 -0
- package/dist/src/command-line/migrate/run/state-machine.js +315 -0
- package/dist/src/command-line/migrate/run/util.d.ts +59 -0
- package/dist/src/command-line/migrate/run/util.js +148 -0
- package/dist/src/command-line/migrate/run/worker.d.ts +16 -0
- package/dist/src/command-line/migrate/run/worker.js +682 -0
- package/dist/src/command-line/migrate/run-migration-process.js +6 -5
- package/dist/src/command-line/migrate/safe-prompt.d.ts +14 -26
- package/dist/src/command-line/migrate/safe-prompt.js +32 -43
- package/dist/src/command-line/migrate/sort-migrations.d.ts +16 -0
- package/dist/src/command-line/migrate/sort-migrations.js +32 -0
- package/dist/src/command-line/migrate/step-actions.d.ts +5 -0
- package/dist/src/command-line/migrate/step-actions.js +12 -0
- package/dist/src/command-line/migrate/text.d.ts +18 -0
- package/dist/src/command-line/migrate/text.js +26 -0
- package/dist/src/command-line/migrate/version-skew-guard.d.ts +60 -0
- package/dist/src/command-line/migrate/version-skew-guard.js +175 -0
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -21
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.d.ts +2 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +16 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.d.ts +4 -0
- package/dist/src/command-line/nx-cloud/start-nx-agents/start-nx-agents.js +13 -0
- package/dist/src/command-line/nx-commands.js +26 -24
- package/dist/src/command-line/release/changelog.js +11 -17
- package/dist/src/command-line/release/index.d.ts +1 -1
- package/dist/src/command-line/release/plan.js +15 -28
- package/dist/src/command-line/release/publish.js +5 -0
- package/dist/src/command-line/release/release.js +6 -17
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/release/utils/release-graph.d.ts +18 -0
- package/dist/src/command-line/release/utils/release-graph.js +81 -21
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +17 -23
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +14 -23
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/release-group-processor.d.ts +24 -0
- package/dist/src/command-line/release/version/release-group-processor.js +80 -6
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version/version-actions.d.ts +27 -2
- package/dist/src/command-line/release/version/version-actions.js +9 -1
- package/dist/src/command-line/release/version.js +10 -6
- package/dist/src/command-line/reset/reset.js +6 -1
- package/dist/src/command-line/run/run-one.js +1 -0
- package/dist/src/command-line/run-many/run-many.js +1 -0
- package/dist/src/command-line/show/show-target/inputs.js +50 -153
- package/dist/src/command-line/show/show-target/outputs.js +48 -173
- package/dist/src/command-line/show/show-target/utils.d.ts +28 -0
- package/dist/src/command-line/show/show-target/utils.js +83 -3
- package/dist/src/command-line/watch/watch.js +13 -0
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +2 -2
- package/dist/src/command-line/yargs-utils/shared-options.js +3 -1
- package/dist/src/config/misc-interfaces.d.ts +19 -7
- package/dist/src/config/nx-json.d.ts +4 -2
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +52 -1
- package/dist/src/daemon/client/client.js +160 -36
- package/dist/src/daemon/client/daemon-environment.d.ts +17 -0
- package/dist/src/daemon/client/daemon-environment.js +110 -2
- package/dist/src/daemon/client/daemon-socket-messenger.js +4 -0
- package/dist/src/daemon/message-types/daemon-message.d.ts +32 -0
- package/dist/src/daemon/message-types/daemon-message.js +25 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.d.ts +5 -0
- package/dist/src/daemon/server/file-watching/file-watcher-sockets.js +16 -0
- package/dist/src/daemon/server/handle-tasks-execution-hooks.d.ts +1 -1
- package/dist/src/daemon/server/latest-nx.js +5 -2
- package/dist/src/daemon/server/server.js +31 -4
- package/dist/src/daemon/server/shutdown-utils.d.ts +5 -0
- package/dist/src/daemon/server/shutdown-utils.js +11 -4
- package/dist/src/daemon/socket-utils.d.ts +1 -0
- package/dist/src/daemon/socket-utils.js +24 -3
- package/dist/src/daemon/tmp-dir.d.ts +43 -3
- package/dist/src/daemon/tmp-dir.js +437 -15
- package/dist/src/devkit-internals.d.ts +106 -8
- package/dist/src/devkit-internals.js +225 -7
- package/dist/src/executors/run-commands/running-tasks.js +46 -29
- package/dist/src/generators/internal-utils/format-changed-files.d.ts +24 -0
- package/dist/src/generators/internal-utils/format-changed-files.js +163 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.d.ts +15 -0
- package/dist/src/generators/testing-utils/create-tree-with-empty-workspace.js +21 -3
- package/dist/src/generators/tree.d.ts +4 -2
- package/dist/src/hasher/check-task-files.d.ts +86 -0
- package/dist/src/hasher/check-task-files.js +378 -0
- package/dist/src/migrations/update-15-0-0/prefix-outputs.js +2 -2
- package/dist/src/migrations/update-16-0-0/remove-nrwl-cli.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +2 -2
- package/dist/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -2
- package/dist/src/migrations/update-16-2-0/remove-run-commands-output-path.js +2 -2
- package/dist/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +2 -2
- package/dist/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +2 -2
- package/dist/src/migrations/update-17-2-0/move-default-base.js +2 -2
- package/dist/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +2 -2
- package/dist/src/migrations/update-19-2-4/set-project-name.js +2 -2
- package/dist/src/migrations/update-20-0-0/move-use-daemon-process.js +2 -2
- package/dist/src/migrations/update-20-0-1/use-legacy-cache.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-changelog-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +2 -2
- package/dist/src/migrations/update-21-0-0/remove-legacy-cache.js +2 -2
- package/dist/src/migrations/update-22-0-0/consolidate-release-tag-config.js +2 -2
- package/dist/src/migrations/update-22-0-0/release-version-config-changes.js +2 -2
- package/dist/src/migrations/update-22-2-0/add-self-healing-to-gitignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-settings-local-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-22-7-0/add-polygraph-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-0-0/add-migrate-runs-to-git-ignore.js +2 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +12 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +250 -0
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +50 -0
- package/dist/src/native/index.d.ts +37 -4
- package/dist/src/native/index.js +71 -28
- package/dist/src/native/native-bindings.js +3 -0
- package/dist/src/native/native-file-cache-location.d.ts +17 -1
- package/dist/src/native/native-file-cache-location.js +86 -12
- 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/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +3 -3
- package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
- package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -4
- package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/plugins/js/lock-file/lock-file.d.ts +46 -4
- package/dist/src/plugins/js/lock-file/lock-file.js +192 -15
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +420 -64
- package/dist/src/plugins/js/lock-file/project-graph-pruning.d.ts +25 -1
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +92 -12
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +330 -0
- package/dist/src/plugins/js/lock-file/pruned-output.js +1441 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.d.ts +1 -0
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +9 -5
- package/dist/src/plugins/js/project-graph/affected/npm-packages.js +51 -20
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +14 -4
- package/dist/src/project-graph/affected/affected-project-graph-models.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.d.ts +1 -1
- package/dist/src/project-graph/affected/affected-project-graph.js +2 -2
- package/dist/src/project-graph/affected/locators/project-glob-changes.js +5 -2
- package/dist/src/project-graph/build-project-graph.js +7 -1
- package/dist/src/project-graph/error-types.d.ts +12 -1
- package/dist/src/project-graph/error-types.js +27 -2
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +18 -1
- package/dist/src/project-graph/plugins/isolation/messaging.d.ts +16 -3
- package/dist/src/project-graph/plugins/isolation/messaging.js +3 -0
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +58 -8
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +1 -0
- package/dist/src/project-graph/project-graph.js +23 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +1 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +16 -2
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +12 -8
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +30 -21
- package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +12 -5
- package/dist/src/project-graph/utils/project-configuration/source-maps.js +21 -7
- package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +26 -27
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +50 -8
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +149 -6
- package/dist/src/project-graph/utils/project-configuration/utils.d.ts +15 -0
- package/dist/src/project-graph/utils/project-configuration/utils.js +42 -6
- package/dist/src/project-graph/utils/project-configuration-utils.d.ts +15 -12
- package/dist/src/project-graph/utils/project-configuration-utils.js +79 -99
- package/dist/src/tasks-runner/is-tui-enabled.js +3 -1
- package/dist/src/tasks-runner/life-cycle.d.ts +2 -2
- package/dist/src/tasks-runner/life-cycle.js +2 -2
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +12 -0
- package/dist/src/tasks-runner/life-cycles/performance-report.js +62 -3
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.d.ts +26 -1
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +99 -5
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.d.ts +26 -0
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +113 -17
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +17 -3
- package/dist/src/tasks-runner/pseudo-terminal.js +22 -10
- package/dist/src/tasks-runner/run-command.js +28 -35
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +55 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +161 -8
- package/dist/src/tasks-runner/task-env.d.ts +9 -0
- package/dist/src/tasks-runner/task-env.js +31 -4
- package/dist/src/tasks-runner/task-orchestrator.d.ts +72 -1
- package/dist/src/tasks-runner/task-orchestrator.js +182 -18
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/acknowledge-build-scripts.js +7 -5
- package/dist/src/utils/analytics-enabled.d.ts +7 -0
- package/dist/src/utils/analytics-enabled.js +11 -0
- package/dist/src/utils/analytics-prompt.d.ts +0 -6
- package/dist/src/utils/analytics-prompt.js +4 -58
- package/dist/src/utils/assert-workspace-validity.js +7 -2
- package/dist/src/utils/catalog/bun-manager-utils.d.ts +8 -0
- package/dist/src/utils/catalog/bun-manager-utils.js +174 -0
- package/dist/src/utils/catalog/bun-manager.d.ts +28 -0
- package/dist/src/utils/catalog/bun-manager.js +130 -0
- package/dist/src/utils/catalog/index.d.ts +1 -1
- package/dist/src/utils/catalog/index.js +1 -1
- package/dist/src/utils/catalog/manager-factory.js +3 -0
- package/dist/src/utils/catalog/manager-utils.d.ts +8 -1
- package/dist/src/utils/catalog/manager-utils.js +9 -4
- package/dist/src/utils/catalog/manager.d.ts +13 -1
- package/dist/src/utils/catalog/manager.js +30 -0
- package/dist/src/utils/catalog/pnpm-manager.d.ts +2 -1
- package/dist/src/utils/catalog/pnpm-manager.js +3 -0
- package/dist/src/utils/catalog/types.d.ts +4 -0
- package/dist/src/utils/catalog/yarn-manager.d.ts +6 -2
- package/dist/src/utils/catalog/yarn-manager.js +23 -32
- package/dist/src/utils/child-process.d.ts +31 -1
- package/dist/src/utils/child-process.js +103 -0
- package/dist/src/utils/chunkify.d.ts +7 -1
- package/dist/src/utils/chunkify.js +10 -3
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/formatters/index.d.ts +13 -0
- package/dist/src/utils/formatters/index.js +74 -0
- package/dist/src/utils/formatters/oxfmt.d.ts +32 -0
- package/dist/src/utils/formatters/oxfmt.js +764 -0
- package/dist/src/utils/formatters/prettier.d.ts +26 -0
- package/dist/src/utils/formatters/prettier.js +201 -0
- package/dist/src/utils/formatters/shared.d.ts +5 -0
- package/dist/src/utils/formatters/shared.js +8 -0
- package/dist/src/utils/git-utils.d.ts +48 -2
- package/dist/src/utils/git-utils.js +220 -14
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/has-nx-js-plugin.d.ts +1 -1
- package/dist/src/utils/has-nx-js-plugin.js +1 -1
- package/dist/src/utils/ignore.d.ts +170 -1
- package/dist/src/utils/ignore.js +263 -11
- package/dist/src/utils/kill-child-on-host-exit.d.ts +7 -0
- package/dist/src/utils/kill-child-on-host-exit.js +42 -0
- package/dist/src/utils/long-running-target.d.ts +10 -0
- package/dist/src/utils/long-running-target.js +19 -0
- package/dist/src/utils/min-release-age/behavior/bun.js +7 -11
- package/dist/src/utils/min-release-age/behavior/npm.js +5 -2
- package/dist/src/utils/min-release-age/packument.js +1 -1
- package/dist/src/utils/nx-console-prompt.js +3 -6
- package/dist/src/utils/nx-tmp-dir.d.ts +18 -0
- package/dist/src/utils/nx-tmp-dir.js +40 -0
- package/dist/src/utils/output.d.ts +153 -0
- package/dist/src/utils/output.js +289 -5
- package/dist/src/utils/owned-private-dir.d.ts +132 -0
- package/dist/src/utils/owned-private-dir.js +323 -0
- package/dist/src/utils/package-json.d.ts +2 -0
- package/dist/src/utils/package-json.js +11 -7
- package/dist/src/utils/package-manager-config/bunfig.d.ts +14 -0
- package/dist/src/utils/package-manager-config/bunfig.js +49 -0
- package/dist/src/utils/package-manager-config/npmrc.d.ts +23 -0
- package/dist/src/utils/package-manager-config/npmrc.js +124 -0
- package/dist/src/utils/package-manager-config/pnpm-config.d.ts +17 -0
- package/dist/src/utils/package-manager-config/pnpm-config.js +60 -0
- package/dist/src/utils/package-manager.d.ts +23 -2
- package/dist/src/utils/package-manager.js +262 -42
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/plugins/core-plugins.js +4 -0
- package/dist/src/utils/prompt-helpers.d.ts +53 -0
- package/dist/src/utils/prompt-helpers.js +111 -0
- package/dist/src/utils/provenance.js +6 -14
- package/dist/src/utils/registry-config/bun.d.ts +2 -0
- package/dist/src/utils/registry-config/bun.js +257 -0
- package/dist/src/utils/registry-config/index.d.ts +13 -0
- package/dist/src/utils/registry-config/index.js +102 -0
- package/dist/src/utils/registry-config/pnpm.d.ts +2 -0
- package/dist/src/utils/registry-config/pnpm.js +1551 -0
- package/dist/src/utils/registry-config/utils.d.ts +195 -0
- package/dist/src/utils/registry-config/utils.js +496 -0
- package/dist/src/utils/registry-config/yarn-berry.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-berry.js +612 -0
- package/dist/src/utils/registry-config/yarn-classic.d.ts +2 -0
- package/dist/src/utils/registry-config/yarn-classic.js +1001 -0
- package/dist/src/utils/safe-spawn.d.ts +24 -0
- package/dist/src/utils/safe-spawn.js +104 -0
- package/dist/src/utils/shell-quoting.d.ts +15 -0
- package/dist/src/utils/shell-quoting.js +35 -0
- package/dist/src/utils/wait-for-socket-connection.d.ts +11 -0
- package/dist/src/utils/wait-for-socket-connection.js +14 -8
- package/dist/src/utils/workspace-id.d.ts +20 -0
- package/dist/src/utils/workspace-id.js +54 -0
- package/dist/src/utils/write-formatted-json-file.d.ts +3 -2
- package/dist/src/utils/write-formatted-json-file.js +5 -4
- package/migrations.json +6 -0
- package/package.json +29 -19
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +0 -19
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -81
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -26,6 +26,7 @@ const acknowledge_build_scripts_1 = require("../../../utils/acknowledge-build-sc
|
|
|
26
26
|
const path_2 = require("../../../utils/path");
|
|
27
27
|
const versions_1 = require("../../../utils/versions");
|
|
28
28
|
const fs_1 = require("fs");
|
|
29
|
+
const format_1 = require("./format");
|
|
29
30
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
|
30
31
|
const connect_to_nx_cloud_2 = require("../../nx-cloud/connect/connect-to-nx-cloud");
|
|
31
32
|
const deduce_default_base_1 = require("./deduce-default-base");
|
|
@@ -71,6 +72,7 @@ function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scr
|
|
|
71
72
|
nxJson.defaultBase ??= defaultBase;
|
|
72
73
|
}
|
|
73
74
|
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
75
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
74
76
|
}
|
|
75
77
|
/**
|
|
76
78
|
* Locate-by-target upsert against an in-memory `targetDefaults` map. Merges
|
|
@@ -221,6 +223,7 @@ function addDepsToPackageJson(repoRoot, packageManager, additionalPackages) {
|
|
|
221
223
|
}
|
|
222
224
|
}
|
|
223
225
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
226
|
+
(0, format_1.recordInitWrite)(path);
|
|
224
227
|
// nx has a postinstall script, which pnpm 11+ refuses to install
|
|
225
228
|
// unacknowledged.
|
|
226
229
|
(0, acknowledge_build_scripts_1.acknowledgeBuildScripts)(repoRoot, packageManager, { nx: true });
|
|
@@ -351,6 +354,7 @@ function setNeverConnectToCloud(repoRoot) {
|
|
|
351
354
|
const nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath);
|
|
352
355
|
nxJson.neverConnectToCloud = true;
|
|
353
356
|
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
357
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
354
358
|
}
|
|
355
359
|
function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
|
356
360
|
const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
|
|
@@ -363,9 +367,11 @@ function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
|
|
363
367
|
}
|
|
364
368
|
});
|
|
365
369
|
(0, fileutils_1.writeJsonFile)(vsCodeExtensionsPath, vsCodeExtensionsJson);
|
|
370
|
+
(0, format_1.recordInitWrite)(vsCodeExtensionsPath);
|
|
366
371
|
}
|
|
367
372
|
else {
|
|
368
373
|
(0, fileutils_1.writeJsonFile)(vsCodeExtensionsPath, { recommendations: extensions });
|
|
374
|
+
(0, format_1.recordInitWrite)(vsCodeExtensionsPath);
|
|
369
375
|
}
|
|
370
376
|
}
|
|
371
377
|
function markRootPackageJsonAsNxProjectLegacy(repoRoot, cacheableScripts, pmc) {
|
|
@@ -386,6 +392,7 @@ function markRootPackageJsonAsNxProjectLegacy(repoRoot, cacheableScripts, pmc) {
|
|
|
386
392
|
}
|
|
387
393
|
}
|
|
388
394
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
|
395
|
+
(0, format_1.recordInitWrite)('package.json');
|
|
389
396
|
}
|
|
390
397
|
function markPackageJsonAsNxProject(packageJsonPath) {
|
|
391
398
|
const json = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
@@ -394,6 +401,7 @@ function markPackageJsonAsNxProject(packageJsonPath) {
|
|
|
394
401
|
}
|
|
395
402
|
json.nx = {};
|
|
396
403
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, json);
|
|
404
|
+
(0, format_1.recordInitWrite)(packageJsonPath);
|
|
397
405
|
}
|
|
398
406
|
function printFinalMessage({ learnMoreLink, appendLines, }) {
|
|
399
407
|
output_1.output.success({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initHandler = initHandler;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
|
-
const
|
|
5
|
+
const prompt_helpers_1 = require("../../utils/prompt-helpers");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const semver_1 = require("semver");
|
|
8
8
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
|
@@ -14,6 +14,7 @@ const child_process_2 = require("../../utils/child-process");
|
|
|
14
14
|
const fileutils_1 = require("../../utils/fileutils");
|
|
15
15
|
const versions_1 = require("../../utils/versions");
|
|
16
16
|
const utils_1 = require("./implementation/utils");
|
|
17
|
+
const format_1 = require("./implementation/format");
|
|
17
18
|
async function initHandler(options) {
|
|
18
19
|
// strip the 'init' command itself so we don't forward it
|
|
19
20
|
const args = process.argv.slice(3).join(' ');
|
|
@@ -23,11 +24,13 @@ async function initHandler(options) {
|
|
|
23
24
|
}
|
|
24
25
|
if (options.useDotNxInstallation === true) {
|
|
25
26
|
setupDotNxInstallation(version);
|
|
27
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
26
28
|
}
|
|
27
29
|
else if ((0, fs_1.existsSync)('package.json')) {
|
|
28
30
|
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
|
29
31
|
if ((0, fs_1.existsSync)('angular.json')) {
|
|
30
32
|
await (0, angular_1.addNxToAngularCliRepo)(options);
|
|
33
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
31
34
|
(0, utils_1.printFinalMessage)({
|
|
32
35
|
learnMoreLink: 'https://nx.dev/recipes/angular/migration/angular',
|
|
33
36
|
});
|
|
@@ -35,6 +38,7 @@ async function initHandler(options) {
|
|
|
35
38
|
}
|
|
36
39
|
else if (isNestCLI(packageJson)) {
|
|
37
40
|
await (0, add_nx_to_nest_1.addNxToNest)(options, packageJson);
|
|
41
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
38
42
|
(0, utils_1.printFinalMessage)({
|
|
39
43
|
learnMoreLink: 'https://nx.dev/recipes/adopting-nx/adding-to-monorepo',
|
|
40
44
|
});
|
|
@@ -42,37 +46,30 @@ async function initHandler(options) {
|
|
|
42
46
|
}
|
|
43
47
|
else if ((0, utils_1.isMonorepo)(packageJson)) {
|
|
44
48
|
await (0, add_nx_to_monorepo_1.addNxToMonorepo)({ ...options, legacy: true });
|
|
49
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
45
50
|
(0, utils_1.printFinalMessage)({
|
|
46
51
|
learnMoreLink: 'https://nx.dev/recipes/adopting-nx/adding-to-monorepo',
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
54
|
else {
|
|
50
55
|
await (0, add_nx_to_npm_repo_1.addNxToNpmRepo)({ ...options, legacy: true });
|
|
56
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
51
57
|
(0, utils_1.printFinalMessage)({
|
|
52
58
|
learnMoreLink: 'https://nx.dev/recipes/adopting-nx/adding-to-existing-project',
|
|
53
59
|
});
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
else {
|
|
57
|
-
const useDotNxFolder = await (0,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
name: 'In a new folder under this directory',
|
|
65
|
-
value: 'false',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
name: 'In this directory',
|
|
69
|
-
value: 'true',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
},
|
|
73
|
-
]).then((r) => r.useDotNxFolder === 'true');
|
|
63
|
+
const useDotNxFolder = (await (0, prompt_helpers_1.selectPrompt)({
|
|
64
|
+
message: 'Where should your workspace be created?',
|
|
65
|
+
choices: [
|
|
66
|
+
{ value: 'false', label: 'In a new folder under this directory' },
|
|
67
|
+
{ value: 'true', label: 'In this directory' },
|
|
68
|
+
],
|
|
69
|
+
})) === 'true';
|
|
74
70
|
if (useDotNxFolder) {
|
|
75
71
|
setupDotNxInstallation(version);
|
|
72
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
76
73
|
}
|
|
77
74
|
else {
|
|
78
75
|
(0, child_process_1.execSync)(`npx --yes create-nx-workspace@${version} ${args}`, {
|
|
@@ -5,12 +5,13 @@ exports.getPluginReason = getPluginReason;
|
|
|
5
5
|
exports.detectPlugins = detectPlugins;
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
const
|
|
8
|
+
const prompt_helpers_1 = require("../../utils/prompt-helpers");
|
|
9
9
|
const semver_1 = require("semver");
|
|
10
10
|
const nx_json_1 = require("../../config/nx-json");
|
|
11
11
|
const fileutils_1 = require("../../utils/fileutils");
|
|
12
12
|
const get_package_name_from_import_path_1 = require("../../utils/get-package-name-from-import-path");
|
|
13
13
|
const output_1 = require("../../utils/output");
|
|
14
|
+
const package_json_1 = require("../../utils/package-json");
|
|
14
15
|
const package_manager_1 = require("../../utils/package-manager");
|
|
15
16
|
const versions_1 = require("../../utils/versions");
|
|
16
17
|
const workspace_context_1 = require("../../utils/workspace-context");
|
|
@@ -19,6 +20,7 @@ const configure_plugins_1 = require("./configure-plugins");
|
|
|
19
20
|
const ai_agent_prompts_1 = require("./ai-agent-prompts");
|
|
20
21
|
const set_up_ai_agents_1 = require("../../ai/set-up-ai-agents/set-up-ai-agents");
|
|
21
22
|
const tree_1 = require("../../generators/tree");
|
|
23
|
+
const format_1 = require("./implementation/format");
|
|
22
24
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
|
23
25
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
|
24
26
|
const add_nx_to_turborepo_1 = require("./implementation/add-nx-to-turborepo");
|
|
@@ -26,14 +28,12 @@ const angular_1 = require("./implementation/angular");
|
|
|
26
28
|
const add_nx_scripts_1 = require("./implementation/dot-nx/add-nx-scripts");
|
|
27
29
|
const utils_1 = require("./implementation/utils");
|
|
28
30
|
const provenance_1 = require("../../utils/provenance");
|
|
29
|
-
const devkit_internals_1 = require("../../devkit-internals");
|
|
30
31
|
const handle_import_1 = require("../../utils/handle-import");
|
|
31
32
|
const native_1 = require("../../native");
|
|
32
33
|
const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
|
|
33
34
|
const ab_testing_1 = require("../../utils/ab-testing");
|
|
34
35
|
const analytics_prompt_1 = require("../../utils/analytics-prompt");
|
|
35
36
|
const is_ci_1 = require("../../utils/is-ci");
|
|
36
|
-
const package_manager_2 = require("../../utils/package-manager");
|
|
37
37
|
const ai_output_1 = require("./utils/ai-output");
|
|
38
38
|
async function initHandler(options, inner = false) {
|
|
39
39
|
// Use environment variable to force local execution
|
|
@@ -43,7 +43,7 @@ async function initHandler(options, inner = false) {
|
|
|
43
43
|
let cleanup;
|
|
44
44
|
try {
|
|
45
45
|
await (0, provenance_1.ensurePackageHasProvenance)('nx', 'latest');
|
|
46
|
-
const packageInstallResults = (0,
|
|
46
|
+
const packageInstallResults = (0, package_json_1.installPackageToTmp)('nx', 'latest', (0, package_manager_1.detectPackageManager)(process.cwd()));
|
|
47
47
|
cleanup = packageInstallResults.cleanup;
|
|
48
48
|
let modulePath = require.resolve('nx/src/command-line/init/init-v2.js', {
|
|
49
49
|
paths: [packageInstallResults.tempDir],
|
|
@@ -95,7 +95,7 @@ async function initHandlerImpl(options) {
|
|
|
95
95
|
const baseMeta = {
|
|
96
96
|
nodeVersion: process.versions.node,
|
|
97
97
|
os: process.platform,
|
|
98
|
-
packageManager: (0,
|
|
98
|
+
packageManager: (0, package_manager_1.detectPackageManager)(),
|
|
99
99
|
aiAgent: (0, native_1.isAiAgent)(),
|
|
100
100
|
isCI: (0, is_ci_1.isCI)(),
|
|
101
101
|
};
|
|
@@ -149,6 +149,7 @@ async function runInit(options, baseMeta) {
|
|
|
149
149
|
...options,
|
|
150
150
|
integrated: !!options.integrated,
|
|
151
151
|
});
|
|
152
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
152
153
|
(0, utils_1.printFinalMessage)({
|
|
153
154
|
learnMoreLink: 'https://nx.dev/technologies/angular/migration/angular',
|
|
154
155
|
});
|
|
@@ -162,21 +163,17 @@ async function runInit(options, baseMeta) {
|
|
|
162
163
|
options.interactive &&
|
|
163
164
|
!aiMode &&
|
|
164
165
|
process.stdin.isTTY) {
|
|
165
|
-
const setupMode = await (0,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
]).then((r) => r.setupMode);
|
|
166
|
+
const setupMode = await (0, prompt_helpers_1.selectPrompt)({
|
|
167
|
+
message: 'How would you like to set up Nx in this directory?',
|
|
168
|
+
choices: [
|
|
169
|
+
{
|
|
170
|
+
value: '.nx installation (recommended for non-JavaScript projects)',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
value: 'package.json installation (recommended for JavaScript/TypeScript projects)',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
});
|
|
180
177
|
if (setupMode.startsWith('package.json')) {
|
|
181
178
|
// Create a minimal package.json so the JS/TS workflow takes over
|
|
182
179
|
const workspaceName = (0, path_1.basename)(process.cwd());
|
|
@@ -185,6 +182,7 @@ async function runInit(options, baseMeta) {
|
|
|
185
182
|
version: '0.0.0',
|
|
186
183
|
private: true,
|
|
187
184
|
});
|
|
185
|
+
(0, format_1.recordInitWrite)('package.json');
|
|
188
186
|
}
|
|
189
187
|
else {
|
|
190
188
|
options.useDotNxInstallation = true;
|
|
@@ -199,14 +197,10 @@ async function runInit(options, baseMeta) {
|
|
|
199
197
|
// AI mode defaults to minimum setup, humans can choose
|
|
200
198
|
let guided = !aiMode; // Default to minimum (false) for AI, guided (true) for humans
|
|
201
199
|
if (options.interactive && !(_isTurborepo || _isNonJs)) {
|
|
202
|
-
const setupType = await (0,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
message: 'Would you like a minimum or guided setup?',
|
|
207
|
-
choices: [{ name: 'Minimum' }, { name: 'Guided' }],
|
|
208
|
-
},
|
|
209
|
-
]).then((r) => r.setupPreference);
|
|
200
|
+
const setupType = await (0, prompt_helpers_1.selectPrompt)({
|
|
201
|
+
message: 'Would you like a minimum or guided setup?',
|
|
202
|
+
choices: [{ value: 'Minimum' }, { value: 'Guided' }],
|
|
203
|
+
});
|
|
210
204
|
guided = setupType === 'Guided';
|
|
211
205
|
}
|
|
212
206
|
/**
|
|
@@ -222,6 +216,7 @@ async function runInit(options, baseMeta) {
|
|
|
222
216
|
await (0, add_nx_to_turborepo_1.addNxToTurborepo)({
|
|
223
217
|
interactive: options.interactive,
|
|
224
218
|
});
|
|
219
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
225
220
|
(0, utils_1.printFinalMessage)({
|
|
226
221
|
learnMoreLink: 'https://nx.dev/recipes/adopting-nx/from-turborepo',
|
|
227
222
|
});
|
|
@@ -296,6 +291,9 @@ async function runInit(options, baseMeta) {
|
|
|
296
291
|
reason: getPluginReason(name),
|
|
297
292
|
}));
|
|
298
293
|
(0, ai_output_1.logProgress)('detecting', `Detected ${detectedPluginNames.length} plugin(s): ${detectedPluginNames.join(', ')}`);
|
|
294
|
+
// This path exits without reaching the drain below, and `nx.json` has
|
|
295
|
+
// already been written by now.
|
|
296
|
+
await (0, format_1.formatInitWrites)(repoRoot);
|
|
299
297
|
(0, ai_output_1.writeAiOutput)((0, ai_output_1.buildNeedsInputResult)(detectedPlugins));
|
|
300
298
|
process.exit(0);
|
|
301
299
|
}
|
|
@@ -368,12 +366,16 @@ async function runInit(options, baseMeta) {
|
|
|
368
366
|
analyticsPrompt,
|
|
369
367
|
nodeVersion: process.versions.node,
|
|
370
368
|
os: process.platform,
|
|
371
|
-
packageManager: (0,
|
|
369
|
+
packageManager: (0, package_manager_1.detectPackageManager)(),
|
|
372
370
|
aiAgent: aiMode,
|
|
373
371
|
isCI: (0, is_ci_1.isCI)(),
|
|
374
372
|
pluginsInstalled: pluginsToInstall.join(','),
|
|
375
373
|
},
|
|
376
374
|
});
|
|
375
|
+
// Before the AI record, not after: the formatters write to stdout
|
|
376
|
+
// (`--list-different`, oxfmt's summary), which would otherwise land after the
|
|
377
|
+
// NDJSON result and corrupt the tail an agent parses.
|
|
378
|
+
await (0, format_1.formatInitWrites)(repoRoot);
|
|
377
379
|
// Output success result for AI agents
|
|
378
380
|
if (aiMode) {
|
|
379
381
|
(0, ai_output_1.writeAiOutput)((0, ai_output_1.buildSuccessResult)({
|
|
@@ -401,6 +403,7 @@ async function runInit(options, baseMeta) {
|
|
|
401
403
|
function getPluginReason(plugin) {
|
|
402
404
|
const reasonMap = {
|
|
403
405
|
'@nx/eslint': 'eslint detected in dependencies',
|
|
406
|
+
'@nx/oxlint': 'oxlint detected in dependencies',
|
|
404
407
|
'@nx/storybook': 'storybook detected in dependencies',
|
|
405
408
|
'@nx/vite': 'vite detected in dependencies',
|
|
406
409
|
'@nx/vitest': 'vitest detected in dependencies',
|
|
@@ -448,6 +451,7 @@ function parsePluginsFlag(value) {
|
|
|
448
451
|
const npmPackageToPluginMap = {
|
|
449
452
|
// Generic JS tools
|
|
450
453
|
eslint: '@nx/eslint',
|
|
454
|
+
oxlint: '@nx/oxlint',
|
|
451
455
|
storybook: '@nx/storybook',
|
|
452
456
|
// Bundlers
|
|
453
457
|
vite: '@nx/vite',
|
|
@@ -574,39 +578,18 @@ async function detectPlugins(nxJson, packageJson, interactive, includeAngularCli
|
|
|
574
578
|
`Add these Nx plugins to integrate with the tools used in your workspace.`,
|
|
575
579
|
],
|
|
576
580
|
});
|
|
577
|
-
const pluginsToInstall = await (0,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
|
|
582
|
-
choices: plugins.map((p) => ({ name: p, value: p })),
|
|
583
|
-
/**
|
|
584
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
585
|
-
*/
|
|
586
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
587
|
-
},
|
|
588
|
-
]).then((r) => r.plugins);
|
|
581
|
+
const pluginsToInstall = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
582
|
+
message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
|
|
583
|
+
choices: plugins,
|
|
584
|
+
});
|
|
589
585
|
if (pluginsToInstall?.length === 0)
|
|
590
586
|
return {
|
|
591
587
|
plugins: [],
|
|
592
588
|
updatePackageScripts: false,
|
|
593
589
|
};
|
|
594
590
|
const updatePackageScripts = (0, fs_1.existsSync)('package.json') &&
|
|
595
|
-
(await (0,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
type: 'autocomplete',
|
|
599
|
-
message: `Do you want to start using Nx in your package.json scripts?`,
|
|
600
|
-
choices: [
|
|
601
|
-
{
|
|
602
|
-
name: 'Yes',
|
|
603
|
-
},
|
|
604
|
-
{
|
|
605
|
-
name: 'No',
|
|
606
|
-
},
|
|
607
|
-
],
|
|
608
|
-
initial: 0,
|
|
609
|
-
},
|
|
610
|
-
]).then((r) => r.updatePackageScripts === 'Yes'));
|
|
591
|
+
(await (0, prompt_helpers_1.confirmationPrompt)({
|
|
592
|
+
message: `Do you want to start using Nx in your package.json scripts?`,
|
|
593
|
+
}));
|
|
611
594
|
return { plugins: pluginsToInstall, updatePackageScripts };
|
|
612
595
|
}
|
|
@@ -4,7 +4,7 @@ exports.AGENT_DEFINITIONS = exports.opencodeDefinition = exports.codexDefinition
|
|
|
4
4
|
exports.getAgentDefinition = getAgentDefinition;
|
|
5
5
|
const os_1 = require("os");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
7
|
+
const types_1 = require("./types");
|
|
8
8
|
// --- Claude Code ---------------------------------------------------------
|
|
9
9
|
function claudeCodeWellKnownPaths() {
|
|
10
10
|
if (process.platform === 'win32') {
|
|
@@ -13,21 +13,48 @@ function claudeCodeWellKnownPaths() {
|
|
|
13
13
|
}
|
|
14
14
|
return [(0, path_1.join)((0, os_1.homedir)(), '.claude', 'local', 'claude')];
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The run directory names Nx will interpolate into a permission rule. A rule
|
|
18
|
+
* is a gitignore pattern, which reads `*?[]\` as syntax, and `--allowedTools`
|
|
19
|
+
* splits its value on commas and spaces, so a name carrying any of those
|
|
20
|
+
* would change what the rule authorizes rather than what it names. Run
|
|
21
|
+
* directory names derive from a migration's own version string, which nothing
|
|
22
|
+
* upstream constrains to this alphabet. The leading character rejects `.`
|
|
23
|
+
* and `..`.
|
|
24
|
+
*/
|
|
25
|
+
const RULE_SAFE_RUN_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
26
|
+
/**
|
|
27
|
+
* Pre-authorizes the handoff write. Claude Code's default permission mode
|
|
28
|
+
* asks before a file write it has no allow rule for, so without this every
|
|
29
|
+
* step ends on an approval prompt for Nx's own handoff scratch.
|
|
30
|
+
*
|
|
31
|
+
* The rule reaches one run's handoffs and nothing else. Its own run
|
|
32
|
+
* directory also holds state Nx wrote and reads back, and the sibling
|
|
33
|
+
* directories belong to other runs, including an orchestrated run whose
|
|
34
|
+
* handoffs decide how its steps settle. `Edit` is the only tool name file
|
|
35
|
+
* rules are matched against, and it covers creating the file as well as
|
|
36
|
+
* correcting one already written. Prefix-less patterns resolve against the
|
|
37
|
+
* session cwd, pinned to the workspace root below.
|
|
38
|
+
*
|
|
39
|
+
* Returns null for a name it cannot express, which costs the approval prompt
|
|
40
|
+
* this exists to avoid. That beats widening the rule, and nothing narrower is
|
|
41
|
+
* available: Claude Code has no escape for a literal path.
|
|
42
|
+
*/
|
|
43
|
+
function claudeCodeHandoffAllowedTools(runDirName) {
|
|
44
|
+
if (!RULE_SAFE_RUN_DIR_NAME.test(runDirName)) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return `Edit(${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runDirName}/${types_1.HANDOFFS_DIR_NAME}/**)`;
|
|
48
|
+
}
|
|
22
49
|
function claudeCodeBuildInteractive(ctx) {
|
|
50
|
+
const allowedTools = claudeCodeHandoffAllowedTools(ctx.runDirName);
|
|
23
51
|
return {
|
|
24
52
|
// `--allowedTools` is variadic (space/comma separated): a positional
|
|
25
53
|
// placed right after its value gets swallowed as another rule. The rules
|
|
26
54
|
// must stay in one comma-joined element with a non-variadic flag
|
|
27
55
|
// (`--system-prompt`) between them and the user prompt.
|
|
28
56
|
args: [
|
|
29
|
-
'--allowedTools',
|
|
30
|
-
CLAUDE_CODE_HANDOFF_ALLOWED_TOOLS,
|
|
57
|
+
...(allowedTools ? ['--allowedTools', allowedTools] : []),
|
|
31
58
|
'--system-prompt',
|
|
32
59
|
ctx.systemContext,
|
|
33
60
|
ctx.userPrompt,
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
export declare function isHandoffGitignoreMigration(m: {
|
|
2
|
-
package: string;
|
|
3
|
-
name: string;
|
|
4
|
-
}): boolean;
|
|
5
1
|
/**
|
|
6
|
-
*
|
|
7
|
-
* `.nx/migrate-runs/<run-id
|
|
2
|
+
* Both the agentic runner and the orchestrator write per-run scratch under
|
|
3
|
+
* `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus the durable
|
|
4
|
+
* run state and its plan snapshots for the orchestrator. The v23 migration
|
|
8
5
|
* `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
|
|
9
|
-
* `.gitignore`;
|
|
10
|
-
*
|
|
11
|
-
* scratch into the user-visible diff.
|
|
6
|
+
* `.gitignore`; in its declared slot (typically late) earlier per-migration
|
|
7
|
+
* commits would absorb the scratch into the user-visible diff.
|
|
12
8
|
*
|
|
13
9
|
* Two paths cover the leak, with no overlap:
|
|
14
10
|
*
|
|
15
|
-
* 1. HOIST
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
11
|
+
* 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
|
|
12
|
+
* v23 migration to position 0 when it is in the queue, so it runs first
|
|
13
|
+
* through the normal runner with its own log line and commit. A
|
|
14
|
+
* single-migration worker run needs no hoisting: the requested migration
|
|
15
|
+
* is the entire queue.
|
|
19
16
|
*
|
|
20
|
-
* 2. INLINE FALLBACK
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
17
|
+
* 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
|
|
18
|
+
* AND the highest target version is < v23 (intra-pre-v23 `--agentic`
|
|
19
|
+
* run) it will never run, so apply its body inline against an `FsTree`
|
|
20
|
+
* and commit it as a standalone preflight commit (or leave it in the
|
|
21
|
+
* working tree under `--no-create-commits`).
|
|
25
22
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
23
|
+
* Not in the queue AND target >= v23 means the user is already past v23. They
|
|
24
|
+
* had the entry historically; if it is gone, that is a conscious removal we
|
|
25
|
+
* respect.
|
|
29
26
|
*/
|
|
30
|
-
export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, }: {
|
|
27
|
+
export declare function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned, commitStandalone, }: {
|
|
31
28
|
migrations: ReadonlyArray<{
|
|
32
29
|
package: string;
|
|
33
30
|
name: string;
|
|
@@ -43,4 +40,22 @@ export declare function applyAgenticHandoffGitignoreFallback({ migrations, insta
|
|
|
43
40
|
effectiveCreateCommits: boolean;
|
|
44
41
|
commitPrefix: string;
|
|
45
42
|
root: string;
|
|
43
|
+
/**
|
|
44
|
+
* Apply the entry even when the hoisted migration is in the plan. The
|
|
45
|
+
* classic loop can defer to that migration because its run scratch appears
|
|
46
|
+
* only after migration 1 has run; the orchestrator creates its run dir at
|
|
47
|
+
* init, before any migration, so it needs the entry immediately. A planned
|
|
48
|
+
* migration also means the missing entry is not a conscious removal, so the
|
|
49
|
+
* v23 cutoff does not apply.
|
|
50
|
+
*/
|
|
51
|
+
applyWhenPlanned?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Commit the applied entry as its own preflight commit (the default). The
|
|
54
|
+
* orchestrator suppresses this: it applies the fallback before its init
|
|
55
|
+
* checkpoint so the checkpoint's `git add -A` cannot sweep in older
|
|
56
|
+
* scratch, and in that ordering a standalone commit here would carry the
|
|
57
|
+
* user's pre-existing changes along with the entry. The checkpoint that
|
|
58
|
+
* follows captures both instead.
|
|
59
|
+
*/
|
|
60
|
+
commitStandalone?: boolean;
|
|
46
61
|
}): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isHandoffGitignoreMigration = isHandoffGitignoreMigration;
|
|
4
3
|
exports.applyAgenticHandoffGitignoreFallback = applyAgenticHandoffGitignoreFallback;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const semver_1 = require("semver");
|
|
@@ -9,50 +8,42 @@ const add_migrate_runs_to_git_ignore_1 = tslib_1.__importDefault(require("../../
|
|
|
9
8
|
const tree_1 = require("../../../generators/tree");
|
|
10
9
|
const git_utils_1 = require("../../../utils/git-utils");
|
|
11
10
|
const logger_1 = require("../../../utils/logger");
|
|
11
|
+
const types_1 = require("./types");
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
* `.
|
|
15
|
-
*
|
|
16
|
-
* `.nx/migrate-runs/<run-id>/...` scratch out of per-migration commits. If
|
|
17
|
-
* the migration is ever renamed, this entry must move with it.
|
|
18
|
-
*/
|
|
19
|
-
const HANDOFF_GITIGNORE_MIGRATION_PACKAGE = 'nx';
|
|
20
|
-
const HANDOFF_GITIGNORE_MIGRATION_NAME = '23-0-0-add-migrate-runs-to-git-ignore';
|
|
21
|
-
function isHandoffGitignoreMigration(m) {
|
|
22
|
-
return (m.package === HANDOFF_GITIGNORE_MIGRATION_PACKAGE &&
|
|
23
|
-
m.name === HANDOFF_GITIGNORE_MIGRATION_NAME);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Under `--agentic`, the runner writes per-run scratch under
|
|
27
|
-
* `.nx/migrate-runs/<run-id>/`. The v23 migration
|
|
13
|
+
* Both the agentic runner and the orchestrator write per-run scratch under
|
|
14
|
+
* `.nx/migrate-runs/<run-id>/`: handoff files in both cases, plus the durable
|
|
15
|
+
* run state and its plan snapshots for the orchestrator. The v23 migration
|
|
28
16
|
* `23-0-0-add-migrate-runs-to-git-ignore` adds `.nx/migrate-runs` to
|
|
29
|
-
* `.gitignore`;
|
|
30
|
-
*
|
|
31
|
-
* scratch into the user-visible diff.
|
|
17
|
+
* `.gitignore`; in its declared slot (typically late) earlier per-migration
|
|
18
|
+
* commits would absorb the scratch into the user-visible diff.
|
|
32
19
|
*
|
|
33
20
|
* Two paths cover the leak, with no overlap:
|
|
34
21
|
*
|
|
35
|
-
* 1. HOIST
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
22
|
+
* 1. HOIST: `sortMigrations`, which `executeMigrations` applies, sorts the
|
|
23
|
+
* v23 migration to position 0 when it is in the queue, so it runs first
|
|
24
|
+
* through the normal runner with its own log line and commit. A
|
|
25
|
+
* single-migration worker run needs no hoisting: the requested migration
|
|
26
|
+
* is the entire queue.
|
|
39
27
|
*
|
|
40
|
-
* 2. INLINE FALLBACK
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
28
|
+
* 2. INLINE FALLBACK, this function. When the migration is NOT in the queue
|
|
29
|
+
* AND the highest target version is < v23 (intra-pre-v23 `--agentic`
|
|
30
|
+
* run) it will never run, so apply its body inline against an `FsTree`
|
|
31
|
+
* and commit it as a standalone preflight commit (or leave it in the
|
|
32
|
+
* working tree under `--no-create-commits`).
|
|
45
33
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
34
|
+
* Not in the queue AND target >= v23 means the user is already past v23. They
|
|
35
|
+
* had the entry historically; if it is gone, that is a conscious removal we
|
|
36
|
+
* respect.
|
|
49
37
|
*/
|
|
50
|
-
async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, }) {
|
|
51
|
-
if (migrations.some(isHandoffGitignoreMigration)) {
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVersion, effectiveCreateCommits, commitPrefix, root, applyWhenPlanned = false, commitStandalone = true, }) {
|
|
39
|
+
if (migrations.some(types_1.isHandoffGitignoreMigration)) {
|
|
40
|
+
if (!applyWhenPlanned) {
|
|
41
|
+
// The queue runs it itself: hoisted to the front by the sort comparator
|
|
42
|
+
// in a full run, or as the single requested migration in a worker run.
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
54
45
|
}
|
|
55
|
-
if ((0, semver_1.major)(installedNxVersion) >= 23) {
|
|
46
|
+
else if ((0, semver_1.major)(installedNxVersion) >= 23) {
|
|
56
47
|
// User is past v23. Respect their `.gitignore` state — if the entry
|
|
57
48
|
// is missing, that's a conscious removal.
|
|
58
49
|
return;
|
|
@@ -66,13 +57,13 @@ async function applyAgenticHandoffGitignoreFallback({ migrations, installedNxVer
|
|
|
66
57
|
return;
|
|
67
58
|
}
|
|
68
59
|
(0, tree_1.flushChanges)(root, changes);
|
|
69
|
-
logger_1.logger.info(pc.dim(`- Added .
|
|
70
|
-
if (!effectiveCreateCommits)
|
|
60
|
+
logger_1.logger.info(pc.dim(`- Added ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore so this run's scratch state is ignored.`));
|
|
61
|
+
if (!effectiveCreateCommits || !commitStandalone)
|
|
71
62
|
return;
|
|
72
63
|
if (!(0, git_utils_1.hasUncommittedChanges)(root))
|
|
73
64
|
return;
|
|
74
65
|
try {
|
|
75
|
-
const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add .
|
|
66
|
+
const sha = (0, git_utils_1.tryCommitChanges)(`${commitPrefix}add ${types_1.MIGRATE_RUNS_RELATIVE_DIR} to .gitignore`, root, [types_1.MIGRATE_RUNS_RELATIVE_DIR]);
|
|
76
67
|
if (sha) {
|
|
77
68
|
logger_1.logger.info(pc.dim(` Commit: ${sha}`));
|
|
78
69
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { HandoffFile } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Workspace-relative directory holding all migrate-run scratch (handoff
|
|
4
|
-
* files). Shared with the agent permission rules in `definitions.ts` so the
|
|
5
|
-
* pre-authorized write scope can't drift from the actual layout.
|
|
6
|
-
*/
|
|
7
|
-
export declare const MIGRATE_RUNS_RELATIVE_DIR = ".nx/migrate-runs";
|
|
8
2
|
/** Returns the run directory for a given workspace + run id (target version). */
|
|
9
3
|
export declare function runDirPath(workspaceRoot: string, runId: string): string;
|
|
4
|
+
/** The version-derived run id: the highest target version in the plan. */
|
|
5
|
+
export declare function resolveAgenticRunId(migrations: ReadonlyArray<{
|
|
6
|
+
version: string;
|
|
7
|
+
}>): string;
|
|
10
8
|
/**
|
|
11
9
|
* `mkdir -p` with a contextual error wrapper. Without this, the raw
|
|
12
10
|
* ENOSPC/EACCES/EROFS surfaces with no indication of which directory the
|
|
@@ -22,7 +20,9 @@ export declare function mkdirSafely(dir: string, purpose: string): void;
|
|
|
22
20
|
*/
|
|
23
21
|
export declare function initRunDir(workspaceRoot: string, runId: string): string;
|
|
24
22
|
/**
|
|
25
|
-
* Absolute path of the handoff file for a migration step within a run
|
|
23
|
+
* Absolute path of the handoff file for a migration step within a run, under
|
|
24
|
+
* the run directory's `handoffs/` subtree: the pre-authorized write scope
|
|
25
|
+
* stops there, so a handoff placed anywhere else costs an approval prompt.
|
|
26
26
|
* The package's scope (if any) becomes a real subdirectory so the package name
|
|
27
27
|
* stays readable; two packages can ship a migration with the same name without
|
|
28
28
|
* colliding because they land in different package subdirectories. Each
|