@pnpm/workspace.workspace-manifest-writer 1100.1.2 → 1100.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +63 -60
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @pnpm/workspace.manifest-writer
|
|
2
2
|
|
|
3
|
+
## 1100.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added a new setting `trustPolicyExcludePrune` (default: `false`). When enabled, `pnpm add`, `pnpm update`, and `pnpm remove` prune the entries of `trustPolicyExclude` in `pnpm-workspace.yaml` that the freshly written lockfile no longer resolves: versions that are gone are dropped (an entry is removed once none of its versions remain), and entries for packages that are no longer in the lockfile are removed too. Name patterns (`@scope/*`) are always kept. The cleanup is skipped when the install's lockfile does not cover the whole workspace (`sharedWorkspaceLockfile: false`), since entries another project still needs would look stale.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies:
|
|
12
|
+
- @pnpm/building.policy@1100.1.1
|
|
13
|
+
|
|
14
|
+
## 1100.1.3
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies:
|
|
19
|
+
- @pnpm/building.policy@1100.1.0
|
|
20
|
+
- @pnpm/config.parse-overrides@1100.1.5
|
|
21
|
+
- @pnpm/config.version-policy@1100.2.3
|
|
22
|
+
- @pnpm/lockfile.types@1100.1.1
|
|
23
|
+
- @pnpm/workspace.workspace-manifest-reader@1100.1.9
|
|
24
|
+
|
|
3
25
|
## 1100.1.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/lib/index.d.ts
CHANGED
|
@@ -22,11 +22,12 @@ export declare function updateWorkspaceManifest(dir: string, opts: {
|
|
|
22
22
|
/**
|
|
23
23
|
* Package name → the versions the freshly resolved lockfile records.
|
|
24
24
|
* Supplied when a freshly resolved shared lockfile is available.
|
|
25
|
-
* `minimumReleaseAgeExcludePrune`
|
|
26
|
-
* `allowBuilds` cleanup runs whenever this map is present.
|
|
25
|
+
* `minimumReleaseAgeExcludePrune` and `trustPolicyExcludePrune` gate their
|
|
26
|
+
* cleanups; `allowBuilds` cleanup runs whenever this map is present.
|
|
27
27
|
*/
|
|
28
28
|
resolvedPackageVersions?: ReadonlyMap<string, ReadonlySet<string>>;
|
|
29
29
|
minimumReleaseAgeExcludePrune?: boolean;
|
|
30
|
+
trustPolicyExcludePrune?: boolean;
|
|
30
31
|
}): Promise<void>;
|
|
31
32
|
export interface NewCatalogs {
|
|
32
33
|
[catalogName: string]: {
|
package/lib/index.js
CHANGED
|
@@ -83,7 +83,10 @@ export async function updateWorkspaceManifest(dir, opts) {
|
|
|
83
83
|
}
|
|
84
84
|
if (opts.resolvedPackageVersions != null) {
|
|
85
85
|
if (opts.minimumReleaseAgeExcludePrune) {
|
|
86
|
-
shouldBeUpdated =
|
|
86
|
+
shouldBeUpdated = pruneExcludeList(manifest, 'minimumReleaseAgeExclude', opts.resolvedPackageVersions) || shouldBeUpdated;
|
|
87
|
+
}
|
|
88
|
+
if (opts.trustPolicyExcludePrune) {
|
|
89
|
+
shouldBeUpdated = pruneExcludeList(manifest, 'trustPolicyExclude', opts.resolvedPackageVersions) || shouldBeUpdated;
|
|
87
90
|
}
|
|
88
91
|
shouldBeUpdated = pruneAllowBuilds(manifest, opts.resolvedPackageVersions) || shouldBeUpdated;
|
|
89
92
|
}
|
|
@@ -220,63 +223,15 @@ function addPackageReference(packageReferences, pkgName, version) {
|
|
|
220
223
|
}
|
|
221
224
|
packageReferences[pkgName].add(version);
|
|
222
225
|
}
|
|
223
|
-
// The `minimumReleaseAgeExcludePrune`
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
// install.
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
* whichever spelling the manifest uses — the canonical `audit.ignore` wins
|
|
233
|
-
* over the deprecated `auditConfig.ignoreGhsas`, matching the reader's
|
|
234
|
-
* precedence, so a stale canonical list can't shadow the update on the next
|
|
235
|
-
* read. When both spellings are present, the shadowed deprecated list is
|
|
236
|
-
* removed as part of the write. `auditConfig.ignoreGhsas` is created when
|
|
237
|
-
* neither is present. An empty `ghsas` removes the list, dropping its parent
|
|
238
|
-
* block when nothing else remains in it. Returns whether anything changed.
|
|
239
|
-
*/
|
|
240
|
-
function setAuditIgnoreGhsas(manifest, ghsas) {
|
|
241
|
-
let changed = false;
|
|
242
|
-
if (manifest.audit?.ignore != null) {
|
|
243
|
-
if (ghsas.length === 0) {
|
|
244
|
-
delete manifest.audit.ignore;
|
|
245
|
-
if (Object.keys(manifest.audit).length === 0) {
|
|
246
|
-
delete manifest.audit;
|
|
247
|
-
}
|
|
248
|
-
changed = true;
|
|
249
|
-
}
|
|
250
|
-
else if (!equals(manifest.audit.ignore, ghsas)) {
|
|
251
|
-
manifest.audit.ignore = ghsas;
|
|
252
|
-
changed = true;
|
|
253
|
-
}
|
|
254
|
-
if (manifest.auditConfig?.ignoreGhsas != null) {
|
|
255
|
-
changed = removeAuditConfigIgnoreGhsas(manifest) || changed;
|
|
256
|
-
}
|
|
257
|
-
return changed;
|
|
258
|
-
}
|
|
259
|
-
if (ghsas.length === 0) {
|
|
260
|
-
return removeAuditConfigIgnoreGhsas(manifest);
|
|
261
|
-
}
|
|
262
|
-
if (equals(manifest.auditConfig?.ignoreGhsas, ghsas)) {
|
|
263
|
-
return false;
|
|
264
|
-
}
|
|
265
|
-
manifest.auditConfig = { ...manifest.auditConfig, ignoreGhsas: ghsas };
|
|
266
|
-
return true;
|
|
267
|
-
}
|
|
268
|
-
function removeAuditConfigIgnoreGhsas(manifest) {
|
|
269
|
-
if (manifest.auditConfig?.ignoreGhsas == null) {
|
|
270
|
-
return false;
|
|
271
|
-
}
|
|
272
|
-
delete manifest.auditConfig.ignoreGhsas;
|
|
273
|
-
if (Object.keys(manifest.auditConfig).length === 0) {
|
|
274
|
-
delete manifest.auditConfig;
|
|
275
|
-
}
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
function pruneMinimumReleaseAgeExcludes(manifest, resolvedPackageVersions) {
|
|
279
|
-
const excludes = manifest.minimumReleaseAgeExclude;
|
|
226
|
+
// The `minimumReleaseAgeExcludePrune` / `trustPolicyExcludePrune` pass over
|
|
227
|
+
// the exclude list `field` names. An entry is dropped when the freshly
|
|
228
|
+
// resolved lockfile no longer contains what it names: exact versions that
|
|
229
|
+
// were not resolved are dropped (the entry goes away once none remain), and a
|
|
230
|
+
// bare-name entry goes away when the package is absent entirely. Glob patterns
|
|
231
|
+
// always stay — they are forward-looking and can't be proven stale. Entries
|
|
232
|
+
// that fail to parse stay untouched so cleanup never breaks an install.
|
|
233
|
+
function pruneExcludeList(manifest, field, resolvedPackageVersions) {
|
|
234
|
+
const excludes = manifest[field];
|
|
280
235
|
if (excludes == null || excludes.length === 0) {
|
|
281
236
|
return false;
|
|
282
237
|
}
|
|
@@ -320,10 +275,58 @@ function pruneMinimumReleaseAgeExcludes(manifest, resolvedPackageVersions) {
|
|
|
320
275
|
return false;
|
|
321
276
|
}
|
|
322
277
|
if (survivingSpecs.length === 0) {
|
|
323
|
-
delete manifest
|
|
278
|
+
delete manifest[field];
|
|
324
279
|
}
|
|
325
280
|
else {
|
|
326
|
-
manifest
|
|
281
|
+
manifest[field] = survivingSpecs;
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Set the audit ignore list to `ghsas` (the complete desired list) in
|
|
287
|
+
* whichever spelling the manifest uses — the canonical `audit.ignore` wins
|
|
288
|
+
* over the deprecated `auditConfig.ignoreGhsas`, matching the reader's
|
|
289
|
+
* precedence, so a stale canonical list can't shadow the update on the next
|
|
290
|
+
* read. When both spellings are present, the shadowed deprecated list is
|
|
291
|
+
* removed as part of the write. `auditConfig.ignoreGhsas` is created when
|
|
292
|
+
* neither is present. An empty `ghsas` removes the list, dropping its parent
|
|
293
|
+
* block when nothing else remains in it. Returns whether anything changed.
|
|
294
|
+
*/
|
|
295
|
+
function setAuditIgnoreGhsas(manifest, ghsas) {
|
|
296
|
+
let changed = false;
|
|
297
|
+
if (manifest.audit?.ignore != null) {
|
|
298
|
+
if (ghsas.length === 0) {
|
|
299
|
+
delete manifest.audit.ignore;
|
|
300
|
+
if (Object.keys(manifest.audit).length === 0) {
|
|
301
|
+
delete manifest.audit;
|
|
302
|
+
}
|
|
303
|
+
changed = true;
|
|
304
|
+
}
|
|
305
|
+
else if (!equals(manifest.audit.ignore, ghsas)) {
|
|
306
|
+
manifest.audit.ignore = ghsas;
|
|
307
|
+
changed = true;
|
|
308
|
+
}
|
|
309
|
+
if (manifest.auditConfig?.ignoreGhsas != null) {
|
|
310
|
+
changed = removeAuditConfigIgnoreGhsas(manifest) || changed;
|
|
311
|
+
}
|
|
312
|
+
return changed;
|
|
313
|
+
}
|
|
314
|
+
if (ghsas.length === 0) {
|
|
315
|
+
return removeAuditConfigIgnoreGhsas(manifest);
|
|
316
|
+
}
|
|
317
|
+
if (equals(manifest.auditConfig?.ignoreGhsas, ghsas)) {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
manifest.auditConfig = { ...manifest.auditConfig, ignoreGhsas: ghsas };
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
function removeAuditConfigIgnoreGhsas(manifest) {
|
|
324
|
+
if (manifest.auditConfig?.ignoreGhsas == null) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
delete manifest.auditConfig.ignoreGhsas;
|
|
328
|
+
if (Object.keys(manifest.auditConfig).length === 0) {
|
|
329
|
+
delete manifest.auditConfig;
|
|
327
330
|
}
|
|
328
331
|
return true;
|
|
329
332
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/workspace.workspace-manifest-writer",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.2.0",
|
|
4
4
|
"description": "Updates the workspace manifest file",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"!*.map"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pnpm/building.policy": "1100.
|
|
30
|
+
"@pnpm/building.policy": "1100.1.1",
|
|
31
31
|
"@pnpm/catalogs.types": "1100.0.1",
|
|
32
|
-
"@pnpm/config.parse-overrides": "1100.1.
|
|
33
|
-
"@pnpm/config.version-policy": "1100.2.
|
|
32
|
+
"@pnpm/config.parse-overrides": "1100.1.5",
|
|
33
|
+
"@pnpm/config.version-policy": "1100.2.3",
|
|
34
34
|
"@pnpm/constants": "1102.0.0",
|
|
35
|
-
"@pnpm/lockfile.types": "1100.1.
|
|
35
|
+
"@pnpm/lockfile.types": "1100.1.1",
|
|
36
36
|
"@pnpm/text.ordinal-comparator": "1100.0.0",
|
|
37
37
|
"@pnpm/types": "1102.1.0",
|
|
38
|
-
"@pnpm/workspace.workspace-manifest-reader": "1100.1.
|
|
38
|
+
"@pnpm/workspace.workspace-manifest-reader": "1100.1.9",
|
|
39
39
|
"@pnpm/yaml.document-sync": "1100.0.1",
|
|
40
40
|
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
41
41
|
"write-file-atomic": "^7.0.1",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@jest/globals": "30.4.1",
|
|
46
|
-
"@pnpm/prepare": "1100.0.
|
|
46
|
+
"@pnpm/prepare": "1100.0.30",
|
|
47
47
|
"@pnpm/prepare-temp-dir": "1100.0.1",
|
|
48
|
-
"@pnpm/workspace.projects-reader": "1101.0.
|
|
49
|
-
"@pnpm/workspace.workspace-manifest-writer": "1100.
|
|
48
|
+
"@pnpm/workspace.projects-reader": "1101.0.27",
|
|
49
|
+
"@pnpm/workspace.workspace-manifest-writer": "1100.2.0",
|
|
50
50
|
"@types/ramda": "0.32.0",
|
|
51
51
|
"@types/write-file-atomic": "^4.0.3",
|
|
52
52
|
"read-yaml-file": "^3.0.0",
|