@pnpm/catalogs.config 1100.0.0 → 1100.0.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/lib/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { getCatalogsFromWorkspaceManifest } from './getCatalogsFromWorkspaceManifest.js';
2
+ export { mergeCatalogs } from './mergeCatalogs.js';
package/lib/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { getCatalogsFromWorkspaceManifest } from './getCatalogsFromWorkspaceManifest.js';
2
+ export { mergeCatalogs } from './mergeCatalogs.js';
2
3
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,14 @@
1
+ import type { Catalogs } from '@pnpm/catalogs.types';
2
+ /**
3
+ * Deep-merges catalog definitions, later arguments taking precedence over
4
+ * earlier ones at the individual entry level. Use it to fold the catalog
5
+ * changes produced by an install (`updatedCatalogs`) back into the catalogs
6
+ * read at startup, so the result reflects what was actually written to
7
+ * `pnpm-workspace.yaml`.
8
+ *
9
+ * Catalog and dependency names originate from `pnpm-workspace.yaml`, so the
10
+ * result is built from null-prototype records and entries are copied with
11
+ * `Object.defineProperty`. A name like `__proto__` then becomes an ordinary
12
+ * own property instead of mutating a prototype.
13
+ */
14
+ export declare function mergeCatalogs(...catalogsList: Array<Catalogs | undefined>): Catalogs;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Deep-merges catalog definitions, later arguments taking precedence over
3
+ * earlier ones at the individual entry level. Use it to fold the catalog
4
+ * changes produced by an install (`updatedCatalogs`) back into the catalogs
5
+ * read at startup, so the result reflects what was actually written to
6
+ * `pnpm-workspace.yaml`.
7
+ *
8
+ * Catalog and dependency names originate from `pnpm-workspace.yaml`, so the
9
+ * result is built from null-prototype records and entries are copied with
10
+ * `Object.defineProperty`. A name like `__proto__` then becomes an ordinary
11
+ * own property instead of mutating a prototype.
12
+ */
13
+ export function mergeCatalogs(...catalogsList) {
14
+ const result = Object.create(null);
15
+ for (const catalogs of catalogsList) {
16
+ if (catalogs == null)
17
+ continue;
18
+ for (const catalogName of Object.keys(catalogs)) {
19
+ const catalog = catalogs[catalogName];
20
+ if (catalog == null)
21
+ continue;
22
+ const target = result[catalogName] ?? Object.create(null);
23
+ for (const dependencyName of Object.keys(catalog)) {
24
+ Object.defineProperty(target, dependencyName, {
25
+ value: catalog[dependencyName],
26
+ writable: true,
27
+ enumerable: true,
28
+ configurable: true,
29
+ });
30
+ }
31
+ Object.defineProperty(result, catalogName, {
32
+ value: target,
33
+ writable: true,
34
+ enumerable: true,
35
+ configurable: true,
36
+ });
37
+ }
38
+ }
39
+ return result;
40
+ }
41
+ //# sourceMappingURL=mergeCatalogs.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnpm/catalogs.config",
3
- "version": "1100.0.0",
3
+ "version": "1100.0.2",
4
4
  "description": "Create a normalized catalogs config from pnpm-workspace.yaml contents.",
5
5
  "keywords": [
6
6
  "pnpm",
@@ -9,8 +9,11 @@
9
9
  ],
10
10
  "license": "MIT",
11
11
  "funding": "https://opencollective.com/pnpm",
12
- "repository": "https://github.com/pnpm/pnpm/tree/main/catalogs/config",
13
- "homepage": "https://github.com/pnpm/pnpm/tree/main/catalogs/config#readme",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/catalogs/config"
15
+ },
16
+ "homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/catalogs/config#readme",
14
17
  "bugs": {
15
18
  "url": "https://github.com/pnpm/pnpm/issues"
16
19
  },
@@ -25,12 +28,13 @@
25
28
  "!*.map"
26
29
  ],
27
30
  "dependencies": {
28
- "@pnpm/error": "1100.0.0"
31
+ "@pnpm/error": "1100.0.1"
29
32
  },
30
33
  "devDependencies": {
31
- "@pnpm/catalogs.config": "1100.0.0",
34
+ "@jest/globals": "30.4.1",
32
35
  "@pnpm/catalogs.types": "1100.0.0",
33
- "@pnpm/workspace.workspace-manifest-reader": "1100.0.0"
36
+ "@pnpm/catalogs.config": "1100.0.2",
37
+ "@pnpm/workspace.workspace-manifest-reader": "1100.0.9"
34
38
  },
35
39
  "engines": {
36
40
  "node": ">=22.13"