@vltpkg/cli-sdk 1.0.0-rc.9 → 1.0.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/commands/access.d.ts +23 -0
- package/dist/commands/access.js +251 -0
- package/dist/{esm/commands → commands}/bugs.d.ts +0 -1
- package/dist/{esm/commands → commands}/bugs.js +0 -1
- package/dist/{esm/commands → commands}/build.d.ts +1 -1
- package/dist/{esm/commands → commands}/build.js +1 -1
- package/dist/{esm/commands → commands}/cache.d.ts +1 -1
- package/dist/{esm/commands → commands}/cache.js +1 -1
- package/dist/{esm/commands → commands}/ci.d.ts +1 -1
- package/dist/{esm/commands → commands}/ci.js +12 -3
- package/dist/{esm/commands → commands}/config.d.ts +0 -1
- package/dist/{esm/commands → commands}/config.js +6 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +103 -0
- package/dist/commands/deprecate.d.ts +14 -0
- package/dist/commands/deprecate.js +142 -0
- package/dist/commands/dist-tag.d.ts +22 -0
- package/dist/commands/dist-tag.js +179 -0
- package/dist/{esm/commands → commands}/docs.d.ts +0 -1
- package/dist/{esm/commands → commands}/docs.js +0 -1
- package/dist/{esm/commands → commands}/exec-cache.d.ts +1 -1
- package/dist/{esm/commands → commands}/exec-cache.js +1 -1
- package/dist/{esm/commands/run-exec.d.ts → commands/exec-local.d.ts} +0 -1
- package/dist/{esm/commands → commands}/exec-local.js +23 -1
- package/dist/{esm/commands → commands}/exec.d.ts +1 -1
- package/dist/{esm/commands → commands}/exec.js +85 -10
- package/dist/{esm/commands → commands}/help.d.ts +0 -1
- package/dist/{esm/commands → commands}/help.js +5 -1
- package/dist/{esm/commands → commands}/init.d.ts +0 -1
- package/dist/{esm/commands → commands}/init.js +31 -10
- package/dist/{esm/commands → commands}/install/reporter.d.ts +0 -1
- package/dist/{esm/commands → commands}/install/reporter.js +0 -1
- package/dist/{esm/commands → commands}/install.d.ts +22 -3
- package/dist/commands/install.js +152 -0
- package/dist/{esm/commands → commands}/list.d.ts +5 -2
- package/dist/{esm/commands → commands}/list.js +9 -10
- package/dist/{esm/commands → commands}/login.d.ts +0 -1
- package/dist/commands/login.js +35 -0
- package/dist/{esm/commands → commands}/logout.d.ts +1 -1
- package/dist/commands/logout.js +27 -0
- package/dist/{esm/commands → commands}/pack.d.ts +1 -1
- package/dist/{esm/commands → commands}/pack.js +91 -32
- package/dist/commands/ping.d.ts +18 -0
- package/dist/commands/ping.js +117 -0
- package/dist/{esm/commands → commands}/pkg.d.ts +0 -1
- package/dist/{esm/commands → commands}/pkg.js +27 -1
- package/dist/commands/profile.d.ts +14 -0
- package/dist/commands/profile.js +106 -0
- package/dist/{esm/commands → commands}/publish.d.ts +2 -2
- package/dist/{esm/commands → commands}/publish.js +70 -16
- package/dist/{esm/commands → commands}/query.d.ts +5 -2
- package/dist/{esm/commands → commands}/query.js +54 -11
- package/dist/commands/registry.d.ts +26 -0
- package/dist/commands/registry.js +99 -0
- package/dist/commands/repo.d.ts +17 -0
- package/dist/commands/repo.js +157 -0
- package/dist/{esm/commands/exec-local.d.ts → commands/run-exec.d.ts} +1 -1
- package/dist/commands/run-exec.js +41 -0
- package/dist/{esm/commands → commands}/run.d.ts +0 -1
- package/dist/{esm/commands → commands}/run.js +27 -1
- package/dist/commands/setup.d.ts +25 -0
- package/dist/commands/setup.js +142 -0
- package/dist/commands/token.d.ts +32 -0
- package/dist/commands/token.js +193 -0
- package/dist/{esm/commands → commands}/uninstall.d.ts +1 -1
- package/dist/{esm/commands → commands}/uninstall.js +15 -1
- package/dist/commands/unpublish.d.ts +16 -0
- package/dist/commands/unpublish.js +203 -0
- package/dist/{esm/commands → commands}/update.d.ts +1 -1
- package/dist/{esm/commands → commands}/update.js +7 -1
- package/dist/{esm/commands → commands}/version.d.ts +0 -1
- package/dist/{esm/commands → commands}/version.js +27 -1
- package/dist/commands/view.d.ts +23 -0
- package/dist/commands/view.js +335 -0
- package/dist/{esm/commands → commands}/whoami.d.ts +1 -1
- package/dist/commands/whoami.js +33 -0
- package/dist/{esm/config → config}/definition.d.ts +72 -19
- package/dist/{esm/config → config}/definition.js +157 -50
- package/dist/{esm/config → config}/index.d.ts +0 -1
- package/dist/{esm/config → config}/index.js +43 -2
- package/dist/{esm/config → config}/merge.d.ts +0 -1
- package/dist/{esm/config → config}/merge.js +0 -1
- package/dist/{esm/config → config}/usage.d.ts +0 -1
- package/dist/{esm/config → config}/usage.js +0 -1
- package/dist/{esm/custom-help.d.ts → custom-help.d.ts} +0 -1
- package/dist/{esm/custom-help.js → custom-help.js} +95 -120
- package/dist/{esm/exec-command.d.ts → exec-command.d.ts} +0 -1
- package/dist/{esm/exec-command.js → exec-command.js} +14 -8
- package/dist/{esm/index.d.ts → index.d.ts} +0 -1
- package/dist/{esm/index.js → index.js} +5 -2
- package/dist/{esm/load-command.d.ts → load-command.d.ts} +6 -1
- package/dist/{esm/load-command.js → load-command.js} +0 -1
- package/dist/mermaid-image-view.d.ts +18 -0
- package/dist/mermaid-image-view.js +36 -0
- package/dist/{esm/output.d.ts → output.d.ts} +2 -2
- package/dist/{esm/output.js → output.js} +70 -3
- package/dist/{esm/pack-tarball.d.ts → pack-tarball.d.ts} +15 -1
- package/dist/{esm/pack-tarball.js → pack-tarball.js} +133 -91
- package/dist/{esm/parse-add-remove-args.d.ts → parse-add-remove-args.d.ts} +0 -1
- package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +65 -12
- package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
- package/dist/{esm/print-err.js → print-err.js} +28 -4
- package/dist/query-diff-files.d.ts +17 -0
- package/dist/query-diff-files.js +63 -0
- package/dist/{esm/query-host-contexts.d.ts → query-host-contexts.d.ts} +0 -1
- package/dist/{esm/query-host-contexts.js → query-host-contexts.js} +8 -7
- package/dist/{esm/read-password.d.ts → read-password.d.ts} +0 -1
- package/dist/{esm/read-password.js → read-password.js} +0 -1
- package/dist/read-project-folders.d.ts +17 -0
- package/dist/read-project-folders.js +100 -0
- package/dist/registry-error-message.d.ts +2 -0
- package/dist/registry-error-message.js +29 -0
- package/dist/reload-config.d.ts +2 -0
- package/dist/reload-config.js +11 -0
- package/dist/render-mermaid.d.ts +22 -0
- package/dist/render-mermaid.js +68 -0
- package/dist/require-registry.d.ts +48 -0
- package/dist/require-registry.js +122 -0
- package/dist/select-registry.d.ts +23 -0
- package/dist/select-registry.js +40 -0
- package/dist/telemetry.d.ts +58 -0
- package/dist/telemetry.js +170 -0
- package/dist/verbose-log.d.ts +31 -0
- package/dist/verbose-log.js +62 -0
- package/dist/{esm/view.d.ts → view.d.ts} +0 -1
- package/dist/{esm/view.js → view.js} +1 -2
- package/package.json +75 -82
- package/dist/esm/commands/bugs.d.ts.map +0 -1
- package/dist/esm/commands/bugs.js.map +0 -1
- package/dist/esm/commands/build.d.ts.map +0 -1
- package/dist/esm/commands/build.js.map +0 -1
- package/dist/esm/commands/cache.d.ts.map +0 -1
- package/dist/esm/commands/cache.js.map +0 -1
- package/dist/esm/commands/ci.d.ts.map +0 -1
- package/dist/esm/commands/ci.js.map +0 -1
- package/dist/esm/commands/config.d.ts.map +0 -1
- package/dist/esm/commands/config.js.map +0 -1
- package/dist/esm/commands/docs.d.ts.map +0 -1
- package/dist/esm/commands/docs.js.map +0 -1
- package/dist/esm/commands/exec-cache.d.ts.map +0 -1
- package/dist/esm/commands/exec-cache.js.map +0 -1
- package/dist/esm/commands/exec-local.d.ts.map +0 -1
- package/dist/esm/commands/exec-local.js.map +0 -1
- package/dist/esm/commands/exec.d.ts.map +0 -1
- package/dist/esm/commands/exec.js.map +0 -1
- package/dist/esm/commands/help.d.ts.map +0 -1
- package/dist/esm/commands/help.js.map +0 -1
- package/dist/esm/commands/init.d.ts.map +0 -1
- package/dist/esm/commands/init.js.map +0 -1
- package/dist/esm/commands/install/reporter.d.ts.map +0 -1
- package/dist/esm/commands/install/reporter.js.map +0 -1
- package/dist/esm/commands/install.d.ts.map +0 -1
- package/dist/esm/commands/install.js +0 -46
- package/dist/esm/commands/install.js.map +0 -1
- package/dist/esm/commands/list.d.ts.map +0 -1
- package/dist/esm/commands/list.js.map +0 -1
- package/dist/esm/commands/login.d.ts.map +0 -1
- package/dist/esm/commands/login.js +0 -13
- package/dist/esm/commands/login.js.map +0 -1
- package/dist/esm/commands/logout.d.ts.map +0 -1
- package/dist/esm/commands/logout.js +0 -13
- package/dist/esm/commands/logout.js.map +0 -1
- package/dist/esm/commands/pack.d.ts.map +0 -1
- package/dist/esm/commands/pack.js.map +0 -1
- package/dist/esm/commands/pkg.d.ts.map +0 -1
- package/dist/esm/commands/pkg.js.map +0 -1
- package/dist/esm/commands/publish.d.ts.map +0 -1
- package/dist/esm/commands/publish.js.map +0 -1
- package/dist/esm/commands/query.d.ts.map +0 -1
- package/dist/esm/commands/query.js.map +0 -1
- package/dist/esm/commands/run-exec.d.ts.map +0 -1
- package/dist/esm/commands/run-exec.js +0 -14
- package/dist/esm/commands/run-exec.js.map +0 -1
- package/dist/esm/commands/run.d.ts.map +0 -1
- package/dist/esm/commands/run.js.map +0 -1
- package/dist/esm/commands/serve.d.ts +0 -14
- package/dist/esm/commands/serve.d.ts.map +0 -1
- package/dist/esm/commands/serve.js +0 -103
- package/dist/esm/commands/serve.js.map +0 -1
- package/dist/esm/commands/token.d.ts +0 -4
- package/dist/esm/commands/token.d.ts.map +0 -1
- package/dist/esm/commands/token.js +0 -30
- package/dist/esm/commands/token.js.map +0 -1
- package/dist/esm/commands/uninstall.d.ts.map +0 -1
- package/dist/esm/commands/uninstall.js.map +0 -1
- package/dist/esm/commands/update.d.ts.map +0 -1
- package/dist/esm/commands/update.js.map +0 -1
- package/dist/esm/commands/version.d.ts.map +0 -1
- package/dist/esm/commands/version.js.map +0 -1
- package/dist/esm/commands/whoami.d.ts.map +0 -1
- package/dist/esm/commands/whoami.js +0 -19
- package/dist/esm/commands/whoami.js.map +0 -1
- package/dist/esm/config/definition.d.ts.map +0 -1
- package/dist/esm/config/definition.js.map +0 -1
- package/dist/esm/config/index.d.ts.map +0 -1
- package/dist/esm/config/index.js.map +0 -1
- package/dist/esm/config/merge.d.ts.map +0 -1
- package/dist/esm/config/merge.js.map +0 -1
- package/dist/esm/config/usage.d.ts.map +0 -1
- package/dist/esm/config/usage.js.map +0 -1
- package/dist/esm/custom-help.d.ts.map +0 -1
- package/dist/esm/custom-help.js.map +0 -1
- package/dist/esm/exec-command.d.ts.map +0 -1
- package/dist/esm/exec-command.js.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/load-command.d.ts.map +0 -1
- package/dist/esm/load-command.js.map +0 -1
- package/dist/esm/output.d.ts.map +0 -1
- package/dist/esm/output.js.map +0 -1
- package/dist/esm/pack-tarball.d.ts.map +0 -1
- package/dist/esm/pack-tarball.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/esm/parse-add-remove-args.d.ts.map +0 -1
- package/dist/esm/parse-add-remove-args.js.map +0 -1
- package/dist/esm/print-err.d.ts.map +0 -1
- package/dist/esm/print-err.js.map +0 -1
- package/dist/esm/query-host-contexts.d.ts.map +0 -1
- package/dist/esm/query-host-contexts.js.map +0 -1
- package/dist/esm/read-password.d.ts.map +0 -1
- package/dist/esm/read-password.js.map +0 -1
- package/dist/esm/start-gui.d.ts +0 -10
- package/dist/esm/start-gui.d.ts.map +0 -1
- package/dist/esm/start-gui.js +0 -60
- package/dist/esm/start-gui.js.map +0 -1
- package/dist/esm/view.d.ts.map +0 -1
- package/dist/esm/view.js.map +0 -1
|
@@ -0,0 +1,157 @@
|
|
|
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: 'repo',
|
|
14
|
+
usage: ['[<spec>]', '[--target=<query>]'],
|
|
15
|
+
description: `Open repository page 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 repo for the current package (reads local package.json)',
|
|
27
|
+
},
|
|
28
|
+
'abbrev@2.0.0': {
|
|
29
|
+
description: 'Open repo for a specific package version',
|
|
30
|
+
},
|
|
31
|
+
'--target=":root > *"': {
|
|
32
|
+
description: 'List repository 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 repositories 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, repository, homepage } = manifest;
|
|
49
|
+
if (!name) {
|
|
50
|
+
throw error('No package name found');
|
|
51
|
+
}
|
|
52
|
+
let url;
|
|
53
|
+
// Check repository field first
|
|
54
|
+
if (repository) {
|
|
55
|
+
const repoUrl = typeof repository === 'string' ? repository
|
|
56
|
+
: typeof repository === 'object' && 'url' in repository ?
|
|
57
|
+
repository.url
|
|
58
|
+
: /* c8 ignore next */ undefined;
|
|
59
|
+
if (repoUrl) {
|
|
60
|
+
const info = hostedGitInfoFromUrl(repoUrl.replace(/^git\+/, ''));
|
|
61
|
+
if (info?.browse && typeof info.browse === 'function') {
|
|
62
|
+
url = info.browse();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Use the raw URL if hosted-git-info can't parse it
|
|
66
|
+
url = repoUrl.replace(/^git\+/, '');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Fall back to homepage
|
|
71
|
+
if (!url && homepage) {
|
|
72
|
+
url = homepage;
|
|
73
|
+
}
|
|
74
|
+
// Fallback to vlt.io package page
|
|
75
|
+
if (!url) {
|
|
76
|
+
url = `https://vlt.io/explore/npm/${name}/overview`;
|
|
77
|
+
}
|
|
78
|
+
return url;
|
|
79
|
+
};
|
|
80
|
+
export const command = async (conf) => {
|
|
81
|
+
const { projectRoot, packageJson } = conf.options;
|
|
82
|
+
const targetOption = conf.get('target');
|
|
83
|
+
// Handle --target query
|
|
84
|
+
if (targetOption) {
|
|
85
|
+
const mainManifest = packageJson.maybeRead(projectRoot);
|
|
86
|
+
if (!mainManifest) {
|
|
87
|
+
throw error('No package.json found in project root', {
|
|
88
|
+
path: projectRoot,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
const graph = actual.load({
|
|
92
|
+
...conf.options,
|
|
93
|
+
mainManifest,
|
|
94
|
+
monorepo: conf.options.monorepo,
|
|
95
|
+
loadManifests: true,
|
|
96
|
+
});
|
|
97
|
+
const securityArchive = Query.hasSecuritySelectors(targetOption) ?
|
|
98
|
+
await SecurityArchive.start({
|
|
99
|
+
nodes: [...graph.nodes.values()],
|
|
100
|
+
})
|
|
101
|
+
: undefined;
|
|
102
|
+
const hostContexts = await createHostContextsMap(conf);
|
|
103
|
+
const query = new Query({
|
|
104
|
+
nodes: new Set(graph.nodes.values()),
|
|
105
|
+
edges: graph.edges,
|
|
106
|
+
importers: graph.importers,
|
|
107
|
+
securityArchive,
|
|
108
|
+
hostContexts,
|
|
109
|
+
});
|
|
110
|
+
const { nodes } = await query.search(targetOption, {
|
|
111
|
+
signal: new AbortController().signal,
|
|
112
|
+
});
|
|
113
|
+
const results = [];
|
|
114
|
+
for (const node of nodes) {
|
|
115
|
+
if (!node.manifest)
|
|
116
|
+
continue;
|
|
117
|
+
const url = getUrlFromManifest(node.manifest);
|
|
118
|
+
results.push({
|
|
119
|
+
url,
|
|
120
|
+
name: node.name /* c8 ignore next */ ?? '(unknown)',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (results.length === 0) {
|
|
124
|
+
throw error('No packages found matching target query', {
|
|
125
|
+
found: targetOption,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// If single result, open it
|
|
129
|
+
if (results.length === 1) {
|
|
130
|
+
const result = results[0];
|
|
131
|
+
/* c8 ignore next 3 */
|
|
132
|
+
if (!result) {
|
|
133
|
+
throw error('Unexpected empty result');
|
|
134
|
+
}
|
|
135
|
+
await urlOpen(result.url);
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
// Multiple results, return the list
|
|
139
|
+
return results;
|
|
140
|
+
}
|
|
141
|
+
// read the package spec from a positional argument or local package.json
|
|
142
|
+
const specArg = conf.positionals[0];
|
|
143
|
+
const manifest = conf.positionals.length === 0 ? packageJson.read(projectRoot)
|
|
144
|
+
: specArg ?
|
|
145
|
+
await new PackageInfoClient(conf.options).manifest(Spec.parseArgs(specArg, conf.options))
|
|
146
|
+
: /* c8 ignore next */ packageJson.read(projectRoot);
|
|
147
|
+
const url = getUrlFromManifest(manifest);
|
|
148
|
+
const { name } = manifest;
|
|
149
|
+
/* c8 ignore start - getUrlFromManifest already validates name */
|
|
150
|
+
if (!name) {
|
|
151
|
+
throw error('No package name found');
|
|
152
|
+
}
|
|
153
|
+
/* c8 ignore stop */
|
|
154
|
+
// Open the URL
|
|
155
|
+
await urlOpen(url);
|
|
156
|
+
return { url, name };
|
|
157
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ExecResult } from '../exec-command.ts';
|
|
2
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
3
|
export { views } from '../exec-command.ts';
|
|
4
|
+
export declare const needsRegistry = true;
|
|
4
5
|
export declare const usage: CommandUsage;
|
|
5
6
|
export declare const command: CommandFn<ExecResult>;
|
|
6
|
-
//# sourceMappingURL=exec-local.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { runExec, runExecFG } from '@vltpkg/run';
|
|
2
|
+
import { commandUsage } from "../config/usage.js";
|
|
3
|
+
import { ExecCommand } from "../exec-command.js";
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
5
|
+
export const needsRegistry = true;
|
|
6
|
+
export const usage = () => commandUsage({
|
|
7
|
+
command: 'run-exec',
|
|
8
|
+
usage: '[command ...]',
|
|
9
|
+
description: `If the first argument is a defined script in package.json, then this is
|
|
10
|
+
equivalent to \`vlt run\`.
|
|
11
|
+
|
|
12
|
+
If not, then this is equivalent to \`vlt exec\`.`,
|
|
13
|
+
options: {
|
|
14
|
+
scope: {
|
|
15
|
+
value: '<query>',
|
|
16
|
+
description: 'Filter execution targets using a DSS query.',
|
|
17
|
+
},
|
|
18
|
+
workspace: {
|
|
19
|
+
value: '<path|glob>',
|
|
20
|
+
description: 'Limit execution to matching workspace paths or globs.',
|
|
21
|
+
},
|
|
22
|
+
'workspace-group': {
|
|
23
|
+
value: '<name>',
|
|
24
|
+
description: 'Limit execution to named workspace groups.',
|
|
25
|
+
},
|
|
26
|
+
recursive: {
|
|
27
|
+
description: 'Run across all selected workspaces.',
|
|
28
|
+
},
|
|
29
|
+
'if-present': {
|
|
30
|
+
description: 'When running across multiple packages, only include packages with matching scripts.',
|
|
31
|
+
},
|
|
32
|
+
bail: {
|
|
33
|
+
description: 'When running across multiple workspaces, stop on first failure.',
|
|
34
|
+
},
|
|
35
|
+
'script-shell': {
|
|
36
|
+
value: '<program>',
|
|
37
|
+
description: 'Shell to use when executing package.json scripts.',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
export const command = async (conf) => await new ExecCommand(conf, runExec, runExecFG).run();
|
|
@@ -9,6 +9,33 @@ export const usage = () => commandUsage({
|
|
|
9
9
|
arguments. Note that vlt config values must be specified *before*
|
|
10
10
|
the script name, because everything after that is handed off to
|
|
11
11
|
the script process.`,
|
|
12
|
+
options: {
|
|
13
|
+
scope: {
|
|
14
|
+
value: '<query>',
|
|
15
|
+
description: 'Filter execution targets using a DSS query.',
|
|
16
|
+
},
|
|
17
|
+
workspace: {
|
|
18
|
+
value: '<path|glob>',
|
|
19
|
+
description: 'Limit execution to matching workspace paths or globs.',
|
|
20
|
+
},
|
|
21
|
+
'workspace-group': {
|
|
22
|
+
value: '<name>',
|
|
23
|
+
description: 'Limit execution to named workspace groups.',
|
|
24
|
+
},
|
|
25
|
+
recursive: {
|
|
26
|
+
description: 'Run across all selected workspaces.',
|
|
27
|
+
},
|
|
28
|
+
'if-present': {
|
|
29
|
+
description: 'When running across multiple packages, only include packages with matching scripts.',
|
|
30
|
+
},
|
|
31
|
+
bail: {
|
|
32
|
+
description: 'When running across multiple workspaces, stop on first failure.',
|
|
33
|
+
},
|
|
34
|
+
'script-shell': {
|
|
35
|
+
value: '<program>',
|
|
36
|
+
description: 'Shell to use when executing package.json scripts.',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
12
39
|
});
|
|
13
40
|
class RunCommand extends ExecCommand {
|
|
14
41
|
constructor(conf) {
|
|
@@ -33,4 +60,3 @@ class RunCommand extends ExecCommand {
|
|
|
33
60
|
}
|
|
34
61
|
}
|
|
35
62
|
export const command = async (conf) => await new RunCommand(conf).run();
|
|
36
|
-
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
/** Where users sign up for / log into a vlt.io account. */
|
|
3
|
+
export declare const VLT_SIGNUP_URL = "https://www.vlt.io";
|
|
4
|
+
/** Base URL that per-account registries live under. */
|
|
5
|
+
export declare const VLT_REGISTRY_BASE = "https://registry.vlt.io";
|
|
6
|
+
/**
|
|
7
|
+
* The registry aliases that every vlt.io account is provisioned with.
|
|
8
|
+
* `npm` is the {@link https://docs.vlt.sh | default bare-spec alias}.
|
|
9
|
+
*/
|
|
10
|
+
export declare const accountRegistries: readonly ["npm", "main"];
|
|
11
|
+
/** Build the per-account registry URL for a given registry name. */
|
|
12
|
+
export declare const accountRegistryURL: (account: string, name: string) => string;
|
|
13
|
+
export type SetupResult = {
|
|
14
|
+
/** the account slug the registries were built for */
|
|
15
|
+
account: string;
|
|
16
|
+
/** which config file the registries were written to */
|
|
17
|
+
which: 'user' | 'project';
|
|
18
|
+
/** the alias -> url map that was staged into config */
|
|
19
|
+
registries: Record<string, string>;
|
|
20
|
+
};
|
|
21
|
+
export declare const views: {
|
|
22
|
+
readonly human: (result: SetupResult) => string;
|
|
23
|
+
};
|
|
24
|
+
export declare const usage: CommandUsage;
|
|
25
|
+
export declare const command: CommandFn<SetupResult>;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { RegistryClient } from '@vltpkg/registry-client';
|
|
3
|
+
import { defaultRegistries } from '@vltpkg/spec';
|
|
4
|
+
import { createInterface } from 'node:readline/promises';
|
|
5
|
+
import { commandUsage } from "../config/usage.js";
|
|
6
|
+
import { stdout } from "../output.js";
|
|
7
|
+
/** Where users sign up for / log into a vlt.io account. */
|
|
8
|
+
export const VLT_SIGNUP_URL = 'https://www.vlt.io';
|
|
9
|
+
/** Base URL that per-account registries live under. */
|
|
10
|
+
export const VLT_REGISTRY_BASE = 'https://registry.vlt.io';
|
|
11
|
+
/**
|
|
12
|
+
* The registry aliases that every vlt.io account is provisioned with.
|
|
13
|
+
* `npm` is the {@link https://docs.vlt.sh | default bare-spec alias}.
|
|
14
|
+
*/
|
|
15
|
+
export const accountRegistries = ['npm', 'main'];
|
|
16
|
+
/** Build the per-account registry URL for a given registry name. */
|
|
17
|
+
export const accountRegistryURL = (account, name) => `${VLT_REGISTRY_BASE}/${encodeURIComponent(account)}/${name}/`;
|
|
18
|
+
/** Ensure a registry URL ends with a single trailing slash. */
|
|
19
|
+
const normalizeRegistryURL = (url) => url.endsWith('/') ? url : `${url}/`;
|
|
20
|
+
export const views = {
|
|
21
|
+
human: (result) => {
|
|
22
|
+
const lines = [
|
|
23
|
+
`Configured ${Object.keys(result.registries).length} registry ${Object.keys(result.registries).length === 1 ?
|
|
24
|
+
'alias'
|
|
25
|
+
: 'aliases'} for "${result.account}" in ${result.which} config:`,
|
|
26
|
+
];
|
|
27
|
+
for (const [name, url] of Object.entries(result.registries)) {
|
|
28
|
+
lines.push(` ${name} -> ${url}`);
|
|
29
|
+
}
|
|
30
|
+
lines.push('', 'You can now install packages, e.g.:', ' vlt install <pkg>');
|
|
31
|
+
return lines.join('\n');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
export const usage = () => commandUsage({
|
|
35
|
+
command: 'setup',
|
|
36
|
+
usage: '[<account>]',
|
|
37
|
+
description: `Configure the registry aliases for your vlt.io account so
|
|
38
|
+
that \`vlt install\` and \`vlx\` work out of the box.
|
|
39
|
+
|
|
40
|
+
Sign up or log in at ${VLT_SIGNUP_URL} first. The wizard
|
|
41
|
+
authenticates against your account and writes the
|
|
42
|
+
\`npm\` and \`main\` registry aliases (and any additional
|
|
43
|
+
aliases you add) to your user \`vlt.json\`.`,
|
|
44
|
+
options: {
|
|
45
|
+
config: {
|
|
46
|
+
value: '<user | project>',
|
|
47
|
+
description: 'Which config file to write to. Defaults to `user`; pass ' +
|
|
48
|
+
'`--config=project` to write to the project `vlt.json`.',
|
|
49
|
+
},
|
|
50
|
+
registries: {
|
|
51
|
+
value: '<name=url>',
|
|
52
|
+
description: 'Additional registry aliases to stage non-interactively. ' +
|
|
53
|
+
'Combine with `--yes` to run setup unattended.',
|
|
54
|
+
},
|
|
55
|
+
yes: {
|
|
56
|
+
description: 'Skip interactive prompts (requires <account> and does not ' +
|
|
57
|
+
'open a browser for authentication).',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export const command = async (conf) => {
|
|
62
|
+
const yes = !!conf.get('yes');
|
|
63
|
+
const which = conf.get('config') === 'project' ? 'project' : 'user';
|
|
64
|
+
let rl;
|
|
65
|
+
const ask = async (question) => {
|
|
66
|
+
rl ??= createInterface(process.stdin, process.stdout);
|
|
67
|
+
return (await rl.question(question)).trim();
|
|
68
|
+
};
|
|
69
|
+
try {
|
|
70
|
+
stdout(`Sign up or log in at ${VLT_SIGNUP_URL} before continuing.`);
|
|
71
|
+
// 1. resolve the account slug
|
|
72
|
+
let account = conf.positionals[0]?.trim();
|
|
73
|
+
if (!account) {
|
|
74
|
+
if (yes) {
|
|
75
|
+
throw error('An account slug is required in non-interactive mode. ' +
|
|
76
|
+
'Pass it as an argument: `vlt setup <account> --yes`.', { code: 'ECONFIG' });
|
|
77
|
+
}
|
|
78
|
+
account = await ask('vlt.io account or organization slug: ');
|
|
79
|
+
if (!account) {
|
|
80
|
+
throw error('No account slug provided.', { code: 'ECONFIG' });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// 2. stage the two known account registries
|
|
84
|
+
const registries = {};
|
|
85
|
+
for (const name of accountRegistries) {
|
|
86
|
+
registries[name] = accountRegistryURL(account, name);
|
|
87
|
+
}
|
|
88
|
+
// 3. merge any user-supplied registry aliases (skip built-in defaults)
|
|
89
|
+
const builtinRegistries = defaultRegistries;
|
|
90
|
+
for (const [name, url] of Object.entries(conf.options.registries)) {
|
|
91
|
+
if (builtinRegistries[name] === url)
|
|
92
|
+
continue;
|
|
93
|
+
registries[name] = normalizeRegistryURL(url);
|
|
94
|
+
}
|
|
95
|
+
const rc = new RegistryClient(conf.options);
|
|
96
|
+
// 4. authenticate against the account registries (interactive only)
|
|
97
|
+
if (!yes) {
|
|
98
|
+
const doAuth = await ask('Authenticate with your vlt.io account now? (Y/n) ');
|
|
99
|
+
if (!/^n/i.test(doAuth)) {
|
|
100
|
+
for (const name of accountRegistries) {
|
|
101
|
+
stdout(`Authenticating against the "${name}" registry...`);
|
|
102
|
+
await rc.login(accountRegistryURL(account, name));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 5. offer to add further custom aliases
|
|
106
|
+
for (;;) {
|
|
107
|
+
const more = await ask('Add another registry alias? (y/N) ');
|
|
108
|
+
if (!/^y/i.test(more))
|
|
109
|
+
break;
|
|
110
|
+
const name = await ask(' alias name: ');
|
|
111
|
+
if (!name) {
|
|
112
|
+
stdout(' alias name is required, skipping.');
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (name in registries) {
|
|
116
|
+
stdout(` alias "${name}" is already staged, skipping.`);
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const url = await ask(' registry url: ');
|
|
120
|
+
if (!url) {
|
|
121
|
+
stdout(' registry url is required, skipping.');
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const normalized = normalizeRegistryURL(url);
|
|
125
|
+
registries[name] = normalized;
|
|
126
|
+
const auth = await ask(` authenticate against "${name}" now? (y/N) `);
|
|
127
|
+
if (/^y/i.test(auth)) {
|
|
128
|
+
await rc.login(normalized);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// 6. persist the staged registries (merged, not clobbered)
|
|
133
|
+
await conf.addConfigToFile(which, { registries });
|
|
134
|
+
return { account, which, registries };
|
|
135
|
+
}
|
|
136
|
+
finally {
|
|
137
|
+
if (rl) {
|
|
138
|
+
rl.close();
|
|
139
|
+
process.stdin.pause();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export type TokenInfo = {
|
|
3
|
+
/** The server-side key/id for the token */
|
|
4
|
+
key: string;
|
|
5
|
+
/** A truncated prefix of the token value */
|
|
6
|
+
token: string;
|
|
7
|
+
/** ISO date when the token was created */
|
|
8
|
+
created: string;
|
|
9
|
+
/** Whether this token is read-only */
|
|
10
|
+
readonly: boolean;
|
|
11
|
+
/** CIDR whitelist, if any */
|
|
12
|
+
cidr_whitelist?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type RegistryTokens = {
|
|
15
|
+
registry: string;
|
|
16
|
+
alias?: string;
|
|
17
|
+
/** Masked local keychain token, if stored */
|
|
18
|
+
localToken?: string;
|
|
19
|
+
tokens: TokenInfo[];
|
|
20
|
+
error?: string;
|
|
21
|
+
};
|
|
22
|
+
export type TokenListResult = {
|
|
23
|
+
identity: string;
|
|
24
|
+
registries: RegistryTokens[];
|
|
25
|
+
};
|
|
26
|
+
export declare const needsRegistry = true;
|
|
27
|
+
export declare const usage: CommandUsage;
|
|
28
|
+
export declare const views: {
|
|
29
|
+
readonly human: (r: TokenListResult | void) => string | undefined;
|
|
30
|
+
readonly json: (r: TokenListResult | void) => TokenListResult | undefined;
|
|
31
|
+
};
|
|
32
|
+
export declare const command: CommandFn<TokenListResult | void>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { deleteToken, getKC, getToken, normalizeRegistryKey, registryBase, RegistryClient, setToken, } from '@vltpkg/registry-client';
|
|
3
|
+
import { commandUsage } from "../config/usage.js";
|
|
4
|
+
import { readPassword } from "../read-password.js";
|
|
5
|
+
import { requireRegistry } from "../require-registry.js";
|
|
6
|
+
export const needsRegistry = true;
|
|
7
|
+
export const usage = () => commandUsage({
|
|
8
|
+
command: 'token',
|
|
9
|
+
usage: ['list', 'add', 'rm'],
|
|
10
|
+
description: `Manage registry authentication tokens in the vlt keychain.
|
|
11
|
+
|
|
12
|
+
Target a specific configured registry by alias with
|
|
13
|
+
\`vlt registry <alias> token <subcommand>\`.`,
|
|
14
|
+
subcommands: {
|
|
15
|
+
list: {
|
|
16
|
+
usage: '',
|
|
17
|
+
description: `List tokens for configured registries. Shows
|
|
18
|
+
locally stored auth tokens and queries each
|
|
19
|
+
registry's token API for remote token metadata.`,
|
|
20
|
+
},
|
|
21
|
+
add: {
|
|
22
|
+
usage: '',
|
|
23
|
+
description: `Add a token for the specified registry.
|
|
24
|
+
You will be prompted to paste the bearer token.`,
|
|
25
|
+
},
|
|
26
|
+
rm: {
|
|
27
|
+
usage: '',
|
|
28
|
+
description: `Remove the stored token for the specified registry.`,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
registry: {
|
|
33
|
+
value: '<url>',
|
|
34
|
+
description: 'Registry URL to manage tokens for.',
|
|
35
|
+
},
|
|
36
|
+
registries: {
|
|
37
|
+
value: '<alias=url>',
|
|
38
|
+
description: 'Named registry aliases (used by the list subcommand).',
|
|
39
|
+
},
|
|
40
|
+
identity: {
|
|
41
|
+
value: '<name>',
|
|
42
|
+
description: 'Identity namespace used to store auth tokens.',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const formatDate = (iso) => {
|
|
47
|
+
const d = new Date(iso);
|
|
48
|
+
return d.toLocaleDateString('en-US', {
|
|
49
|
+
year: 'numeric',
|
|
50
|
+
month: 'short',
|
|
51
|
+
day: 'numeric',
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const maskToken = (token) => {
|
|
55
|
+
const bare = token.replace(/^(Bearer|Basic)\s+/i, '');
|
|
56
|
+
if (bare.length <= 8)
|
|
57
|
+
return bare + '…';
|
|
58
|
+
return bare.slice(0, 8) + '…';
|
|
59
|
+
};
|
|
60
|
+
const formatTokenEntry = (t) => {
|
|
61
|
+
const parts = [
|
|
62
|
+
`key: ${t.key}`,
|
|
63
|
+
`token: ${t.token}…`,
|
|
64
|
+
`created: ${formatDate(t.created)}`,
|
|
65
|
+
`readonly: ${t.readonly ? 'yes' : 'no'}`,
|
|
66
|
+
];
|
|
67
|
+
if (t.cidr_whitelist && t.cidr_whitelist.length > 0) {
|
|
68
|
+
parts.push(`cidr: ${t.cidr_whitelist.join(', ')}`);
|
|
69
|
+
}
|
|
70
|
+
return parts.join(' │ ');
|
|
71
|
+
};
|
|
72
|
+
const formatRegistryTokens = (r) => {
|
|
73
|
+
const header = r.alias ? `${r.alias} (${r.registry})` : r.registry;
|
|
74
|
+
const lines = [header];
|
|
75
|
+
lines.push(` local: ${r.localToken ? maskToken(r.localToken) : '(none)'}`);
|
|
76
|
+
if (!r.localToken) {
|
|
77
|
+
lines.push(' (skipped remote query — no auth token)');
|
|
78
|
+
}
|
|
79
|
+
else if (r.error) {
|
|
80
|
+
lines.push(` error: ${r.error}`);
|
|
81
|
+
}
|
|
82
|
+
else if (r.tokens.length === 0) {
|
|
83
|
+
lines.push(' (no remote tokens found)');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
for (const t of r.tokens) {
|
|
87
|
+
lines.push(` ${formatTokenEntry(t)}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return lines.join('\n');
|
|
91
|
+
};
|
|
92
|
+
export const views = {
|
|
93
|
+
human: (r) => {
|
|
94
|
+
if (!r)
|
|
95
|
+
return;
|
|
96
|
+
const header = r.identity ? `identity: ${r.identity}` : 'identity: (default)';
|
|
97
|
+
return [header, ...r.registries.map(formatRegistryTokens)].join('\n\n');
|
|
98
|
+
},
|
|
99
|
+
json: (r) => {
|
|
100
|
+
if (!r)
|
|
101
|
+
return;
|
|
102
|
+
return r;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
const listTokens = async (rc, registry, identity, alias) => {
|
|
106
|
+
const localTok = await getToken(normalizeRegistryKey(registry), identity);
|
|
107
|
+
if (!localTok) {
|
|
108
|
+
return { registry, alias, tokens: [] };
|
|
109
|
+
}
|
|
110
|
+
const tokensUrl = new URL('-/npm/v1/tokens', registryBase(registry));
|
|
111
|
+
try {
|
|
112
|
+
const objects = await rc.scroll(tokensUrl, {
|
|
113
|
+
useCache: false,
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
registry,
|
|
117
|
+
alias,
|
|
118
|
+
localToken: localTok,
|
|
119
|
+
tokens: objects.map(o => ({
|
|
120
|
+
key: o.key,
|
|
121
|
+
token: o.token,
|
|
122
|
+
created: o.created,
|
|
123
|
+
readonly: o.readonly,
|
|
124
|
+
cidr_whitelist: o.cidr_whitelist,
|
|
125
|
+
})),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
return {
|
|
130
|
+
registry,
|
|
131
|
+
alias,
|
|
132
|
+
localToken: localTok,
|
|
133
|
+
tokens: [],
|
|
134
|
+
error: err instanceof Error ? err.message : String(err),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
export const command = async (conf) => {
|
|
139
|
+
const reg = normalizeRegistryKey(requireRegistry(conf));
|
|
140
|
+
switch (conf.positionals[0]) {
|
|
141
|
+
case 'ls':
|
|
142
|
+
case 'list': {
|
|
143
|
+
const rc = new RegistryClient(conf.options);
|
|
144
|
+
const identity = conf.options.identity;
|
|
145
|
+
const registries = [];
|
|
146
|
+
const seen = new Set();
|
|
147
|
+
// Always query the default registry first
|
|
148
|
+
const defaultReg = requireRegistry(conf);
|
|
149
|
+
seen.add(normalizeRegistryKey(defaultReg));
|
|
150
|
+
registries.push(await listTokens(rc, defaultReg, identity, 'default'));
|
|
151
|
+
// Then query all configured registry aliases
|
|
152
|
+
const configuredRegistries = conf.options.registries;
|
|
153
|
+
for (const [alias, registry] of Object.entries(configuredRegistries)) {
|
|
154
|
+
const key = normalizeRegistryKey(registry);
|
|
155
|
+
if (!seen.has(key)) {
|
|
156
|
+
seen.add(key);
|
|
157
|
+
registries.push(await listTokens(rc, registry, identity, alias));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Also show any keychain entries for registries not
|
|
161
|
+
// already covered (e.g. added via `vlt token add --registry`)
|
|
162
|
+
const kc = getKC(identity);
|
|
163
|
+
for (const key of await kc.keys()) {
|
|
164
|
+
if (!seen.has(key)) {
|
|
165
|
+
seen.add(key);
|
|
166
|
+
const tok = await kc.get(key);
|
|
167
|
+
registries.push({
|
|
168
|
+
registry: key,
|
|
169
|
+
localToken: tok ?? undefined,
|
|
170
|
+
tokens: [],
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { identity, registries };
|
|
175
|
+
}
|
|
176
|
+
case 'add': {
|
|
177
|
+
await setToken(reg, `Bearer ${await readPassword('Paste bearer token: ')}`, conf.options.identity);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case 'remove':
|
|
181
|
+
case 'rm': {
|
|
182
|
+
await deleteToken(reg, conf.options.identity);
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
default: {
|
|
186
|
+
throw error('Invalid token subcommand', {
|
|
187
|
+
found: conf.positionals[0],
|
|
188
|
+
validOptions: ['list', 'ls', 'add', 'rm', 'remove'],
|
|
189
|
+
code: 'EUSAGE',
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
@@ -7,10 +7,10 @@ export type UninstallResult = {
|
|
|
7
7
|
*/
|
|
8
8
|
graph: Graph;
|
|
9
9
|
};
|
|
10
|
+
export declare const needsRegistry = true;
|
|
10
11
|
export declare const usage: CommandUsage;
|
|
11
12
|
export declare const views: {
|
|
12
13
|
readonly json: (i: UninstallResult) => import("@vltpkg/graph").LockfileData;
|
|
13
14
|
readonly human: typeof InstallReporter;
|
|
14
15
|
};
|
|
15
16
|
export declare const command: CommandFn<UninstallResult>;
|
|
16
|
-
//# sourceMappingURL=uninstall.d.ts.map
|