@vltpkg/graph 0.0.0-0.1730724342581 → 0.0.0-3
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 +6 -6
- package/dist/esm/actual/load.d.ts.map +1 -1
- package/dist/esm/actual/load.js +8 -4
- package/dist/esm/actual/load.js.map +1 -1
- package/dist/esm/browser.d.ts +8 -6
- package/dist/esm/browser.d.ts.map +1 -1
- package/dist/esm/browser.js +8 -6
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/dependencies.d.ts +15 -27
- package/dist/esm/dependencies.d.ts.map +1 -1
- package/dist/esm/dependencies.js +1 -30
- package/dist/esm/dependencies.js.map +1 -1
- package/dist/esm/diff.d.ts +4 -4
- package/dist/esm/diff.d.ts.map +1 -1
- package/dist/esm/diff.js.map +1 -1
- package/dist/esm/edge.d.ts +5 -5
- package/dist/esm/edge.d.ts.map +1 -1
- package/dist/esm/edge.js.map +1 -1
- package/dist/esm/graph.d.ts +10 -10
- package/dist/esm/graph.d.ts.map +1 -1
- package/dist/esm/graph.js +4 -3
- package/dist/esm/graph.js.map +1 -1
- package/dist/esm/ideal/add-nodes.d.ts +4 -4
- package/dist/esm/ideal/add-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/add-nodes.js +2 -2
- package/dist/esm/ideal/add-nodes.js.map +1 -1
- package/dist/esm/ideal/append-nodes.d.ts +8 -8
- package/dist/esm/ideal/append-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/append-nodes.js +37 -15
- package/dist/esm/ideal/append-nodes.js.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts +3 -3
- package/dist/esm/ideal/build-ideal-from-starting-graph.d.ts.map +1 -1
- package/dist/esm/ideal/build-ideal-from-starting-graph.js +28 -5
- package/dist/esm/ideal/build-ideal-from-starting-graph.js.map +1 -1
- package/dist/esm/ideal/build.d.ts +4 -4
- package/dist/esm/ideal/build.d.ts.map +1 -1
- package/dist/esm/ideal/build.js +8 -4
- package/dist/esm/ideal/build.js.map +1 -1
- package/dist/esm/ideal/get-importer-specs.d.ts +2 -2
- package/dist/esm/ideal/get-importer-specs.d.ts.map +1 -1
- package/dist/esm/ideal/get-importer-specs.js +39 -11
- package/dist/esm/ideal/get-importer-specs.js.map +1 -1
- package/dist/esm/ideal/remove-nodes.d.ts +1 -1
- package/dist/esm/ideal/remove-nodes.d.ts.map +1 -1
- package/dist/esm/ideal/remove-nodes.js.map +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.d.ts +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.d.ts.map +1 -1
- package/dist/esm/ideal/remove-satisfied-specs.js.map +1 -1
- package/dist/esm/ideal/types.d.ts +3 -3
- package/dist/esm/ideal/types.d.ts.map +1 -1
- package/dist/esm/ideal/types.js.map +1 -1
- package/dist/esm/index.d.ts +25 -22
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install.d.ts +13 -0
- package/dist/esm/install.d.ts.map +1 -0
- package/dist/esm/install.js +29 -0
- package/dist/esm/install.js.map +1 -0
- package/dist/esm/lockfile/load-edges.d.ts +3 -3
- package/dist/esm/lockfile/load-edges.d.ts.map +1 -1
- package/dist/esm/lockfile/load-edges.js +2 -1
- package/dist/esm/lockfile/load-edges.js.map +1 -1
- package/dist/esm/lockfile/load-nodes.d.ts +2 -2
- package/dist/esm/lockfile/load-nodes.d.ts.map +1 -1
- package/dist/esm/lockfile/load-nodes.js +3 -1
- package/dist/esm/lockfile/load-nodes.js.map +1 -1
- package/dist/esm/lockfile/load.d.ts +5 -5
- package/dist/esm/lockfile/load.d.ts.map +1 -1
- package/dist/esm/lockfile/load.js +6 -4
- package/dist/esm/lockfile/load.js.map +1 -1
- package/dist/esm/lockfile/save.d.ts +3 -3
- package/dist/esm/lockfile/save.d.ts.map +1 -1
- package/dist/esm/lockfile/save.js +1 -1
- package/dist/esm/lockfile/save.js.map +1 -1
- package/dist/esm/lockfile/types.d.ts +3 -4
- package/dist/esm/lockfile/types.d.ts.map +1 -1
- package/dist/esm/lockfile/types.js.map +1 -1
- package/dist/esm/node.d.ts +19 -15
- package/dist/esm/node.d.ts.map +1 -1
- package/dist/esm/node.js +23 -17
- package/dist/esm/node.js.map +1 -1
- package/dist/esm/reify/add-edge.d.ts +4 -4
- package/dist/esm/reify/add-edge.d.ts.map +1 -1
- package/dist/esm/reify/add-edge.js +4 -4
- package/dist/esm/reify/add-edge.js.map +1 -1
- package/dist/esm/reify/add-edges.d.ts +4 -4
- package/dist/esm/reify/add-edges.d.ts.map +1 -1
- package/dist/esm/reify/add-edges.js +2 -2
- package/dist/esm/reify/add-edges.js.map +1 -1
- package/dist/esm/reify/add-nodes.d.ts +5 -5
- package/dist/esm/reify/add-nodes.d.ts.map +1 -1
- package/dist/esm/reify/add-nodes.js +10 -7
- package/dist/esm/reify/add-nodes.js.map +1 -1
- package/dist/esm/reify/bin-paths.d.ts +1 -1
- package/dist/esm/reify/bin-paths.d.ts.map +1 -1
- package/dist/esm/reify/bin-paths.js.map +1 -1
- package/dist/esm/reify/build.d.ts +3 -3
- package/dist/esm/reify/build.d.ts.map +1 -1
- package/dist/esm/reify/build.js +7 -7
- package/dist/esm/reify/build.js.map +1 -1
- package/dist/esm/reify/delete-edge.d.ts +3 -3
- package/dist/esm/reify/delete-edge.d.ts.map +1 -1
- package/dist/esm/reify/delete-edge.js +2 -2
- package/dist/esm/reify/delete-edge.js.map +1 -1
- package/dist/esm/reify/delete-edges.d.ts +3 -3
- package/dist/esm/reify/delete-edges.d.ts.map +1 -1
- package/dist/esm/reify/delete-edges.js +1 -1
- package/dist/esm/reify/delete-edges.js.map +1 -1
- package/dist/esm/reify/delete-nodes.d.ts +3 -3
- package/dist/esm/reify/delete-nodes.d.ts.map +1 -1
- package/dist/esm/reify/delete-nodes.js.map +1 -1
- package/dist/esm/reify/index.d.ts +6 -5
- package/dist/esm/reify/index.d.ts.map +1 -1
- package/dist/esm/reify/index.js +25 -19
- package/dist/esm/reify/index.js.map +1 -1
- package/dist/esm/reify/optional-fail.d.ts +2 -2
- package/dist/esm/reify/optional-fail.d.ts.map +1 -1
- package/dist/esm/reify/optional-fail.js +1 -1
- package/dist/esm/reify/optional-fail.js.map +1 -1
- package/dist/esm/reify/rollback.d.ts +2 -2
- package/dist/esm/reify/rollback.d.ts.map +1 -1
- package/dist/esm/reify/rollback.js +1 -1
- package/dist/esm/reify/rollback.js.map +1 -1
- package/dist/esm/reify/update-importers-package-json.d.ts +3 -3
- package/dist/esm/reify/update-importers-package-json.d.ts.map +1 -1
- package/dist/esm/reify/update-importers-package-json.js +5 -3
- package/dist/esm/reify/update-importers-package-json.js.map +1 -1
- package/dist/esm/remove-optional-subgraph.d.ts +2 -2
- package/dist/esm/remove-optional-subgraph.d.ts.map +1 -1
- package/dist/esm/remove-optional-subgraph.js.map +1 -1
- package/dist/esm/stringify-node.d.ts +1 -1
- package/dist/esm/stringify-node.d.ts.map +1 -1
- package/dist/esm/stringify-node.js.map +1 -1
- package/dist/esm/types.d.ts +5 -4
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/uninstall.d.ts +13 -0
- package/dist/esm/uninstall.d.ts.map +1 -0
- package/dist/esm/uninstall.js +29 -0
- package/dist/esm/uninstall.js.map +1 -0
- package/dist/esm/visualization/human-readable-output.d.ts +7 -6
- package/dist/esm/visualization/human-readable-output.d.ts.map +1 -1
- package/dist/esm/visualization/human-readable-output.js +2 -2
- package/dist/esm/visualization/human-readable-output.js.map +1 -1
- package/dist/esm/visualization/json-output.d.ts +4 -4
- package/dist/esm/visualization/json-output.d.ts.map +1 -1
- package/dist/esm/visualization/json-output.js +1 -1
- package/dist/esm/visualization/json-output.js.map +1 -1
- package/dist/esm/visualization/mermaid-output.d.ts +3 -3
- package/dist/esm/visualization/mermaid-output.d.ts.map +1 -1
- package/dist/esm/visualization/mermaid-output.js +2 -2
- package/dist/esm/visualization/mermaid-output.js.map +1 -1
- package/dist/esm/visualization/object-like-output.d.ts +1 -1
- package/dist/esm/visualization/object-like-output.d.ts.map +1 -1
- package/dist/esm/visualization/object-like-output.js.map +1 -1
- package/package.json +34 -26
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { type DependencyTypeShort } from '../dependencies.js';
|
|
1
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
2
|
+
import type { Spec, SpecOptions } from '@vltpkg/spec';
|
|
3
|
+
import type { Integrity, Manifest, DependencyTypeShort } from '@vltpkg/types';
|
|
5
4
|
/**
|
|
6
5
|
* This is the main type definition for the contents of the
|
|
7
6
|
* `vlt-lock.json` file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lockfile/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
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,QAAQ,EACR,mBAAmB,EACpB,MAAM,eAAe,CAAA;AAGtB;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,WAAW,CAAA;IACpB,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAA;IAClC,KAAK,EAAE,aAAa,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,GAAG,CAAC,EAAE,OAAO,CAAA;CACd,kBAIuB,CAAA;AAExB,eAAO,MAAM,sBAAsB,UAAW,iBAAiB;;;CAG7D,CAAA;AAEF,eAAO,MAAM,oBAAoB,IAAI,CAAA;AACrC,eAAO,MAAM,wBAAwB,IAAI,CAAA;AACzC,eAAO,MAAM,mBAAmB,IAAI,CAAA;AACpC,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAE7C;;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,QAAQ,GAAG,IAAI;CAC3B,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,CAAC,GAAG,EAAE,eAAe,GAAG,iBAAiB,CAAA;CAC1C,CAAA;AAED,4BAA4B;AAC5B,MAAM,MAAM,eAAe,GAAG,GAAG,KAAK,IAAI,MAAM,EAAE,CAAA;AAElD,8BAA8B;AAC9B,MAAM,MAAM,iBAAiB,GAC3B,GAAG,mBAAmB,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,GAAG,SAAS,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lockfile/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lockfile/types.ts"],"names":[],"mappings":"AAsBA,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 Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport type { Graph } from '../graph.ts'\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 options: SpecOptions\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?: Manifest | 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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Edge } from './edge.
|
|
6
|
-
import {
|
|
1
|
+
import type { PathScurry } from 'path-scurry';
|
|
2
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
3
|
+
import type { Spec, SpecOptions } from '@vltpkg/spec';
|
|
4
|
+
import type { Integrity, Manifest, DependencyTypeShort } from '@vltpkg/types';
|
|
5
|
+
import { Edge } from './edge.ts';
|
|
6
|
+
import type { GraphLike, NodeLike } from './types.ts';
|
|
7
7
|
export type NodeOptions = SpecOptions & {
|
|
8
8
|
projectRoot: string;
|
|
9
9
|
graph: GraphLike;
|
|
@@ -78,15 +78,6 @@ export declare class Node implements NodeLike {
|
|
|
78
78
|
*/
|
|
79
79
|
registry?: string;
|
|
80
80
|
get name(): string;
|
|
81
|
-
/**
|
|
82
|
-
* The location of the node_modules folder where this node's edgesOut
|
|
83
|
-
* should be linked into. For nodes in the store, this is the parent
|
|
84
|
-
* directory, since they're extracted into a node_modules folder
|
|
85
|
-
* side by side with links to their deps. For nodes outside of the store
|
|
86
|
-
* (ie, importers and arbitrary link deps) this is the node_modules folder
|
|
87
|
-
* directly inside the node's directory.
|
|
88
|
-
*/
|
|
89
|
-
get nodeModules(): string;
|
|
90
81
|
/**
|
|
91
82
|
* The version of the package represented by this node, this is usually
|
|
92
83
|
* equivalent to `manifest.version` but in a few ways it may differ such as
|
|
@@ -103,6 +94,19 @@ export declare class Node implements NodeLike {
|
|
|
103
94
|
*/
|
|
104
95
|
get location(): string;
|
|
105
96
|
set location(location: string);
|
|
97
|
+
/**
|
|
98
|
+
* The resolved location of the node in the file system.
|
|
99
|
+
*/
|
|
100
|
+
resolvedLocation(scurry: PathScurry): string;
|
|
101
|
+
/**
|
|
102
|
+
* The location of the node_modules folder where this node's edgesOut
|
|
103
|
+
* should be linked into. For nodes in the store, this is the parent
|
|
104
|
+
* directory, since they're extracted into a node_modules folder
|
|
105
|
+
* side by side with links to their deps. For nodes outside of the store
|
|
106
|
+
* (ie, importers and arbitrary link deps) this is the node_modules folder
|
|
107
|
+
* directly inside the node's directory.
|
|
108
|
+
*/
|
|
109
|
+
nodeModules(scurry: PathScurry): string;
|
|
106
110
|
constructor(options: NodeOptions, id?: DepID, manifest?: Manifest, spec?: Spec, name?: string, version?: string);
|
|
107
111
|
/**
|
|
108
112
|
* return true if this node is located in the vlt store
|
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,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,K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,QAAQ,CAAC,EAAE,MAAM,CAAA;IASjB,IAAI,IAAI,WAIP;IAED;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,IAAI,QAAQ,IAAI,MAAM,CAQrB;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAM5B;IAED;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAI5C;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;gBAQrC,OAAO,EAAE,WAAW,EACpB,EAAE,CAAC,EAAE,KAAK,EACV,QAAQ,CAAC,EAAE,QAAQ,EACnB,IAAI,CAAC,EAAE,IAAI,EACX,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM;IAuBlB;;;;OAIG;IACH,UAAU,IAAI,OAAO;IAkBrB,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,MAAM;;;;;;;;;;;;;IAgBN,QAAQ;CAGT"}
|
package/dist/esm/node.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getId, hydrateTuple, splitDepID
|
|
1
|
+
import { getId, hydrateTuple, splitDepID } from '@vltpkg/dep-id';
|
|
2
2
|
import { typeError } from '@vltpkg/error-cause';
|
|
3
|
-
import { Edge } from
|
|
4
|
-
import { stringifyNode } from
|
|
3
|
+
import { Edge } from "./edge.js";
|
|
4
|
+
import { stringifyNode } from "./stringify-node.js";
|
|
5
5
|
export class Node {
|
|
6
6
|
get [Symbol.toStringTag]() {
|
|
7
7
|
return '@vltpkg/graph.Node';
|
|
@@ -113,20 +113,6 @@ export class Node {
|
|
|
113
113
|
this.#name = this.id;
|
|
114
114
|
return this.#name;
|
|
115
115
|
}
|
|
116
|
-
/**
|
|
117
|
-
* The location of the node_modules folder where this node's edgesOut
|
|
118
|
-
* should be linked into. For nodes in the store, this is the parent
|
|
119
|
-
* directory, since they're extracted into a node_modules folder
|
|
120
|
-
* side by side with links to their deps. For nodes outside of the store
|
|
121
|
-
* (ie, importers and arbitrary link deps) this is the node_modules folder
|
|
122
|
-
* directly inside the node's directory.
|
|
123
|
-
*/
|
|
124
|
-
get nodeModules() {
|
|
125
|
-
const loc = this.location;
|
|
126
|
-
return this.inVltStore() ?
|
|
127
|
-
loc.substring(0, loc.length - this.name.length - 1)
|
|
128
|
-
: loc + '/node_modules';
|
|
129
|
-
}
|
|
130
116
|
/**
|
|
131
117
|
* The version of the package represented by this node, this is usually
|
|
132
118
|
* equivalent to `manifest.version` but in a few ways it may differ such as
|
|
@@ -157,6 +143,26 @@ export class Node {
|
|
|
157
143
|
this.inVltStore = Node.prototype.inVltStore;
|
|
158
144
|
}
|
|
159
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* The resolved location of the node in the file system.
|
|
148
|
+
*/
|
|
149
|
+
resolvedLocation(scurry) {
|
|
150
|
+
return scurry.cwd.resolve(this.location).fullpath();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The location of the node_modules folder where this node's edgesOut
|
|
154
|
+
* should be linked into. For nodes in the store, this is the parent
|
|
155
|
+
* directory, since they're extracted into a node_modules folder
|
|
156
|
+
* side by side with links to their deps. For nodes outside of the store
|
|
157
|
+
* (ie, importers and arbitrary link deps) this is the node_modules folder
|
|
158
|
+
* directly inside the node's directory.
|
|
159
|
+
*/
|
|
160
|
+
nodeModules(scurry) {
|
|
161
|
+
const loc = this.resolvedLocation(scurry);
|
|
162
|
+
return this.inVltStore() ?
|
|
163
|
+
loc.substring(0, loc.length - this.name.length - 1)
|
|
164
|
+
: scurry.resolve(loc, 'node_modules');
|
|
165
|
+
}
|
|
160
166
|
constructor(options, id, manifest, spec, name, version) {
|
|
161
167
|
this.#options = options;
|
|
162
168
|
this.projectRoot = options.projectRoot;
|
package/dist/esm/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,EACL,YAAY,EACZ,UAAU,GACX,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAI/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAAoB,CAAA;IAC7B,CAAC;IAED,QAAQ,CAAa;IACrB,SAAS,CAAS;IAElB,SAAS,GAAG,KAAK,CAAA;IACjB;;;;;;OAMG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IACD,IAAI,QAAQ,CAAC,QAAiB;QAC5B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAA;QACzB,IAAI,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;YACxB,8BAA8B;YAC9B,KAAK,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,QAAQ;oBAAE,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAA;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,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MAAM;QACJ,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,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;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import {\n type DepID,\n type DepIDTuple,\n getId,\n hydrateTuple,\n splitDepID,\n} from '@vltpkg/dep-id'\nimport { typeError } from '@vltpkg/error-cause'\nimport { type Spec, type SpecOptions } from '@vltpkg/spec'\nimport { type Integrity, type Manifest } from '@vltpkg/types'\nimport { type DependencyTypeShort } from './dependencies.js'\nimport { Edge } from './edge.js'\nimport { type GraphLike, type NodeLike } from './types.js'\nimport { stringifyNode } from './stringify-node.js'\nimport { type PackageInfoClient } from '@vltpkg/package-info'\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\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 * 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 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?: Manifest\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 * 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 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 get nodeModules() {\n const loc = this.location\n return this.inVltStore() ?\n loc.substring(0, loc.length - this.name.length - 1)\n : loc + '/node_modules'\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 * 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 constructor(\n options: NodeOptions,\n id?: DepID,\n manifest?: Manifest,\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 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 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 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: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAO/C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAQnD,MAAM,OAAO,IAAI;IACf,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC;QACtB,OAAO,oBAA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E,IAAI,CAAC,GAAG;YACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF","sourcesContent":["import type { PathScurry } from 'path-scurry'\nimport { getId, hydrateTuple, splitDepID } 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 type {\n Integrity,\n Manifest,\n DependencyTypeShort,\n} from '@vltpkg/types'\nimport { Edge } from './edge.ts'\nimport type { GraphLike, NodeLike } from './types.ts'\nimport { stringifyNode } from './stringify-node.ts'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\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\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 * 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 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?: Manifest\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 * 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 * 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?: Manifest,\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 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 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 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: this.manifest,\n projectRoot: this.projectRoot,\n integrity: this.integrity,\n resolved: this.resolved,\n dev: this.dev,\n optional: this.optional,\n }\n }\n\n toString() {\n return stringifyNode(this)\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
2
|
+
import type { Manifest } from '@vltpkg/types';
|
|
3
|
+
import type { PathScurry } from 'path-scurry';
|
|
4
|
+
import type { Edge } from '../edge.ts';
|
|
5
5
|
/**
|
|
6
6
|
* reify an edge into a node_modules folder, with bins linked
|
|
7
7
|
* this does NOT chmod the bins to 0o777, because they might not exist
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"add-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAG7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAwBtC;;;;GAIG;AACH,eAAO,MAAM,OAAO,SACZ,IAAI,YACA,QAAQ,UACV,UAAU,WACT,cAAc,kBAyBxB,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, symlink } from 'fs/promises';
|
|
2
2
|
import { dirname, relative } from 'path';
|
|
3
|
-
import { binPaths } from
|
|
3
|
+
import { binPaths } from "./bin-paths.js";
|
|
4
4
|
const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
5
5
|
await mkdir(dirname(link), { recursive: true });
|
|
6
6
|
try {
|
|
@@ -26,10 +26,10 @@ const clobberSymlink = async (target, link, remover, type = 'file') => {
|
|
|
26
26
|
export const addEdge = async (edge, manifest, scurry, remover) => {
|
|
27
27
|
if (!edge.to)
|
|
28
28
|
return;
|
|
29
|
-
const binRoot = scurry.resolve(edge.from.nodeModules, '.bin');
|
|
30
|
-
const path = scurry.resolve(edge.from.nodeModules, edge.spec.name);
|
|
29
|
+
const binRoot = scurry.resolve(edge.from.nodeModules(scurry), '.bin');
|
|
30
|
+
const path = scurry.resolve(edge.from.nodeModules(scurry), edge.spec.name);
|
|
31
31
|
const promises = [];
|
|
32
|
-
const target = relative(dirname(path),
|
|
32
|
+
const target = relative(dirname(path), edge.to.resolvedLocation(scurry));
|
|
33
33
|
promises.push(clobberSymlink(target, path, remover, 'dir'));
|
|
34
34
|
const bp = binPaths(manifest);
|
|
35
35
|
for (const [key, val] of Object.entries(bp)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edge.js","sourceRoot":"","sources":["../../../src/reify/add-edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,a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,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CACjC,CAAA;IACD,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAC3D,MAAM,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;QAC3D,uCAAuC;QACvC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAA;IACtD,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["import type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { Manifest } from '@vltpkg/types'\nimport { mkdir, symlink } from 'fs/promises'\nimport { dirname, relative } from 'path'\nimport type { PathScurry } from 'path-scurry'\nimport type { Edge } from '../edge.ts'\nimport { binPaths } from './bin-paths.ts'\n\nconst clobberSymlink = async (\n target: string,\n link: string,\n remover: RollbackRemove,\n type = 'file',\n) => {\n await mkdir(dirname(link), { recursive: true })\n try {\n await symlink(target, link, type)\n } catch (e) {\n const er = e as NodeJS.ErrnoException\n if (er.code === 'EEXIST') {\n return remover.rm(link).then(() => symlink(target, link))\n /* c8 ignore start */\n } else {\n throw er\n }\n }\n /* c8 ignore stop */\n}\n\n/**\n * reify an edge into a node_modules folder, with bins linked\n * this does NOT chmod the bins to 0o777, because they might not exist\n * until scripts are run, in the case of non-store deps like workspaces\n */\nexport const addEdge = async (\n edge: Edge,\n manifest: Manifest,\n scurry: PathScurry,\n remover: RollbackRemove,\n) => {\n if (!edge.to) return\n const binRoot = scurry.resolve(\n edge.from.nodeModules(scurry),\n '.bin',\n )\n const path = scurry.resolve(\n edge.from.nodeModules(scurry),\n edge.spec.name,\n )\n const promises: Promise<unknown>[] = []\n const target = relative(\n dirname(path),\n edge.to.resolvedLocation(scurry),\n )\n promises.push(clobberSymlink(target, path, remover, 'dir'))\n const bp = binPaths(manifest)\n for (const [key, val] of Object.entries(bp)) {\n const link = scurry.resolve(binRoot, key)\n const target = relative(binRoot, scurry.resolve(path, val))\n // TODO: bash/cmd/pwsh shims on Windows\n promises.push(clobberSymlink(target, link, remover))\n }\n await Promise.all(promises)\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
|
+
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
3
|
+
import type { PathScurry } from 'path-scurry';
|
|
4
|
+
import type { Diff } from '../diff.ts';
|
|
5
5
|
export declare const addEdges: (diff: Diff, packageJson: PackageJson, scurry: PathScurry, remover: RollbackRemove) => Promise<unknown>[];
|
|
6
6
|
//# sourceMappingURL=add-edges.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edges.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"add-edges.d.ts","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAGtC,eAAO,MAAM,QAAQ,SACb,IAAI,eACG,WAAW,UAChB,UAAU,WACT,cAAc,KACtB,OAAO,CAAC,OAAO,CAAC,EAUlB,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { addEdge } from
|
|
1
|
+
import { addEdge } from "./add-edge.js";
|
|
2
2
|
export const addEdges = (diff, packageJson, scurry, remover) => {
|
|
3
3
|
const actions = [];
|
|
4
4
|
for (const edge of diff.edges.add) {
|
|
5
5
|
const { to } = edge;
|
|
6
6
|
if (!to)
|
|
7
7
|
continue;
|
|
8
|
-
const mani = to.manifest ?? packageJson.read(to.
|
|
8
|
+
const mani = to.manifest ?? packageJson.read(to.resolvedLocation(scurry));
|
|
9
9
|
actions.push(addEdge(edge, mani, scurry, remover));
|
|
10
10
|
}
|
|
11
11
|
return actions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-edges.js","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,WAAwB,EACxB,MAAkB,EAClB,OAAuB,EACH,EAAE;IACtB,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,EAAE;YAAE,SAAQ;QACjB,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"add-edges.js","sourceRoot":"","sources":["../../../src/reify/add-edges.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,IAAU,EACV,WAAwB,EACxB,MAAkB,EAClB,OAAuB,EACH,EAAE;IACtB,MAAM,OAAO,GAAuB,EAAE,CAAA;IACtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,EAAE;YAAE,SAAQ;QACjB,MAAM,IAAI,GACR,EAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAA;QAC9D,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACpD,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import type { PackageJson } from '@vltpkg/package-json'\nimport type { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport { addEdge } from './add-edge.ts'\n\nexport const addEdges = (\n diff: Diff,\n packageJson: PackageJson,\n scurry: PathScurry,\n remover: RollbackRemove,\n): Promise<unknown>[] => {\n const actions: Promise<unknown>[] = []\n for (const edge of diff.edges.add) {\n const { to } = edge\n if (!to) continue\n const mani =\n to.manifest ?? packageJson.read(to.resolvedLocation(scurry))\n actions.push(addEdge(edge, mani, scurry, remover))\n }\n return actions\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { PackageInfoClient } from '@vltpkg/package-info';
|
|
2
|
+
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
3
|
+
import type { SpecOptions } from '@vltpkg/spec';
|
|
4
|
+
import type { PathScurry } from 'path-scurry';
|
|
5
|
+
import type { Diff } from '../diff.ts';
|
|
6
6
|
export declare const addNodes: (diff: Diff, scurry: PathScurry, remover: RollbackRemove, options: SpecOptions, packageInfo: PackageInfoClient) => (() => Promise<unknown>)[];
|
|
7
7
|
//# sourceMappingURL=add-nodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"add-nodes.d.ts","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAE7D,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,EA6C1B,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hydrate } from '@vltpkg/dep-id';
|
|
2
2
|
import { platformCheck } from '@vltpkg/pick-manifest';
|
|
3
|
-
import { optionalFail } from
|
|
3
|
+
import { optionalFail } from "./optional-fail.js";
|
|
4
4
|
export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
5
5
|
const actions = [];
|
|
6
6
|
// fetch and extract all the nodes, removing any in the way
|
|
@@ -12,10 +12,11 @@ export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
|
12
12
|
if (!node.inVltStore())
|
|
13
13
|
continue;
|
|
14
14
|
// remove anything already there
|
|
15
|
-
const target =
|
|
15
|
+
const target = node.resolvedLocation(scurry);
|
|
16
16
|
const from = scurry.resolve('');
|
|
17
17
|
const spec = hydrate(node.id, manifest.name, options);
|
|
18
18
|
const onErr = optionalFail(diff, node);
|
|
19
|
+
const { integrity, resolved } = node;
|
|
19
20
|
// if it's optional, and we know it isn't for this platform, or it's
|
|
20
21
|
// deprecated, don't install it. if it's not optional, try our best.
|
|
21
22
|
if (onErr &&
|
|
@@ -24,13 +25,15 @@ export const addNodes = (diff, scurry, remover, options, packageInfo) => {
|
|
|
24
25
|
onErr();
|
|
25
26
|
continue;
|
|
26
27
|
}
|
|
27
|
-
actions.push(() => remover
|
|
28
|
-
.rm(target)
|
|
29
|
-
.then(() => onErr ?
|
|
28
|
+
actions.push(() => remover.rm(target).then(() => onErr ?
|
|
30
29
|
packageInfo
|
|
31
|
-
.extract(spec, target, { from })
|
|
30
|
+
.extract(spec, target, { from, integrity, resolved })
|
|
32
31
|
.then(x => x, onErr)
|
|
33
|
-
: packageInfo.extract(spec, target, {
|
|
32
|
+
: packageInfo.extract(spec, target, {
|
|
33
|
+
from,
|
|
34
|
+
integrity,
|
|
35
|
+
resolved,
|
|
36
|
+
})));
|
|
34
37
|
}
|
|
35
38
|
return actions;
|
|
36
39
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-nodes.js","sourceRoot":"","sources":["../../../src/reify/add-nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAKrD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,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,6DAA6D;QAC7D,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QACpE,IACE,KAAK;YACL,CAAC,QAAQ,CAAC,UAAU;gBAClB,CAAC,aAAa,CACZ,QAAQ,EACR,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,IAAI,CACb,CAAC,EACJ,CAAC;YACD,KAAK,EAAE,CAAA;YACP,SAAQ;QACV,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAChB,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAC3B,KAAK,CAAC,CAAC;YACL,WAAW;iBACR,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;iBACpD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;YACxB,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE;gBAChC,IAAI;gBACJ,SAAS;gBACT,QAAQ;aACT,CAAC,CACL,CACF,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { hydrate } from '@vltpkg/dep-id'\nimport type { PackageInfoClient } from '@vltpkg/package-info'\nimport { platformCheck } from '@vltpkg/pick-manifest'\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 { optionalFail } from './optional-fail.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 /* c8 ignore next - all nodes have manifests by this point */\n const { manifest = {} } = node\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 // remove anything already there\n const target = node.resolvedLocation(scurry)\n const from = scurry.resolve('')\n const spec = hydrate(node.id, manifest.name, options)\n const onErr = optionalFail(diff, node)\n const { integrity, resolved } = node\n // if it's optional, and we know it isn't for this platform, or it's\n // deprecated, don't install it. if it's not optional, try our best.\n if (\n onErr &&\n (manifest.deprecated ||\n !platformCheck(\n manifest,\n process.version,\n process.platform,\n process.arch,\n ))\n ) {\n onErr()\n continue\n }\n actions.push(() =>\n remover.rm(target).then(() =>\n onErr ?\n packageInfo\n .extract(spec, target, { from, integrity, resolved })\n .then(x => x, onErr)\n : packageInfo.extract(spec, target, {\n from,\n integrity,\n resolved,\n }),\n ),\n )\n }\n return actions\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-paths.d.ts","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"bin-paths.d.ts","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAU7C,wCAAwC;AACxC,eAAO,MAAM,QAAQ,aACT,QAAQ,KACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAYvB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-paths.js","sourceRoot":"","sources":["../../../src/reify/bin-paths.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAgC,EAAE;IAClE,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChD,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,CA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IAAI,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAA;IAE9B,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;YACtC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAA;QACvB,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACnC,OAAO,GAAG,CAAA;QACZ,CAAC;IACH,CAAC;IACD,OAAO,EAAE,CAAA;AACX,CAAC,CAAA","sourcesContent":["import type { Manifest } from '@vltpkg/types'\n\nconst parseScope = (scoped: string): [string | undefined, string] => {\n if (scoped.startsWith('@')) {\n const [scope, name, ...rest] = scoped.split('/')\n if (scope && name && rest.length === 0) return [scope, name]\n }\n return [undefined, scoped]\n}\n\n/** get the bin scripts for a package */\nexport const binPaths = (\n manifest: Manifest,\n): Record<string, string> => {\n const { name, bin } = manifest\n\n if (bin) {\n if (name && typeof bin === 'string') {\n const [_scope, pkg] = parseScope(name)\n return { [pkg]: bin }\n } else if (typeof bin === 'object') {\n return bin\n }\n }\n return {}\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { PackageJson } from '@vltpkg/package-json';
|
|
2
|
+
import type { PathScurry } from 'path-scurry';
|
|
3
|
+
import type { Diff } from '../diff.ts';
|
|
4
4
|
export declare const build: (diff: Diff, packageJson: PackageJson, scurry: PathScurry) => Promise<void>;
|
|
5
5
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
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;AAMtC,eAAO,MAAM,KAAK,SACV,IAAI,eACG,WAAW,UAChB,UAAU,kBAiCnB,CAAA"}
|
package/dist/esm/reify/build.js
CHANGED
|
@@ -5,9 +5,9 @@ import { run } from '@vltpkg/run';
|
|
|
5
5
|
import { statSync } from 'fs';
|
|
6
6
|
import { chmod } from 'fs/promises';
|
|
7
7
|
import { graphRun } from 'graph-run';
|
|
8
|
-
import { nonEmptyList } from
|
|
9
|
-
import { binPaths } from
|
|
10
|
-
import { optionalFail } from
|
|
8
|
+
import { nonEmptyList } from "../non-empty-list.js";
|
|
9
|
+
import { binPaths } from "./bin-paths.js";
|
|
10
|
+
import { optionalFail } from "./optional-fail.js";
|
|
11
11
|
export const build = async (diff, packageJson, scurry) => {
|
|
12
12
|
const graph = diff.to;
|
|
13
13
|
const nodes = nonEmptyList([...graph.importers]);
|
|
@@ -39,7 +39,7 @@ export const build = async (diff, packageJson, scurry) => {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
const visit = async (packageJson, scurry, node, signal, _path) => {
|
|
42
|
-
node.manifest ??= packageJson.read(
|
|
42
|
+
node.manifest ??= packageJson.read(node.resolvedLocation(scurry));
|
|
43
43
|
const { manifest } = node;
|
|
44
44
|
const { scripts = {} } = manifest;
|
|
45
45
|
const { install, preinstall, postinstall, prepare, preprepare, postprepare, } = scripts;
|
|
@@ -51,7 +51,7 @@ const visit = async (packageJson, scurry, node, signal, _path) => {
|
|
|
51
51
|
arg0: 'install',
|
|
52
52
|
ignoreMissing: true,
|
|
53
53
|
packageJson,
|
|
54
|
-
cwd: node.
|
|
54
|
+
cwd: node.resolvedLocation(scurry),
|
|
55
55
|
projectRoot: node.projectRoot,
|
|
56
56
|
manifest,
|
|
57
57
|
});
|
|
@@ -65,14 +65,14 @@ const visit = async (packageJson, scurry, node, signal, _path) => {
|
|
|
65
65
|
arg0: 'prepare',
|
|
66
66
|
ignoreMissing: true,
|
|
67
67
|
packageJson,
|
|
68
|
-
cwd: node.
|
|
68
|
+
cwd: node.resolvedLocation(scurry),
|
|
69
69
|
projectRoot: node.projectRoot,
|
|
70
70
|
manifest,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
const chmods = [];
|
|
74
74
|
for (const bin of Object.values(binPaths(manifest))) {
|
|
75
|
-
const path = scurry.resolve(node.
|
|
75
|
+
const path = scurry.resolve(`${node.resolvedLocation(scurry)}/${bin}`);
|
|
76
76
|
chmods.push(makeExecutable(path));
|
|
77
77
|
}
|
|
78
78
|
await Promise.all(chmods);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/reify/build.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAClE,oCAAoC;AAGpC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIpC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,EACxB,IAAU,EACV,WAAwB,EACxB,MAAkB,EAClB,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAA;IACrB,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,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AAI,QAAQ,CAAA;IAEtD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,GAAG,CAAC;YACR,MAAM;YACN,IAAI,EAAE,SAAS;YACf,aAAa,EAAE,IAAI;YACnB,WAAW;YACX,GAAG,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAClC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,MAAM,GAAuB,EAAE,CAAA;IACrC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CACzB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,CAC1C,CAAA;QACD,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAA;IACnC,CAAC;IACD,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;AAC3B,CAAC,CAAA;AAED,qBAAqB;AACrB,4DAA4D;AAC5D,oEAAoE;AACpE,IAAI,QAAQ,GAAG,CAAC,CAAA;AAChB,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAC5C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,QAAQ,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAA;IAClD,CAAC;IACD,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["// walk the graph of added nodes, building and chmoding their bins\n// at the end, we get back to the importers, and run their prepare\n// script as well as install script.\n\nimport type { PackageJson } from '@vltpkg/package-json'\nimport { run } from '@vltpkg/run'\nimport { statSync } from 'fs'\nimport { chmod } from 'fs/promises'\nimport { graphRun } from 'graph-run'\nimport type { PathScurry } from 'path-scurry'\nimport type { Diff } from '../diff.ts'\nimport type { Node } from '../node.ts'\nimport { nonEmptyList } from '../non-empty-list.ts'\nimport { binPaths } from './bin-paths.ts'\nimport { optionalFail } from './optional-fail.ts'\n\nexport const build = async (\n diff: Diff,\n packageJson: PackageJson,\n scurry: PathScurry,\n) => {\n const graph = diff.to\n const nodes = nonEmptyList([...graph.importers])\n /* c8 ignore next - all graphs have at least one importer */\n if (!nodes) return\n\n await graphRun<Node, unknown>({\n graph: nodes,\n visit: async (node: Node, signal, path) => {\n // if it's not an importer or an added node, nothing to do.\n // TODO: only build importers if it has changed deps, there's never\n // been a previous build, or it contains something newer than the\n // most recent build.\n // For now, just always build all importers, because we don't\n // track all that other stuff.\n if (!node.importer && !diff.nodes.add.has(node)) return\n\n await visit(packageJson, scurry, node, signal, path).then(\n x => x,\n optionalFail(diff, node),\n )\n },\n\n getDeps: node => {\n const deps: Node[] = []\n for (const { to } of node.edgesOut.values()) {\n /* c8 ignore next - vanishingly unlikely in practice */\n if (to) deps.push(to)\n }\n return deps\n },\n })\n}\n\nconst visit = async (\n packageJson: PackageJson,\n scurry: PathScurry,\n node: Node,\n signal: AbortSignal,\n _path: Node[],\n): Promise<void> => {\n node.manifest ??= packageJson.read(node.resolvedLocation(scurry))\n const { manifest } = node\n const { scripts = {} } = manifest\n\n const {\n install,\n preinstall,\n postinstall,\n prepare,\n preprepare,\n postprepare,\n } = scripts\n\n // if it has install script, run it\n const runInstall = !!(install || preinstall || postinstall)\n if (runInstall) {\n await run({\n signal,\n arg0: 'install',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n // if it's an importer or git, run prepare\n const prepable =\n node.id.startsWith('git') || node.importer || !node.inVltStore()\n const runPrepare =\n !!(prepare || preprepare || postprepare) && prepable\n\n if (runPrepare) {\n await run({\n signal,\n arg0: 'prepare',\n ignoreMissing: true,\n packageJson,\n cwd: node.resolvedLocation(scurry),\n projectRoot: node.projectRoot,\n manifest,\n })\n }\n\n const chmods: Promise<unknown>[] = []\n for (const bin of Object.values(binPaths(manifest))) {\n const path = scurry.resolve(\n `${node.resolvedLocation(scurry)}/${bin}`,\n )\n chmods.push(makeExecutable(path))\n }\n await Promise.all(chmods)\n}\n\n// 0 is \"not yet set\"\n// This is defined by doing `0o111 | <mode>` so that systems\n// that create files group-writable result in 0o775 instead of 0o755\nlet execMode = 0\nconst makeExecutable = async (path: string) => {\n if (!execMode) {\n execMode = (statSync(path).mode & 0o777) | 0o111\n }\n await chmod(path, execMode)\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { RollbackRemove } from '@vltpkg/rollback-remove';
|
|
2
|
+
import type { PathScurry } from 'path-scurry';
|
|
3
|
+
import type { Edge } from '../edge.ts';
|
|
4
4
|
export declare const deleteEdge: (edge: Edge, scurry: PathScurry, remover: RollbackRemove) => Promise<void>;
|
|
5
5
|
//# sourceMappingURL=delete-edge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/delete-edge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"delete-edge.d.ts","sourceRoot":"","sources":["../../../src/reify/delete-edge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAiBtC,eAAO,MAAM,UAAU,SACf,IAAI,UACF,UAAU,WACT,cAAc,kBAmBxB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { binPaths } from
|
|
1
|
+
import { binPaths } from "./bin-paths.js";
|
|
2
2
|
const rmBinPosix = (remover, bin) => {
|
|
3
3
|
return [remover.rm(bin)];
|
|
4
4
|
};
|
|
@@ -12,7 +12,7 @@ const rmBinWin32 = (remover, bin) => {
|
|
|
12
12
|
const rmBin = process.platform === 'win32' ? rmBinWin32 : rmBinPosix;
|
|
13
13
|
export const deleteEdge = async (edge, scurry, remover) => {
|
|
14
14
|
const { spec: { name }, to, } = edge;
|
|
15
|
-
const nm = edge.from.nodeModules;
|
|
15
|
+
const nm = edge.from.nodeModules(scurry);
|
|
16
16
|
const path = scurry.resolve(nm, name);
|
|
17
17
|
const binRoot = scurry.cwd.resolve(`${nm}/.bin`);
|
|
18
18
|
const promises = [];
|