@vltpkg/graph 1.0.0-rc.18 → 1.0.0-rc.22

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.
Files changed (217) hide show
  1. package/package.json +45 -41
  2. package/dist/actual/load.d.ts +0 -100
  3. package/dist/actual/load.d.ts.map +0 -1
  4. package/dist/actual/load.js +0 -320
  5. package/dist/actual/load.js.map +0 -1
  6. package/dist/browser.d.ts +0 -15
  7. package/dist/browser.d.ts.map +0 -1
  8. package/dist/browser.js +0 -17
  9. package/dist/browser.js.map +0 -1
  10. package/dist/build.d.ts +0 -29
  11. package/dist/build.d.ts.map +0 -1
  12. package/dist/build.js +0 -79
  13. package/dist/build.js.map +0 -1
  14. package/dist/dependencies.d.ts +0 -66
  15. package/dist/dependencies.d.ts.map +0 -1
  16. package/dist/dependencies.js +0 -112
  17. package/dist/dependencies.js.map +0 -1
  18. package/dist/diff.d.ts +0 -120
  19. package/dist/diff.d.ts.map +0 -1
  20. package/dist/diff.js +0 -152
  21. package/dist/diff.js.map +0 -1
  22. package/dist/edge.d.ts +0 -47
  23. package/dist/edge.d.ts.map +0 -1
  24. package/dist/edge.js +0 -78
  25. package/dist/edge.js.map +0 -1
  26. package/dist/fixup-added-names.d.ts +0 -19
  27. package/dist/fixup-added-names.d.ts.map +0 -1
  28. package/dist/fixup-added-names.js +0 -47
  29. package/dist/fixup-added-names.js.map +0 -1
  30. package/dist/graph.d.ts +0 -154
  31. package/dist/graph.d.ts.map +0 -1
  32. package/dist/graph.js +0 -445
  33. package/dist/graph.js.map +0 -1
  34. package/dist/ideal/append-nodes.d.ts +0 -32
  35. package/dist/ideal/append-nodes.d.ts.map +0 -1
  36. package/dist/ideal/append-nodes.js +0 -561
  37. package/dist/ideal/append-nodes.js.map +0 -1
  38. package/dist/ideal/build-ideal-from-starting-graph.d.ts +0 -15
  39. package/dist/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
  40. package/dist/ideal/build-ideal-from-starting-graph.js +0 -70
  41. package/dist/ideal/build-ideal-from-starting-graph.js.map +0 -1
  42. package/dist/ideal/build.d.ts +0 -41
  43. package/dist/ideal/build.d.ts.map +0 -1
  44. package/dist/ideal/build.js +0 -85
  45. package/dist/ideal/build.js.map +0 -1
  46. package/dist/ideal/get-importer-specs.d.ts +0 -21
  47. package/dist/ideal/get-importer-specs.d.ts.map +0 -1
  48. package/dist/ideal/get-importer-specs.js +0 -181
  49. package/dist/ideal/get-importer-specs.js.map +0 -1
  50. package/dist/ideal/peers.d.ts +0 -161
  51. package/dist/ideal/peers.d.ts.map +0 -1
  52. package/dist/ideal/peers.js +0 -697
  53. package/dist/ideal/peers.js.map +0 -1
  54. package/dist/ideal/refresh-ideal-graph.d.ts +0 -44
  55. package/dist/ideal/refresh-ideal-graph.d.ts.map +0 -1
  56. package/dist/ideal/refresh-ideal-graph.js +0 -63
  57. package/dist/ideal/refresh-ideal-graph.js.map +0 -1
  58. package/dist/ideal/remove-satisfied-specs.d.ts +0 -8
  59. package/dist/ideal/remove-satisfied-specs.d.ts.map +0 -1
  60. package/dist/ideal/remove-satisfied-specs.js +0 -35
  61. package/dist/ideal/remove-satisfied-specs.js.map +0 -1
  62. package/dist/ideal/sorting.d.ts +0 -46
  63. package/dist/ideal/sorting.d.ts.map +0 -1
  64. package/dist/ideal/sorting.js +0 -71
  65. package/dist/ideal/sorting.js.map +0 -1
  66. package/dist/ideal/types.d.ts +0 -108
  67. package/dist/ideal/types.d.ts.map +0 -1
  68. package/dist/ideal/types.js +0 -2
  69. package/dist/ideal/types.js.map +0 -1
  70. package/dist/index.d.ts +0 -39
  71. package/dist/index.d.ts.map +0 -1
  72. package/dist/index.js +0 -33
  73. package/dist/index.js.map +0 -1
  74. package/dist/install.d.ts +0 -20
  75. package/dist/install.d.ts.map +0 -1
  76. package/dist/install.js +0 -209
  77. package/dist/install.js.map +0 -1
  78. package/dist/lockfile/load-edges.d.ts +0 -12
  79. package/dist/lockfile/load-edges.d.ts.map +0 -1
  80. package/dist/lockfile/load-edges.js +0 -106
  81. package/dist/lockfile/load-edges.js.map +0 -1
  82. package/dist/lockfile/load-nodes.d.ts +0 -5
  83. package/dist/lockfile/load-nodes.d.ts.map +0 -1
  84. package/dist/lockfile/load-nodes.js +0 -102
  85. package/dist/lockfile/load-nodes.js.map +0 -1
  86. package/dist/lockfile/load.d.ts +0 -46
  87. package/dist/lockfile/load.d.ts.map +0 -1
  88. package/dist/lockfile/load.js +0 -85
  89. package/dist/lockfile/load.js.map +0 -1
  90. package/dist/lockfile/save.d.ts +0 -31
  91. package/dist/lockfile/save.d.ts.map +0 -1
  92. package/dist/lockfile/save.js +0 -175
  93. package/dist/lockfile/save.js.map +0 -1
  94. package/dist/lockfile/types.d.ts +0 -96
  95. package/dist/lockfile/types.d.ts.map +0 -1
  96. package/dist/lockfile/types.js +0 -50
  97. package/dist/lockfile/types.js.map +0 -1
  98. package/dist/modifiers.d.ts +0 -189
  99. package/dist/modifiers.d.ts.map +0 -1
  100. package/dist/modifiers.js +0 -330
  101. package/dist/modifiers.js.map +0 -1
  102. package/dist/node.d.ts +0 -235
  103. package/dist/node.d.ts.map +0 -1
  104. package/dist/node.js +0 -389
  105. package/dist/node.js.map +0 -1
  106. package/dist/non-empty-list.d.ts +0 -3
  107. package/dist/non-empty-list.d.ts.map +0 -1
  108. package/dist/non-empty-list.js +0 -3
  109. package/dist/non-empty-list.js.map +0 -1
  110. package/dist/reify/add-edge.d.ts +0 -10
  111. package/dist/reify/add-edge.d.ts.map +0 -1
  112. package/dist/reify/add-edge.js +0 -65
  113. package/dist/reify/add-edge.js.map +0 -1
  114. package/dist/reify/add-edges.d.ts +0 -5
  115. package/dist/reify/add-edges.d.ts.map +0 -1
  116. package/dist/reify/add-edges.js +0 -13
  117. package/dist/reify/add-edges.js.map +0 -1
  118. package/dist/reify/add-nodes.d.ts +0 -7
  119. package/dist/reify/add-nodes.d.ts.map +0 -1
  120. package/dist/reify/add-nodes.js +0 -17
  121. package/dist/reify/add-nodes.js.map +0 -1
  122. package/dist/reify/bin-chmod.d.ts +0 -11
  123. package/dist/reify/bin-chmod.d.ts.map +0 -1
  124. package/dist/reify/bin-chmod.js +0 -39
  125. package/dist/reify/bin-chmod.js.map +0 -1
  126. package/dist/reify/build.d.ts +0 -14
  127. package/dist/reify/build.d.ts.map +0 -1
  128. package/dist/reify/build.js +0 -112
  129. package/dist/reify/build.js.map +0 -1
  130. package/dist/reify/calculate-save-value.d.ts +0 -3
  131. package/dist/reify/calculate-save-value.d.ts.map +0 -1
  132. package/dist/reify/calculate-save-value.js +0 -45
  133. package/dist/reify/calculate-save-value.js.map +0 -1
  134. package/dist/reify/check-needed-build.d.ts +0 -35
  135. package/dist/reify/check-needed-build.d.ts.map +0 -1
  136. package/dist/reify/check-needed-build.js +0 -72
  137. package/dist/reify/check-needed-build.js.map +0 -1
  138. package/dist/reify/delete-edge.d.ts +0 -5
  139. package/dist/reify/delete-edge.d.ts.map +0 -1
  140. package/dist/reify/delete-edge.js +0 -28
  141. package/dist/reify/delete-edge.js.map +0 -1
  142. package/dist/reify/delete-edges.d.ts +0 -5
  143. package/dist/reify/delete-edges.d.ts.map +0 -1
  144. package/dist/reify/delete-edges.js +0 -14
  145. package/dist/reify/delete-edges.js.map +0 -1
  146. package/dist/reify/delete-nodes.d.ts +0 -5
  147. package/dist/reify/delete-nodes.d.ts.map +0 -1
  148. package/dist/reify/delete-nodes.js +0 -16
  149. package/dist/reify/delete-nodes.js.map +0 -1
  150. package/dist/reify/extract-node.d.ts +0 -24
  151. package/dist/reify/extract-node.d.ts.map +0 -1
  152. package/dist/reify/extract-node.js +0 -84
  153. package/dist/reify/extract-node.js.map +0 -1
  154. package/dist/reify/index.d.ts +0 -35
  155. package/dist/reify/index.d.ts.map +0 -1
  156. package/dist/reify/index.js +0 -162
  157. package/dist/reify/index.js.map +0 -1
  158. package/dist/reify/internal-hoist.d.ts +0 -9
  159. package/dist/reify/internal-hoist.d.ts.map +0 -1
  160. package/dist/reify/internal-hoist.js +0 -134
  161. package/dist/reify/internal-hoist.js.map +0 -1
  162. package/dist/reify/optional-fail.d.ts +0 -16
  163. package/dist/reify/optional-fail.d.ts.map +0 -1
  164. package/dist/reify/optional-fail.js +0 -16
  165. package/dist/reify/optional-fail.js.map +0 -1
  166. package/dist/reify/rollback.d.ts +0 -5
  167. package/dist/reify/rollback.d.ts.map +0 -1
  168. package/dist/reify/rollback.js +0 -24
  169. package/dist/reify/rollback.js.map +0 -1
  170. package/dist/reify/update-importers-package-json.d.ts +0 -36
  171. package/dist/reify/update-importers-package-json.d.ts.map +0 -1
  172. package/dist/reify/update-importers-package-json.js +0 -123
  173. package/dist/reify/update-importers-package-json.js.map +0 -1
  174. package/dist/remove-optional-subgraph.d.ts +0 -34
  175. package/dist/remove-optional-subgraph.d.ts.map +0 -1
  176. package/dist/remove-optional-subgraph.js +0 -48
  177. package/dist/remove-optional-subgraph.js.map +0 -1
  178. package/dist/resolve-save-type.d.ts +0 -6
  179. package/dist/resolve-save-type.d.ts.map +0 -1
  180. package/dist/resolve-save-type.js +0 -5
  181. package/dist/resolve-save-type.js.map +0 -1
  182. package/dist/stringify-node.d.ts +0 -3
  183. package/dist/stringify-node.d.ts.map +0 -1
  184. package/dist/stringify-node.js +0 -33
  185. package/dist/stringify-node.js.map +0 -1
  186. package/dist/transfer-data/load.d.ts +0 -44
  187. package/dist/transfer-data/load.d.ts.map +0 -1
  188. package/dist/transfer-data/load.js +0 -176
  189. package/dist/transfer-data/load.js.map +0 -1
  190. package/dist/uninstall.d.ts +0 -15
  191. package/dist/uninstall.d.ts.map +0 -1
  192. package/dist/uninstall.js +0 -68
  193. package/dist/uninstall.js.map +0 -1
  194. package/dist/update.d.ts +0 -13
  195. package/dist/update.d.ts.map +0 -1
  196. package/dist/update.js +0 -74
  197. package/dist/update.js.map +0 -1
  198. package/dist/virtual-root.d.ts +0 -16
  199. package/dist/virtual-root.d.ts.map +0 -1
  200. package/dist/virtual-root.js +0 -79
  201. package/dist/virtual-root.js.map +0 -1
  202. package/dist/visualization/human-readable-output.d.ts +0 -27
  203. package/dist/visualization/human-readable-output.d.ts.map +0 -1
  204. package/dist/visualization/human-readable-output.js +0 -164
  205. package/dist/visualization/human-readable-output.js.map +0 -1
  206. package/dist/visualization/json-output.d.ts +0 -42
  207. package/dist/visualization/json-output.d.ts.map +0 -1
  208. package/dist/visualization/json-output.js +0 -51
  209. package/dist/visualization/json-output.js.map +0 -1
  210. package/dist/visualization/mermaid-output.d.ts +0 -18
  211. package/dist/visualization/mermaid-output.d.ts.map +0 -1
  212. package/dist/visualization/mermaid-output.js +0 -176
  213. package/dist/visualization/mermaid-output.js.map +0 -1
  214. package/dist/visualization/object-like-output.d.ts +0 -3
  215. package/dist/visualization/object-like-output.d.ts.map +0 -1
  216. package/dist/visualization/object-like-output.js +0 -48
  217. package/dist/visualization/object-like-output.js.map +0 -1
@@ -1,85 +0,0 @@
1
- import { error } from '@vltpkg/error-cause';
2
- import { PackageJson } from '@vltpkg/package-json';
3
- import { Monorepo } from '@vltpkg/workspaces';
4
- import { readFileSync } from 'node:fs';
5
- import { resolve } from 'node:path';
6
- import { loadEdges } from "./load-edges.js";
7
- import { loadNodes } from "./load-nodes.js";
8
- import { Graph } from "../graph.js";
9
- import { LOCKFILE_VERSION } from "./types.js";
10
- const loadLockfile = (projectRoot, lockfilePath) => JSON.parse(readFileSync(resolve(projectRoot, lockfilePath), {
11
- encoding: 'utf8',
12
- }));
13
- export const load = (options) => {
14
- const { projectRoot } = options;
15
- return loadObject(options, loadLockfile(projectRoot, 'vlt-lock.json'));
16
- };
17
- export const loadHidden = (options) => {
18
- const { projectRoot } = options;
19
- // Ensure that missing manifests throw an error when loading hidden lockfiles
20
- options.throwOnMissingManifest = true;
21
- return loadObject(options, loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'));
22
- };
23
- export const loadObject = (options, lockfileData) => {
24
- const version = lockfileData.lockfileVersion;
25
- // Lockfile version is required, likely a corrupted lockfile if missing
26
- if (version == null) {
27
- throw error('Missing lockfile version', {
28
- code: 'ELOCKFILEVERSION',
29
- found: version,
30
- wanted: LOCKFILE_VERSION,
31
- });
32
- }
33
- // Lockfile version must match current version
34
- if (version !== LOCKFILE_VERSION) {
35
- throw error(`Unsupported lockfile version.
36
-
37
- Run: \`vlt update\` to start a new, supported lockfile.`, {
38
- code: 'ELOCKFILEVERSION',
39
- found: version,
40
- wanted: LOCKFILE_VERSION,
41
- });
42
- }
43
- const { mainManifest, scurry } = options;
44
- const packageJson = options.packageJson ?? new PackageJson();
45
- const monorepo = options.monorepo ??
46
- Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry });
47
- const { catalog = {}, catalogs = {}, 'scope-registries': scopeRegistries, registry, registries, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives,
48
- /* c8 ignore next */
49
- } = lockfileData.options ?? {};
50
- // Optimize options merging - only create new objects when needed
51
- const mergedOptions = {
52
- ...options,
53
- catalog,
54
- catalogs,
55
- 'scope-registries': scopeRegistries ?
56
- { ...options['scope-registries'], ...scopeRegistries }
57
- : options['scope-registries'],
58
- registry: registry ?? options.registry,
59
- registries: registries ?
60
- { ...options.registries, ...registries }
61
- : options.registries,
62
- 'git-hosts': gitHosts ?
63
- { ...options['git-hosts'], ...gitHosts }
64
- : options['git-hosts'],
65
- 'git-host-archives': gitHostArchives ?
66
- { ...options['git-host-archives'], ...gitHostArchives }
67
- : options['git-host-archives'],
68
- };
69
- const graph = new Graph({
70
- ...mergedOptions,
71
- mainManifest,
72
- monorepo,
73
- });
74
- loadNodes(graph, lockfileData.nodes, mergedOptions, options.actual, options.throwOnMissingManifest);
75
- loadEdges(graph, lockfileData.edges, mergedOptions);
76
- // hydrate missing node-level registry data
77
- for (const node of graph.nodes.values()) {
78
- const [firstEdge] = node.edgesIn;
79
- if (firstEdge?.spec.registry) {
80
- node.registry = firstEdge.spec.registry;
81
- }
82
- }
83
- return graph;
84
- };
85
- //# sourceMappingURL=load.js.map
@@ -1 +0,0 @@
1
- {"version":3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AAQ,IAAI,OAAO,CAAC,QAAQ;QACtC,UAAU,EACR,UAAU,CAAC,CAAC;YACV,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,GAAG,UAAU,EAAE;YAC1C,CAAC,CAAC,OAAO,CAAC,UAAU;QACtB,WAAW,EACT,QAAQ,CAAC,CAAC;YACR,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,EAAE,GAAG,QAAQ,EAAE;YAC1C,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QACxB,mBAAmB,EACjB,eAAe,CAAC,CAAC;YACf,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,GAAG,eAAe,EAAE;YACzD,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC;KACjC,CAAA;IACD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC;QACtB,GAAG,aAAa;QAChB,YAAY;QACZ,QAAQ;KACT,CAAC,CAAA;IACF,SAAS,CACP,KAAK,EACL,YAAY,CAAC,KAAK,EAClB,aAAa,EACb,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,sBAAsB,CAC/B,CAAA;IACD,SAAS,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;IAEnD,2CAA2C;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,OAAO,CAAA;QAChC,IAAI,SAAS,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAA;QACzC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { PackageJson } from '@vltpkg/package-json'\nimport { Monorepo } from '@vltpkg/workspaces'\nimport { readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { loadEdges } from './load-edges.ts'\nimport { loadNodes } from './load-nodes.ts'\nimport { Graph } from '../graph.ts'\nimport { LOCKFILE_VERSION } from './types.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { LockfileData } from './types.ts'\nimport type { GraphModifier } from '../modifiers.ts'\n\nexport type LoadOptions = SpecOptions & {\n /**\n * An optional {@link Graph} object to hydrate extra data from.\n */\n actual?: Graph\n /**\n * The project root dirname.\n */\n projectRoot: string\n /**\n * The project root manifest.\n */\n mainManifest: NormalizedManifest\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * A {@link Monorepo} object, for managing workspaces\n */\n monorepo?: Monorepo\n /**\n * A {@link PackageJson} object, for sharing manifest caches\n */\n packageJson?: PackageJson\n /**\n * A {@link PathScurry} object, for use in globs\n */\n scurry?: PathScurry\n /**\n * Whether to throw an error if a manifest is missing when loading nodes.\n */\n throwOnMissingManifest?: boolean\n}\n\nconst loadLockfile = (projectRoot: string, lockfilePath: string) =>\n JSON.parse(\n readFileSync(resolve(projectRoot, lockfilePath), {\n encoding: 'utf8',\n }),\n ) as LockfileData\n\nexport const load = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n return loadObject(\n options,\n loadLockfile(projectRoot, 'vlt-lock.json'),\n )\n}\n\nexport const loadHidden = (options: LoadOptions): Graph => {\n const { projectRoot } = options\n // Ensure that missing manifests throw an error when loading hidden lockfiles\n options.throwOnMissingManifest = true\n return loadObject(\n options,\n loadLockfile(projectRoot, 'node_modules/.vlt-lock.json'),\n )\n}\n\nexport const loadObject = (\n options: LoadOptions,\n lockfileData: Omit<LockfileData, 'options' | 'lockfileVersion'> &\n Partial<Pick<LockfileData, 'options' | 'lockfileVersion'>>,\n) => {\n const version = lockfileData.lockfileVersion\n // Lockfile version is required, likely a corrupted lockfile if missing\n if (version == null) {\n throw error('Missing lockfile version', {\n code: 'ELOCKFILEVERSION',\n found: version,\n wanted: LOCKFILE_VERSION,\n })\n }\n // Lockfile version must match current version\n if (version !== LOCKFILE_VERSION) {\n throw error(\n `Unsupported lockfile version.\n\n Run: \\`vlt update\\` to start a new, supported lockfile.`,\n {\n code: 'ELOCKFILEVERSION',\n found: version,\n wanted: LOCKFILE_VERSION,\n },\n )\n }\n\n const { mainManifest, scurry } = options\n const packageJson = options.packageJson ?? new PackageJson()\n const monorepo =\n options.monorepo ??\n Monorepo.maybeLoad(options.projectRoot, { packageJson, scurry })\n const {\n catalog = {},\n catalogs = {},\n 'scope-registries': scopeRegistries,\n registry,\n registries,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n /* c8 ignore next */\n } = lockfileData.options ?? {}\n\n // Optimize options merging - only create new objects when needed\n const mergedOptions = {\n ...options,\n catalog,\n catalogs,\n 'scope-registries':\n scopeRegistries ?\n { ...options['scope-registries'], ...scopeRegistries }\n : options['scope-registries'],\n registry: registry ?? options.registry,\n registries:\n registries ?\n { ...options.registries, ...registries }\n : options.registries,\n 'git-hosts':\n gitHosts ?\n { ...options['git-hosts'], ...gitHosts }\n : options['git-hosts'],\n 'git-host-archives':\n gitHostArchives ?\n { ...options['git-host-archives'], ...gitHostArchives }\n : options['git-host-archives'],\n }\n const graph = new Graph({\n ...mergedOptions,\n mainManifest,\n monorepo,\n })\n loadNodes(\n graph,\n lockfileData.nodes,\n mergedOptions,\n options.actual,\n options.throwOnMissingManifest,\n )\n loadEdges(graph, lockfileData.edges, mergedOptions)\n\n // hydrate missing node-level registry data\n for (const node of graph.nodes.values()) {\n const [firstEdge] = node.edgesIn\n if (firstEdge?.spec.registry) {\n node.registry = firstEdge.spec.registry\n }\n }\n\n return graph\n}\n"]}
@@ -1,31 +0,0 @@
1
- import type { SpecOptions } from '@vltpkg/spec';
2
- import type { Graph } from '../graph.ts';
3
- import type { LockfileData } from './types.ts';
4
- import type { GraphModifier } from '../modifiers.ts';
5
- export type SaveOptions = SpecOptions & {
6
- /**
7
- * The graph to be stored in the lockfile.
8
- */
9
- graph: Graph;
10
- /**
11
- * The graph modifiers helper object.
12
- */
13
- modifiers?: GraphModifier;
14
- /**
15
- * Should it save manifest data in the lockfile?
16
- */
17
- saveManifests?: boolean;
18
- /**
19
- * Should it save build state data in the lockfile?
20
- */
21
- saveBuildData?: boolean;
22
- /**
23
- * Should it throw an error if a manifest is missing?
24
- */
25
- throwOnMissingManifest?: boolean;
26
- };
27
- export declare const lockfileData: ({ graph, catalog, catalogs, "git-hosts": gitHosts, "git-host-archives": gitHostArchives, modifiers, registry, registries, saveManifests, saveBuildData, "scope-registries": scopeRegistries, "jsr-registries": jsrRegistries, throwOnMissingManifest, }: SaveOptions) => LockfileData;
28
- export declare const saveData: (data: LockfileData, fileName: string, saveManifests?: boolean) => void;
29
- export declare const save: (options: Omit<SaveOptions, "saveManifests">) => void;
30
- export declare const saveHidden: (options: Omit<SaveOptions, "saveManifests" | "saveBuildData">) => void;
31
- //# sourceMappingURL=save.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"save.d.ts","sourceRoot":"","sources":["../../src/lockfile/save.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAE/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,KAAK,EACV,YAAY,EAMb,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAGpD,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG;IACtC;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC,CAAA;AAoHD,eAAO,MAAM,YAAY,4PActB,WAAW,KAAG,YA+DhB,CAAA;AAeD,eAAO,MAAM,QAAQ,SACb,YAAY,YACR,MAAM,8BAEf,IAIF,CAAA;AAED,eAAO,MAAM,IAAI,YACN,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,KAC1C,IAKF,CAAA;AAED,eAAO,MAAM,UAAU,YACZ,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,eAAe,CAAC,KAC5D,IAqBF,CAAA"}
@@ -1,175 +0,0 @@
1
- import { expandNormalizedManifestSymbols, isRecordStringString, } from '@vltpkg/types';
2
- import { defaultGitHostArchives, defaultGitHosts, defaultJsrRegistries, defaultRegistries, defaultRegistry, defaultScopeRegistries, } from '@vltpkg/spec';
3
- import { mkdirSync, writeFileSync } from 'node:fs';
4
- import { dirname, resolve } from 'node:path';
5
- import { getFlagNumFromNode, getBuildStateFromNode, LOCKFILE_VERSION, } from "./types.js";
6
- import { error } from '@vltpkg/error-cause';
7
- const formatNodes = (nodes, saveManifests, saveBuildData, registry, throwOnMissingManifest) => {
8
- // we do not store importers in the lockfile, though we do store
9
- // their edges. when we load, we always read workspaces/main fresh.
10
- const arr = [...nodes].filter(node => !node.importer);
11
- // nodes are sorted in order to have a deterministic result
12
- const orderedNodes = arr.sort((a, b) => a.id.localeCompare(b.id, 'en'));
13
- const res = {};
14
- for (const node of orderedNodes) {
15
- const customRegistry = node.resolved && registry && !node.resolved.startsWith(registry);
16
- const resolved = customRegistry ? node.resolved : undefined;
17
- // if it's in a location other than the default, stash that
18
- const location = node.id.startsWith('file') || node.inVltStore() ?
19
- undefined
20
- : node.location;
21
- const flags = getFlagNumFromNode(node);
22
- const lockfileNode = [flags, node.name];
23
- if (node.integrity) {
24
- lockfileNode[2] = node.integrity;
25
- }
26
- // skip resolved for remote nodes since
27
- // these are already part of the dep id
28
- if (resolved && !node.id.startsWith('remote')) {
29
- lockfileNode[3] = resolved;
30
- }
31
- if (location) {
32
- lockfileNode[4] = location;
33
- }
34
- if (saveManifests && node.manifest) {
35
- lockfileNode[5] = expandNormalizedManifestSymbols(node.manifest);
36
- if (node.confused && node.rawManifest) {
37
- lockfileNode[6] = expandNormalizedManifestSymbols(node.rawManifest);
38
- }
39
- }
40
- // Throw an error if a manifest is missing and the option is enabled
41
- if (throwOnMissingManifest && !node.manifest) {
42
- throw error(`Missing manifest for node ${node.id}.`);
43
- }
44
- // Always save platform data for optional dependencies if available
45
- if (node.optional && node.platform) {
46
- lockfileNode[7] = node.platform;
47
- }
48
- // Save bin data if available
49
- if (node.bins && Object.keys(node.bins).length) {
50
- lockfileNode[8] = node.bins;
51
- }
52
- // Save build state data if requested
53
- if (saveBuildData) {
54
- const buildState = getBuildStateFromNode(node);
55
- if (buildState !== undefined) {
56
- lockfileNode[9] = buildState;
57
- }
58
- }
59
- res[node.id] = lockfileNode;
60
- }
61
- return res;
62
- };
63
- const formatEdges = (edges) => Object.fromEntries([...edges]
64
- .sort((a, b) =>
65
- /* c8 ignore start - nondeterminstic and annoying to test */
66
- // sort importers to the top, then alphabetically by
67
- // id, type, target
68
- Number(b.from.importer) - Number(a.from.importer) ||
69
- a.from.id.localeCompare(b.from.id, 'en') ||
70
- a.type.localeCompare(b.type, 'en') ||
71
- (a.to?.id ?? '').localeCompare(b.to?.id ?? ''))
72
- .map((edge) => [
73
- `${edge.from.id} ${edge.spec.name}`,
74
- `${edge.type} ${edge.spec.bareSpec || '*'} ${edge.to?.id ?? 'MISSING'}`,
75
- ]));
76
- const removeDefaultItems = (defaultItems, items) => {
77
- const res = {};
78
- for (const [key, value] of Object.entries(items)) {
79
- if (!defaultItems[key] || defaultItems[key] !== value) {
80
- res[key] = value;
81
- }
82
- }
83
- return res;
84
- };
85
- export const lockfileData = ({ graph, catalog, catalogs, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, modifiers, registry, registries, saveManifests, saveBuildData, 'scope-registries': scopeRegistries, 'jsr-registries': jsrRegistries, throwOnMissingManifest, }) => {
86
- const cleanGitHosts = isRecordStringString(gitHosts) ?
87
- removeDefaultItems(defaultGitHosts, gitHosts)
88
- : undefined;
89
- const cleanGitHostArchives = isRecordStringString(gitHostArchives) ?
90
- removeDefaultItems(defaultGitHostArchives, gitHostArchives)
91
- : undefined;
92
- const cleanModifiers = modifiers && isRecordStringString(modifiers.config) ?
93
- modifiers.config
94
- : undefined;
95
- const cleanRegistries = isRecordStringString(registries) ?
96
- removeDefaultItems(defaultRegistries, registries)
97
- : undefined;
98
- const cleanScopeRegistries = isRecordStringString(scopeRegistries) ?
99
- removeDefaultItems(defaultScopeRegistries, scopeRegistries)
100
- : undefined;
101
- const cleanJsrRegistries = isRecordStringString(jsrRegistries) ?
102
- removeDefaultItems(defaultJsrRegistries, jsrRegistries)
103
- : undefined;
104
- const hasItems = (clean) => clean && Object.keys(clean).length;
105
- return {
106
- lockfileVersion: LOCKFILE_VERSION,
107
- options: {
108
- ...(hasItems(cleanModifiers) ?
109
- { modifiers: cleanModifiers }
110
- : {}),
111
- ...(hasItems(catalog) ? { catalog } : {}),
112
- ...(hasItems(catalogs) ? { catalogs } : {}),
113
- ...(hasItems(cleanScopeRegistries) ?
114
- { 'scope-registries': cleanScopeRegistries }
115
- : undefined),
116
- ...(hasItems(cleanJsrRegistries) ?
117
- { 'jsr-registries': cleanJsrRegistries }
118
- : undefined),
119
- ...(registry !== undefined && registry !== defaultRegistry ?
120
- { registry }
121
- : undefined),
122
- ...(hasItems(cleanRegistries) ?
123
- { registries: cleanRegistries }
124
- : undefined),
125
- ...(hasItems(cleanGitHosts) ?
126
- { 'git-hosts': cleanGitHosts }
127
- : undefined),
128
- ...(hasItems(cleanGitHostArchives) ?
129
- { 'git-host-archives': cleanGitHostArchives }
130
- : undefined),
131
- },
132
- nodes: formatNodes(graph.nodes.values(), saveManifests, saveBuildData, registry, throwOnMissingManifest),
133
- edges: formatEdges(graph.edges),
134
- };
135
- };
136
- // renders each node / edge as a single line entry
137
- const extraFormat = (jsonString) => {
138
- const str = `${jsonString}\n`;
139
- const [init, ...parts] = str.split(' "nodes": {');
140
- const res = [init];
141
- for (const part of parts) {
142
- res.push(part.replaceAll('\n ', '').replaceAll('\n ]', ']'));
143
- }
144
- return res.join(' "nodes": {');
145
- };
146
- export const saveData = (data, fileName, saveManifests = false) => {
147
- const json = JSON.stringify(data, null, 2);
148
- const content = saveManifests ? json : extraFormat(json);
149
- writeFileSync(fileName, content);
150
- };
151
- export const save = (options) => {
152
- const { graph } = options;
153
- const data = lockfileData({ ...options, saveManifests: false });
154
- const fileName = resolve(graph.projectRoot, 'vlt-lock.json');
155
- saveData(data, fileName, false);
156
- };
157
- export const saveHidden = (options) => {
158
- const { graph } = options;
159
- let data;
160
- try {
161
- data = lockfileData({
162
- ...options,
163
- saveManifests: true,
164
- saveBuildData: true,
165
- throwOnMissingManifest: true,
166
- });
167
- }
168
- catch { }
169
- if (!data)
170
- return;
171
- const fileName = resolve(graph.projectRoot, 'node_modules/.vlt-lock.json');
172
- mkdirSync(dirname(fileName), { recursive: true });
173
- saveData(data, fileName, true);
174
- };
175
- //# sourceMappingURL=save.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"save.js","sourceRoot":"","sources":["../../src/lockfile/save.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,GACvB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,YAAY,CAAA;AAenB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAyB3C,MAAM,WAAW,GAAG,CAClB,KAAqB,EACrB,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CAAC,CAAA;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,OAA2C,EACrC,EAAE;IACR,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACzB,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;IAC/D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;IAC5D,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;AACjC,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,OAA6D,EACvD,EAAE;IACR,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IACzB,IAAI,IAA8B,CAAA;IAElC,IAAI,CAAC;QACH,IAAI,GAAG,YAAY,CAAC;YAClB,GAAG,OAAO;YACV,aAAa,EAAE,IAAI;YACnB,aAAa,EAAE,IAAI;YACnB,sBAAsB,EAAE,IAAI;SAC7B,CAAC,CAAA;IACJ,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IAEV,IAAI,CAAC,IAAI;QAAE,OAAM;IAEjB,MAAM,QAAQ,GAAG,OAAO,CACtB,KAAK,CAAC,WAAW,EACjB,6BAA6B,CAC9B,CAAA;IACD,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACjD,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAA;AAChC,CAAC,CAAA","sourcesContent":["import {\n expandNormalizedManifestSymbols,\n isRecordStringString,\n} from '@vltpkg/types'\nimport {\n defaultGitHostArchives,\n defaultGitHosts,\n defaultJsrRegistries,\n defaultRegistries,\n defaultRegistry,\n defaultScopeRegistries,\n} from '@vltpkg/spec'\nimport { mkdirSync, writeFileSync } from 'node:fs'\nimport { dirname, resolve } from 'node:path'\nimport {\n getFlagNumFromNode,\n getBuildStateFromNode,\n LOCKFILE_VERSION,\n} from './types.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { Edge } from '../edge.ts'\nimport type { Graph } from '../graph.ts'\nimport type { Node } from '../node.ts'\nimport type {\n LockfileData,\n LockfileEdgeKey,\n LockfileEdges,\n LockfileEdgeValue,\n LockfileNode,\n LockfilePlatform,\n} from './types.ts'\nimport type { GraphModifier } from '../modifiers.ts'\nimport { error } from '@vltpkg/error-cause'\n\nexport type SaveOptions = SpecOptions & {\n /**\n * The graph to be stored in the lockfile.\n */\n graph: Graph\n /**\n * The graph modifiers helper object.\n */\n modifiers?: GraphModifier\n /**\n * Should it save manifest data in the lockfile?\n */\n saveManifests?: boolean\n /**\n * Should it save build state data in the lockfile?\n */\n saveBuildData?: boolean\n /**\n * Should it throw an error if a manifest is missing?\n */\n throwOnMissingManifest?: boolean\n}\n\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n saveBuildData?: boolean,\n registry?: string,\n throwOnMissingManifest?: boolean,\n) => {\n // we do not store importers in the lockfile, though we do store\n // their edges. when we load, we always read workspaces/main fresh.\n const arr: Node[] = [...nodes].filter(node => !node.importer)\n // nodes are sorted in order to have a deterministic result\n const orderedNodes: Node[] = arr.sort((a, b) =>\n a.id.localeCompare(b.id, 'en'),\n )\n\n const res: Record<DepID, LockfileNode> = {}\n for (const node of orderedNodes) {\n const customRegistry =\n node.resolved && registry && !node.resolved.startsWith(registry)\n const resolved = customRegistry ? node.resolved : undefined\n // if it's in a location other than the default, stash that\n const location =\n node.id.startsWith('file') || node.inVltStore() ?\n undefined\n : node.location\n\n const flags = getFlagNumFromNode(node)\n const lockfileNode: LockfileNode = [flags, node.name]\n\n if (node.integrity) {\n lockfileNode[2] = node.integrity\n }\n\n // skip resolved for remote nodes since\n // these are already part of the dep id\n if (resolved && !node.id.startsWith('remote')) {\n lockfileNode[3] = resolved\n }\n\n if (location) {\n lockfileNode[4] = location\n }\n\n if (saveManifests && node.manifest) {\n lockfileNode[5] = expandNormalizedManifestSymbols(node.manifest)\n\n if (node.confused && node.rawManifest) {\n lockfileNode[6] = expandNormalizedManifestSymbols(\n node.rawManifest,\n )\n }\n }\n\n // Throw an error if a manifest is missing and the option is enabled\n if (throwOnMissingManifest && !node.manifest) {\n throw error(`Missing manifest for node ${node.id}.`)\n }\n\n // Always save platform data for optional dependencies if available\n if (node.optional && node.platform) {\n lockfileNode[7] = node.platform as LockfilePlatform\n }\n\n // Save bin data if available\n if (node.bins && Object.keys(node.bins).length) {\n lockfileNode[8] = node.bins\n }\n\n // Save build state data if requested\n if (saveBuildData) {\n const buildState = getBuildStateFromNode(node)\n if (buildState !== undefined) {\n lockfileNode[9] = buildState\n }\n }\n\n res[node.id] = lockfileNode\n }\n return res\n}\n\nconst formatEdges = (edges: Set<Edge>): LockfileEdges =>\n Object.fromEntries(\n [...edges]\n .sort(\n (a, b) =>\n /* c8 ignore start - nondeterminstic and annoying to test */\n // sort importers to the top, then alphabetically by\n // id, type, target\n Number(b.from.importer) - Number(a.from.importer) ||\n a.from.id.localeCompare(b.from.id, 'en') ||\n a.type.localeCompare(b.type, 'en') ||\n (a.to?.id ?? '').localeCompare(b.to?.id ?? ''),\n /* c8 ignore stop */\n )\n .map((edge): [LockfileEdgeKey, LockfileEdgeValue] => [\n `${edge.from.id} ${edge.spec.name}`,\n `${edge.type} ${edge.spec.bareSpec || '*'} ${edge.to?.id ?? 'MISSING'}`,\n ]),\n )\n\nconst removeDefaultItems = (\n defaultItems: Record<string, string>,\n items: Record<string, string>,\n) => {\n const res: Record<string, string> = {}\n for (const [key, value] of Object.entries(items)) {\n if (!defaultItems[key] || defaultItems[key] !== value) {\n res[key] = value\n }\n }\n return res\n}\n\nexport const lockfileData = ({\n graph,\n catalog,\n catalogs,\n 'git-hosts': gitHosts,\n 'git-host-archives': gitHostArchives,\n modifiers,\n registry,\n registries,\n saveManifests,\n saveBuildData,\n 'scope-registries': scopeRegistries,\n 'jsr-registries': jsrRegistries,\n throwOnMissingManifest,\n}: SaveOptions): LockfileData => {\n const cleanGitHosts =\n isRecordStringString(gitHosts) ?\n removeDefaultItems(defaultGitHosts, gitHosts)\n : undefined\n const cleanGitHostArchives =\n isRecordStringString(gitHostArchives) ?\n removeDefaultItems(defaultGitHostArchives, gitHostArchives)\n : undefined\n const cleanModifiers =\n modifiers && isRecordStringString(modifiers.config) ?\n modifiers.config\n : undefined\n const cleanRegistries =\n isRecordStringString(registries) ?\n removeDefaultItems(defaultRegistries, registries)\n : undefined\n const cleanScopeRegistries =\n isRecordStringString(scopeRegistries) ?\n removeDefaultItems(defaultScopeRegistries, scopeRegistries)\n : undefined\n const cleanJsrRegistries =\n isRecordStringString(jsrRegistries) ?\n removeDefaultItems(defaultJsrRegistries, jsrRegistries)\n : undefined\n const hasItems = (clean: Record<string, unknown> | undefined) =>\n clean && Object.keys(clean).length\n return {\n lockfileVersion: LOCKFILE_VERSION,\n options: {\n ...(hasItems(cleanModifiers) ?\n { modifiers: cleanModifiers }\n : {}),\n ...(hasItems(catalog) ? { catalog } : {}),\n ...(hasItems(catalogs) ? { catalogs } : {}),\n ...(hasItems(cleanScopeRegistries) ?\n { 'scope-registries': cleanScopeRegistries }\n : undefined),\n ...(hasItems(cleanJsrRegistries) ?\n { 'jsr-registries': cleanJsrRegistries }\n : undefined),\n ...(registry !== undefined && registry !== defaultRegistry ?\n { registry }\n : undefined),\n ...(hasItems(cleanRegistries) ?\n { registries: cleanRegistries }\n : undefined),\n ...(hasItems(cleanGitHosts) ?\n { 'git-hosts': cleanGitHosts }\n : undefined),\n ...(hasItems(cleanGitHostArchives) ?\n { 'git-host-archives': cleanGitHostArchives }\n : undefined),\n },\n nodes: formatNodes(\n graph.nodes.values(),\n saveManifests,\n saveBuildData,\n registry,\n throwOnMissingManifest,\n ),\n edges: formatEdges(graph.edges),\n }\n}\n\n// renders each node / edge as a single line entry\nconst extraFormat = (jsonString: string) => {\n const str = `${jsonString}\\n`\n const [init, ...parts] = str.split(' \"nodes\": {')\n const res = [init]\n for (const part of parts) {\n res.push(\n part.replaceAll('\\n ', '').replaceAll('\\n ]', ']'),\n )\n }\n return res.join(' \"nodes\": {')\n}\n\nexport const saveData = (\n data: LockfileData,\n fileName: string,\n saveManifests = false,\n): void => {\n const json = JSON.stringify(data, null, 2)\n const content = saveManifests ? json : extraFormat(json)\n writeFileSync(fileName, content)\n}\n\nexport const save = (\n options: Omit<SaveOptions, 'saveManifests'>,\n): void => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: false })\n const fileName = resolve(graph.projectRoot, 'vlt-lock.json')\n saveData(data, fileName, false)\n}\n\nexport const saveHidden = (\n options: Omit<SaveOptions, 'saveManifests' | 'saveBuildData'>,\n): void => {\n const { graph } = options\n let data: LockfileData | undefined\n\n try {\n data = lockfileData({\n ...options,\n saveManifests: true,\n saveBuildData: true,\n throwOnMissingManifest: true,\n })\n } catch {}\n\n if (!data) return\n\n const fileName = resolve(\n graph.projectRoot,\n 'node_modules/.vlt-lock.json',\n )\n mkdirSync(dirname(fileName), { recursive: true })\n saveData(data, fileName, true)\n}\n"]}
@@ -1,96 +0,0 @@
1
- import type { DepID } from '@vltpkg/dep-id';
2
- import type { Spec, SpecOptions } from '@vltpkg/spec';
3
- import type { Integrity, NormalizedManifest, DependencyTypeShort } from '@vltpkg/types';
4
- /**
5
- * Platform requirements for a lockfile node
6
- */
7
- export type LockfilePlatform = {
8
- engines?: Record<string, string>;
9
- os?: string[] | string;
10
- cpu?: string[] | string;
11
- libc?: string[] | string;
12
- };
13
- /**
14
- * This is the main type definition for the contents of the
15
- * `vlt-lock.json` file.
16
- *
17
- * The nodes and edges information from the lockfile are used to reconstruct
18
- * a {@link Graph} representing a previous install.
19
- */
20
- export type LockfileData = {
21
- lockfileVersion: number;
22
- options: SpecOptions & {
23
- modifiers?: Record<string, string> | undefined;
24
- };
25
- nodes: Record<DepID, LockfileNode>;
26
- edges: LockfileEdges;
27
- };
28
- /**
29
- * Current lockfile format version.
30
- * Only lockfiles with matching version are considered valid.
31
- * Bump when making breaking format changes.
32
- */
33
- export declare const LOCKFILE_VERSION = 1;
34
- export declare const getFlagNumFromNode: (node: {
35
- optional?: boolean;
36
- dev?: boolean;
37
- }) => 1 | 0 | 2 | 3;
38
- export declare const getBooleanFlagsFromNum: (flags: LockfileNodeFlags) => {
39
- dev: boolean;
40
- optional: boolean;
41
- };
42
- export declare const LockfileNodeFlagNone = 0;
43
- export declare const LockfileNodeFlagOptional = 1;
44
- export declare const LockfileNodeFlagDev = 2;
45
- export declare const LockfileNodeFlagDevOptional = 3;
46
- /**
47
- * Bit flags indicating whether a node is optional and/or dev.
48
- */
49
- export type LockfileNodeFlags = 0 | 1 | 2 | 3;
50
- /**
51
- * Build state constants for lockfile nodes
52
- */
53
- export declare const BuildStateNone: undefined;
54
- export declare const BuildStateNeeded = 1;
55
- export declare const BuildStateBuilt = 2;
56
- export declare const BuildStateFailed = 3;
57
- /**
58
- * Build state for a node - tracks whether it needs building, has been built, or failed
59
- */
60
- export type LockfileBuildState = undefined | 1 | 2 | 3;
61
- export declare const getBuildStateFromNode: (node: {
62
- buildState?: "none" | "needed" | "built" | "failed";
63
- }) => LockfileBuildState;
64
- export declare const getBuildStateFromNum: (state: LockfileBuildState) => "none" | "needed" | "built" | "failed";
65
- /**
66
- * Lockfile representation of a node from the install graph.
67
- */
68
- export type LockfileNode = [
69
- flags: LockfileNodeFlags,
70
- name?: string | null,
71
- integrity?: Integrity | null,
72
- resolved?: string | null,
73
- location?: string | null,
74
- manifest?: NormalizedManifest | null,
75
- rawManifest?: NormalizedManifest | null,
76
- platform?: LockfilePlatform | null,
77
- bins?: Record<string, string> | null,
78
- buildState?: LockfileBuildState | null
79
- ];
80
- /**
81
- * Lockfile edges are stored as a record object where the key
82
- * is `${from.id} ${spec.name}` and the value is
83
- * `${type} ${spec.bareSpec} ${to.id | 'MISSING'}`
84
- *
85
- * Storing them in a record like this means that we are guaranteed to
86
- * never end up with duplicates, and a standard `JSON.stringify()`
87
- * will nicely print them out one line per edge.
88
- */
89
- export type LockfileEdges = {
90
- [key: LockfileEdgeKey]: LockfileEdgeValue;
91
- };
92
- /** `${from} ${dep name}` */
93
- export type LockfileEdgeKey = `${DepID} ${string}`;
94
- /** `${type} ${spec} ${to}` */
95
- export type LockfileEdgeValue = `${DependencyTypeShort} ${Spec['bareSpec']} ${DepID | 'MISSING'}`;
96
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lockfile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAGtB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACtB,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;CACzB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,WAAW,GAAG;QACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;KAC/C,CAAA;IACD,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAClC,KAAK,EAAE,aAAa,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,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,EAAE,kBAAkB,GAAG,IAAI;IACvC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IACpC,UAAU,CAAC,EAAE,kBAAkB,GAAG,IAAI;CACvC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,eAAe,GAAG,iBAAiB,CAAA;CAC1C,CAAA;AAED,4BAA4B;AAC5B,MAAM,MAAM,eAAe,GAAG,GAAG,KAAK,IAAI,MAAM,EAAE,CAAA;AAElD,8BAA8B;AAC9B,MAAM,MAAM,iBAAiB,GAC3B,GAAG,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAA"}
@@ -1,50 +0,0 @@
1
- /**
2
- * Current lockfile format version.
3
- * Only lockfiles with matching version are considered valid.
4
- * Bump when making breaking format changes.
5
- */
6
- export const LOCKFILE_VERSION = 1;
7
- export const getFlagNumFromNode = (node) => node.optional && node.dev ? LockfileNodeFlagDevOptional
8
- : node.optional ? LockfileNodeFlagOptional
9
- : node.dev ? LockfileNodeFlagDev
10
- : LockfileNodeFlagNone;
11
- export const getBooleanFlagsFromNum = (flags) => ({
12
- dev: !!(flags & LockfileNodeFlagDev),
13
- optional: !!(flags & LockfileNodeFlagOptional),
14
- });
15
- export const LockfileNodeFlagNone = 0;
16
- export const LockfileNodeFlagOptional = 1;
17
- export const LockfileNodeFlagDev = 2;
18
- export const LockfileNodeFlagDevOptional = 3;
19
- /**
20
- * Build state constants for lockfile nodes
21
- */
22
- export const BuildStateNone = undefined;
23
- export const BuildStateNeeded = 1;
24
- export const BuildStateBuilt = 2;
25
- export const BuildStateFailed = 3;
26
- export const getBuildStateFromNode = (node) => {
27
- switch (node.buildState) {
28
- case 'needed':
29
- return BuildStateNeeded;
30
- case 'built':
31
- return BuildStateBuilt;
32
- case 'failed':
33
- return BuildStateFailed;
34
- default:
35
- return BuildStateNone;
36
- }
37
- };
38
- export const getBuildStateFromNum = (state) => {
39
- switch (state) {
40
- case BuildStateNeeded:
41
- return 'needed';
42
- case BuildStateBuilt:
43
- return 'built';
44
- case BuildStateFailed:
45
- return 'failed';
46
- default:
47
- return 'none';
48
- }
49
- };
50
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lockfile/types.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAEjC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAGlC,EAAE,EAAE,CACH,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,2BAA2B;IACvD,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,wBAAwB;QAC1C,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,mBAAmB;YAChC,CAAC,CAAC,oBAAoB,CAAA;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAwB,EAAE,EAAE,CAAC,CAAC;IACnE,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,mBAAmB,CAAC;IACpC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,wBAAwB,CAAC;CAC/C,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAA;AACrC,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAA;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAA;AACpC,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAO5C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAA;AACvC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAA;AAChC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAOjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAErC,EAAsB,EAAE;IACvB,QAAQ,IAAI,CAAC,UAAU,EAAE,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAA;QACzB,KAAK,OAAO;YACV,OAAO,eAAe,CAAA;QACxB,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAA;QACzB;YACE,OAAO,cAAc,CAAA;IACzB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,KAAyB,EACe,EAAE;IAC1C,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,gBAAgB;YACnB,OAAO,QAAQ,CAAA;QACjB,KAAK,eAAe;YAClB,OAAO,OAAO,CAAA;QAChB,KAAK,gBAAgB;YACnB,OAAO,QAAQ,CAAA;QACjB;YACE,OAAO,MAAM,CAAA;IACjB,CAAC;AACH,CAAC,CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Graph } from '../graph.ts'\n\n/**\n * Platform requirements for a lockfile node\n */\nexport type LockfilePlatform = {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n libc?: string[] | string\n}\n\n/**\n * This is the main type definition for the contents of the\n * `vlt-lock.json` file.\n *\n * The nodes and edges information from the lockfile are used to reconstruct\n * a {@link Graph} representing a previous install.\n */\nexport type LockfileData = {\n lockfileVersion: number\n options: SpecOptions & {\n modifiers?: Record<string, string> | undefined\n }\n nodes: Record<DepID, LockfileNode>\n edges: LockfileEdges\n}\n\n/**\n * Current lockfile format version.\n * Only lockfiles with matching version are considered valid.\n * Bump when making breaking format changes.\n */\nexport const LOCKFILE_VERSION = 1\n\nexport const getFlagNumFromNode = (node: {\n optional?: boolean\n dev?: boolean\n}) =>\n node.optional && node.dev ? LockfileNodeFlagDevOptional\n : node.optional ? LockfileNodeFlagOptional\n : node.dev ? LockfileNodeFlagDev\n : LockfileNodeFlagNone\n\nexport const getBooleanFlagsFromNum = (flags: LockfileNodeFlags) => ({\n dev: !!(flags & LockfileNodeFlagDev),\n optional: !!(flags & LockfileNodeFlagOptional),\n})\n\nexport const LockfileNodeFlagNone = 0\nexport const LockfileNodeFlagOptional = 1\nexport const LockfileNodeFlagDev = 2\nexport const LockfileNodeFlagDevOptional = 3\n\n/**\n * Bit flags indicating whether a node is optional and/or dev.\n */\nexport type LockfileNodeFlags = 0 | 1 | 2 | 3\n\n/**\n * Build state constants for lockfile nodes\n */\nexport const BuildStateNone = undefined\nexport const BuildStateNeeded = 1\nexport const BuildStateBuilt = 2\nexport const BuildStateFailed = 3\n\n/**\n * Build state for a node - tracks whether it needs building, has been built, or failed\n */\nexport type LockfileBuildState = undefined | 1 | 2 | 3\n\nexport const getBuildStateFromNode = (node: {\n buildState?: 'none' | 'needed' | 'built' | 'failed'\n}): LockfileBuildState => {\n switch (node.buildState) {\n case 'needed':\n return BuildStateNeeded\n case 'built':\n return BuildStateBuilt\n case 'failed':\n return BuildStateFailed\n default:\n return BuildStateNone\n }\n}\n\nexport const getBuildStateFromNum = (\n state: LockfileBuildState,\n): 'none' | 'needed' | 'built' | 'failed' => {\n switch (state) {\n case BuildStateNeeded:\n return 'needed'\n case BuildStateBuilt:\n return 'built'\n case BuildStateFailed:\n return 'failed'\n default:\n return 'none'\n }\n}\n\n/**\n * Lockfile representation of a node from the install graph.\n */\nexport type LockfileNode = [\n flags: LockfileNodeFlags,\n name?: string | null,\n integrity?: Integrity | null,\n resolved?: string | null,\n location?: string | null,\n manifest?: NormalizedManifest | null,\n rawManifest?: NormalizedManifest | null,\n platform?: LockfilePlatform | null,\n bins?: Record<string, string> | null,\n buildState?: LockfileBuildState | null,\n]\n\n/**\n * Lockfile edges are stored as a record object where the key\n * is `${from.id} ${spec.name}` and the value is\n * `${type} ${spec.bareSpec} ${to.id | 'MISSING'}`\n *\n * Storing them in a record like this means that we are guaranteed to\n * never end up with duplicates, and a standard `JSON.stringify()`\n * will nicely print them out one line per edge.\n */\nexport type LockfileEdges = {\n [key: LockfileEdgeKey]: LockfileEdgeValue\n}\n\n/** `${from} ${dep name}` */\nexport type LockfileEdgeKey = `${DepID} ${string}`\n\n/** `${type} ${spec} ${to}` */\nexport type LockfileEdgeValue =\n `${DependencyTypeShort} ${Spec['bareSpec']} ${DepID | 'MISSING'}`\n"]}