@nx/js 24.1.0-beta.1 → 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/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/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 +12 -0
- package/package.json +11 -11
- 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
|
@@ -2,304 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = update;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const internal_1 = require("@nx/devkit/internal");
|
|
6
5
|
const pnpm_install_settings_inputs_1 = require("../../utils/pnpm-install-settings-inputs");
|
|
7
|
-
const
|
|
8
|
-
const PRUNE_LOCKFILE_EXECUTOR = '@nx/js:prune-lockfile';
|
|
9
|
-
const PNPM_LOCKFILE = 'pnpm-lock.yaml';
|
|
10
|
-
// Artifacts the executor emits next to the pruned lockfile; without them in
|
|
11
|
-
// `outputs`, a cache replay restores only the manifest and the lockfile.
|
|
12
|
-
const PNPM_PRUNE_ARTIFACTS = [
|
|
13
|
-
'pnpm-workspace.yaml',
|
|
14
|
-
'patches',
|
|
15
|
-
'local_path_modules',
|
|
16
|
-
];
|
|
17
|
-
// The workspace root files those artifacts are built from. Neither the pnpm
|
|
18
|
-
// build approvals nor `supportedArchitectures` are recorded in the lockfile, so
|
|
19
|
-
// nothing else in the hash moves when they change. The pnpm major decides
|
|
20
|
-
// which emitted file carries them, and the ambient binary supplies it when the
|
|
21
|
-
// manifest's `packageManager` field is absent, so the major probe is added
|
|
22
|
-
// alongside.
|
|
23
|
-
const PNPM_ROOT_SETTINGS_SOURCES = [
|
|
24
|
-
'{workspaceRoot}/pnpm-workspace.yaml',
|
|
25
|
-
'{workspaceRoot}/package.json',
|
|
26
|
-
];
|
|
6
|
+
const prune_lockfile_cache_config_1 = require("../../utils/prune-lockfile-cache-config");
|
|
27
7
|
async function update(tree) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
(target.command
|
|
46
|
-
? 'nx:run-commands'
|
|
47
|
-
: (0, target_defaults_matching_1.resolveDefaultsExecutor)(targetName, projectName, projectNode, targetDefaults, PRUNE_LOCKFILE_EXECUTOR));
|
|
48
|
-
if (executor !== PRUNE_LOCKFILE_EXECUTOR) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
pruneTargets.push({
|
|
52
|
-
targetName,
|
|
53
|
-
projectName,
|
|
54
|
-
projectNode,
|
|
55
|
-
matcherExecutor: target.executor,
|
|
56
|
-
target,
|
|
57
|
-
});
|
|
58
|
-
if (appendPnpmPruneOutputs(target)) {
|
|
59
|
-
changedProjects.add(projectName);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
let defaultsChanged = false;
|
|
64
|
-
// runtime applies only the first key that resolves for a target (executor,
|
|
65
|
-
// exact name, then longest glob), so anchor each prune target to its
|
|
66
|
-
// selected key
|
|
67
|
-
const keyedPruneTargets = pruneTargets.map((ref) => ({
|
|
68
|
-
ref,
|
|
69
|
-
selectedKey: targetDefaults
|
|
70
|
-
? (0, target_defaults_matching_1.selectDefaultsKey)(ref, targetDefaults, PRUNE_LOCKFILE_EXECUTOR)
|
|
71
|
-
: null,
|
|
72
|
-
}));
|
|
73
|
-
if (targetDefaults) {
|
|
74
|
-
for (const [key, value] of Object.entries(targetDefaults)) {
|
|
75
|
-
// a value may be the plain object form or the filtered array form
|
|
76
|
-
for (const config of Array.isArray(value) ? value : [value]) {
|
|
77
|
-
if (!appliesToPruneLockfileTargets(key, config, keyedPruneTargets)) {
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
defaultsChanged = appendPnpmPruneOutputs(config) || defaultsChanged;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// `inputs` is decided separately from `outputs`, because the two can be
|
|
85
|
-
// authored on different layers and a target's own `inputs` replaces the
|
|
86
|
-
// defaults' array rather than merging with it. The sources are only ever
|
|
87
|
-
// appended to an array that already exists, or written with nx's default as
|
|
88
|
-
// the base when no layer declares one. The migration never authors a `'...'`
|
|
89
|
-
// of its own: whether the entry it would expand against survives depends on
|
|
90
|
-
// the document-order identity resets in nx's own merge, and a spread that
|
|
91
|
-
// ends up with nothing to expand narrows the target to the two root files.
|
|
92
|
-
for (const { ref, selectedKey } of keyedPruneTargets) {
|
|
93
|
-
const entries = (0, target_defaults_matching_1.compatibleDefaultsEntries)(ref, selectedKey, targetDefaults);
|
|
94
|
-
const defaults = entries.length
|
|
95
|
-
? (0, internal_1.readTargetDefaultsForTarget)(ref.targetName, { [selectedKey]: entries }, ref.matcherExecutor, { projectName: ref.projectName, projectNode: ref.projectNode })
|
|
96
|
-
: null;
|
|
97
|
-
// The effective outputs, not the target's own array: a target inheriting
|
|
98
|
-
// its lockfile entry, or spreading the defaults' outputs into its own, is
|
|
99
|
-
// still a pnpm prune target.
|
|
100
|
-
const effective = (0, internal_1.mergeTargetConfigurations)(ref.target, defaults ?? {});
|
|
101
|
-
if (!declaresPnpmLockfile(effective.outputs)) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (ref.target.inputs !== undefined) {
|
|
105
|
-
// A target's own array wins outright, so nothing else can carry them.
|
|
106
|
-
if (addRootSettingsInputs(ref.target, effective.inputs)) {
|
|
107
|
-
changedProjects.add(ref.projectName);
|
|
108
|
-
}
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
// Otherwise they belong to the entry supplying the array the target
|
|
112
|
-
// inherits, which is the last matching one declaring `inputs`.
|
|
113
|
-
const supplier = (0, target_defaults_matching_1.lastMatchingInputsSupplier)(ref, selectedKey, entries);
|
|
114
|
-
if (supplier) {
|
|
115
|
-
defaultsChanged =
|
|
116
|
-
addRootSettingsInputs(supplier, effective.inputs) || defaultsChanged;
|
|
117
|
-
}
|
|
118
|
-
else if (addRootSettingsInputs(ref.target, effective.inputs)) {
|
|
119
|
-
changedProjects.add(ref.projectName);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
// A workspace configuring its prune targets purely through `targetDefaults`
|
|
123
|
-
// has no concrete target to carry the decision above.
|
|
124
|
-
if (targetDefaults && pruneTargets.length === 0) {
|
|
125
|
-
for (const [key, value] of Object.entries(targetDefaults)) {
|
|
126
|
-
const entries = Array.isArray(value) ? value : [value];
|
|
127
|
-
// The key qualifies only when it locates the executor without a
|
|
128
|
-
// concrete target to resolve against: the key itself, an entry pinning
|
|
129
|
-
// it, or an entry filtering on it. Every identity-compatible sibling
|
|
130
|
-
// still merges for such a target, an identity-neutral one included.
|
|
131
|
-
const compatible = entries.filter(entryIdentityCompatible);
|
|
132
|
-
const locatesExecutor = key === PRUNE_LOCKFILE_EXECUTOR ||
|
|
133
|
-
compatible.some((config) => config.executor === PRUNE_LOCKFILE_EXECUTOR ||
|
|
134
|
-
config.filter?.executor === PRUNE_LOCKFILE_EXECUTOR);
|
|
135
|
-
if (!locatesExecutor ||
|
|
136
|
-
!compatible.some((config) => declaresPnpmLockfile(config.outputs))) {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
// Every compatible entry declaring `inputs` can be the array a future
|
|
140
|
-
// target inherits (a later filtered one replaces it for its projects),
|
|
141
|
-
// so each carries the sources itself; a sibling's array covers nothing
|
|
142
|
-
// unless a `'...'` spread pulls it in, in which case only the strictly
|
|
143
|
-
// filter-less earlier entries are the base it expands against: a
|
|
144
|
-
// filtered one supplies nothing to the targets its filter excludes,
|
|
145
|
-
// an executor filter failing for a target whose executor a sibling
|
|
146
|
-
// supplies (earlier entries are updated first, so the base is checked
|
|
147
|
-
// with the sources already added).
|
|
148
|
-
const suppliers = compatible.filter((config) => config.inputs !== undefined);
|
|
149
|
-
for (const [index, config] of compatible.entries()) {
|
|
150
|
-
if (config.inputs === undefined) {
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const reference = config.inputs.includes('...')
|
|
154
|
-
? [
|
|
155
|
-
...config.inputs,
|
|
156
|
-
...compatible
|
|
157
|
-
.slice(0, index)
|
|
158
|
-
.filter((earlier) => !earlier.filter)
|
|
159
|
-
.flatMap((earlier) => earlier.inputs ?? []),
|
|
160
|
-
]
|
|
161
|
-
: config.inputs;
|
|
162
|
-
defaultsChanged =
|
|
163
|
-
addRootSettingsInputs(config, reference) || defaultsChanged;
|
|
164
|
-
}
|
|
165
|
-
// Targets no filtered supplier matches fall back to nx's own default
|
|
166
|
-
// when no filter-less entry declares an array, so the spelled-out
|
|
167
|
-
// default is prepended as its own entry: prepending keeps it from
|
|
168
|
-
// replacing a later supplier's array. A prepended carrier must match
|
|
169
|
-
// only targets an existing entry already matched, or the key starts
|
|
170
|
-
// winning selection for targets that previously fell through to their
|
|
171
|
-
// name or glob defaults. That holds under an executor key with a
|
|
172
|
-
// filter-less entry (a neutral carrier), and under a name or glob key
|
|
173
|
-
// with a filter-less pin (a pinned carrier, which a same-name target of
|
|
174
|
-
// another executor cannot inherit). An all-filtered array gets no
|
|
175
|
-
// fallback: any carrier would widen the key. The object form has no
|
|
176
|
-
// room to prepend; its single filter-less entry carries it instead.
|
|
177
|
-
if (!suppliers.some((supplier) => !supplier.filter)) {
|
|
178
|
-
const canCarry = key === PRUNE_LOCKFILE_EXECUTOR
|
|
179
|
-
? compatible.some((config) => !config.filter)
|
|
180
|
-
: compatible.some((config) => !config.filter && config.executor === PRUNE_LOCKFILE_EXECUTOR);
|
|
181
|
-
if (canCarry) {
|
|
182
|
-
if (Array.isArray(value)) {
|
|
183
|
-
const fallback = key === PRUNE_LOCKFILE_EXECUTOR
|
|
184
|
-
? {}
|
|
185
|
-
: { executor: PRUNE_LOCKFILE_EXECUTOR };
|
|
186
|
-
addRootSettingsInputs(fallback, []);
|
|
187
|
-
value.unshift(fallback);
|
|
188
|
-
defaultsChanged = true;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
defaultsChanged =
|
|
192
|
-
addRootSettingsInputs(value, []) || defaultsChanged;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
for (const projectName of changedProjects) {
|
|
199
|
-
(0, devkit_1.updateProjectConfiguration)(tree, projectName, projects.get(projectName));
|
|
200
|
-
}
|
|
201
|
-
if (defaultsChanged) {
|
|
202
|
-
(0, devkit_1.updateNxJson)(tree, nxJson);
|
|
203
|
-
}
|
|
8
|
+
(0, prune_lockfile_cache_config_1.addPruneLockfileCacheConfig)(tree, {
|
|
9
|
+
lockFile: 'pnpm-lock.yaml',
|
|
10
|
+
// Artifacts the executor emits next to the pruned lockfile; without them
|
|
11
|
+
// in `outputs`, a cache replay restores only the manifest and the lockfile.
|
|
12
|
+
artifacts: ['pnpm-workspace.yaml', 'patches', 'local_path_modules'],
|
|
13
|
+
// The workspace root files those artifacts are built from. Neither the
|
|
14
|
+
// pnpm build approvals nor `supportedArchitectures` are recorded in the
|
|
15
|
+
// lockfile, so nothing else in the hash moves when they change. The pnpm
|
|
16
|
+
// major decides which emitted file carries them, and the ambient binary
|
|
17
|
+
// supplies it when the manifest's `packageManager` field is absent, so the
|
|
18
|
+
// major probe is added alongside.
|
|
19
|
+
rootInputs: [
|
|
20
|
+
'{workspaceRoot}/pnpm-workspace.yaml',
|
|
21
|
+
'{workspaceRoot}/package.json',
|
|
22
|
+
pnpm_install_settings_inputs_1.PNPM_MAJOR_RUNTIME_INPUT,
|
|
23
|
+
],
|
|
24
|
+
});
|
|
204
25
|
await (0, devkit_1.formatFiles)(tree);
|
|
205
26
|
}
|
|
206
|
-
function declaresPnpmLockfile(outputs) {
|
|
207
|
-
return pnpmLockfileEntry(outputs) !== undefined;
|
|
208
|
-
}
|
|
209
|
-
function pnpmLockfileEntry(outputs) {
|
|
210
|
-
return outputs?.find((output) => typeof output === 'string' &&
|
|
211
|
-
(output === PNPM_LOCKFILE || output.endsWith(`/${PNPM_LOCKFILE}`)));
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Adds the workspace root files the pnpm install settings live in, and the
|
|
215
|
-
* pnpm major probe, skipping any the target already hashes: a `'...'` in the
|
|
216
|
-
* owner's array can carry one in from the layer below, where a check against
|
|
217
|
-
* the owner's own entries cannot see it. An absent `inputs` means nx's own
|
|
218
|
-
* default, so that is spelled out before adding to it rather than narrowing
|
|
219
|
-
* the configuration to the settings sources alone.
|
|
220
|
-
*/
|
|
221
|
-
function addRootSettingsInputs(config, referenceInputs = []) {
|
|
222
|
-
const alreadyHashed = (0, target_defaults_matching_1.namedFilesets)(referenceInputs);
|
|
223
|
-
const missing = PNPM_ROOT_SETTINGS_SOURCES.filter((source) => !alreadyHashed.has(source) && !config.inputs?.includes(source));
|
|
224
|
-
if (!hasPnpmMajorProbe(referenceInputs) &&
|
|
225
|
-
!hasPnpmMajorProbe(config.inputs)) {
|
|
226
|
-
missing.push(pnpm_install_settings_inputs_1.PNPM_MAJOR_RUNTIME_INPUT);
|
|
227
|
-
}
|
|
228
|
-
if (missing.length === 0) {
|
|
229
|
-
return false;
|
|
230
|
-
}
|
|
231
|
-
config.inputs = [...(config.inputs ?? target_defaults_matching_1.DEFAULT_INPUTS), ...missing];
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
function hasPnpmMajorProbe(inputs) {
|
|
235
|
-
return (inputs ?? []).some((existing) => typeof existing === 'object' &&
|
|
236
|
-
existing !== null &&
|
|
237
|
-
'runtime' in existing &&
|
|
238
|
-
existing.runtime === pnpm_install_settings_inputs_1.PNPM_MAJOR_RUNTIME_INPUT.runtime);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Whether a `targetDefaults` entry applies to `@nx/js:prune-lockfile` targets,
|
|
242
|
-
* mirroring nx's runtime matching: the entry's `filter` and merge-time
|
|
243
|
-
* payload compatibility are evaluated first, then the entry must sit under a
|
|
244
|
-
* prune target's selected key and match its context. Entries locating the
|
|
245
|
-
* executor (key, `executor` field, or `filter.executor`) match without a
|
|
246
|
-
* concrete target so a defaults-only workspace still gets the update. The
|
|
247
|
-
* in-key merge accumulation (identity replacement, outputs replacement, `...`
|
|
248
|
-
* spreads) is deliberately not replicated: an entry the merge ends up
|
|
249
|
-
* discarding for the prune target may still get the artifacts appended, which
|
|
250
|
-
* is additive-only for the target's own replay.
|
|
251
|
-
*/
|
|
252
|
-
function appliesToPruneLockfileTargets(key, config, pruneTargets) {
|
|
253
|
-
if (!entryIdentityCompatible(config)) {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
const filter = config.filter;
|
|
257
|
-
if (pruneTargets.length === 0) {
|
|
258
|
-
const locatesExecutor = key === PRUNE_LOCKFILE_EXECUTOR ||
|
|
259
|
-
config.executor === PRUNE_LOCKFILE_EXECUTOR ||
|
|
260
|
-
filter?.executor === PRUNE_LOCKFILE_EXECUTOR;
|
|
261
|
-
return locatesExecutor && !filter?.projects;
|
|
262
|
-
}
|
|
263
|
-
return pruneTargets.some(({ ref, selectedKey }) => selectedKey === key &&
|
|
264
|
-
(0, internal_1.readTargetDefaultsForTarget)(ref.targetName, { [key]: [config] }, ref.matcherExecutor, { projectName: ref.projectName, projectNode: ref.projectNode }) !== null);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Whether a `targetDefaults` entry can merge into an `@nx/js:prune-lockfile`
|
|
268
|
-
* target at all: a filter or payload pinning another executor or a command
|
|
269
|
-
* identity never does (isCompatibleTarget), and prune-lockfile targets are
|
|
270
|
-
* always explicitly configured, never inferred, so a plugin-filtered entry
|
|
271
|
-
* never applies either.
|
|
272
|
-
*/
|
|
273
|
-
function entryIdentityCompatible(config) {
|
|
274
|
-
const filter = config.filter;
|
|
275
|
-
if (filter?.executor && filter.executor !== PRUNE_LOCKFILE_EXECUTOR) {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
if (filter?.plugin) {
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
|
-
return !((config.executor && config.executor !== PRUNE_LOCKFILE_EXECUTOR) ||
|
|
282
|
-
config.command);
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Appends the pnpm prune artifacts next to an existing pnpm-lock.yaml entry,
|
|
286
|
-
* reusing that entry's own path spelling. Configurations with no `outputs` or no
|
|
287
|
-
* pnpm lockfile entry are left alone: the lockfile entry is what identifies the
|
|
288
|
-
* target as pnpm's, and one without `outputs` caches nothing to begin with.
|
|
289
|
-
*/
|
|
290
|
-
function appendPnpmPruneOutputs(config) {
|
|
291
|
-
const lockfileEntry = pnpmLockfileEntry(config.outputs);
|
|
292
|
-
if (!lockfileEntry) {
|
|
293
|
-
return false;
|
|
294
|
-
}
|
|
295
|
-
const prefix = lockfileEntry.slice(0, -PNPM_LOCKFILE.length);
|
|
296
|
-
let changed = false;
|
|
297
|
-
for (const artifact of PNPM_PRUNE_ARTIFACTS) {
|
|
298
|
-
const entry = `${prefix}${artifact}`;
|
|
299
|
-
if (!config.outputs.includes(entry)) {
|
|
300
|
-
config.outputs.push(entry);
|
|
301
|
-
changed = true;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return changed;
|
|
305
|
-
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Tree } from '@nx/devkit';
|
|
2
|
+
/**
|
|
3
|
+
* Adds the root package.json fields a pruned Bun deploy output is built from
|
|
4
|
+
* to the `inputs` of build targets that emit it. The trust list reaches no
|
|
5
|
+
* package's hash, so without them an untrusted package leaves the task hash
|
|
6
|
+
* unchanged and a cached run replays an output that still trusts it.
|
|
7
|
+
*/
|
|
8
|
+
export default function update(tree: Tree): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const bun_install_settings_inputs_1 = require("../../utils/bun-install-settings-inputs");
|
|
6
|
+
const deploy_output_cache_inputs_1 = require("../../utils/deploy-output-cache-inputs");
|
|
7
|
+
/**
|
|
8
|
+
* Adds the root package.json fields a pruned Bun deploy output is built from
|
|
9
|
+
* to the `inputs` of build targets that emit it. The trust list reaches no
|
|
10
|
+
* package's hash, so without them an untrusted package leaves the task hash
|
|
11
|
+
* unchanged and a cached run replays an output that still trusts it.
|
|
12
|
+
*/
|
|
13
|
+
async function update(tree) {
|
|
14
|
+
// A workspace on the binary bun.lockb gets the inputs too: its output
|
|
15
|
+
// carries the trust list once it switches to bun.lock.
|
|
16
|
+
if (!tree.exists('bun.lock') && !tree.exists('bun.lockb')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
await (0, deploy_output_cache_inputs_1.addDeployOutputCacheInputsToBuildTargets)(tree, bun_install_settings_inputs_1.BUN_INSTALL_SETTINGS_INPUTS);
|
|
20
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#### Add the Bun install settings fields to the inputs of build targets that emit the pruned deploy output
|
|
2
|
+
|
|
3
|
+
In a Bun workspace on the text `bun.lock`, build executors that generate a deployable `package.json` now also emit a pruned `bun.lock` and the `.patch` files of a `bun patch` workspace next to it. `@nx/esbuild:esbuild` builds do this when `generatePackageJson` is enabled, `@nx/js:tsc` and `@nx/js:swc` builds when `generateLockfile` is, and builds inferred by `@nx/webpack/plugin` or `@nx/rspack/plugin` when `NxAppWebpackPlugin` or `NxAppRspackPlugin` has `generatePackageJson` enabled. The emitted `package.json` carries the root `trustedDependencies` list and the `patchedDependencies` of the patches it ships.
|
|
4
|
+
|
|
5
|
+
Nothing in a build target's default task hash covers the root `trustedDependencies`. Removing a package from that list would replay the previous build from cache and ship an output that still trusts it to run install scripts.
|
|
6
|
+
|
|
7
|
+
The migration adds a `json` input hashing only the `trustedDependencies` and `patchedDependencies` fields of the root `package.json`, so ordinary dependency bumps in the root manifest do not invalidate every build. The patch contents already reach the task hash through the patched packages. Workspaces on the binary `bun.lockb` get the input too. Their deploy output is the `package.json` alone until they switch to the text `bun.lock`, and from then on it carries the trust list.
|
|
8
|
+
|
|
9
|
+
The input is placed with the same rules as the pnpm migration in Nx 23.2 (`update-23-2-0-add-pnpm-deploy-output-cache-inputs`): on the target's own `inputs` when it declares them, otherwise on the `targetDefaults` entry supplying the array it inherits, and otherwise on the target itself with nx's own default spelled out first. An existing whole-file root `package.json` fileset or a `json` input covering both fields counts as already hashing them. Targets inferred by the `@nx/webpack` and `@nx/rspack` plugins declare the input themselves, but a project-level or `targetDefaults` entry that supplies its own `inputs` array without `"..."` replaces the inferred array and discards it; the migration appends the input to that replacing array.
|
|
10
|
+
|
|
11
|
+
#### Sample code changes
|
|
12
|
+
|
|
13
|
+
##### Before
|
|
14
|
+
|
|
15
|
+
```json title="apps/app1/project.json"
|
|
16
|
+
{
|
|
17
|
+
"targets": {
|
|
18
|
+
"build": {
|
|
19
|
+
"executor": "@nx/esbuild:esbuild",
|
|
20
|
+
"options": {
|
|
21
|
+
"generatePackageJson": true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
##### After
|
|
29
|
+
|
|
30
|
+
```json title="apps/app1/project.json"
|
|
31
|
+
{
|
|
32
|
+
"targets": {
|
|
33
|
+
"build": {
|
|
34
|
+
"executor": "@nx/esbuild:esbuild",
|
|
35
|
+
"inputs": [
|
|
36
|
+
"default",
|
|
37
|
+
"^default",
|
|
38
|
+
{
|
|
39
|
+
"json": "{workspaceRoot}/package.json",
|
|
40
|
+
"fields": ["trustedDependencies", "patchedDependencies"]
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"options": {
|
|
44
|
+
"generatePackageJson": true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = update;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const prune_lockfile_cache_config_1 = require("../../utils/prune-lockfile-cache-config");
|
|
6
|
+
// The `bun patch` files and the vendored local-path dependencies the executor
|
|
7
|
+
// emits next to the pruned lockfile; without them in `outputs`, a cache replay
|
|
8
|
+
// restores only the manifest and the lockfile.
|
|
9
|
+
const ARTIFACTS = ['patches', 'local_path_modules'];
|
|
10
|
+
// The root manifest declares the trusted install scripts and the patches the
|
|
11
|
+
// output carries. The trust list reaches no package's hash, so nothing else in
|
|
12
|
+
// the hash moves when a package is untrusted.
|
|
13
|
+
const ROOT_INPUTS = ['{workspaceRoot}/package.json'];
|
|
14
|
+
async function update(tree) {
|
|
15
|
+
(0, prune_lockfile_cache_config_1.addPruneLockfileCacheConfig)(tree, {
|
|
16
|
+
lockFile: 'bun.lock',
|
|
17
|
+
artifacts: ARTIFACTS,
|
|
18
|
+
rootInputs: ROOT_INPUTS,
|
|
19
|
+
});
|
|
20
|
+
// A target generated on the binary bun.lockb declares that file, and the
|
|
21
|
+
// executor writes the text bun.lock once the workspace switches to it.
|
|
22
|
+
(0, prune_lockfile_cache_config_1.addPruneLockfileCacheConfig)(tree, {
|
|
23
|
+
lockFile: 'bun.lockb',
|
|
24
|
+
artifacts: ['bun.lock', ...ARTIFACTS],
|
|
25
|
+
rootInputs: ROOT_INPUTS,
|
|
26
|
+
});
|
|
27
|
+
await (0, devkit_1.formatFiles)(tree);
|
|
28
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#### Update the cache configuration of `@nx/js:prune-lockfile` targets for the Bun install artifacts
|
|
2
|
+
|
|
3
|
+
In a Bun workspace on the text `bun.lock`, the `@nx/js:prune-lockfile` executor now emits a pruned `bun.lock` next to the pruned `package.json`, the `.patch` files of a `bun patch` workspace under `patches/`, and the non-workspace `file:` and `link:` dependencies the output installs under `local_path_modules/`. The emitted `package.json` carries the root `trustedDependencies` list and the `patchedDependencies` of the patches it ships.
|
|
4
|
+
|
|
5
|
+
Targets generated before this change declare only the manifest and the lockfile in `outputs`, so a cache replay in a clean checkout restores just those two files, and `bun install --frozen-lockfile` in the output fails on the missing patch files or vendored packages. The same targets declare no `inputs`, so nothing in the task hash covers the root `trustedDependencies`. Removing a package from that list would replay the previous run's output from cache and ship a manifest that still trusts it. The patch contents and the vendored package contents already reach the task hash through the packages they belong to.
|
|
6
|
+
|
|
7
|
+
The `patches` and `local_path_modules` paths are appended to whichever `outputs` array declares the `bun.lock` entry, reusing that entry's own path prefix. A target generated on the binary `bun.lockb` declares that file instead. It gets the same paths and a `bun.lock` output next to it, because the executor writes the text lockfile once the workspace switches to it. The root `package.json` is added to the `inputs` the target actually uses: its own `inputs` when it declares them, otherwise the `targetDefaults` entry supplying the array it inherits, and otherwise the target itself with nx's own default spelled out first, so nothing that was hashed stops being hashed. Targets on another package manager's lockfile are left alone, as are paths and inputs already present. Placement follows the same rules as the pnpm migration in Nx 23.2 (`update-23-2-0-add-pnpm-prune-lockfile-cache-config`).
|
|
8
|
+
|
|
9
|
+
#### Sample code changes
|
|
10
|
+
|
|
11
|
+
##### Before
|
|
12
|
+
|
|
13
|
+
```json title="apps/app1/project.json"
|
|
14
|
+
{
|
|
15
|
+
"targets": {
|
|
16
|
+
"prune-lockfile": {
|
|
17
|
+
"executor": "@nx/js:prune-lockfile",
|
|
18
|
+
"outputs": [
|
|
19
|
+
"{workspaceRoot}/dist/apps/app1/package.json",
|
|
20
|
+
"{workspaceRoot}/dist/apps/app1/bun.lock"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
##### After
|
|
28
|
+
|
|
29
|
+
```json title="apps/app1/project.json"
|
|
30
|
+
{
|
|
31
|
+
"targets": {
|
|
32
|
+
"prune-lockfile": {
|
|
33
|
+
"executor": "@nx/js:prune-lockfile",
|
|
34
|
+
"inputs": ["default", "^default", "{workspaceRoot}/package.json"],
|
|
35
|
+
"outputs": [
|
|
36
|
+
"{workspaceRoot}/dist/apps/app1/package.json",
|
|
37
|
+
"{workspaceRoot}/dist/apps/app1/bun.lock",
|
|
38
|
+
"{workspaceRoot}/dist/apps/app1/patches",
|
|
39
|
+
"{workspaceRoot}/dist/apps/app1/local_path_modules"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
@@ -205,6 +205,12 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
205
205
|
let version = dependenciesToUpdate[targetProject.projectName];
|
|
206
206
|
if (version !== undefined) {
|
|
207
207
|
if (catalogManager?.isCatalogReference(currentVersion)) {
|
|
208
|
+
const catalogVersion = catalogManager.resolveCatalogReference(tree, dependencyName, currentVersion);
|
|
209
|
+
if (manifestToUpdate.preserveLocalDependencyProtocols &&
|
|
210
|
+
typeof catalogVersion === 'string' &&
|
|
211
|
+
this.isLocalDependencyProtocol(catalogVersion)) {
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
208
214
|
// collect the catalog updates so we can update the catalog definitions later
|
|
209
215
|
const catalogRef = catalogManager.parseCatalogReference(currentVersion);
|
|
210
216
|
catalogUpdates.push({
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PackageManager } from '@nx/devkit';
|
|
2
|
+
import type { JsonInput } from '@nx/devkit/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Task inputs covering the root package.json fields a pruned Bun deploy output
|
|
5
|
+
* is built from: `trustedDependencies` (the packages allowed to run install
|
|
6
|
+
* scripts) and `patchedDependencies` (the patches it declares and ships).
|
|
7
|
+
* Nothing else in a build target's default hash moves when a package is
|
|
8
|
+
* untrusted, so a target that emits the deploy output must hash these or a
|
|
9
|
+
* cached run replays an output that still trusts it. The patch contents reach
|
|
10
|
+
* the hash through the patched packages' external nodes. The manifest is
|
|
11
|
+
* narrowed to these fields so dependency bumps in the root package.json do
|
|
12
|
+
* not invalidate every build.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BUN_INSTALL_SETTINGS_INPUTS: JsonInput[];
|
|
15
|
+
/**
|
|
16
|
+
* Whether an inferred build target needs {@link BUN_INSTALL_SETTINGS_INPUTS}:
|
|
17
|
+
* the workspace uses Bun with the text bun.lock. On the binary bun.lockb the
|
|
18
|
+
* deploy output is the manifest alone, without the trust list or patches.
|
|
19
|
+
*/
|
|
20
|
+
export declare function shouldIncludeBunInstallSettingsInputs(packageManager: PackageManager, workspaceRoot: string): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BUN_INSTALL_SETTINGS_INPUTS = void 0;
|
|
4
|
+
exports.shouldIncludeBunInstallSettingsInputs = shouldIncludeBunInstallSettingsInputs;
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
/**
|
|
8
|
+
* Task inputs covering the root package.json fields a pruned Bun deploy output
|
|
9
|
+
* is built from: `trustedDependencies` (the packages allowed to run install
|
|
10
|
+
* scripts) and `patchedDependencies` (the patches it declares and ships).
|
|
11
|
+
* Nothing else in a build target's default hash moves when a package is
|
|
12
|
+
* untrusted, so a target that emits the deploy output must hash these or a
|
|
13
|
+
* cached run replays an output that still trusts it. The patch contents reach
|
|
14
|
+
* the hash through the patched packages' external nodes. The manifest is
|
|
15
|
+
* narrowed to these fields so dependency bumps in the root package.json do
|
|
16
|
+
* not invalidate every build.
|
|
17
|
+
*/
|
|
18
|
+
exports.BUN_INSTALL_SETTINGS_INPUTS = [
|
|
19
|
+
{
|
|
20
|
+
json: '{workspaceRoot}/package.json',
|
|
21
|
+
fields: ['trustedDependencies', 'patchedDependencies'],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Whether an inferred build target needs {@link BUN_INSTALL_SETTINGS_INPUTS}:
|
|
26
|
+
* the workspace uses Bun with the text bun.lock. On the binary bun.lockb the
|
|
27
|
+
* deploy output is the manifest alone, without the trust list or patches.
|
|
28
|
+
*/
|
|
29
|
+
function shouldIncludeBunInstallSettingsInputs(packageManager, workspaceRoot) {
|
|
30
|
+
return (packageManager === 'bun' && (0, fs_1.existsSync)((0, path_1.join)(workspaceRoot, 'bun.lock')));
|
|
31
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type TargetDefaults, type Tree } from '@nx/devkit';
|
|
2
|
+
import { type JsonInput } from '@nx/devkit/internal';
|
|
3
|
+
import { type MatchedTargetRef } from './target-defaults-matching';
|
|
4
|
+
/**
|
|
5
|
+
* A source of the install settings a pruned deploy output carries and its
|
|
6
|
+
* lockfile does not record: a workspace root file, fields of a root JSON file,
|
|
7
|
+
* or a runtime probe.
|
|
8
|
+
*/
|
|
9
|
+
export type DeployOutputSettingsInput = string | JsonInput | {
|
|
10
|
+
runtime: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Adds `settingsInputs` to the `inputs` of build targets that emit the pruned
|
|
14
|
+
* deploy output. The settings those outputs carry reach no lockfile, so
|
|
15
|
+
* without these a changed setting leaves the task hash unchanged and a cached
|
|
16
|
+
* run replays an output that still carries the old one. Inferred targets are
|
|
17
|
+
* covered by the `@nx/webpack` and `@nx/rspack` plugins themselves; this
|
|
18
|
+
* covers the explicitly configured executor targets, plus overlays of inferred
|
|
19
|
+
* targets (a project-level entry, under the exact name or a glob-pattern key
|
|
20
|
+
* matching it, or a matching `targetDefaults` entry) whose replacing `inputs`
|
|
21
|
+
* array discards the plugin-generated one.
|
|
22
|
+
*/
|
|
23
|
+
export declare function addDeployOutputCacheInputsToBuildTargets(tree: Tree, settingsInputs: readonly DeployOutputSettingsInput[]): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Adds the missing `settingsInputs` to the layer whose `inputs` array the
|
|
26
|
+
* runtime actually uses for this target: the target's own `inputs` when it
|
|
27
|
+
* declares them (its array replaces the defaults' rather than merging with
|
|
28
|
+
* it), otherwise the matching `targetDefaults` entry supplying the array it
|
|
29
|
+
* inherits, and otherwise the target itself with nx's own default spelled out
|
|
30
|
+
* first, so nothing that was hashed stops being hashed. Sources the effective
|
|
31
|
+
* inputs already hash, including via a whole-file fileset of a JSON source or
|
|
32
|
+
* a `json` input covering its fields, are left alone; no `'...'` is ever
|
|
33
|
+
* authored. Returns which layer was mutated, or null when nothing was missing.
|
|
34
|
+
*/
|
|
35
|
+
export declare function addDeployOutputCacheInputs(ref: MatchedTargetRef, targetDefaults: TargetDefaults | undefined, executor: string, settingsInputs: readonly DeployOutputSettingsInput[]): 'target' | 'defaults' | null;
|