@effected/lockfiles 0.2.2 → 0.3.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/LockfileFormat.js CHANGED
@@ -21,32 +21,59 @@ const LockfileFormat = Schema.Literals([
21
21
  "yarn"
22
22
  ]);
23
23
  const FILENAMES = {
24
- bun: "bun.lock",
25
- npm: "package-lock.json",
26
- pnpm: "pnpm-lock.yaml",
27
- yarn: "yarn.lock"
24
+ bun: ["bun.lock", "bun.lockb"],
25
+ npm: ["package-lock.json", "npm-shrinkwrap.json"],
26
+ pnpm: ["pnpm-lock.yaml"],
27
+ yarn: ["yarn.lock"]
28
28
  };
29
29
  /**
30
30
  * The conventional lockfile filename for a format: `"bun.lock"`,
31
31
  * `"package-lock.json"`, `"pnpm-lock.yaml"` or `"yarn.lock"`.
32
32
  *
33
+ * @remarks
34
+ * The primary name only — the first element of {@link filenamesFor}, which is
35
+ * what detection that must also see the genuine alternates should use.
36
+ *
37
+ * @public
38
+ */
39
+ const filenameFor = (format) => FILENAMES[format][0];
40
+ /**
41
+ * Every filename a format is genuinely written under, primary first.
42
+ *
43
+ * @remarks
44
+ * Real detection needs more than the conventional name: npm honours
45
+ * `npm-shrinkwrap.json` (and prefers it over `package-lock.json` when both
46
+ * exist — the ordering here is conventional-name-first, not npm's own
47
+ * precedence), and bun has shipped two formats, the current text `bun.lock`
48
+ * and the older **binary** `bun.lockb`. pnpm and yarn each have exactly one.
49
+ *
50
+ * Only genuine *lockfile* spellings appear here. Files that merely influence
51
+ * what an install resolves to — `pnpm-workspace.yaml`, `.pnpmfile.cjs`, yarn's
52
+ * PnP artifacts — are a consumer's cache policy, not alternates of the
53
+ * lockfile.
54
+ *
55
+ * Two deliberate asymmetries with the rest of this module: `bun.lockb` is a
56
+ * detection alternate but not a parse target (`Lockfile.parse` takes text; the
57
+ * binary format fails typed), and {@link fromFilename} keeps answering for the
58
+ * primary names only.
59
+ *
33
60
  * @public
34
61
  */
35
- const filenameFor = (format) => FILENAMES[format];
62
+ const filenamesFor = (format) => FILENAMES[format];
36
63
  /**
37
64
  * The format a lockfile filename identifies, if any.
38
65
  *
39
66
  * @remarks
40
67
  * Matches exact conventional filenames only (`"bun.lock"`,
41
- * `"package-lock.json"`, `"pnpm-lock.yaml"`, `"yarn.lock"`) — paths and
42
- * other spellings return `Option.none()`.
68
+ * `"package-lock.json"`, `"pnpm-lock.yaml"`, `"yarn.lock"`) — paths, other
69
+ * spellings and the {@link filenamesFor} alternates return `Option.none()`.
43
70
  *
44
71
  * @public
45
72
  */
46
73
  const fromFilename = (name) => {
47
- for (const format of LockfileFormat.literals) if (FILENAMES[format] === name) return Option.some(format);
74
+ for (const format of LockfileFormat.literals) if (FILENAMES[format][0] === name) return Option.some(format);
48
75
  return Option.none();
49
76
  };
50
77
 
51
78
  //#endregion
52
- export { LockfileFormat, filenameFor, fromFilename };
79
+ export { LockfileFormat, filenameFor, filenamesFor, fromFilename };
package/index.d.ts CHANGED
@@ -85,16 +85,43 @@ type LockfileFormat = typeof LockfileFormat.Type;
85
85
  * The conventional lockfile filename for a format: `"bun.lock"`,
86
86
  * `"package-lock.json"`, `"pnpm-lock.yaml"` or `"yarn.lock"`.
87
87
  *
88
+ * @remarks
89
+ * The primary name only — the first element of {@link filenamesFor}, which is
90
+ * what detection that must also see the genuine alternates should use.
91
+ *
88
92
  * @public
89
93
  */
90
94
  declare const filenameFor: (format: LockfileFormat) => string;
95
+ /**
96
+ * Every filename a format is genuinely written under, primary first.
97
+ *
98
+ * @remarks
99
+ * Real detection needs more than the conventional name: npm honours
100
+ * `npm-shrinkwrap.json` (and prefers it over `package-lock.json` when both
101
+ * exist — the ordering here is conventional-name-first, not npm's own
102
+ * precedence), and bun has shipped two formats, the current text `bun.lock`
103
+ * and the older **binary** `bun.lockb`. pnpm and yarn each have exactly one.
104
+ *
105
+ * Only genuine *lockfile* spellings appear here. Files that merely influence
106
+ * what an install resolves to — `pnpm-workspace.yaml`, `.pnpmfile.cjs`, yarn's
107
+ * PnP artifacts — are a consumer's cache policy, not alternates of the
108
+ * lockfile.
109
+ *
110
+ * Two deliberate asymmetries with the rest of this module: `bun.lockb` is a
111
+ * detection alternate but not a parse target (`Lockfile.parse` takes text; the
112
+ * binary format fails typed), and {@link fromFilename} keeps answering for the
113
+ * primary names only.
114
+ *
115
+ * @public
116
+ */
117
+ declare const filenamesFor: (format: LockfileFormat) => readonly [string, ...ReadonlyArray<string>];
91
118
  /**
92
119
  * The format a lockfile filename identifies, if any.
93
120
  *
94
121
  * @remarks
95
122
  * Matches exact conventional filenames only (`"bun.lock"`,
96
- * `"package-lock.json"`, `"pnpm-lock.yaml"`, `"yarn.lock"`) — paths and
97
- * other spellings return `Option.none()`.
123
+ * `"package-lock.json"`, `"pnpm-lock.yaml"`, `"yarn.lock"`) — paths, other
124
+ * spellings and the {@link filenamesFor} alternates return `Option.none()`.
98
125
  *
99
126
  * @public
100
127
  */
@@ -463,5 +490,5 @@ declare class LockfileIntegrity extends LockfileIntegrity_base {
463
490
  static compare(lockfile: Lockfile, manifests: ReadonlyArray<WorkspaceManifest>): LockfileIntegrity;
464
491
  }
465
492
  //#endregion
466
- export { BunExtension, ImporterDependency, Lockfile, LockfileFormat, LockfileFramingError, LockfileImporter, LockfileIntegrity, LockfileParseError, type PnpmCatalogs, PnpmExtension, ResolvedPackage, WorkspaceDependency, WorkspaceManifest, filenameFor, fromFilename };
493
+ export { BunExtension, ImporterDependency, Lockfile, LockfileFormat, LockfileFramingError, LockfileImporter, LockfileIntegrity, LockfileParseError, type PnpmCatalogs, PnpmExtension, ResolvedPackage, WorkspaceDependency, WorkspaceManifest, filenameFor, filenamesFor, fromFilename };
467
494
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -4,8 +4,8 @@ import { LockfileImporter } from "./LockfileImporter.js";
4
4
  import { ResolvedPackage } from "./ResolvedPackage.js";
5
5
  import { WorkspaceDependency } from "./WorkspaceDependency.js";
6
6
  import { PnpmExtension } from "./PnpmExtension.js";
7
- import { LockfileFormat, filenameFor, fromFilename } from "./LockfileFormat.js";
7
+ import { LockfileFormat, filenameFor, filenamesFor, fromFilename } from "./LockfileFormat.js";
8
8
  import { Lockfile, LockfileFramingError, LockfileParseError } from "./Lockfile.js";
9
9
  import { LockfileIntegrity, WorkspaceManifest } from "./LockfileIntegrity.js";
10
10
 
11
- export { BunExtension, ImporterDependency, Lockfile, LockfileFormat, LockfileFramingError, LockfileImporter, LockfileIntegrity, LockfileParseError, PnpmExtension, ResolvedPackage, WorkspaceDependency, WorkspaceManifest, filenameFor, fromFilename };
11
+ export { BunExtension, ImporterDependency, Lockfile, LockfileFormat, LockfileFramingError, LockfileImporter, LockfileIntegrity, LockfileParseError, PnpmExtension, ResolvedPackage, WorkspaceDependency, WorkspaceManifest, filenameFor, filenamesFor, fromFilename };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/lockfiles",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "Pure lockfile parsing for bun, npm, pnpm and yarn Berry into one unified Effect schema model, with pure integrity checking against workspace manifests.",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@effected/jsonc": "~0.5.1",
44
- "@effected/npm": "~0.6.0",
45
- "@effected/semver": "~0.2.1",
44
+ "@effected/npm": "~0.8.0",
45
+ "@effected/semver": "~0.3.0",
46
46
  "@effected/yaml": "~0.6.0",
47
47
  "effect": "4.0.0-beta.101"
48
48
  },