@vltpkg/cli-sdk 0.0.0-8 → 1.0.0-rc.1
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/commands/build.d.ts +25 -0
- package/dist/esm/commands/build.d.ts.map +1 -0
- package/dist/esm/commands/build.js +102 -0
- package/dist/esm/commands/build.js.map +1 -0
- package/dist/esm/commands/cache.d.ts +65 -0
- package/dist/esm/commands/cache.d.ts.map +1 -0
- package/dist/esm/commands/cache.js +257 -0
- package/dist/esm/commands/cache.js.map +1 -0
- package/dist/esm/commands/ci.d.ts +11 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +32 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/config.d.ts +3 -2
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +372 -101
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/docs.d.ts +18 -0
- package/dist/esm/commands/docs.d.ts.map +1 -0
- package/dist/esm/commands/docs.js +154 -0
- package/dist/esm/commands/docs.js.map +1 -0
- package/dist/esm/commands/exec-cache.d.ts +49 -0
- package/dist/esm/commands/exec-cache.d.ts.map +1 -0
- package/dist/esm/commands/exec-cache.js +146 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +6 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -0
- package/dist/esm/commands/exec-local.js +24 -0
- package/dist/esm/commands/exec-local.js.map +1 -0
- package/dist/esm/commands/exec.d.ts +4 -0
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +75 -10
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/help.d.ts +1 -1
- package/dist/esm/commands/help.d.ts.map +1 -1
- package/dist/esm/commands/help.js +32 -3
- package/dist/esm/commands/help.js.map +1 -1
- package/dist/esm/commands/init.d.ts +4 -5
- package/dist/esm/commands/init.d.ts.map +1 -1
- package/dist/esm/commands/init.js +95 -9
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts +3 -2
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +43 -15
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +24 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +27 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts +2 -2
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +149 -49
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +32 -0
- package/dist/esm/commands/pack.d.ts.map +1 -0
- package/dist/esm/commands/pack.js +147 -0
- package/dist/esm/commands/pack.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +2 -3
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +123 -38
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +22 -0
- package/dist/esm/commands/publish.d.ts.map +1 -0
- package/dist/esm/commands/publish.js +245 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +2 -2
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +170 -39
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/commands/run-exec.d.ts +1 -0
- package/dist/esm/commands/run-exec.d.ts.map +1 -1
- package/dist/esm/commands/run-exec.js +1 -0
- package/dist/esm/commands/run-exec.js.map +1 -1
- package/dist/esm/commands/run.d.ts +1 -0
- package/dist/esm/commands/run.d.ts.map +1 -1
- package/dist/esm/commands/run.js +13 -16
- package/dist/esm/commands/run.js.map +1 -1
- package/dist/esm/commands/serve.d.ts +14 -0
- package/dist/esm/commands/serve.d.ts.map +1 -0
- package/dist/esm/commands/serve.js +103 -0
- package/dist/esm/commands/serve.js.map +1 -0
- package/dist/esm/commands/uninstall.d.ts +12 -3
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +8 -3
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/update.d.ts +14 -0
- package/dist/esm/commands/update.d.ts.map +1 -0
- package/dist/esm/commands/update.js +41 -0
- package/dist/esm/commands/update.js.map +1 -0
- package/dist/esm/commands/version.d.ts +26 -0
- package/dist/esm/commands/version.d.ts.map +1 -0
- package/dist/esm/commands/version.js +226 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/commands/whoami.d.ts +4 -2
- package/dist/esm/commands/whoami.d.ts.map +1 -1
- package/dist/esm/commands/whoami.js +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/config/definition.d.ts +123 -11
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +197 -34
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +42 -37
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +116 -172
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/merge.d.ts +3 -1
- package/dist/esm/config/merge.d.ts.map +1 -1
- package/dist/esm/config/merge.js +11 -6
- package/dist/esm/config/merge.js.map +1 -1
- package/dist/esm/config/usage.d.ts +3 -2
- package/dist/esm/config/usage.d.ts.map +1 -1
- package/dist/esm/config/usage.js.map +1 -1
- package/dist/esm/custom-help.d.ts +9 -0
- package/dist/esm/custom-help.d.ts.map +1 -0
- package/dist/esm/custom-help.js +400 -0
- package/dist/esm/custom-help.js.map +1 -0
- package/dist/esm/exec-command.d.ts +33 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +214 -65
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/index.d.ts +1 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +46 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/load-command.d.ts +16 -0
- package/dist/esm/load-command.d.ts.map +1 -0
- package/dist/esm/load-command.js +21 -0
- package/dist/esm/load-command.js.map +1 -0
- package/dist/esm/output.d.ts +6 -10
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +73 -35
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/pack-tarball.d.ts +22 -0
- package/dist/esm/pack-tarball.d.ts.map +1 -0
- package/dist/esm/pack-tarball.js +249 -0
- package/dist/esm/pack-tarball.js.map +1 -0
- package/dist/esm/parse-add-remove-args.d.ts +1 -1
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
- package/dist/esm/parse-add-remove-args.js +1 -1
- package/dist/esm/parse-add-remove-args.js.map +1 -1
- package/dist/esm/print-err.d.ts +12 -1
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +157 -26
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/query-host-contexts.d.ts +16 -0
- package/dist/esm/query-host-contexts.d.ts.map +1 -0
- package/dist/esm/query-host-contexts.js +135 -0
- package/dist/esm/query-host-contexts.js.map +1 -0
- package/dist/esm/start-gui.d.ts +1 -0
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +25 -6
- package/dist/esm/start-gui.js.map +1 -1
- package/dist/esm/view.d.ts +2 -3
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +51 -35
- package/dist/esm/commands/gui.d.ts +0 -6
- package/dist/esm/commands/gui.d.ts.map +0 -1
- package/dist/esm/commands/gui.js +0 -13
- package/dist/esm/commands/gui.js.map +0 -1
- package/dist/esm/commands/install-exec.d.ts +0 -4
- package/dist/esm/commands/install-exec.d.ts.map +0 -1
- package/dist/esm/commands/install-exec.js +0 -13
- package/dist/esm/commands/install-exec.js.map +0 -1
|
@@ -1,17 +1,38 @@
|
|
|
1
|
-
import { actual, humanReadableOutput, jsonOutput, mermaidOutput, } from '@vltpkg/graph';
|
|
1
|
+
import { actual, asNode, humanReadableOutput, jsonOutput, mermaidOutput, GraphModifier, } from '@vltpkg/graph';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import LZString from 'lz-string';
|
|
2
4
|
import { Query } from '@vltpkg/query';
|
|
3
5
|
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
4
|
-
import { commandUsage } from "../config/usage.js";
|
|
5
6
|
import { startGUI } from "../start-gui.js";
|
|
7
|
+
import { commandUsage } from "../config/usage.js";
|
|
8
|
+
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
6
9
|
export const usage = () => commandUsage({
|
|
7
10
|
command: 'query',
|
|
8
|
-
usage: [
|
|
9
|
-
|
|
11
|
+
usage: [
|
|
12
|
+
'',
|
|
13
|
+
'<query> --view=<human | json | mermaid | gui>',
|
|
14
|
+
'<query> --expect-results=<comparison string>',
|
|
15
|
+
'--target=<query> --view=<human | json | mermaid | gui>',
|
|
16
|
+
],
|
|
17
|
+
description: `List installed dependencies matching the provided query.
|
|
18
|
+
|
|
19
|
+
The vlt Dependency Selector Syntax is a CSS-like query language that
|
|
20
|
+
allows you to filter installed dependencies using a variety of metadata
|
|
21
|
+
in the form of CSS-like attributes, pseudo selectors & combinators.
|
|
22
|
+
|
|
23
|
+
The --scope and --target options accepts DSS query selectors to filter
|
|
24
|
+
packages. Using --scope, you can specify which packages to treat as the
|
|
25
|
+
top-level items in the output graph. The --target option can be used as
|
|
26
|
+
an alternative to positional arguments, it allows you to filter what
|
|
27
|
+
dependencies to include in the output. Using both options allows you to
|
|
28
|
+
render subgraphs of the dependency graph.
|
|
29
|
+
|
|
30
|
+
Defaults to listing all dependencies of the project root and workspaces.`,
|
|
10
31
|
examples: {
|
|
11
32
|
[`'#foo'`]: {
|
|
12
|
-
description: 'Query
|
|
33
|
+
description: 'Query dependencies declared as "foo"',
|
|
13
34
|
},
|
|
14
|
-
[`'
|
|
35
|
+
[`'*:workspace > *:peer'`]: {
|
|
15
36
|
description: 'Query all peer dependencies of workspaces',
|
|
16
37
|
},
|
|
17
38
|
[`':project > *:attr(scripts, [build])'`]: {
|
|
@@ -20,64 +41,174 @@ export const usage = () => commandUsage({
|
|
|
20
41
|
[`'[name^="@vltpkg"]'`]: {
|
|
21
42
|
description: 'Query packages with names starting with "@vltpkg"',
|
|
22
43
|
},
|
|
44
|
+
[`'*:license(copyleft) --expect-results=0'`]: {
|
|
45
|
+
description: 'Errors if a copyleft licensed package is found',
|
|
46
|
+
},
|
|
47
|
+
'--scope=":root > #dependency-name"': {
|
|
48
|
+
description: 'Defines a direct dependency as the output top-level scope',
|
|
49
|
+
},
|
|
50
|
+
[`'--target="*"'`]: {
|
|
51
|
+
description: 'Query all dependencies using the target option',
|
|
52
|
+
},
|
|
53
|
+
[`'--target=":workspace > *:peer"'`]: {
|
|
54
|
+
description: 'Query all peer dependencies of workspaces using target option',
|
|
55
|
+
},
|
|
23
56
|
},
|
|
24
57
|
options: {
|
|
58
|
+
'expect-results': {
|
|
59
|
+
value: '[number | string]',
|
|
60
|
+
description: 'Sets an expected number of resulting items. Errors if the number of resulting items does not match the set value. Accepts a specific numeric value or a string value starting with either ">", "<", ">=" or "<=" followed by a numeric value to be compared.',
|
|
61
|
+
},
|
|
62
|
+
scope: {
|
|
63
|
+
value: '<query>',
|
|
64
|
+
description: 'Query selector to select top-level packages using the DSS query language syntax.',
|
|
65
|
+
},
|
|
66
|
+
target: {
|
|
67
|
+
value: '<query>',
|
|
68
|
+
description: 'Query selector to filter packages using DSS syntax.',
|
|
69
|
+
},
|
|
25
70
|
view: {
|
|
26
71
|
value: '[human | json | mermaid | gui]',
|
|
27
72
|
description: 'Output format. Defaults to human-readable or json if no tty.',
|
|
28
73
|
},
|
|
29
74
|
},
|
|
30
75
|
});
|
|
76
|
+
const validateExpectedResult = (conf, edges) => {
|
|
77
|
+
const expectResults = conf.values['expect-results'];
|
|
78
|
+
if (expectResults?.startsWith('>=')) {
|
|
79
|
+
return edges.length >= parseInt(expectResults.slice(2).trim(), 10);
|
|
80
|
+
}
|
|
81
|
+
else if (expectResults?.startsWith('<=')) {
|
|
82
|
+
return edges.length <= parseInt(expectResults.slice(2).trim(), 10);
|
|
83
|
+
}
|
|
84
|
+
else if (expectResults?.startsWith('>')) {
|
|
85
|
+
return edges.length > parseInt(expectResults.slice(1).trim(), 10);
|
|
86
|
+
}
|
|
87
|
+
else if (expectResults?.startsWith('<')) {
|
|
88
|
+
return edges.length < parseInt(expectResults.slice(1).trim(), 10);
|
|
89
|
+
}
|
|
90
|
+
else if (expectResults) {
|
|
91
|
+
return edges.length === parseInt(expectResults.trim(), 10);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
};
|
|
31
95
|
export const views = {
|
|
32
96
|
json: jsonOutput,
|
|
33
97
|
mermaid: mermaidOutput,
|
|
34
98
|
human: humanReadableOutput,
|
|
35
99
|
gui: async ({ queryString }, _, conf) => {
|
|
36
|
-
await startGUI(conf,
|
|
100
|
+
await startGUI(conf, `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`);
|
|
37
101
|
},
|
|
38
102
|
};
|
|
39
103
|
export const command = async (conf) => {
|
|
104
|
+
const modifiers = GraphModifier.maybeLoad(conf.options);
|
|
40
105
|
const monorepo = conf.options.monorepo;
|
|
41
|
-
const mainManifest = conf.options.packageJson.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
106
|
+
const mainManifest = conf.options.packageJson.maybeRead(conf.options.projectRoot);
|
|
107
|
+
let graph;
|
|
108
|
+
let securityArchive;
|
|
109
|
+
// optionally load the cwd graph if we found a package.json file
|
|
110
|
+
if (mainManifest) {
|
|
111
|
+
graph = actual.load({
|
|
112
|
+
...conf.options,
|
|
113
|
+
mainManifest,
|
|
114
|
+
modifiers,
|
|
115
|
+
monorepo,
|
|
116
|
+
loadManifests: true,
|
|
117
|
+
});
|
|
118
|
+
securityArchive = await SecurityArchive.start({
|
|
119
|
+
nodes: [...graph.nodes.values()],
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
// retrieve default values and set up host contexts
|
|
123
|
+
const defaultProjectQueryString = '*';
|
|
124
|
+
const defaultLocalScopeQueryString = ':host(local) *';
|
|
125
|
+
const positionalQueryString = conf.positionals[0];
|
|
126
|
+
const targetQueryString = conf.get('target');
|
|
127
|
+
const scopeQueryString = conf.get('scope');
|
|
128
|
+
const queryString = targetQueryString || positionalQueryString;
|
|
129
|
+
const hostContexts = await createHostContextsMap(conf);
|
|
62
130
|
const importers = new Set();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
131
|
+
const scopeIDs = [];
|
|
132
|
+
// Handle --scope option to add scope nodes as importers
|
|
133
|
+
let scopeNodes;
|
|
134
|
+
if (scopeQueryString) {
|
|
135
|
+
// Run scope query to get all matching nodes
|
|
136
|
+
/* c8 ignore start */
|
|
137
|
+
const edges = graph?.edges ?? new Set();
|
|
138
|
+
const nodes = graph?.nodes ?
|
|
139
|
+
new Set(graph.nodes.values())
|
|
140
|
+
: new Set();
|
|
141
|
+
const importers = graph?.importers ?? new Set();
|
|
142
|
+
/* c8 ignore stop */
|
|
143
|
+
const scopeQuery = new Query({
|
|
144
|
+
edges,
|
|
145
|
+
nodes,
|
|
146
|
+
importers,
|
|
147
|
+
securityArchive,
|
|
148
|
+
hostContexts,
|
|
149
|
+
});
|
|
150
|
+
const { nodes: resultNodes } = await scopeQuery.search(scopeQueryString, {
|
|
151
|
+
signal: new AbortController().signal,
|
|
152
|
+
});
|
|
153
|
+
scopeNodes = resultNodes;
|
|
154
|
+
}
|
|
155
|
+
if (scopeQueryString && scopeNodes) {
|
|
156
|
+
// Add all scope nodes to importers Set (treat them as top-level items)
|
|
157
|
+
for (const queryNode of scopeNodes) {
|
|
158
|
+
importers.add(asNode(queryNode));
|
|
68
159
|
}
|
|
69
160
|
}
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
161
|
+
else if ('workspace' in conf.values) {
|
|
162
|
+
// if in a workspace environment, select only the specified
|
|
163
|
+
// workspaces as top-level items
|
|
164
|
+
if (monorepo && graph) {
|
|
165
|
+
for (const workspace of monorepo.filter(conf.values)) {
|
|
166
|
+
const w = graph.nodes.get(workspace.id);
|
|
167
|
+
if (w) {
|
|
168
|
+
importers.add(w);
|
|
169
|
+
scopeIDs.push(workspace.id);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
73
172
|
}
|
|
74
173
|
}
|
|
174
|
+
// retrieve the selected nodes and edges
|
|
175
|
+
const edges_ = graph?.edges ?? new Set();
|
|
176
|
+
const nodes_ = graph?.nodes ?
|
|
177
|
+
new Set(graph.nodes.values())
|
|
178
|
+
: new Set();
|
|
179
|
+
const importers_ = importers.size === 0 && graph ?
|
|
180
|
+
new Set([graph.mainImporter])
|
|
181
|
+
: importers;
|
|
182
|
+
const q = new Query({
|
|
183
|
+
edges: edges_,
|
|
184
|
+
nodes: nodes_,
|
|
185
|
+
importers: importers_,
|
|
186
|
+
securityArchive,
|
|
187
|
+
hostContexts,
|
|
188
|
+
});
|
|
189
|
+
const query = queryString ||
|
|
190
|
+
(graph ? defaultProjectQueryString : defaultLocalScopeQueryString);
|
|
191
|
+
const { edges, nodes, importers: queryResultImporters, } = await q.search(query, {
|
|
192
|
+
signal: new AbortController().signal,
|
|
193
|
+
scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,
|
|
194
|
+
});
|
|
195
|
+
if (!validateExpectedResult(conf, edges)) {
|
|
196
|
+
throw error('Unexpected number of items', {
|
|
197
|
+
found: edges.length,
|
|
198
|
+
wanted: conf.values['expect-results'],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
75
201
|
return {
|
|
76
|
-
importers
|
|
202
|
+
importers: importers.size === 0 ?
|
|
203
|
+
new Set(queryResultImporters)
|
|
204
|
+
: importers,
|
|
77
205
|
edges,
|
|
78
206
|
nodes,
|
|
79
|
-
highlightSelection: !!
|
|
80
|
-
queryString: queryString ||
|
|
207
|
+
highlightSelection: !!(targetQueryString || positionalQueryString),
|
|
208
|
+
queryString: queryString ||
|
|
209
|
+
(graph ?
|
|
210
|
+
defaultProjectQueryString
|
|
211
|
+
: defaultLocalScopeQueryString),
|
|
81
212
|
};
|
|
82
213
|
};
|
|
83
214
|
//# sourceMappingURL=query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../../src/commands/query.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,MAAM,EACN,mBAAmB,EACnB,UAAU,EACV,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAG1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC,EAAE,EAAE,+CAA+C,CAAC;IAC5D,WAAW,EACT,0DAA0D;IAC5D,QAAQ,EAAE;QACR,CAAC,QAAQ,CAAC,EAAE;YACV,WAAW,EAAE,oCAAoC;SAClD;QACD,CAAC,wBAAwB,CAAC,EAAE;YAC1B,WAAW,EAAE,2CAA2C;SACzD;QACD,CAAC,uCAAuC,CAAC,EAAE;YACzC,WAAW,EACT,6DAA6D;SAChE;QACD,CAAC,qBAAqB,CAAC,EAAE;YACvB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,IAAI,CAAC,OAAO;QACzB,eAAe;KAChB,CAAC,CAAA;IAEF,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,MAAM,KAAK,CAAC,MAAM,CACzC,WAAW,IAAI,kBAAkB,CAClC,CAAA;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAAQ,CAAA;IACjC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,CAAC,GAAqB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;YACzD,IAAI,CAAC;gBAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACvC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO;QACL,SAAS;QACT,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,WAAW;QACjC,WAAW,EAAE,WAAW,IAAI,kBAAkB;KAC/C,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n} from '@vltpkg/graph'\nimport {\n actual,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n} from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'query',\n usage: ['', '<query> --view=[human | json | mermaid | gui]'],\n description:\n 'List installed dependencies matching the provided query.',\n examples: {\n [`'#foo'`]: {\n description: 'Query packages with the name \"foo\"',\n },\n [`'*.workspace > *.peer'`]: {\n description: 'Query all peer dependencies of workspaces',\n },\n [`':project > *:attr(scripts, [build])'`]: {\n description:\n 'Query all direct project dependencies with a \"build\" script',\n },\n [`'[name^=\"@vltpkg\"]'`]: {\n description:\n 'Query packages with names starting with \"@vltpkg\"',\n },\n },\n options: {\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\ntype QueryResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n '/explore?query=' + encodeURIComponent(queryString),\n )\n },\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.read(\n conf.options.projectRoot,\n )\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo,\n loadManifests: true,\n })\n\n const defaultQueryString = '*'\n const queryString = conf.positionals[0]\n const securityArchive =\n queryString && Query.hasSecuritySelectors(queryString) ?\n await SecurityArchive.start({\n graph,\n specOptions: conf.options,\n })\n : undefined\n const query = new Query({\n graph,\n specOptions: conf.options,\n securityArchive,\n })\n\n const { edges, nodes } = await query.search(\n queryString || defaultQueryString,\n )\n\n const importers = new Set<Node>()\n if (monorepo) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) importers.add(w)\n }\n }\n if (importers.size === 0) {\n for (const importer of graph.importers) {\n importers.add(importer)\n }\n }\n\n return {\n importers,\n edges,\n nodes,\n highlightSelection: !!queryString,\n queryString: queryString || defaultQueryString,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"query.js","source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AAS,EAAE,UAAU;QACrB,eAAe;QACf,YAAY;KACb,CAAC,CAAA;IACF,MAAM,KAAK,GACT,WAAW;QACX,CAAC,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,SAAS,EAAE,oBAAoB,GAChC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE;QACxB,MAAM,EAAE,IAAI,eAAe,EAAE,CAAC,MAAM;QACpC,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;KACrD,CAAC,CAAA;IAEF,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,CAAC,4BAA4B,EAAE;YACxC,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC;SACtC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EACP,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC;YACpB,IAAI,GAAG,CAAC,oBAAoB,CAAC;YAC/B,CAAC,CAAC,SAAS;QACb,KAAK;QACL,KAAK;QACL,kBAAkB,EAAE,CAAC,CAAC,CACpB,iBAAiB,IAAI,qBAAqB,CAC3C;QACD,WAAW,EACT,WAAW;YACX,CAAC,KAAK,CAAC,CAAC;gBACN,yBAAyB;gBAC3B,CAAC,CAAC,4BAA4B,CAAC;KAClC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import {\n actual,\n asNode,\n humanReadableOutput,\n jsonOutput,\n mermaidOutput,\n GraphModifier,\n} from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport LZString from 'lz-string'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { startGUI } from '../start-gui.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport type {\n HumanReadableOutputGraph,\n JSONOutputGraph,\n MermaidOutputGraph,\n Node,\n Graph,\n} from '@vltpkg/graph'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { EdgeLike, NodeLike } from '@vltpkg/types'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { LoadedConfig } from '../config/index.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'query',\n usage: [\n '',\n '<query> --view=<human | json | mermaid | gui>',\n '<query> --expect-results=<comparison string>',\n '--target=<query> --view=<human | json | mermaid | gui>',\n ],\n description: `List installed dependencies matching the provided query.\n\n The vlt Dependency Selector Syntax is a CSS-like query language that\n allows you to filter installed dependencies using a variety of metadata\n in the form of CSS-like attributes, pseudo selectors & combinators.\n\n The --scope and --target options accepts DSS query selectors to filter\n packages. Using --scope, you can specify which packages to treat as the\n top-level items in the output graph. The --target option can be used as\n an alternative to positional arguments, it allows you to filter what\n dependencies to include in the output. Using both options allows you to\n render subgraphs of the dependency graph.\n\n Defaults to listing all dependencies of the project root and workspaces.`,\n\n examples: {\n [`'#foo'`]: {\n description: 'Query dependencies declared as \"foo\"',\n },\n [`'*:workspace > *:peer'`]: {\n description: 'Query all peer dependencies of workspaces',\n },\n [`':project > *:attr(scripts, [build])'`]: {\n description:\n 'Query all direct project dependencies with a \"build\" script',\n },\n [`'[name^=\"@vltpkg\"]'`]: {\n description:\n 'Query packages with names starting with \"@vltpkg\"',\n },\n [`'*:license(copyleft) --expect-results=0'`]: {\n description: 'Errors if a copyleft licensed package is found',\n },\n '--scope=\":root > #dependency-name\"': {\n description:\n 'Defines a direct dependency as the output top-level scope',\n },\n [`'--target=\"*\"'`]: {\n description: 'Query all dependencies using the target option',\n },\n [`'--target=\":workspace > *:peer\"'`]: {\n description:\n 'Query all peer dependencies of workspaces using target option',\n },\n },\n options: {\n 'expect-results': {\n value: '[number | string]',\n description:\n 'Sets an expected number of resulting items. Errors if the number of resulting items does not match the set value. Accepts a specific numeric value or a string value starting with either \">\", \"<\", \">=\" or \"<=\" followed by a numeric value to be compared.',\n },\n scope: {\n value: '<query>',\n description:\n 'Query selector to select top-level packages using the DSS query language syntax.',\n },\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\n view: {\n value: '[human | json | mermaid | gui]',\n description:\n 'Output format. Defaults to human-readable or json if no tty.',\n },\n },\n })\n\ntype QueryResult = JSONOutputGraph &\n MermaidOutputGraph &\n HumanReadableOutputGraph & { queryString: string }\n\nconst validateExpectedResult = (\n conf: LoadedConfig,\n edges: EdgeLike[],\n): boolean => {\n const expectResults = conf.values['expect-results']\n if (expectResults?.startsWith('>=')) {\n return edges.length >= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('<=')) {\n return edges.length <= parseInt(expectResults.slice(2).trim(), 10)\n } else if (expectResults?.startsWith('>')) {\n return edges.length > parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults?.startsWith('<')) {\n return edges.length < parseInt(expectResults.slice(1).trim(), 10)\n } else if (expectResults) {\n return edges.length === parseInt(expectResults.trim(), 10)\n }\n return true\n}\n\nexport const views = {\n json: jsonOutput,\n mermaid: mermaidOutput,\n human: humanReadableOutput,\n gui: async ({ queryString }, _, conf) => {\n await startGUI(\n conf,\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`,\n )\n },\n} as const satisfies Views<QueryResult>\n\nexport const command: CommandFn<QueryResult> = async conf => {\n const modifiers = GraphModifier.maybeLoad(conf.options)\n const monorepo = conf.options.monorepo\n const mainManifest = conf.options.packageJson.maybeRead(\n conf.options.projectRoot,\n )\n let graph: Graph | undefined\n let securityArchive: SecurityArchive | undefined\n\n // optionally load the cwd graph if we found a package.json file\n if (mainManifest) {\n graph = actual.load({\n ...conf.options,\n mainManifest,\n modifiers,\n monorepo,\n loadManifests: true,\n })\n securityArchive = await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n }\n\n // retrieve default values and set up host contexts\n const defaultProjectQueryString = '*'\n const defaultLocalScopeQueryString = ':host(local) *'\n const positionalQueryString = conf.positionals[0]\n const targetQueryString = conf.get('target')\n const scopeQueryString = conf.get('scope')\n const queryString = targetQueryString || positionalQueryString\n const hostContexts = await createHostContextsMap(conf)\n const importers = new Set<Node>()\n const scopeIDs: DepID[] = []\n\n // Handle --scope option to add scope nodes as importers\n let scopeNodes\n if (scopeQueryString) {\n // Run scope query to get all matching nodes\n /* c8 ignore start */\n const edges = graph?.edges ?? new Set()\n const nodes =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers = graph?.importers ?? new Set()\n /* c8 ignore stop */\n const scopeQuery = new Query({\n edges,\n nodes,\n importers,\n securityArchive,\n hostContexts,\n })\n const { nodes: resultNodes } = await scopeQuery.search(\n scopeQueryString,\n {\n signal: new AbortController().signal,\n },\n )\n scopeNodes = resultNodes\n }\n\n if (scopeQueryString && scopeNodes) {\n // Add all scope nodes to importers Set (treat them as top-level items)\n for (const queryNode of scopeNodes) {\n importers.add(asNode(queryNode))\n }\n } else if ('workspace' in conf.values) {\n // if in a workspace environment, select only the specified\n // workspaces as top-level items\n if (monorepo && graph) {\n for (const workspace of monorepo.filter(conf.values)) {\n const w: Node | undefined = graph.nodes.get(workspace.id)\n if (w) {\n importers.add(w)\n scopeIDs.push(workspace.id)\n }\n }\n }\n }\n\n // retrieve the selected nodes and edges\n const edges_ = graph?.edges ?? new Set()\n const nodes_ =\n graph?.nodes ?\n new Set<NodeLike>(graph.nodes.values())\n : new Set<NodeLike>()\n const importers_ =\n importers.size === 0 && graph ?\n new Set([graph.mainImporter])\n : importers\n const q = new Query({\n edges: edges_,\n nodes: nodes_,\n importers: importers_,\n securityArchive,\n hostContexts,\n })\n const query =\n queryString ||\n (graph ? defaultProjectQueryString : defaultLocalScopeQueryString)\n const {\n edges,\n nodes,\n importers: queryResultImporters,\n } = await q.search(query, {\n signal: new AbortController().signal,\n scopeIDs: scopeIDs.length > 0 ? scopeIDs : undefined,\n })\n\n if (!validateExpectedResult(conf, edges)) {\n throw error('Unexpected number of items', {\n found: edges.length,\n wanted: conf.values['expect-results'],\n })\n }\n\n return {\n importers:\n importers.size === 0 ?\n new Set(queryResultImporters)\n : importers,\n edges,\n nodes,\n highlightSelection: !!(\n targetQueryString || positionalQueryString\n ),\n queryString:\n queryString ||\n (graph ?\n defaultProjectQueryString\n : defaultLocalScopeQueryString),\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExecResult } from '../exec-command.ts';
|
|
2
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
export { views } from '../exec-command.ts';
|
|
3
4
|
export declare const usage: CommandUsage;
|
|
4
5
|
export declare const command: CommandFn<ExecResult>;
|
|
5
6
|
//# sourceMappingURL=run-exec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-exec.d.ts","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AAEJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACa,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runExec, runExecFG } from '@vltpkg/run';
|
|
2
2
|
import { commandUsage } from "../config/usage.js";
|
|
3
3
|
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
4
5
|
export const usage = () => commandUsage({
|
|
5
6
|
command: 'run-exec',
|
|
6
7
|
usage: '[command ...]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-exec.js","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"run-exec.js","sourceRoot":"","sources":["../../../src/commands/run-exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,UAAU;IACnB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;;;mEAGkD;CAChE,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { runExec, runExecFG } from '@vltpkg/run'\nimport { commandUsage } from '../config/usage.ts'\nimport type { ExecResult } from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run-exec',\n usage: '[command ...]',\n description: `If the first argument is a defined script in package.json, then this is\n equivalent to \\`vlt run\\`.\n\n If not, then this is equivalent to \\`vlt exec\\`.`,\n })\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new ExecCommand(conf, runExec, runExecFG).run()\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExecResult } from '../exec-command.ts';
|
|
2
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
export { views } from '../exec-command.ts';
|
|
3
4
|
export declare const usage: CommandUsage;
|
|
4
5
|
export declare const command: CommandFn<ExecResult>;
|
|
5
6
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,UAAU,EAGX,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAQhB,CAAA;AA2BJ,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CACR,CAAA"}
|
package/dist/esm/commands/run.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PackageJson } from '@vltpkg/package-json';
|
|
2
1
|
import { run, runFG } from '@vltpkg/run';
|
|
3
2
|
import { commandUsage } from "../config/usage.js";
|
|
4
3
|
import { ExecCommand } from "../exec-command.js";
|
|
5
|
-
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
6
5
|
export const usage = () => commandUsage({
|
|
7
6
|
command: 'run',
|
|
8
7
|
usage: '<script> [args ...]',
|
|
@@ -15,24 +14,22 @@ class RunCommand extends ExecCommand {
|
|
|
15
14
|
constructor(conf) {
|
|
16
15
|
super(conf, run, runFG);
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
// do not provide the interactive shell arg, just do nothing
|
|
18
|
+
// so that it falls back up to the noArgsSingle() method
|
|
19
|
+
defaultArg0() { }
|
|
20
|
+
noArgsSingle() {
|
|
19
21
|
// called when there's no arg0, with a single workspace or root
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const mani = packageJson.read(cwd);
|
|
24
|
-
stdout('Scripts available:', mani.scripts);
|
|
25
|
-
return undefined;
|
|
22
|
+
const cwd = this.getCwd();
|
|
23
|
+
const { scripts = {} } = this.conf.options.packageJson.read(cwd);
|
|
24
|
+
return scripts;
|
|
26
25
|
}
|
|
27
26
|
noArgsMulti() {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
stdout('Scripts available:');
|
|
33
|
-
for (const [ws, scripts] of m.runSync(ws => ws.manifest.scripts)) {
|
|
34
|
-
stdout(ws.path, scripts);
|
|
27
|
+
const scripts = {};
|
|
28
|
+
for (const { label, manifest } of this.getTargets()) {
|
|
29
|
+
if (manifest.scripts)
|
|
30
|
+
scripts[label] = manifest.scripts;
|
|
35
31
|
}
|
|
32
|
+
return scripts;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
export const command = async (conf) => await new RunCommand(conf).run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE;;;sCAGqB;CACnC,CAAC,CAAA;AAEJ,MAAM,UAAW,SAAQ,WAAqC;IAC5D,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;IAED,4DAA4D;IAC5D,wDAAwD;IACxD,WAAW,KAAe,CAAC;IAE3B,YAAY;QACV,+DAA+D;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QACzB,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,WAAW;QACT,MAAM,OAAO,GAAmB,EAAE,CAAA;QAClC,KAAK,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACpD,IAAI,QAAQ,CAAC,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAA;QACzD,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { run, runFG } from '@vltpkg/run'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ExecResult,\n MultiScriptSet,\n ScriptSet,\n} from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run',\n usage: '<script> [args ...]',\n description: `Run a script defined in 'package.json', passing along any extra\n arguments. Note that vlt config values must be specified *before*\n the script name, because everything after that is handed off to\n the script process.`,\n })\n\nclass RunCommand extends ExecCommand<typeof run, typeof runFG> {\n constructor(conf: LoadedConfig) {\n super(conf, run, runFG)\n }\n\n // do not provide the interactive shell arg, just do nothing\n // so that it falls back up to the noArgsSingle() method\n defaultArg0(): undefined {}\n\n noArgsSingle(): ScriptSet {\n // called when there's no arg0, with a single workspace or root\n const cwd = this.getCwd()\n const { scripts = {} } = this.conf.options.packageJson.read(cwd)\n return scripts\n }\n\n noArgsMulti(): MultiScriptSet {\n const scripts: MultiScriptSet = {}\n for (const { label, manifest } of this.getTargets()) {\n if (manifest.scripts) scripts[label] = manifest.scripts\n }\n return scripts\n }\n}\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new RunCommand(conf).run()\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export declare const usage: CommandUsage;
|
|
3
|
+
export type ServeResult = {
|
|
4
|
+
guiPort: number;
|
|
5
|
+
registryPort: number;
|
|
6
|
+
uiURL: string;
|
|
7
|
+
registryURL: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const views: {
|
|
10
|
+
readonly human: (result: ServeResult) => void;
|
|
11
|
+
readonly json: (result: ServeResult) => ServeResult;
|
|
12
|
+
};
|
|
13
|
+
export declare const command: CommandFn<ServeResult>;
|
|
14
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAyBhB,CAAA;AAEJ,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,KAAK;6BACA,WAAW;4BAcZ,WAAW;CACW,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAuE1C,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { onExit } from 'signal-exit';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { exec, execFG } from '@vltpkg/run';
|
|
4
|
+
import * as vlx from '@vltpkg/vlx';
|
|
5
|
+
import { ExecCommand } from "../exec-command.js";
|
|
6
|
+
import { commandUsage } from "../config/usage.js";
|
|
7
|
+
import { stdout, styleTextStdout } from "../output.js";
|
|
8
|
+
import { startGUI } from "../start-gui.js";
|
|
9
|
+
export const usage = () => commandUsage({
|
|
10
|
+
command: 'serve',
|
|
11
|
+
usage: '',
|
|
12
|
+
description: `Start a local development server that runs both the browser-based
|
|
13
|
+
UI server and the VSR (vlt serverless registry) registry instance.
|
|
14
|
+
|
|
15
|
+
The UI server will start first on port 8000 (or the next
|
|
16
|
+
available port), and then the VSR registry will start on
|
|
17
|
+
port 1337.
|
|
18
|
+
|
|
19
|
+
This allows you to develop and test the full vlt ecosystem
|
|
20
|
+
locally, including package publishing and installation from
|
|
21
|
+
your local registry.`,
|
|
22
|
+
options: {
|
|
23
|
+
port: {
|
|
24
|
+
value: '<number>',
|
|
25
|
+
description: 'Port for the broser-based UI server (default: 8000)',
|
|
26
|
+
},
|
|
27
|
+
'registry-port': {
|
|
28
|
+
value: '<number>',
|
|
29
|
+
description: 'Port for the VSR registry (default: 1337)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const views = {
|
|
34
|
+
human: (result) => {
|
|
35
|
+
stdout('');
|
|
36
|
+
stdout(styleTextStdout(['bgWhiteBright', 'black', 'bold'], ' vlt serve running '));
|
|
37
|
+
stdout('');
|
|
38
|
+
stdout(`UI Server: ${result.uiURL}`);
|
|
39
|
+
stdout(`VSR Registry: ${result.registryURL}`);
|
|
40
|
+
stdout('');
|
|
41
|
+
stdout('Press Ctrl+C to stop both servers');
|
|
42
|
+
},
|
|
43
|
+
json: (result) => result,
|
|
44
|
+
};
|
|
45
|
+
export const command = async (conf) => {
|
|
46
|
+
const registryPort = Number(conf.get('registry-port') ?? 1337);
|
|
47
|
+
// Start the GUI server first
|
|
48
|
+
stdout('Starting UI server...');
|
|
49
|
+
const server = await startGUI(conf, '/');
|
|
50
|
+
const actualGuiPort = server.port;
|
|
51
|
+
if (!actualGuiPort) {
|
|
52
|
+
throw error('missing ui server port');
|
|
53
|
+
}
|
|
54
|
+
// Start the VSR registry with the GUI server port
|
|
55
|
+
stdout('Starting VSR registry...');
|
|
56
|
+
// Prepare environment for VSR registry
|
|
57
|
+
const registryEnv = {
|
|
58
|
+
ARG_DAEMON: 'true',
|
|
59
|
+
DAEMON_START_SERVER: 'false',
|
|
60
|
+
DAEMON_PORT: String(actualGuiPort),
|
|
61
|
+
DAEMON_URL: `http://localhost:${actualGuiPort}`,
|
|
62
|
+
};
|
|
63
|
+
// runs the exec command internally
|
|
64
|
+
/* c8 ignore start */
|
|
65
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
66
|
+
String(conf.get('allow-scripts'))
|
|
67
|
+
: ':not(*)';
|
|
68
|
+
/* c8 ignore stop */
|
|
69
|
+
const arg0 = await vlx.resolve(['@vltpkg/vsr'], {
|
|
70
|
+
...conf.options,
|
|
71
|
+
query: undefined,
|
|
72
|
+
allowScripts,
|
|
73
|
+
}, async () => 'y');
|
|
74
|
+
if (arg0) {
|
|
75
|
+
conf.positionals[0] = arg0;
|
|
76
|
+
}
|
|
77
|
+
delete conf.options['script-shell'];
|
|
78
|
+
const ex = new ExecCommand(conf, exec, execFG);
|
|
79
|
+
ex.env = registryEnv;
|
|
80
|
+
await ex.run();
|
|
81
|
+
// Handle process termination
|
|
82
|
+
/* c8 ignore start */
|
|
83
|
+
const cleanup = () => {
|
|
84
|
+
stdout('\nShutting down servers...');
|
|
85
|
+
try {
|
|
86
|
+
void server.close();
|
|
87
|
+
stdout('UI server stopped');
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
};
|
|
91
|
+
onExit(cleanup);
|
|
92
|
+
/* c8 ignore stop */
|
|
93
|
+
// Return the server information
|
|
94
|
+
const result = {
|
|
95
|
+
guiPort: actualGuiPort,
|
|
96
|
+
registryPort,
|
|
97
|
+
uiURL: `http://localhost:${actualGuiPort}`,
|
|
98
|
+
registryURL: `http://localhost:${registryPort}`,
|
|
99
|
+
};
|
|
100
|
+
// This return will never be reached due to the infinite promise above
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAK1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;;;;;;;uCASsB;IACnC,OAAO,EAAE;QACP,IAAI,EAAE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Z,KAAK,EAAE,oBAAoB,aAAa,EAAE;QAC1C,WAAW,EAAE,oBAAoB,YAAY,EAAE;KAChD,CAAA;IAED,sEAAsE;IACtE,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { error } from '@vltpkg/error-cause'\nimport { exec, execFG } from '@vltpkg/run'\nimport * as vlx from '@vltpkg/vlx'\nimport { ExecCommand } from '../exec-command.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport { stdout, styleTextStdout } from '../output.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'serve',\n usage: '',\n description: `Start a local development server that runs both the browser-based\n UI server and the VSR (vlt serverless registry) registry instance.\n\n The UI server will start first on port 8000 (or the next\n available port), and then the VSR registry will start on\n port 1337.\n\n This allows you to develop and test the full vlt ecosystem\n locally, including package publishing and installation from\n your local registry.`,\n options: {\n port: {\n value: '<number>',\n description:\n 'Port for the broser-based UI server (default: 8000)',\n },\n 'registry-port': {\n value: '<number>',\n description: 'Port for the VSR registry (default: 1337)',\n },\n },\n })\n\nexport type ServeResult = {\n guiPort: number\n registryPort: number\n uiURL: string\n registryURL: string\n}\n\nexport const views = {\n human: (result: ServeResult) => {\n stdout('')\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ' vlt serve running ',\n ),\n )\n stdout('')\n stdout(`UI Server: ${result.uiURL}`)\n stdout(`VSR Registry: ${result.registryURL}`)\n stdout('')\n stdout('Press Ctrl+C to stop both servers')\n },\n json: (result: ServeResult) => result,\n} as const satisfies Views<ServeResult>\n\nexport const command: CommandFn<ServeResult> = async (\n conf: LoadedConfig,\n) => {\n const registryPort = Number(conf.get('registry-port') ?? 1337)\n\n // Start the GUI server first\n stdout('Starting UI server...')\n const server = await startGUI(conf, '/')\n const actualGuiPort = server.port\n\n if (!actualGuiPort) {\n throw error('missing ui server port')\n }\n\n // Start the VSR registry with the GUI server port\n stdout('Starting VSR registry...')\n\n // Prepare environment for VSR registry\n const registryEnv = {\n ARG_DAEMON: 'true',\n DAEMON_START_SERVER: 'false',\n DAEMON_PORT: String(actualGuiPort),\n DAEMON_URL: `http://localhost:${actualGuiPort}`,\n }\n\n // runs the exec command internally\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const arg0 = await vlx.resolve(\n ['@vltpkg/vsr'],\n {\n ...conf.options,\n query: undefined,\n allowScripts,\n },\n async () => 'y',\n )\n if (arg0) {\n conf.positionals[0] = arg0\n }\n delete conf.options['script-shell']\n const ex = new ExecCommand(conf, exec, execFG)\n ex.env = registryEnv\n await ex.run()\n\n // Handle process termination\n /* c8 ignore start */\n const cleanup = () => {\n stdout('\\nShutting down servers...')\n try {\n void server.close()\n stdout('UI server stopped')\n } catch {}\n }\n onExit(cleanup)\n /* c8 ignore stop */\n\n // Return the server information\n const result: ServeResult = {\n guiPort: actualGuiPort,\n registryPort,\n uiURL: `http://localhost:${actualGuiPort}`,\n registryURL: `http://localhost:${registryPort}`,\n }\n\n // This return will never be reached due to the infinite promise above\n return result\n}\n"]}
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import type { Graph } from '@vltpkg/graph';
|
|
2
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
-
import
|
|
3
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
4
|
+
export type UninstallResult = {
|
|
5
|
+
/**
|
|
6
|
+
* The resulting graph structure at the end of an uninstall.
|
|
7
|
+
*/
|
|
8
|
+
graph: Graph;
|
|
9
|
+
};
|
|
4
10
|
export declare const usage: CommandUsage;
|
|
5
|
-
export declare const views:
|
|
6
|
-
|
|
11
|
+
export declare const views: {
|
|
12
|
+
readonly json: (i: UninstallResult) => import("@vltpkg/graph").LockfileData;
|
|
13
|
+
readonly human: typeof InstallReporter;
|
|
14
|
+
};
|
|
15
|
+
export declare const command: CommandFn<UninstallResult>;
|
|
7
16
|
//# sourceMappingURL=uninstall.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGyB,CAAA;AAE3C,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,eAAe,CAc9C,CAAA"}
|
|
@@ -9,13 +9,18 @@ export const usage = () => commandUsage({
|
|
|
9
9
|
vlt-lock.json and package.json appropriately.`,
|
|
10
10
|
});
|
|
11
11
|
export const views = {
|
|
12
|
-
json:
|
|
12
|
+
json: i => i.graph.toJSON(),
|
|
13
13
|
human: InstallReporter,
|
|
14
14
|
};
|
|
15
15
|
export const command = async (conf) => {
|
|
16
16
|
const monorepo = conf.options.monorepo;
|
|
17
17
|
const { remove } = parseRemoveArgs(conf, monorepo);
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/* c8 ignore start */
|
|
19
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
20
|
+
String(conf.get('allow-scripts'))
|
|
21
|
+
: ':not(*)';
|
|
22
|
+
/* c8 ignore stop */
|
|
23
|
+
const { graph } = await uninstall({ ...conf.options, allowScripts }, remove);
|
|
24
|
+
return { graph };
|
|
20
25
|
};
|
|
21
26
|
//# sourceMappingURL=uninstall.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAUvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;gEAC+C;CAC7D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,eAAe;CACmB,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAClD,qBAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAC/B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,EACjC,MAAM,CACP,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { uninstall } from '@vltpkg/graph'\nimport type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { parseRemoveArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\n\nexport type UninstallResult = {\n /**\n * The resulting graph structure at the end of an uninstall.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'uninstall',\n usage: '[package ...]',\n description: `The opposite of \\`vlt install\\`. Removes deps and updates\n vlt-lock.json and package.json appropriately.`,\n })\n\nexport const views = {\n json: i => i.graph.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<UninstallResult>\n\nexport const command: CommandFn<UninstallResult> = async conf => {\n const monorepo = conf.options.monorepo\n const { remove } = parseRemoveArgs(conf, monorepo)\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { graph } = await uninstall(\n { ...conf.options, allowScripts },\n remove,\n )\n return { graph }\n}\n"]}
|