@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
|
@@ -14,6 +14,7 @@ export declare function loadPnpmHoistedDepsDefinition(): any;
|
|
|
14
14
|
* Parsing and mapping logic from pnpm lockfile `read` function
|
|
15
15
|
*/
|
|
16
16
|
export declare function parseAndNormalizePnpmLockfile(content: string): Lockfile;
|
|
17
|
+
export declare function extractMainLockfileDocument(content: string): string;
|
|
17
18
|
/**
|
|
18
19
|
* Mapping and writing logic from pnpm lockfile `write` function
|
|
19
20
|
*/
|
|
@@ -8,6 +8,7 @@ exports.isV5Syntax = isV5Syntax;
|
|
|
8
8
|
exports.usesLeadingDash = usesLeadingDash;
|
|
9
9
|
exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
|
|
10
10
|
exports.parseAndNormalizePnpmLockfile = parseAndNormalizePnpmLockfile;
|
|
11
|
+
exports.extractMainLockfileDocument = extractMainLockfileDocument;
|
|
11
12
|
exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
|
|
12
13
|
const node_fs_1 = require("node:fs");
|
|
13
14
|
const semver_1 = require("semver");
|
|
@@ -48,10 +49,11 @@ function parseAndNormalizePnpmLockfile(content) {
|
|
|
48
49
|
// https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts
|
|
49
50
|
const YAML_DOCUMENT_START = '---\n';
|
|
50
51
|
const YAML_DOCUMENT_SEPARATOR = '\n---\n';
|
|
51
|
-
// pnpm 11 writes a two-document lockfile when `
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
52
|
+
// pnpm 11 writes a two-document lockfile when `shouldPersistLockfile` holds
|
|
53
|
+
// (the package manager came from `devEngines`, or declares major 12 or above):
|
|
54
|
+
// the first document holds package-manager metadata, and the second holds the
|
|
55
|
+
// workspace lockfile. Mirror pnpm's own positional extraction so we always read
|
|
56
|
+
// the workspace document.
|
|
55
57
|
// https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts
|
|
56
58
|
function extractMainLockfileDocument(content) {
|
|
57
59
|
// Lockfiles written on Windows may use CRLF line endings, which would never
|
|
@@ -667,7 +669,6 @@ function normalizeLockfile(lockfile, opts) {
|
|
|
667
669
|
if (!lockfileToSave.pnpmfileChecksum) {
|
|
668
670
|
delete lockfileToSave.pnpmfileChecksum;
|
|
669
671
|
}
|
|
670
|
-
delete lockfileToSave['catalogs'];
|
|
671
672
|
return lockfileToSave;
|
|
672
673
|
}
|
|
673
674
|
const ROOT_KEYS = [
|
|
@@ -23,6 +23,17 @@ import type { CompilerOptions } from 'typescript';
|
|
|
23
23
|
* Throws if neither `@swc-node/register` nor `ts-node` is installed.
|
|
24
24
|
*/
|
|
25
25
|
export declare function forceRegisterEsmLoader(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Effective `TS_NODE_COMPILER_OPTIONS` value for `ts-node/esm`. CommonJS emit
|
|
28
|
+
* can never work for the true-ESM loads the loader exists for (`import.meta`
|
|
29
|
+
* fails with TS1343), and CommonJS-format files are deferred to the `require`
|
|
30
|
+
* pipeline untouched, so `module`/`moduleResolution` are forced to `nodenext`
|
|
31
|
+
* over any inherited value. Values that are not a JSON object pass through
|
|
32
|
+
* unchanged for ts-node to handle.
|
|
33
|
+
*
|
|
34
|
+
* Exported so the merge semantics can be exercised directly in unit tests.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveTsNodeEsmCompilerOptions(raw: string | undefined): string;
|
|
26
37
|
/**
|
|
27
38
|
* Source of a minimal ESM resolution hook that rewrites TypeScript NodeNext
|
|
28
39
|
* `.js`/`.mjs`/`.cjs` relative specifiers to their `.ts`/`.mts`/`.cts` sources.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NODENEXT_ESM_RESOLVER_SOURCE = void 0;
|
|
4
4
|
exports.forceRegisterEsmLoader = forceRegisterEsmLoader;
|
|
5
|
+
exports.resolveTsNodeEsmCompilerOptions = resolveTsNodeEsmCompilerOptions;
|
|
5
6
|
exports.nodeNextEsmResolveHook = nodeNextEsmResolveHook;
|
|
6
7
|
exports.ensureNodeNextEsmResolverRegistered = ensureNodeNextEsmResolverRegistered;
|
|
7
8
|
exports.ensureCjsResolverPatched = ensureCjsResolverPatched;
|
|
@@ -65,12 +66,6 @@ function ensureEsmLoaderRegistered(opts) {
|
|
|
65
66
|
}
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
// ts-node reads compilerOptions from this env var. Setting nodenext
|
|
69
|
-
// module/resolution avoids surprises when ts-node is the chosen loader.
|
|
70
|
-
process.env.TS_NODE_COMPILER_OPTIONS ??= JSON.stringify({
|
|
71
|
-
moduleResolution: 'nodenext',
|
|
72
|
-
module: 'nodenext',
|
|
73
|
-
});
|
|
74
69
|
// Prefer @swc-node/register/esm (faster) over ts-node/esm.
|
|
75
70
|
const swcEsm = tryResolveLoader('@swc-node/register/esm');
|
|
76
71
|
const tsNodeEsm = tryResolveLoader('ts-node/esm');
|
|
@@ -87,9 +82,48 @@ function ensureEsmLoaderRegistered(opts) {
|
|
|
87
82
|
logger_1.logger.warn((0, logger_1.stripIndent)(`${logger_1.NX_PREFIX} Registering ESM TypeScript loader ${loaderName}. All subsequent ESM imports in this process will go through it - native Node.js TypeScript stripping is forfeited for the dynamic-import path.`));
|
|
88
83
|
}
|
|
89
84
|
const url = require('node:url');
|
|
85
|
+
if (!swcEsm) {
|
|
86
|
+
// ts-node/esm reads TS_NODE_COMPILER_OPTIONS from its hooks thread, which
|
|
87
|
+
// snapshots process.env only when the first hook in the process registers,
|
|
88
|
+
// possibly long before this call. A registered setter module runs on the
|
|
89
|
+
// hooks thread itself, so the value lands there without mutating this
|
|
90
|
+
// process's env (which an existing hooks thread would never see, and
|
|
91
|
+
// child processes would inherit).
|
|
92
|
+
module.register('data:text/javascript,' +
|
|
93
|
+
encodeURIComponent(`process.env.TS_NODE_COMPILER_OPTIONS = ${JSON.stringify(resolveTsNodeEsmCompilerOptions(process.env.TS_NODE_COMPILER_OPTIONS))};`));
|
|
94
|
+
}
|
|
90
95
|
module.register(url.pathToFileURL(loaderPath));
|
|
91
96
|
isTsEsmLoaderRegistered = true;
|
|
92
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Effective `TS_NODE_COMPILER_OPTIONS` value for `ts-node/esm`. CommonJS emit
|
|
100
|
+
* can never work for the true-ESM loads the loader exists for (`import.meta`
|
|
101
|
+
* fails with TS1343), and CommonJS-format files are deferred to the `require`
|
|
102
|
+
* pipeline untouched, so `module`/`moduleResolution` are forced to `nodenext`
|
|
103
|
+
* over any inherited value. Values that are not a JSON object pass through
|
|
104
|
+
* unchanged for ts-node to handle.
|
|
105
|
+
*
|
|
106
|
+
* Exported so the merge semantics can be exercised directly in unit tests.
|
|
107
|
+
*/
|
|
108
|
+
function resolveTsNodeEsmCompilerOptions(raw) {
|
|
109
|
+
if (raw === undefined) {
|
|
110
|
+
return JSON.stringify({ moduleResolution: 'nodenext', module: 'nodenext' });
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
const parsed = JSON.parse(raw);
|
|
114
|
+
if (typeof parsed === 'object' &&
|
|
115
|
+
parsed !== null &&
|
|
116
|
+
!Array.isArray(parsed)) {
|
|
117
|
+
return JSON.stringify({
|
|
118
|
+
...parsed,
|
|
119
|
+
module: 'nodenext',
|
|
120
|
+
moduleResolution: 'nodenext',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
catch { }
|
|
125
|
+
return raw;
|
|
126
|
+
}
|
|
93
127
|
/**
|
|
94
128
|
* Source of a minimal ESM resolution hook that rewrites TypeScript NodeNext
|
|
95
129
|
* `.js`/`.mjs`/`.cjs` relative specifiers to their `.ts`/`.mts`/`.cts` sources.
|
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
import { NxJsonConfiguration } from '../../config/nx-json';
|
|
1
|
+
import { NxJsonConfiguration, PluginConfiguration } from '../../config/nx-json';
|
|
2
2
|
import type { LoadedNxPlugin } from './loaded-nx-plugin';
|
|
3
3
|
export interface SeparatedPlugins {
|
|
4
4
|
specifiedPlugins: LoadedNxPlugin[];
|
|
5
5
|
defaultPlugins: LoadedNxPlugin[];
|
|
6
6
|
}
|
|
7
|
+
/** Exported for tests: the fallback latch is process-scoped by design. */
|
|
8
|
+
export declare function resetIsolationFallbackForTesting(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Loads a plugin in a worker, falling back to this process when the worker's
|
|
11
|
+
* socket was refused.
|
|
12
|
+
*
|
|
13
|
+
* Isolation is preferred: it is what keeps two plugins with conflicting
|
|
14
|
+
* TypeScript versions or module-level state apart. But a sandbox that has not
|
|
15
|
+
* been told about the Nx socket root refuses the worker's socket, and failing
|
|
16
|
+
* the whole command over that is worse than running the plugins here. The
|
|
17
|
+
* fallback is narrow on purpose. It needs a failure to start or reach the
|
|
18
|
+
* worker, plus either a detectable sandbox or the worker's own EPERM/EACCES
|
|
19
|
+
* exit code under an AI agent — the second arm is what covers an agent whose
|
|
20
|
+
* sandbox sets no variable `isSandbox()` reads. A plugin that loaded and then
|
|
21
|
+
* threw is rethrown, because rerunning it in-process would bury its actual
|
|
22
|
+
* error.
|
|
23
|
+
*/
|
|
24
|
+
export declare const loadingMethod: (plugin: PluginConfiguration, root: string, index?: number) => Promise<readonly [Promise<LoadedNxPlugin>, () => void]>;
|
|
7
25
|
/**
|
|
8
26
|
* Returns all plugins (specified + default) as a flat list.
|
|
9
27
|
* Specified plugins come first, followed by default plugins.
|
|
@@ -21,5 +39,13 @@ export declare function getPlugins(nxJson: NxJsonConfiguration, root?: string):
|
|
|
21
39
|
*/
|
|
22
40
|
export declare function getPluginsSeparated(nxJson: NxJsonConfiguration, root?: string): Promise<SeparatedPlugins>;
|
|
23
41
|
export declare function getOnlyDefaultPlugins(root?: string): Promise<LoadedNxPlugin[]>;
|
|
42
|
+
/**
|
|
43
|
+
* The plugins from an in-flight load (whose workers may already be forked) or
|
|
44
|
+
* the last committed one, without triggering a load. Undefined when neither
|
|
45
|
+
* exists or plugins were cleaned up. After a plugins-config change the
|
|
46
|
+
* committed set can be the previous, already-disposed one until the new load
|
|
47
|
+
* commits, so callers must tolerate a disposed worker.
|
|
48
|
+
*/
|
|
49
|
+
export declare function getPluginsIfLoadedOrLoading(): Promise<LoadedNxPlugin[]> | undefined;
|
|
24
50
|
export declare function cleanupPlugins(): void;
|
|
25
51
|
export declare function reasonToError(reason: unknown): Error;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadingMethod = void 0;
|
|
4
|
+
exports.resetIsolationFallbackForTesting = resetIsolationFallbackForTesting;
|
|
3
5
|
exports.getPlugins = getPlugins;
|
|
4
6
|
exports.getPluginsSeparated = getPluginsSeparated;
|
|
5
7
|
exports.getOnlyDefaultPlugins = getOnlyDefaultPlugins;
|
|
8
|
+
exports.getPluginsIfLoadedOrLoading = getPluginsIfLoadedOrLoading;
|
|
6
9
|
exports.cleanupPlugins = cleanupPlugins;
|
|
7
10
|
exports.reasonToError = reasonToError;
|
|
8
11
|
const node_path_1 = require("node:path");
|
|
@@ -13,6 +16,11 @@ const in_process_loader_1 = require("./in-process-loader");
|
|
|
13
16
|
const isolation_1 = require("./isolation");
|
|
14
17
|
const resolve_plugin_1 = require("./resolve-plugin");
|
|
15
18
|
const enabled_1 = require("./isolation/enabled");
|
|
19
|
+
const isolated_plugin_1 = require("./isolation/isolated-plugin");
|
|
20
|
+
const sandbox_socket_hint_1 = require("../../daemon/sandbox-socket-hint");
|
|
21
|
+
const is_sandbox_1 = require("../../utils/is-sandbox");
|
|
22
|
+
const native_1 = require("../../native");
|
|
23
|
+
const output_1 = require("../../utils/output");
|
|
16
24
|
const transpiler_1 = require("./transpiler");
|
|
17
25
|
/**
|
|
18
26
|
* Stuff for specified NX Plugins.
|
|
@@ -28,9 +36,90 @@ let cleanupSpecifiedPlugins;
|
|
|
28
36
|
// it's still the registered load when it finishes, so a slow older load can't
|
|
29
37
|
// clobber a newer one's result (two recomputes can overlap).
|
|
30
38
|
let pendingSeparatedPlugins;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Set once a worker has been refused in this process, and read by every later
|
|
41
|
+
* plugin: nothing about a second attempt can succeed once the first has been
|
|
42
|
+
* refused for a reason that belongs to the sandbox.
|
|
43
|
+
*
|
|
44
|
+
* It does not stop the spawns of the plugins already in flight. Callers load
|
|
45
|
+
* plugins concurrently, so all of them are past the entry check before the
|
|
46
|
+
* first worker dies; what the latch guarantees is that the advice is printed
|
|
47
|
+
* once rather than once per plugin, and that anything loaded after the refusal
|
|
48
|
+
* skips the worker entirely.
|
|
49
|
+
*
|
|
50
|
+
* Process-scoped rather than persisted: the refusal describes the environment
|
|
51
|
+
* Nx is running in, so it must not follow the workspace into a plain terminal.
|
|
52
|
+
*/
|
|
53
|
+
let isolationRefusedInThisProcess = false;
|
|
54
|
+
/** Exported for tests: the fallback latch is process-scoped by design. */
|
|
55
|
+
function resetIsolationFallbackForTesting() {
|
|
56
|
+
isolationRefusedInThisProcess = false;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Loads a plugin in a worker, falling back to this process when the worker's
|
|
60
|
+
* socket was refused.
|
|
61
|
+
*
|
|
62
|
+
* Isolation is preferred: it is what keeps two plugins with conflicting
|
|
63
|
+
* TypeScript versions or module-level state apart. But a sandbox that has not
|
|
64
|
+
* been told about the Nx socket root refuses the worker's socket, and failing
|
|
65
|
+
* the whole command over that is worse than running the plugins here. The
|
|
66
|
+
* fallback is narrow on purpose. It needs a failure to start or reach the
|
|
67
|
+
* worker, plus either a detectable sandbox or the worker's own EPERM/EACCES
|
|
68
|
+
* exit code under an AI agent — the second arm is what covers an agent whose
|
|
69
|
+
* sandbox sets no variable `isSandbox()` reads. A plugin that loaded and then
|
|
70
|
+
* threw is rethrown, because rerunning it in-process would bury its actual
|
|
71
|
+
* error.
|
|
72
|
+
*/
|
|
73
|
+
const loadingMethod = async (plugin, root, index) => {
|
|
74
|
+
if (!(0, enabled_1.isIsolationEnabled)() || isolationRefusedInThisProcess) {
|
|
75
|
+
return (0, in_process_loader_1.loadNxPlugin)(plugin, root, index);
|
|
76
|
+
}
|
|
77
|
+
const [isolatedPlugin, cleanup] = await (0, isolation_1.loadIsolatedNxPlugin)(plugin, root, index);
|
|
78
|
+
// Awaited here rather than handed on, because the worker failure surfaces on
|
|
79
|
+
// this promise and the fallback has to happen before the caller sees it.
|
|
80
|
+
try {
|
|
81
|
+
return [Promise.resolve(await isolatedPlugin), cleanup];
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
// Proof, kept separate from policy. The errno the worker saw is what makes
|
|
85
|
+
// the message certain; whether that errno is also grounds for degrading is a
|
|
86
|
+
// different question, and conflating them made the warning assert a sandbox
|
|
87
|
+
// for agents the hint itself declines to name.
|
|
88
|
+
const provenRefusal = (0, isolated_plugin_1.isPluginWorkerSocketRefusal)(e);
|
|
89
|
+
// An agent is required alongside the errno, so a refusal on an ordinary
|
|
90
|
+
// workstation still surfaces rather than silently losing isolation.
|
|
91
|
+
if (!(0, isolated_plugin_1.isPluginWorkerStartupFailure)(e) ||
|
|
92
|
+
!((provenRefusal && (0, native_1.isAiAgent)()) || (0, is_sandbox_1.isSandbox)())) {
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
cleanup();
|
|
96
|
+
// Read and set in one synchronous step. Concurrently loaded plugins each
|
|
97
|
+
// arrive here with their own failure, so testing the latch after setting it
|
|
98
|
+
// is what keeps the advice to one copy.
|
|
99
|
+
const alreadyRefused = isolationRefusedInThisProcess;
|
|
100
|
+
isolationRefusedInThisProcess = true;
|
|
101
|
+
if (!alreadyRefused) {
|
|
102
|
+
output_1.output.warn({
|
|
103
|
+
// Names what Nx observed, not what it infers. `isAiAgent()` is broader
|
|
104
|
+
// than the agents `sandboxSpecificRemedy` will name a setting for, so a
|
|
105
|
+
// title asserting a sandbox could sit above a body that deliberately
|
|
106
|
+
// does not.
|
|
107
|
+
title: provenRefusal
|
|
108
|
+
? 'Nx was denied permission to create a plugin worker socket. Running plugins in the main process instead.'
|
|
109
|
+
: 'Could not start a plugin worker. Running plugins in the main process instead.',
|
|
110
|
+
bodyLines: [
|
|
111
|
+
'Plugins that expect isolation may misbehave, and this is slower than a worker.',
|
|
112
|
+
// `certain` on the errno alone. Reaching here via `isSandbox()` proves
|
|
113
|
+
// only that a worker died before it connected, which denied permission
|
|
114
|
+
// explains but so does an OOM kill or a broken install.
|
|
115
|
+
...(0, sandbox_socket_hint_1.sandboxSocketHint)({ certain: provenRefusal }),
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return (0, in_process_loader_1.loadNxPlugin)(plugin, root, index);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
exports.loadingMethod = loadingMethod;
|
|
34
123
|
/**
|
|
35
124
|
* Returns all plugins (specified + default) as a flat list.
|
|
36
125
|
* Specified plugins come first, followed by default plugins.
|
|
@@ -146,6 +235,22 @@ async function getOnlyDefaultPlugins(root = workspace_root_1.workspaceRoot) {
|
|
|
146
235
|
loadedDefaultPluginsHash = hash;
|
|
147
236
|
return result;
|
|
148
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* The plugins from an in-flight load (whose workers may already be forked) or
|
|
240
|
+
* the last committed one, without triggering a load. Undefined when neither
|
|
241
|
+
* exists or plugins were cleaned up. After a plugins-config change the
|
|
242
|
+
* committed set can be the previous, already-disposed one until the new load
|
|
243
|
+
* commits, so callers must tolerate a disposed worker.
|
|
244
|
+
*/
|
|
245
|
+
function getPluginsIfLoadedOrLoading() {
|
|
246
|
+
const separated = pendingSeparatedPlugins
|
|
247
|
+
? pendingSeparatedPlugins.promise
|
|
248
|
+
: cachedSeparatedPlugins;
|
|
249
|
+
if (!separated) {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
return Promise.resolve(separated).then(({ specifiedPlugins, defaultPlugins }) => specifiedPlugins.concat(defaultPlugins));
|
|
253
|
+
}
|
|
149
254
|
function cleanupPlugins() {
|
|
150
255
|
cleanupSpecifiedPlugins?.();
|
|
151
256
|
cleanupDefaultPlugins?.();
|
|
@@ -165,7 +270,7 @@ async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
|
|
|
165
270
|
const cleanupFunctions = [];
|
|
166
271
|
const results = await Promise.allSettled(plugins.map(async (plugin) => {
|
|
167
272
|
performance.mark(`Load Nx Plugin: ${plugin} - start`);
|
|
168
|
-
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
|
|
273
|
+
const [loadedPluginPromise, cleanup] = await (0, exports.loadingMethod)(plugin, root);
|
|
169
274
|
cleanupFunctions.push(cleanup);
|
|
170
275
|
const res = await loadedPluginPromise;
|
|
171
276
|
performance.mark(`Load Nx Plugin: ${plugin} - end`);
|
|
@@ -226,7 +331,7 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
|
|
|
226
331
|
const results = await Promise.allSettled(pluginsConfigurations.map(async (plugin, index) => {
|
|
227
332
|
const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
|
|
228
333
|
performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
|
|
229
|
-
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root, index);
|
|
334
|
+
const [loadedPluginPromise, cleanup] = await (0, exports.loadingMethod)(plugin, root, index);
|
|
230
335
|
cleanupFunctions.push(cleanup);
|
|
231
336
|
const res = await loadedPluginPromise;
|
|
232
337
|
performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isIsolationEnabled = isIsolationEnabled;
|
|
4
4
|
const native_1 = require("../../../native");
|
|
5
|
-
const is_sandbox_1 = require("../../../utils/is-sandbox");
|
|
6
5
|
function isIsolationEnabled() {
|
|
7
6
|
// Explicitly enabled, regardless of further conditions
|
|
8
7
|
if (process.env.NX_ISOLATE_PLUGINS === 'true') {
|
|
@@ -12,9 +11,7 @@ function isIsolationEnabled() {
|
|
|
12
11
|
// Explicitly disabled
|
|
13
12
|
process.env.NX_ISOLATE_PLUGINS === 'false' ||
|
|
14
13
|
// Isolation is disabled on WASM builds currently.
|
|
15
|
-
native_1.IS_WASM
|
|
16
|
-
// Isolation is disabled in sandbox environments (AI agents, etc.)
|
|
17
|
-
(0, is_sandbox_1.isSandbox)()) {
|
|
14
|
+
native_1.IS_WASM) {
|
|
18
15
|
return false;
|
|
19
16
|
}
|
|
20
17
|
// Default value
|
|
@@ -61,3 +61,19 @@ export declare class IsolatedPlugin implements LoadedNxPlugin {
|
|
|
61
61
|
private registerProcessMetrics;
|
|
62
62
|
}
|
|
63
63
|
export declare function getPluginWorkerSocketId(): string;
|
|
64
|
+
/**
|
|
65
|
+
* Marks a failure to *start or reach* a worker, as distinct from a plugin that
|
|
66
|
+
* loaded and then threw. Only the former can be retried in-process: swallowing
|
|
67
|
+
* the latter would rerun a plugin that already failed on its own merits and
|
|
68
|
+
* bury the real error.
|
|
69
|
+
*/
|
|
70
|
+
export declare const PLUGIN_WORKER_STARTUP_FAILURE: unique symbol;
|
|
71
|
+
/**
|
|
72
|
+
* Set when the worker exited with the socket-refused code. Narrower than
|
|
73
|
+
* {@link PLUGIN_WORKER_STARTUP_FAILURE}, which covers every way a worker can
|
|
74
|
+
* fail to come up, and is what lets the caller degrade on a refusal without
|
|
75
|
+
* also degrading for an OOM kill or a broken install.
|
|
76
|
+
*/
|
|
77
|
+
export declare const PLUGIN_WORKER_SOCKET_REFUSED: unique symbol;
|
|
78
|
+
export declare function isPluginWorkerStartupFailure(error: unknown): boolean;
|
|
79
|
+
export declare function isPluginWorkerSocketRefusal(error: unknown): boolean;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsolatedPlugin = void 0;
|
|
3
|
+
exports.PLUGIN_WORKER_SOCKET_REFUSED = exports.PLUGIN_WORKER_STARTUP_FAILURE = exports.IsolatedPlugin = void 0;
|
|
4
4
|
exports.getPluginWorkerSocketId = getPluginWorkerSocketId;
|
|
5
|
+
exports.isPluginWorkerStartupFailure = isPluginWorkerStartupFailure;
|
|
6
|
+
exports.isPluginWorkerSocketRefusal = isPluginWorkerSocketRefusal;
|
|
5
7
|
const child_process_1 = require("child_process");
|
|
6
8
|
const crypto_1 = require("crypto");
|
|
7
9
|
const net_1 = require("net");
|
|
8
10
|
const path = require("path");
|
|
9
11
|
const logger_1 = require("../../../daemon/logger");
|
|
12
|
+
const sandbox_socket_hint_1 = require("../../../daemon/sandbox-socket-hint");
|
|
13
|
+
const socket_refused_exit_code_1 = require("../../../utils/socket-refused-exit-code");
|
|
10
14
|
const socket_utils_1 = require("../../../daemon/socket-utils");
|
|
11
15
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
|
12
16
|
const typescript_1 = require("../../../plugins/js/utils/typescript");
|
|
13
17
|
const installation_directory_1 = require("../../../utils/installation-directory");
|
|
18
|
+
const is_sandbox_1 = require("../../../utils/is-sandbox");
|
|
14
19
|
const logger_2 = require("../../../utils/logger");
|
|
15
20
|
const progress_topics_1 = require("../../../utils/progress-topics");
|
|
16
21
|
const wait_for_socket_connection_1 = require("../../../utils/wait-for-socket-connection");
|
|
@@ -53,7 +58,17 @@ class IsolatedPlugin {
|
|
|
53
58
|
this.responseHandlers = new Map();
|
|
54
59
|
this.exitHandler = null;
|
|
55
60
|
this.handleSocketData = (raw) => {
|
|
56
|
-
|
|
61
|
+
let message;
|
|
62
|
+
try {
|
|
63
|
+
message = (0, consume_messages_from_socket_1.parseMessage)(raw);
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
// Runs inside a synchronous socket 'data' callback, so a throw here
|
|
67
|
+
// becomes an uncaughtException in the host process rather than a failed
|
|
68
|
+
// plugin call.
|
|
69
|
+
logger_2.logger.error(`[plugin-client] "${this.name}" sent a message that could not be parsed: ${e instanceof Error ? e.message : e}\nReceived: ${(0, consume_messages_from_socket_1.describeMessage)(raw)}`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
57
72
|
if ((0, messaging_1.isPluginWorkerNotification)(message)) {
|
|
58
73
|
handlePluginWorkerNotification(message);
|
|
59
74
|
return;
|
|
@@ -95,7 +110,13 @@ class IsolatedPlugin {
|
|
|
95
110
|
this.responseHandlers.clear();
|
|
96
111
|
};
|
|
97
112
|
worker.on('exit', this.exitHandler);
|
|
98
|
-
socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)(this.handleSocketData)
|
|
113
|
+
socket.on('data', (0, consume_messages_from_socket_1.consumeMessagesFromSocket)(this.handleSocketData, (err) => {
|
|
114
|
+
// Nothing else settles the pending hook promises on a framing
|
|
115
|
+
// failure, so surface it the same way a dead worker would.
|
|
116
|
+
this.exitHandler?.();
|
|
117
|
+
socket.destroy();
|
|
118
|
+
console.error(err.message);
|
|
119
|
+
}));
|
|
99
120
|
return this.sendLoadMessage();
|
|
100
121
|
}
|
|
101
122
|
/**
|
|
@@ -351,11 +372,7 @@ async function startPluginWorker(name) {
|
|
|
351
372
|
...process.env,
|
|
352
373
|
...(isWorkerTypescript
|
|
353
374
|
? {
|
|
354
|
-
|
|
355
|
-
TS_NODE_COMPILER_OPTIONS: JSON.stringify({
|
|
356
|
-
moduleResolution: 'node',
|
|
357
|
-
module: 'commonjs',
|
|
358
|
-
}),
|
|
375
|
+
SWC_NODE_PROJECT: path.join(__dirname, '../../../../tsconfig.lib.json'),
|
|
359
376
|
}
|
|
360
377
|
: {}),
|
|
361
378
|
};
|
|
@@ -371,7 +388,9 @@ async function startPluginWorker(name) {
|
|
|
371
388
|
// Spawn the worker with the same resolve conditions Nx uses for plugin
|
|
372
389
|
// entries so the plugin's transitive workspace imports resolve to source.
|
|
373
390
|
...(0, typescript_1.getPluginResolveConditionNodeArgs)(),
|
|
374
|
-
|
|
391
|
+
// swc transpiles without type-checking: ~7x faster to boot, and this is
|
|
392
|
+
// paid once per worker spawn.
|
|
393
|
+
...(isWorkerTypescript ? ['--require', '@swc-node/register'] : []),
|
|
375
394
|
workerPath,
|
|
376
395
|
ipcPath,
|
|
377
396
|
name,
|
|
@@ -413,7 +432,19 @@ async function connectToWorker(worker, ipcPath, name) {
|
|
|
413
432
|
// rather than burning through attempts against a dead socket.
|
|
414
433
|
worker.once('exit', (code) => {
|
|
415
434
|
if (!abortController.signal.aborted) {
|
|
416
|
-
|
|
435
|
+
// The worker sets this code only after an EPERM/EACCES on its own bind,
|
|
436
|
+
// so it is proof of a refusal rather than an inference from the
|
|
437
|
+
// environment — the only evidence available under an agent whose sandbox
|
|
438
|
+
// sets no variable `isSandbox()` reads.
|
|
439
|
+
const refused = code === socket_refused_exit_code_1.SOCKET_REFUSED_EXIT_CODE;
|
|
440
|
+
earlyExitError = markWorkerStartupFailure(new Error([
|
|
441
|
+
`Plugin worker for "${name}" exited with code ${code} before the connection was established.`,
|
|
442
|
+
// The worker's own stderr may be lost with the process, so the
|
|
443
|
+
// cause and the fix are repeated here.
|
|
444
|
+
...(refused || (0, is_sandbox_1.isSandbox)()
|
|
445
|
+
? (0, sandbox_socket_hint_1.sandboxSocketHint)({ certain: refused })
|
|
446
|
+
: []),
|
|
447
|
+
].join('\n')), refused);
|
|
417
448
|
abortController.abort();
|
|
418
449
|
}
|
|
419
450
|
});
|
|
@@ -429,7 +460,34 @@ async function connectToWorker(worker, ipcPath, name) {
|
|
|
429
460
|
if (earlyExitError) {
|
|
430
461
|
throw earlyExitError;
|
|
431
462
|
}
|
|
432
|
-
throw new Error(`Failed to start plugin worker for plugin ${name}`);
|
|
463
|
+
throw markWorkerStartupFailure(new Error(`Failed to start plugin worker for plugin ${name}`));
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Marks a failure to *start or reach* a worker, as distinct from a plugin that
|
|
467
|
+
* loaded and then threw. Only the former can be retried in-process: swallowing
|
|
468
|
+
* the latter would rerun a plugin that already failed on its own merits and
|
|
469
|
+
* bury the real error.
|
|
470
|
+
*/
|
|
471
|
+
exports.PLUGIN_WORKER_STARTUP_FAILURE = Symbol.for('nx.pluginWorkerStartupFailure');
|
|
472
|
+
/**
|
|
473
|
+
* Set when the worker exited with the socket-refused code. Narrower than
|
|
474
|
+
* {@link PLUGIN_WORKER_STARTUP_FAILURE}, which covers every way a worker can
|
|
475
|
+
* fail to come up, and is what lets the caller degrade on a refusal without
|
|
476
|
+
* also degrading for an OOM kill or a broken install.
|
|
477
|
+
*/
|
|
478
|
+
exports.PLUGIN_WORKER_SOCKET_REFUSED = Symbol.for('nx.pluginWorkerSocketRefused');
|
|
479
|
+
function markWorkerStartupFailure(error, refused = false) {
|
|
480
|
+
error[exports.PLUGIN_WORKER_STARTUP_FAILURE] = true;
|
|
481
|
+
if (refused) {
|
|
482
|
+
error[exports.PLUGIN_WORKER_SOCKET_REFUSED] = true;
|
|
483
|
+
}
|
|
484
|
+
return error;
|
|
485
|
+
}
|
|
486
|
+
function isPluginWorkerStartupFailure(error) {
|
|
487
|
+
return Boolean(error?.[exports.PLUGIN_WORKER_STARTUP_FAILURE]);
|
|
488
|
+
}
|
|
489
|
+
function isPluginWorkerSocketRefusal(error) {
|
|
490
|
+
return Boolean(error?.[exports.PLUGIN_WORKER_SOCKET_REFUSED]);
|
|
433
491
|
}
|
|
434
492
|
function getTypeName(u) {
|
|
435
493
|
if (u === null)
|
|
@@ -6,7 +6,6 @@ exports.isPluginWorkerResult = isPluginWorkerResult;
|
|
|
6
6
|
exports.consumeMessage = consumeMessage;
|
|
7
7
|
exports.sendMessageOverSocket = sendMessageOverSocket;
|
|
8
8
|
const socket_utils_1 = require("../../../daemon/socket-utils");
|
|
9
|
-
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
|
10
9
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
11
10
|
const NOTIFICATION_TYPES = [
|
|
12
11
|
'emitLog',
|
|
@@ -84,6 +83,5 @@ async function consumeMessage(socket, raw, handlers) {
|
|
|
84
83
|
function sendMessageOverSocket(socket, message) {
|
|
85
84
|
// Stamped here rather than in each constructor, mirroring the daemon.
|
|
86
85
|
message.workspaceRoot = workspace_root_1.workspaceRoot;
|
|
87
|
-
|
|
88
|
-
socket.write(consume_messages_from_socket_1.MESSAGE_END_SEQ);
|
|
86
|
+
(0, socket_utils_1.sendMessage)(socket, message);
|
|
89
87
|
}
|
|
@@ -14,6 +14,10 @@ const fs_1 = require("fs");
|
|
|
14
14
|
const net_1 = require("net");
|
|
15
15
|
const analytics_1 = require("../../../analytics");
|
|
16
16
|
const daemon_environment_1 = require("../../../daemon/client/daemon-environment");
|
|
17
|
+
const sandbox_socket_hint_1 = require("../../../daemon/sandbox-socket-hint");
|
|
18
|
+
const permission_errors_1 = require("../../../utils/permission-errors");
|
|
19
|
+
const socket_refused_exit_code_1 = require("../../../utils/socket-refused-exit-code");
|
|
20
|
+
const is_sandbox_1 = require("../../../utils/is-sandbox");
|
|
17
21
|
require("../../../utils/perf-logging");
|
|
18
22
|
const environment = process.env;
|
|
19
23
|
(0, analytics_1.startAnalytics)();
|
|
@@ -88,7 +92,8 @@ const server = (0, net_1.createServer)((socket) => {
|
|
|
88
92
|
exclude: plugin.exclude,
|
|
89
93
|
createNodesPattern: plugin.createNodes?.[0],
|
|
90
94
|
hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
|
|
91
|
-
hasProcessProjectGraph: 'processProjectGraph' in plugin &&
|
|
95
|
+
hasProcessProjectGraph: 'processProjectGraph' in plugin &&
|
|
96
|
+
!!plugin.processProjectGraph,
|
|
92
97
|
hasCreateMetadata: 'createMetadata' in plugin && !!plugin.createMetadata,
|
|
93
98
|
hasPreTasksExecution: 'preTasksExecution' in plugin && !!plugin.preTasksExecution,
|
|
94
99
|
hasPostTasksExecution: 'postTasksExecution' in plugin && !!plugin.postTasksExecution,
|
|
@@ -117,6 +122,13 @@ const server = (0, net_1.createServer)((socket) => {
|
|
|
117
122
|
(0, daemon_environment_1.applyDaemonEnvFromClient)(env);
|
|
118
123
|
}),
|
|
119
124
|
});
|
|
125
|
+
}, (err) => {
|
|
126
|
+
// The host link cannot resynchronize. Exit so the host's 'exit' handler
|
|
127
|
+
// rejects the pending hooks instead of waiting on a reply that the
|
|
128
|
+
// framing failure guarantees will never arrive.
|
|
129
|
+
console.error(err.message);
|
|
130
|
+
socket.destroy();
|
|
131
|
+
process.exit(1);
|
|
120
132
|
}));
|
|
121
133
|
// When the host disconnects, clean up and exit.
|
|
122
134
|
socket.on('end', () => {
|
|
@@ -132,7 +144,16 @@ server.on('error', (err) => {
|
|
|
132
144
|
// Without this the host only sees "exited before the connection was
|
|
133
145
|
// established"; the errno distinguishes a denied bind from EADDRINUSE.
|
|
134
146
|
console.error(`[plugin-worker] "${expectedPluginName}" (pid: ${process.pid}) failed to listen on ${socketPath}: ${err.message}`);
|
|
135
|
-
|
|
147
|
+
// A bind can fail for reasons permission does not explain (EADDRINUSE from a
|
|
148
|
+
// leftover socket, ENOENT from a reaped socket dir), so print the hint only
|
|
149
|
+
// when the errno proves a refusal or the environment says a sandbox is here.
|
|
150
|
+
const refusedByOs = (0, permission_errors_1.isPermissionDenied)(err);
|
|
151
|
+
if (refusedByOs || (0, is_sandbox_1.isSandbox)()) {
|
|
152
|
+
console.error((0, sandbox_socket_hint_1.sandboxSocketHint)({ certain: refusedByOs }).join('\n'));
|
|
153
|
+
}
|
|
154
|
+
// The host cannot see this errno, and stderr may be lost with the process, so
|
|
155
|
+
// the exit code is what tells it a refusal happened rather than a crash.
|
|
156
|
+
process.exit(refusedByOs ? socket_refused_exit_code_1.SOCKET_REFUSED_EXIT_CODE : 1);
|
|
136
157
|
});
|
|
137
158
|
// A worker killed without its 'end' handler leaves the socket behind. Colliding
|
|
138
159
|
// takes a recycled host pid landing on the same counter *and* the same 4 random
|
|
@@ -14,12 +14,14 @@ const analytics_1 = require("../analytics");
|
|
|
14
14
|
const nx_json_1 = require("../config/nx-json");
|
|
15
15
|
const client_1 = require("../daemon/client/client");
|
|
16
16
|
const is_on_daemon_1 = require("../daemon/is-on-daemon");
|
|
17
|
+
const sandbox_socket_hint_1 = require("../daemon/sandbox-socket-hint");
|
|
17
18
|
const tmp_dir_1 = require("../daemon/tmp-dir");
|
|
18
19
|
const native_1 = require("../native");
|
|
19
20
|
const cache_directory_1 = require("../utils/cache-directory");
|
|
20
21
|
const call_sites_1 = require("../utils/call-sites");
|
|
21
22
|
const delayed_spinner_1 = require("../utils/delayed-spinner");
|
|
22
23
|
const fileutils_1 = require("../utils/fileutils");
|
|
24
|
+
const is_sandbox_1 = require("../utils/is-sandbox");
|
|
23
25
|
const logger_1 = require("../utils/logger");
|
|
24
26
|
const output_1 = require("../utils/output");
|
|
25
27
|
const strip_indents_1 = require("../utils/strip-indents");
|
|
@@ -376,15 +378,38 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
|
376
378
|
}
|
|
377
379
|
if (e.internalDaemonError) {
|
|
378
380
|
const errorLogFile = (0, tmp_dir_1.writeDaemonLogs)(e.message);
|
|
381
|
+
const sandboxed = (0, is_sandbox_1.isSandbox)();
|
|
379
382
|
output_1.output.warn({
|
|
380
383
|
title: `Nx Daemon was not able to compute the project graph.`,
|
|
381
384
|
bodyLines: [
|
|
382
385
|
`Log file with the error: ${errorLogFile}`,
|
|
386
|
+
// Inline rather than left to the log file, which an agent will
|
|
387
|
+
// not open. This branch covers every internal daemon error,
|
|
388
|
+
// including ones a sandbox cannot explain, so the issue link stays
|
|
389
|
+
// either way.
|
|
390
|
+
...(sandboxed ? (0, sandbox_socket_hint_1.sandboxSocketHint)() : []),
|
|
383
391
|
`Please file an issue at https://github.com/nrwl/nx`,
|
|
384
|
-
|
|
392
|
+
sandboxed
|
|
393
|
+
? 'Nx Daemon is disabled for this command.'
|
|
394
|
+
: 'Nx Daemon is going to be disabled until you run "nx reset".',
|
|
385
395
|
],
|
|
386
396
|
});
|
|
387
|
-
|
|
397
|
+
// A sandbox refusal describes the environment, not the workspace. The
|
|
398
|
+
// on-disk marker would follow the checkout into an ordinary terminal
|
|
399
|
+
// and survive the user fixing their allowlist, since only `nx reset`
|
|
400
|
+
// clears it.
|
|
401
|
+
if (sandboxed) {
|
|
402
|
+
(0, tmp_dir_1.disableDaemonForThisProcess)(e.message);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
(0, tmp_dir_1.markDaemonAsDisabled)(e.message);
|
|
406
|
+
}
|
|
407
|
+
// Both writes are only read through `isDaemonDisabled()`, which
|
|
408
|
+
// `enabled()` consults once and then memoizes. Without clearing that,
|
|
409
|
+
// every later daemon consumer in this process — task hashing, workspace
|
|
410
|
+
// context, sync generators — starts the daemon again and waits out the
|
|
411
|
+
// full connect budget, under a warning saying it is off.
|
|
412
|
+
client_1.daemonClient.reset();
|
|
388
413
|
return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
389
414
|
}
|
|
390
415
|
handleProjectGraphError(opts, e);
|
|
@@ -4,6 +4,13 @@ export { validateProject } from './target-normalization';
|
|
|
4
4
|
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean, deferSpreadsWithoutBase?: boolean): {
|
|
5
5
|
nameChanged: boolean;
|
|
6
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* The existing target names a glob-pattern target key merges onto. This maps
|
|
9
|
+
* atomized targets to the glob pattern the same way targetDefaults does.
|
|
10
|
+
* Returns an empty array for a non-glob key or a pattern matching nothing;
|
|
11
|
+
* the merge treats those as literal target names.
|
|
12
|
+
*/
|
|
13
|
+
export declare function findMatchingTargetNames(pattern: string, targetNames: string[]): string[];
|
|
7
14
|
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
|
8
15
|
export declare function createRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, string>;
|
|
9
16
|
/**
|