@nx/js 24.1.0-beta.0 → 24.1.0-beta.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/internal.d.ts +2 -1
- package/dist/internal.js +8 -5
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +40 -32
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +105 -8
- package/dist/src/executors/verdaccio/placeholder-auth-token.d.ts +8 -0
- package/dist/src/executors/verdaccio/placeholder-auth-token.js +36 -0
- package/dist/src/executors/verdaccio/verdaccio.impl.js +49 -15
- package/dist/src/generators/setup-verdaccio/files/config.yml +8 -0
- package/dist/src/generators/typescript-sync/typescript-sync.js +5 -7
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.d.ts +1 -6
- package/dist/src/migrations/update-23-2-0/add-pnpm-deploy-output-cache-inputs.js +4 -224
- package/dist/src/migrations/update-23-2-0/add-pnpm-prune-lockfile-cache-config.js +18 -297
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.d.ts +8 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.js +21 -0
- package/dist/src/migrations/update-24-1-0/add-bun-deploy-output-cache-inputs.md +49 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.d.ts +2 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.js +28 -0
- package/dist/src/migrations/update-24-1-0/add-bun-prune-lockfile-cache-config.md +44 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.d.ts +10 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.js +145 -0
- package/dist/src/migrations/update-24-1-0/add-verdaccio-jwt-security.md +49 -0
- package/dist/src/plugins/jest/start-local-registry.d.ts +4 -4
- package/dist/src/plugins/jest/start-local-registry.js +46 -32
- package/dist/src/release/version-actions.js +6 -0
- package/dist/src/utils/bun-install-settings-inputs.d.ts +20 -0
- package/dist/src/utils/bun-install-settings-inputs.js +31 -0
- package/dist/src/utils/deploy-output-cache-inputs.d.ts +35 -0
- package/dist/src/utils/deploy-output-cache-inputs.js +400 -0
- package/dist/src/utils/pnpm-install-settings-inputs.d.ts +0 -6
- package/dist/src/utils/pnpm-install-settings-inputs.js +0 -6
- package/dist/src/utils/prune-lockfile-cache-config.d.ts +18 -0
- package/dist/src/utils/prune-lockfile-cache-config.js +288 -0
- package/dist/src/utils/target-defaults-matching.d.ts +3 -0
- package/dist/src/utils/target-defaults-matching.js +7 -0
- package/dist/src/utils/workspace-module-sections.d.ts +10 -5
- package/dist/src/utils/workspace-module-sections.js +15 -6
- package/migrations.json +18 -0
- package/package.json +12 -12
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.d.ts +0 -29
- package/dist/src/utils/pnpm-deploy-output-cache-inputs.js +0 -177
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDeployOutputCacheInputsToBuildTargets = addDeployOutputCacheInputsToBuildTargets;
|
|
4
|
+
exports.addDeployOutputCacheInputs = addDeployOutputCacheInputs;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const target_defaults_matching_1 = require("./target-defaults-matching");
|
|
9
|
+
// The executors that emit the pruned deploy output, each with the option that
|
|
10
|
+
// turns the emission on. webpack, rspack, vite and esbuild gate it on
|
|
11
|
+
// `generatePackageJson`; next, remix, tsc and swc emit the manifest regardless
|
|
12
|
+
// and gate only the deploy output on `generateLockfile`.
|
|
13
|
+
const DEPLOY_OUTPUT_EXECUTORS = {
|
|
14
|
+
'@nx/webpack:webpack': 'generatePackageJson',
|
|
15
|
+
'@nx/rspack:rspack': 'generatePackageJson',
|
|
16
|
+
'@nx/vite:build': 'generatePackageJson',
|
|
17
|
+
'@nx/esbuild:esbuild': 'generatePackageJson',
|
|
18
|
+
'@nx/next:build': 'generateLockfile',
|
|
19
|
+
'@nx/remix:build': 'generateLockfile',
|
|
20
|
+
'@nx/js:tsc': 'generateLockfile',
|
|
21
|
+
'@nx/js:swc': 'generateLockfile',
|
|
22
|
+
};
|
|
23
|
+
// The config-file plugins whose inferred build target can emit the deploy
|
|
24
|
+
// output (NxAppWebpackPlugin/NxAppRspackPlugin with generatePackageJson).
|
|
25
|
+
// The globs mirror each plugin's own createNodes pattern; the commands are
|
|
26
|
+
// what each plugin sets on the build target it creates.
|
|
27
|
+
const INFERRED_DEPLOY_PLUGINS = {
|
|
28
|
+
'@nx/webpack/plugin': {
|
|
29
|
+
configGlob: '**/webpack.config.{js,ts,mjs,cjs}',
|
|
30
|
+
command: 'webpack-cli build',
|
|
31
|
+
},
|
|
32
|
+
'@nx/rspack/plugin': {
|
|
33
|
+
configGlob: '**/rspack.config.{js,ts,mjs,mts,cjs,cts}',
|
|
34
|
+
command: 'rspack build',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Adds `settingsInputs` to the `inputs` of build targets that emit the pruned
|
|
39
|
+
* deploy output. The settings those outputs carry reach no lockfile, so
|
|
40
|
+
* without these a changed setting leaves the task hash unchanged and a cached
|
|
41
|
+
* run replays an output that still carries the old one. Inferred targets are
|
|
42
|
+
* covered by the `@nx/webpack` and `@nx/rspack` plugins themselves; this
|
|
43
|
+
* covers the explicitly configured executor targets, plus overlays of inferred
|
|
44
|
+
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
45
|
+
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
46
|
+
* array discards the plugin-generated one.
|
|
47
|
+
*/
|
|
48
|
+
async function addDeployOutputCacheInputsToBuildTargets(tree, settingsInputs) {
|
|
49
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
50
|
+
const targetDefaults = nxJson?.targetDefaults;
|
|
51
|
+
const projects = new Map();
|
|
52
|
+
const changedProjects = new Set();
|
|
53
|
+
let defaultsChanged = false;
|
|
54
|
+
for (const [projectName, project] of (0, devkit_1.getProjects)(tree)) {
|
|
55
|
+
projects.set(projectName, project);
|
|
56
|
+
const projectNode = {
|
|
57
|
+
name: projectName,
|
|
58
|
+
type: 'lib',
|
|
59
|
+
data: { root: project.root, tags: project.tags },
|
|
60
|
+
};
|
|
61
|
+
for (const [targetName, target] of Object.entries(project.targets ?? {})) {
|
|
62
|
+
// The executor may come from a matching targetDefaults entry rather
|
|
63
|
+
// than the target itself. A `command` target resolves to nx:run-commands
|
|
64
|
+
// before defaults apply, so a default can never re-identify it.
|
|
65
|
+
const executor = target.executor ??
|
|
66
|
+
(target.command
|
|
67
|
+
? 'nx:run-commands'
|
|
68
|
+
: (0, target_defaults_matching_1.resolveDefaultsExecutor)(targetName, projectName, projectNode, targetDefaults));
|
|
69
|
+
if (!executor || !DEPLOY_OUTPUT_EXECUTORS[executor]) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const ref = {
|
|
73
|
+
targetName,
|
|
74
|
+
projectName,
|
|
75
|
+
projectNode,
|
|
76
|
+
matcherExecutor: target.executor,
|
|
77
|
+
target,
|
|
78
|
+
};
|
|
79
|
+
const selectedKey = targetDefaults
|
|
80
|
+
? (0, target_defaults_matching_1.selectDefaultsKey)(ref, targetDefaults, executor)
|
|
81
|
+
: null;
|
|
82
|
+
const entries = (0, target_defaults_matching_1.compatibleDefaultsEntries)(ref, selectedKey, targetDefaults);
|
|
83
|
+
const defaults = entries.length
|
|
84
|
+
? (0, internal_1.readTargetDefaultsForTarget)(targetName, { [selectedKey]: entries }, ref.matcherExecutor, { projectName, projectNode })
|
|
85
|
+
: null;
|
|
86
|
+
// The effective view, not the target's own: the gating option may be
|
|
87
|
+
// supplied by a matching defaults entry or set only in a configuration.
|
|
88
|
+
const effective = (0, internal_1.mergeTargetConfigurations)(target, defaults ?? {});
|
|
89
|
+
if (!emitsDeployOutput(effective, DEPLOY_OUTPUT_EXECUTORS[executor])) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const changed = addDeployOutputCacheInputs(ref, targetDefaults, executor, settingsInputs);
|
|
93
|
+
if (changed === 'target') {
|
|
94
|
+
changedProjects.add(projectName);
|
|
95
|
+
}
|
|
96
|
+
else if (changed === 'defaults') {
|
|
97
|
+
defaultsChanged = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Overlays of plugin-inferred build targets carry no executor, so the loop
|
|
102
|
+
// above cannot see them, yet a replacing `inputs` array in one discards the
|
|
103
|
+
// settings inputs the plugin generates. The plugin adds those inputs without
|
|
104
|
+
// knowing whether the config enables generatePackageJson (that lives inside
|
|
105
|
+
// the user's config file), so the overlay repair is equally unconditional.
|
|
106
|
+
// It appends the full set, a runtime probe included, even where the plugin
|
|
107
|
+
// omits it: the repair runs once and what made the plugin omit it can
|
|
108
|
+
// change later.
|
|
109
|
+
for (const ref of await inferredDeployTargetOverlayRefs(tree, nxJson, projects)) {
|
|
110
|
+
const changed = addDeployOutputCacheInputsToInferredTargetOverlay(ref, targetDefaults, settingsInputs);
|
|
111
|
+
if (changed === 'target') {
|
|
112
|
+
changedProjects.add(ref.projectName);
|
|
113
|
+
}
|
|
114
|
+
else if (changed === 'defaults') {
|
|
115
|
+
defaultsChanged = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
for (const projectName of changedProjects) {
|
|
119
|
+
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projects.get(projectName));
|
|
120
|
+
}
|
|
121
|
+
if (defaultsChanged) {
|
|
122
|
+
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Adds the missing `settingsInputs` to the layer whose `inputs` array the
|
|
127
|
+
* runtime actually uses for this target: the target's own `inputs` when it
|
|
128
|
+
* declares them (its array replaces the defaults' rather than merging with
|
|
129
|
+
* it), otherwise the matching `targetDefaults` entry supplying the array it
|
|
130
|
+
* inherits, and otherwise the target itself with nx's own default spelled out
|
|
131
|
+
* first, so nothing that was hashed stops being hashed. Sources the effective
|
|
132
|
+
* inputs already hash, including via a whole-file fileset of a JSON source or
|
|
133
|
+
* a `json` input covering its fields, are left alone; no `'...'` is ever
|
|
134
|
+
* authored. Returns which layer was mutated, or null when nothing was missing.
|
|
135
|
+
*/
|
|
136
|
+
function addDeployOutputCacheInputs(ref, targetDefaults, executor, settingsInputs) {
|
|
137
|
+
const selectedKey = targetDefaults
|
|
138
|
+
? (0, target_defaults_matching_1.selectDefaultsKey)(ref, targetDefaults, executor)
|
|
139
|
+
: null;
|
|
140
|
+
const entries = (0, target_defaults_matching_1.compatibleDefaultsEntries)(ref, selectedKey, targetDefaults);
|
|
141
|
+
const defaults = entries.length
|
|
142
|
+
? (0, internal_1.readTargetDefaultsForTarget)(ref.targetName, { [selectedKey]: entries }, ref.matcherExecutor, {
|
|
143
|
+
projectName: ref.projectName,
|
|
144
|
+
projectNode: ref.projectNode,
|
|
145
|
+
sourcePlugin: ref.sourcePlugin,
|
|
146
|
+
})
|
|
147
|
+
: null;
|
|
148
|
+
const effective = (0, internal_1.mergeTargetConfigurations)(ref.target, defaults ?? {});
|
|
149
|
+
const missing = missingSettingsInputs(effective.inputs, settingsInputs);
|
|
150
|
+
if (missing.length === 0) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
if (ref.target.inputs !== undefined) {
|
|
154
|
+
appendInputs(ref.target, missing);
|
|
155
|
+
return 'target';
|
|
156
|
+
}
|
|
157
|
+
const supplier = (0, target_defaults_matching_1.lastMatchingInputsSupplier)(ref, selectedKey, entries);
|
|
158
|
+
if (supplier) {
|
|
159
|
+
appendInputs(supplier, missing);
|
|
160
|
+
return 'defaults';
|
|
161
|
+
}
|
|
162
|
+
appendInputs(ref.target, missing);
|
|
163
|
+
return 'target';
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Variant for a plugin-inferred target, whose generated `inputs` already carry
|
|
167
|
+
* the settings sources (a runtime probe possibly only under some conditions):
|
|
168
|
+
* a repair is only needed when an overlay (a project-level target entry,
|
|
169
|
+
* exact or glob key, or a matching `targetDefaults` entry) supplies a
|
|
170
|
+
* replacing `inputs` array that discards them. The repair appends the full
|
|
171
|
+
* set, probe included, because it runs once and the plugin's conditions can
|
|
172
|
+
* change later. The inferred layer is modeled as an array of exactly the
|
|
173
|
+
* settings inputs: enough for the missing check, and it makes an overlay-less
|
|
174
|
+
* target come back as nothing missing, so the fallback that would narrow the
|
|
175
|
+
* plugin's richer array to `DEFAULT_INPUTS` can never be reached: with no
|
|
176
|
+
* replacing supplier there is nothing to mutate.
|
|
177
|
+
*/
|
|
178
|
+
function addDeployOutputCacheInputsToInferredTargetOverlay(ref, targetDefaults, settingsInputs) {
|
|
179
|
+
const selectedKey = targetDefaults
|
|
180
|
+
? (0, target_defaults_matching_1.selectDefaultsKey)(ref, targetDefaults, ref.matcherExecutor)
|
|
181
|
+
: null;
|
|
182
|
+
const entries = (0, target_defaults_matching_1.compatibleDefaultsEntries)(ref, selectedKey, targetDefaults);
|
|
183
|
+
const defaults = entries.length
|
|
184
|
+
? (0, internal_1.readTargetDefaultsForTarget)(ref.targetName, { [selectedKey]: entries }, ref.matcherExecutor, {
|
|
185
|
+
projectName: ref.projectName,
|
|
186
|
+
projectNode: ref.projectNode,
|
|
187
|
+
sourcePlugin: ref.sourcePlugin,
|
|
188
|
+
})
|
|
189
|
+
: null;
|
|
190
|
+
const inferredLayer = {
|
|
191
|
+
inputs: [...settingsInputs],
|
|
192
|
+
};
|
|
193
|
+
const effective = (0, internal_1.mergeTargetConfigurations)(ref.target, (0, internal_1.mergeTargetConfigurations)(defaults ?? {}, inferredLayer));
|
|
194
|
+
const missing = missingSettingsInputs(effective.inputs, settingsInputs);
|
|
195
|
+
if (missing.length === 0) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
if (ref.target.inputs !== undefined) {
|
|
199
|
+
appendInputs(ref.target, missing);
|
|
200
|
+
return 'target';
|
|
201
|
+
}
|
|
202
|
+
const supplier = (0, target_defaults_matching_1.lastMatchingInputsSupplier)(ref, selectedKey, entries);
|
|
203
|
+
if (supplier) {
|
|
204
|
+
appendInputs(supplier, missing);
|
|
205
|
+
return 'defaults';
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The settings sources the effective inputs do not hash yet. A JSON source
|
|
211
|
+
* counts as covered by a whole-file fileset no negative pattern can cancel,
|
|
212
|
+
* or by an existing `json` input on the same file that hashes all the
|
|
213
|
+
* settings fields (`json` inputs are immune to fileset negations); any other
|
|
214
|
+
* file by its fileset (a negative pattern cancelling that fileset has no
|
|
215
|
+
* input-level counter, so it is left to the author who wrote it); a runtime
|
|
216
|
+
* probe by an identical `runtime` entry.
|
|
217
|
+
*/
|
|
218
|
+
function missingSettingsInputs(inputs, settingsInputs) {
|
|
219
|
+
const filesets = (0, target_defaults_matching_1.namedFilesets)(inputs);
|
|
220
|
+
const missing = [];
|
|
221
|
+
for (const input of settingsInputs) {
|
|
222
|
+
if (typeof input === 'string') {
|
|
223
|
+
if (!filesets.has(input)) {
|
|
224
|
+
missing.push(input);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
else if ('runtime' in input) {
|
|
228
|
+
if (!(0, target_defaults_matching_1.hasRuntimeInput)(inputs, input)) {
|
|
229
|
+
missing.push(input);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else if (!(filesets.has(input.json) && !negationMayCancel(inputs)) &&
|
|
233
|
+
!(inputs ?? []).some((existing) => typeof existing === 'object' &&
|
|
234
|
+
existing !== null &&
|
|
235
|
+
'json' in existing &&
|
|
236
|
+
existing.json === input.json &&
|
|
237
|
+
input.fields !== undefined &&
|
|
238
|
+
input.fields.every((field) => jsonInputCoversField(existing, field)))) {
|
|
239
|
+
missing.push(input);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return missing;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Whether a negative fileset entry could remove the source from the hash. Any
|
|
246
|
+
* workspace-root-scoped negation counts, in the string or `{ fileset }` form:
|
|
247
|
+
* nx's pattern syntax (globs, extglobs) is not re-evaluated here, and an
|
|
248
|
+
* extra input for a source the negation does not actually touch is harmless.
|
|
249
|
+
* Project-relative negations never match a workspace-root file.
|
|
250
|
+
*/
|
|
251
|
+
function negationMayCancel(inputs) {
|
|
252
|
+
return (inputs ?? []).some((existing) => {
|
|
253
|
+
const pattern = typeof existing === 'string'
|
|
254
|
+
? existing
|
|
255
|
+
: typeof existing === 'object' &&
|
|
256
|
+
existing !== null &&
|
|
257
|
+
'fileset' in existing
|
|
258
|
+
? existing.fileset
|
|
259
|
+
: undefined;
|
|
260
|
+
return (typeof pattern === 'string' &&
|
|
261
|
+
pattern.startsWith('!') &&
|
|
262
|
+
pattern.includes('{workspaceRoot}'));
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Whether an existing `json` input hashes `field`: selected by the allowlist
|
|
267
|
+
* (an entry covers its whole subtree) and not touched by the denylist, which
|
|
268
|
+
* the hasher applies after selection. A denylist entry below the field only
|
|
269
|
+
* removes part of its subtree, but that part is then unhashed, so it
|
|
270
|
+
* disqualifies coverage too.
|
|
271
|
+
*/
|
|
272
|
+
function jsonInputCoversField(input, field) {
|
|
273
|
+
const selected = input.fields === undefined ||
|
|
274
|
+
input.fields.some((path) => path === field || field.startsWith(`${path}.`));
|
|
275
|
+
if (!selected) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
return !(input.excludeFields ?? []).some((path) => path === field ||
|
|
279
|
+
field.startsWith(`${path}.`) ||
|
|
280
|
+
path.startsWith(`${field}.`));
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Appends to an array that already exists, or writes nx's default as the base
|
|
284
|
+
* when no layer declares one, so the configuration is never narrowed to the
|
|
285
|
+
* settings sources alone.
|
|
286
|
+
*/
|
|
287
|
+
function appendInputs(config, missing) {
|
|
288
|
+
config.inputs = [...(config.inputs ?? target_defaults_matching_1.DEFAULT_INPUTS), ...missing];
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* One ref per (project, inferred build target) the registered `@nx/webpack` or
|
|
292
|
+
* `@nx/rspack` config-file plugins would create, resolved the way the plugins
|
|
293
|
+
* do: their createNodes glob filtered by each registration's include/exclude,
|
|
294
|
+
* the config file's directory as the project root, and the registration's
|
|
295
|
+
* `buildTargetName` option. The overlaying project-level entry may sit under
|
|
296
|
+
* the exact target name or a glob-pattern key matching it; one that replaces
|
|
297
|
+
* what the target runs disqualifies the target instead.
|
|
298
|
+
*/
|
|
299
|
+
async function inferredDeployTargetOverlayRefs(tree, nxJson, projects) {
|
|
300
|
+
const rootToProject = new Map();
|
|
301
|
+
for (const [projectName, project] of projects) {
|
|
302
|
+
rootToProject.set(project.root, projectName);
|
|
303
|
+
}
|
|
304
|
+
const refs = [];
|
|
305
|
+
for (const registration of nxJson?.plugins ?? []) {
|
|
306
|
+
const pluginName = typeof registration === 'string' ? registration : registration.plugin;
|
|
307
|
+
const inferredPlugin = INFERRED_DEPLOY_PLUGINS[pluginName];
|
|
308
|
+
if (!inferredPlugin) {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const options = typeof registration === 'string'
|
|
312
|
+
? undefined
|
|
313
|
+
: registration.options;
|
|
314
|
+
const targetName = options?.buildTargetName ?? 'build';
|
|
315
|
+
const configFiles = (0, internal_1.findMatchingConfigFiles)(await (0, devkit_1.globAsync)(tree, [inferredPlugin.configGlob]), typeof registration === 'string' ? undefined : registration.include, typeof registration === 'string' ? undefined : registration.exclude);
|
|
316
|
+
for (const configFile of configFiles) {
|
|
317
|
+
const projectName = rootToProject.get((0, path_1.dirname)(configFile));
|
|
318
|
+
if (!projectName) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
const project = projects.get(projectName);
|
|
322
|
+
const target = inferredTargetOverlayEntry(project.targets, targetName);
|
|
323
|
+
// An entry that changes what the target runs is not an overlay; the
|
|
324
|
+
// executor loop covers the deploy executors among those.
|
|
325
|
+
if (target &&
|
|
326
|
+
replacesInferredRunCommandsIdentity(target, inferredPlugin.command, project.root)) {
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
refs.push({
|
|
330
|
+
targetName,
|
|
331
|
+
projectName,
|
|
332
|
+
projectNode: {
|
|
333
|
+
name: projectName,
|
|
334
|
+
type: 'lib',
|
|
335
|
+
data: { root: project.root, tags: project.tags },
|
|
336
|
+
},
|
|
337
|
+
// the runtime matcher sees the plugin target's effective identity:
|
|
338
|
+
// its `command` payload resolves to nx:run-commands
|
|
339
|
+
matcherExecutor: 'nx:run-commands',
|
|
340
|
+
// the runtime drops the plugin attribution as soon as the project
|
|
341
|
+
// entry authors an executor or command, restated or not, so a
|
|
342
|
+
// plugin-filtered defaults entry no longer applies to the target
|
|
343
|
+
sourcePlugin: target?.executor !== undefined || target?.command !== undefined
|
|
344
|
+
? undefined
|
|
345
|
+
: pluginName,
|
|
346
|
+
target: target ?? {},
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return refs;
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* The project-level entry that overlays the inferred `targetName`. Its key is
|
|
354
|
+
* the exact name or a glob pattern the name matches; the inferred target
|
|
355
|
+
* exists before any project-level entry merges, so a matching glob key
|
|
356
|
+
* overlays it too. When several keys match, each entry merges against the
|
|
357
|
+
* inferred target independently and the last write wins, so only the last
|
|
358
|
+
* one applies. A glob key matching an earlier same-file sibling never
|
|
359
|
+
* surfaces here: the project read already collapsed it onto that sibling and
|
|
360
|
+
* dropped the key.
|
|
361
|
+
*/
|
|
362
|
+
function inferredTargetOverlayEntry(targets, targetName) {
|
|
363
|
+
const matching = Object.entries(targets ?? {}).filter(([key]) => key === targetName ||
|
|
364
|
+
(0, internal_1.findMatchingTargetNames)(key, [targetName]).length > 0);
|
|
365
|
+
return matching[matching.length - 1]?.[1];
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Whether the entry changes what the inferred run-commands target runs when
|
|
369
|
+
* merged, resolved with nx's own merge so `"..."` placement and restated
|
|
370
|
+
* identities land the way the runtime lands them: a merged executor other
|
|
371
|
+
* than nx:run-commands, an effective command differing from the plugin's, or
|
|
372
|
+
* a `command`/`commands` clash the run-commands schema rejects. An entry
|
|
373
|
+
* restating the identity the plugin infers is still an overlay.
|
|
374
|
+
*/
|
|
375
|
+
function replacesInferredRunCommandsIdentity(target, inferredCommand, projectRoot) {
|
|
376
|
+
// `command` alongside `executor` fails graph construction outright;
|
|
377
|
+
// there is nothing running to repair.
|
|
378
|
+
if (target.command && target.executor) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
const merged = (0, internal_1.mergeTargetConfigurations)((0, internal_1.resolveCommandSyntacticSugar)(target, projectRoot), { executor: 'nx:run-commands', options: { command: inferredCommand } });
|
|
382
|
+
if (merged.executor !== 'nx:run-commands') {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
// Both present fails the run-commands schema's oneOf; the target cannot run.
|
|
386
|
+
if (merged.options?.command && merged.options?.commands) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
const command = merged.options?.command ?? merged.options?.commands?.join(' && ');
|
|
390
|
+
return command !== inferredCommand;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Whether the target ships the deploy output in any of its runs: the gating
|
|
394
|
+
* option can sit in `options` or in any configuration, and `inputs` cannot
|
|
395
|
+
* vary per configuration, so one enabled configuration is enough.
|
|
396
|
+
*/
|
|
397
|
+
function emitsDeployOutput(effective, gate) {
|
|
398
|
+
return (Boolean(effective.options?.[gate]) ||
|
|
399
|
+
Object.values(effective.configurations ?? {}).some((configuration) => Boolean(configuration?.[gate])));
|
|
400
|
+
}
|
|
@@ -21,12 +21,6 @@ import { type JsonInput } from '@nx/devkit/internal';
|
|
|
21
21
|
* once, and the pin can be removed later. Plugins re-infer on every graph
|
|
22
22
|
* build, so they use {@link pnpmInstallSettingsInputsForInferredTarget} to
|
|
23
23
|
* add the probe only while no valid pin exists.
|
|
24
|
-
*
|
|
25
|
-
* The contents of vendored non-workspace local-path dependencies also ship in
|
|
26
|
-
* the deploy output but are not covered: their set is derived from the
|
|
27
|
-
* lockfile at build time, so no static input list stays correct as
|
|
28
|
-
* dependencies change. Covering them needs content hashing at the graph level
|
|
29
|
-
* (the pnpm parser's directory/link external nodes hash only name and path).
|
|
30
24
|
*/
|
|
31
25
|
export declare const PNPM_MAJOR_RUNTIME_INPUT: {
|
|
32
26
|
runtime: string;
|
|
@@ -27,12 +27,6 @@ const path_1 = require("path");
|
|
|
27
27
|
* once, and the pin can be removed later. Plugins re-infer on every graph
|
|
28
28
|
* build, so they use {@link pnpmInstallSettingsInputsForInferredTarget} to
|
|
29
29
|
* add the probe only while no valid pin exists.
|
|
30
|
-
*
|
|
31
|
-
* The contents of vendored non-workspace local-path dependencies also ship in
|
|
32
|
-
* the deploy output but are not covered: their set is derived from the
|
|
33
|
-
* lockfile at build time, so no static input list stays correct as
|
|
34
|
-
* dependencies change. Covering them needs content hashing at the graph level
|
|
35
|
-
* (the pnpm parser's directory/link external nodes hash only name and path).
|
|
36
30
|
*/
|
|
37
31
|
exports.PNPM_MAJOR_RUNTIME_INPUT = {
|
|
38
32
|
runtime: `node -e "try{console.log('pnpm major '+require('child_process').execSync('pnpm --version',{stdio:['ignore','pipe','ignore']}).toString().trim().split('.')[0])}catch{console.log('pnpm major unavailable')}"`,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
interface PruneLockfileCacheConfig {
|
|
3
|
+
/** The lockfile whose `outputs` entry identifies a package manager's prune targets. */
|
|
4
|
+
lockFile: string;
|
|
5
|
+
/** What the executor emits next to the pruned lockfile, beside its entry. */
|
|
6
|
+
artifacts: readonly string[];
|
|
7
|
+
/** The workspace root sources those artifacts are built from. */
|
|
8
|
+
rootInputs: readonly (string | {
|
|
9
|
+
runtime: string;
|
|
10
|
+
})[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Adds `artifacts` to the `outputs` of `@nx/js:prune-lockfile` targets that
|
|
14
|
+
* declare `lockFile`, and `rootInputs` to their `inputs`, on whichever layer
|
|
15
|
+
* (the target or a `targetDefaults` entry) the runtime reads each from.
|
|
16
|
+
*/
|
|
17
|
+
export declare function addPruneLockfileCacheConfig(tree: Tree, config: PruneLockfileCacheConfig): void;
|
|
18
|
+
export {};
|