@pnpm/lockfile.settings-checker 1.0.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,13 @@
1
+ # @pnpm/lockfile.settings-checker
2
+
3
+ > Utilities to check if lockfile settings are out-of-date.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @pnpm/lockfile.settings-checker
9
+ ```
10
+
11
+ ## License
12
+
13
+ MIT
@@ -0,0 +1,2 @@
1
+ import { type PatchFile } from '@pnpm/lockfile.types';
2
+ export declare function calcPatchHashes(patches: Record<string, string>, lockfileDir: string): Promise<Record<string, PatchFile>>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.calcPatchHashes = calcPatchHashes;
7
+ const path_1 = __importDefault(require("path"));
8
+ const p_map_values_1 = __importDefault(require("p-map-values"));
9
+ const crypto_base32_hash_1 = require("@pnpm/crypto.base32-hash");
10
+ async function calcPatchHashes(patches, lockfileDir) {
11
+ return (0, p_map_values_1.default)(async (patchFilePath) => {
12
+ return {
13
+ hash: await (0, crypto_base32_hash_1.createBase32HashFromFile)(patchFilePath),
14
+ path: path_1.default.relative(lockfileDir, patchFilePath).replaceAll('\\', '/'),
15
+ };
16
+ }, patches);
17
+ }
18
+ //# sourceMappingURL=calcPatchHashes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calcPatchHashes.js","sourceRoot":"","sources":["../src/calcPatchHashes.ts"],"names":[],"mappings":";;;;;AAKA,0CAOC;AAZD,gDAAuB;AACvB,gEAAqC;AACrC,iEAAmE;AAG5D,KAAK,UAAU,eAAe,CAAE,OAA+B,EAAE,WAAmB;IACzF,OAAO,IAAA,sBAAU,EAAC,KAAK,EAAE,aAAa,EAAE,EAAE;QACxC,OAAO;YACL,IAAI,EAAE,MAAM,IAAA,6CAAwB,EAAC,aAAa,CAAC;YACnD,IAAI,EAAE,cAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC;SACtE,CAAA;IACH,CAAC,EAAE,OAAO,CAAC,CAAA;AACb,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { type VersionOverride } from '@pnpm/parse-overrides';
2
+ export declare function createOverridesMapFromParsed(parsedOverrides: VersionOverride[] | undefined): Record<string, string>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createOverridesMapFromParsed = createOverridesMapFromParsed;
4
+ function createOverridesMapFromParsed(parsedOverrides) {
5
+ if (!parsedOverrides)
6
+ return {};
7
+ const overridesMap = {};
8
+ for (const { selector, newPref } of parsedOverrides) {
9
+ overridesMap[selector] = newPref;
10
+ }
11
+ return overridesMap;
12
+ }
13
+ //# sourceMappingURL=createOverridesMapFromParsed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createOverridesMapFromParsed.js","sourceRoot":"","sources":["../src/createOverridesMapFromParsed.ts"],"names":[],"mappings":";;AAEA,oEAOC;AAPD,SAAgB,4BAA4B,CAAE,eAA8C;IAC1F,IAAI,CAAC,eAAe;QAAE,OAAO,EAAE,CAAA;IAC/B,MAAM,YAAY,GAA2B,EAAE,CAAA;IAC/C,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,eAAe,EAAE,CAAC;QACpD,YAAY,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAA;IAClC,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { type Lockfile, type PatchFile } from '@pnpm/lockfile.types';
2
+ export type ChangedField = 'patchedDependencies' | 'overrides' | 'packageExtensionsChecksum' | 'ignoredOptionalDependencies' | 'settings.autoInstallPeers' | 'settings.excludeLinksFromLockfile' | 'settings.peersSuffixMaxLength' | 'pnpmfileChecksum';
3
+ export declare function getOutdatedLockfileSetting(lockfile: Lockfile, { overrides, packageExtensionsChecksum, ignoredOptionalDependencies, patchedDependencies, autoInstallPeers, excludeLinksFromLockfile, peersSuffixMaxLength, pnpmfileChecksum, }: {
4
+ overrides?: Record<string, string>;
5
+ packageExtensionsChecksum?: string;
6
+ patchedDependencies?: Record<string, PatchFile>;
7
+ ignoredOptionalDependencies?: string[];
8
+ autoInstallPeers?: boolean;
9
+ excludeLinksFromLockfile?: boolean;
10
+ peersSuffixMaxLength?: number;
11
+ pnpmfileChecksum?: string;
12
+ }): ChangedField | null;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getOutdatedLockfileSetting = getOutdatedLockfileSetting;
7
+ const equals_1 = __importDefault(require("ramda/src/equals"));
8
+ function getOutdatedLockfileSetting(lockfile, { overrides, packageExtensionsChecksum, ignoredOptionalDependencies, patchedDependencies, autoInstallPeers, excludeLinksFromLockfile, peersSuffixMaxLength, pnpmfileChecksum, }) {
9
+ if (!(0, equals_1.default)(lockfile.overrides ?? {}, overrides ?? {})) {
10
+ return 'overrides';
11
+ }
12
+ if (lockfile.packageExtensionsChecksum !== packageExtensionsChecksum) {
13
+ return 'packageExtensionsChecksum';
14
+ }
15
+ if (!(0, equals_1.default)(lockfile.ignoredOptionalDependencies?.sort() ?? [], ignoredOptionalDependencies?.sort() ?? [])) {
16
+ return 'ignoredOptionalDependencies';
17
+ }
18
+ if (!(0, equals_1.default)(lockfile.patchedDependencies ?? {}, patchedDependencies ?? {})) {
19
+ return 'patchedDependencies';
20
+ }
21
+ if ((lockfile.settings?.autoInstallPeers != null && lockfile.settings.autoInstallPeers !== autoInstallPeers)) {
22
+ return 'settings.autoInstallPeers';
23
+ }
24
+ if (lockfile.settings?.excludeLinksFromLockfile != null && lockfile.settings.excludeLinksFromLockfile !== excludeLinksFromLockfile) {
25
+ return 'settings.excludeLinksFromLockfile';
26
+ }
27
+ if (lockfile.settings?.peersSuffixMaxLength != null && lockfile.settings.peersSuffixMaxLength !== peersSuffixMaxLength ||
28
+ lockfile.settings?.peersSuffixMaxLength == null && peersSuffixMaxLength !== 1000) {
29
+ return 'settings.peersSuffixMaxLength';
30
+ }
31
+ if (lockfile.pnpmfileChecksum !== pnpmfileChecksum) {
32
+ return 'pnpmfileChecksum';
33
+ }
34
+ return null;
35
+ }
36
+ //# sourceMappingURL=getOutdatedLockfileSetting.js.map
@@ -0,0 +1 @@
1
+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AC,QAAQ,EAAE,oBAAoB,IAAI,IAAI,IAAI,QAAQ,CAAC,QAAQ,CAAC,oBAAoB,KAAK,oBAAoB;QAClH,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,IAAI,IAAI,IAAI,oBAAoB,KAAK,IAAI,EAChF,CAAC;QACD,OAAO,+BAA+B,CAAA;IACxC,CAAC;IACD,IAAI,QAAQ,CAAC,gBAAgB,KAAK,gBAAgB,EAAE,CAAC;QACnD,OAAO,kBAAkB,CAAA;IAC3B,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { calcPatchHashes } from './calcPatchHashes';
2
+ export { createOverridesMapFromParsed } from './createOverridesMapFromParsed';
3
+ export { type ChangedField, getOutdatedLockfileSetting } from './getOutdatedLockfileSetting';
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOutdatedLockfileSetting = exports.createOverridesMapFromParsed = exports.calcPatchHashes = void 0;
4
+ var calcPatchHashes_1 = require("./calcPatchHashes");
5
+ Object.defineProperty(exports, "calcPatchHashes", { enumerable: true, get: function () { return calcPatchHashes_1.calcPatchHashes; } });
6
+ var createOverridesMapFromParsed_1 = require("./createOverridesMapFromParsed");
7
+ Object.defineProperty(exports, "createOverridesMapFromParsed", { enumerable: true, get: function () { return createOverridesMapFromParsed_1.createOverridesMapFromParsed; } });
8
+ var getOutdatedLockfileSetting_1 = require("./getOutdatedLockfileSetting");
9
+ Object.defineProperty(exports, "getOutdatedLockfileSetting", { enumerable: true, get: function () { return getOutdatedLockfileSetting_1.getOutdatedLockfileSetting; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAmD;AAA1C,kHAAA,eAAe,OAAA;AACxB,+EAA6E;AAApE,4IAAA,4BAA4B,OAAA;AACrC,2EAA4F;AAAhE,wIAAA,0BAA0B,OAAA"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@pnpm/lockfile.settings-checker",
3
+ "version": "1.0.0",
4
+ "description": "Utilities to check if lockfile settings are out-of-date",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "!*.map"
10
+ ],
11
+ "repository": "https://github.com/pnpm/pnpm/blob/main/lockfile/settings-checker",
12
+ "keywords": [
13
+ "pnpm9",
14
+ "hash",
15
+ "crypto",
16
+ "base32"
17
+ ],
18
+ "engines": {
19
+ "node": ">=18.12"
20
+ },
21
+ "license": "MIT",
22
+ "bugs": {
23
+ "url": "https://github.com/pnpm/pnpm/issues"
24
+ },
25
+ "homepage": "https://github.com/pnpm/pnpm/blob/main/lockfile/settings-checker#readme",
26
+ "dependencies": {
27
+ "p-map-values": "^1.0.0",
28
+ "ramda": "npm:@pnpm/ramda@0.28.1",
29
+ "sort-keys": "^4.2.0",
30
+ "@pnpm/lockfile.types": "1.0.3",
31
+ "@pnpm/crypto.base32-hash": "3.0.0",
32
+ "@pnpm/parse-overrides": "5.1.1"
33
+ },
34
+ "devDependencies": {
35
+ "@types/ramda": "0.29.12",
36
+ "@pnpm/prepare": "0.0.103",
37
+ "@pnpm/lockfile.settings-checker": "1.0.0"
38
+ },
39
+ "funding": "https://opencollective.com/pnpm",
40
+ "exports": {
41
+ ".": "./lib/index.js"
42
+ },
43
+ "scripts": {
44
+ "lint": "eslint \"src/**/*.ts\"",
45
+ "test": "pnpm run compile",
46
+ "compile": "tsc --build && pnpm run lint --fix"
47
+ }
48
+ }