@depup/nx 23.1.2-depup.1 → 23.2.0-depup.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 +7 -6
- package/changes.json +12 -8
- package/dist/bin/init-local.js +3 -5
- package/dist/bin/nx.js +1 -0
- package/dist/src/adapter/ngcli-adapter.js +60 -1
- package/dist/src/ai/constants.d.ts +15 -0
- package/dist/src/ai/constants.js +17 -1
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +57 -9
- package/dist/src/ai/utils.d.ts +13 -0
- package/dist/src/ai/utils.js +29 -0
- package/dist/src/analytics/analytics.js +2 -4
- package/dist/src/command-line/completion/command-object.js +7 -12
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +42 -31
- 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/import/import.js +29 -38
- 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/legacy-angular-versions.js +2 -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 +5 -0
- 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 -8
- package/dist/src/command-line/init/init-v1.js +15 -18
- package/dist/src/command-line/init/init-v2.js +77 -66
- 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 +24 -55
- package/dist/src/command-line/migrate/migrate.js +553 -226
- 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 +16 -20
- 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 +6 -17
- 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/release-graph.d.ts +1 -0
- package/dist/src/command-line/release/utils/release-graph.js +10 -2
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +10 -22
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +13 -22
- package/dist/src/command-line/release/utils/resolve-semver-specifier.js +19 -41
- package/dist/src/command-line/release/version/resolve-current-version.js +7 -10
- package/dist/src/command-line/release/version.js +2 -2
- package/dist/src/command-line/reset/reset.js +17 -15
- package/dist/src/command-line/yargs-utils/shared-options.d.ts +1 -1
- 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/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +2 -7
- package/dist/src/daemon/client/client.js +113 -28
- package/dist/src/daemon/client/daemon-environment.d.ts +35 -0
- package/dist/src/daemon/client/daemon-environment.js +106 -6
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
- package/dist/src/daemon/client/daemon-socket-messenger.js +8 -3
- package/dist/src/daemon/is-v8-serializer-enabled.d.ts +2 -2
- package/dist/src/daemon/is-v8-serializer-enabled.js +2 -2
- package/dist/src/daemon/message-types/daemon-message.d.ts +2 -1
- package/dist/src/daemon/message-types/daemon-message.js +25 -2
- package/dist/src/daemon/sandbox-socket-hint.d.ts +27 -0
- package/dist/src/daemon/sandbox-socket-hint.js +136 -0
- package/dist/src/daemon/server/client-socket-context.d.ts +1 -1
- package/dist/src/daemon/server/client-socket-context.js +2 -3
- package/dist/src/daemon/server/dotenv-graph-changes.d.ts +97 -0
- package/dist/src/daemon/server/dotenv-graph-changes.js +284 -0
- package/dist/src/daemon/server/handle-client-env.d.ts +8 -0
- package/dist/src/daemon/server/handle-client-env.js +92 -0
- package/dist/src/daemon/server/handle-outputs-changes.d.ts +10 -0
- package/dist/src/daemon/server/handle-outputs-changes.js +86 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +21 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +159 -6
- package/dist/src/daemon/server/server.js +36 -72
- package/dist/src/daemon/server/shutdown-utils.d.ts +1 -1
- package/dist/src/daemon/server/shutdown-utils.js +2 -2
- package/dist/src/daemon/socket-utils.d.ts +26 -7
- package/dist/src/daemon/socket-utils.js +45 -31
- package/dist/src/daemon/tmp-dir.d.ts +10 -0
- package/dist/src/daemon/tmp-dir.js +21 -37
- package/dist/src/devkit-internals.d.ts +20 -9
- package/dist/src/devkit-internals.js +49 -6
- package/dist/src/executors/run-commands/running-tasks.js +46 -29
- package/dist/src/generators/internal-utils/{format-changed-files-with-prettier-if-available.d.ts → format-changed-files.d.ts} +6 -6
- 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/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.js +2 -2
- package/dist/src/native/index.d.ts +7 -3
- 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/url-shorten.d.ts +1 -4
- package/dist/src/nx-cloud/utilities/url-shorten.js +9 -8
- 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/npm-parser.js +10 -3
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +356 -62
- 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 +78 -4
- 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 +6 -5
- package/dist/src/plugins/js/utils/register.d.ts +11 -0
- package/dist/src/plugins/js/utils/register.js +40 -6
- package/dist/src/project-graph/plugins/get-plugins.d.ts +27 -1
- package/dist/src/project-graph/plugins/get-plugins.js +110 -5
- package/dist/src/project-graph/plugins/isolation/enabled.js +1 -4
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +16 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +69 -11
- package/dist/src/project-graph/plugins/isolation/messaging.js +1 -3
- package/dist/src/project-graph/plugins/isolation/plugin-worker.js +23 -2
- package/dist/src/project-graph/project-graph.js +27 -2
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +7 -0
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +14 -6
- package/dist/src/project-graph/utils/project-configuration/target-defaults.js +47 -21
- 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-ipc.js +14 -13
- 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 +32 -39
- 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 +25 -0
- package/dist/src/tasks-runner/task-env.js +39 -0
- package/dist/src/tasks-runner/task-orchestrator.d.ts +68 -0
- package/dist/src/tasks-runner/task-orchestrator.js +159 -8
- 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.js +4 -7
- package/dist/src/utils/cache-directory.d.ts +62 -3
- package/dist/src/utils/cache-directory.js +276 -25
- 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/consume-messages-from-socket.d.ts +42 -7
- package/dist/src/utils/consume-messages-from-socket.js +273 -38
- package/dist/src/utils/db-connection.js +8 -16
- package/dist/src/utils/exit-codes.d.ts +9 -0
- package/dist/src/utils/exit-codes.js +19 -0
- 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 +38 -2
- package/dist/src/utils/git-utils.js +422 -19
- 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 +47 -5
- package/dist/src/utils/ignore.js +93 -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/nx-console-prompt.js +3 -6
- package/dist/src/utils/nx-tmp-dir.d.ts +5 -0
- package/dist/src/utils/nx-tmp-dir.js +7 -2
- 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 +13 -0
- package/dist/src/utils/owned-private-dir.js +39 -0
- package/dist/src/utils/package-json.d.ts +2 -0
- package/dist/src/utils/package-manager.js +17 -7
- package/dist/src/utils/params.d.ts +7 -1
- package/dist/src/utils/params.js +64 -6
- package/dist/src/utils/permission-errors.d.ts +11 -0
- package/dist/src/utils/permission-errors.js +17 -0
- 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/socket-refused-exit-code.d.ts +15 -0
- package/dist/src/utils/socket-refused-exit-code.js +18 -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/package.json +33 -24
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +0 -88
- package/dist/src/utils/is-using-prettier.d.ts +0 -3
- package/dist/src/utils/is-using-prettier.js +0 -62
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordInitWrite = recordInitWrite;
|
|
4
|
+
exports.formatInitWrites = formatInitWrites;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
8
|
+
const chunkify_1 = require("../../../utils/chunkify");
|
|
9
|
+
const formatters_1 = require("../../../utils/formatters");
|
|
10
|
+
const oxfmt_1 = require("../../../utils/formatters/oxfmt");
|
|
11
|
+
const prettier_1 = require("../../../utils/formatters/prettier");
|
|
12
|
+
const output_1 = require("../../../utils/output");
|
|
13
|
+
/**
|
|
14
|
+
* Paths `nx init` has created or modified.
|
|
15
|
+
*
|
|
16
|
+
* Module state because init's flows write from many call sites across
|
|
17
|
+
* several files, a number behind early returns; the alternative is threading
|
|
18
|
+
* a collector through every one.
|
|
19
|
+
*/
|
|
20
|
+
const writtenFiles = new Set();
|
|
21
|
+
/**
|
|
22
|
+
* Records a file for `formatInitWrites`. Only for files a formatter handles -
|
|
23
|
+
* `.gitignore` and the vendored `.nx` scripts are left out rather than
|
|
24
|
+
* filtered later.
|
|
25
|
+
*
|
|
26
|
+
* Two recording helpers are shared with `nx import`, which drains before each
|
|
27
|
+
* commit amend; draining after one would leave the formatting uncommitted.
|
|
28
|
+
* The drain is a no-op when empty.
|
|
29
|
+
*/
|
|
30
|
+
function recordInitWrite(filePath) {
|
|
31
|
+
writtenFiles.add(filePath);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Formats what init just wrote and nothing else: an existing repo's other
|
|
35
|
+
* files are not init's to reformat.
|
|
36
|
+
*
|
|
37
|
+
* Never fatal - the repo is already initialised, so a formatter that cannot
|
|
38
|
+
* run costs a `nx format` the user can run themselves, not their setup.
|
|
39
|
+
*/
|
|
40
|
+
async function formatInitWrites(repoRoot,
|
|
41
|
+
// `nx import` drains this set too, and a user who never ran `nx init` should
|
|
42
|
+
// not be told `nx init` failed.
|
|
43
|
+
command = 'nx init') {
|
|
44
|
+
const recorded = [...writtenFiles];
|
|
45
|
+
// Cleared unconditionally: a second init in the same process must not
|
|
46
|
+
// reformat the first one's files.
|
|
47
|
+
writtenFiles.clear();
|
|
48
|
+
if (process.env.NX_SKIP_FORMAT === 'true' || recorded.length === 0) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Repo-relative with `repoRoot` as cwd, so paths stay short and resolve
|
|
52
|
+
// against the repo. That also pins oxfmt's `.editorconfig` lookup, which it
|
|
53
|
+
// does once from the working directory; it does not pin config discovery.
|
|
54
|
+
//
|
|
55
|
+
// De-duplicated *after* normalising: the same file is routinely recorded
|
|
56
|
+
// both as `'nx.json'` and as `join(repoRoot, 'nx.json')`, which are two Set
|
|
57
|
+
// keys for one file.
|
|
58
|
+
const files = [
|
|
59
|
+
...new Set(recorded.map((file) => path
|
|
60
|
+
.relative(repoRoot, path.resolve(repoRoot, file))
|
|
61
|
+
.split(path.sep)
|
|
62
|
+
.join('/'))),
|
|
63
|
+
].filter((file) => file &&
|
|
64
|
+
!file.startsWith('../') &&
|
|
65
|
+
!path.isAbsolute(file) &&
|
|
66
|
+
(0, node_fs_1.existsSync)(path.join(repoRoot, file)));
|
|
67
|
+
if (files.length === 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// `detectFormatter` reads package.json, so it belongs inside the try - a
|
|
71
|
+
// workspace whose package.json cannot be parsed must not fail an init that
|
|
72
|
+
// already finished.
|
|
73
|
+
//
|
|
74
|
+
// Chunked as `nx format` chunks: the Angular flow records a `project.json`
|
|
75
|
+
// per project. The prettier path is sized against its quoted length; oxfmt
|
|
76
|
+
// goes through execFile and gets raw paths.
|
|
77
|
+
let formatter = null;
|
|
78
|
+
try {
|
|
79
|
+
formatter = (0, formatters_1.detectFormatter)(repoRoot);
|
|
80
|
+
if (!formatter) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (formatter === 'oxfmt') {
|
|
84
|
+
for (const chunk of (0, chunkify_1.chunkify)(files)) {
|
|
85
|
+
if (chunk.length) {
|
|
86
|
+
(0, oxfmt_1.writeWithOxfmt)(chunk, repoRoot);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// oxfmt needs no equivalent filter - it silently skips file types it
|
|
92
|
+
// does not handle and exits 0. prettier still formats the rest of the
|
|
93
|
+
// batch, but exits 2 on one unsupported file, which would end a
|
|
94
|
+
// successful init with a spurious warning and prettier's own stderr.
|
|
95
|
+
const supported = await (0, prettier_1.filterToPrettierSupportedFiles)(files);
|
|
96
|
+
for (const chunk of (0, chunkify_1.chunkify)(supported, undefined, (pattern) => (0, prettier_1.quoteForShell)(pattern).length)) {
|
|
97
|
+
if (chunk.length) {
|
|
98
|
+
(0, prettier_1.writeWithPrettier)(chunk, repoRoot);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
output_1.output.warn({
|
|
105
|
+
title: formatter
|
|
106
|
+
? `Could not format the files ${command} wrote with ${formatter}.`
|
|
107
|
+
: `Could not work out which formatter to use for the files ${command} wrote.`,
|
|
108
|
+
bodyLines: [
|
|
109
|
+
...(e?.message ? [e.message] : []),
|
|
110
|
+
'Run "nx format:write" to format them.',
|
|
111
|
+
],
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -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
|
|
@@ -194,14 +196,6 @@ function createNxJsonFromTurboJson(turboJson) {
|
|
|
194
196
|
nxJson.targetDefaults = targetDefaults;
|
|
195
197
|
}
|
|
196
198
|
}
|
|
197
|
-
/**
|
|
198
|
-
* The fact that cacheDir was in use suggests the user had a reason for deviating from the default.
|
|
199
|
-
* We can't know what that reason was, nor if it would still be applicable in Nx, but we can at least
|
|
200
|
-
* improve discoverability of the relevant Nx option by explicitly including it with its default value.
|
|
201
|
-
*/
|
|
202
|
-
if (turboJson.cacheDir) {
|
|
203
|
-
nxJson.cacheDirectory = '.nx/cache';
|
|
204
|
-
}
|
|
205
199
|
const defaultBase = (0, deduce_default_base_1.deduceDefaultBase)();
|
|
206
200
|
// Do not add defaultBase if it is inferred to be the Nx default value of main
|
|
207
201
|
if (defaultBase !== 'main') {
|
|
@@ -221,6 +215,7 @@ function addDepsToPackageJson(repoRoot, packageManager, additionalPackages) {
|
|
|
221
215
|
}
|
|
222
216
|
}
|
|
223
217
|
(0, fileutils_1.writeJsonFile)(path, json);
|
|
218
|
+
(0, format_1.recordInitWrite)(path);
|
|
224
219
|
// nx has a postinstall script, which pnpm 11+ refuses to install
|
|
225
220
|
// unacknowledged.
|
|
226
221
|
(0, acknowledge_build_scripts_1.acknowledgeBuildScripts)(repoRoot, packageManager, { nx: true });
|
|
@@ -351,6 +346,7 @@ function setNeverConnectToCloud(repoRoot) {
|
|
|
351
346
|
const nxJson = (0, fileutils_1.readJsonFile)(nxJsonPath);
|
|
352
347
|
nxJson.neverConnectToCloud = true;
|
|
353
348
|
(0, fileutils_1.writeJsonFile)(nxJsonPath, nxJson);
|
|
349
|
+
(0, format_1.recordInitWrite)(nxJsonPath);
|
|
354
350
|
}
|
|
355
351
|
function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
|
356
352
|
const vsCodeExtensionsPath = (0, path_1.join)(repoRoot, '.vscode/extensions.json');
|
|
@@ -363,9 +359,11 @@ function addVsCodeRecommendedExtensions(repoRoot, extensions) {
|
|
|
363
359
|
}
|
|
364
360
|
});
|
|
365
361
|
(0, fileutils_1.writeJsonFile)(vsCodeExtensionsPath, vsCodeExtensionsJson);
|
|
362
|
+
(0, format_1.recordInitWrite)(vsCodeExtensionsPath);
|
|
366
363
|
}
|
|
367
364
|
else {
|
|
368
365
|
(0, fileutils_1.writeJsonFile)(vsCodeExtensionsPath, { recommendations: extensions });
|
|
366
|
+
(0, format_1.recordInitWrite)(vsCodeExtensionsPath);
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
369
|
function markRootPackageJsonAsNxProjectLegacy(repoRoot, cacheableScripts, pmc) {
|
|
@@ -386,6 +384,7 @@ function markRootPackageJsonAsNxProjectLegacy(repoRoot, cacheableScripts, pmc) {
|
|
|
386
384
|
}
|
|
387
385
|
}
|
|
388
386
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
|
387
|
+
(0, format_1.recordInitWrite)('package.json');
|
|
389
388
|
}
|
|
390
389
|
function markPackageJsonAsNxProject(packageJsonPath) {
|
|
391
390
|
const json = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
|
@@ -394,6 +393,7 @@ function markPackageJsonAsNxProject(packageJsonPath) {
|
|
|
394
393
|
}
|
|
395
394
|
json.nx = {};
|
|
396
395
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, json);
|
|
396
|
+
(0, format_1.recordInitWrite)(packageJsonPath);
|
|
397
397
|
}
|
|
398
398
|
function printFinalMessage({ learnMoreLink, appendLines, }) {
|
|
399
399
|
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,7 +5,7 @@ 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");
|
|
@@ -20,6 +20,7 @@ const configure_plugins_1 = require("./configure-plugins");
|
|
|
20
20
|
const ai_agent_prompts_1 = require("./ai-agent-prompts");
|
|
21
21
|
const set_up_ai_agents_1 = require("../../ai/set-up-ai-agents/set-up-ai-agents");
|
|
22
22
|
const tree_1 = require("../../generators/tree");
|
|
23
|
+
const format_1 = require("./implementation/format");
|
|
23
24
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
|
24
25
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
|
25
26
|
const add_nx_to_turborepo_1 = require("./implementation/add-nx-to-turborepo");
|
|
@@ -29,11 +30,14 @@ const utils_1 = require("./implementation/utils");
|
|
|
29
30
|
const provenance_1 = require("../../utils/provenance");
|
|
30
31
|
const handle_import_1 = require("../../utils/handle-import");
|
|
31
32
|
const native_1 = require("../../native");
|
|
33
|
+
const utils_2 = require("../../ai/utils");
|
|
34
|
+
const permission_errors_1 = require("../../utils/permission-errors");
|
|
32
35
|
const detect_ai_agent_1 = require("../../ai/detect-ai-agent");
|
|
33
36
|
const ab_testing_1 = require("../../utils/ab-testing");
|
|
34
37
|
const analytics_prompt_1 = require("../../utils/analytics-prompt");
|
|
35
38
|
const is_ci_1 = require("../../utils/is-ci");
|
|
36
39
|
const ai_output_1 = require("./utils/ai-output");
|
|
40
|
+
const is_sandbox_1 = require("../../utils/is-sandbox");
|
|
37
41
|
async function initHandler(options, inner = false) {
|
|
38
42
|
// Use environment variable to force local execution
|
|
39
43
|
if (process.env.NX_USE_LOCAL === 'true' || inner) {
|
|
@@ -118,8 +122,15 @@ async function runInit(options, baseMeta) {
|
|
|
118
122
|
}
|
|
119
123
|
// AI agent mode: apply defaults for non-interactive operation
|
|
120
124
|
const aiMode = (0, native_1.isAiAgent)();
|
|
125
|
+
const isSandboxed = (0, is_sandbox_1.isSandbox)();
|
|
121
126
|
if (aiMode) {
|
|
122
127
|
options.interactive = false; // Force non-interactive
|
|
128
|
+
if (isSandboxed) {
|
|
129
|
+
// During init, before configuring AI agents, the daemon and
|
|
130
|
+
// plugin socket connections are not available
|
|
131
|
+
process.env.NX_DAEMON = 'false';
|
|
132
|
+
process.env.NX_ISOLATE_PLUGINS = 'false';
|
|
133
|
+
}
|
|
123
134
|
if (options.nxCloud === undefined) {
|
|
124
135
|
options.nxCloud = false; // Default to skip Nx Cloud
|
|
125
136
|
}
|
|
@@ -148,6 +159,7 @@ async function runInit(options, baseMeta) {
|
|
|
148
159
|
...options,
|
|
149
160
|
integrated: !!options.integrated,
|
|
150
161
|
});
|
|
162
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
151
163
|
(0, utils_1.printFinalMessage)({
|
|
152
164
|
learnMoreLink: 'https://nx.dev/technologies/angular/migration/angular',
|
|
153
165
|
});
|
|
@@ -161,21 +173,17 @@ async function runInit(options, baseMeta) {
|
|
|
161
173
|
options.interactive &&
|
|
162
174
|
!aiMode &&
|
|
163
175
|
process.stdin.isTTY) {
|
|
164
|
-
const setupMode = await (0,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
]).then((r) => r.setupMode);
|
|
176
|
+
const setupMode = await (0, prompt_helpers_1.selectPrompt)({
|
|
177
|
+
message: 'How would you like to set up Nx in this directory?',
|
|
178
|
+
choices: [
|
|
179
|
+
{
|
|
180
|
+
value: '.nx installation (recommended for non-JavaScript projects)',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value: 'package.json installation (recommended for JavaScript/TypeScript projects)',
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
});
|
|
179
187
|
if (setupMode.startsWith('package.json')) {
|
|
180
188
|
// Create a minimal package.json so the JS/TS workflow takes over
|
|
181
189
|
const workspaceName = (0, path_1.basename)(process.cwd());
|
|
@@ -184,6 +192,7 @@ async function runInit(options, baseMeta) {
|
|
|
184
192
|
version: '0.0.0',
|
|
185
193
|
private: true,
|
|
186
194
|
});
|
|
195
|
+
(0, format_1.recordInitWrite)('package.json');
|
|
187
196
|
}
|
|
188
197
|
else {
|
|
189
198
|
options.useDotNxInstallation = true;
|
|
@@ -198,14 +207,10 @@ async function runInit(options, baseMeta) {
|
|
|
198
207
|
// AI mode defaults to minimum setup, humans can choose
|
|
199
208
|
let guided = !aiMode; // Default to minimum (false) for AI, guided (true) for humans
|
|
200
209
|
if (options.interactive && !(_isTurborepo || _isNonJs)) {
|
|
201
|
-
const setupType = await (0,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
message: 'Would you like a minimum or guided setup?',
|
|
206
|
-
choices: [{ name: 'Minimum' }, { name: 'Guided' }],
|
|
207
|
-
},
|
|
208
|
-
]).then((r) => r.setupPreference);
|
|
210
|
+
const setupType = await (0, prompt_helpers_1.selectPrompt)({
|
|
211
|
+
message: 'Would you like a minimum or guided setup?',
|
|
212
|
+
choices: [{ value: 'Minimum' }, { value: 'Guided' }],
|
|
213
|
+
});
|
|
209
214
|
guided = setupType === 'Guided';
|
|
210
215
|
}
|
|
211
216
|
/**
|
|
@@ -221,6 +226,7 @@ async function runInit(options, baseMeta) {
|
|
|
221
226
|
await (0, add_nx_to_turborepo_1.addNxToTurborepo)({
|
|
222
227
|
interactive: options.interactive,
|
|
223
228
|
});
|
|
229
|
+
await (0, format_1.formatInitWrites)(process.cwd());
|
|
224
230
|
(0, utils_1.printFinalMessage)({
|
|
225
231
|
learnMoreLink: 'https://nx.dev/recipes/adopting-nx/from-turborepo',
|
|
226
232
|
});
|
|
@@ -295,6 +301,9 @@ async function runInit(options, baseMeta) {
|
|
|
295
301
|
reason: getPluginReason(name),
|
|
296
302
|
}));
|
|
297
303
|
(0, ai_output_1.logProgress)('detecting', `Detected ${detectedPluginNames.length} plugin(s): ${detectedPluginNames.join(', ')}`);
|
|
304
|
+
// This path exits without reaching the drain below, and `nx.json` has
|
|
305
|
+
// already been written by now.
|
|
306
|
+
await (0, format_1.formatInitWrites)(repoRoot);
|
|
298
307
|
(0, ai_output_1.writeAiOutput)((0, ai_output_1.buildNeedsInputResult)(detectedPlugins));
|
|
299
308
|
process.exit(0);
|
|
300
309
|
}
|
|
@@ -321,21 +330,38 @@ async function runInit(options, baseMeta) {
|
|
|
321
330
|
await (0, configure_plugins_1.configurePlugins)(pluginsToInstall, updatePackageScripts, pmc, repoRoot, options.verbose);
|
|
322
331
|
}
|
|
323
332
|
}
|
|
324
|
-
|
|
333
|
+
// AI agent mode configures the detected agent automatically (aiAgents is
|
|
334
|
+
// pre-filled above); interactive humans are always prompted — even in the
|
|
335
|
+
// minimum setup — since agent configuration also writes the sandbox
|
|
336
|
+
// allowances the Nx daemon needs when driven by an agent later.
|
|
337
|
+
const selectedAgents = await (0, ai_agent_prompts_1.determineAiAgents)(options.aiAgents, options.interactive);
|
|
325
338
|
if (selectedAgents && selectedAgents.length > 0) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
+
try {
|
|
340
|
+
const tree = new tree_1.FsTree(repoRoot, false);
|
|
341
|
+
const aiAgentsCallback = await (0, set_up_ai_agents_1.setupAiAgentsGenerator)(tree, {
|
|
342
|
+
directory: '.',
|
|
343
|
+
writeNxCloudRules: options.nxCloud !== false,
|
|
344
|
+
packageVersion: 'latest',
|
|
345
|
+
agents: [...selectedAgents],
|
|
346
|
+
});
|
|
347
|
+
const changes = tree.listChanges();
|
|
348
|
+
(0, tree_1.flushChanges)(repoRoot, changes);
|
|
349
|
+
if (aiAgentsCallback) {
|
|
350
|
+
const results = await aiAgentsCallback();
|
|
351
|
+
results.messages.forEach((m) => output_1.output.log(m));
|
|
352
|
+
results.errors.forEach((e) => output_1.output.error(e));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
catch (e) {
|
|
356
|
+
if (!(0, permission_errors_1.isPermissionDenied)(e)) {
|
|
357
|
+
throw e;
|
|
358
|
+
}
|
|
359
|
+
// Don't fail the whole init over this — everything else succeeded.
|
|
360
|
+
// Warned rather than thrown so the rest of the init result still stands.
|
|
361
|
+
output_1.output.warn({
|
|
362
|
+
title: 'AI agent configuration could not be written from this process',
|
|
363
|
+
bodyLines: (0, utils_2.agentConfigWriteBlockedLines)(e),
|
|
364
|
+
});
|
|
339
365
|
}
|
|
340
366
|
}
|
|
341
367
|
let nxCloudChoice;
|
|
@@ -373,6 +399,10 @@ async function runInit(options, baseMeta) {
|
|
|
373
399
|
pluginsInstalled: pluginsToInstall.join(','),
|
|
374
400
|
},
|
|
375
401
|
});
|
|
402
|
+
// Before the AI record, not after: the formatters write to stdout
|
|
403
|
+
// (`--list-different`, oxfmt's summary), which would otherwise land after the
|
|
404
|
+
// NDJSON result and corrupt the tail an agent parses.
|
|
405
|
+
await (0, format_1.formatInitWrites)(repoRoot);
|
|
376
406
|
// Output success result for AI agents
|
|
377
407
|
if (aiMode) {
|
|
378
408
|
(0, ai_output_1.writeAiOutput)((0, ai_output_1.buildSuccessResult)({
|
|
@@ -400,6 +430,7 @@ async function runInit(options, baseMeta) {
|
|
|
400
430
|
function getPluginReason(plugin) {
|
|
401
431
|
const reasonMap = {
|
|
402
432
|
'@nx/eslint': 'eslint detected in dependencies',
|
|
433
|
+
'@nx/oxlint': 'oxlint detected in dependencies',
|
|
403
434
|
'@nx/storybook': 'storybook detected in dependencies',
|
|
404
435
|
'@nx/vite': 'vite detected in dependencies',
|
|
405
436
|
'@nx/vitest': 'vitest detected in dependencies',
|
|
@@ -447,6 +478,7 @@ function parsePluginsFlag(value) {
|
|
|
447
478
|
const npmPackageToPluginMap = {
|
|
448
479
|
// Generic JS tools
|
|
449
480
|
eslint: '@nx/eslint',
|
|
481
|
+
oxlint: '@nx/oxlint',
|
|
450
482
|
storybook: '@nx/storybook',
|
|
451
483
|
// Bundlers
|
|
452
484
|
vite: '@nx/vite',
|
|
@@ -573,39 +605,18 @@ async function detectPlugins(nxJson, packageJson, interactive, includeAngularCli
|
|
|
573
605
|
`Add these Nx plugins to integrate with the tools used in your workspace.`,
|
|
574
606
|
],
|
|
575
607
|
});
|
|
576
|
-
const pluginsToInstall = await (0,
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
|
|
581
|
-
choices: plugins.map((p) => ({ name: p, value: p })),
|
|
582
|
-
/**
|
|
583
|
-
* limit is missing from the interface but it limits the amount of options shown
|
|
584
|
-
*/
|
|
585
|
-
limit: process.stdout.rows - 4, // 4 leaves room for the header above, the prompt and some whitespace
|
|
586
|
-
},
|
|
587
|
-
]).then((r) => r.plugins);
|
|
608
|
+
const pluginsToInstall = await (0, prompt_helpers_1.multiselectPrompt)({
|
|
609
|
+
message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
|
|
610
|
+
choices: plugins,
|
|
611
|
+
});
|
|
588
612
|
if (pluginsToInstall?.length === 0)
|
|
589
613
|
return {
|
|
590
614
|
plugins: [],
|
|
591
615
|
updatePackageScripts: false,
|
|
592
616
|
};
|
|
593
617
|
const updatePackageScripts = (0, fs_1.existsSync)('package.json') &&
|
|
594
|
-
(await (0,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
type: 'autocomplete',
|
|
598
|
-
message: `Do you want to start using Nx in your package.json scripts?`,
|
|
599
|
-
choices: [
|
|
600
|
-
{
|
|
601
|
-
name: 'Yes',
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
name: 'No',
|
|
605
|
-
},
|
|
606
|
-
],
|
|
607
|
-
initial: 0,
|
|
608
|
-
},
|
|
609
|
-
]).then((r) => r.updatePackageScripts === 'Yes'));
|
|
618
|
+
(await (0, prompt_helpers_1.confirmationPrompt)({
|
|
619
|
+
message: `Do you want to start using Nx in your package.json scripts?`,
|
|
620
|
+
}));
|
|
610
621
|
return { plugins: pluginsToInstall, updatePackageScripts };
|
|
611
622
|
}
|
|
@@ -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,
|