@vltpkg/graph 1.0.0-rc.2 → 1.0.0-rc.23

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 (211) hide show
  1. package/README.md +101 -22
  2. package/package.json +51 -63
  3. package/dist/esm/actual/load.d.ts +0 -100
  4. package/dist/esm/actual/load.d.ts.map +0 -1
  5. package/dist/esm/actual/load.js +0 -304
  6. package/dist/esm/actual/load.js.map +0 -1
  7. package/dist/esm/browser.d.ts +0 -15
  8. package/dist/esm/browser.d.ts.map +0 -1
  9. package/dist/esm/browser.js +0 -17
  10. package/dist/esm/browser.js.map +0 -1
  11. package/dist/esm/build.d.ts +0 -29
  12. package/dist/esm/build.d.ts.map +0 -1
  13. package/dist/esm/build.js +0 -79
  14. package/dist/esm/build.js.map +0 -1
  15. package/dist/esm/dependencies.d.ts +0 -66
  16. package/dist/esm/dependencies.d.ts.map +0 -1
  17. package/dist/esm/dependencies.js +0 -112
  18. package/dist/esm/dependencies.js.map +0 -1
  19. package/dist/esm/diff.d.ts +0 -116
  20. package/dist/esm/diff.d.ts.map +0 -1
  21. package/dist/esm/diff.js +0 -148
  22. package/dist/esm/diff.js.map +0 -1
  23. package/dist/esm/edge.d.ts +0 -46
  24. package/dist/esm/edge.d.ts.map +0 -1
  25. package/dist/esm/edge.js +0 -74
  26. package/dist/esm/edge.js.map +0 -1
  27. package/dist/esm/graph.d.ts +0 -133
  28. package/dist/esm/graph.d.ts.map +0 -1
  29. package/dist/esm/graph.js +0 -407
  30. package/dist/esm/graph.js.map +0 -1
  31. package/dist/esm/ideal/add-nodes.d.ts +0 -34
  32. package/dist/esm/ideal/add-nodes.d.ts.map +0 -1
  33. package/dist/esm/ideal/add-nodes.js +0 -39
  34. package/dist/esm/ideal/add-nodes.js.map +0 -1
  35. package/dist/esm/ideal/append-nodes.d.ts +0 -19
  36. package/dist/esm/ideal/append-nodes.d.ts.map +0 -1
  37. package/dist/esm/ideal/append-nodes.js +0 -289
  38. package/dist/esm/ideal/append-nodes.js.map +0 -1
  39. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +0 -15
  40. package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +0 -1
  41. package/dist/esm/ideal/build-ideal-from-starting-graph.js +0 -55
  42. package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +0 -1
  43. package/dist/esm/ideal/build.d.ts +0 -41
  44. package/dist/esm/ideal/build.d.ts.map +0 -1
  45. package/dist/esm/ideal/build.js +0 -48
  46. package/dist/esm/ideal/build.js.map +0 -1
  47. package/dist/esm/ideal/get-importer-specs.d.ts +0 -14
  48. package/dist/esm/ideal/get-importer-specs.d.ts.map +0 -1
  49. package/dist/esm/ideal/get-importer-specs.js +0 -106
  50. package/dist/esm/ideal/get-importer-specs.js.map +0 -1
  51. package/dist/esm/ideal/remove-nodes.d.ts +0 -7
  52. package/dist/esm/ideal/remove-nodes.d.ts.map +0 -1
  53. package/dist/esm/ideal/remove-nodes.js +0 -19
  54. package/dist/esm/ideal/remove-nodes.js.map +0 -1
  55. package/dist/esm/ideal/remove-satisfied-specs.d.ts +0 -8
  56. package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +0 -1
  57. package/dist/esm/ideal/remove-satisfied-specs.js +0 -35
  58. package/dist/esm/ideal/remove-satisfied-specs.js.map +0 -1
  59. package/dist/esm/ideal/types.d.ts +0 -35
  60. package/dist/esm/ideal/types.d.ts.map +0 -1
  61. package/dist/esm/ideal/types.js +0 -2
  62. package/dist/esm/ideal/types.js.map +0 -1
  63. package/dist/esm/index.d.ts +0 -38
  64. package/dist/esm/index.d.ts.map +0 -1
  65. package/dist/esm/index.js +0 -32
  66. package/dist/esm/index.js.map +0 -1
  67. package/dist/esm/install.d.ts +0 -19
  68. package/dist/esm/install.d.ts.map +0 -1
  69. package/dist/esm/install.js +0 -173
  70. package/dist/esm/install.js.map +0 -1
  71. package/dist/esm/lockfile/load-edges.d.ts +0 -12
  72. package/dist/esm/lockfile/load-edges.d.ts.map +0 -1
  73. package/dist/esm/lockfile/load-edges.js +0 -105
  74. package/dist/esm/lockfile/load-edges.js.map +0 -1
  75. package/dist/esm/lockfile/load-nodes.d.ts +0 -5
  76. package/dist/esm/lockfile/load-nodes.d.ts.map +0 -1
  77. package/dist/esm/lockfile/load-nodes.js +0 -95
  78. package/dist/esm/lockfile/load-nodes.js.map +0 -1
  79. package/dist/esm/lockfile/load.d.ts +0 -50
  80. package/dist/esm/lockfile/load.d.ts.map +0 -1
  81. package/dist/esm/lockfile/load.js +0 -89
  82. package/dist/esm/lockfile/load.js.map +0 -1
  83. package/dist/esm/lockfile/save.d.ts +0 -31
  84. package/dist/esm/lockfile/save.d.ts.map +0 -1
  85. package/dist/esm/lockfile/save.js +0 -173
  86. package/dist/esm/lockfile/save.js.map +0 -1
  87. package/dist/esm/lockfile/types.d.ts +0 -89
  88. package/dist/esm/lockfile/types.d.ts.map +0 -1
  89. package/dist/esm/lockfile/types.js +0 -44
  90. package/dist/esm/lockfile/types.js.map +0 -1
  91. package/dist/esm/modifiers.d.ts +0 -189
  92. package/dist/esm/modifiers.d.ts.map +0 -1
  93. package/dist/esm/modifiers.js +0 -330
  94. package/dist/esm/modifiers.js.map +0 -1
  95. package/dist/esm/node.d.ts +0 -219
  96. package/dist/esm/node.d.ts.map +0 -1
  97. package/dist/esm/node.js +0 -368
  98. package/dist/esm/node.js.map +0 -1
  99. package/dist/esm/non-empty-list.d.ts +0 -3
  100. package/dist/esm/non-empty-list.d.ts.map +0 -1
  101. package/dist/esm/non-empty-list.js +0 -3
  102. package/dist/esm/non-empty-list.js.map +0 -1
  103. package/dist/esm/package.json +0 -3
  104. package/dist/esm/reify/add-edge.d.ts +0 -10
  105. package/dist/esm/reify/add-edge.d.ts.map +0 -1
  106. package/dist/esm/reify/add-edge.js +0 -65
  107. package/dist/esm/reify/add-edge.js.map +0 -1
  108. package/dist/esm/reify/add-edges.d.ts +0 -5
  109. package/dist/esm/reify/add-edges.d.ts.map +0 -1
  110. package/dist/esm/reify/add-edges.js +0 -12
  111. package/dist/esm/reify/add-edges.js.map +0 -1
  112. package/dist/esm/reify/add-nodes.d.ts +0 -7
  113. package/dist/esm/reify/add-nodes.d.ts.map +0 -1
  114. package/dist/esm/reify/add-nodes.js +0 -17
  115. package/dist/esm/reify/add-nodes.js.map +0 -1
  116. package/dist/esm/reify/bin-chmod.d.ts +0 -11
  117. package/dist/esm/reify/bin-chmod.d.ts.map +0 -1
  118. package/dist/esm/reify/bin-chmod.js +0 -39
  119. package/dist/esm/reify/bin-chmod.js.map +0 -1
  120. package/dist/esm/reify/build.d.ts +0 -14
  121. package/dist/esm/reify/build.d.ts.map +0 -1
  122. package/dist/esm/reify/build.js +0 -103
  123. package/dist/esm/reify/build.js.map +0 -1
  124. package/dist/esm/reify/calculate-save-value.d.ts +0 -3
  125. package/dist/esm/reify/calculate-save-value.d.ts.map +0 -1
  126. package/dist/esm/reify/calculate-save-value.js +0 -45
  127. package/dist/esm/reify/calculate-save-value.js.map +0 -1
  128. package/dist/esm/reify/check-needed-build.d.ts +0 -25
  129. package/dist/esm/reify/check-needed-build.d.ts.map +0 -1
  130. package/dist/esm/reify/check-needed-build.js +0 -50
  131. package/dist/esm/reify/check-needed-build.js.map +0 -1
  132. package/dist/esm/reify/delete-edge.d.ts +0 -5
  133. package/dist/esm/reify/delete-edge.d.ts.map +0 -1
  134. package/dist/esm/reify/delete-edge.js +0 -28
  135. package/dist/esm/reify/delete-edge.js.map +0 -1
  136. package/dist/esm/reify/delete-edges.d.ts +0 -5
  137. package/dist/esm/reify/delete-edges.d.ts.map +0 -1
  138. package/dist/esm/reify/delete-edges.js +0 -14
  139. package/dist/esm/reify/delete-edges.js.map +0 -1
  140. package/dist/esm/reify/delete-nodes.d.ts +0 -5
  141. package/dist/esm/reify/delete-nodes.d.ts.map +0 -1
  142. package/dist/esm/reify/delete-nodes.js +0 -16
  143. package/dist/esm/reify/delete-nodes.js.map +0 -1
  144. package/dist/esm/reify/extract-node.d.ts +0 -24
  145. package/dist/esm/reify/extract-node.d.ts.map +0 -1
  146. package/dist/esm/reify/extract-node.js +0 -76
  147. package/dist/esm/reify/extract-node.js.map +0 -1
  148. package/dist/esm/reify/index.d.ts +0 -34
  149. package/dist/esm/reify/index.d.ts.map +0 -1
  150. package/dist/esm/reify/index.js +0 -161
  151. package/dist/esm/reify/index.js.map +0 -1
  152. package/dist/esm/reify/internal-hoist.d.ts +0 -9
  153. package/dist/esm/reify/internal-hoist.d.ts.map +0 -1
  154. package/dist/esm/reify/internal-hoist.js +0 -134
  155. package/dist/esm/reify/internal-hoist.js.map +0 -1
  156. package/dist/esm/reify/optional-fail.d.ts +0 -16
  157. package/dist/esm/reify/optional-fail.d.ts.map +0 -1
  158. package/dist/esm/reify/optional-fail.js +0 -16
  159. package/dist/esm/reify/optional-fail.js.map +0 -1
  160. package/dist/esm/reify/rollback.d.ts +0 -5
  161. package/dist/esm/reify/rollback.d.ts.map +0 -1
  162. package/dist/esm/reify/rollback.js +0 -24
  163. package/dist/esm/reify/rollback.js.map +0 -1
  164. package/dist/esm/reify/update-importers-package-json.d.ts +0 -36
  165. package/dist/esm/reify/update-importers-package-json.d.ts.map +0 -1
  166. package/dist/esm/reify/update-importers-package-json.js +0 -120
  167. package/dist/esm/reify/update-importers-package-json.js.map +0 -1
  168. package/dist/esm/remove-optional-subgraph.d.ts +0 -34
  169. package/dist/esm/remove-optional-subgraph.d.ts.map +0 -1
  170. package/dist/esm/remove-optional-subgraph.js +0 -48
  171. package/dist/esm/remove-optional-subgraph.js.map +0 -1
  172. package/dist/esm/resolve-save-type.d.ts +0 -6
  173. package/dist/esm/resolve-save-type.d.ts.map +0 -1
  174. package/dist/esm/resolve-save-type.js +0 -5
  175. package/dist/esm/resolve-save-type.js.map +0 -1
  176. package/dist/esm/stringify-node.d.ts +0 -3
  177. package/dist/esm/stringify-node.d.ts.map +0 -1
  178. package/dist/esm/stringify-node.js +0 -24
  179. package/dist/esm/stringify-node.js.map +0 -1
  180. package/dist/esm/transfer-data/load.d.ts +0 -44
  181. package/dist/esm/transfer-data/load.d.ts.map +0 -1
  182. package/dist/esm/transfer-data/load.js +0 -176
  183. package/dist/esm/transfer-data/load.js.map +0 -1
  184. package/dist/esm/uninstall.d.ts +0 -15
  185. package/dist/esm/uninstall.d.ts.map +0 -1
  186. package/dist/esm/uninstall.js +0 -58
  187. package/dist/esm/uninstall.js.map +0 -1
  188. package/dist/esm/update.d.ts +0 -13
  189. package/dist/esm/update.d.ts.map +0 -1
  190. package/dist/esm/update.js +0 -63
  191. package/dist/esm/update.js.map +0 -1
  192. package/dist/esm/virtual-root.d.ts +0 -16
  193. package/dist/esm/virtual-root.d.ts.map +0 -1
  194. package/dist/esm/virtual-root.js +0 -79
  195. package/dist/esm/virtual-root.js.map +0 -1
  196. package/dist/esm/visualization/human-readable-output.d.ts +0 -27
  197. package/dist/esm/visualization/human-readable-output.d.ts.map +0 -1
  198. package/dist/esm/visualization/human-readable-output.js +0 -159
  199. package/dist/esm/visualization/human-readable-output.js.map +0 -1
  200. package/dist/esm/visualization/json-output.d.ts +0 -41
  201. package/dist/esm/visualization/json-output.d.ts.map +0 -1
  202. package/dist/esm/visualization/json-output.js +0 -51
  203. package/dist/esm/visualization/json-output.js.map +0 -1
  204. package/dist/esm/visualization/mermaid-output.d.ts +0 -17
  205. package/dist/esm/visualization/mermaid-output.d.ts.map +0 -1
  206. package/dist/esm/visualization/mermaid-output.js +0 -123
  207. package/dist/esm/visualization/mermaid-output.js.map +0 -1
  208. package/dist/esm/visualization/object-like-output.d.ts +0 -3
  209. package/dist/esm/visualization/object-like-output.d.ts.map +0 -1
  210. package/dist/esm/visualization/object-like-output.js +0 -48
  211. package/dist/esm/visualization/object-like-output.js.map +0 -1
@@ -1,112 +0,0 @@
1
- import { error } from '@vltpkg/error-cause';
2
- import { Spec } from '@vltpkg/spec/browser';
3
- import { dependencyTypes, longDependencyTypes, shortDependencyTypes, } from '@vltpkg/types';
4
- export const isDependencyTypeShort = (obj) => shortDependencyTypes.has(obj);
5
- export const isDependencySaveType = (obj) => shortDependencyTypes.has(obj) ||
6
- obj === 'implicit';
7
- export const asDependencyTypeShort = (obj) => {
8
- if (!isDependencyTypeShort(obj)) {
9
- throw error('Invalid dependency type', {
10
- found: obj,
11
- validOptions: [...shortDependencyTypes],
12
- });
13
- }
14
- return obj;
15
- };
16
- const isObj = (o) => !!o && typeof o === 'object';
17
- // TODO: it would be nice to have a @vltpkg/spec.isSpec method
18
- export const isDependency = (o) =>
19
- // TODO: it would be nice to have a @vltpkg/spec.isSpec method
20
- isObj(o) &&
21
- isObj(o.spec) &&
22
- !!o.spec.type &&
23
- isDependencySaveType(o.type);
24
- export const asDependency = (obj) => {
25
- if (!isDependency(obj)) {
26
- throw error('Invalid dependency', { found: obj });
27
- }
28
- return obj;
29
- };
30
- /**
31
- * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.
32
- */
33
- export const shorten = (typeLong, name, manifest) => {
34
- const shortName = dependencyTypes.get(typeLong);
35
- if (!shortName) {
36
- throw error('Invalid dependency type name', {
37
- found: typeLong,
38
- validOptions: [...longDependencyTypes],
39
- });
40
- }
41
- if (shortName !== 'peer') {
42
- return shortName;
43
- }
44
- if (name &&
45
- manifest?.peerDependenciesMeta?.[name]?.optional === true) {
46
- return 'peerOptional';
47
- }
48
- return 'peer';
49
- };
50
- const isStringArray = (a) => Array.isArray(a) && !a.some(b => typeof b !== 'string');
51
- /*
52
- * Retrieves a map of all dependencies, of all types, that can be iterated
53
- * on and consulted when parsing the directory contents of a given node.
54
- */
55
- export const getRawDependencies = (node) => {
56
- const dependencies = new Map();
57
- const bundleDeps = node.manifest?.bundleDependencies ?? [];
58
- // if it's an importer, bundleDeps are just normal. if it's a dep,
59
- // then they're ignored entirely.
60
- const bundled = (!node.importer &&
61
- !node.id.startsWith('git') &&
62
- isStringArray(bundleDeps)) ?
63
- new Set(bundleDeps)
64
- : new Set();
65
- for (const depType of longDependencyTypes) {
66
- const obj = node.manifest?.[depType];
67
- // only care about devDeps for importers and git or symlink deps
68
- // technically this will also include devDeps for tarball file: specs,
69
- // but that is likely rare enough to not worry about too much.
70
- if (depType === 'devDependencies' &&
71
- !node.importer &&
72
- !node.id.startsWith('git') &&
73
- !node.id.startsWith('file')) {
74
- continue;
75
- }
76
- if (obj) {
77
- for (const [name, bareSpec] of Object.entries(obj)) {
78
- // if it's a bundled dependency, we just ignore it entirely.
79
- if (bundled.has(name))
80
- continue;
81
- dependencies.set(name, {
82
- name,
83
- type: depType,
84
- bareSpec,
85
- registry: node.registry,
86
- });
87
- }
88
- }
89
- }
90
- return dependencies;
91
- };
92
- /**
93
- * Retrieves a map of all dependencies, of all types, that can be inferred
94
- * from a given node manifest, including missing dependencies.
95
- */
96
- export const getDependencies = (node, options) => {
97
- const res = new Map();
98
- const dependencies = getRawDependencies(node);
99
- for (const { name, type, bareSpec } of dependencies.values()) {
100
- const depType = shorten(type, name, node.manifest);
101
- const spec = Spec.parse(name, bareSpec, {
102
- ...options,
103
- registry: node.registry,
104
- });
105
- res.set(name, {
106
- spec,
107
- type: depType,
108
- });
109
- }
110
- return res;
111
- };
112
- //# sourceMappingURL=dependencies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAS3C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC,CAAA;AAEtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAY,EACgB,EAAE,CAC9B,oBAAoB,CAAC,GAAG,CAAC,GAA0B,CAAC;IACpD,GAAG,K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CAAA","sourcesContent":["import type { DepID } from '@vltpkg/dep-id'\nimport { error } from '@vltpkg/error-cause'\nimport { Spec } from '@vltpkg/spec/browser'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type {\n DependencySaveType,\n DependencyTypeLong,\n DependencyTypeShort,\n Manifest,\n NodeLike,\n} from '@vltpkg/types'\nimport {\n dependencyTypes,\n longDependencyTypes,\n shortDependencyTypes,\n} from '@vltpkg/types'\n\nexport const isDependencyTypeShort = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort)\n\nexport const isDependencySaveType = (\n obj: unknown,\n): obj is DependencyTypeShort =>\n shortDependencyTypes.has(obj as DependencyTypeShort) ||\n obj === 'implicit'\n\nexport const asDependencyTypeShort = (\n obj: unknown,\n): DependencyTypeShort => {\n if (!isDependencyTypeShort(obj)) {\n throw error('Invalid dependency type', {\n found: obj,\n validOptions: [...shortDependencyTypes],\n })\n }\n return obj\n}\n\n/**\n * Dependency entries info as defined in a package.json file.\n */\nexport type RawDependency = {\n name: string\n bareSpec: string\n type: DependencyTypeLong\n registry?: string\n}\n\n/**\n * Parsed dependency entries info.\n */\nexport type Dependency = {\n /**\n * The parsed {@link Spec} object describing the dependency requirements.\n */\n spec: Spec\n /**\n * The {@link DependencySaveType}, describing the way this dependency should\n * be saved back to the manifest.\n */\n type: DependencySaveType\n}\n\n/**\n * A `Map` in which keys are {@link DepID} linking to another `Map` in which\n * keys are the dependency names and values are {@link Dependency}. This\n * structure represents dependencies that need to be added to the importer\n * represented by {@link DepID}.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type AddImportersDependenciesMap = Map<\n DepID,\n Map<string, Dependency>\n> & { modifiedDependencies: boolean }\n\n/**\n * A `Map` object representing nodes to be removed from the ideal graph.\n * Each {@link DepID} key represents an importer node and the `Set` of\n * dependency names to be removed from its dependency list.\n *\n * The `modifiedDependencies` property can be used to indicate that there\n * are added dependencies to any of the importer nodes.\n */\nexport type RemoveImportersDependenciesMap = Map<\n DepID,\n Set<string>\n> & { modifiedDependencies: boolean }\n\nconst isObj = (o: unknown): o is Record<string, unknown> =>\n !!o && typeof o === 'object'\n\n// TODO: it would be nice to have a @vltpkg/spec.isSpec method\nexport const isDependency = (o: unknown): o is Dependency =>\n // TODO: it would be nice to have a @vltpkg/spec.isSpec method\n isObj(o) &&\n isObj(o.spec) &&\n !!o.spec.type &&\n isDependencySaveType(o.type)\n\nexport const asDependency = (obj: unknown): Dependency => {\n if (!isDependency(obj)) {\n throw error('Invalid dependency', { found: obj })\n }\n return obj\n}\n\n/**\n * Get the {@link DependencyTypeShort} from a {@link DependencyTypeLong}.\n */\nexport const shorten = (\n typeLong: DependencyTypeLong,\n name?: string,\n manifest?: Pick<Manifest, 'peerDependenciesMeta'> | null,\n): DependencyTypeShort => {\n const shortName = dependencyTypes.get(typeLong)\n if (!shortName) {\n throw error('Invalid dependency type name', {\n found: typeLong,\n validOptions: [...longDependencyTypes],\n })\n }\n if (shortName !== 'peer') {\n return shortName\n }\n if (\n name &&\n manifest?.peerDependenciesMeta?.[name]?.optional === true\n ) {\n return 'peerOptional'\n }\n return 'peer'\n}\n\nconst isStringArray = (a: unknown): a is string[] =>\n Array.isArray(a) && !a.some(b => typeof b !== 'string')\n\n/*\n * Retrieves a map of all dependencies, of all types, that can be iterated\n * on and consulted when parsing the directory contents of a given node.\n */\nexport const getRawDependencies = (node: NodeLike) => {\n const dependencies = new Map<string, RawDependency>()\n const bundleDeps: unknown = node.manifest?.bundleDependencies ?? []\n // if it's an importer, bundleDeps are just normal. if it's a dep,\n // then they're ignored entirely.\n const bundled =\n (\n !node.importer &&\n !node.id.startsWith('git') &&\n isStringArray(bundleDeps)\n ) ?\n new Set(bundleDeps)\n : new Set<string>()\n for (const depType of longDependencyTypes) {\n const obj: Record<string, string> | undefined =\n node.manifest?.[depType]\n // only care about devDeps for importers and git or symlink deps\n // technically this will also include devDeps for tarball file: specs,\n // but that is likely rare enough to not worry about too much.\n if (\n depType === 'devDependencies' &&\n !node.importer &&\n !node.id.startsWith('git') &&\n !node.id.startsWith('file')\n ) {\n continue\n }\n if (obj) {\n for (const [name, bareSpec] of Object.entries(obj)) {\n // if it's a bundled dependency, we just ignore it entirely.\n if (bundled.has(name)) continue\n dependencies.set(name, {\n name,\n type: depType,\n bareSpec,\n registry: node.registry,\n })\n }\n }\n }\n return dependencies\n}\n\n/**\n * Retrieves a map of all dependencies, of all types, that can be inferred\n * from a given node manifest, including missing dependencies.\n */\nexport const getDependencies = (\n node: NodeLike,\n options: SpecOptions,\n): Map<string, Dependency> => {\n const res = new Map<string, Dependency>()\n const dependencies = getRawDependencies(node)\n for (const { name, type, bareSpec } of dependencies.values()) {\n const depType = shorten(type, name, node.manifest)\n const spec = Spec.parse(name, bareSpec, {\n ...options,\n registry: node.registry,\n })\n res.set(name, {\n spec,\n type: depType,\n })\n }\n return res\n}\n"]}
@@ -1,116 +0,0 @@
1
- import type { InspectOptions } from 'node:util';
2
- import type { Edge } from './edge.ts';
3
- import type { Graph } from './graph.ts';
4
- import type { Node } from './node.ts';
5
- declare const kCustomInspect: unique symbol;
6
- /**
7
- * A Diff object is a representation of a set of changes from one
8
- * graph to another, typically from the actual graph as it is reified
9
- * on disk, to an intended ideal graph.
10
- *
11
- * The naming convention can get a bit confusing here, because it's a
12
- * set of directed changes from one set of directed objects to another.
13
- *
14
- * Within the context the Diff object, `from` is the Graph we're coming from,
15
- * and `to` is the Graph we're trying to create.
16
- */
17
- export declare class Diff {
18
- from: Graph;
19
- to: Graph;
20
- projectRoot: string;
21
- /**
22
- * If changes need to be made later for failures of optional nodes,
23
- * set this flag so that we know to call graph.gc() at the appropriate time.
24
- */
25
- hadOptionalFailures: boolean;
26
- /**
27
- * Collection of nodes to add and delete
28
- */
29
- nodes: {
30
- /** Nodes in the `to` graph that are not in the `from` graph */
31
- add: Set<Node>;
32
- /** Nodes in the `from` graph that are not in the `to` graph */
33
- delete: Set<Node>;
34
- };
35
- /**
36
- * Collection of nodes to add and delete
37
- */
38
- edges: {
39
- /** Edges in the `to` graph that are not found in the `from` graph */
40
- add: Set<Edge>;
41
- /** Edges in the `from` graph that are not found in the `to` graph */
42
- delete: Set<Edge>;
43
- };
44
- /**
45
- * True if the diff only contains optional nodes (computed during construction)
46
- */
47
- optionalOnly: boolean;
48
- get [Symbol.toStringTag](): string;
49
- constructor(from: Graph, to: Graph);
50
- [kCustomInspect](_: number, options?: InspectOptions): string;
51
- hasChanges(): boolean;
52
- toJSON(): {
53
- nodes: {
54
- add: {
55
- rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
56
- id: import("@vltpkg/dep-id").DepID;
57
- name: string;
58
- version: string | undefined;
59
- location: string;
60
- importer: boolean;
61
- manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
62
- projectRoot: string;
63
- integrity: `sha512-${string}` | undefined;
64
- resolved: string | undefined;
65
- dev: boolean;
66
- optional: boolean;
67
- confused: boolean;
68
- modifier: string | undefined;
69
- platform: {
70
- engines?: Record<string, string>;
71
- os?: string[] | string;
72
- cpu?: string[] | string;
73
- } | undefined;
74
- buildState: "none" | "needed" | "built" | "failed";
75
- }[];
76
- delete: {
77
- rawManifest?: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
78
- id: import("@vltpkg/dep-id").DepID;
79
- name: string;
80
- version: string | undefined;
81
- location: string;
82
- importer: boolean;
83
- manifest: import("@vltpkg/types").Override<import("@vltpkg/types").Manifest, import("@vltpkg/types").NormalizedFields> | undefined;
84
- projectRoot: string;
85
- integrity: `sha512-${string}` | undefined;
86
- resolved: string | undefined;
87
- dev: boolean;
88
- optional: boolean;
89
- confused: boolean;
90
- modifier: string | undefined;
91
- platform: {
92
- engines?: Record<string, string>;
93
- os?: string[] | string;
94
- cpu?: string[] | string;
95
- } | undefined;
96
- buildState: "none" | "needed" | "built" | "failed";
97
- }[];
98
- };
99
- edges: {
100
- add: {
101
- from: import("@vltpkg/dep-id").DepID;
102
- to: import("@vltpkg/dep-id").DepID | undefined;
103
- type: import("@vltpkg/types").DependencyTypeShort;
104
- spec: string;
105
- }[];
106
- delete: {
107
- from: import("@vltpkg/dep-id").DepID;
108
- to: import("@vltpkg/dep-id").DepID | undefined;
109
- type: import("@vltpkg/types").DependencyTypeShort;
110
- spec: string;
111
- }[];
112
- };
113
- };
114
- }
115
- export {};
116
- //# sourceMappingURL=diff.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAOrC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,qBAAa,IAAI;IACf,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IAET,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,mBAAmB,UAAQ;IAE3B;;OAEG;IACH,KAAK;QACH,+DAA+D;;QAE/D,+DAA+D;;MAEhE;IAED;;OAEG;IACH,KAAK;QACH,qEAAqE;;QAErE,qEAAqE;;MAEtE;IAED;;OAEG;IACH,YAAY,UAAO;IAEnB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;gBAEW,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK;IA4ClC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,MAAM;IAwC7D,UAAU,IAAI,OAAO;IASrB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAYP"}
package/dist/esm/diff.js DELETED
@@ -1,148 +0,0 @@
1
- import { error } from '@vltpkg/error-cause';
2
- // XXX should file deps *always* be considered changed?
3
- // unless the thing containing it wasn't possibly changed because it's inside
4
- // a dep that didn't change?
5
- // Same with remote deps
6
- const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
7
- /**
8
- * A Diff object is a representation of a set of changes from one
9
- * graph to another, typically from the actual graph as it is reified
10
- * on disk, to an intended ideal graph.
11
- *
12
- * The naming convention can get a bit confusing here, because it's a
13
- * set of directed changes from one set of directed objects to another.
14
- *
15
- * Within the context the Diff object, `from` is the Graph we're coming from,
16
- * and `to` is the Graph we're trying to create.
17
- */
18
- export class Diff {
19
- from;
20
- to;
21
- projectRoot;
22
- /**
23
- * If changes need to be made later for failures of optional nodes,
24
- * set this flag so that we know to call graph.gc() at the appropriate time.
25
- */
26
- hadOptionalFailures = false;
27
- /**
28
- * Collection of nodes to add and delete
29
- */
30
- nodes = {
31
- /** Nodes in the `to` graph that are not in the `from` graph */
32
- add: new Set(),
33
- /** Nodes in the `from` graph that are not in the `to` graph */
34
- delete: new Set(),
35
- };
36
- /**
37
- * Collection of nodes to add and delete
38
- */
39
- edges = {
40
- /** Edges in the `to` graph that are not found in the `from` graph */
41
- add: new Set(),
42
- /** Edges in the `from` graph that are not found in the `to` graph */
43
- delete: new Set(),
44
- };
45
- /**
46
- * True if the diff only contains optional nodes (computed during construction)
47
- */
48
- optionalOnly = true;
49
- get [Symbol.toStringTag]() {
50
- return '@vltpkg/graph.Diff';
51
- }
52
- constructor(from, to) {
53
- this.from = from;
54
- this.to = to;
55
- this.projectRoot = from.projectRoot;
56
- if (to.projectRoot !== from.projectRoot) {
57
- throw error('projectRoot mismatch in Graph diff', {
58
- wanted: from.projectRoot,
59
- found: to.projectRoot,
60
- });
61
- }
62
- for (const [id, node] of this.from.nodes) {
63
- if (!this.to.nodes.get(id)?.equals(node)) {
64
- this.nodes.delete.add(node);
65
- }
66
- }
67
- for (const [id, node] of this.to.nodes) {
68
- if (!this.from.nodes.get(id)?.equals(node)) {
69
- this.nodes.add.add(node);
70
- if (!node.optional) {
71
- this.optionalOnly = false;
72
- }
73
- }
74
- }
75
- for (const edge of this.to.edges) {
76
- // the node with this dep, in the from graph
77
- const fromNode = this.from.nodes.get(edge.from.id);
78
- const fromEdge = fromNode?.edgesOut.get(edge.spec.name);
79
- if (fromEdge?.to?.id === edge.to?.id)
80
- continue;
81
- if (fromEdge?.to)
82
- this.edges.delete.add(fromEdge);
83
- if (edge.to)
84
- this.edges.add.add(edge);
85
- }
86
- for (const edge of this.from.edges) {
87
- // the node with this dep, in the to graph
88
- const toNode = this.to.nodes.get(edge.from.id);
89
- const toEdge = toNode?.edgesOut.get(edge.spec.name);
90
- if (toEdge?.to?.id === edge.to?.id)
91
- continue;
92
- if (edge.to)
93
- this.edges.delete.add(edge);
94
- if (toEdge?.to)
95
- this.edges.add.add(toEdge);
96
- }
97
- }
98
- [kCustomInspect](_, options) {
99
- const red = options?.colors ? ['\x1b[31m', '\x1b[m'] : ['', ''];
100
- const green = options?.colors ? ['\x1b[32m', '\x1b[m'] : ['', ''];
101
- const lines = [];
102
- for (const node of this.nodes.add) {
103
- lines.push(`+ ${node.id}`);
104
- }
105
- for (const node of this.nodes.delete) {
106
- lines.push(`- ${node.id}`);
107
- }
108
- for (const edge of this.edges.add) {
109
- /* c8 ignore next */
110
- const to = edge.to?.id ?? '';
111
- lines.push(`+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim());
112
- }
113
- for (const edge of this.edges.delete) {
114
- /* c8 ignore next */
115
- const to = edge.to?.id ?? '';
116
- lines.push(`- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim());
117
- }
118
- const wrap = (s, c) => c.join(s);
119
- const color = options?.colors ?
120
- (s) => wrap(s, s.startsWith('+') ? green : red)
121
- : (s) => s;
122
- return `${this[Symbol.toStringTag]} {
123
- ${lines
124
- .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))
125
- .map(s => ' ' + color(s))
126
- .join('\n')}
127
- }`;
128
- }
129
- hasChanges() {
130
- return (this.nodes.add.size > 0 ||
131
- this.nodes.delete.size > 0 ||
132
- this.edges.add.size > 0 ||
133
- this.edges.delete.size > 0);
134
- }
135
- toJSON() {
136
- return {
137
- nodes: {
138
- add: [...this.nodes.add].map(node => node.toJSON()),
139
- delete: [...this.nodes.delete].map(node => node.toJSON()),
140
- },
141
- edges: {
142
- add: [...this.edges.add].map(edge => edge.toJSON()),
143
- delete: [...this.edges.delete].map(edge => edge.toJSON()),
144
- },
145
- };
146
- }
147
- }
148
- //# sourceMappingURL=diff.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAM3C,uDAAuD;AACvD,6EAA6E;AAC7E,4BAA4B;AAC5B,wBAAwB;AAExB,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,MAAM,OAAO,IAAI;IACf,IAAI,CAAO;IACX,EAAE,CAAO;IAET,WAAW,CAAQ;IAEnB;;;OAGG;IACH,mBAAmB,GAAG,KAAK,CAAA;IAE3B;;OAEG;IACH,KAAK,GAAG;QACN,+DAA+D;QAC/D,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,+DAA+D;QAC/D,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,KAAK,GAAG;QACN,qEAAqE;QACrE,GAAG,EAAE,IAAI,GAAG,EAAQ;QACpB,qEAAqE;QACrE,MAAM,EAAE,IAAI,GAAG,EAAQ;KACxB,CAAA;IAED;;OAEG;IACH,YAAY,GAAG,IAAI,CAAA;I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GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;YACD,KAAK,EAAE;gBACL,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnD,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aAC1D;SACF,CAAA;IACH,CAAC;CACF","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport type { InspectOptions } from 'node:util'\nimport type { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport type { Node } from './node.ts'\n\n// XXX should file deps *always* be considered changed?\n// unless the thing containing it wasn't possibly changed because it's inside\n// a dep that didn't change?\n// Same with remote deps\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\n/**\n * A Diff object is a representation of a set of changes from one\n * graph to another, typically from the actual graph as it is reified\n * on disk, to an intended ideal graph.\n *\n * The naming convention can get a bit confusing here, because it's a\n * set of directed changes from one set of directed objects to another.\n *\n * Within the context the Diff object, `from` is the Graph we're coming from,\n * and `to` is the Graph we're trying to create.\n */\nexport class Diff {\n from: Graph\n to: Graph\n\n projectRoot: string\n\n /**\n * If changes need to be made later for failures of optional nodes,\n * set this flag so that we know to call graph.gc() at the appropriate time.\n */\n hadOptionalFailures = false\n\n /**\n * Collection of nodes to add and delete\n */\n nodes = {\n /** Nodes in the `to` graph that are not in the `from` graph */\n add: new Set<Node>(),\n /** Nodes in the `from` graph that are not in the `to` graph */\n delete: new Set<Node>(),\n }\n\n /**\n * Collection of nodes to add and delete\n */\n edges = {\n /** Edges in the `to` graph that are not found in the `from` graph */\n add: new Set<Edge>(),\n /** Edges in the `from` graph that are not found in the `to` graph */\n delete: new Set<Edge>(),\n }\n\n /**\n * True if the diff only contains optional nodes (computed during construction)\n */\n optionalOnly = true\n\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Diff'\n }\n\n constructor(from: Graph, to: Graph) {\n this.from = from\n this.to = to\n this.projectRoot = from.projectRoot\n if (to.projectRoot !== from.projectRoot) {\n throw error('projectRoot mismatch in Graph diff', {\n wanted: from.projectRoot,\n found: to.projectRoot,\n })\n }\n\n for (const [id, node] of this.from.nodes) {\n if (!this.to.nodes.get(id)?.equals(node)) {\n this.nodes.delete.add(node)\n }\n }\n\n for (const [id, node] of this.to.nodes) {\n if (!this.from.nodes.get(id)?.equals(node)) {\n this.nodes.add.add(node)\n if (!node.optional) {\n this.optionalOnly = false\n }\n }\n }\n\n for (const edge of this.to.edges) {\n // the node with this dep, in the from graph\n const fromNode = this.from.nodes.get(edge.from.id)\n const fromEdge = fromNode?.edgesOut.get(edge.spec.name)\n if (fromEdge?.to?.id === edge.to?.id) continue\n if (fromEdge?.to) this.edges.delete.add(fromEdge)\n if (edge.to) this.edges.add.add(edge)\n }\n for (const edge of this.from.edges) {\n // the node with this dep, in the to graph\n const toNode = this.to.nodes.get(edge.from.id)\n const toEdge = toNode?.edgesOut.get(edge.spec.name)\n if (toEdge?.to?.id === edge.to?.id) continue\n if (edge.to) this.edges.delete.add(edge)\n if (toEdge?.to) this.edges.add.add(toEdge)\n }\n }\n\n [kCustomInspect](_: number, options?: InspectOptions): string {\n const red: [string, string] =\n options?.colors ? ['\\x1b[31m', '\\x1b[m'] : ['', '']\n const green: [string, string] =\n options?.colors ? ['\\x1b[32m', '\\x1b[m'] : ['', '']\n const lines: string[] = []\n for (const node of this.nodes.add) {\n lines.push(`+ ${node.id}`)\n }\n for (const node of this.nodes.delete) {\n lines.push(`- ${node.id}`)\n }\n for (const edge of this.edges.add) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `+ ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n for (const edge of this.edges.delete) {\n /* c8 ignore next */\n const to = edge.to?.id ?? ''\n lines.push(\n `- ${edge.from.id} ${edge.type} ${edge.spec} ${to}`.trim(),\n )\n }\n const wrap = (s: string, c: [string, string]) => c.join(s)\n const color =\n options?.colors ?\n (s: string) => wrap(s, s.startsWith('+') ? green : red)\n : (s: string) => s\n\n return `${this[Symbol.toStringTag]} {\n${lines\n .sort((a, b) => a.substring(1).localeCompare(b.substring(1), 'en'))\n .map(s => ' ' + color(s))\n .join('\\n')}\n}`\n }\n\n hasChanges(): boolean {\n return (\n this.nodes.add.size > 0 ||\n this.nodes.delete.size > 0 ||\n this.edges.add.size > 0 ||\n this.edges.delete.size > 0\n )\n }\n\n toJSON() {\n return {\n nodes: {\n add: [...this.nodes.add].map(node => node.toJSON()),\n delete: [...this.nodes.delete].map(node => node.toJSON()),\n },\n edges: {\n add: [...this.edges.add].map(edge => edge.toJSON()),\n delete: [...this.edges.delete].map(edge => edge.toJSON()),\n },\n }\n }\n}\n"]}
@@ -1,46 +0,0 @@
1
- import type { Spec } from '@vltpkg/spec';
2
- import type { InspectOptions } from 'node:util';
3
- import type { DependencyTypeShort, EdgeLike } from '@vltpkg/types';
4
- import type { Node } from './node.ts';
5
- declare const kCustomInspect: unique symbol;
6
- export declare class Edge implements EdgeLike {
7
- get [Symbol.toStringTag](): string;
8
- [kCustomInspect](_: number, options: InspectOptions): string;
9
- /**
10
- * The Node this Edge is connecting from, this is usually the dependent.
11
- */
12
- from: Node;
13
- /**
14
- * The node this Edge is connecting to, this is usually a direct dependency.
15
- */
16
- to?: Node;
17
- /**
18
- * What type of dependency relationship `from` and `to` nodes have.
19
- */
20
- type: DependencyTypeShort;
21
- /**
22
- * The defined spec value for `to` as parsed from the dependent metadata.
23
- */
24
- spec: Spec;
25
- constructor(type: DependencyTypeShort, spec: Spec, from: Node, to?: Node);
26
- /**
27
- * The name of the dependency `to` as defined in the dependent metadata.
28
- */
29
- get name(): string;
30
- /**
31
- * This edge was defined as part of a `devDependencies` in `package.json`
32
- */
33
- get dev(): boolean;
34
- get optional(): boolean;
35
- get peer(): boolean;
36
- get peerOptional(): boolean;
37
- valid(): boolean;
38
- toJSON(): {
39
- from: import("@vltpkg/dep-id").DepID;
40
- to: import("@vltpkg/dep-id").DepID | undefined;
41
- type: DependencyTypeShort;
42
- spec: string;
43
- };
44
- }
45
- export {};
46
- //# sourceMappingURL=edge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAClE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC,QAAA,MAAM,cAAc,eAA2C,CAAA;AAE/D,qBAAa,IAAK,YAAW,QAAQ;IACnC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,WAEvB;IAED,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc;IAanD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IAEV;;OAEG;IACH,EAAE,CAAC,EAAE,IAAI,CAAA;IAET;;OAEG;IACH,IAAI,EAAE,mBAAmB,CAAA;IAEzB;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;gBAGR,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,EAAE,CAAC,EAAE,IAAI;IAQX;;OAEG;IACH,IAAI,IAAI,WAEP;IAED;;OAEG;IACH,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED,IAAI,IAAI,IAAI,OAAO,CAElB;IAED,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,KAAK,IAAI,OAAO;IAWhB,MAAM;;;;;;CAQP"}
package/dist/esm/edge.js DELETED
@@ -1,74 +0,0 @@
1
- import { satisfies } from '@vltpkg/satisfies';
2
- import { inspect } from 'node:util';
3
- const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
4
- export class Edge {
5
- get [Symbol.toStringTag]() {
6
- return '@vltpkg/graph.Edge';
7
- }
8
- [kCustomInspect](_, options) {
9
- const str = inspect({
10
- from: this.from.id,
11
- type: this.type,
12
- spec: String(this.spec),
13
- to: this.to?.id,
14
- }, options);
15
- return `${this[Symbol.toStringTag]} ${str}`;
16
- }
17
- /**
18
- * The Node this Edge is connecting from, this is usually the dependent.
19
- */
20
- from;
21
- /**
22
- * The node this Edge is connecting to, this is usually a direct dependency.
23
- */
24
- to;
25
- /**
26
- * What type of dependency relationship `from` and `to` nodes have.
27
- */
28
- type;
29
- /**
30
- * The defined spec value for `to` as parsed from the dependent metadata.
31
- */
32
- spec;
33
- constructor(type, spec, from, to) {
34
- this.from = from;
35
- this.to = to;
36
- this.type = type;
37
- this.spec = spec;
38
- }
39
- /**
40
- * The name of the dependency `to` as defined in the dependent metadata.
41
- */
42
- get name() {
43
- return this.spec.name;
44
- }
45
- /**
46
- * This edge was defined as part of a `devDependencies` in `package.json`
47
- */
48
- get dev() {
49
- return this.type === 'dev';
50
- }
51
- get optional() {
52
- return this.type === 'peerOptional' || this.type === 'optional';
53
- }
54
- get peer() {
55
- return this.type === 'peer' || this.type === 'peerOptional';
56
- }
57
- get peerOptional() {
58
- return this.type === 'peerOptional';
59
- }
60
- valid() {
61
- return !this.to ?
62
- this.optional
63
- : satisfies(this.to.id, this.spec, this.from.location, this.from.projectRoot);
64
- }
65
- toJSON() {
66
- return {
67
- from: this.from.id,
68
- to: this.to?.id,
69
- type: this.type,
70
- spec: String(this.spec),
71
- };
72
- }
73
- }
74
- //# sourceMappingURL=edge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge.js","sourceRoot":"","sources":["../../src/edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAE7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAE/D,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,CAAC,cAAc,CAAC,CAAC,CAAS,EAAE,OAAuB;QACjD,MAAM,GAAG,GAAG,OAAO,CACjB;YACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACvB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;SAChB,EACD,OAAO,CACR,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,EAAE,CAAA;IAC7C,CAAC;IAED;;OAEG;IACH,IAAI,CAAM;IAEV;;OAEG;IACH,EAAE,CAAO;IAET;;OAEG;IACH,IAAI,CAAqB;IAEzB;;OAEG;IACH,IAAI,CAAM;IAEV,YACE,IAAyB,EACzB,IAAU,EACV,IAAU,EACV,EAAS;QAET,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,KAAK,CAAA;IAC5B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,CAAA;IACjE,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IAC7D,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAA;IACrC,CAAC;IAED,KAAK;QACH,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACb,IAAI,CAAC,QAAQ;YACf,CAAC,CAAC,SAAS,CACP,IAAI,CAAC,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAClB,IAAI,CAAC,IAAI,CAAC,WAAW,CACtB,CAAA;IACP,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;YAClB,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,CAAA;IACH,CAAC;CACF","sourcesContent":["import { satisfies } from '@vltpkg/satisfies'\nimport type { Spec } from '@vltpkg/spec'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { DependencyTypeShort, EdgeLike } from '@vltpkg/types'\nimport type { Node } from './node.ts'\n\nconst kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport class Edge implements EdgeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Edge'\n }\n\n [kCustomInspect](_: number, options: InspectOptions) {\n const str = inspect(\n {\n from: this.from.id,\n type: this.type,\n spec: String(this.spec),\n to: this.to?.id,\n },\n options,\n )\n return `${this[Symbol.toStringTag]} ${str}`\n }\n\n /**\n * The Node this Edge is connecting from, this is usually the dependent.\n */\n from: Node\n\n /**\n * The node this Edge is connecting to, this is usually a direct dependency.\n */\n to?: Node\n\n /**\n * What type of dependency relationship `from` and `to` nodes have.\n */\n type: DependencyTypeShort\n\n /**\n * The defined spec value for `to` as parsed from the dependent metadata.\n */\n spec: Spec\n\n constructor(\n type: DependencyTypeShort,\n spec: Spec,\n from: Node,\n to?: Node,\n ) {\n this.from = from\n this.to = to\n this.type = type\n this.spec = spec\n }\n\n /**\n * The name of the dependency `to` as defined in the dependent metadata.\n */\n get name() {\n return this.spec.name\n }\n\n /**\n * This edge was defined as part of a `devDependencies` in `package.json`\n */\n get dev(): boolean {\n return this.type === 'dev'\n }\n\n get optional(): boolean {\n return this.type === 'peerOptional' || this.type === 'optional'\n }\n\n get peer(): boolean {\n return this.type === 'peer' || this.type === 'peerOptional'\n }\n\n get peerOptional(): boolean {\n return this.type === 'peerOptional'\n }\n\n valid(): boolean {\n return !this.to ?\n this.optional\n : satisfies(\n this.to.id,\n this.spec,\n this.from.location,\n this.from.projectRoot,\n )\n }\n\n toJSON() {\n return {\n from: this.from.id,\n to: this.to?.id,\n type: this.type,\n spec: String(this.spec),\n }\n }\n}\n"]}