@vltpkg/graph 0.0.0-30 → 0.0.0-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/actual/load.d.ts +5 -0
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +1 -0
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/build.d.ts +29 -0
- package/dist/esm/build.d.ts.map +1 -0
- package/dist/esm/build.js +79 -0
- package/dist/esm/build.js.map +1 -0
- package/dist/esm/diff.d.ts +62 -0
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js +12 -0
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +6 -0
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js +8 -0
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/ideal/add-nodes.d.ts +12 -2
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/add-nodes.js +8 -2
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +3 -1
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +24 -3
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +5 -0
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +2 -1
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +7 -0
- package/dist/esm/install.d.ts.map +1 -1
- package/dist/esm/install.js +26 -2
- package/dist/esm/install.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +6 -2
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +3 -1
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +6 -2
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +16 -5
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +17 -1
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js +31 -0
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/node.d.ts +19 -1
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +17 -0
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +4 -29
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/build.d.ts +10 -1
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +30 -4
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/check-needed-build.d.ts +25 -0
- package/dist/esm/reify/check-needed-build.d.ts.map +1 -0
- package/dist/esm/reify/check-needed-build.js +50 -0
- package/dist/esm/reify/check-needed-build.js.map +1 -0
- package/dist/esm/reify/extract-node.d.ts +24 -0
- package/dist/esm/reify/extract-node.d.ts.map +1 -0
- package/dist/esm/reify/extract-node.js +76 -0
- package/dist/esm/reify/extract-node.js.map +1 -0
- package/dist/esm/reify/index.d.ts +16 -1
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +59 -12
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/transfer-data/load.d.ts.map +1 -1
- package/dist/esm/transfer-data/load.js.map +1 -1
- package/dist/esm/uninstall.d.ts +5 -1
- package/dist/esm/uninstall.d.ts.map +1 -1
- package/dist/esm/uninstall.js +51 -19
- package/dist/esm/uninstall.js.map +1 -1
- package/dist/esm/update.d.ts +2 -0
- package/dist/esm/update.d.ts.map +1 -1
- package/dist/esm/update.js +36 -22
- package/dist/esm/update.js.map +1 -1
- package/dist/esm/virtual-root.d.ts.map +1 -1
- package/dist/esm/virtual-root.js +1 -0
- package/dist/esm/virtual-root.js.map +1 -1
- package/package.json +21 -20
|
@@ -2,8 +2,8 @@ import { expandNormalizedManifestSymbols, isRecordStringString, } from '@vltpkg/
|
|
|
2
2
|
import { defaultGitHostArchives, defaultGitHosts, defaultJsrRegistries, defaultRegistries, defaultRegistry, defaultScopeRegistries, } from '@vltpkg/spec';
|
|
3
3
|
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
|
-
import { getFlagNumFromNode } from "./types.js";
|
|
6
|
-
const formatNodes = (nodes, saveManifests, registry) => {
|
|
5
|
+
import { getFlagNumFromNode, getBuildStateFromNode } from "./types.js";
|
|
6
|
+
const formatNodes = (nodes, saveManifests, saveBuildData, registry) => {
|
|
7
7
|
// we do not store importers in the lockfile, though we do store
|
|
8
8
|
// their edges. when we load, we always read workspaces/main fresh.
|
|
9
9
|
const arr = [...nodes].filter(node => !node.importer);
|
|
@@ -38,6 +38,13 @@ const formatNodes = (nodes, saveManifests, registry) => {
|
|
|
38
38
|
if (node.optional && node.platform) {
|
|
39
39
|
lockfileNode[7] = node.platform;
|
|
40
40
|
}
|
|
41
|
+
// Save build state data if requested
|
|
42
|
+
if (saveBuildData) {
|
|
43
|
+
const buildState = getBuildStateFromNode(node);
|
|
44
|
+
if (buildState !== undefined) {
|
|
45
|
+
lockfileNode[8] = buildState;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
41
48
|
res[node.id] = lockfileNode;
|
|
42
49
|
}
|
|
43
50
|
return res;
|
|
@@ -64,7 +71,7 @@ const removeDefaultItems = (defaultItems, items) => {
|
|
|
64
71
|
}
|
|
65
72
|
return res;
|
|
66
73
|
};
|
|
67
|
-
export const lockfileData = ({ graph, catalog, catalogs, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, modifiers, registry, registries, saveManifests, 'scope-registries': scopeRegistries, 'jsr-registries': jsrRegistries, }) => {
|
|
74
|
+
export const lockfileData = ({ graph, catalog, catalogs, 'git-hosts': gitHosts, 'git-host-archives': gitHostArchives, modifiers, registry, registries, saveManifests, saveBuildData, 'scope-registries': scopeRegistries, 'jsr-registries': jsrRegistries, }) => {
|
|
68
75
|
const cleanGitHosts = isRecordStringString(gitHosts) ?
|
|
69
76
|
removeDefaultItems(defaultGitHosts, gitHosts)
|
|
70
77
|
: undefined;
|
|
@@ -111,7 +118,7 @@ export const lockfileData = ({ graph, catalog, catalogs, 'git-hosts': gitHosts,
|
|
|
111
118
|
{ 'git-host-archives': cleanGitHostArchives }
|
|
112
119
|
: undefined),
|
|
113
120
|
},
|
|
114
|
-
nodes: formatNodes(graph.nodes.values(), saveManifests, registry),
|
|
121
|
+
nodes: formatNodes(graph.nodes.values(), saveManifests, saveBuildData, registry),
|
|
115
122
|
edges: formatEdges(graph.edges),
|
|
116
123
|
};
|
|
117
124
|
};
|
|
@@ -138,7 +145,11 @@ export const save = (options) => {
|
|
|
138
145
|
};
|
|
139
146
|
export const saveHidden = (options) => {
|
|
140
147
|
const { graph } = options;
|
|
141
|
-
const data = lockfileData({
|
|
148
|
+
const data = lockfileData({
|
|
149
|
+
...options,
|
|
150
|
+
saveManifests: true,
|
|
151
|
+
saveBuildData: true,
|
|
152
|
+
});
|
|
142
153
|
const fileName = resolve(graph.projectRoot, 'node_modules/.vlt-lock.json');
|
|
143
154
|
mkdirSync(dirname(fileName), { recursive: true });
|
|
144
155
|
saveData(data, fileName, true);
|
|
@@ -1 +1 @@
|
|
|
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,EAC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AAA;IACzB,MAAM,IAAI,GAAG,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAC9D,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 { getFlagNumFromNode } 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'\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\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n registry?: string,\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 if (resolved) {\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 // 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 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 'scope-registries': scopeRegistries,\n 'jsr-registries': jsrRegistries,\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: 0,\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(registries) ?\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(graph.nodes.values(), saveManifests, registry),\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'>,\n): void => {\n const { graph } = options\n const data = lockfileData({ ...options, saveManifests: true })\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
|
+
{"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,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAmCtE,MAAM,WAAW,GAAG,CAClB,KAAqB,EACrB,aAAuB,EACvB,aAAuB,EACvB,QAAiB,EACjB,EAAE;IACF,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,GAAG,GAAW,CAAC,GA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A;IACF,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 { getFlagNumFromNode, getBuildStateFromNode } 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'\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\nconst formatNodes = (\n nodes: Iterable<Node>,\n saveManifests?: boolean,\n saveBuildData?: boolean,\n registry?: string,\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 if (resolved) {\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 // 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 build state data if requested\n if (saveBuildData) {\n const buildState = getBuildStateFromNode(node)\n if (buildState !== undefined) {\n lockfileNode[8] = 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}: 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: 0,\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(registries) ?\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 ),\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 const data = lockfileData({\n ...options,\n saveManifests: true,\n saveBuildData: true,\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"]}
|
|
@@ -40,6 +40,21 @@ export declare const LockfileNodeFlagDevOptional = 3;
|
|
|
40
40
|
* Bit flags indicating whether a node is optional and/or dev.
|
|
41
41
|
*/
|
|
42
42
|
export type LockfileNodeFlags = 0 | 1 | 2 | 3;
|
|
43
|
+
/**
|
|
44
|
+
* Build state constants for lockfile nodes
|
|
45
|
+
*/
|
|
46
|
+
export declare const BuildStateNone: undefined;
|
|
47
|
+
export declare const BuildStateNeeded = 1;
|
|
48
|
+
export declare const BuildStateBuilt = 2;
|
|
49
|
+
export declare const BuildStateFailed = 3;
|
|
50
|
+
/**
|
|
51
|
+
* Build state for a node - tracks whether it needs building, has been built, or failed
|
|
52
|
+
*/
|
|
53
|
+
export type LockfileBuildState = undefined | 1 | 2 | 3;
|
|
54
|
+
export declare const getBuildStateFromNode: (node: {
|
|
55
|
+
buildState?: "none" | "needed" | "built" | "failed";
|
|
56
|
+
}) => LockfileBuildState;
|
|
57
|
+
export declare const getBuildStateFromNum: (state: LockfileBuildState) => "none" | "needed" | "built" | "failed";
|
|
43
58
|
/**
|
|
44
59
|
* Lockfile representation of a node from the install graph.
|
|
45
60
|
*/
|
|
@@ -51,7 +66,8 @@ export type LockfileNode = [
|
|
|
51
66
|
location?: string | null,
|
|
52
67
|
manifest?: NormalizedManifest | null,
|
|
53
68
|
rawManifest?: NormalizedManifest | null,
|
|
54
|
-
platform?: LockfilePlatform | null
|
|
69
|
+
platform?: LockfilePlatform | null,
|
|
70
|
+
buildState?: LockfileBuildState | null
|
|
55
71
|
];
|
|
56
72
|
/**
|
|
57
73
|
* Lockfile edges are stored as a record object where the key
|
|
@@ -1 +1 @@
|
|
|
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;CACxB,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,MAA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AAM,qBAAqB,SAAU;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAA;CACpD,KAAG,kBAWH,CAAA;AAED,eAAO,MAAM,oBAAoB,UACxB,kBAAkB,KACxB,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,QAWhC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,iBAAiB;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IACpB,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IACxB,QAAQ,CAAC,EAAE,kBAAkB,GAAG,IAAI;IACpC,WAAW,CAAC,EAAE,kBAAkB,GAAG,IAAI;IACvC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI;IAClC,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"}
|
|
@@ -10,4 +10,35 @@ export const LockfileNodeFlagNone = 0;
|
|
|
10
10
|
export const LockfileNodeFlagOptional = 1;
|
|
11
11
|
export const LockfileNodeFlagDev = 2;
|
|
12
12
|
export const LockfileNodeFlagDevOptional = 3;
|
|
13
|
+
/**
|
|
14
|
+
* Build state constants for lockfile nodes
|
|
15
|
+
*/
|
|
16
|
+
export const BuildStateNone = undefined;
|
|
17
|
+
export const BuildStateNeeded = 1;
|
|
18
|
+
export const BuildStateBuilt = 2;
|
|
19
|
+
export const BuildStateFailed = 3;
|
|
20
|
+
export const getBuildStateFromNode = (node) => {
|
|
21
|
+
switch (node.buildState) {
|
|
22
|
+
case 'needed':
|
|
23
|
+
return BuildStateNeeded;
|
|
24
|
+
case 'built':
|
|
25
|
+
return BuildStateBuilt;
|
|
26
|
+
case 'failed':
|
|
27
|
+
return BuildStateFailed;
|
|
28
|
+
default:
|
|
29
|
+
return BuildStateNone;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const getBuildStateFromNum = (state) => {
|
|
33
|
+
switch (state) {
|
|
34
|
+
case BuildStateNeeded:
|
|
35
|
+
return 'needed';
|
|
36
|
+
case BuildStateBuilt:
|
|
37
|
+
return 'built';
|
|
38
|
+
case BuildStateFailed:
|
|
39
|
+
return 'failed';
|
|
40
|
+
default:
|
|
41
|
+
return 'none';
|
|
42
|
+
}
|
|
43
|
+
};
|
|
13
44
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lockfile/types.ts"],"names":[],"mappings":"AAkCA,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","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}\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\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 * 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]\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"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lockfile/types.ts"],"names":[],"mappings":"AAkCA,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}\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\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 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"]}
|
package/dist/esm/node.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { DepID } from '@vltpkg/dep-id';
|
|
|
3
3
|
import type { Spec, SpecOptions } from '@vltpkg/spec';
|
|
4
4
|
import type { Integrity, NormalizedManifest, DependencyTypeShort, GraphLike, NodeLike } from '@vltpkg/types';
|
|
5
5
|
import { Edge } from './edge.ts';
|
|
6
|
+
import type { Graph } from './graph.ts';
|
|
6
7
|
export type NodeOptions = SpecOptions & {
|
|
7
8
|
projectRoot: string;
|
|
8
9
|
graph: GraphLike;
|
|
@@ -37,6 +38,10 @@ export declare class Node implements NodeLike {
|
|
|
37
38
|
* True if there's a manifest-confused package name.
|
|
38
39
|
*/
|
|
39
40
|
confused: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* True if this node has been extracted to the file system.
|
|
43
|
+
*/
|
|
44
|
+
extracted: boolean;
|
|
40
45
|
/**
|
|
41
46
|
* List of edges coming into this node.
|
|
42
47
|
*/
|
|
@@ -66,7 +71,7 @@ export declare class Node implements NodeLike {
|
|
|
66
71
|
/**
|
|
67
72
|
* A reference to the graph this node is a part of.
|
|
68
73
|
*/
|
|
69
|
-
graph:
|
|
74
|
+
graph: Graph;
|
|
70
75
|
/**
|
|
71
76
|
* The manifest integrity value.
|
|
72
77
|
*/
|
|
@@ -113,6 +118,18 @@ export declare class Node implements NodeLike {
|
|
|
113
118
|
os?: string[] | string;
|
|
114
119
|
cpu?: string[] | string;
|
|
115
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* True if this node has been built as part of the reify step.
|
|
123
|
+
*/
|
|
124
|
+
built: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Build state of this node - tracks whether it needs building, has been built, or failed.
|
|
127
|
+
* - 'none': No build state (default)
|
|
128
|
+
* - 'needed': Node needs to be built
|
|
129
|
+
* - 'built': Node has been successfully built
|
|
130
|
+
* - 'failed': Node build has failed
|
|
131
|
+
*/
|
|
132
|
+
buildState: 'none' | 'needed' | 'built' | 'failed';
|
|
116
133
|
/**
|
|
117
134
|
* The file system location for this node.
|
|
118
135
|
*/
|
|
@@ -189,6 +206,7 @@ export declare class Node implements NodeLike {
|
|
|
189
206
|
os?: string[] | string;
|
|
190
207
|
cpu?: string[] | string;
|
|
191
208
|
} | undefined;
|
|
209
|
+
buildState: "none" | "needed" | "built" | "failed";
|
|
192
210
|
};
|
|
193
211
|
toString(): string;
|
|
194
212
|
}
|
package/dist/esm/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAO7C,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,QAAQ,EACT,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO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,IAAI,OAAO;IAkBrB,IAAI,OAAO,IAKQ,WAAW,CAH7B;IAGD,IAAI,OAAO,CAAC,KAAK,EAAE,WAAW,EAAI;IAElC,MAAM,CAAC,KAAK,EAAE,IAAI;IAIlB;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,MAAM;IAKpC;;;;OAIG;IACH,WAAW;IAgBX,kBAAkB;IAclB;;OAEG;IACH,UAAU,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI;IAO7D;;;OAGG;IACH,IAAI,WAAW,IAAI,kBAAkB,GAAG,SAAS,CAEhD;IAED;;OAEG;IACH,mBAAmB,CACjB,KAAK,EAAE,kBAAkB,EACzB,QAAQ,CAAC,EAAE,kBAAkB;IAQ/B;;OAEG;IACH,wBAAwB,CACtB,IAAI,EAAE,IAAI,EACV,QAAQ,CAAC,EAAE,kBAAkB;IAa/B,MAAM;;;;;;;;;;;;;;;;sBA1NM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;iBAC3B,MAAM,EAAE,GAAG,MAAM;kBAChB,MAAM,EAAE,GAAG,MAAM;;;;IAiPzB,QAAQ;CAGT;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,KAAK,IAAI,IAQhD,CAAA;AAED,eAAO,MAAM,MAAM,UAAW,OAAO,KAAG,IAKvC,CAAA"}
|
package/dist/esm/node.js
CHANGED
|
@@ -63,6 +63,10 @@ export class Node {
|
|
|
63
63
|
* True if there's a manifest-confused package name.
|
|
64
64
|
*/
|
|
65
65
|
confused = false;
|
|
66
|
+
/**
|
|
67
|
+
* True if this node has been extracted to the file system.
|
|
68
|
+
*/
|
|
69
|
+
extracted = false;
|
|
66
70
|
/**
|
|
67
71
|
* List of edges coming into this node.
|
|
68
72
|
*/
|
|
@@ -147,6 +151,18 @@ export class Node {
|
|
|
147
151
|
* when manifest is not loaded.
|
|
148
152
|
*/
|
|
149
153
|
platform;
|
|
154
|
+
/**
|
|
155
|
+
* True if this node has been built as part of the reify step.
|
|
156
|
+
*/
|
|
157
|
+
built = false;
|
|
158
|
+
/**
|
|
159
|
+
* Build state of this node - tracks whether it needs building, has been built, or failed.
|
|
160
|
+
* - 'none': No build state (default)
|
|
161
|
+
* - 'needed': Node needs to be built
|
|
162
|
+
* - 'built': Node has been successfully built
|
|
163
|
+
* - 'failed': Node build has failed
|
|
164
|
+
*/
|
|
165
|
+
buildState = 'none';
|
|
150
166
|
/**
|
|
151
167
|
* The file system location for this node.
|
|
152
168
|
*/
|
|
@@ -322,6 +338,7 @@ export class Node {
|
|
|
322
338
|
confused: this.confused,
|
|
323
339
|
modifier: this.modifier,
|
|
324
340
|
platform: this.platform,
|
|
341
|
+
buildState: this.buildState,
|
|
325
342
|
...(this.confused ?
|
|
326
343
|
{ rawManifest: this.#rawManifest }
|
|
327
344
|
: undefined),
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAQ/D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AASnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAClB,YAAY,CAAqB;IAEjC,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAA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Ac,EAAiB,EAAE;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,IAAI,IAAI,KAAK;QACb,UAAU,IAAI,KAAK;QAClB,KAAc,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,oBAAoB,CAC7D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: GraphLike\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,EACrB,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C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ChD,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACjB,EAAE,WAAW,EAAE,IAAI,CAAC,YAAY,EAAE;gBACpC,CAAC,CAAC,SAAS,CAAC;SACb,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAiB,EAAE;IACtD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,IAAI,IAAI;QACb,IAAI,IAAI,KAAK;QACb,UAAU,IAAI,KAAK;QAClB,KAAc,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,oBAAoB,CAC7D,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IAC7C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,SAAS,CAAC,iBAAiB,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport {\n isPackageNameConfused,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport type { DepID, DepIDTuple } from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport type { Spec, SpecOptions } from '@vltpkg/spec'\nimport { expandNormalizedManifestSymbols } from '@vltpkg/types'\nimport type {\n Integrity,\n NormalizedManifest,\n DependencyTypeShort,\n GraphLike,\n NodeLike,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { Graph } from './graph.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { GraphModifier } from './modifiers.ts'\n\nexport type NodeOptions = SpecOptions & {\n projectRoot: string\n graph: GraphLike\n}\n\nexport class Node implements NodeLike {\n get [Symbol.toStringTag]() {\n return '@vltpkg/graph.Node'\n }\n\n #options: SpecOptions\n #location?: string\n #rawManifest?: NormalizedManifest\n\n #optional = false\n /**\n * True if a node is only reachable via optional or peerOptional edges from\n * any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any optional-flagged non-optional dependencies.\n */\n get optional() {\n return this.#optional\n }\n set optional(optional: boolean) {\n const before = this.#optional\n this.#optional = optional\n if (before && !optional) {\n // unset for all deps, as well\n for (const { to, optional } of this.edgesOut.values()) {\n if (!optional && to?.optional) to.optional = false\n }\n }\n }\n\n isOptional(): this is Node & { optional: true } {\n return this.#optional\n }\n\n #dev = false\n /**\n * True if a node is only reachable via dev edges from any importer.\n *\n * Setting this to false, if previously set to true, will also unset\n * the flag on any dev-flagged non-dev dependencies.\n */\n get dev() {\n return this.#dev\n }\n set dev(dev: boolean) {\n const before = this.#dev\n this.#dev = dev\n if (before && !dev) {\n // unset for all deps, as well\n for (const { to, dev } of this.edgesOut.values()) {\n if (!dev && to?.dev) to.dev = false\n }\n }\n }\n\n isDev(): this is Node & { dev: true } {\n return this.#dev\n }\n\n /**\n * True if there's a manifest-confused package name.\n */\n confused = false\n\n /**\n * True if this node has been extracted to the file system.\n */\n extracted = false\n\n /**\n * List of edges coming into this node.\n */\n edgesIn = new Set<Edge>()\n\n /**\n * List of edges from this node into other nodes. This usually represents\n * that the connected node is a direct dependency of this node.\n */\n edgesOut = new Map<string, Edge>()\n\n /**\n * A `mainImporter` node may have workspace connected to it,\n * equivalent to its `edgesOut` linked deps.\n */\n workspaces: Map<string, Edge> | undefined\n\n /**\n * A reference to the {@link DepID} this node represents in the graph.\n */\n id: DepID\n\n /**\n * True if this node is an importer node.\n */\n importer = false\n\n /**\n * True if this node is the project root node.\n */\n mainImporter = false\n\n /**\n * A reference to the graph this node is a part of.\n */\n graph: Graph\n\n /**\n * The manifest integrity value.\n */\n integrity?: Integrity\n\n /**\n * The manifest this node represents in the graph.\n */\n manifest?: NormalizedManifest\n\n /**\n * Project where this node resides\n */\n projectRoot: string\n\n /**\n * For registry nodes, this is the registry we fetched them from.\n * Needed because their un-prefixed dependencies need to come from\n * the same registry, if it's not the default.\n */\n registry?: string\n\n /**\n * If this node has been modified as part of applying a {@link GraphModifier}\n * then this field will contain the modifier query that was applied.\n * Otherwise, it will be `undefined`.\n */\n modifier: string | undefined\n\n /**\n * The name of the package represented by this node, this is usually\n * equivalent to `manifest.name` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package names instead.\n */\n #name?: string\n get name() {\n if (this.#name) return this.#name\n this.#name = this.id\n return this.#name\n }\n\n /**\n * The version of the package represented by this node, this is usually\n * equivalent to `manifest.version` but in a few ways it may differ such as\n * nodes loaded from a lockfile that lacks a loaded manifest.\n * This field should be used to retrieve package versions instead.\n */\n version?: string\n\n /**\n * An address {@link PackageInfoClient} may use to extract this package.\n */\n resolved?: string\n\n /**\n * Platform requirements (engines, os, cpu) extracted from manifest.\n * Stored separately for optional dependencies to enable platform checks\n * when manifest is not loaded.\n */\n platform?: {\n engines?: Record<string, string>\n os?: string[] | string\n cpu?: string[] | string\n }\n\n /**\n * True if this node has been built as part of the reify step.\n */\n built = false\n\n /**\n * Build state of this node - tracks whether it needs building, has been built, or failed.\n * - 'none': No build state (default)\n * - 'needed': Node needs to be built\n * - 'built': Node has been successfully built\n * - 'failed': Node build has failed\n */\n buildState: 'none' | 'needed' | 'built' | 'failed' = 'none'\n\n /**\n * The file system location for this node.\n */\n get location(): string {\n if (this.#location) {\n return this.#location\n }\n this.#location = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n // if using the default location, it is in the store\n this.inVltStore = () => true\n return this.#location\n }\n\n set location(location: string) {\n this.#location = location\n // reset memoization, since it might be elsewhere now\n if (this.inVltStore !== Node.prototype.inVltStore) {\n this.inVltStore = Node.prototype.inVltStore\n }\n }\n\n /**\n * The resolved location of the node in the file system.\n */\n resolvedLocation(scurry: PathScurry): string {\n return scurry.cwd.resolve(this.location).fullpath()\n }\n\n /**\n * The location of the node_modules folder where this node's edgesOut\n * should be linked into. For nodes in the store, this is the parent\n * directory, since they're extracted into a node_modules folder\n * side by side with links to their deps. For nodes outside of the store\n * (ie, importers and arbitrary link deps) this is the node_modules folder\n * directly inside the node's directory.\n */\n nodeModules(scurry: PathScurry): string {\n const loc = this.resolvedLocation(scurry)\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : scurry.resolve(loc, 'node_modules')\n }\n\n constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: NormalizedManifest,\n spec?: Spec,\n name?: string,\n version?: string,\n ) {\n this.#options = options\n this.projectRoot = options.projectRoot\n if (id) {\n this.id = id\n } else {\n if (!manifest || !spec) {\n throw typeError(\n 'A new Node needs either a manifest & spec or an id parameter',\n {\n manifest,\n },\n )\n }\n this.id = getId(spec, manifest)\n }\n this.graph = options.graph as Graph\n this.manifest = manifest\n\n this.#name = name || this.manifest?.name\n this.version = version || this.manifest?.version\n }\n\n /**\n * return true if this node is located in the vlt store\n * memoized the first time it's called, since the store location\n * doesn't change within the context of a single operation.\n */\n inVltStore(): boolean {\n // technically this just means it's in *a* vlt store, but we can safely\n // assume that a user won't construct a path like this by accident,\n // and there's only ever one store in any given project.\n const inStore = this.location.endsWith(\n `.vlt/${this.id}/node_modules/${this.name}`,\n )\n this.inVltStore = () => inStore\n return inStore\n }\n\n #registryNodeResolved(tuple: DepIDTuple) {\n const spec = hydrateTuple(tuple, this.#name, this.#options)\n this.resolved =\n this.manifest?.dist?.tarball || spec.conventionalRegistryTarball\n this.integrity ??= this.manifest?.dist?.integrity\n }\n\n get options() {\n return this.#options\n }\n\n /* c8 ignore next */\n set options(_opts: SpecOptions) {}\n\n equals(other: Node) {\n return this.id === other.id && this.location === other.location\n }\n\n /**\n * Sets the node as an importer along with its location.\n */\n setImporterLocation(location: string) {\n this.#location = location\n this.importer = true\n }\n\n /**\n * Sets the appropriate resolve / integrity value for this node.\n * Note that other places might also set these values, like for\n * example the lockfile that might have already have this info.\n */\n setResolved() {\n // file | remote | workspace type of ids all points to a URI that\n // can be used as the `resolved` value, so we split the dep id\n // for these cases.\n const tuple = splitDepID(this.id)\n const [type, resolved] = tuple\n switch (type) {\n case 'registry':\n this.#registryNodeResolved(tuple)\n break\n default:\n this.resolved = resolved\n break\n }\n }\n\n setDefaultLocation() {\n const def = `./node_modules/.vlt/${this.id}/node_modules/${this.name}`\n\n // only relocate if the location is in node_modules already\n if (\n !this.importer &&\n (!this.#location ||\n (this.#location !== def &&\n /^(?:\\.\\/)?node_modules\\//.test(this.#location)))\n ) {\n this.#location = def\n }\n }\n\n /**\n * Add an edge from this node connecting it to a direct dependency.\n */\n addEdgesTo(type: DependencyTypeShort, spec: Spec, node?: Node) {\n const edge = new Edge(type, spec, this, node)\n node?.edgesIn.add(edge)\n this.edgesOut.set(spec.name, edge)\n return edge\n }\n\n /**\n * The raw manifest before any modifications.\n * If not set, falls back to the current manifest.\n */\n get rawManifest(): NormalizedManifest | undefined {\n return this.#rawManifest ?? this.manifest\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n setConfusedManifest(\n fixed: NormalizedManifest,\n confused?: NormalizedManifest,\n ) {\n this.manifest = fixed\n this.#rawManifest = confused\n this.confused = true\n this.#name = this.manifest.name\n }\n\n /**\n * Sets this node as having a manifest-confused manifest.\n */\n maybeSetConfusedManifest(\n spec: Spec,\n confused?: NormalizedManifest,\n ) {\n if (isPackageNameConfused(spec, this.manifest?.name)) {\n this.setConfusedManifest(\n {\n ...this.manifest,\n name: spec.name,\n },\n confused,\n )\n }\n }\n\n toJSON() {\n return {\n id: this.id,\n name: this.name,\n version: this.version,\n location: this.location,\n importer: this.importer,\n manifest:\n this.manifest &&\n expandNormalizedManifestSymbols(this.manifest),\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n confused: this.confused,\n modifier: this.modifier,\n platform: this.platform,\n buildState: this.buildState,\n ...(this.confused ?\n { rawManifest: this.#rawManifest }\n : undefined),\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n\nexport const isNode = (value: unknown): value is Node => {\n return (\n typeof value === 'object' &&\n value != null &&\n 'id' in value &&\n 'manifest' in value &&\n (value as Node)[Symbol.toStringTag] === '@vltpkg/graph.Node'\n )\n}\n\nexport const asNode = (value: unknown): Node => {\n if (!isNode(value)) {\n throw typeError('Expected a node', { found: value })\n }\n return value\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,UACF,UAAU,WACT,cAAc,WACd,WAAW,eACP,iBAAiB,KAC7B,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAgB1B,CAAA"}
|
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { platformCheck } from '@vltpkg/pick-manifest';
|
|
3
|
-
import { optionalFail } from "./optional-fail.js";
|
|
1
|
+
import { extractNode } from "./extract-node.js";
|
|
4
2
|
export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
5
3
|
const actions = [];
|
|
6
4
|
// fetch and extract all the nodes, removing any in the way
|
|
7
5
|
for (const node of diff.nodes.add) {
|
|
8
|
-
/* c8 ignore next - all nodes have manifests by this point */
|
|
9
|
-
const { manifest = {} } = node;
|
|
10
6
|
// if it's not in the store, we don't have to extract it, because
|
|
11
7
|
// we're just linking to a location that already exists.
|
|
12
8
|
if (!node.inVltStore())
|
|
13
9
|
continue;
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
const from = scurry.resolve('');
|
|
17
|
-
const spec = hydrate(node.id, node.name, options);
|
|
18
|
-
const onErr = optionalFail(diff, node);
|
|
19
|
-
const { integrity, resolved } = node;
|
|
20
|
-
// if it's optional, and we know it isn't for this platform, or it's
|
|
21
|
-
// deprecated, don't install it. if it's not optional, try our best.
|
|
22
|
-
// Use platform data from node if available (from lockfile), otherwise fall back to manifest
|
|
23
|
-
const platformData = node.platform ?? manifest;
|
|
24
|
-
if (onErr &&
|
|
25
|
-
(manifest.deprecated ||
|
|
26
|
-
!platformCheck(platformData, process.version, process.platform, process.arch))) {
|
|
27
|
-
onErr();
|
|
10
|
+
// skip nodes that have already been extracted
|
|
11
|
+
if (node.extracted)
|
|
28
12
|
continue;
|
|
29
|
-
|
|
30
|
-
actions.push(() => remover.rm(target).then(() => onErr ?
|
|
31
|
-
packageInfo
|
|
32
|
-
.extract(spec, target, { from, integrity, resolved })
|
|
33
|
-
.then(x => x, onErr)
|
|
34
|
-
: packageInfo.extract(spec, target, {
|
|
35
|
-
from,
|
|
36
|
-
integrity,
|
|
37
|
-
resolved,
|
|
38
|
-
})));
|
|
13
|
+
actions.push(() => extractNode(node, scurry, remover, options, packageInfo, diff));
|
|
39
14
|
}
|
|
40
15
|
return actions;
|
|
41
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,MAAkB,EAClB,OAAuB,EACvB,OAAoB,EACpB,WAA8B,EACF,EAAE;IAC9B,MAAM,OAAO,GAA+B,EAAE,CAAA;IAC9C,2DAA2D;IAC3D,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,iEAAiE;QACjE,wDAAwD;QACxD,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,SAAQ;QAEhC,8CAA8C;QAC9C,IAAI,IAAI,CAAC,SAAS;YAAE,SAAQ;QAE5B,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAC/D,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import type { PackageInfoClient } from '@vltpkg/package-info'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { SpecOptions } from '@vltpkg/spec'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { extractNode } from './extract-node.ts'\n\nexport const addNodes = (\n diff: Diff,\n scurry: PathScurry,\n remover: RollbackRemove,\n options: SpecOptions,\n packageInfo: PackageInfoClient,\n): (() => Promise<unknown>)[] => {\n const actions: (() => Promise<unknown>)[] = []\n // fetch and extract all the nodes, removing any in the way\n for (const node of diff.nodes.add) {\n // if it's not in the store, we don't have to extract it, because\n // we're just linking to a location that already exists.\n if (!node.inVltStore()) continue\n\n // skip nodes that have already been extracted\n if (node.extracted) continue\n\n actions.push(() =>\n extractNode(node, scurry, remover, options, packageInfo, diff),\n )\n }\n return actions\n}\n"]}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
2
|
import type { PathScurry } from 'path-scurry';
|
|
3
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
3
4
|
import type { Diff } from '../diff.ts';
|
|
4
|
-
|
|
5
|
+
import type { Node } from '../node.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Returns an object mapping registries to the names of the packages built.
|
|
8
|
+
*/
|
|
9
|
+
export type BuildResult = {
|
|
10
|
+
success: Node[];
|
|
11
|
+
failure: Node[];
|
|
12
|
+
};
|
|
13
|
+
export declare const build: (diff: Diff, packageJson: PackageJson, scurry: PathScurry, allowScriptsNodes: Set<DepID>) => Promise<BuildResult>;
|
|
5
14
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAKvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAKtC;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,IAAI,EAAE,CAAA;IACf,OAAO,EAAE,IAAI,EAAE,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,KAAK,SACV,IAAI,eACG,WAAW,UAChB,UAAU,qBACC,GAAG,CAAC,KAAK,CAAC,KAC5B,OAAO,CAAC,WAAW,CA6DrB,CAAA"}
|
package/dist/esm/reify/build.js
CHANGED
|
@@ -8,12 +8,15 @@ import { graphRun } from 'graph-run';
|
|
|
8
8
|
import { nonEmptyList } from "../non-empty-list.js";
|
|
9
9
|
import { binPaths } from "./bin-paths.js";
|
|
10
10
|
import { optionalFail } from "./optional-fail.js";
|
|
11
|
-
export const build = async (diff, packageJson, scurry) => {
|
|
11
|
+
export const build = async (diff, packageJson, scurry, allowScriptsNodes) => {
|
|
12
12
|
const graph = diff.to;
|
|
13
13
|
const nodes = nonEmptyList([...graph.importers]);
|
|
14
|
+
const res = { success: [], failure: [] };
|
|
15
|
+
// determine if scripts should run - check if node is in allowed set
|
|
16
|
+
const shouldRunScripts = (node) => allowScriptsNodes.has(node.id);
|
|
14
17
|
/* c8 ignore next - all graphs have at least one importer */
|
|
15
18
|
if (!nodes)
|
|
16
|
-
return;
|
|
19
|
+
return res;
|
|
17
20
|
await graphRun({
|
|
18
21
|
graph: nodes,
|
|
19
22
|
visit: async (node, signal, path) => {
|
|
@@ -23,9 +26,31 @@ export const build = async (diff, packageJson, scurry) => {
|
|
|
23
26
|
// most recent build.
|
|
24
27
|
// For now, just always build all importers, because we don't
|
|
25
28
|
// track all that other stuff.
|
|
26
|
-
if (!node.importer &&
|
|
29
|
+
if (!node.importer &&
|
|
30
|
+
(!diff.nodes.add.has(node) || !shouldRunScripts(node)))
|
|
27
31
|
return;
|
|
28
|
-
|
|
32
|
+
try {
|
|
33
|
+
await visit(packageJson, scurry, node, signal, path);
|
|
34
|
+
if (!node.importer) {
|
|
35
|
+
node.buildState = 'built';
|
|
36
|
+
res.success.push(node);
|
|
37
|
+
}
|
|
38
|
+
/* c8 ignore start - windows on CI is missing those tests */
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
// Check if this is an optional failure that was handled
|
|
42
|
+
if (node.optional) {
|
|
43
|
+
node.buildState = 'failed';
|
|
44
|
+
res.failure.push(node);
|
|
45
|
+
// Let optionalFail handle the error
|
|
46
|
+
await Promise.reject(err).catch(optionalFail(diff, node));
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Re-throw non-optional failures
|
|
50
|
+
throw err;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/* c8 ignore stop */
|
|
29
54
|
},
|
|
30
55
|
getDeps: node => {
|
|
31
56
|
const deps = [];
|
|
@@ -37,6 +62,7 @@ export const build = async (diff, packageJson, scurry) => {
|
|
|
37
62
|
return deps;
|
|
38
63
|
},
|
|
39
64
|
});
|
|
65
|
+
return res;
|
|
40
66
|
};
|
|
41
67
|
const visit = async (packageJson, scurry, node, signal, _path) => {
|
|
42
68
|
node.manifest ??= packageJson.read(node.resolvedLocation(scurry));
|