@vltpkg/cli-sdk 1.0.0-rc.3 → 1.0.0-rc.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/access.d.ts +22 -0
- package/dist/commands/access.js +246 -0
- package/dist/commands/bugs.d.ts +17 -0
- package/dist/commands/bugs.js +163 -0
- package/dist/{esm/commands → commands}/build.d.ts +0 -1
- package/dist/{esm/commands → commands}/build.js +0 -1
- package/dist/{esm/commands → commands}/cache.d.ts +0 -1
- package/dist/{esm/commands → commands}/cache.js +0 -1
- package/dist/{esm/commands → commands}/ci.d.ts +0 -1
- package/dist/{esm/commands → commands}/ci.js +11 -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 +8 -0
- package/dist/commands/create.js +102 -0
- package/dist/commands/deprecate.d.ts +13 -0
- package/dist/commands/deprecate.js +139 -0
- package/dist/commands/dist-tag.d.ts +21 -0
- package/dist/commands/dist-tag.js +177 -0
- package/dist/{esm/commands → commands}/docs.d.ts +0 -1
- package/dist/{esm/commands → commands}/docs.js +2 -3
- package/dist/{esm/commands → commands}/exec-cache.d.ts +0 -1
- package/dist/{esm/commands → commands}/exec-cache.js +0 -1
- package/dist/{esm/commands → 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 +0 -1
- package/dist/{esm/commands → commands}/exec.js +84 -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 +21 -3
- package/dist/commands/install.js +140 -0
- package/dist/{esm/commands → commands}/list.d.ts +4 -2
- package/dist/{esm/commands → commands}/list.js +8 -10
- package/dist/{esm/commands → commands}/login.d.ts +0 -1
- package/dist/{esm/commands → commands}/login.js +10 -1
- package/dist/{esm/commands/token.d.ts → commands/logout.d.ts} +0 -1
- package/dist/{esm/commands → commands}/logout.js +10 -1
- package/dist/{esm/commands → commands}/pack.d.ts +0 -1
- package/dist/{esm/commands → commands}/pack.js +90 -32
- package/dist/commands/ping.d.ts +17 -0
- package/dist/commands/ping.js +114 -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 +13 -0
- package/dist/commands/profile.js +104 -0
- package/dist/{esm/commands → commands}/publish.d.ts +1 -2
- package/dist/{esm/commands → commands}/publish.js +63 -12
- package/dist/{esm/commands → commands}/query.d.ts +4 -2
- package/dist/{esm/commands → commands}/query.js +12 -10
- package/dist/commands/repo.d.ts +17 -0
- package/dist/commands/repo.js +157 -0
- package/dist/{esm/commands → commands}/run-exec.d.ts +0 -1
- package/dist/commands/run-exec.js +40 -0
- package/dist/{esm/commands → commands}/run.d.ts +0 -1
- package/dist/{esm/commands → commands}/run.js +27 -1
- package/dist/commands/token.d.ts +31 -0
- package/dist/commands/token.js +186 -0
- package/dist/{esm/commands → commands}/uninstall.d.ts +0 -1
- package/dist/{esm/commands → commands}/uninstall.js +16 -3
- package/dist/commands/unpublish.d.ts +15 -0
- package/dist/commands/unpublish.js +200 -0
- package/dist/{esm/commands → commands}/update.d.ts +0 -1
- package/dist/{esm/commands → commands}/update.js +6 -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 +22 -0
- package/dist/commands/view.js +334 -0
- package/dist/{esm/commands → commands}/whoami.d.ts +0 -1
- package/dist/{esm/commands → commands}/whoami.js +10 -1
- package/dist/{esm/config → config}/definition.d.ts +39 -19
- package/dist/{esm/config → config}/definition.js +74 -39
- package/dist/{esm/config → config}/index.d.ts +0 -1
- package/dist/{esm/config → config}/index.js +37 -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} +35 -9
- 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} +1 -2
- package/dist/{esm/load-command.d.ts → load-command.d.ts} +0 -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} +55 -2
- 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} +9 -3
- package/dist/{esm/parse-add-remove-args.js → parse-add-remove-args.js} +43 -11
- package/dist/{esm/print-err.d.ts → print-err.d.ts} +0 -1
- package/dist/{esm/print-err.js → print-err.js} +18 -3
- 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/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/telemetry.d.ts +58 -0
- package/dist/telemetry.js +170 -0
- package/dist/{esm/view.d.ts → view.d.ts} +0 -1
- package/dist/{esm/view.js → view.js} +1 -2
- package/package.json +69 -83
- 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 -45
- 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.map +0 -1
- package/dist/esm/commands/logout.d.ts +0 -4
- package/dist/esm/commands/logout.d.ts.map +0 -1
- 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.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.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,139 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { PackageInfoClient } from '@vltpkg/package-info';
|
|
3
|
+
import { RegistryClient } from '@vltpkg/registry-client';
|
|
4
|
+
import { Spec } from '@vltpkg/spec';
|
|
5
|
+
import { satisfies } from '@vltpkg/semver';
|
|
6
|
+
import { asError } from '@vltpkg/types';
|
|
7
|
+
import { commandUsage } from "../config/usage.js";
|
|
8
|
+
export const usage = () => commandUsage({
|
|
9
|
+
command: 'deprecate',
|
|
10
|
+
usage: '<pkg>[@<version>] <message>',
|
|
11
|
+
description: `Update the npm registry entry for a package, providing a
|
|
12
|
+
deprecation warning to all who attempt to install it.
|
|
13
|
+
|
|
14
|
+
It works on version ranges as well as specific versions,
|
|
15
|
+
so you can un-deprecate a previously deprecated package by
|
|
16
|
+
specifying the version range with an empty string as the
|
|
17
|
+
message.`,
|
|
18
|
+
examples: {
|
|
19
|
+
'my-package "this package is no longer maintained"': {
|
|
20
|
+
description: 'Deprecate all versions of a package',
|
|
21
|
+
},
|
|
22
|
+
'my-package@"<0.2.0" "critical bug, please update"': {
|
|
23
|
+
description: 'Deprecate specific versions',
|
|
24
|
+
},
|
|
25
|
+
'my-package ""': {
|
|
26
|
+
description: 'Un-deprecate a package',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
options: {
|
|
30
|
+
registry: {
|
|
31
|
+
value: '<url>',
|
|
32
|
+
description: 'The registry to update.',
|
|
33
|
+
},
|
|
34
|
+
otp: {
|
|
35
|
+
description: `Provide an OTP to use when deprecating a package.`,
|
|
36
|
+
value: '<otp>',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
export const views = {
|
|
41
|
+
human: result => {
|
|
42
|
+
if (result.message === '') {
|
|
43
|
+
return `✅ Un-deprecated ${result.name}@${result.version} (${result.versions.length} version${result.versions.length === 1 ? '' : 's'})`;
|
|
44
|
+
}
|
|
45
|
+
return `⚠️ Deprecated ${result.name}@${result.version} (${result.versions.length} version${result.versions.length === 1 ? '' : 's'}): ${result.message}`;
|
|
46
|
+
},
|
|
47
|
+
json: r => r,
|
|
48
|
+
};
|
|
49
|
+
export const command = async (conf) => {
|
|
50
|
+
const specArg = conf.positionals[0];
|
|
51
|
+
const message = conf.positionals[1];
|
|
52
|
+
if (!specArg) {
|
|
53
|
+
throw error('deprecate requires a package spec and message argument', {
|
|
54
|
+
code: 'EUSAGE',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (message === undefined) {
|
|
58
|
+
throw error('deprecate requires a message argument', {
|
|
59
|
+
code: 'EUSAGE',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const spec = Spec.parseArgs(specArg, conf.options);
|
|
63
|
+
const { name } = spec;
|
|
64
|
+
if (!name || name === '(unknown)') {
|
|
65
|
+
throw error('could not determine package name from spec', {
|
|
66
|
+
found: specArg,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const { registry, otp } = conf.options;
|
|
70
|
+
const registryUrl = new URL(registry);
|
|
71
|
+
// Fetch the current packument
|
|
72
|
+
const pic = new PackageInfoClient(conf.options);
|
|
73
|
+
const packument = await pic.packument(spec);
|
|
74
|
+
// Determine which versions match the spec
|
|
75
|
+
const versionRange = spec.bareSpec;
|
|
76
|
+
const matchedVersions = [];
|
|
77
|
+
for (const version of Object.keys(packument.versions)) {
|
|
78
|
+
if (!versionRange || satisfies(version, versionRange)) {
|
|
79
|
+
matchedVersions.push(version);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (matchedVersions.length === 0) {
|
|
83
|
+
throw error('no versions found matching the spec', {
|
|
84
|
+
found: specArg,
|
|
85
|
+
wanted: Object.keys(packument.versions),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
// Build the update payload with deprecated field set on matched versions
|
|
89
|
+
const versions = {};
|
|
90
|
+
for (const version of matchedVersions) {
|
|
91
|
+
const manifest = packument.versions[version];
|
|
92
|
+
/* c8 ignore next */
|
|
93
|
+
if (!manifest)
|
|
94
|
+
continue;
|
|
95
|
+
versions[version] = {
|
|
96
|
+
...manifest,
|
|
97
|
+
...(message === '' ?
|
|
98
|
+
{ deprecated: undefined }
|
|
99
|
+
: { deprecated: message }),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const body = {
|
|
103
|
+
_id: name,
|
|
104
|
+
name,
|
|
105
|
+
versions,
|
|
106
|
+
};
|
|
107
|
+
const rc = new RegistryClient(conf.options);
|
|
108
|
+
const packageUrl = new URL(name.startsWith('@') ? name.replace('/', '%2F') : name, registryUrl);
|
|
109
|
+
let response;
|
|
110
|
+
try {
|
|
111
|
+
response = await rc.request(packageUrl, {
|
|
112
|
+
method: 'PUT',
|
|
113
|
+
headers: {
|
|
114
|
+
'content-type': 'application/json',
|
|
115
|
+
'npm-auth-type': 'web',
|
|
116
|
+
'npm-command': 'deprecate',
|
|
117
|
+
},
|
|
118
|
+
body: JSON.stringify(body),
|
|
119
|
+
otp,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
throw error('failed to update deprecation status', {
|
|
124
|
+
cause: asError(err),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
if (response.statusCode !== 200 && response.statusCode !== 201) {
|
|
128
|
+
throw error('failed to update deprecation status', {
|
|
129
|
+
url: packageUrl,
|
|
130
|
+
response,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
name,
|
|
135
|
+
version: versionRange || '*',
|
|
136
|
+
message,
|
|
137
|
+
versions: matchedVersions,
|
|
138
|
+
};
|
|
139
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export declare const usage: CommandUsage;
|
|
3
|
+
export type DistTagLsResult = {
|
|
4
|
+
id: string;
|
|
5
|
+
tags: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
export type DistTagAddResult = {
|
|
8
|
+
id: string;
|
|
9
|
+
tag: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
export type DistTagRmResult = {
|
|
13
|
+
id: string;
|
|
14
|
+
tag: string;
|
|
15
|
+
};
|
|
16
|
+
export type CommandResult = DistTagLsResult | DistTagAddResult | DistTagRmResult;
|
|
17
|
+
export declare const views: {
|
|
18
|
+
readonly human: (result: CommandResult) => string;
|
|
19
|
+
readonly json: (r: CommandResult) => CommandResult;
|
|
20
|
+
};
|
|
21
|
+
export declare const command: CommandFn<CommandResult>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { error } from '@vltpkg/error-cause';
|
|
2
|
+
import { RegistryClient } from '@vltpkg/registry-client';
|
|
3
|
+
import { Spec } from '@vltpkg/spec';
|
|
4
|
+
import { commandUsage } from "../config/usage.js";
|
|
5
|
+
export const usage = () => commandUsage({
|
|
6
|
+
command: 'dist-tag',
|
|
7
|
+
usage: [
|
|
8
|
+
'add <pkg>@<version> [<tag>]',
|
|
9
|
+
'rm <pkg> <tag>',
|
|
10
|
+
'ls [<pkg>]',
|
|
11
|
+
],
|
|
12
|
+
description: `Manage distribution tags for a package.
|
|
13
|
+
|
|
14
|
+
Distribution tags (dist-tags) provide aliases for package versions,
|
|
15
|
+
allowing users to install specific versions using tag names instead
|
|
16
|
+
of version numbers. The most common tag is \`latest\`, which is used
|
|
17
|
+
by default when no tag is specified during install.`,
|
|
18
|
+
subcommands: {
|
|
19
|
+
add: {
|
|
20
|
+
usage: '<pkg>@<version> [<tag>]',
|
|
21
|
+
description: 'Tag the specified version of a package with the given tag, or "latest" if unspecified.',
|
|
22
|
+
},
|
|
23
|
+
rm: {
|
|
24
|
+
usage: '<pkg> <tag>',
|
|
25
|
+
description: 'Remove a dist-tag from a package.',
|
|
26
|
+
},
|
|
27
|
+
ls: {
|
|
28
|
+
usage: '[<pkg>]',
|
|
29
|
+
description: 'List all dist-tags for a package, defaulting to the package in the current directory.',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
options: {
|
|
33
|
+
registry: {
|
|
34
|
+
value: '<url>',
|
|
35
|
+
description: 'Registry URL to manage dist-tags for.',
|
|
36
|
+
},
|
|
37
|
+
identity: {
|
|
38
|
+
value: '<name>',
|
|
39
|
+
description: 'Identity namespace used to look up auth tokens.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const isLsResult = (r) => 'tags' in r;
|
|
44
|
+
const isAddResult = (r) => 'version' in r;
|
|
45
|
+
export const views = {
|
|
46
|
+
human: result => {
|
|
47
|
+
if (isLsResult(result)) {
|
|
48
|
+
const entries = Object.entries(result.tags);
|
|
49
|
+
if (entries.length === 0)
|
|
50
|
+
return 'No dist-tags found.';
|
|
51
|
+
return entries
|
|
52
|
+
.map(([tag, version]) => `${tag}: ${version}`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
}
|
|
55
|
+
if (isAddResult(result)) {
|
|
56
|
+
return `+${result.tag}: ${result.id}@${result.version}`;
|
|
57
|
+
}
|
|
58
|
+
return `-${result.tag}: ${result.id}`;
|
|
59
|
+
},
|
|
60
|
+
json: r => r,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Build the dist-tags API URL for a package.
|
|
64
|
+
* Uses the `/-/package/{name}/dist-tags` endpoint.
|
|
65
|
+
*/
|
|
66
|
+
const distTagsUrl = (name, registry, tag) => {
|
|
67
|
+
const encoded = name.startsWith('@') ? name.replace('/', '%2f') : name;
|
|
68
|
+
const path = tag ?
|
|
69
|
+
`-/package/${encoded}/dist-tags/${encodeURIComponent(tag)}`
|
|
70
|
+
: `-/package/${encoded}/dist-tags`;
|
|
71
|
+
return new URL(path, registry);
|
|
72
|
+
};
|
|
73
|
+
const readPackageName = (positional, conf) => {
|
|
74
|
+
if (positional) {
|
|
75
|
+
const spec = Spec.parseArgs(positional, conf.options);
|
|
76
|
+
return spec.name;
|
|
77
|
+
}
|
|
78
|
+
const manifest = conf.options.packageJson.maybeRead(conf.projectRoot);
|
|
79
|
+
if (manifest?.name)
|
|
80
|
+
return manifest.name;
|
|
81
|
+
throw error('Could not determine package name', {
|
|
82
|
+
code: 'EUSAGE',
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export const command = async (conf) => {
|
|
86
|
+
const [sub, ...args] = conf.positionals;
|
|
87
|
+
if (!sub) {
|
|
88
|
+
throw error('dist-tag command requires a subcommand', {
|
|
89
|
+
code: 'EUSAGE',
|
|
90
|
+
validOptions: ['add', 'rm', 'remove', 'ls', 'list'],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const rc = new RegistryClient(conf.options);
|
|
94
|
+
const registry = conf.options.registry;
|
|
95
|
+
switch (sub) {
|
|
96
|
+
case 'add': {
|
|
97
|
+
const specArg = args[0];
|
|
98
|
+
if (!specArg) {
|
|
99
|
+
throw error('dist-tag add requires a package@version argument', {
|
|
100
|
+
code: 'EUSAGE',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const spec = Spec.parseArgs(specArg, conf.options);
|
|
104
|
+
const name = spec.name;
|
|
105
|
+
const version = spec.bareSpec;
|
|
106
|
+
if (!version) {
|
|
107
|
+
throw error('dist-tag add requires a version in the spec', {
|
|
108
|
+
code: 'EUSAGE',
|
|
109
|
+
found: specArg,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const tag = args[1] ?? conf.options.tag;
|
|
113
|
+
const url = distTagsUrl(name, registry, tag);
|
|
114
|
+
const response = await rc.request(url, {
|
|
115
|
+
method: 'PUT',
|
|
116
|
+
headers: {
|
|
117
|
+
'content-type': 'application/json',
|
|
118
|
+
},
|
|
119
|
+
body: JSON.stringify(version),
|
|
120
|
+
useCache: false,
|
|
121
|
+
});
|
|
122
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
123
|
+
throw error('Failed to add dist-tag', {
|
|
124
|
+
url,
|
|
125
|
+
response,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return { id: name, tag, version };
|
|
129
|
+
}
|
|
130
|
+
case 'rm':
|
|
131
|
+
case 'remove': {
|
|
132
|
+
const pkgArg = args[0];
|
|
133
|
+
const tag = args[1];
|
|
134
|
+
if (!pkgArg || !tag) {
|
|
135
|
+
throw error('dist-tag rm requires a package name and tag', {
|
|
136
|
+
code: 'EUSAGE',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const name = readPackageName(pkgArg, conf);
|
|
140
|
+
const url = distTagsUrl(name, registry, tag);
|
|
141
|
+
const response = await rc.request(url, {
|
|
142
|
+
method: 'DELETE',
|
|
143
|
+
useCache: false,
|
|
144
|
+
});
|
|
145
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
146
|
+
throw error('Failed to remove dist-tag', {
|
|
147
|
+
url,
|
|
148
|
+
response,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return { id: name, tag };
|
|
152
|
+
}
|
|
153
|
+
case 'ls':
|
|
154
|
+
case 'list': {
|
|
155
|
+
const name = readPackageName(args[0], conf);
|
|
156
|
+
const url = distTagsUrl(name, registry);
|
|
157
|
+
const response = await rc.request(url, {
|
|
158
|
+
useCache: false,
|
|
159
|
+
});
|
|
160
|
+
if (response.statusCode < 200 || response.statusCode >= 300) {
|
|
161
|
+
throw error('Failed to list dist-tags', {
|
|
162
|
+
url,
|
|
163
|
+
response,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const tags = response.json();
|
|
167
|
+
return { id: name, tags };
|
|
168
|
+
}
|
|
169
|
+
default: {
|
|
170
|
+
throw error('Invalid dist-tag subcommand', {
|
|
171
|
+
found: sub,
|
|
172
|
+
validOptions: ['add', 'rm', 'remove', 'ls', 'list'],
|
|
173
|
+
code: 'EUSAGE',
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
@@ -67,9 +67,9 @@ const getUrlFromManifest = (manifest) => {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
// Fallback to
|
|
70
|
+
// Fallback to vlt.io package page
|
|
71
71
|
if (!url) {
|
|
72
|
-
url = `https://
|
|
72
|
+
url = `https://vlt.io/explore/npm/${name}/overview`;
|
|
73
73
|
}
|
|
74
74
|
return url;
|
|
75
75
|
};
|
|
@@ -151,4 +151,3 @@ export const command = async (conf) => {
|
|
|
151
151
|
await urlOpen(url);
|
|
152
152
|
return { url, name };
|
|
153
153
|
};
|
|
154
|
-
//# sourceMappingURL=docs.js.map
|
|
@@ -16,9 +16,31 @@ export const usage = () => commandUsage({
|
|
|
16
16
|
Note that any vlt configs must be specified *before* the
|
|
17
17
|
command, as the remainder of the command line options are
|
|
18
18
|
provided to the exec process.`,
|
|
19
|
+
options: {
|
|
20
|
+
scope: {
|
|
21
|
+
value: '<query>',
|
|
22
|
+
description: 'Filter execution targets using a DSS query.',
|
|
23
|
+
},
|
|
24
|
+
workspace: {
|
|
25
|
+
value: '<path|glob>',
|
|
26
|
+
description: 'Limit execution to matching workspace paths or globs.',
|
|
27
|
+
},
|
|
28
|
+
'workspace-group': {
|
|
29
|
+
value: '<name>',
|
|
30
|
+
description: 'Limit execution to named workspace groups.',
|
|
31
|
+
},
|
|
32
|
+
recursive: {
|
|
33
|
+
description: 'Run across all selected workspaces.',
|
|
34
|
+
},
|
|
35
|
+
'if-present': {
|
|
36
|
+
description: 'When running across multiple packages, only include packages with matching scripts.',
|
|
37
|
+
},
|
|
38
|
+
bail: {
|
|
39
|
+
description: 'When running across multiple workspaces, stop on first failure.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
19
42
|
});
|
|
20
43
|
export const command = async (conf) => {
|
|
21
44
|
delete conf.options['script-shell'];
|
|
22
45
|
return await new ExecCommand(conf, exec, execFG).run();
|
|
23
46
|
};
|
|
24
|
-
//# sourceMappingURL=exec-local.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { exec, execFG } from '@vltpkg/run';
|
|
2
2
|
import * as vlx from '@vltpkg/vlx';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
|
+
import { env, platform } from 'node:process';
|
|
4
5
|
import { createInterface } from 'node:readline/promises';
|
|
5
6
|
import { commandUsage } from "../config/usage.js";
|
|
6
7
|
import { ExecCommand } from "../exec-command.js";
|
|
@@ -8,14 +9,14 @@ import { styleTextStdout } from "../output.js";
|
|
|
8
9
|
export { views } from "../exec-command.js";
|
|
9
10
|
export const usage = () => commandUsage({
|
|
10
11
|
command: 'exec',
|
|
11
|
-
usage: '[--package=<pkg>] [command...]',
|
|
12
|
+
usage: '[--package=<pkg>] [--call=<cmd>] [command...]',
|
|
12
13
|
description: `Run a command defined by a package, installing it
|
|
13
14
|
if necessary.
|
|
14
15
|
|
|
15
16
|
If the package specifier is provided explicitly via the
|
|
16
17
|
\`--package\` config, then that is what will be used. If
|
|
17
18
|
a satisfying instance of the named package exists in the
|
|
18
|
-
local \`
|
|
19
|
+
local \`node_modules\` folder, then that will be used.
|
|
19
20
|
|
|
20
21
|
If \`--package\` is not set, then vlt will attempt to infer
|
|
21
22
|
the package to be installed if necessary, in the following
|
|
@@ -55,6 +56,51 @@ export const usage = () => commandUsage({
|
|
|
55
56
|
'eslint@9.24 src/file.js': {
|
|
56
57
|
description: 'Run the default bin provided by eslint version 9.24',
|
|
57
58
|
},
|
|
59
|
+
'create-react-app --call="echo $PWD"': {
|
|
60
|
+
description: 'Install create-react-app and run an arbitrary command with its bins in PATH',
|
|
61
|
+
},
|
|
62
|
+
'--call="echo $PWD" --scope=":workspace"': {
|
|
63
|
+
description: 'Run an arbitrary command in the context of each workspace',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
options: {
|
|
67
|
+
package: {
|
|
68
|
+
value: '<specifier>',
|
|
69
|
+
description: 'Explicitly set the package to search for bins.',
|
|
70
|
+
},
|
|
71
|
+
call: {
|
|
72
|
+
value: '<cmd>',
|
|
73
|
+
description: 'Run an arbitrary command string after installing any specified package and adding its bins to PATH.',
|
|
74
|
+
},
|
|
75
|
+
'allow-scripts': {
|
|
76
|
+
value: '<query>',
|
|
77
|
+
description: 'Filter which packages are allowed to run lifecycle scripts using DSS query syntax.',
|
|
78
|
+
},
|
|
79
|
+
scope: {
|
|
80
|
+
value: '<query>',
|
|
81
|
+
description: 'Filter execution targets using a DSS query.',
|
|
82
|
+
},
|
|
83
|
+
workspace: {
|
|
84
|
+
value: '<path|glob>',
|
|
85
|
+
description: 'Limit execution to matching workspace paths or globs.',
|
|
86
|
+
},
|
|
87
|
+
'workspace-group': {
|
|
88
|
+
value: '<name>',
|
|
89
|
+
description: 'Limit execution to named workspace groups.',
|
|
90
|
+
},
|
|
91
|
+
recursive: {
|
|
92
|
+
description: 'Run across all selected workspaces.',
|
|
93
|
+
},
|
|
94
|
+
'if-present': {
|
|
95
|
+
description: 'When running across multiple packages, only include packages with matching scripts.',
|
|
96
|
+
},
|
|
97
|
+
bail: {
|
|
98
|
+
description: 'When running across multiple workspaces, stop on first failure.',
|
|
99
|
+
},
|
|
100
|
+
'script-shell': {
|
|
101
|
+
value: '<shell>',
|
|
102
|
+
description: 'The shell to use for --call commands and script execution.',
|
|
103
|
+
},
|
|
58
104
|
},
|
|
59
105
|
});
|
|
60
106
|
const HOME = homedir();
|
|
@@ -73,15 +119,43 @@ export const command = async (conf) => {
|
|
|
73
119
|
String(conf.get('allow-scripts'))
|
|
74
120
|
: ':not(*)';
|
|
75
121
|
/* c8 ignore stop */
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
122
|
+
const callOption = conf.get('call');
|
|
123
|
+
if (callOption) {
|
|
124
|
+
// Install any specified package and add its bins to PATH, but don't
|
|
125
|
+
// use its default executable - the --call string is the command to run.
|
|
126
|
+
// Only install when a package is explicitly defined (via --package flag
|
|
127
|
+
// or as a positional argument). Don't prompt for confirmation since the
|
|
128
|
+
// user's explicit --call command implies consent.
|
|
129
|
+
const pkgOption = conf.get('package') ?? conf.positionals[0];
|
|
130
|
+
if (pkgOption) {
|
|
131
|
+
await vlx.resolve([], {
|
|
132
|
+
...conf.options,
|
|
133
|
+
package: pkgOption,
|
|
134
|
+
query: undefined,
|
|
135
|
+
allowScripts,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// Determine the shell to use for the --call command
|
|
139
|
+
const shell = conf.get('script-shell') ??
|
|
140
|
+
env.SHELL ??
|
|
141
|
+
/* c8 ignore next */
|
|
142
|
+
(platform === 'win32' ? 'cmd.exe' : '/bin/sh');
|
|
143
|
+
// cmd.exe uses '/c', all other shells use '-c'
|
|
144
|
+
/* c8 ignore next */
|
|
145
|
+
const shellFlag = shell === 'cmd.exe' ? '/c' : '-c';
|
|
146
|
+
// Replace positionals with [shell, shellFlag, callOption]
|
|
147
|
+
conf.positionals.splice(0, conf.positionals.length, shell, shellFlag, callOption);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const arg0 = await vlx.resolve(conf.positionals, {
|
|
151
|
+
...conf.options,
|
|
152
|
+
query: undefined,
|
|
153
|
+
allowScripts,
|
|
154
|
+
}, promptFn);
|
|
155
|
+
if (arg0)
|
|
156
|
+
conf.positionals[0] = arg0;
|
|
157
|
+
}
|
|
83
158
|
// now we have arg0! let's gooooo!!
|
|
84
159
|
delete conf.options['script-shell'];
|
|
85
160
|
return await new ExecCommand(conf, exec, execFG).run();
|
|
86
161
|
};
|
|
87
|
-
//# sourceMappingURL=exec.js.map
|
|
@@ -12,6 +12,11 @@ export const usage = () => commandUsage({
|
|
|
12
12
|
install: { description: 'Show help for the install command' },
|
|
13
13
|
run: { description: 'Show help for the run command' },
|
|
14
14
|
},
|
|
15
|
+
options: {
|
|
16
|
+
all: {
|
|
17
|
+
description: 'Show all commands, bins, and flags.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
15
20
|
});
|
|
16
21
|
export const command = async (conf) => {
|
|
17
22
|
// If no positional arguments, show general help
|
|
@@ -36,4 +41,3 @@ export const command = async (conf) => {
|
|
|
36
41
|
const command = await loadCommand(canonicalCmd);
|
|
37
42
|
return command.usage().usage();
|
|
38
43
|
};
|
|
39
|
-
//# sourceMappingURL=help.js.map
|
|
@@ -2,13 +2,22 @@ import { mkdirSync } from 'node:fs';
|
|
|
2
2
|
import { relative, resolve } from 'node:path';
|
|
3
3
|
import { minimatch } from 'minimatch';
|
|
4
4
|
import { init } from '@vltpkg/init';
|
|
5
|
+
import { install } from '@vltpkg/graph';
|
|
5
6
|
import { load, save } from '@vltpkg/vlt-json';
|
|
6
7
|
import { assertWSConfig, asWSConfig } from '@vltpkg/workspaces';
|
|
7
8
|
import { commandUsage } from "../config/usage.js";
|
|
8
9
|
export const usage = () => commandUsage({
|
|
9
10
|
command: 'init',
|
|
10
11
|
usage: '',
|
|
11
|
-
description: `
|
|
12
|
+
description: `Initialize a new project in the current directory.
|
|
13
|
+
Creates a package.json, a .gitignore, and installs
|
|
14
|
+
dependencies so the project is ready to use immediately.`,
|
|
15
|
+
options: {
|
|
16
|
+
workspace: {
|
|
17
|
+
value: '<path|glob>',
|
|
18
|
+
description: 'Create package.json files in matching workspaces.',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
12
21
|
});
|
|
13
22
|
// TODO: colorize the JSON if config.options.color
|
|
14
23
|
export const views = {
|
|
@@ -17,17 +26,20 @@ export const views = {
|
|
|
17
26
|
// if results is an array, it means multiple workspaces were initialized
|
|
18
27
|
if (Array.isArray(results)) {
|
|
19
28
|
for (const result of results) {
|
|
20
|
-
for (const [type,
|
|
21
|
-
output.push(`Wrote ${type} to ${path}
|
|
29
|
+
for (const [type, value] of Object.entries(result)) {
|
|
30
|
+
output.push(`Wrote ${type} to ${value.path}`);
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
}
|
|
25
34
|
else {
|
|
26
35
|
// otherwise, it's a single result
|
|
27
|
-
for (const [type,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
for (const [type, value] of Object.entries(results)) {
|
|
37
|
+
if ('data' in value) {
|
|
38
|
+
output.push(`Wrote ${type} to ${value.path}:\n\n${JSON.stringify(value.data, null, 2)}`);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
output.push(`Wrote ${type} to ${value.path}`);
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
output.push(`\nModify/add properties using \`vlt pkg\`. For example:
|
|
@@ -37,6 +49,11 @@ ${JSON.stringify(data, null, 2)}`);
|
|
|
37
49
|
},
|
|
38
50
|
};
|
|
39
51
|
export const command = async (conf) => {
|
|
52
|
+
/* c8 ignore start */
|
|
53
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
54
|
+
String(conf.get('allow-scripts'))
|
|
55
|
+
: ':not(*)';
|
|
56
|
+
/* c8 ignore stop */
|
|
40
57
|
if (conf.values.workspace?.length) {
|
|
41
58
|
const workspacesConfig = load('workspaces', assertWSConfig);
|
|
42
59
|
const parsedWSConfig = asWSConfig(workspacesConfig ?? {});
|
|
@@ -78,7 +95,7 @@ export const command = async (conf) => {
|
|
|
78
95
|
else {
|
|
79
96
|
// otherwise we assume it's an Record<string, string[]> object
|
|
80
97
|
// and we'll add the new workspaces to the `packages` keys
|
|
81
|
-
workspaces =
|
|
98
|
+
workspaces = workspacesConfig ?? {};
|
|
82
99
|
// if the `packages` key is not being used
|
|
83
100
|
if (!workspaces.packages) {
|
|
84
101
|
workspaces.packages = addToConfig;
|
|
@@ -104,8 +121,12 @@ export const command = async (conf) => {
|
|
|
104
121
|
// finally, we add the new workspaces to the config file
|
|
105
122
|
save('workspaces', workspaces);
|
|
106
123
|
}
|
|
124
|
+
// run install to set up node_modules and vlt-lock.json
|
|
125
|
+
await install({ ...conf.options, allowScripts });
|
|
107
126
|
return results;
|
|
108
127
|
}
|
|
109
|
-
|
|
128
|
+
const result = await init({ cwd: process.cwd() });
|
|
129
|
+
// run install to set up node_modules and vlt-lock.json
|
|
130
|
+
await install({ ...conf.options, allowScripts });
|
|
131
|
+
return result;
|
|
110
132
|
};
|
|
111
|
-
//# sourceMappingURL=init.js.map
|