nx 24.0.0-beta.2 → 24.0.0-beta.3
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/post-install.js +5 -3
- package/dist/src/adapter/ngcli-adapter.js +1 -2
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +23 -5
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -41
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -48
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +63 -36
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +7 -5
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +35 -5
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +5 -5
- package/dist/src/command-line/migrate/command-object.js +3 -3
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +12 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +26 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +9 -10
- package/dist/src/command-line/migrate/migrate-commits.js +25 -18
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.js +16 -27
- package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
- package/dist/src/command-line/migrate/run/agent-output.js +4 -0
- package/dist/src/command-line/migrate/run/broker.js +1 -1
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +2 -1
- package/dist/src/command-line/migrate/run/index.js +5 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +233 -92
- package/dist/src/command-line/migrate/run/run-state.d.ts +4 -1
- package/dist/src/command-line/migrate/run/run-state.js +20 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +99 -21
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/util.d.ts +4 -2
- package/dist/src/command-line/migrate/run/util.js +23 -2
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/nx-json.d.ts +8 -5
- package/dist/src/config/workspace-json-project-json.d.ts +12 -9
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/devkit-exports.d.ts +4 -0
- package/dist/src/devkit-exports.js +6 -1
- package/dist/src/devkit-internals.d.ts +1 -1
- package/dist/src/devkit-internals.js +4 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +20 -10
- package/dist/src/executors/run-commands/running-tasks.d.ts +12 -3
- package/dist/src/executors/run-commands/running-tasks.js +22 -18
- package/dist/src/hasher/check-task-files.js +1 -4
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +7 -6
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/index.d.ts +3 -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/plugins/js/lock-file/pnpm-parser.js +1 -3
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +6 -5
- package/dist/src/project-graph/affected/affected-tasks.js +16 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +7 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/tasks-runner/readiness/probes.js +30 -1
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +31 -10
- package/dist/src/tasks-runner/readiness/ready-when.js +178 -41
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -0
- package/dist/src/tasks-runner/task-orchestrator.js +113 -38
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +15 -1
- package/dist/src/tasks-runner/utils.js +79 -33
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/migrations.json +13 -6
- package/package.json +11 -11
- package/schemas/nx-schema.json +17 -11
- package/schemas/project-schema.json +8 -7
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const format_changed_files_1 = require("../../generators/internal-utils/format-changed-files");
|
|
5
|
+
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
|
6
|
+
const RENAMED_ULTRACACHE_KEYS = new Map([
|
|
7
|
+
['ignoredReads', 'ignoreReads'],
|
|
8
|
+
['ignoredWrites', 'ignoreWrites'],
|
|
9
|
+
]);
|
|
10
|
+
const WORKFLOWS_DIR = '.nx/workflows';
|
|
11
|
+
const CONFIG_EXTENSIONS = ['yaml', 'yml'];
|
|
12
|
+
const OLD_CONFIG_PATH = /(\.nx\/workflows\/)sandboxing-config\.(ya?ml)/g;
|
|
13
|
+
// Matches a block-style key at the start of a line or after a sequence dash,
|
|
14
|
+
// optionally quoted. Comments and values are left alone.
|
|
15
|
+
const OLD_YAML_KEY = /^(\s*(?:-\s+)?)(['"]?)exclude-(reads|writes)\2(\s*:)/gm;
|
|
16
|
+
async function update(tree) {
|
|
17
|
+
const manual = [];
|
|
18
|
+
for (const [name, project] of (0, project_configuration_1.getProjects)(tree)) {
|
|
19
|
+
let changed = false;
|
|
20
|
+
for (const target of Object.values(project.targets ?? {})) {
|
|
21
|
+
changed = renameUltracacheKeys(target) || changed;
|
|
22
|
+
}
|
|
23
|
+
const rewritten = rewriteConfigPaths(project);
|
|
24
|
+
if (changed || rewritten !== project) {
|
|
25
|
+
(0, project_configuration_1.updateProjectConfiguration)(tree, name, rewritten);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const nxJson = (0, project_configuration_1.readNxJson)(tree);
|
|
29
|
+
if (nxJson) {
|
|
30
|
+
let changed = false;
|
|
31
|
+
for (const value of Object.values(nxJson.targetDefaults ?? {})) {
|
|
32
|
+
for (const entry of targetDefaultEntries(value)) {
|
|
33
|
+
changed = renameUltracacheKeys(entry) || changed;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const rewritten = rewriteConfigPaths(nxJson);
|
|
37
|
+
if (changed || rewritten !== nxJson) {
|
|
38
|
+
(0, project_configuration_1.updateNxJson)(tree, rewritten);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
manual.push(...renameWorkspaceConfig(tree));
|
|
42
|
+
await (0, format_changed_files_1.formatChangedFiles)(tree);
|
|
43
|
+
if (manual.length === 0) {
|
|
44
|
+
return { skipAgentic: true };
|
|
45
|
+
}
|
|
46
|
+
return { nextSteps: manual, agentContext: manual };
|
|
47
|
+
}
|
|
48
|
+
function targetDefaultEntries(value) {
|
|
49
|
+
return Array.isArray(value) ? value : [value];
|
|
50
|
+
}
|
|
51
|
+
function renameUltracacheKeys(target) {
|
|
52
|
+
const ultracache = target?.ultracache;
|
|
53
|
+
if (!ultracache ||
|
|
54
|
+
typeof ultracache !== 'object' ||
|
|
55
|
+
!Object.keys(ultracache).some((key) => RENAMED_ULTRACACHE_KEYS.has(key))) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const renamed = {};
|
|
59
|
+
for (const [key, value] of Object.entries(ultracache)) {
|
|
60
|
+
const newKey = RENAMED_ULTRACACHE_KEYS.get(key) ?? key;
|
|
61
|
+
renamed[newKey] = mergePatterns(renamed[newKey], value);
|
|
62
|
+
}
|
|
63
|
+
target.ultracache = renamed;
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
// A target may already declare the new key beside the old one; keep both sets.
|
|
67
|
+
function mergePatterns(existing, incoming) {
|
|
68
|
+
if (existing === undefined) {
|
|
69
|
+
return incoming;
|
|
70
|
+
}
|
|
71
|
+
if (!Array.isArray(existing) || !Array.isArray(incoming)) {
|
|
72
|
+
return incoming;
|
|
73
|
+
}
|
|
74
|
+
return [...existing, ...incoming.filter((p) => !existing.includes(p))];
|
|
75
|
+
}
|
|
76
|
+
// Returns the same reference when nothing changed.
|
|
77
|
+
function rewriteConfigPaths(value) {
|
|
78
|
+
if (typeof value === 'string') {
|
|
79
|
+
const replaced = value.replace(OLD_CONFIG_PATH, '$1ultracache-config.$2');
|
|
80
|
+
return (replaced === value ? value : replaced);
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
const mapped = value.map(rewriteConfigPaths);
|
|
84
|
+
return (mapped.some((v, i) => v !== value[i]) ? mapped : value);
|
|
85
|
+
}
|
|
86
|
+
if (value && typeof value === 'object') {
|
|
87
|
+
let changed = false;
|
|
88
|
+
const mapped = {};
|
|
89
|
+
for (const [key, v] of Object.entries(value)) {
|
|
90
|
+
mapped[key] = rewriteConfigPaths(v);
|
|
91
|
+
changed ||= mapped[key] !== v;
|
|
92
|
+
}
|
|
93
|
+
return (changed ? mapped : value);
|
|
94
|
+
}
|
|
95
|
+
return value;
|
|
96
|
+
}
|
|
97
|
+
function renameWorkspaceConfig(tree) {
|
|
98
|
+
const existingNew = CONFIG_EXTENSIONS.map((ext) => `${WORKFLOWS_DIR}/ultracache-config.${ext}`).filter((path) => tree.exists(path));
|
|
99
|
+
const manual = [];
|
|
100
|
+
for (const ext of CONFIG_EXTENSIONS) {
|
|
101
|
+
const oldPath = `${WORKFLOWS_DIR}/sandboxing-config.${ext}`;
|
|
102
|
+
if (!tree.exists(oldPath)) {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (existingNew.length > 0) {
|
|
106
|
+
manual.push(`Both "${oldPath}" and "${existingNew[0]}" exist. Nx Cloud reads only "${existingNew[0]}", so merge the patterns from "${oldPath}" into it and delete "${oldPath}".`);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
const newPath = `${WORKFLOWS_DIR}/ultracache-config.${ext}`;
|
|
110
|
+
tree.rename(oldPath, newPath);
|
|
111
|
+
existingNew.push(newPath);
|
|
112
|
+
}
|
|
113
|
+
for (const path of existingNew) {
|
|
114
|
+
const content = tree.read(path, 'utf-8') ?? '';
|
|
115
|
+
const updated = content.replace(OLD_YAML_KEY, '$1$2ignore-$3$2$4');
|
|
116
|
+
if (updated !== content) {
|
|
117
|
+
tree.write(path, updated);
|
|
118
|
+
}
|
|
119
|
+
if (hasOldYamlKey(updated)) {
|
|
120
|
+
manual.push(`"${path}" still uses "exclude-reads" or "exclude-writes" in a form the migration could not rewrite. Rename them to "ignore-reads" and "ignore-writes".`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return manual;
|
|
124
|
+
}
|
|
125
|
+
function hasOldYamlKey(content) {
|
|
126
|
+
return content
|
|
127
|
+
.split('\n')
|
|
128
|
+
.map((line) => line.replace(/#.*$/, ''))
|
|
129
|
+
.some((line) => /['"]?exclude-(reads|writes)['"]?\s*:/.test(line));
|
|
130
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#### Rename ultracache ignore options
|
|
2
|
+
|
|
3
|
+
Nx 24 renames the `ultracache` target options `ignoredReads` and `ignoredWrites` to `ignoreReads` and `ignoreWrites`.
|
|
4
|
+
The workspace-wide exclusions file moves from `.nx/workflows/sandboxing-config.yaml` to `.nx/workflows/ultracache-config.yaml`, and its `exclude-reads` and `exclude-writes` keys become `ignore-reads` and `ignore-writes`.
|
|
5
|
+
|
|
6
|
+
This migration renames the options in every target in `project.json` files, in the `nx` block of `package.json` files, and in `targetDefaults` in `nx.json`.
|
|
7
|
+
When a target sets both the old and the new option, it combines their patterns under the new one.
|
|
8
|
+
It renames `.nx/workflows/sandboxing-config.yaml` (or `.yml`) and the keys inside it, including those in `task-exclusions` entries.
|
|
9
|
+
It also updates any `inputs` or `namedInputs` entry that points at the old file.
|
|
10
|
+
|
|
11
|
+
If `.nx/workflows/ultracache-config.yaml` already exists, the migration leaves both files in place and lists them in its next steps so you can merge them by hand.
|
|
12
|
+
It does the same when the file writes those keys in a form it can't rewrite, such as an inline `{ }` map.
|
|
13
|
+
|
|
14
|
+
#### Sample code changes
|
|
15
|
+
|
|
16
|
+
##### Before
|
|
17
|
+
|
|
18
|
+
```json title="apps/app/project.json"
|
|
19
|
+
{
|
|
20
|
+
"targets": {
|
|
21
|
+
"build": {
|
|
22
|
+
"ultracache": {
|
|
23
|
+
"ignoredReads": ["tmp/**"],
|
|
24
|
+
"ignoredWrites": ["**/.cache/**"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```yaml title=".nx/workflows/sandboxing-config.yaml"
|
|
32
|
+
exclude-reads:
|
|
33
|
+
- 'dist/**'
|
|
34
|
+
task-exclusions:
|
|
35
|
+
- target: lint
|
|
36
|
+
exclude-writes:
|
|
37
|
+
- .eslintcache/**
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
##### After
|
|
41
|
+
|
|
42
|
+
```json title="apps/app/project.json"
|
|
43
|
+
{
|
|
44
|
+
"targets": {
|
|
45
|
+
"build": {
|
|
46
|
+
"ultracache": {
|
|
47
|
+
"ignoreReads": ["tmp/**"],
|
|
48
|
+
"ignoreWrites": ["**/.cache/**"]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```yaml title=".nx/workflows/ultracache-config.yaml"
|
|
56
|
+
ignore-reads:
|
|
57
|
+
- 'dist/**'
|
|
58
|
+
task-exclusions:
|
|
59
|
+
- target: lint
|
|
60
|
+
ignore-writes:
|
|
61
|
+
- .eslintcache/**
|
|
62
|
+
```
|
|
@@ -1168,7 +1168,7 @@ export interface ProjectGraph {
|
|
|
1168
1168
|
externalNodes: Record<string, ExternalNode>
|
|
1169
1169
|
}
|
|
1170
1170
|
|
|
1171
|
-
/** Exactly one of `url`, `port` or `command` is set.
|
|
1171
|
+
/** Exactly one of `url`, `port` or `command` is set. */
|
|
1172
1172
|
export interface ReadinessProbeConfig {
|
|
1173
1173
|
url?: string
|
|
1174
1174
|
port?: number
|
|
@@ -1470,14 +1470,14 @@ export interface TaskUltracacheSettings {
|
|
|
1470
1470
|
* and `?`, `!`, `[`, `]` and extglobs are not supported; anchor the
|
|
1471
1471
|
* pattern to a directory instead of leading with `**`.
|
|
1472
1472
|
*/
|
|
1473
|
-
|
|
1473
|
+
ignoreReads?: Array<string>
|
|
1474
1474
|
/**
|
|
1475
1475
|
* Workspace-relative glob patterns for writes that should be excluded
|
|
1476
1476
|
* from ultracache reports. The first path segment cannot contain `*`,
|
|
1477
1477
|
* and `?`, `!`, `[`, `]` and extglobs are not supported; anchor the
|
|
1478
1478
|
* pattern to a directory instead of leading with `**`.
|
|
1479
1479
|
*/
|
|
1480
|
-
|
|
1480
|
+
ignoreWrites?: Array<string>
|
|
1481
1481
|
}
|
|
1482
1482
|
|
|
1483
1483
|
export interface TerminalOutputRecord {
|
|
Binary file
|
|
Binary file
|
|
@@ -603,9 +603,7 @@ function stringifyPnpmLockfile(graph, rootLockFileContent, packageJson, workspac
|
|
|
603
603
|
// relocated at its synthesis site, which is why it is added afterwards: a
|
|
604
604
|
// second pass over an already-relocated path cannot tell it apart from a
|
|
605
605
|
// workspace path that genuinely starts with the shipped directory's name.
|
|
606
|
-
|
|
607
|
-
// the copied workspace module silently supersedes the file: dependency.
|
|
608
|
-
(0, pruned_output_1.warnOnWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
|
|
606
|
+
(0, pruned_output_1.assertNoWorkspaceModulePathCollision)(snapshots, synthesizedModulePaths);
|
|
609
607
|
(0, pruned_output_1.containShippedLocalFilePaths)(output, synthesizedModulePaths);
|
|
610
608
|
// Peers pnpm left out of the importer (autoInstallPeers off) still ship as
|
|
611
609
|
// real dependencies, matching the copied manifest that moves every
|
|
@@ -148,12 +148,12 @@ export declare function normalizeLocalPathSpec(spec: string): string;
|
|
|
148
148
|
*/
|
|
149
149
|
export declare function uncontainLocalPathSpec(spec: string): string;
|
|
150
150
|
/**
|
|
151
|
-
*
|
|
151
|
+
* Throws when a workspace directory occupies the output path of a copied
|
|
152
152
|
* workspace module. Both spell `workspace_modules/<name>`, so no later pass can
|
|
153
153
|
* tell them apart: the vendored source is read as the copied module and never
|
|
154
154
|
* ships, leaving the lockfile pointing at a path the output does not carry.
|
|
155
155
|
*/
|
|
156
|
-
export declare function
|
|
156
|
+
export declare function assertNoWorkspaceModulePathCollision(sourcePackages: Record<string, unknown> | undefined, synthesizedModulePaths: ReadonlySet<string>): void;
|
|
157
157
|
/**
|
|
158
158
|
* Relocates every shippable non-workspace `file:` local-path reference in a
|
|
159
159
|
* pruned lockfile (package keys, resolutions, and snapshot/importer dependency
|
|
@@ -11,7 +11,7 @@ exports.containLocalPath = containLocalPath;
|
|
|
11
11
|
exports.uncontainLocalPath = uncontainLocalPath;
|
|
12
12
|
exports.normalizeLocalPathSpec = normalizeLocalPathSpec;
|
|
13
13
|
exports.uncontainLocalPathSpec = uncontainLocalPathSpec;
|
|
14
|
-
exports.
|
|
14
|
+
exports.assertNoWorkspaceModulePathCollision = assertNoWorkspaceModulePathCollision;
|
|
15
15
|
exports.containShippedLocalFilePaths = containShippedLocalFilePaths;
|
|
16
16
|
exports.containShippedLocalLinkRefs = containShippedLocalLinkRefs;
|
|
17
17
|
exports.getPrunedPnpmLocalPathArtifacts = getPrunedPnpmLocalPathArtifacts;
|
|
@@ -772,18 +772,18 @@ function containFileToken(token, synthesized) {
|
|
|
772
772
|
: `${token.slice(0, pathStart)}${contained}`;
|
|
773
773
|
}
|
|
774
774
|
/**
|
|
775
|
-
*
|
|
775
|
+
* Throws when a workspace directory occupies the output path of a copied
|
|
776
776
|
* workspace module. Both spell `workspace_modules/<name>`, so no later pass can
|
|
777
777
|
* tell them apart: the vendored source is read as the copied module and never
|
|
778
778
|
* ships, leaving the lockfile pointing at a path the output does not carry.
|
|
779
779
|
*/
|
|
780
|
-
function
|
|
780
|
+
function assertNoWorkspaceModulePathCollision(sourcePackages, synthesizedModulePaths) {
|
|
781
781
|
for (const snapshot of Object.values(sourcePackages ?? {})) {
|
|
782
782
|
const directory = snapshot
|
|
783
783
|
?.resolution?.directory;
|
|
784
784
|
if (typeof directory === 'string' &&
|
|
785
785
|
synthesizedModulePaths.has((0, path_2.normalizePath)(directory))) {
|
|
786
|
-
|
|
786
|
+
throw new Error(`Cannot prune pnpm lockfile: local-path dependency "file:${directory}" sits where the standalone output copies a workspace module of the same name. Move it out of ${WORKSPACE_MODULES_DIR}/ so they do not collide.`);
|
|
787
787
|
}
|
|
788
788
|
}
|
|
789
789
|
}
|
|
@@ -11,13 +11,14 @@ import { TaskPlanningContext } from '../../hasher/task-planning-context';
|
|
|
11
11
|
import type { TaskSelection } from '../../tasks-runner/run-command';
|
|
12
12
|
/**
|
|
13
13
|
* Whether `nx affected` selects the individual tasks whose inputs a change
|
|
14
|
-
* reaches, rather than whole projects.
|
|
15
|
-
*
|
|
14
|
+
* reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
|
|
15
|
+
* nx.json's `affected.legacy`.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
* script agree. The run also executes the selected tasks' dependencies.
|
|
17
|
+
* The run also executes the selected tasks' dependencies.
|
|
19
18
|
*/
|
|
20
|
-
export declare function selectsAffectedTasks(): boolean;
|
|
19
|
+
export declare function selectsAffectedTasks(nxJson: NxJsonConfiguration): boolean;
|
|
20
|
+
/** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
|
|
21
|
+
export declare function taskGranularityRequirement(): string;
|
|
21
22
|
export interface AffectedTasksResult {
|
|
22
23
|
/** The graph selection ran against, which the command should run with too. */
|
|
23
24
|
projectGraph: ProjectGraph;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.selectsAffectedTasks = selectsAffectedTasks;
|
|
4
|
+
exports.taskGranularityRequirement = taskGranularityRequirement;
|
|
4
5
|
exports.computeAffectedTasks = computeAffectedTasks;
|
|
5
6
|
exports.selectAffectedTasks = selectAffectedTasks;
|
|
6
7
|
const native_1 = require("../../native");
|
|
@@ -25,14 +26,23 @@ const npm_packages_1 = require("../../plugins/js/project-graph/affected/npm-pack
|
|
|
25
26
|
const lock_file_1 = require("../../plugins/js/lock-file/lock-file");
|
|
26
27
|
/**
|
|
27
28
|
* Whether `nx affected` selects the individual tasks whose inputs a change
|
|
28
|
-
* reaches, rather than whole projects.
|
|
29
|
-
*
|
|
29
|
+
* reaches, rather than whole projects. `NX_LEGACY_AFFECTED` overrides
|
|
30
|
+
* nx.json's `affected.legacy`.
|
|
30
31
|
*
|
|
31
|
-
*
|
|
32
|
-
* script agree. The run also executes the selected tasks' dependencies.
|
|
32
|
+
* The run also executes the selected tasks' dependencies.
|
|
33
33
|
*/
|
|
34
|
-
function selectsAffectedTasks() {
|
|
35
|
-
|
|
34
|
+
function selectsAffectedTasks(nxJson) {
|
|
35
|
+
if (process.env.NX_LEGACY_AFFECTED === 'true')
|
|
36
|
+
return false;
|
|
37
|
+
if (process.env.NX_LEGACY_AFFECTED === 'false')
|
|
38
|
+
return true;
|
|
39
|
+
return !nxJson.affected?.legacy;
|
|
40
|
+
}
|
|
41
|
+
/** What to change so {@link selectsAffectedTasks} returns true, for error messages. */
|
|
42
|
+
function taskGranularityRequirement() {
|
|
43
|
+
return process.env.NX_LEGACY_AFFECTED === 'true'
|
|
44
|
+
? 'NX_LEGACY_AFFECTED unset or set to false'
|
|
45
|
+
: 'affected.legacy unset or false in nx.json';
|
|
36
46
|
}
|
|
37
47
|
/**
|
|
38
48
|
* Selects the tasks a change reaches, rather than the projects that own a
|
|
@@ -141,7 +141,7 @@ function mergeConfigurationValue(newConfig, baseConfig, projectConfigSourceMap,
|
|
|
141
141
|
}
|
|
142
142
|
// `ultracache` keeps replace-unless-`'...'` semantics at the object level, but its
|
|
143
143
|
// values still have to be merged per key: neither the wholesale replace nor
|
|
144
|
-
// `mergeObjectWithSpread` recurses, so an `
|
|
144
|
+
// `mergeObjectWithSpread` recurses, so an `ignoreReads: ['...', 'tmp/**']`
|
|
145
145
|
// would otherwise reach the task graph with `'...'` intact — a glob matching
|
|
146
146
|
// nothing, silently dropping the inherited patterns.
|
|
147
147
|
function mergeUltracache(newUltracache, baseUltracache, projectConfigSourceMap, sourceInformation, targetIdentifier, deferSpreadsWithoutBase) {
|
|
@@ -5,8 +5,6 @@ exports.normalizeTarget = normalizeTarget;
|
|
|
5
5
|
exports.validateAndNormalizeProjectRootMap = validateAndNormalizeProjectRootMap;
|
|
6
6
|
const executor_utils_1 = require("../../../command-line/run/executor-utils");
|
|
7
7
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
8
|
-
const long_running_target_1 = require("../../../utils/long-running-target");
|
|
9
|
-
const output_1 = require("../../../utils/output");
|
|
10
8
|
const to_project_name_1 = require("../../../config/to-project-name");
|
|
11
9
|
const error_types_1 = require("../../error-types");
|
|
12
10
|
const target_merging_1 = require("./target-merging");
|
|
@@ -69,114 +67,6 @@ function normalizeTarget(target, project, workspaceRoot, projectsMap, errorMsgKe
|
|
|
69
67
|
}
|
|
70
68
|
return target;
|
|
71
69
|
}
|
|
72
|
-
// TODO(v24): remove the legacy target-name cache fallback and its warning.
|
|
73
|
-
// Removal needs a second mechanism for plugin-inferred targets, which the
|
|
74
|
-
// accompanying migration cannot reach.
|
|
75
|
-
/**
|
|
76
|
-
* Whether `target` is cacheable only by way of the legacy name-based fallback:
|
|
77
|
-
* the exact target-name key of `targetDefaults` declares `cache: true`, but an
|
|
78
|
-
* executor key won target-default resolution instead, so the merged target never
|
|
79
|
-
* received it.
|
|
80
|
-
*
|
|
81
|
-
* A `true` result means the user's `cache: true` silently lost, so this doubles
|
|
82
|
-
* as the condition for warning them that the name key is being shadowed.
|
|
83
|
-
*/
|
|
84
|
-
function isLegacyCachedTarget(targetName, targetDefaults, target) {
|
|
85
|
-
// Resolution already decided `cache`, so the name key isn't shadowed.
|
|
86
|
-
if (target.cache !== undefined) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
if (isLongRunningTarget(targetName, target)) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
// Restricted to shadowing, which is narrower than what pre-23 restored: that
|
|
93
|
-
// derivation matched on target name alone, so a name key dropped as
|
|
94
|
-
// incompatible (its entry declared a foreign executor) was cacheable too.
|
|
95
|
-
// Restoring that as well would mean writing `cache` with no key to name in
|
|
96
|
-
// the warning, and no migration able to retire it. Deliberately not covered.
|
|
97
|
-
if (!findShadowingTargetDefaultKey(targetDefaults, target)) {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return declaresCacheTrue(targetDefaults?.[targetName]);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Whether the name key declares `cache: true` on an entry that always applies.
|
|
104
|
-
*
|
|
105
|
-
* Filters are deliberately not evaluated. They cannot express a pre-23 config
|
|
106
|
-
* (the filtered array shape postdates the behavior being restored), and a
|
|
107
|
-
* filtered entry declaring `cache` may or may not apply to this project — so
|
|
108
|
-
* rather than guess, a filtered `cache` declares the value unknowable and
|
|
109
|
-
* nothing is restored. Among unfiltered entries the last wins, matching the
|
|
110
|
-
* in-key merge order.
|
|
111
|
-
*/
|
|
112
|
-
function declaresCacheTrue(value) {
|
|
113
|
-
if (!value) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
const entries = Array.isArray(value) ? value : [value];
|
|
117
|
-
let declared;
|
|
118
|
-
for (const entry of entries) {
|
|
119
|
-
// `nx.json` is hand-edited; a null or scalar entry would throw here.
|
|
120
|
-
if (!entry || typeof entry !== 'object')
|
|
121
|
-
continue;
|
|
122
|
-
if (entry.cache === undefined)
|
|
123
|
-
continue;
|
|
124
|
-
if (entry.filter)
|
|
125
|
-
return false;
|
|
126
|
-
declared = entry.cache;
|
|
127
|
-
}
|
|
128
|
-
return declared === true;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* The normalization-time half of the pre-23 `longRunningTask` guard, which kept
|
|
132
|
-
* `cacheableOperations` from ever making these cacheable. Its remaining clause
|
|
133
|
-
* — `task.overrides['watch']` — is a runtime invocation override with no target
|
|
134
|
-
* equivalent, so it has no counterpart here.
|
|
135
|
-
*/
|
|
136
|
-
function isLongRunningTarget(targetName, target) {
|
|
137
|
-
return !!target.continuous || (0, long_running_target_1.isLongRunningTargetName)(targetName);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* The `targetDefaults` key that beat the target-name key for `target`. Only an
|
|
141
|
-
* executor key can: key precedence puts the exact target name ahead of every
|
|
142
|
-
* glob, so nothing else outranks it. Undefined when the name key lost for
|
|
143
|
-
* another reason (e.g. its entry declared a foreign executor and was dropped as
|
|
144
|
-
* incompatible) — see {@link isLegacyCachedTarget} for why that case is left
|
|
145
|
-
* alone even though pre-23 restored it.
|
|
146
|
-
*
|
|
147
|
-
* `hasOwnProperty` rather than a lookup: an executor named `__proto__` resolves
|
|
148
|
-
* through the prototype chain to a truthy object, which would report a key the
|
|
149
|
-
* user never wrote.
|
|
150
|
-
*/
|
|
151
|
-
function findShadowingTargetDefaultKey(targetDefaults, target) {
|
|
152
|
-
return target.executor &&
|
|
153
|
-
targetDefaults &&
|
|
154
|
-
Object.prototype.hasOwnProperty.call(targetDefaults, target.executor)
|
|
155
|
-
? target.executor
|
|
156
|
-
: undefined;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Emits a single grouped warning for every (shadowing key, target-name key)
|
|
160
|
-
* pair that relied on the deprecated fallback. Grouping matters because the
|
|
161
|
-
* same pair recurs in every affected project — a per-target warning would
|
|
162
|
-
* print hundreds of identical lines in a large workspace.
|
|
163
|
-
*/
|
|
164
|
-
function warnAboutLegacyCachedTargets(legacyCacheReads) {
|
|
165
|
-
if (legacyCacheReads.size === 0) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const bodyLines = [];
|
|
169
|
-
for (const [shadowingKey, targetKeys] of legacyCacheReads) {
|
|
170
|
-
for (const targetKey of targetKeys) {
|
|
171
|
-
bodyLines.push(` - "${shadowingKey}" does not set "cache", so it was read from "${targetKey}"`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
bodyLines.push('', 'An executor key applies to every target that resolves through it, so exclude any continuous target before setting "cache" on one — a target that is both cacheable and continuous is rejected.', 'Target defaults resolve to a single key rather than merging, so an executor key hides the target name key entirely.', 'Set "cache" on the executor key to keep these targets cacheable — reading it from the target name key is deprecated and will be removed in Nx 24.');
|
|
175
|
-
output_1.output.warn({
|
|
176
|
-
title: 'Some targets are only cacheable through a deprecated fallback.',
|
|
177
|
-
bodyLines,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
70
|
/**
|
|
181
71
|
* Nothing downstream rejects a key it does not know — the Rust hasher drops it,
|
|
182
72
|
* the Cloud runner reads only the keys it reads, and the Kotlin API decodes with
|
|
@@ -187,8 +77,8 @@ function warnAboutLegacyCachedTargets(legacyCacheReads) {
|
|
|
187
77
|
const KNOWN_ULTRACACHE_KEYS = new Set([
|
|
188
78
|
'mode',
|
|
189
79
|
'collectStats',
|
|
190
|
-
'
|
|
191
|
-
'
|
|
80
|
+
'ignoreReads',
|
|
81
|
+
'ignoreWrites',
|
|
192
82
|
utils_1.NX_SPREAD_TOKEN,
|
|
193
83
|
]);
|
|
194
84
|
const ULTRACACHE_MODES = ['on', 'warn', 'error', 'off'];
|
|
@@ -234,7 +124,7 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
|
|
|
234
124
|
const errors = [];
|
|
235
125
|
for (const key of Object.keys(ultracache)) {
|
|
236
126
|
if (!KNOWN_ULTRACACHE_KEYS.has(key)) {
|
|
237
|
-
errors.push(`"ultracache.${key}" for target ${where} is not an ultracache option. Supported options are "mode", "collectStats", "
|
|
127
|
+
errors.push(`"ultracache.${key}" for target ${where} is not an ultracache option. Supported options are "mode", "collectStats", "ignoreReads" and "ignoreWrites".`);
|
|
238
128
|
}
|
|
239
129
|
}
|
|
240
130
|
if (ultracache.mode !== undefined &&
|
|
@@ -248,7 +138,7 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
|
|
|
248
138
|
typeof ultracache.collectStats !== 'boolean') {
|
|
249
139
|
errors.push(`"ultracache.collectStats" for target ${where} must be a boolean, but it is ${describeUltracacheValue(ultracache.collectStats)}.`);
|
|
250
140
|
}
|
|
251
|
-
for (const key of ['
|
|
141
|
+
for (const key of ['ignoreReads', 'ignoreWrites']) {
|
|
252
142
|
const value = ultracache[key];
|
|
253
143
|
if (value === undefined)
|
|
254
144
|
continue;
|
|
@@ -263,30 +153,16 @@ function validateTargetUltracache(ultracache, projectName, projectRoot, targetNa
|
|
|
263
153
|
}
|
|
264
154
|
return errors;
|
|
265
155
|
}
|
|
266
|
-
function normalizeTargets(project, sourceMaps,
|
|
156
|
+
function normalizeTargets(project, sourceMaps, workspaceRoot,
|
|
267
157
|
/**
|
|
268
158
|
* Project configurations keyed by project name
|
|
269
159
|
*/
|
|
270
|
-
projects
|
|
271
|
-
/**
|
|
272
|
-
* Shadowing `targetDefaults` key -> target name keys its `cache` was read
|
|
273
|
-
* from. Accumulated across projects so the deprecation warns once per pair.
|
|
274
|
-
*/
|
|
275
|
-
legacyCacheReads) {
|
|
160
|
+
projects) {
|
|
276
161
|
const targetErrorMessage = [];
|
|
277
162
|
for (const targetName in project.targets) {
|
|
278
163
|
project.targets[targetName] = normalizeTarget(project.targets[targetName], project, workspaceRoot, projects, [project.root, targetName].join(':'));
|
|
279
164
|
const target = project.targets[targetName];
|
|
280
165
|
targetErrorMessage.push(...validateTargetUltracache(target.ultracache, project.name ?? project.root, project.root, targetName, sourceMaps).map((message) => `- ${message}`));
|
|
281
|
-
const targetDefaults = nxJsonConfiguration.targetDefaults;
|
|
282
|
-
if (isLegacyCachedTarget(targetName, targetDefaults, target)) {
|
|
283
|
-
target.cache = true;
|
|
284
|
-
// Always defined: `isLegacyCachedTarget` returns false without it.
|
|
285
|
-
const shadowingKey = findShadowingTargetDefaultKey(targetDefaults, target);
|
|
286
|
-
const targetKeys = legacyCacheReads.get(shadowingKey) ?? new Set();
|
|
287
|
-
targetKeys.add(targetName);
|
|
288
|
-
legacyCacheReads.set(shadowingKey, targetKeys);
|
|
289
|
-
}
|
|
290
166
|
if (
|
|
291
167
|
// If the target has no executor or command, it doesn't do anything
|
|
292
168
|
!target.executor &&
|
|
@@ -319,7 +195,6 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
|
|
|
319
195
|
const conflicts = new Map();
|
|
320
196
|
const projectRootsWithNoName = [];
|
|
321
197
|
const validityErrors = [];
|
|
322
|
-
const legacyCacheReads = new Map();
|
|
323
198
|
for (const root in projectRootMap) {
|
|
324
199
|
const project = projectRootMap[root];
|
|
325
200
|
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
|
@@ -369,7 +244,7 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
|
|
|
369
244
|
for (const root in projectRootMap) {
|
|
370
245
|
const project = projectRootMap[root];
|
|
371
246
|
try {
|
|
372
|
-
normalizeTargets(project, sourceMaps,
|
|
247
|
+
normalizeTargets(project, sourceMaps, workspaceRoot, projects);
|
|
373
248
|
}
|
|
374
249
|
catch (e) {
|
|
375
250
|
if (e instanceof error_types_1.WorkspaceValidityError) {
|
|
@@ -380,7 +255,6 @@ function validateAndNormalizeProjectRootMap(workspaceRoot, projectRootMap, nxJso
|
|
|
380
255
|
}
|
|
381
256
|
}
|
|
382
257
|
}
|
|
383
|
-
warnAboutLegacyCachedTargets(legacyCacheReads);
|
|
384
258
|
const errors = [];
|
|
385
259
|
if (conflicts.size > 0) {
|
|
386
260
|
// Only on the way to throwing, so a workspace without duplicates never
|
|
@@ -316,8 +316,8 @@ function createMatcher(patterns, emptyValue) {
|
|
|
316
316
|
return (file) => compiled.some((m) => m.match(file));
|
|
317
317
|
}
|
|
318
318
|
function findMatchingConfigFiles(projectFiles, include, exclude) {
|
|
319
|
-
//
|
|
320
|
-
//
|
|
319
|
+
// Callers pass files that already match the plugin's createNodes pattern,
|
|
320
|
+
// so only include/exclude filters remain here.
|
|
321
321
|
// Empty include means include everything, empty exclude means exclude nothing
|
|
322
322
|
const includes = createMatcher(include, true);
|
|
323
323
|
const excludes = createMatcher(exclude, false);
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitForReadiness = waitForReadiness;
|
|
4
|
+
const net_1 = require("net");
|
|
5
|
+
const os_1 = require("os");
|
|
4
6
|
const native_1 = require("../../native");
|
|
5
7
|
const ready_when_1 = require("./ready-when");
|
|
6
8
|
// Never rejects for a transient probe error: every failure is retried until
|
|
@@ -18,7 +20,7 @@ async function waitForReadiness(readyWhen, context) {
|
|
|
18
20
|
...(readyWhen.kind === 'url'
|
|
19
21
|
? { url: readyWhen.url }
|
|
20
22
|
: readyWhen.kind === 'port'
|
|
21
|
-
? { port: readyWhen.port, host: readyWhen.host }
|
|
23
|
+
? { port: readyWhen.port, host: resolveStartupHost(readyWhen.host) }
|
|
22
24
|
: { command: readyWhen.command }),
|
|
23
25
|
}, context.cwd);
|
|
24
26
|
const cancel = () => probe.cancel();
|
|
@@ -39,6 +41,33 @@ async function waitForReadiness(readyWhen, context) {
|
|
|
39
41
|
: (0, ready_when_1.readinessTimeoutError)(context.taskId, readyWhen);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
// webpack-dev-server and the Rspack dev server resolve these hosts when they
|
|
45
|
+
// start (`Server.getHostname`). A wildcard fallback means loopback to the probe.
|
|
46
|
+
function resolveStartupHost(host) {
|
|
47
|
+
switch (host) {
|
|
48
|
+
case 'local-ip':
|
|
49
|
+
return findIp('IPv4') ?? findIp('IPv6') ?? '0.0.0.0';
|
|
50
|
+
case 'local-ipv4':
|
|
51
|
+
return findIp('IPv4') ?? '0.0.0.0';
|
|
52
|
+
case 'local-ipv6':
|
|
53
|
+
return findIp('IPv6') ?? '::';
|
|
54
|
+
default:
|
|
55
|
+
return host;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// The IPv6 ranges `Server.findIp` accepts: unique local, IPv4-mapped, loopback
|
|
59
|
+
const FIND_IP_V6_RANGES = new net_1.BlockList();
|
|
60
|
+
FIND_IP_V6_RANGES.addSubnet('fc00::', 7, 'ipv6');
|
|
61
|
+
FIND_IP_V6_RANGES.addSubnet('::ffff:0:0', 96, 'ipv6');
|
|
62
|
+
FIND_IP_V6_RANGES.addAddress('::1', 'ipv6');
|
|
63
|
+
function findIp(family) {
|
|
64
|
+
return Object.values((0, os_1.networkInterfaces)())
|
|
65
|
+
.flatMap((addresses) => addresses ?? [])
|
|
66
|
+
.find(({ address, family: addressFamily, internal }) => address &&
|
|
67
|
+
addressFamily === family &&
|
|
68
|
+
!internal &&
|
|
69
|
+
(family === 'IPv4' || FIND_IP_V6_RANGES.check(address, 'ipv6')))?.address;
|
|
70
|
+
}
|
|
42
71
|
function waitForLogMatch(readyWhen, context) {
|
|
43
72
|
return new Promise((resolve, reject) => {
|
|
44
73
|
const matcher = new native_1.LogMatcher(readyWhen.logMatches);
|