nx 23.1.0 → 23.1.2
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/dist/bin/nx.js +2 -1
- package/dist/release/changelog-renderer/index.js +4 -5
- package/dist/release/index.d.ts +1 -1
- package/dist/src/ai/configure-ai-agents-disclaimer.d.ts +5 -0
- package/dist/src/ai/configure-ai-agents-disclaimer.js +31 -0
- package/dist/src/analytics/analytics.d.ts +6 -0
- package/dist/src/analytics/analytics.js +16 -8
- 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 +13 -1
- package/dist/src/command-line/affected/affected.js +1 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
- 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 +2 -3
- package/dist/src/command-line/init/ai-agent-prompts.d.ts +1 -1
- package/dist/src/command-line/init/ai-agent-prompts.js +7 -6
- package/dist/src/command-line/init/command-object.js +10 -2
- package/dist/src/command-line/init/configure-plugins.js +3 -2
- package/dist/src/command-line/init/implementation/add-nx-to-monorepo.js +4 -2
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +4 -3
- package/dist/src/command-line/init/implementation/add-nx-to-npm-repo.js +4 -3
- package/dist/src/command-line/init/implementation/add-nx-to-turborepo.js +4 -3
- package/dist/src/command-line/init/implementation/angular/index.js +4 -2
- 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 +3 -0
- package/dist/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +4 -1
- package/dist/src/command-line/init/implementation/utils.d.ts +3 -3
- package/dist/src/command-line/init/implementation/utils.js +22 -3
- package/dist/src/command-line/init/init-v2.js +4 -5
- package/dist/src/command-line/migrate/execute-migration.d.ts +72 -0
- package/dist/src/command-line/migrate/execute-migration.js +389 -0
- package/dist/src/command-line/migrate/migrate-ui-api.js +17 -12
- package/dist/src/command-line/migrate/migrate.d.ts +5 -45
- package/dist/src/command-line/migrate/migrate.js +122 -402
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +1 -1
- package/dist/src/command-line/nx-cloud/connect/view-logs.js +2 -0
- package/dist/src/command-line/release/changelog.js +5 -0
- package/dist/src/command-line/release/index.d.ts +1 -1
- package/dist/src/command-line/release/utils/git.js +7 -3
- package/dist/src/command-line/release/utils/release-graph.d.ts +19 -2
- package/dist/src/command-line/release/utils/release-graph.js +71 -19
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +7 -1
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +1 -1
- package/dist/src/command-line/release/utils/shared.d.ts +2 -2
- 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/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 +9 -5
- 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/info.js +11 -2
- 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 +1 -1
- package/dist/src/commands-runner/create-command-graph.js +5 -0
- package/dist/src/config/nx-json.d.ts +5 -3
- 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 -3
- package/dist/src/daemon/client/client.js +177 -55
- 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 +96 -3
- package/dist/src/devkit-internals.js +200 -4
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.d.ts +5 -0
- package/dist/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +9 -2
- package/dist/src/generators/tree.d.ts +4 -2
- package/dist/src/generators/utils/nx-json.js +13 -3
- 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-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 +31 -2
- 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/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/onboarding.js +5 -2
- package/dist/src/plugins/js/lock-file/bun-parser.js +43 -10
- package/dist/src/plugins/js/lock-file/npm-parser.js +71 -27
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +110 -17
- package/dist/src/plugins/js/lock-file/project-graph-pruning.js +15 -9
- package/dist/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -0
- package/dist/src/plugins/js/lock-file/yarn-parser.js +32 -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/plugins/js/utils/register.d.ts +18 -0
- package/dist/src/plugins/js/utils/register.js +81 -0
- package/dist/src/plugins/js/utils/typescript.d.ts +9 -0
- package/dist/src/plugins/js/utils/typescript.js +15 -0
- 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 +68 -3
- package/dist/src/project-graph/file-utils.js +6 -1
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.d.ts +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +22 -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/plugins/transpiler.js +4 -0
- package/dist/src/project-graph/project-graph.js +23 -0
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +10 -12
- package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +93 -63
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +5 -8
- package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +16 -15
- 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 -101
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +11 -4
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +15 -6
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +5 -4
- package/dist/src/tasks-runner/life-cycles/performance-report.d.ts +18 -8
- package/dist/src/tasks-runner/life-cycles/performance-report.js +66 -29
- package/dist/src/tasks-runner/run-command.js +4 -2
- 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 +4 -1
- package/dist/src/tasks-runner/task-orchestrator.js +23 -10
- package/dist/src/tasks-runner/utils.js +2 -6
- package/dist/src/utils/acknowledge-build-scripts.d.ts +13 -0
- package/dist/src/utils/acknowledge-build-scripts.js +102 -0
- package/dist/src/utils/analytics-prompt.d.ts +0 -6
- package/dist/src/utils/analytics-prompt.js +0 -51
- package/dist/src/utils/assert-workspace-validity.js +7 -2
- package/dist/src/utils/catalog/manager-utils.d.ts +1 -2
- package/dist/src/utils/catalog/manager-utils.js +22 -5
- package/dist/src/utils/catalog/pnpm-manager.d.ts +1 -0
- package/dist/src/utils/catalog/pnpm-manager.js +3 -15
- package/dist/src/utils/catalog/yarn-manager.d.ts +1 -0
- package/dist/src/utils/catalog/yarn-manager.js +3 -15
- package/dist/src/utils/command-line-utils.js +30 -20
- package/dist/src/utils/fileutils.d.ts +5 -0
- package/dist/src/utils/fileutils.js +7 -2
- package/dist/src/utils/git-revision.d.ts +12 -0
- package/dist/src/utils/git-revision.js +25 -0
- package/dist/src/utils/git-utils.d.ts +16 -3
- package/dist/src/utils/git-utils.js +146 -52
- package/dist/src/utils/git-worktrees.d.ts +30 -0
- package/dist/src/utils/git-worktrees.js +212 -0
- package/dist/src/utils/ignore.d.ts +128 -1
- package/dist/src/utils/ignore.js +182 -12
- 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/behavior/pnpm.js +9 -7
- package/dist/src/utils/min-release-age/packument.js +1 -1
- 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/owned-private-dir.d.ts +132 -0
- package/dist/src/utils/owned-private-dir.js +323 -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 +264 -43
- package/dist/src/utils/provenance.js +18 -16
- 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/migrations.json +13 -1
- package/package.json +22 -17
- package/dist/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
- package/dist/src/migrations/update-17-3-0/nx-release-path.js +0 -47
- package/dist/src/utils/min-release-age/npmrc.d.ts +0 -15
- package/dist/src/utils/min-release-age/npmrc.js +0 -45
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDaemonEnv = getDaemonEnv;
|
|
4
|
+
exports.getDaemonSpawnEnv = getDaemonSpawnEnv;
|
|
4
5
|
exports.applyDaemonEnvFromClient = applyDaemonEnvFromClient;
|
|
5
6
|
const DAEMON_ENV_REQUIRED_SETTINGS = {
|
|
6
7
|
NX_PROJECT_GLOB_CACHE: 'false',
|
|
@@ -37,6 +38,12 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
37
38
|
'NX_BATCH_MODE',
|
|
38
39
|
'NX_CI_EXECUTION_ID',
|
|
39
40
|
'NX_DAEMON_PROCESS',
|
|
41
|
+
'NX_CLI_SET',
|
|
42
|
+
// Set by Nx Console on the extension host; always equals the daemon's own
|
|
43
|
+
// workspace root (foreign-workspace messages are rejected), and the daemon
|
|
44
|
+
// resolves its root at startup before any client env is applied. The spawn
|
|
45
|
+
// env keeps it so that startup resolution honors the pinned root.
|
|
46
|
+
'NX_WORKSPACE_ROOT_PATH',
|
|
40
47
|
// Nx UI/logging vars (don't affect graph structure)
|
|
41
48
|
'NX_TUI',
|
|
42
49
|
'NX_TUI_AUTO_EXIT',
|
|
@@ -46,6 +53,7 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
46
53
|
'NX_NATIVE_LOGGING',
|
|
47
54
|
'NX_PROFILE',
|
|
48
55
|
'NX_DAEMON_VERBOSE_LOGGING',
|
|
56
|
+
'NX_ORIGINAL_FORCE_COLOR',
|
|
49
57
|
// AI agent detection vars (the daemon itself is not an AI agent)
|
|
50
58
|
'CLAUDECODE',
|
|
51
59
|
'CLAUDE_CODE',
|
|
@@ -54,9 +62,12 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
54
62
|
'COMPOSER_NO_INTERACTION',
|
|
55
63
|
'OPENCODE',
|
|
56
64
|
'GEMINI_CLI',
|
|
65
|
+
'CODEX_THREAD_ID',
|
|
66
|
+
'AI_AGENT',
|
|
57
67
|
// Shell mechanics
|
|
58
68
|
'_',
|
|
59
69
|
'SHLVL',
|
|
70
|
+
'PWD',
|
|
60
71
|
'OLDPWD',
|
|
61
72
|
'SHELL_SESSION_ID',
|
|
62
73
|
'TERM_SESSION_ID',
|
|
@@ -66,6 +77,56 @@ const DAEMON_ENV_VARS_EXCLUSIONS = new Set([
|
|
|
66
77
|
'COLUMNS',
|
|
67
78
|
'LINES',
|
|
68
79
|
'TMPDIR',
|
|
80
|
+
'PROMPT',
|
|
81
|
+
// Package-manager per-invocation vars not covered by the npm_/pnpm_ prefixes
|
|
82
|
+
'INIT_CWD',
|
|
83
|
+
'COLOR',
|
|
84
|
+
// Per-shell-session state; these tools' other vars are stable or can be
|
|
85
|
+
// meaningful (e.g. fnm's FNM_DIR), so no prefix exclusion
|
|
86
|
+
'FNM_MULTISHELL_PATH',
|
|
87
|
+
'POSH_SESSION_ID',
|
|
88
|
+
'MISE_SHELL',
|
|
89
|
+
// Editor preference; graph computation is non-interactive
|
|
90
|
+
'EDITOR',
|
|
91
|
+
'VISUAL',
|
|
92
|
+
// Output presentation
|
|
93
|
+
'PAGER',
|
|
94
|
+
'FORCE_COLOR',
|
|
95
|
+
'NO_COLOR',
|
|
96
|
+
'NODE_DISABLE_COLORS',
|
|
97
|
+
'FORCE_HYPERLINK',
|
|
98
|
+
// Terminal identification/presentation; differs per terminal app, so it
|
|
99
|
+
// churns whenever clients from different terminals share the daemon
|
|
100
|
+
'TERM',
|
|
101
|
+
'TERM_PROGRAM',
|
|
102
|
+
'TERM_PROGRAM_VERSION',
|
|
103
|
+
'COLORTERM',
|
|
104
|
+
'COLORFGBG',
|
|
105
|
+
'VTE_VERSION',
|
|
106
|
+
'GNOME_TERMINAL_SCREEN',
|
|
107
|
+
'GNOME_TERMINAL_SERVICE',
|
|
108
|
+
'WT_SESSION',
|
|
109
|
+
'WT_PROFILE_ID',
|
|
110
|
+
'TERMINAL_EMULATOR',
|
|
111
|
+
'TERMINUS_SUBLIME',
|
|
112
|
+
'ConEmuTask',
|
|
113
|
+
'ZELLIJ_PANE_ID',
|
|
114
|
+
'LC_TERMINAL',
|
|
115
|
+
'LC_TERMINAL_VERSION',
|
|
116
|
+
// Injected by VS Code and its extensions into integrated terminals. Single
|
|
117
|
+
// entries rather than GIT_/CHROME_/COPILOT_ prefixes: GIT_DIR, CHROME_BIN,
|
|
118
|
+
// COPILOT_HOME and COPILOT_GITHUB_TOKEN are functional inputs.
|
|
119
|
+
'GIT_ASKPASS',
|
|
120
|
+
'GIT_EDITOR',
|
|
121
|
+
'GIT_PAGER',
|
|
122
|
+
'GIT_MERGE_AUTOEDIT',
|
|
123
|
+
'APPLICATION_INSIGHTS_NO_STATSBEAT',
|
|
124
|
+
// Override for the @microsoft/mxc-sdk sandbox binaries; the SDK falls back
|
|
125
|
+
// to its bundled binaries when unset
|
|
126
|
+
'MXC_BIN_DIR',
|
|
127
|
+
'CHROME_CRASHPAD_PIPE_NAME',
|
|
128
|
+
'COPILOT_OTEL_FILE_EXPORTER_PATH',
|
|
129
|
+
'COPILOT_DEBUG_NONCE',
|
|
69
130
|
// Session / auth
|
|
70
131
|
'SSH_AUTH_SOCK',
|
|
71
132
|
'SSH_AGENT_PID',
|
|
@@ -103,16 +164,37 @@ const DAEMON_ENV_PREFIX_EXCLUSIONS = [
|
|
|
103
164
|
// Editors / IDEs
|
|
104
165
|
'VSCODE_',
|
|
105
166
|
'JETBRAINS_',
|
|
167
|
+
'ELECTRON_',
|
|
168
|
+
// AI agent harnesses (per-session ids; the bare CLAUDECODE/CLAUDE_CODE
|
|
169
|
+
// detection vars are excluded above)
|
|
170
|
+
'CLAUDE_CODE_',
|
|
171
|
+
// Shell prompts / integrations (per-command and per-session state)
|
|
172
|
+
'ATUIN_',
|
|
173
|
+
'STARSHIP_',
|
|
174
|
+
'MCFLY_',
|
|
175
|
+
'DIRENV_',
|
|
176
|
+
'__MISE_',
|
|
106
177
|
// Terminal emulators
|
|
107
178
|
'ITERM_',
|
|
108
179
|
'KITTY_',
|
|
109
180
|
'WEZTERM_',
|
|
110
181
|
'ALACRITTY_',
|
|
111
182
|
'KONSOLE_',
|
|
183
|
+
'GHOSTTY_',
|
|
112
184
|
'TMUX',
|
|
113
185
|
// Benchmarking / profiling tools
|
|
114
186
|
'HYPERFINE_', // hyperfine sets HYPERFINE_RANDOMIZED_ENVIRONMENT_OFFSET for each iteration
|
|
115
187
|
];
|
|
188
|
+
/**
|
|
189
|
+
* Env var name patterns that should never be sent to the daemon. For vars
|
|
190
|
+
* whose NAME embeds a process id, so neither an exact entry nor a safe
|
|
191
|
+
* prefix can match them.
|
|
192
|
+
*/
|
|
193
|
+
const DAEMON_ENV_PATTERN_EXCLUSIONS = [
|
|
194
|
+
// Set by Windows 11 explorer.exe as EFC_<pid> (observed as EFC_<pid>_<hash>
|
|
195
|
+
// in Electron-spawned shells); regenerated on every login
|
|
196
|
+
/^EFC_\d+(_\d+)?$/,
|
|
197
|
+
];
|
|
116
198
|
/**
|
|
117
199
|
* Vars that match an excluded prefix but should still reach the daemon. The
|
|
118
200
|
* Nx Cloud auth/access tokens are excluded by the `NX_CLOUD_` prefix, but
|
|
@@ -125,11 +207,14 @@ const DAEMON_ENV_PREFIX_EXCLUSION_OVERRIDES = new Set([
|
|
|
125
207
|
'NX_CLOUD_AUTH_TOKEN',
|
|
126
208
|
]);
|
|
127
209
|
function isExcludedEnvVar(key) {
|
|
210
|
+
if (DAEMON_ENV_VARS_EXCLUSIONS.has(key) ||
|
|
211
|
+
DAEMON_ENV_PATTERN_EXCLUSIONS.some((pattern) => pattern.test(key))) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
128
214
|
if (DAEMON_ENV_PREFIX_EXCLUSION_OVERRIDES.has(key)) {
|
|
129
215
|
return false;
|
|
130
216
|
}
|
|
131
|
-
return (
|
|
132
|
-
DAEMON_ENV_PREFIX_EXCLUSIONS.some((prefix) => key.startsWith(prefix)));
|
|
217
|
+
return DAEMON_ENV_PREFIX_EXCLUSIONS.some((prefix) => key.startsWith(prefix));
|
|
133
218
|
}
|
|
134
219
|
function getDaemonEnv() {
|
|
135
220
|
const env = { ...DAEMON_ENV_OVERRIDABLE_SETTINGS };
|
|
@@ -140,6 +225,29 @@ function getDaemonEnv() {
|
|
|
140
225
|
}
|
|
141
226
|
return Object.assign(env, DAEMON_ENV_REQUIRED_SETTINGS);
|
|
142
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Env for spawning the daemon process. On top of the reflected env, it must
|
|
230
|
+
* keep excluded vars the daemon needs to start correctly:
|
|
231
|
+
* - ELECTRON_RUN_AS_NODE (matched by the ELECTRON_ prefix exclusion): when
|
|
232
|
+
* the spawning client runs inside an Electron host, process.execPath is
|
|
233
|
+
* the Electron binary and only this var makes it run the daemon's Node
|
|
234
|
+
* entry point.
|
|
235
|
+
* - NX_WORKSPACE_ROOT_PATH: the daemon resolves its workspace root at
|
|
236
|
+
* startup by walking up from cwd looking for workspace markers; without
|
|
237
|
+
* the pin, a root without markers under an ancestor that has them
|
|
238
|
+
* resolves to the ancestor and the daemon publishes its socket under the
|
|
239
|
+
* wrong workspace.
|
|
240
|
+
*/
|
|
241
|
+
function getDaemonSpawnEnv() {
|
|
242
|
+
const env = getDaemonEnv();
|
|
243
|
+
if (process.env.ELECTRON_RUN_AS_NODE !== undefined) {
|
|
244
|
+
env.ELECTRON_RUN_AS_NODE = process.env.ELECTRON_RUN_AS_NODE;
|
|
245
|
+
}
|
|
246
|
+
if (process.env.NX_WORKSPACE_ROOT_PATH !== undefined) {
|
|
247
|
+
env.NX_WORKSPACE_ROOT_PATH = process.env.NX_WORKSPACE_ROOT_PATH;
|
|
248
|
+
}
|
|
249
|
+
return env;
|
|
250
|
+
}
|
|
143
251
|
/**
|
|
144
252
|
* Without the deletion step, a var set by one client (e.g.
|
|
145
253
|
* `NX_PREFER_NODE_STRIP_TYPES=true` or `JAVA_TOOL_OPTIONS=...` for a single
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DaemonSocketMessenger = exports.VersionMismatchError = void 0;
|
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
|
5
5
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
6
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
7
8
|
const socket_utils_1 = require("../socket-utils");
|
|
8
9
|
class VersionMismatchError extends Error {
|
|
@@ -21,6 +22,9 @@ class DaemonSocketMessenger {
|
|
|
21
22
|
if (!this.socket) {
|
|
22
23
|
throw new Error('Socket not initialized.');
|
|
23
24
|
}
|
|
25
|
+
// Stamp every message with the sending workspace's root so the daemon can
|
|
26
|
+
// reject messages from a different workspace (e.g. a shared NX_SOCKET_DIR).
|
|
27
|
+
messageToDaemon.workspaceRoot = workspace_root_1.workspaceRoot;
|
|
24
28
|
logger_1.clientLogger.log('[Messenger] Sending message type:', messageToDaemon.type);
|
|
25
29
|
perf_hooks_1.performance.mark('daemon-message-serialization-start-' + messageToDaemon.type);
|
|
26
30
|
const serialized = (0, socket_utils_1.serialize)(messageToDaemon, force);
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
export type DaemonMessage = {
|
|
2
2
|
type: string;
|
|
3
3
|
env?: Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Stamped centrally by `DaemonSocketMessenger.sendMessage`, not by the ~30
|
|
6
|
+
* sites that construct messages — hence optional. It can also be absent on a
|
|
7
|
+
* message that predates the field, which is why `isForeignWorkspaceMessage`
|
|
8
|
+
* treats `undefined` as "not foreign".
|
|
9
|
+
*/
|
|
10
|
+
workspaceRoot?: string;
|
|
4
11
|
data?: any;
|
|
5
12
|
};
|
|
6
13
|
export declare function isDaemonMessage(msg: unknown): msg is DaemonMessage;
|
|
14
|
+
/**
|
|
15
|
+
* Any message carrying the sender's workspace root. Structural so the checks
|
|
16
|
+
* below serve the daemon and the plugin worker without either importing the
|
|
17
|
+
* other's message type. `type` is required only so the type is not all-optional,
|
|
18
|
+
* which would accept `{}`.
|
|
19
|
+
*/
|
|
20
|
+
type WorkspaceScopedMessage = {
|
|
21
|
+
type: string;
|
|
22
|
+
workspaceRoot?: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A message from a different workspace — two sharing an NX_SOCKET_DIR — must not
|
|
26
|
+
* be processed. Compared directly; both come from the same resolution.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isForeignWorkspaceMessage(msg: WorkspaceScopedMessage, receiverWorkspaceRoot: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Throws on a message this receiver must not act on. The daemon catches it and
|
|
31
|
+
* responds with the mismatch; the plugin worker catches it and drops the
|
|
32
|
+
* message. `receiverDescription` names whichever raised it.
|
|
33
|
+
*
|
|
34
|
+
* An unstamped message is deliberately accepted: this is accident detection,
|
|
35
|
+
* not a control.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertNotForeignWorkspaceMessage(msg: WorkspaceScopedMessage, receiverWorkspaceRoot: string, receiverDescription?: string): void;
|
|
38
|
+
export {};
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isDaemonMessage = isDaemonMessage;
|
|
4
|
+
exports.isForeignWorkspaceMessage = isForeignWorkspaceMessage;
|
|
5
|
+
exports.assertNotForeignWorkspaceMessage = assertNotForeignWorkspaceMessage;
|
|
4
6
|
function isDaemonMessage(msg) {
|
|
5
7
|
return typeof msg === 'object' && msg && 'type' in msg;
|
|
6
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A message from a different workspace — two sharing an NX_SOCKET_DIR — must not
|
|
11
|
+
* be processed. Compared directly; both come from the same resolution.
|
|
12
|
+
*/
|
|
13
|
+
function isForeignWorkspaceMessage(msg, receiverWorkspaceRoot) {
|
|
14
|
+
if (msg.workspaceRoot === undefined) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return msg.workspaceRoot !== receiverWorkspaceRoot;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Throws on a message this receiver must not act on. The daemon catches it and
|
|
21
|
+
* responds with the mismatch; the plugin worker catches it and drops the
|
|
22
|
+
* message. `receiverDescription` names whichever raised it.
|
|
23
|
+
*
|
|
24
|
+
* An unstamped message is deliberately accepted: this is accident detection,
|
|
25
|
+
* not a control.
|
|
26
|
+
*/
|
|
27
|
+
function assertNotForeignWorkspaceMessage(msg, receiverWorkspaceRoot, receiverDescription = `The Nx Daemon for '${receiverWorkspaceRoot}'`) {
|
|
28
|
+
if (isForeignWorkspaceMessage(msg, receiverWorkspaceRoot)) {
|
|
29
|
+
throw new Error(`${receiverDescription} received a message from a different workspace ('${msg.workspaceRoot}') and refused to process it. This usually means multiple workspaces are sharing a socket directory; ensure NX_SOCKET_DIR (or NX_DAEMON_SOCKET_DIR) is not set to a shared location.`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -9,4 +9,9 @@ export declare let registeredFileWatcherSockets: {
|
|
|
9
9
|
}[];
|
|
10
10
|
export declare function removeRegisteredFileWatcherSocket(socket: Socket): void;
|
|
11
11
|
export declare function hasRegisteredFileWatcherSockets(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The workspace watcher has died; no further change events will ever arrive.
|
|
14
|
+
* Registered clients are passive, so without this push they wait forever.
|
|
15
|
+
*/
|
|
16
|
+
export declare function notifyFileWatcherSocketsOfError(error: Error): void;
|
|
12
17
|
export declare function notifyFileWatcherSockets(createdFiles: string[] | null, updatedFiles: string[], deletedFiles: string[]): void;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registeredFileWatcherSockets = void 0;
|
|
4
4
|
exports.removeRegisteredFileWatcherSocket = removeRegisteredFileWatcherSocket;
|
|
5
5
|
exports.hasRegisteredFileWatcherSockets = hasRegisteredFileWatcherSockets;
|
|
6
|
+
exports.notifyFileWatcherSocketsOfError = notifyFileWatcherSocketsOfError;
|
|
6
7
|
exports.notifyFileWatcherSockets = notifyFileWatcherSockets;
|
|
7
8
|
const find_matching_projects_1 = require("../../../utils/find-matching-projects");
|
|
8
9
|
const project_graph_utils_1 = require("../../../utils/project-graph-utils");
|
|
@@ -18,6 +19,21 @@ function removeRegisteredFileWatcherSocket(socket) {
|
|
|
18
19
|
function hasRegisteredFileWatcherSockets() {
|
|
19
20
|
return exports.registeredFileWatcherSockets.length > 0;
|
|
20
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* The workspace watcher has died; no further change events will ever arrive.
|
|
24
|
+
* Registered clients are passive, so without this push they wait forever.
|
|
25
|
+
*/
|
|
26
|
+
function notifyFileWatcherSocketsOfError(error) {
|
|
27
|
+
if (!hasRegisteredFileWatcherSockets()) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
queue.sendToQueue(async () => {
|
|
31
|
+
await Promise.all(exports.registeredFileWatcherSockets.map(({ socket }) => (0, server_1.handleResult)(socket, 'FILE-WATCH-CHANGED', () => Promise.resolve({
|
|
32
|
+
description: 'File watch error',
|
|
33
|
+
response: JSON.stringify({ watcherError: error.message }),
|
|
34
|
+
}), 'json')));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
21
37
|
function notifyFileWatcherSockets(createdFiles, updatedFiles, deletedFiles) {
|
|
22
38
|
if (!hasRegisteredFileWatcherSockets()) {
|
|
23
39
|
return;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PostTasksExecutionContext, PreTasksExecutionContext } from '../../project-graph/plugins/public-api';
|
|
2
2
|
export declare function handleRunPreTasksExecution(context: PreTasksExecutionContext): Promise<{
|
|
3
|
-
error?: undefined;
|
|
4
3
|
response: NodeJS.ProcessEnv[];
|
|
5
4
|
description: string;
|
|
5
|
+
error?: undefined;
|
|
6
6
|
} | {
|
|
7
7
|
response?: undefined;
|
|
8
8
|
error: any;
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLatestNxTmpPath = getLatestNxTmpPath;
|
|
4
4
|
exports.cleanupLatestNx = cleanupLatestNx;
|
|
5
|
-
|
|
5
|
+
// Import from the defining module, not the devkit-internals barrel: the barrel
|
|
6
|
+
// eagerly pulls in the task-execution subsystem and instantiates a daemon
|
|
7
|
+
// client, all of which would stay resident for the daemon server's lifetime.
|
|
8
|
+
const package_json_1 = require("../../utils/package-json");
|
|
6
9
|
const package_manager_1 = require("../../utils/package-manager");
|
|
7
10
|
const provenance_1 = require("../../utils/provenance");
|
|
8
11
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
@@ -28,7 +31,7 @@ async function getLatestNxTmpPath() {
|
|
|
28
31
|
try {
|
|
29
32
|
logger_1.serverLogger.log('[LATEST-NX]: Pulling latest Nx...');
|
|
30
33
|
await (0, provenance_1.ensurePackageHasProvenance)('nx', 'latest');
|
|
31
|
-
const result = await (0,
|
|
34
|
+
const result = await (0, package_json_1.installPackageToTmpAsync)('nx', 'latest', (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot));
|
|
32
35
|
latestNxTmpPath = result.tempDir;
|
|
33
36
|
cleanupFn = result.cleanup;
|
|
34
37
|
logger_1.serverLogger.log('[LATEST-NX]: Successfully pulled latest Nx to', latestNxTmpPath);
|
|
@@ -119,6 +119,17 @@ async function handleMessage(socket, data) {
|
|
|
119
119
|
await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${unparsedPayload}`));
|
|
120
120
|
}
|
|
121
121
|
logger_1.serverLogger.log(`Received ${mode} message of type ${payload.type}`);
|
|
122
|
+
// A mismatch means the client reached the wrong daemon (e.g. a shared
|
|
123
|
+
// NX_SOCKET_DIR). Respond, but stay alive for our own workspace.
|
|
124
|
+
if ((0, daemon_message_1.isDaemonMessage)(payload)) {
|
|
125
|
+
try {
|
|
126
|
+
(0, daemon_message_1.assertNotForeignWorkspaceMessage)(payload, workspace_root_1.workspaceRoot);
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
await (0, shutdown_utils_1.respondWithError)(socket, `Workspace root mismatch`, e);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
122
133
|
if ((0, daemon_message_1.isDaemonMessage)(payload) && payload.env) {
|
|
123
134
|
const changedEnvKeys = (0, daemon_environment_1.applyDaemonEnvFromClient)(payload.env);
|
|
124
135
|
if (changedEnvKeys.length > 0) {
|
|
@@ -325,6 +336,7 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
|
325
336
|
logger_1.serverLogger.watcherLog('Unexpected workspace watcher error', error.message);
|
|
326
337
|
console.error(error);
|
|
327
338
|
workspaceWatcherError = error;
|
|
339
|
+
(0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(error);
|
|
328
340
|
return;
|
|
329
341
|
}
|
|
330
342
|
logger_1.serverLogger.watcherLog((0, watcher_1.convertChangeEventsToLogMessage)(changeEvents));
|
|
@@ -334,6 +346,7 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
|
334
346
|
logger_1.serverLogger.watcherLog(`Unexpected workspace error`, err.message);
|
|
335
347
|
console.error(err);
|
|
336
348
|
workspaceWatcherError = err;
|
|
349
|
+
(0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(err);
|
|
337
350
|
}
|
|
338
351
|
};
|
|
339
352
|
const handleOutputsChanges = async (err, changeEvents) => {
|
|
@@ -360,6 +373,13 @@ const handleOutputsChanges = async (err, changeEvents) => {
|
|
|
360
373
|
}
|
|
361
374
|
};
|
|
362
375
|
async function startServer() {
|
|
376
|
+
// Watch before scan: a file written during boot must be visible to the
|
|
377
|
+
// watcher or the scan below. Scan-first left a blind window where such
|
|
378
|
+
// files stayed invisible to both until an unrelated change arrived.
|
|
379
|
+
if (!(0, shutdown_utils_1.getWatcherInstance)()) {
|
|
380
|
+
(0, shutdown_utils_1.storeWatcherInstance)(await (0, watcher_1.watchWorkspace)(server, handleWorkspaceChanges));
|
|
381
|
+
logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot} (native)`);
|
|
382
|
+
}
|
|
363
383
|
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
364
384
|
// Initialize analytics for daemon process
|
|
365
385
|
await (0, analytics_1.startAnalytics)();
|
|
@@ -416,12 +436,19 @@ async function startServer() {
|
|
|
416
436
|
server.listen(socketPath, async () => {
|
|
417
437
|
try {
|
|
418
438
|
logger_1.serverLogger.log(`Started listening on: ${socketPath}`);
|
|
439
|
+
// Linux gates connect() on write permission to the socket file; macOS/BSD gate
|
|
440
|
+
// on the directory, which is already 0700. Done after listen because
|
|
441
|
+
// net.Server.listen takes no mode and umask is process-global.
|
|
442
|
+
if (!socket_utils_1.isWindows) {
|
|
443
|
+
try {
|
|
444
|
+
(0, fs_1.chmodSync)(socketPath, 0o600);
|
|
445
|
+
}
|
|
446
|
+
catch {
|
|
447
|
+
// Best effort; the 0700 socket directory is the primary control.
|
|
448
|
+
}
|
|
449
|
+
}
|
|
419
450
|
// this triggers the storage of the lock file hash
|
|
420
451
|
daemonIsOutdated();
|
|
421
|
-
if (!(0, shutdown_utils_1.getWatcherInstance)()) {
|
|
422
|
-
(0, shutdown_utils_1.storeWatcherInstance)(await (0, watcher_1.watchWorkspace)(server, handleWorkspaceChanges));
|
|
423
|
-
logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot} (native)`);
|
|
424
|
-
}
|
|
425
452
|
if (!(0, shutdown_utils_1.getOutputWatcherInstance)()) {
|
|
426
453
|
(0, shutdown_utils_1.storeOutputWatcherInstance)(await (0, watcher_1.watchOutputFiles)(server, handleOutputsChanges));
|
|
427
454
|
}
|
|
@@ -14,5 +14,10 @@ export declare function handleServerProcessTermination({ server, reason, sockets
|
|
|
14
14
|
export declare function handleServerProcessTerminationWithRestart({ server, reason, sockets, }: HandleServerProcessTerminationParams): Promise<void>;
|
|
15
15
|
export declare function resetInactivityTimeout(cb: () => void): void;
|
|
16
16
|
export declare function respondToClient(socket: Socket, response: string, description: string): Promise<unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Send an error to the client without terminating the daemon. Use this when the
|
|
19
|
+
* daemon should keep running for other clients after refusing a request.
|
|
20
|
+
*/
|
|
21
|
+
export declare function respondWithError(socket: Socket, description: string, error: Error): Promise<void>;
|
|
17
22
|
export declare function respondWithErrorAndExit(socket: Socket, description: string, error: Error): Promise<void>;
|
|
18
23
|
export {};
|
|
@@ -9,6 +9,7 @@ exports.handleServerProcessTermination = handleServerProcessTermination;
|
|
|
9
9
|
exports.handleServerProcessTerminationWithRestart = handleServerProcessTerminationWithRestart;
|
|
10
10
|
exports.resetInactivityTimeout = resetInactivityTimeout;
|
|
11
11
|
exports.respondToClient = respondToClient;
|
|
12
|
+
exports.respondWithError = respondWithError;
|
|
12
13
|
exports.respondWithErrorAndExit = respondWithErrorAndExit;
|
|
13
14
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
14
15
|
const logger_1 = require("../logger");
|
|
@@ -135,9 +136,12 @@ function respondToClient(socket, response, description) {
|
|
|
135
136
|
});
|
|
136
137
|
});
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Send an error to the client without terminating the daemon. Use this when the
|
|
141
|
+
* daemon should keep running for other clients after refusing a request.
|
|
142
|
+
*/
|
|
143
|
+
async function respondWithError(socket, description, error) {
|
|
144
|
+
const normalizedError = error instanceof error_types_1.DaemonProjectGraphError
|
|
141
145
|
? error_types_1.ProjectGraphError.fromDaemonProjectGraphError(error)
|
|
142
146
|
: error;
|
|
143
147
|
// print some extra stuff in the error message
|
|
@@ -145,8 +149,11 @@ async function respondWithErrorAndExit(socket, description, error) {
|
|
|
145
149
|
console.error(normalizedError.stack);
|
|
146
150
|
// Respond with the original error
|
|
147
151
|
await respondToClient(socket, (0, socket_utils_1.serializeResult)(error, null, null), null);
|
|
152
|
+
}
|
|
153
|
+
async function respondWithErrorAndExit(socket, description, error) {
|
|
154
|
+
await respondWithError(socket, description, error);
|
|
148
155
|
// Project Graph errors are okay. Restarting the daemon won't help with this.
|
|
149
|
-
if (!
|
|
156
|
+
if (!(error instanceof error_types_1.DaemonProjectGraphError)) {
|
|
150
157
|
process.exit(1);
|
|
151
158
|
}
|
|
152
159
|
}
|
|
@@ -8,6 +8,7 @@ export declare const isWindows: boolean;
|
|
|
8
8
|
export declare const getFullOsSocketPath: () => string;
|
|
9
9
|
export declare const getForkedProcessOsSocketPath: (id: string) => string;
|
|
10
10
|
export declare const getPluginOsSocketPath: (id: string) => string;
|
|
11
|
+
export declare function getPluginSocketFileName(id: string): string;
|
|
11
12
|
export declare function killSocketOrPath(): void;
|
|
12
13
|
export declare function serializeResult(error: Error | null, serializedProjectGraph: string | null, serializedSourceMaps: string | null): string | null;
|
|
13
14
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPluginOsSocketPath = exports.getForkedProcessOsSocketPath = exports.getFullOsSocketPath = exports.isWindows = void 0;
|
|
4
|
+
exports.getPluginSocketFileName = getPluginSocketFileName;
|
|
4
5
|
exports.killSocketOrPath = killSocketOrPath;
|
|
5
6
|
exports.serializeResult = serializeResult;
|
|
6
7
|
exports.serialize = serialize;
|
|
@@ -31,18 +32,38 @@ const getForkedProcessOsSocketPath = (id) => {
|
|
|
31
32
|
};
|
|
32
33
|
exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
|
|
33
34
|
const getPluginOsSocketPath = (id) => {
|
|
34
|
-
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.
|
|
35
|
+
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getPluginSocketDir)(), getPluginSocketFileName(id)));
|
|
35
36
|
assertValidSocketPath(path);
|
|
36
37
|
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + path : path;
|
|
37
38
|
};
|
|
38
39
|
exports.getPluginOsSocketPath = getPluginOsSocketPath;
|
|
40
|
+
function getPluginSocketFileName(id) {
|
|
41
|
+
return `p${id}.sock`;
|
|
42
|
+
}
|
|
39
43
|
function assertValidSocketPath(path) {
|
|
40
44
|
if (path.length > 95) {
|
|
45
|
+
const fallbackCause = (0, tmp_dir_1.getSocketDirFallbackCause)();
|
|
46
|
+
const refusedConfiguredSocketDir = (0, tmp_dir_1.getRefusedConfiguredSocketDir)();
|
|
41
47
|
throw new Error([
|
|
42
48
|
'Attempted to open socket that exceeds the maximum socket length.',
|
|
49
|
+
...(fallbackCause === undefined
|
|
50
|
+
? []
|
|
51
|
+
: [
|
|
52
|
+
`Nx fell back to ${(0, path_1.dirname)(path)} because the default socket directory could not be used.`,
|
|
53
|
+
'Run the command with --verbose to see why the default directory was rejected.',
|
|
54
|
+
]),
|
|
43
55
|
'',
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
...(refusedConfiguredSocketDir === undefined
|
|
57
|
+
? [
|
|
58
|
+
`Set NX_SOCKET_DIR to a shorter path (e.g. ${exports.isWindows ? '%TMP%/nx-tmp' : '/tmp/nx-tmp'}) to avoid this issue.`,
|
|
59
|
+
]
|
|
60
|
+
: [
|
|
61
|
+
// Saying "set a shorter path" here would be advice they already
|
|
62
|
+
// followed: they set one, and it was refused for another reason.
|
|
63
|
+
`The directory set in NX_SOCKET_DIR (${refusedConfiguredSocketDir}) could not be used — see the warning above — so Nx fell back to a longer path.`,
|
|
64
|
+
'Point NX_SOCKET_DIR at a short directory your user owns.',
|
|
65
|
+
]),
|
|
66
|
+
].join('\n'), fallbackCause === undefined ? undefined : { cause: fallbackCause });
|
|
46
67
|
}
|
|
47
68
|
}
|
|
48
69
|
function killSocketOrPath() {
|
|
@@ -1,12 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a directory was refused. Named rather than a boolean so a table entry
|
|
3
|
+
* reads as its own reason: picking the wrong one tells a user their private
|
|
4
|
+
* directory is a code-execution risk, which is the one claim here that most
|
|
5
|
+
* needs to be true.
|
|
6
|
+
*/
|
|
7
|
+
export type SocketDirRefusal = 'shared-with-other-users' | 'nx-managed' | 'os-temp-root';
|
|
8
|
+
/**
|
|
9
|
+
* Thrown when the socket dir resolves to a directory Nx will not accept.
|
|
10
|
+
* Invalid configuration, not a recoverable failure.
|
|
11
|
+
*
|
|
12
|
+
* Three reasons, and they are not interchangeable. A directory other users can
|
|
13
|
+
* reach is a security problem; the OS temp root is the user's own but holds
|
|
14
|
+
* everything else that uses it, and Nx deletes the socket directory
|
|
15
|
+
* recursively; an Nx container or cache root is refused because Nx manages what
|
|
16
|
+
* lives there. Telling someone their own `0700` directory lets a local attacker
|
|
17
|
+
* execute code would be false, which is why the reason is derived from the
|
|
18
|
+
* directory rather than the platform.
|
|
19
|
+
*/
|
|
20
|
+
export declare class InvalidSocketDirConfigured extends Error {
|
|
21
|
+
readonly dir: string;
|
|
22
|
+
readonly reason: SocketDirRefusal;
|
|
23
|
+
constructor(dir: string, reason: SocketDirRefusal);
|
|
24
|
+
}
|
|
1
25
|
export declare const DAEMON_DIR_FOR_CURRENT_WORKSPACE: string;
|
|
2
26
|
export declare const DAEMON_OUTPUT_LOG_FILE: string;
|
|
3
27
|
export declare const getDaemonSocketDir: () => string;
|
|
4
28
|
export declare function writeDaemonLogs(error?: string): string;
|
|
5
29
|
export declare function markDaemonAsDisabled(reason: string): void;
|
|
6
30
|
export declare function isDaemonDisabled(): boolean;
|
|
31
|
+
export declare function getSocketDir(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Plugin worker sockets get their own workspace-scoped directory rather than
|
|
34
|
+
* sitting in the shared system temp dir, which cannot be locked down.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPluginSocketDir(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Exported for tests: both fallback warnings fire once per process, so a suite
|
|
39
|
+
* that stages either fallback more than once has to clear the latches between
|
|
40
|
+
* cases.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resetSocketDirWarningsForTesting(): void;
|
|
43
|
+
export declare function getSocketDirFallbackCause(): unknown;
|
|
7
44
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
45
|
+
* The NX_SOCKET_DIR that was refused, if that is why we are in the fallback.
|
|
46
|
+
* Reflects the most recent resolution only — both accessors are cleared at the
|
|
47
|
+
* top of every `createOwnerOnlySocketDir` call, and the daemon and plugin socket
|
|
48
|
+
* paths each drive one. Read it immediately after the call that produced the
|
|
49
|
+
* path, which is what `assertValidSocketPath` does.
|
|
10
50
|
*/
|
|
11
|
-
export declare function
|
|
51
|
+
export declare function getRefusedConfiguredSocketDir(): string | undefined;
|
|
12
52
|
export declare function removeSocketDir(): void;
|