@vltpkg/cli-sdk 0.0.0-30 → 0.0.0-32
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/ci.d.ts +5 -4
- package/dist/esm/commands/ci.d.ts.map +1 -1
- package/dist/esm/commands/ci.js +6 -3
- package/dist/esm/commands/ci.js.map +1 -1
- 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 +379 -58
- 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.js +12 -0
- package/dist/esm/commands/exec-cache.js.map +1 -1
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +6 -0
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts +2 -1
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +35 -6
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +21 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +21 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/serve.d.ts.map +1 -1
- package/dist/esm/commands/serve.js +6 -0
- package/dist/esm/commands/serve.js.map +1 -1
- package/dist/esm/commands/uninstall.d.ts +8 -2
- 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 +7 -3
- package/dist/esm/commands/update.d.ts.map +1 -1
- package/dist/esm/commands/update.js +19 -3
- package/dist/esm/commands/update.js.map +1 -1
- package/dist/esm/config/definition.d.ts +16 -2
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +30 -6
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +11 -2
- package/dist/esm/start-gui.js.map +1 -1
- package/package.json +26 -25
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
3
|
+
import { Spec } from '@vltpkg/spec';
|
|
4
|
+
import { urlOpen } from '@vltpkg/url-open';
|
|
5
|
+
import { actual } from '@vltpkg/graph';
|
|
6
|
+
import { Query } from '@vltpkg/query';
|
|
7
|
+
import { SecurityArchive } from '@vltpkg/security-archive';
|
|
8
|
+
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
9
|
+
import { commandUsage } from "../config/usage.js";
|
|
10
|
+
import hostedGitInfo from 'hosted-git-info';
|
|
11
|
+
const { fromUrl: hostedGitInfoFromUrl } = hostedGitInfo;
|
|
12
|
+
export const usage = () => commandUsage({
|
|
13
|
+
command: 'docs',
|
|
14
|
+
usage: ['[<spec>]', '[--target=<query>]'],
|
|
15
|
+
description: `Open documentation for a package in a web browser.
|
|
16
|
+
Reads repository information from package.json or fetches
|
|
17
|
+
manifest data for the specified package.`,
|
|
18
|
+
options: {
|
|
19
|
+
target: {
|
|
20
|
+
value: '<query>',
|
|
21
|
+
description: 'Query selector to filter packages using DSS syntax.',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
examples: {
|
|
25
|
+
'': {
|
|
26
|
+
description: 'Open docs for the current package (reads local package.json)',
|
|
27
|
+
},
|
|
28
|
+
'abbrev@2.0.0': {
|
|
29
|
+
description: 'Open docs for a specific package version',
|
|
30
|
+
},
|
|
31
|
+
'--target=":root > *"': {
|
|
32
|
+
description: 'List documentation URLs for all direct dependencies',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
export const views = {
|
|
37
|
+
human: r => {
|
|
38
|
+
if (Array.isArray(r)) {
|
|
39
|
+
let msg = 'Multiple package docs found:\n';
|
|
40
|
+
msg += r.map(item => `• ${item.name}: ${item.url}`).join('\n');
|
|
41
|
+
return msg;
|
|
42
|
+
}
|
|
43
|
+
return '';
|
|
44
|
+
},
|
|
45
|
+
json: r => r,
|
|
46
|
+
};
|
|
47
|
+
const getUrlFromManifest = (manifest) => {
|
|
48
|
+
const { name, homepage, repository } = manifest;
|
|
49
|
+
if (!name) {
|
|
50
|
+
throw error('No package name found');
|
|
51
|
+
}
|
|
52
|
+
// Extract repository URL
|
|
53
|
+
let url;
|
|
54
|
+
if (homepage) {
|
|
55
|
+
url = homepage;
|
|
56
|
+
}
|
|
57
|
+
else if (repository) {
|
|
58
|
+
const repoUrl = typeof repository === 'string' ? repository
|
|
59
|
+
: typeof repository === 'object' && 'url' in repository ?
|
|
60
|
+
repository.url
|
|
61
|
+
: /* c8 ignore next */ undefined;
|
|
62
|
+
if (repoUrl) {
|
|
63
|
+
// Try to get hosted git info
|
|
64
|
+
const info = hostedGitInfoFromUrl(repoUrl.replace(/^git\+/, ''));
|
|
65
|
+
if (info && typeof info.docs === 'function') {
|
|
66
|
+
url = info.docs();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Fallback to npmjs.com package page
|
|
71
|
+
if (!url) {
|
|
72
|
+
url = `https://www.npmjs.com/package/${name}`;
|
|
73
|
+
}
|
|
74
|
+
return url;
|
|
75
|
+
};
|
|
76
|
+
export const command = async (conf) => {
|
|
77
|
+
const { projectRoot, packageJson } = conf.options;
|
|
78
|
+
const targetOption = conf.get('target');
|
|
79
|
+
// Handle --target query
|
|
80
|
+
if (targetOption) {
|
|
81
|
+
const mainManifest = packageJson.maybeRead(projectRoot);
|
|
82
|
+
if (!mainManifest) {
|
|
83
|
+
throw error('No package.json found in project root', {
|
|
84
|
+
path: projectRoot,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const graph = actual.load({
|
|
88
|
+
...conf.options,
|
|
89
|
+
mainManifest,
|
|
90
|
+
monorepo: conf.options.monorepo,
|
|
91
|
+
loadManifests: true,
|
|
92
|
+
});
|
|
93
|
+
const securityArchive = Query.hasSecuritySelectors(targetOption) ?
|
|
94
|
+
await SecurityArchive.start({
|
|
95
|
+
nodes: [...graph.nodes.values()],
|
|
96
|
+
})
|
|
97
|
+
: undefined;
|
|
98
|
+
const hostContexts = await createHostContextsMap(conf);
|
|
99
|
+
const query = new Query({
|
|
100
|
+
nodes: new Set(graph.nodes.values()),
|
|
101
|
+
edges: graph.edges,
|
|
102
|
+
importers: graph.importers,
|
|
103
|
+
securityArchive,
|
|
104
|
+
hostContexts,
|
|
105
|
+
});
|
|
106
|
+
const { nodes } = await query.search(targetOption, {
|
|
107
|
+
signal: new AbortController().signal,
|
|
108
|
+
});
|
|
109
|
+
const results = [];
|
|
110
|
+
for (const node of nodes) {
|
|
111
|
+
if (!node.manifest)
|
|
112
|
+
continue;
|
|
113
|
+
const url = getUrlFromManifest(node.manifest);
|
|
114
|
+
results.push({
|
|
115
|
+
url,
|
|
116
|
+
name: node.name /* c8 ignore next */ ?? '(unknown)',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (results.length === 0) {
|
|
120
|
+
throw error('No packages found matching target query', {
|
|
121
|
+
found: targetOption,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// If single result, open it
|
|
125
|
+
if (results.length === 1) {
|
|
126
|
+
const result = results[0];
|
|
127
|
+
/* c8 ignore next 3 */
|
|
128
|
+
if (!result) {
|
|
129
|
+
throw error('Unexpected empty result');
|
|
130
|
+
}
|
|
131
|
+
await urlOpen(result.url);
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
// Multiple results, return the list
|
|
135
|
+
return results;
|
|
136
|
+
}
|
|
137
|
+
// read the package spec from a positional argument or local package.json
|
|
138
|
+
const specArg = conf.positionals[0];
|
|
139
|
+
const manifest = conf.positionals.length === 0 ? packageJson.read(projectRoot)
|
|
140
|
+
: specArg ?
|
|
141
|
+
await new PackageInfoClient(conf.options).manifest(Spec.parseArgs(specArg, conf.options))
|
|
142
|
+
: /* c8 ignore next */ packageJson.read(projectRoot);
|
|
143
|
+
const url = getUrlFromManifest(manifest);
|
|
144
|
+
const { name } = manifest;
|
|
145
|
+
/* c8 ignore start - getUrlFromManifest already validates name */
|
|
146
|
+
if (!name) {
|
|
147
|
+
throw error('No package name found');
|
|
148
|
+
}
|
|
149
|
+
/* c8 ignore stop */
|
|
150
|
+
// Open the URL
|
|
151
|
+
await urlOpen(url);
|
|
152
|
+
return { url, name };
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../src/commands/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjD,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,GAAG,aAAa,CAAA;AAEvD,MAAM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nimport { PackageInfoClient } from '@vltpkg/package-info'\nimport { Spec } from '@vltpkg/spec'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { actual } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { SecurityArchive } from '@vltpkg/security-archive'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { Manifest, NormalizedManifest } from '@vltpkg/types'\nimport hostedGitInfo from 'hosted-git-info'\nconst { fromUrl: hostedGitInfoFromUrl } = hostedGitInfo\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'docs',\n usage: ['[<spec>]', '[--target=<query>]'],\n description: `Open documentation for a package in a web browser.\n Reads repository information from package.json or fetches\n manifest data for the specified package.`,\n options: {\n target: {\n value: '<query>',\n description:\n 'Query selector to filter packages using DSS syntax.',\n },\n },\n examples: {\n '': {\n description:\n 'Open docs for the current package (reads local package.json)',\n },\n 'abbrev@2.0.0': {\n description: 'Open docs for a specific package version',\n },\n '--target=\":root > *\"': {\n description:\n 'List documentation URLs for all direct dependencies',\n },\n },\n })\n\ntype CommandResultSingle = {\n url: string\n name: string\n}\n\ntype CommandResultMultiple = {\n url: string\n name: string\n}[]\n\nexport type CommandResult =\n | CommandResultSingle\n | CommandResultMultiple\n\nexport const views = {\n human: r => {\n if (Array.isArray(r)) {\n let msg = 'Multiple package docs found:\\n'\n msg += r.map(item => `• ${item.name}: ${item.url}`).join('\\n')\n return msg\n }\n return ''\n },\n json: r => r,\n} as const satisfies Views<CommandResult>\n\nconst getUrlFromManifest = (\n manifest: Manifest | NormalizedManifest,\n): string => {\n const { name, homepage, repository } = manifest\n\n if (!name) {\n throw error('No package name found')\n }\n\n // Extract repository URL\n let url: string | undefined\n\n if (homepage) {\n url = homepage\n } else if (repository) {\n const repoUrl =\n typeof repository === 'string' ? repository\n : typeof repository === 'object' && 'url' in repository ?\n repository.url\n : /* c8 ignore next */ undefined\n\n if (repoUrl) {\n // Try to get hosted git info\n\n const info = hostedGitInfoFromUrl(repoUrl.replace(/^git\\+/, ''))\n\n if (info && typeof info.docs === 'function') {\n url = info.docs()\n }\n }\n }\n\n // Fallback to npmjs.com package page\n if (!url) {\n url = `https://www.npmjs.com/package/${name}`\n }\n\n return url\n}\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const { projectRoot, packageJson } = conf.options\n const targetOption = conf.get('target')\n\n // Handle --target query\n if (targetOption) {\n const mainManifest = packageJson.maybeRead(projectRoot)\n if (!mainManifest) {\n throw error('No package.json found in project root', {\n path: projectRoot,\n })\n }\n\n const graph = actual.load({\n ...conf.options,\n mainManifest,\n monorepo: conf.options.monorepo,\n loadManifests: true,\n })\n\n const securityArchive =\n Query.hasSecuritySelectors(targetOption) ?\n await SecurityArchive.start({\n nodes: [...graph.nodes.values()],\n })\n : undefined\n\n const hostContexts = await createHostContextsMap(conf)\n const query = new Query({\n nodes: new Set(graph.nodes.values()),\n edges: graph.edges,\n importers: graph.importers,\n securityArchive,\n hostContexts,\n })\n\n const { nodes } = await query.search(targetOption, {\n signal: new AbortController().signal,\n })\n\n const results: CommandResultMultiple = []\n for (const node of nodes) {\n if (!node.manifest) continue\n const url = getUrlFromManifest(node.manifest)\n results.push({\n url,\n name: node.name /* c8 ignore next */ ?? '(unknown)',\n })\n }\n\n if (results.length === 0) {\n throw error('No packages found matching target query', {\n found: targetOption,\n })\n }\n\n // If single result, open it\n if (results.length === 1) {\n const result = results[0]\n /* c8 ignore next 3 */\n if (!result) {\n throw error('Unexpected empty result')\n }\n await urlOpen(result.url)\n return result\n }\n\n // Multiple results, return the list\n return results\n }\n\n // read the package spec from a positional argument or local package.json\n const specArg = conf.positionals[0]\n const manifest =\n conf.positionals.length === 0 ? packageJson.read(projectRoot)\n : specArg ?\n await new PackageInfoClient(conf.options).manifest(\n Spec.parseArgs(specArg, conf.options),\n )\n : /* c8 ignore next */ packageJson.read(projectRoot)\n\n const url = getUrlFromManifest(manifest)\n const { name } = manifest\n /* c8 ignore start - getUrlFromManifest already validates name */\n if (!name) {\n throw error('No package name found')\n }\n /* c8 ignore stop */\n // Open the URL\n await urlOpen(url)\n\n return { url, name }\n}\n"]}
|
|
@@ -87,10 +87,14 @@ const install = async (conf, keys, view) => {
|
|
|
87
87
|
code: 'EUSAGE',
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
91
|
+
String(conf.get('allow-scripts'))
|
|
92
|
+
: ':not(*)';
|
|
90
93
|
return Promise.all(keys.map(async (key) => {
|
|
91
94
|
const info = await vlx.install(key, {
|
|
92
95
|
...conf.options,
|
|
93
96
|
query: undefined,
|
|
97
|
+
allowScripts,
|
|
94
98
|
});
|
|
95
99
|
view?.stdout(info);
|
|
96
100
|
return info.path;
|
|
@@ -108,11 +112,15 @@ const ls = async (_conf, args, view) => {
|
|
|
108
112
|
return results;
|
|
109
113
|
};
|
|
110
114
|
const info = async (conf, keys, view) => {
|
|
115
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
116
|
+
String(conf.get('allow-scripts'))
|
|
117
|
+
: ':not(*)';
|
|
111
118
|
const results = [];
|
|
112
119
|
for await (const key of keys.length ? keys : vlx.list()) {
|
|
113
120
|
const info = vlx.info(key, {
|
|
114
121
|
...conf.options,
|
|
115
122
|
query: undefined,
|
|
123
|
+
allowScripts,
|
|
116
124
|
});
|
|
117
125
|
results.push(info);
|
|
118
126
|
view?.stdout(info);
|
|
@@ -120,10 +128,14 @@ const info = async (conf, keys, view) => {
|
|
|
120
128
|
return results;
|
|
121
129
|
};
|
|
122
130
|
const deleteEntries = async (conf, keys, view) => {
|
|
131
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
132
|
+
String(conf.get('allow-scripts'))
|
|
133
|
+
: ':not(*)';
|
|
123
134
|
const remover = new RollbackRemove();
|
|
124
135
|
const removed = (await vlx.delete(keys, remover, {
|
|
125
136
|
...conf.options,
|
|
126
137
|
query: undefined,
|
|
138
|
+
allowScripts,
|
|
127
139
|
})).map(path => {
|
|
128
140
|
view?.stdout(`- ${basename(path)}`);
|
|
129
141
|
return path;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec-cache.js","sourceRoot":"","sources":["../../../src/commands/exec-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAKtC,IAAI,IAAmB,CAAA;AACvB,MAAM,OAAO,aAAc,SAAQ,SAAS;IAC1C,YAAY,OAAoB,EAAE,IAAkB;QAClD,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QACpB,IAAI,GAAG,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAe;QACvB,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,KAAK,GAAuC;IACvD,KAAK,EAAE,aAAa;CACrB,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,kCAAkC;IAE/C,WAAW,EAAE;QACX,EAAE,EAAE;YACF,KAAK,EAAE,EAAE;YACT,WAAW,EAAE;;yBAEM;SACpB;QAED,MAAM,EAAE;YACN,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE;;qCAEkB;SAChC;QAED,IAAI,EAAE;YACJ,KAAK,EAAE,OAAO;YACd,WAAW,EAAE;kC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AAO;QACf,KAAK,EAAE,SAAS;QAChB,YAAY;KACb,CAAC,CACH,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC,KAAK,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;IACF,OAAO,CAAC,OAAO,EAAE,CAAA;IACjB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { error } from '@vltpkg/error-cause'\nimport { RollbackRemove } from '@vltpkg/rollback-remove'\nimport type { VlxInfo } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { basename } from 'node:path'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { CommandUsageDefinition } from '../config/usage.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { stdout } from '../output.ts'\nimport type { ViewOptions, Views } from '../view.ts'\nimport { ViewClass } from '../view.ts'\n\nexport type ExecCacheSubcommands =\n keyof (typeof usageDef)['subcommands']\n\nlet view: ExecCacheView\nexport class ExecCacheView extends ViewClass {\n constructor(options: ViewOptions, conf: LoadedConfig) {\n super(options, conf)\n view = this\n }\n stdout(...args: unknown[]) {\n stdout(...args)\n }\n}\n\nexport const views: Views<void | string[] | VlxInfo[]> = {\n human: ExecCacheView,\n}\n\nconst usageDef = {\n command: 'exec-cache',\n usage: '<command> [flags]',\n description: 'Work with vlt exec-cache folders',\n\n subcommands: {\n ls: {\n usage: '',\n description: `Show previously installed packages used for \\`vlt exec\\`.\n Key provided can be either the package name, or the full\n key.`,\n },\n\n delete: {\n usage: '[<key>...]',\n description: `Delete previously installed packages used for\n \\`vlt exec\\`. If no keys are provided, then all entries\n will be deleted.`,\n },\n\n info: {\n usage: '<key>',\n description: `Show extended information about a given \\`vlt exec\\`\n installation.`,\n },\n\n install: {\n usage: '<spec>...',\n description: `Install the specified package(s) in the \\`vlt exec\\`\n central cache location. Metadata info about each\n installation will be printed.`,\n },\n },\n\n examples: {\n ls: {\n description: `Show all the keys for the installations in the \\`vlt exec\\`\n cache.`,\n },\n 'delete typescript': {\n description: `Delete all versions of typescript installed for vlt exec`,\n },\n 'info typescript-695bf962': {\n description: `Show extended info about a specific version of typescript`,\n },\n },\n} as const satisfies CommandUsageDefinition\n\nexport const usage: CommandUsage = () => commandUsage(usageDef)\n\nexport const command: CommandFn<\n string[] | VlxInfo[]\n> = async conf => {\n const [sub, ...args] = conf.positionals\n switch (sub) {\n case 'ls':\n return ls(conf, args, view)\n\n case 'info':\n return info(conf, args, view)\n\n case 'install':\n return install(conf, args, view)\n\n case 'delete':\n return deleteEntries(conf, args, view)\n\n default: {\n throw error('Unrecognized exec-cache command', {\n code: 'EUSAGE',\n found: sub,\n validOptions: Object.keys(usageDef.subcommands),\n })\n }\n }\n}\n\nconst install = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n if (!keys.length) {\n throw error('Must supply a package spec to install', {\n code: 'EUSAGE',\n })\n }\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n return Promise.all(\n keys.map(async key => {\n const info = await vlx.install(key, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n view?.stdout(info)\n return info.path\n }),\n )\n}\n\nconst ls = async (\n _conf: LoadedConfig,\n args: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const results: string[] = []\n for await (const path of vlx.list()) {\n const key = basename(path)\n if (args.length && !args.some(a => key.includes(a))) continue\n results.push(key)\n view?.stdout(key)\n }\n return results\n}\n\nconst info = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<VlxInfo[]> => {\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n const results: VlxInfo[] = []\n for await (const key of keys.length ? keys : vlx.list()) {\n const info = vlx.info(key, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n results.push(info)\n view?.stdout(info)\n }\n return results\n}\n\nconst deleteEntries = async (\n conf: LoadedConfig,\n keys: string[],\n view?: ExecCacheView,\n): Promise<string[]> => {\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n const remover = new RollbackRemove()\n const removed = (\n await vlx.delete(keys, remover, {\n ...conf.options,\n query: undefined,\n allowScripts,\n })\n ).map(path => {\n view?.stdout(`- ${basename(path)}`)\n return path\n })\n remover.confirm()\n return removed\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAoDhB,CAAA;AAGJ,eAAO,MAAM,UAAU,SAAU,MAAM,WAC2B,CAAA;AAElE,eAAO,MAAM,QAAQ,EAAE,QAyBtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"exec.d.ts","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAK3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,eAAO,MAAM,KAAK,EAAE,YAoDhB,CAAA;AAGJ,eAAO,MAAM,UAAU,SAAU,MAAM,WAC2B,CAAA;AAElE,eAAO,MAAM,QAAQ,EAAE,QAyBtB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,UAAU,CAoBzC,CAAA"}
|
|
@@ -68,9 +68,15 @@ Is this ok? (y) `);
|
|
|
68
68
|
return response;
|
|
69
69
|
};
|
|
70
70
|
export const command = async (conf) => {
|
|
71
|
+
/* c8 ignore start */
|
|
72
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
73
|
+
String(conf.get('allow-scripts'))
|
|
74
|
+
: ':not(*)';
|
|
75
|
+
/* c8 ignore stop */
|
|
71
76
|
const arg0 = await vlx.resolve(conf.positionals, {
|
|
72
77
|
...conf.options,
|
|
73
78
|
query: undefined,
|
|
79
|
+
allowScripts,
|
|
74
80
|
}, promptFn);
|
|
75
81
|
if (arg0)
|
|
76
82
|
conf.positionals[0] = arg0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../../src/commands/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,gCAAgC;IACvC,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;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,GAAG,MAAM,eAAe,CACpC,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,MAAM,CACf,CAAC,QAAQ,CACR,qBAAqB,eAAe,CAClC,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,MAAM,CAAC,OAAO,CAAC,CAChB;QACG,eAAe,CACjB,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CACX;QACG,eAAe,CACjB,CAAC,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,EAClC,UAAU,CAAC,IAAI,CAAC,CACjB;iBACY,CACd,CAAA;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACrB,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE;IACzD,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,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAC5B,IAAI,CAAC,WAAW,EAChB;QACE,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;QAChB,YAAY;KACb,EACD,QAAQ,CACT,CAAA;IACD,IAAI,IAAI;QAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACpC,mCAAmC;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,OAAO,MAAM,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAA;AACxD,CAAC,CAAA","sourcesContent":["import { exec, execFG } from '@vltpkg/run'\nimport type { PromptFn } from '@vltpkg/vlx'\nimport * as vlx from '@vltpkg/vlx'\nimport { homedir } from 'node:os'\nimport { createInterface } from 'node:readline/promises'\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'\nimport { styleTextStdout } from '../output.ts'\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'exec',\n usage: '[--package=<pkg>] [command...]',\n description: `Run a command defined by a package, installing it\n if necessary.\n\n If the package specifier is provided explicitly via the\n \\`--package\\` config, then that is what will be used. If\n a satisfying instance of the named package exists in the\n local \\`node_mnodules\\` folder, then that will be used.\n\n If \\`--package\\` is not set, then vlt will attempt to infer\n the package to be installed if necessary, in the following\n manner:\n\n - If the first argument is an executable found in the\n \\`node_modules/.bin\\` folder (ie, provided by an\n installed direct dependency), then that will be used.\n The search stops, and nothing will be installed.\n - Otherwise, vlt attempts to resolve the first argument\n as if it was a \\`--package\\` option, and then swap it\n out with the \"default\" executable provided by that\n package.\n\n The \"default\" executable provided by a package is:\n\n - If the package provides a single executable string in the\n \\`bin\\` field, then that is the executable to use.\n - Otherwise, if there is a \\`bin\\` with the same name\n as the package (or just the portion after the \\`/\\` in\n the case of scoped packages), then that will be used.\n\n If the appropriate excutable cannot be determined, then\n an error will be raised.\n\n At no point will \\`vlt exec\\` change the locally installed\n dependencies. Any installs it performs is done in vlt's XDG\n data directory.\n `,\n examples: {\n '--package typescript@5 tsc': {\n description: 'Run tsc provided by typescript version 5',\n },\n 'eslint src/file.js': {\n description: 'Run the default bin provided by eslint',\n },\n 'eslint@9.24 src/file.js': {\n description:\n 'Run the default bin provided by eslint version 9.24',\n },\n },\n })\n\nconst HOME = homedir()\nexport const prettyPath = (path: string) =>\n path.startsWith(HOME) ? `~${path.substring(HOME.length)}` : path\n\nexport const promptFn: PromptFn = async (\n pkgSpec,\n path,\n resolution,\n) => {\n const response = await createInterface(\n process.stdin,\n process.stdout,\n ).question(\n `About to install: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n String(pkgSpec),\n )}\nfrom: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n resolution,\n )}\ninto: ${styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n prettyPath(path),\n )}\nIs this ok? (y) `,\n )\n process.stdin.pause()\n return response\n}\n\nexport const command: CommandFn<ExecResult> = async conf => {\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 conf.positionals,\n {\n ...conf.options,\n query: undefined,\n allowScripts,\n },\n promptFn,\n )\n if (arg0) conf.positionals[0] = arg0\n // now we have arg0! let's gooooo!!\n delete conf.options['script-shell']\n return await new ExecCommand(conf, exec, execFG).run()\n}\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ViewClass } from '../../view.ts';
|
|
2
|
+
import type { InstallResult } from '../install.ts';
|
|
2
3
|
export declare class InstallReporter extends ViewClass {
|
|
3
4
|
#private;
|
|
4
5
|
start(): void;
|
|
5
|
-
done(_result:
|
|
6
|
+
done(_result: InstallResult, { time }: {
|
|
6
7
|
time: number;
|
|
7
8
|
}): Promise<undefined>;
|
|
8
9
|
error(err: unknown): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAqGlD,qBAAa,eAAgB,SAAQ,SAAS;;IAG5C,KAAK;IAIC,IAAI,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE;IAe7D,KAAK,CAAC,GAAG,EAAE,OAAO;CAGnB"}
|
|
@@ -4,6 +4,11 @@ import Spinner from 'ink-spinner';
|
|
|
4
4
|
import { createElement as $, Fragment, useEffect, useState, } from 'react';
|
|
5
5
|
import { ViewClass } from "../../view.js";
|
|
6
6
|
import { asError } from '@vltpkg/types';
|
|
7
|
+
const labels = {
|
|
8
|
+
build: 'resolving dependencies',
|
|
9
|
+
actual: '',
|
|
10
|
+
reify: 'extracting files',
|
|
11
|
+
};
|
|
7
12
|
const GraphStep = ({ text, step }) => {
|
|
8
13
|
if (step.state === 'waiting') {
|
|
9
14
|
return $(Text, { color: 'gray' }, text);
|
|
@@ -15,6 +20,7 @@ const GraphStep = ({ text, step }) => {
|
|
|
15
20
|
};
|
|
16
21
|
const App = ({ trailer }) => {
|
|
17
22
|
const [requests, setRequests] = useState(0);
|
|
23
|
+
const [cacheHit, setCacheHit] = useState(0);
|
|
18
24
|
const [steps, setSteps] = useState({
|
|
19
25
|
build: {
|
|
20
26
|
state: 'waiting',
|
|
@@ -27,9 +33,16 @@ const App = ({ trailer }) => {
|
|
|
27
33
|
},
|
|
28
34
|
});
|
|
29
35
|
useEffect(() => {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
const updateRequests = ({ state }) => {
|
|
37
|
+
if (state === 'start') {
|
|
38
|
+
setRequests(p => p + 1);
|
|
39
|
+
}
|
|
40
|
+
else if (state === 'cache' || state === 'stale') {
|
|
41
|
+
setCacheHit(p => p + 1);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
emitter.on('request', updateRequests);
|
|
45
|
+
return () => emitter.off('request', updateRequests);
|
|
33
46
|
}, []);
|
|
34
47
|
useEffect(() => {
|
|
35
48
|
const update = ({ step, state }) => {
|
|
@@ -46,8 +59,15 @@ const App = ({ trailer }) => {
|
|
|
46
59
|
}, []);
|
|
47
60
|
return $(Fragment, null, $(Box, null, ...['build', 'actual', 'reify'].map((step, idx, list) => {
|
|
48
61
|
const separator = idx === list.length - 1 ? '' : ' > ';
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
const label = labels[step];
|
|
63
|
+
if (!label)
|
|
64
|
+
return null;
|
|
65
|
+
return $(Text, { key: step }, $(GraphStep, { text: label, step: steps[step] }), $(Text, { color: 'gray' }, separator));
|
|
66
|
+
})), cacheHit > 0 ?
|
|
67
|
+
$(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)
|
|
68
|
+
: null, requests > 0 ?
|
|
69
|
+
$(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)
|
|
70
|
+
: null, trailer ? $(Text, null, trailer) : null);
|
|
51
71
|
};
|
|
52
72
|
export class InstallReporter extends ViewClass {
|
|
53
73
|
#instance = null;
|
|
@@ -55,7 +75,16 @@ export class InstallReporter extends ViewClass {
|
|
|
55
75
|
this.#instance = render($(App));
|
|
56
76
|
}
|
|
57
77
|
async done(_result, { time }) {
|
|
58
|
-
|
|
78
|
+
let out = `Done in ${time}ms`;
|
|
79
|
+
// prints a very complete message explaining users the next steps
|
|
80
|
+
// in case there are packages to be built
|
|
81
|
+
if (_result.buildQueue?.length) {
|
|
82
|
+
out += `\n\n📦 ${_result.buildQueue.length} packages have install scripts defined & were not fully built\n`;
|
|
83
|
+
out += '🔎 Run `vlt query :scripts` to list them\n';
|
|
84
|
+
out +=
|
|
85
|
+
'🔨 Run `vlt build` to run all required scripts to build installed packages.\n';
|
|
86
|
+
}
|
|
87
|
+
this.#instance?.rerender($(App, { trailer: out }));
|
|
59
88
|
return undefined;
|
|
60
89
|
}
|
|
61
90
|
error(err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.js","sourceRoot":"","sources":["../../../../src/commands/install/reporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAg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AAI,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;IACvC,CAAC;CACF","sourcesContent":["import { emitter } from '@vltpkg/output'\nimport type { Events } from '@vltpkg/output'\nimport { Box, render, Text } from 'ink'\nimport type { Instance } from 'ink'\nimport Spinner from 'ink-spinner'\nimport {\n createElement as $,\n Fragment,\n useEffect,\n useState,\n} from 'react'\nimport { ViewClass } from '../../view.ts'\nimport { asError } from '@vltpkg/types'\nimport type { InstallResult } from '../install.ts'\n\ntype Step = {\n state: 'waiting' | 'in_progress' | 'completed'\n}\n\nconst labels: Record<Events['graphStep']['step'], string> = {\n build: 'resolving dependencies',\n actual: '',\n reify: 'extracting files',\n}\n\nconst GraphStep = ({ text, step }: { text: string; step: Step }) => {\n if (step.state === 'waiting') {\n return $(Text, { color: 'gray' }, text)\n }\n if (step.state === 'in_progress') {\n return $(\n Text,\n { color: 'yellow' },\n text + ' ',\n $(Spinner, { type: 'dots' }),\n )\n }\n return $(Text, { color: 'green' }, text, ' ✓')\n}\n\nconst App = ({ trailer }: { trailer?: string }) => {\n const [requests, setRequests] = useState(0)\n const [cacheHit, setCacheHit] = useState(0)\n\n const [steps, setSteps] = useState<\n Record<Events['graphStep']['step'], Step>\n >({\n build: {\n state: 'waiting',\n },\n actual: {\n state: 'waiting',\n },\n reify: {\n state: 'waiting',\n },\n })\n\n useEffect(() => {\n const updateRequests = ({ state }: Events['request']) => {\n if (state === 'start') {\n setRequests(p => p + 1)\n } else if (state === 'cache' || state === 'stale') {\n setCacheHit(p => p + 1)\n }\n }\n emitter.on('request', updateRequests)\n return () => emitter.off('request', updateRequests)\n }, [])\n\n useEffect(() => {\n const update = ({ step, state }: Events['graphStep']) => {\n setSteps(p => ({\n ...p,\n [step]: {\n ...p[step],\n state: state === 'start' ? 'in_progress' : 'completed',\n },\n }))\n }\n emitter.on('graphStep', update)\n return () => emitter.off('graphStep', update)\n }, [])\n\n return $(\n Fragment,\n null,\n $(\n Box,\n null,\n ...(['build', 'actual', 'reify'] as const).map(\n (step, idx, list) => {\n const separator = idx === list.length - 1 ? '' : ' > '\n const label = labels[step]\n if (!label) return null\n return $(\n Text,\n { key: step },\n $(GraphStep, { text: label, step: steps[step] }),\n $(Text, { color: 'gray' }, separator),\n )\n },\n ),\n ),\n cacheHit > 0 ?\n $(Text, null, `${cacheHit} cache hit${cacheHit > 1 ? 's' : ''}`)\n : null,\n requests > 0 ?\n $(Text, null, `${requests} request${requests > 1 ? 's' : ''}`)\n : null,\n trailer ? $(Text, null, trailer) : null,\n )\n}\n\nexport class InstallReporter extends ViewClass {\n #instance: Instance | null = null\n\n start() {\n this.#instance = render($(App))\n }\n\n async done(_result: InstallResult, { time }: { time: number }) {\n let out = `Done in ${time}ms`\n\n // prints a very complete message explaining users the next steps\n // in case there are packages to be built\n if (_result.buildQueue?.length) {\n out += `\\n\\n📦 ${_result.buildQueue.length} packages have install scripts defined & were not fully built\\n`\n out += '🔎 Run `vlt query :scripts` to list them\\n'\n out +=\n '🔨 Run `vlt build` to run all required scripts to build installed packages.\\n'\n }\n this.#instance?.rerender($(App, { trailer: out }))\n return undefined\n }\n\n error(err: unknown) {\n this.#instance?.unmount(asError(err))\n }\n}\n"]}
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
2
|
+
import type { DepID } from '@vltpkg/dep-id';
|
|
1
3
|
import type { Graph } from '@vltpkg/graph';
|
|
2
4
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
-
|
|
5
|
+
/**
|
|
6
|
+
* The resulting object of an install operation. To be used by the view impl.
|
|
7
|
+
*/
|
|
8
|
+
export type InstallResult = {
|
|
9
|
+
/**
|
|
10
|
+
* A queue of package IDs that need to be built after the install is complete.
|
|
11
|
+
*/
|
|
12
|
+
buildQueue?: DepID[];
|
|
13
|
+
/**
|
|
14
|
+
* The resulting graph structure at the end of an install.
|
|
15
|
+
*/
|
|
16
|
+
graph: Graph;
|
|
17
|
+
};
|
|
4
18
|
export declare const usage: CommandUsage;
|
|
5
19
|
export declare const views: {
|
|
6
|
-
readonly json: (
|
|
20
|
+
readonly json: (i: InstallResult) => {
|
|
21
|
+
graph: import("@vltpkg/graph").LockfileData;
|
|
22
|
+
buildQueue?: DepID[] | undefined;
|
|
23
|
+
message?: string | undefined;
|
|
24
|
+
};
|
|
7
25
|
readonly human: typeof InstallReporter;
|
|
8
26
|
};
|
|
9
|
-
export declare const command: CommandFn<
|
|
27
|
+
export declare const command: CommandFn<InstallResult>;
|
|
10
28
|
//# sourceMappingURL=install.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,EAAE,CAAA;IACpB;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAyB5C,CAAA"}
|
|
@@ -9,19 +9,37 @@ export const usage = () => commandUsage({
|
|
|
9
9
|
vlt-lock.json appropriately.`,
|
|
10
10
|
});
|
|
11
11
|
export const views = {
|
|
12
|
-
json:
|
|
12
|
+
json: i => ({
|
|
13
|
+
...(i.buildQueue?.length ?
|
|
14
|
+
{
|
|
15
|
+
buildQueue: i.buildQueue,
|
|
16
|
+
message: `${i.buildQueue.length} packages that will need to be built, run "vlt build" to complete the install.`,
|
|
17
|
+
}
|
|
18
|
+
: null),
|
|
19
|
+
graph: i.graph.toJSON(),
|
|
20
|
+
}),
|
|
13
21
|
human: InstallReporter,
|
|
14
22
|
};
|
|
15
23
|
export const command = async (conf) => {
|
|
24
|
+
// TODO: we should probably throw an error if the user
|
|
25
|
+
// tries to install using either view=mermaid or view=gui
|
|
16
26
|
const monorepo = conf.options.monorepo;
|
|
17
27
|
const { add } = parseAddArgs(conf, monorepo);
|
|
18
28
|
const frozenLockfile = conf.options['frozen-lockfile'];
|
|
19
29
|
const expectLockfile = conf.options['expect-lockfile'];
|
|
20
|
-
const
|
|
30
|
+
const lockfileOnly = conf.options['lockfile-only'];
|
|
31
|
+
/* c8 ignore start */
|
|
32
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
33
|
+
String(conf.get('allow-scripts'))
|
|
34
|
+
: ':not(*)';
|
|
35
|
+
/* c8 ignore stop */
|
|
36
|
+
const { buildQueue, graph } = await install({
|
|
21
37
|
...conf.options,
|
|
22
38
|
frozenLockfile,
|
|
23
39
|
expectLockfile,
|
|
40
|
+
allowScripts,
|
|
41
|
+
lockfileOnly,
|
|
24
42
|
}, add);
|
|
25
|
-
return graph;
|
|
43
|
+
return { buildQueue, graph };
|
|
26
44
|
};
|
|
27
45
|
//# sourceMappingURL=install.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../../src/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAA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C,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,OAAO,CACzC;QACE,GAAG,IAAI,CAAC,OAAO;QACf,cAAc;QACd,cAAc;QACd,YAAY;QACZ,YAAY;KACb,EACD,GAAG,CACJ,CAAA;IACD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { commandUsage } from '../config/usage.ts'\nimport { install } from '@vltpkg/graph'\nimport { parseAddArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { DepID } from '@vltpkg/dep-id'\nimport type { Graph } from '@vltpkg/graph'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\n\n/**\n * The resulting object of an install operation. To be used by the view impl.\n */\nexport type InstallResult = {\n /**\n * A queue of package IDs that need to be built after the install is complete.\n */\n buildQueue?: DepID[]\n /**\n * The resulting graph structure at the end of an install.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'install',\n usage: '[packages ...]',\n description: `Install the specified packages, updating package.json and\n vlt-lock.json appropriately.`,\n })\n\nexport const views = {\n json: i => ({\n ...(i.buildQueue?.length ?\n {\n buildQueue: i.buildQueue,\n message: `${i.buildQueue.length} packages that will need to be built, run \"vlt build\" to complete the install.`,\n }\n : null),\n graph: i.graph.toJSON(),\n }),\n human: InstallReporter,\n} as const satisfies Views<InstallResult>\n\nexport const command: CommandFn<InstallResult> = async conf => {\n // TODO: we should probably throw an error if the user\n // tries to install using either view=mermaid or view=gui\n const monorepo = conf.options.monorepo\n const { add } = parseAddArgs(conf, monorepo)\n const frozenLockfile = conf.options['frozen-lockfile']\n const expectLockfile = conf.options['expect-lockfile']\n const lockfileOnly = conf.options['lockfile-only']\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 { buildQueue, graph } = await install(\n {\n ...conf.options,\n frozenLockfile,\n expectLockfile,\n allowScripts,\n lockfileOnly,\n },\n add,\n )\n return { buildQueue, graph }\n}\n"]}
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -61,9 +61,15 @@ export const command = async (conf) => {
|
|
|
61
61
|
DAEMON_URL: `http://localhost:${actualGuiPort}`,
|
|
62
62
|
};
|
|
63
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 */
|
|
64
69
|
const arg0 = await vlx.resolve(['@vltpkg/vsr'], {
|
|
65
70
|
...conf.options,
|
|
66
71
|
query: undefined,
|
|
72
|
+
allowScripts,
|
|
67
73
|
}, async () => 'y');
|
|
68
74
|
if (arg0) {
|
|
69
75
|
conf.positionals[0] = arg0;
|
|
@@ -1 +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;YACJ,KAAK,EAAE,UAAU;YACjB,WAAW,EACT,qDAAqD;SACxD;QACD,eAAe,EAAE;YACf,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,2CAA2C;SACzD;KACF;CACF,CAAC,CAAA;AASJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,MAAmB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,CAAA;IACD,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC9C,EAAE,CAAC,GAAG,GAAG,WAAW,CAAA;IACpB,MAAM,EAAE,CAAC,GAAG,EAAE,CAAA;IAEd,6BAA6B;IAC7B,qBAAqB;IACrB,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,CAAC,4BAA4B,CAAC,CAAA;QACpC,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,KAAK,EAAE,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,CAAA;QAC7B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,CAAA;IACf,oBAAoB;IAEpB,gCAAgC;IAChC,MAAM,MAAM,GAAgB;QAC1B,OAAO,EAAE,aAAa;QACtB,YAAY;QACZ,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"]}
|