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
|
@@ -1,7 +1,37 @@
|
|
|
1
|
-
import { type ExecOptions, type ExecSyncOptions } from 'child_process';
|
|
1
|
+
import { type ExecOptions, type ExecSyncOptions, type SpawnSyncOptions } from 'child_process';
|
|
2
2
|
import { PackageManagerCommands } from './package-manager';
|
|
3
3
|
import { ChildProcess } from '../native';
|
|
4
4
|
export declare function getRunNxBaseCommand(packageManagerCommand?: PackageManagerCommands, cwd?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Locate an nx entry point to spawn for the workspace at `root`, so a caller
|
|
7
|
+
* can run it directly instead of going through a shell. `findInstalledNxBin`
|
|
8
|
+
* decides which one.
|
|
9
|
+
*
|
|
10
|
+
* Null means nothing may be spawned directly, leaving the caller to fall back
|
|
11
|
+
* to `getRunNxBaseCommand`. Null is therefore always safe: it costs the
|
|
12
|
+
* argument fidelity a direct spawn buys, never the ability to run.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getNxBin(root?: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* The entry point the nx installed directly under `dir` names, with no ascent
|
|
17
|
+
* to `dir`'s ancestors. For an installation that declares nx itself, such as
|
|
18
|
+
* the temp CLI `nx migrate` builds, an ancestor's nx is never the right answer.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readInstalledNxBin(dir: string): string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Run a nx command, passing the arguments through as an argv array.
|
|
23
|
+
*
|
|
24
|
+
* When `getNxBin` names an entry point, the child is spawned directly with no
|
|
25
|
+
* shell in between, so every argument reaches the child exactly as provided:
|
|
26
|
+
* shell metacharacters (`(`, `%`, `^`, spaces, quotes) are data, not syntax.
|
|
27
|
+
* Otherwise falls back to the package-manager + shell path, where every
|
|
28
|
+
* argument goes through `quoteShellArg` and the Windows limits it documents
|
|
29
|
+
* apply.
|
|
30
|
+
*/
|
|
31
|
+
export declare function runNxArgvSync(argv: string[], options?: SpawnSyncOptions & {
|
|
32
|
+
cwd?: string;
|
|
33
|
+
nxBin?: string;
|
|
34
|
+
}): void;
|
|
5
35
|
export declare function runNxSync(cmd: string, options?: ExecSyncOptions & {
|
|
6
36
|
cwd?: string;
|
|
7
37
|
packageManagerCommand?: PackageManagerCommands;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PseudoTtyProcess = void 0;
|
|
4
4
|
exports.getRunNxBaseCommand = getRunNxBaseCommand;
|
|
5
|
+
exports.getNxBin = getNxBin;
|
|
6
|
+
exports.readInstalledNxBin = readInstalledNxBin;
|
|
7
|
+
exports.runNxArgvSync = runNxArgvSync;
|
|
5
8
|
exports.runNxSync = runNxSync;
|
|
6
9
|
exports.runNxAsync = runNxAsync;
|
|
7
10
|
const child_process_1 = require("child_process");
|
|
@@ -10,9 +13,14 @@ const path_1 = require("path");
|
|
|
10
13
|
const package_manager_1 = require("./package-manager");
|
|
11
14
|
const workspace_root_1 = require("./workspace-root");
|
|
12
15
|
const exit_codes_1 = require("./exit-codes");
|
|
16
|
+
const fileutils_1 = require("./fileutils");
|
|
17
|
+
const shell_quoting_1 = require("./shell-quoting");
|
|
13
18
|
function getRunNxBaseCommand(packageManagerCommand, cwd = process.cwd()) {
|
|
14
19
|
if ((0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, 'package.json'))) {
|
|
15
20
|
if (!packageManagerCommand) {
|
|
21
|
+
// `readLocalNxVersion` (command-line/migrate/migrate.ts) mirrors this
|
|
22
|
+
// selector to predict which nx a spawn will run, for the workspaces
|
|
23
|
+
// `getNxBin` declines to resolve; keep the two in sync.
|
|
16
24
|
const pm = (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot);
|
|
17
25
|
packageManagerCommand = (0, package_manager_1.getPackageManagerCommand)(pm, workspace_root_1.workspaceRoot);
|
|
18
26
|
}
|
|
@@ -28,6 +36,101 @@ function getRunNxBaseCommand(packageManagerCommand, cwd = process.cwd()) {
|
|
|
28
36
|
}
|
|
29
37
|
}
|
|
30
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Locate an nx entry point to spawn for the workspace at `root`, so a caller
|
|
41
|
+
* can run it directly instead of going through a shell. `findInstalledNxBin`
|
|
42
|
+
* decides which one.
|
|
43
|
+
*
|
|
44
|
+
* Null means nothing may be spawned directly, leaving the caller to fall back
|
|
45
|
+
* to `getRunNxBaseCommand`. Null is therefore always safe: it costs the
|
|
46
|
+
* argument fidelity a direct spawn buys, never the ability to run.
|
|
47
|
+
*/
|
|
48
|
+
function getNxBin(root = workspace_root_1.workspaceRoot) {
|
|
49
|
+
// A workspace with no root package.json runs nx through the `./nx` wrapper,
|
|
50
|
+
// which reinstalls `.nx/installation` whenever it drifts from nx.json's
|
|
51
|
+
// `installation.version`. Spawning the resolved entry point would skip that
|
|
52
|
+
// sync, and a migration is precisely when the version changes.
|
|
53
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(root, 'package.json'))) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
return findInstalledNxBin(root);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The entry point the nx installed directly under `dir` names, with no ascent
|
|
60
|
+
* to `dir`'s ancestors. For an installation that declares nx itself, such as
|
|
61
|
+
* the temp CLI `nx migrate` builds, an ancestor's nx is never the right answer.
|
|
62
|
+
*/
|
|
63
|
+
function readInstalledNxBin(dir) {
|
|
64
|
+
const packageDir = (0, path_1.join)(dir, 'node_modules', 'nx');
|
|
65
|
+
const manifest = (0, path_1.join)(packageDir, 'package.json');
|
|
66
|
+
if (!(0, fs_1.existsSync)(manifest)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
let bin;
|
|
70
|
+
try {
|
|
71
|
+
({ bin } = (0, fileutils_1.readJsonFile)(manifest));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
// npm accepts both the single-entry shorthand and the map form.
|
|
77
|
+
const entry = typeof bin === 'string' ? bin : bin?.nx;
|
|
78
|
+
return typeof entry === 'string' ? (0, path_1.join)(packageDir, entry) : null;
|
|
79
|
+
}
|
|
80
|
+
// Ascend to the nearest installed nx and take the entry point its `bin` field
|
|
81
|
+
// names, which is the file a package manager links into `node_modules/.bin`.
|
|
82
|
+
// Deliberately npx-shaped: npx and bun ascend unconditionally while pnpm and
|
|
83
|
+
// yarn stop at an outer workspace, so this can name an nx those two would
|
|
84
|
+
// decline to run.
|
|
85
|
+
//
|
|
86
|
+
// Deliberately not a resolver. Resolvers answer from NODE_PATH once their
|
|
87
|
+
// explicit paths miss, and `nxCliPath` (command-line/migrate/migrate.ts) points
|
|
88
|
+
// NODE_PATH at the temp installation before spawning it; they also answer
|
|
89
|
+
// through package self-reference, which hands back the running nx whatever
|
|
90
|
+
// `paths` they are given. Either one lets the temp installation hand off to
|
|
91
|
+
// itself, which for `--run-migrations` re-enters the same hand-off and respawns
|
|
92
|
+
// without end.
|
|
93
|
+
function findInstalledNxBin(root) {
|
|
94
|
+
for (let dir = root;; dir = (0, path_1.dirname)(dir)) {
|
|
95
|
+
// The nearest install wins, so an unusable manifest there ends the search
|
|
96
|
+
// rather than deferring to an ancestor.
|
|
97
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(dir, 'node_modules', 'nx', 'package.json'))) {
|
|
98
|
+
return readInstalledNxBin(dir);
|
|
99
|
+
}
|
|
100
|
+
if (dir === (0, path_1.dirname)(dir)) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Run a nx command, passing the arguments through as an argv array.
|
|
107
|
+
*
|
|
108
|
+
* When `getNxBin` names an entry point, the child is spawned directly with no
|
|
109
|
+
* shell in between, so every argument reaches the child exactly as provided:
|
|
110
|
+
* shell metacharacters (`(`, `%`, `^`, spaces, quotes) are data, not syntax.
|
|
111
|
+
* Otherwise falls back to the package-manager + shell path, where every
|
|
112
|
+
* argument goes through `quoteShellArg` and the Windows limits it documents
|
|
113
|
+
* apply.
|
|
114
|
+
*/
|
|
115
|
+
function runNxArgvSync(argv, options) {
|
|
116
|
+
let { nxBin, ...spawnOptions } = options ?? {};
|
|
117
|
+
spawnOptions.cwd ??= process.cwd();
|
|
118
|
+
spawnOptions.windowsHide ??= true;
|
|
119
|
+
nxBin ??= getNxBin((0, workspace_root_1.workspaceRootInner)(spawnOptions.cwd, null) ?? workspace_root_1.workspaceRoot);
|
|
120
|
+
if (!nxBin) {
|
|
121
|
+
runNxSync(argv.map(shell_quoting_1.quoteShellArg).join(' '), spawnOptions);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const result = (0, child_process_1.spawnSync)(process.execPath, [nxBin, ...argv], spawnOptions);
|
|
125
|
+
if (result.error) {
|
|
126
|
+
throw result.error;
|
|
127
|
+
}
|
|
128
|
+
if (result.status !== 0) {
|
|
129
|
+
const error = new Error(`Command failed: nx ${argv.join(' ')} (exit code ${result.status})`);
|
|
130
|
+
error.status = result.status ?? 1;
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
31
134
|
function runNxSync(cmd, options) {
|
|
32
135
|
let { packageManagerCommand, ...execSyncOptions } = options ?? {};
|
|
33
136
|
execSyncOptions.cwd ??= process.cwd();
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
export declare function chunkify(target: string[], maxChunkLength?: number
|
|
1
|
+
export declare function chunkify(target: string[], maxChunkLength?: number,
|
|
2
|
+
/**
|
|
3
|
+
* How long each entry will be once it reaches the command line. Callers that
|
|
4
|
+
* quote or escape afterwards pass that transformation's length here, so the
|
|
5
|
+
* chunk is sized against what is actually spawned rather than the raw string.
|
|
6
|
+
*/
|
|
7
|
+
measure?: (item: string) => number): string[][];
|
|
2
8
|
/**
|
|
3
9
|
* Get the maximum length of a command-line argument string based on current platform
|
|
4
10
|
*
|
|
@@ -3,22 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.chunkify = chunkify;
|
|
4
4
|
exports.getMaxArgLength = getMaxArgLength;
|
|
5
5
|
const TERMINAL_SIZE = getMaxArgLength();
|
|
6
|
-
function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500
|
|
6
|
+
function chunkify(target, maxChunkLength = TERMINAL_SIZE - 500,
|
|
7
|
+
/**
|
|
8
|
+
* How long each entry will be once it reaches the command line. Callers that
|
|
9
|
+
* quote or escape afterwards pass that transformation's length here, so the
|
|
10
|
+
* chunk is sized against what is actually spawned rather than the raw string.
|
|
11
|
+
*/
|
|
12
|
+
measure = (item) => item.length) {
|
|
7
13
|
const chunks = [];
|
|
8
14
|
let currentChunk = [];
|
|
9
15
|
let currentChunkLength = 0;
|
|
10
16
|
for (const file of target) {
|
|
17
|
+
const length = measure(file);
|
|
11
18
|
if (
|
|
12
19
|
// Prevent empty chunk if first file path is longer than maxChunkLength
|
|
13
20
|
currentChunk.length &&
|
|
14
21
|
// +1 accounts for the space between file names
|
|
15
|
-
currentChunkLength +
|
|
22
|
+
currentChunkLength + length + 1 >= maxChunkLength) {
|
|
16
23
|
chunks.push(currentChunk);
|
|
17
24
|
currentChunk = [];
|
|
18
25
|
currentChunkLength = 0;
|
|
19
26
|
}
|
|
20
27
|
currentChunk.push(file);
|
|
21
|
-
currentChunkLength +=
|
|
28
|
+
currentChunkLength += length + 1;
|
|
22
29
|
}
|
|
23
30
|
chunks.push(currentChunk);
|
|
24
31
|
return chunks;
|
|
@@ -13,3 +13,12 @@ export declare const EXPECTED_TERMINATION_SIGNALS: Set<number>;
|
|
|
13
13
|
* Handles both Linux exact-match and macOS strsignal formats (e.g. "Terminated by Hangup: 1").
|
|
14
14
|
*/
|
|
15
15
|
export declare function messageToCode(message: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* Ends the process the way an interrupted process ends: by SIGINT, not by
|
|
18
|
+
* exiting with its conventional code.
|
|
19
|
+
*
|
|
20
|
+
* A shell reports 130 either way, but a parent using waitpid sees
|
|
21
|
+
* `signal: 'SIGINT'` rather than `code: 130`, which is what tools wrapping nx
|
|
22
|
+
* check to tell "the user pressed Ctrl+C" from "the command failed".
|
|
23
|
+
*/
|
|
24
|
+
export declare function exitAsInterrupted(): never;
|
|
@@ -4,6 +4,7 @@ exports.EXPECTED_TERMINATION_SIGNALS = void 0;
|
|
|
4
4
|
exports.signalToCode = signalToCode;
|
|
5
5
|
exports.codeToSignal = codeToSignal;
|
|
6
6
|
exports.messageToCode = messageToCode;
|
|
7
|
+
exports.exitAsInterrupted = exitAsInterrupted;
|
|
7
8
|
/**
|
|
8
9
|
* Translates NodeJS signals to numeric exit code
|
|
9
10
|
* @param signal
|
|
@@ -73,3 +74,21 @@ function messageToCode(message) {
|
|
|
73
74
|
return 1;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Ends the process the way an interrupted process ends: by SIGINT, not by
|
|
79
|
+
* exiting with its conventional code.
|
|
80
|
+
*
|
|
81
|
+
* A shell reports 130 either way, but a parent using waitpid sees
|
|
82
|
+
* `signal: 'SIGINT'` rather than `code: 130`, which is what tools wrapping nx
|
|
83
|
+
* check to tell "the user pressed Ctrl+C" from "the command failed".
|
|
84
|
+
*/
|
|
85
|
+
function exitAsInterrupted() {
|
|
86
|
+
// Windows has no signal disposition to inherit - `process.kill` there
|
|
87
|
+
// terminates with an arbitrary code - so keep the 128+SIGINT convention.
|
|
88
|
+
if (process.platform !== 'win32') {
|
|
89
|
+
// Any listener would swallow this; the default action is what terminates.
|
|
90
|
+
process.removeAllListeners('SIGINT');
|
|
91
|
+
process.kill(process.pid, 'SIGINT');
|
|
92
|
+
}
|
|
93
|
+
process.exit(130);
|
|
94
|
+
}
|
|
@@ -27,6 +27,11 @@ interface YamlReadOptions {
|
|
|
27
27
|
* Compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error.
|
|
28
28
|
*/
|
|
29
29
|
json?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Resolves only the tags every YAML parser must support, so every scalar stays
|
|
32
|
+
* a string instead of `true` or `12`.
|
|
33
|
+
*/
|
|
34
|
+
failsafe?: boolean;
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Reads a YAML file and returns the object the YAML content represents.
|
|
@@ -41,8 +41,13 @@ function readJsonFile(path, options) {
|
|
|
41
41
|
*/
|
|
42
42
|
function readYamlFile(path, options) {
|
|
43
43
|
const content = (0, node_fs_1.readFileSync)(path, 'utf-8');
|
|
44
|
-
const { load } = require('@zkochan/js-yaml');
|
|
45
|
-
|
|
44
|
+
const { load, FAILSAFE_SCHEMA } = require('@zkochan/js-yaml');
|
|
45
|
+
const { failsafe, ...loadOptions } = options ?? {};
|
|
46
|
+
return load(content, {
|
|
47
|
+
...loadOptions,
|
|
48
|
+
...(failsafe ? { schema: FAILSAFE_SCHEMA } : {}),
|
|
49
|
+
filename: path,
|
|
50
|
+
});
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* Serializes the given data to JSON and writes it to a file.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Adding a member here does NOT reliably break compilation: the repo builds
|
|
4
|
+
* with `strict: false`, so a `switch` that omits one is not an error. The
|
|
5
|
+
* `never` assertions and type-keyed tables that do catch it fail immediately
|
|
6
|
+
* inside `packages/nx`, but the ones in devkit and `@nx/js` read the type from
|
|
7
|
+
* its emitted declarations, so those only fail once it has been rebuilt.
|
|
8
|
+
*/
|
|
9
|
+
export type FormatterType = 'prettier' | 'oxfmt';
|
|
10
|
+
/** Test-only: the warn-once flag is module state and would leak between cases. */
|
|
11
|
+
export declare function resetFormatterWarningsForTesting(): void;
|
|
12
|
+
export declare function detectFormatter(root: string): FormatterType | null;
|
|
13
|
+
export declare function detectFormatterInTree(tree: Tree): FormatterType | null;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetFormatterWarningsForTesting = resetFormatterWarningsForTesting;
|
|
4
|
+
exports.detectFormatter = detectFormatter;
|
|
5
|
+
exports.detectFormatterInTree = detectFormatterInTree;
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const json_1 = require("../../generators/utils/json");
|
|
9
|
+
const fileutils_1 = require("../fileutils");
|
|
10
|
+
const oxfmt_1 = require("./oxfmt");
|
|
11
|
+
const prettier_1 = require("./prettier");
|
|
12
|
+
const logger_1 = require("../logger");
|
|
13
|
+
// Once per process: detection runs on every one of 200+ `formatFiles` call sites.
|
|
14
|
+
let warnedBothConfigured = false;
|
|
15
|
+
function warnBothConfigured() {
|
|
16
|
+
warnedBothConfigured = true;
|
|
17
|
+
logger_1.logger.warn('Both an oxfmt and a prettier config were found. Nx is formatting with ' +
|
|
18
|
+
'oxfmt. Delete the config you are not using to make the choice ' +
|
|
19
|
+
'explicit: https://nx.dev/docs/reference/code-formatting');
|
|
20
|
+
}
|
|
21
|
+
/** Test-only: the warn-once flag is module state and would leak between cases. */
|
|
22
|
+
function resetFormatterWarningsForTesting() {
|
|
23
|
+
warnedBothConfigured = false;
|
|
24
|
+
}
|
|
25
|
+
function detectFormatter(root) {
|
|
26
|
+
if ((0, oxfmt_1.isUsingOxfmt)(root)) {
|
|
27
|
+
// Flag first, so the lookup stops repeating once we have warned.
|
|
28
|
+
if (!warnedBothConfigured && (0, prettier_1.isUsingPrettier)(root)) {
|
|
29
|
+
warnBothConfigured();
|
|
30
|
+
}
|
|
31
|
+
return 'oxfmt';
|
|
32
|
+
}
|
|
33
|
+
if ((0, prettier_1.isUsingPrettier)(root)) {
|
|
34
|
+
return 'prettier';
|
|
35
|
+
}
|
|
36
|
+
// Neither is configured. Both formatters run on their defaults, so a
|
|
37
|
+
// dependency declared in the root package.json is the only statement of
|
|
38
|
+
// intent an unconfigured workspace gives. #30426 ruled out treating prettier
|
|
39
|
+
// as *resolvable in node_modules*, which a declared dependency is not.
|
|
40
|
+
const packageJsonPath = (0, node_path_1.join)(root, 'package.json');
|
|
41
|
+
if ((0, node_fs_1.existsSync)(packageJsonPath)) {
|
|
42
|
+
return detectFormatterFromDependencies((0, fileutils_1.readJsonFile)(packageJsonPath));
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
function detectFormatterInTree(tree) {
|
|
47
|
+
if ((0, oxfmt_1.isUsingOxfmtInTree)(tree)) {
|
|
48
|
+
if (!warnedBothConfigured && (0, prettier_1.isUsingPrettierInTree)(tree)) {
|
|
49
|
+
warnBothConfigured();
|
|
50
|
+
}
|
|
51
|
+
return 'oxfmt';
|
|
52
|
+
}
|
|
53
|
+
if ((0, prettier_1.isUsingPrettierInTree)(tree)) {
|
|
54
|
+
return 'prettier';
|
|
55
|
+
}
|
|
56
|
+
// See detectFormatter: a declared dependency is the fallback for both.
|
|
57
|
+
if (tree.exists('package.json')) {
|
|
58
|
+
return detectFormatterFromDependencies((0, json_1.readJson)(tree, 'package.json'));
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/** oxfmt first, matching the precedence the config files already have. */
|
|
63
|
+
function detectFormatterFromDependencies(packageJson) {
|
|
64
|
+
if (hasDependency(packageJson, 'oxfmt')) {
|
|
65
|
+
return 'oxfmt';
|
|
66
|
+
}
|
|
67
|
+
if (hasDependency(packageJson, 'prettier')) {
|
|
68
|
+
return 'prettier';
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function hasDependency(packageJson, name) {
|
|
73
|
+
return Boolean(packageJson.dependencies?.[name] ?? packageJson.devDependencies?.[name]);
|
|
74
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Tree } from '../../generators/tree';
|
|
2
|
+
/**
|
|
3
|
+
* Config filenames oxfmt *discovers* - narrower than the set `-c` accepts.
|
|
4
|
+
* Measured against 0.60.0: `oxfmt.config.{js,cjs,mjs,cts}` load when named
|
|
5
|
+
* but are never searched for, so treating one as config would format on
|
|
6
|
+
* options oxfmt ignores. No precedence order - oxfmt fails with
|
|
7
|
+
* "Both '<a>' and '<b>' found in <dir>" when a directory holds two.
|
|
8
|
+
*/
|
|
9
|
+
export declare const oxfmtConfigFiles: string[];
|
|
10
|
+
export declare function isUsingOxfmt(root: string): boolean;
|
|
11
|
+
export declare function isUsingOxfmtInTree(tree: Tree): boolean;
|
|
12
|
+
export declare function getOxfmtBinPath(): string;
|
|
13
|
+
export declare function writeWithOxfmt(patterns: string[], cwd?: string): void;
|
|
14
|
+
export declare function checkWithOxfmt(patterns: string[]): Promise<string[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Nothing is written to disk: staging files inside the workspace would race the
|
|
17
|
+
* daemon's watcher and the project graph mid-generator.
|
|
18
|
+
*
|
|
19
|
+
* A path is absent from the result when oxfmt has no parser for it, an ignore
|
|
20
|
+
* file covers it, or it is already formatted. One unparseable file fails only
|
|
21
|
+
* itself; the rest of the batch still applies.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatFilesWithOxfmt(files: {
|
|
24
|
+
path: string;
|
|
25
|
+
content: string;
|
|
26
|
+
}[], workspaceRoot: string, seedConfig?: {
|
|
27
|
+
name: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}, rootConfigNames?: readonly string[], read?: (relativePath: string) => string | null | undefined): Promise<{
|
|
30
|
+
formatted: Map<string, string>;
|
|
31
|
+
errors?: string[];
|
|
32
|
+
}>;
|