@pnpm/catalogs.config 0.1.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2024 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @pnpm/catalogs.config
2
+
3
+ > Create a normalized catalogs config from `pnpm-workspace.yaml` contents.
@@ -0,0 +1,4 @@
1
+ import { type Catalogs } from '@pnpm/catalogs.types';
2
+ import { type WorkspaceManifest } from '@pnpm/workspace.read-manifest';
3
+ export declare function getCatalogsFromWorkspaceManifest(workspaceManifest: Pick<WorkspaceManifest, 'catalog' | 'catalogs'> | undefined): Catalogs;
4
+ export declare function checkDefaultCatalogIsDefinedOnce(manifest: Pick<WorkspaceManifest, 'catalog' | 'catalogs'>): void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkDefaultCatalogIsDefinedOnce = exports.getCatalogsFromWorkspaceManifest = void 0;
4
+ const error_1 = require("@pnpm/error");
5
+ function getCatalogsFromWorkspaceManifest(workspaceManifest) {
6
+ // If the pnpm-workspace.yaml file doesn't exist, no catalogs are defined.
7
+ //
8
+ // In some cases, it makes sense for callers to handle null/undefined checks
9
+ // of this form. In this case, let's explicitly handle not found
10
+ // pnpm-workspace.yaml files by returning an empty catalog to make consuming
11
+ // logic easier.
12
+ if (workspaceManifest == null) {
13
+ return {};
14
+ }
15
+ checkDefaultCatalogIsDefinedOnce(workspaceManifest);
16
+ return {
17
+ // If workspaceManifest.catalog is undefined, intentionally allow the spread
18
+ // below to overwrite it. The check above ensures only one or the either is
19
+ // defined.
20
+ default: workspaceManifest.catalog,
21
+ ...workspaceManifest.catalogs,
22
+ };
23
+ }
24
+ exports.getCatalogsFromWorkspaceManifest = getCatalogsFromWorkspaceManifest;
25
+ function checkDefaultCatalogIsDefinedOnce(manifest) {
26
+ if (manifest.catalog != null && manifest.catalogs?.default != null) {
27
+ throw new error_1.PnpmError('INVALID_CATALOGS_CONFIGURATION', 'The \'default\' catalog was defined multiple times. Use the \'catalog\' field or \'catalogs.default\', but not both.');
28
+ }
29
+ }
30
+ exports.checkDefaultCatalogIsDefinedOnce = checkDefaultCatalogIsDefinedOnce;
31
+ //# sourceMappingURL=getCatalogsFromWorkspaceManifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getCatalogsFromWorkspaceManifest.js","sourceRoot":"","sources":["../src/getCatalogsFromWorkspaceManifest.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AAIvC,SAAgB,gCAAgC,CAC9C,iBAA8E;IAE9E,0EAA0E;IAC1E,EAAE;IACF,4EAA4E;IAC5E,gEAAgE;IAChE,4EAA4E;IAC5E,gBAAgB;IAChB,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAA;IACX,CAAC;IAED,gCAAgC,CAAC,iBAAiB,CAAC,CAAA;IAEnD,OAAO;QACL,4EAA4E;QAC5E,2EAA2E;QAC3E,WAAW;QACX,OAAO,EAAE,iBAAiB,CAAC,OAAO;QAElC,GAAG,iBAAiB,CAAC,QAAQ;KAC9B,CAAA;AACH,CAAC;AAvBD,4EAuBC;AAED,SAAgB,gCAAgC,CAAE,QAAyD;IACzG,IAAI,QAAQ,CAAC,OAAO,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC;QACnE,MAAM,IAAI,iBAAS,CACjB,gCAAgC,EAChC,sHAAsH,CAAC,CAAA;IAC3H,CAAC;AACH,CAAC;AAND,4EAMC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { getCatalogsFromWorkspaceManifest } from './getCatalogsFromWorkspaceManifest';
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCatalogsFromWorkspaceManifest = void 0;
4
+ var getCatalogsFromWorkspaceManifest_1 = require("./getCatalogsFromWorkspaceManifest");
5
+ Object.defineProperty(exports, "getCatalogsFromWorkspaceManifest", { enumerable: true, get: function () { return getCatalogsFromWorkspaceManifest_1.getCatalogsFromWorkspaceManifest; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uFAAqF;AAA5E,oJAAA,gCAAgC,OAAA"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@pnpm/catalogs.config",
3
+ "version": "0.1.0",
4
+ "description": "Create a normalized catalogs config from pnpm-workspace.yaml contents.",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "engines": {
8
+ "node": ">=18.12"
9
+ },
10
+ "files": [
11
+ "lib",
12
+ "!*.map"
13
+ ],
14
+ "repository": "https://github.com/pnpm/pnpm/blob/main/catalogs/config",
15
+ "keywords": [
16
+ "pnpm9",
17
+ "pnpm",
18
+ "types"
19
+ ],
20
+ "license": "MIT",
21
+ "bugs": {
22
+ "url": "https://github.com/pnpm/pnpm/issues"
23
+ },
24
+ "homepage": "https://github.com/pnpm/pnpm/blob/main/catalogs/config#readme",
25
+ "funding": "https://opencollective.com/pnpm",
26
+ "exports": {
27
+ ".": "./lib/index.js"
28
+ },
29
+ "dependencies": {
30
+ "@pnpm/error": "6.0.1"
31
+ },
32
+ "devDependencies": {
33
+ "@pnpm/catalogs.config": "0.1.0",
34
+ "@pnpm/catalogs.types": "0.1.0",
35
+ "@pnpm/workspace.read-manifest": "2.1.0"
36
+ },
37
+ "scripts": {
38
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
39
+ "compile": "tsc --build && pnpm run lint --fix",
40
+ "test": "pnpm run compile && pnpm run _test",
41
+ "_test": "jest"
42
+ }
43
+ }