@vltpkg/cli-sdk 0.0.0-3 → 0.0.0-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/README.md +3 -0
- package/dist/esm/commands/build.d.ts +25 -0
- package/dist/esm/commands/build.d.ts.map +1 -0
- package/dist/esm/commands/build.js +102 -0
- package/dist/esm/commands/build.js.map +1 -0
- package/dist/esm/commands/cache.d.ts +65 -0
- package/dist/esm/commands/cache.d.ts.map +1 -0
- package/dist/esm/commands/cache.js +257 -0
- package/dist/esm/commands/cache.js.map +1 -0
- package/dist/esm/commands/ci.d.ts +11 -0
- package/dist/esm/commands/ci.d.ts.map +1 -0
- package/dist/esm/commands/ci.js +32 -0
- package/dist/esm/commands/ci.js.map +1 -0
- package/dist/esm/commands/config.d.ts +3 -2
- package/dist/esm/commands/config.d.ts.map +1 -1
- package/dist/esm/commands/config.js +372 -101
- package/dist/esm/commands/config.js.map +1 -1
- package/dist/esm/commands/exec-cache.d.ts +49 -0
- package/dist/esm/commands/exec-cache.d.ts.map +1 -0
- package/dist/esm/commands/exec-cache.js +146 -0
- package/dist/esm/commands/exec-cache.js.map +1 -0
- package/dist/esm/commands/exec-local.d.ts +6 -0
- package/dist/esm/commands/exec-local.d.ts.map +1 -0
- package/dist/esm/commands/exec-local.js +24 -0
- package/dist/esm/commands/exec-local.js.map +1 -0
- package/dist/esm/commands/exec.d.ts +4 -0
- package/dist/esm/commands/exec.d.ts.map +1 -1
- package/dist/esm/commands/exec.js +75 -10
- package/dist/esm/commands/exec.js.map +1 -1
- package/dist/esm/commands/help.d.ts +1 -1
- package/dist/esm/commands/help.d.ts.map +1 -1
- package/dist/esm/commands/help.js +25 -3
- package/dist/esm/commands/help.js.map +1 -1
- package/dist/esm/commands/init.d.ts +4 -5
- package/dist/esm/commands/init.d.ts.map +1 -1
- package/dist/esm/commands/init.js +95 -9
- package/dist/esm/commands/init.js.map +1 -1
- package/dist/esm/commands/install/reporter.d.ts +3 -2
- package/dist/esm/commands/install/reporter.d.ts.map +1 -1
- package/dist/esm/commands/install/reporter.js +43 -15
- package/dist/esm/commands/install/reporter.js.map +1 -1
- package/dist/esm/commands/install.d.ts +24 -3
- package/dist/esm/commands/install.d.ts.map +1 -1
- package/dist/esm/commands/install.js +27 -3
- package/dist/esm/commands/install.js.map +1 -1
- package/dist/esm/commands/list.d.ts +1 -1
- package/dist/esm/commands/list.d.ts.map +1 -1
- package/dist/esm/commands/list.js +150 -42
- package/dist/esm/commands/list.js.map +1 -1
- package/dist/esm/commands/pack.d.ts +32 -0
- package/dist/esm/commands/pack.d.ts.map +1 -0
- package/dist/esm/commands/pack.js +147 -0
- package/dist/esm/commands/pack.js.map +1 -0
- package/dist/esm/commands/pkg.d.ts +2 -3
- package/dist/esm/commands/pkg.d.ts.map +1 -1
- package/dist/esm/commands/pkg.js +123 -38
- package/dist/esm/commands/pkg.js.map +1 -1
- package/dist/esm/commands/publish.d.ts +22 -0
- package/dist/esm/commands/publish.d.ts.map +1 -0
- package/dist/esm/commands/publish.js +239 -0
- package/dist/esm/commands/publish.js.map +1 -0
- package/dist/esm/commands/query.d.ts +1 -1
- package/dist/esm/commands/query.d.ts.map +1 -1
- package/dist/esm/commands/query.js +171 -32
- package/dist/esm/commands/query.js.map +1 -1
- package/dist/esm/commands/run-exec.d.ts +1 -0
- package/dist/esm/commands/run-exec.d.ts.map +1 -1
- package/dist/esm/commands/run-exec.js +1 -0
- package/dist/esm/commands/run-exec.js.map +1 -1
- package/dist/esm/commands/run.d.ts +1 -0
- package/dist/esm/commands/run.d.ts.map +1 -1
- package/dist/esm/commands/run.js +13 -16
- package/dist/esm/commands/run.js.map +1 -1
- package/dist/esm/commands/serve.d.ts +14 -0
- package/dist/esm/commands/serve.d.ts.map +1 -0
- package/dist/esm/commands/serve.js +103 -0
- package/dist/esm/commands/serve.js.map +1 -0
- package/dist/esm/commands/uninstall.d.ts +13 -1
- package/dist/esm/commands/uninstall.d.ts.map +1 -1
- package/dist/esm/commands/uninstall.js +12 -1
- package/dist/esm/commands/uninstall.js.map +1 -1
- package/dist/esm/commands/update.d.ts +14 -0
- package/dist/esm/commands/update.d.ts.map +1 -0
- package/dist/esm/commands/update.js +41 -0
- package/dist/esm/commands/update.js.map +1 -0
- package/dist/esm/commands/version.d.ts +26 -0
- package/dist/esm/commands/version.d.ts.map +1 -0
- package/dist/esm/commands/version.js +226 -0
- package/dist/esm/commands/version.js.map +1 -0
- package/dist/esm/commands/whoami.d.ts +4 -2
- package/dist/esm/commands/whoami.d.ts.map +1 -1
- package/dist/esm/commands/whoami.js +1 -1
- package/dist/esm/commands/whoami.js.map +1 -1
- package/dist/esm/config/definition.d.ts +117 -10
- package/dist/esm/config/definition.d.ts.map +1 -1
- package/dist/esm/config/definition.js +203 -31
- package/dist/esm/config/definition.js.map +1 -1
- package/dist/esm/config/index.d.ts +46 -40
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +126 -176
- package/dist/esm/config/index.js.map +1 -1
- package/dist/esm/config/merge.d.ts +3 -1
- package/dist/esm/config/merge.d.ts.map +1 -1
- package/dist/esm/config/merge.js +11 -6
- package/dist/esm/config/merge.js.map +1 -1
- package/dist/esm/config/usage.d.ts +3 -2
- package/dist/esm/config/usage.d.ts.map +1 -1
- package/dist/esm/config/usage.js.map +1 -1
- package/dist/esm/exec-command.d.ts +33 -14
- package/dist/esm/exec-command.d.ts.map +1 -1
- package/dist/esm/exec-command.js +214 -65
- package/dist/esm/exec-command.js.map +1 -1
- package/dist/esm/index.d.ts +1 -14
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +46 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/load-command.d.ts +16 -0
- package/dist/esm/load-command.d.ts.map +1 -0
- package/dist/esm/load-command.js +21 -0
- package/dist/esm/load-command.js.map +1 -0
- package/dist/esm/output.d.ts +6 -10
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +63 -33
- package/dist/esm/output.js.map +1 -1
- package/dist/esm/pack-tarball.d.ts +22 -0
- package/dist/esm/pack-tarball.d.ts.map +1 -0
- package/dist/esm/pack-tarball.js +247 -0
- package/dist/esm/pack-tarball.js.map +1 -0
- package/dist/esm/parse-add-remove-args.d.ts +1 -1
- package/dist/esm/parse-add-remove-args.d.ts.map +1 -1
- package/dist/esm/parse-add-remove-args.js +1 -1
- package/dist/esm/parse-add-remove-args.js.map +1 -1
- package/dist/esm/print-err.d.ts +12 -1
- package/dist/esm/print-err.d.ts.map +1 -1
- package/dist/esm/print-err.js +157 -26
- package/dist/esm/print-err.js.map +1 -1
- package/dist/esm/query-host-contexts.d.ts +16 -0
- package/dist/esm/query-host-contexts.d.ts.map +1 -0
- package/dist/esm/query-host-contexts.js +135 -0
- package/dist/esm/query-host-contexts.js.map +1 -0
- package/dist/esm/start-gui.d.ts +7 -33
- package/dist/esm/start-gui.d.ts.map +1 -1
- package/dist/esm/start-gui.js +51 -349
- package/dist/esm/start-gui.js.map +1 -1
- package/dist/esm/view.d.ts +2 -3
- package/dist/esm/view.d.ts.map +1 -1
- package/dist/esm/view.js +1 -1
- package/dist/esm/view.js.map +1 -1
- package/package.json +73 -45
- package/dist/esm/commands/gui.d.ts +0 -6
- package/dist/esm/commands/gui.d.ts.map +0 -1
- package/dist/esm/commands/gui.js +0 -14
- package/dist/esm/commands/gui.js.map +0 -1
- package/dist/esm/commands/install-exec.d.ts +0 -4
- package/dist/esm/commands/install-exec.d.ts.map +0 -1
- package/dist/esm/commands/install-exec.js +0 -13
- package/dist/esm/commands/install-exec.js.map +0 -1
- package/dist/esm/ignored-homedir-folder-names.d.ts +0 -7
- package/dist/esm/ignored-homedir-folder-names.d.ts.map +0 -1
- package/dist/esm/ignored-homedir-folder-names.js +0 -35
- package/dist/esm/ignored-homedir-folder-names.js.map +0 -1
- package/dist/esm/project-info.d.ts +0 -32
- package/dist/esm/project-info.d.ts.map +0 -1
- package/dist/esm/project-info.js +0 -90
- package/dist/esm/project-info.js.map +0 -1
- package/dist/esm/read-project-folders.d.ts +0 -27
- package/dist/esm/read-project-folders.d.ts.map +0 -1
- package/dist/esm/read-project-folders.js +0 -66
- package/dist/esm/read-project-folders.js.map +0 -1
package/dist/esm/commands/run.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { PackageJson } from '@vltpkg/package-json';
|
|
2
1
|
import { run, runFG } from '@vltpkg/run';
|
|
3
2
|
import { commandUsage } from "../config/usage.js";
|
|
4
3
|
import { ExecCommand } from "../exec-command.js";
|
|
5
|
-
|
|
4
|
+
export { views } from "../exec-command.js";
|
|
6
5
|
export const usage = () => commandUsage({
|
|
7
6
|
command: 'run',
|
|
8
7
|
usage: '<script> [args ...]',
|
|
@@ -15,24 +14,22 @@ class RunCommand extends ExecCommand {
|
|
|
15
14
|
constructor(conf) {
|
|
16
15
|
super(conf, run, runFG);
|
|
17
16
|
}
|
|
18
|
-
|
|
17
|
+
// do not provide the interactive shell arg, just do nothing
|
|
18
|
+
// so that it falls back up to the noArgsSingle() method
|
|
19
|
+
defaultArg0() { }
|
|
20
|
+
noArgsSingle() {
|
|
19
21
|
// called when there's no arg0, with a single workspace or root
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const mani = packageJson.read(cwd);
|
|
24
|
-
stdout('Scripts available:', mani.scripts);
|
|
25
|
-
return undefined;
|
|
22
|
+
const cwd = this.getCwd();
|
|
23
|
+
const { scripts = {} } = this.conf.options.packageJson.read(cwd);
|
|
24
|
+
return scripts;
|
|
26
25
|
}
|
|
27
26
|
noArgsMulti() {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
stdout('Scripts available:');
|
|
33
|
-
for (const [ws, scripts] of m.runSync(ws => ws.manifest.scripts)) {
|
|
34
|
-
stdout(ws.path, scripts);
|
|
27
|
+
const scripts = {};
|
|
28
|
+
for (const { label, manifest } of this.getTargets()) {
|
|
29
|
+
if (manifest.scripts)
|
|
30
|
+
scripts[label] = manifest.scripts;
|
|
35
31
|
}
|
|
32
|
+
return scripts;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
export const command = async (conf) => await new RunCommand(conf).run();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAGhD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EAAE;;;sCAGqB;CACnC,CAAC,CAAA;AAEJ,MAAM,UAAW,SAAQ,WAAqC;IAC5D,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;IACzB,CAAC;IAED,4DAA4D;IAC5D,wDAAwD;IACxD,WAAW,KAAe,CAAC;IAE3B,YAAY;QACV,+DAA+D;QAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QACzB,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAChE,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,WAAW;QACT,MAAM,OAAO,GAAmB,EAAE,CAAA;QAClC,KAAK,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACpD,IAAI,QAAQ,CAAC,OAAO;gBAAE,OAAO,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAA;QACzD,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAA0B,KAAK,EAAC,IAAI,EAAC,EAAE,CACzD,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,CAAA","sourcesContent":["import { run, runFG } from '@vltpkg/run'\nimport type { LoadedConfig } from '../config/index.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport type {\n ExecResult,\n MultiScriptSet,\n ScriptSet,\n} from '../exec-command.ts'\nimport { ExecCommand } from '../exec-command.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\n\nexport { views } from '../exec-command.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'run',\n usage: '<script> [args ...]',\n description: `Run a script defined in 'package.json', passing along any extra\n arguments. Note that vlt config values must be specified *before*\n the script name, because everything after that is handed off to\n the script process.`,\n })\n\nclass RunCommand extends ExecCommand<typeof run, typeof runFG> {\n constructor(conf: LoadedConfig) {\n super(conf, run, runFG)\n }\n\n // do not provide the interactive shell arg, just do nothing\n // so that it falls back up to the noArgsSingle() method\n defaultArg0(): undefined {}\n\n noArgsSingle(): ScriptSet {\n // called when there's no arg0, with a single workspace or root\n const cwd = this.getCwd()\n const { scripts = {} } = this.conf.options.packageJson.read(cwd)\n return scripts\n }\n\n noArgsMulti(): MultiScriptSet {\n const scripts: MultiScriptSet = {}\n for (const { label, manifest } of this.getTargets()) {\n if (manifest.scripts) scripts[label] = manifest.scripts\n }\n return scripts\n }\n}\n\nexport const command: CommandFn<ExecResult> = async conf =>\n await new RunCommand(conf).run()\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export declare const usage: CommandUsage;
|
|
3
|
+
export type ServeResult = {
|
|
4
|
+
guiPort: number;
|
|
5
|
+
registryPort: number;
|
|
6
|
+
uiURL: string;
|
|
7
|
+
registryURL: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const views: {
|
|
10
|
+
readonly human: (result: ServeResult) => void;
|
|
11
|
+
readonly json: (result: ServeResult) => ServeResult;
|
|
12
|
+
};
|
|
13
|
+
export declare const command: CommandFn<ServeResult>;
|
|
14
|
+
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAI1D,eAAO,MAAM,KAAK,EAAE,YAyBhB,CAAA;AAEJ,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,KAAK;6BACA,WAAW;4BAcZ,WAAW;CACW,CAAA;AAEvC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,WAAW,CAuE1C,CAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { onExit } from 'signal-exit';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { exec, execFG } from '@vltpkg/run';
|
|
4
|
+
import * as vlx from '@vltpkg/vlx';
|
|
5
|
+
import { ExecCommand } from "../exec-command.js";
|
|
6
|
+
import { commandUsage } from "../config/usage.js";
|
|
7
|
+
import { stdout, styleTextStdout } from "../output.js";
|
|
8
|
+
import { startGUI } from "../start-gui.js";
|
|
9
|
+
export const usage = () => commandUsage({
|
|
10
|
+
command: 'serve',
|
|
11
|
+
usage: '',
|
|
12
|
+
description: `Start a local development server that runs both the browser-based
|
|
13
|
+
UI server and the VSR (vlt serverless registry) registry instance.
|
|
14
|
+
|
|
15
|
+
The UI server will start first on port 8000 (or the next
|
|
16
|
+
available port), and then the VSR registry will start on
|
|
17
|
+
port 1337.
|
|
18
|
+
|
|
19
|
+
This allows you to develop and test the full vlt ecosystem
|
|
20
|
+
locally, including package publishing and installation from
|
|
21
|
+
your local registry.`,
|
|
22
|
+
options: {
|
|
23
|
+
port: {
|
|
24
|
+
value: '<number>',
|
|
25
|
+
description: 'Port for the broser-based UI server (default: 8000)',
|
|
26
|
+
},
|
|
27
|
+
'registry-port': {
|
|
28
|
+
value: '<number>',
|
|
29
|
+
description: 'Port for the VSR registry (default: 1337)',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const views = {
|
|
34
|
+
human: (result) => {
|
|
35
|
+
stdout('');
|
|
36
|
+
stdout(styleTextStdout(['bgWhiteBright', 'black', 'bold'], ' vlt serve running '));
|
|
37
|
+
stdout('');
|
|
38
|
+
stdout(`UI Server: ${result.uiURL}`);
|
|
39
|
+
stdout(`VSR Registry: ${result.registryURL}`);
|
|
40
|
+
stdout('');
|
|
41
|
+
stdout('Press Ctrl+C to stop both servers');
|
|
42
|
+
},
|
|
43
|
+
json: (result) => result,
|
|
44
|
+
};
|
|
45
|
+
export const command = async (conf) => {
|
|
46
|
+
const registryPort = Number(conf.get('registry-port') ?? 1337);
|
|
47
|
+
// Start the GUI server first
|
|
48
|
+
stdout('Starting UI server...');
|
|
49
|
+
const server = await startGUI(conf, '/');
|
|
50
|
+
const actualGuiPort = server.port;
|
|
51
|
+
if (!actualGuiPort) {
|
|
52
|
+
throw error('missing ui server port');
|
|
53
|
+
}
|
|
54
|
+
// Start the VSR registry with the GUI server port
|
|
55
|
+
stdout('Starting VSR registry...');
|
|
56
|
+
// Prepare environment for VSR registry
|
|
57
|
+
const registryEnv = {
|
|
58
|
+
ARG_DAEMON: 'true',
|
|
59
|
+
DAEMON_START_SERVER: 'false',
|
|
60
|
+
DAEMON_PORT: String(actualGuiPort),
|
|
61
|
+
DAEMON_URL: `http://localhost:${actualGuiPort}`,
|
|
62
|
+
};
|
|
63
|
+
// runs the exec command internally
|
|
64
|
+
/* c8 ignore start */
|
|
65
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
66
|
+
String(conf.get('allow-scripts'))
|
|
67
|
+
: ':not(*)';
|
|
68
|
+
/* c8 ignore stop */
|
|
69
|
+
const arg0 = await vlx.resolve(['@vltpkg/vsr'], {
|
|
70
|
+
...conf.options,
|
|
71
|
+
query: undefined,
|
|
72
|
+
allowScripts,
|
|
73
|
+
}, async () => 'y');
|
|
74
|
+
if (arg0) {
|
|
75
|
+
conf.positionals[0] = arg0;
|
|
76
|
+
}
|
|
77
|
+
delete conf.options['script-shell'];
|
|
78
|
+
const ex = new ExecCommand(conf, exec, execFG);
|
|
79
|
+
ex.env = registryEnv;
|
|
80
|
+
await ex.run();
|
|
81
|
+
// Handle process termination
|
|
82
|
+
/* c8 ignore start */
|
|
83
|
+
const cleanup = () => {
|
|
84
|
+
stdout('\nShutting down servers...');
|
|
85
|
+
try {
|
|
86
|
+
void server.close();
|
|
87
|
+
stdout('UI server stopped');
|
|
88
|
+
}
|
|
89
|
+
catch { }
|
|
90
|
+
};
|
|
91
|
+
onExit(cleanup);
|
|
92
|
+
/* c8 ignore stop */
|
|
93
|
+
// Return the server information
|
|
94
|
+
const result = {
|
|
95
|
+
guiPort: actualGuiPort,
|
|
96
|
+
registryPort,
|
|
97
|
+
uiURL: `http://localhost:${actualGuiPort}`,
|
|
98
|
+
registryURL: `http://localhost:${registryPort}`,
|
|
99
|
+
};
|
|
100
|
+
// This return will never be reached due to the infinite promise above
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=serve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EA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AAC,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"]}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
import type { Graph } from '@vltpkg/graph';
|
|
1
2
|
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
3
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
4
|
+
export type UninstallResult = {
|
|
5
|
+
/**
|
|
6
|
+
* The resulting graph structure at the end of an uninstall.
|
|
7
|
+
*/
|
|
8
|
+
graph: Graph;
|
|
9
|
+
};
|
|
2
10
|
export declare const usage: CommandUsage;
|
|
3
|
-
export declare const
|
|
11
|
+
export declare const views: {
|
|
12
|
+
readonly json: (i: UninstallResult) => import("@vltpkg/graph").LockfileData;
|
|
13
|
+
readonly human: typeof InstallReporter;
|
|
14
|
+
};
|
|
15
|
+
export declare const command: CommandFn<UninstallResult>;
|
|
4
16
|
//# sourceMappingURL=uninstall.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"uninstall.d.ts","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAGvD,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;CAGyB,CAAA;AAE3C,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,eAAe,CAc9C,CAAA"}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { uninstall } from '@vltpkg/graph';
|
|
2
2
|
import { commandUsage } from "../config/usage.js";
|
|
3
3
|
import { parseRemoveArgs } from "../parse-add-remove-args.js";
|
|
4
|
+
import { InstallReporter } from "./install/reporter.js";
|
|
4
5
|
export const usage = () => commandUsage({
|
|
5
6
|
command: 'uninstall',
|
|
6
7
|
usage: '[package ...]',
|
|
7
8
|
description: `The opposite of \`vlt install\`. Removes deps and updates
|
|
8
9
|
vlt-lock.json and package.json appropriately.`,
|
|
9
10
|
});
|
|
11
|
+
export const views = {
|
|
12
|
+
json: i => i.graph.toJSON(),
|
|
13
|
+
human: InstallReporter,
|
|
14
|
+
};
|
|
10
15
|
export const command = async (conf) => {
|
|
11
16
|
const monorepo = conf.options.monorepo;
|
|
12
17
|
const { remove } = parseRemoveArgs(conf, monorepo);
|
|
13
|
-
|
|
18
|
+
/* c8 ignore start */
|
|
19
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
20
|
+
String(conf.get('allow-scripts'))
|
|
21
|
+
: ':not(*)';
|
|
22
|
+
/* c8 ignore stop */
|
|
23
|
+
const { graph } = await uninstall({ ...conf.options, allowScripts }, remove);
|
|
24
|
+
return { graph };
|
|
14
25
|
};
|
|
15
26
|
//# sourceMappingURL=uninstall.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"uninstall.js","sourceRoot":"","sources":["../../../src/commands/uninstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAUvD,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE;gEAC+C;CAC7D,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,eAAe;CACmB,CAAA;AAE3C,MAAM,CAAC,MAAM,OAAO,GAA+B,KAAK,EAAC,IAAI,EAAC,EAAE;IAC9D,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAClD,qBAAqB;IACrB,MAAM,YAAY,GAChB,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,SAAS,CAC/B,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,EACjC,MAAM,CACP,CAAA;IACD,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC,CAAA","sourcesContent":["import { uninstall } from '@vltpkg/graph'\nimport type { Graph } from '@vltpkg/graph'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { parseRemoveArgs } from '../parse-add-remove-args.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\n\nexport type UninstallResult = {\n /**\n * The resulting graph structure at the end of an uninstall.\n */\n graph: Graph\n}\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'uninstall',\n usage: '[package ...]',\n description: `The opposite of \\`vlt install\\`. Removes deps and updates\n vlt-lock.json and package.json appropriately.`,\n })\n\nexport const views = {\n json: i => i.graph.toJSON(),\n human: InstallReporter,\n} as const satisfies Views<UninstallResult>\n\nexport const command: CommandFn<UninstallResult> = async conf => {\n const monorepo = conf.options.monorepo\n const { remove } = parseRemoveArgs(conf, monorepo)\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const { graph } = await uninstall(\n { ...conf.options, allowScripts },\n remove,\n )\n return { graph }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
import { InstallReporter } from './install/reporter.ts';
|
|
3
|
+
import type { InstallResult } from './install.ts';
|
|
4
|
+
export declare const usage: CommandUsage;
|
|
5
|
+
export declare const views: {
|
|
6
|
+
readonly json: (i: InstallResult) => {
|
|
7
|
+
graph: import("@vltpkg/graph").LockfileData;
|
|
8
|
+
buildQueue?: import("@vltpkg/dep-id").DepID[] | undefined;
|
|
9
|
+
message?: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
readonly human: typeof InstallReporter;
|
|
12
|
+
};
|
|
13
|
+
export declare const command: CommandFn<InstallResult>;
|
|
14
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,eAAO,MAAM,KAAK,EAAE,YAMhB,CAAA;AAEJ,eAAO,MAAM,KAAK;;;;;;;CAWuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAmB5C,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { update } from '@vltpkg/graph';
|
|
2
|
+
import { error } from '@vltpkg/error-cause';
|
|
3
|
+
import { commandUsage } from "../config/usage.js";
|
|
4
|
+
import { InstallReporter } from "./install/reporter.js";
|
|
5
|
+
export const usage = () => commandUsage({
|
|
6
|
+
command: 'update',
|
|
7
|
+
usage: '',
|
|
8
|
+
description: `Update dependencies to their latest in-range versions.
|
|
9
|
+
Discards the lockfile and resolves dependencies from scratch.`,
|
|
10
|
+
});
|
|
11
|
+
export const views = {
|
|
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 update.`,
|
|
17
|
+
}
|
|
18
|
+
: null),
|
|
19
|
+
graph: i.graph.toJSON(),
|
|
20
|
+
}),
|
|
21
|
+
human: InstallReporter,
|
|
22
|
+
};
|
|
23
|
+
export const command = async (conf) => {
|
|
24
|
+
// Throw error if any arguments are provided
|
|
25
|
+
if (conf.positionals.length > 0) {
|
|
26
|
+
throw error('Arguments are not yet supported for vlt update', {
|
|
27
|
+
code: 'EUSAGE',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/* c8 ignore start */
|
|
31
|
+
const allowScripts = conf.get('allow-scripts') ?
|
|
32
|
+
String(conf.get('allow-scripts'))
|
|
33
|
+
: ':not(*)';
|
|
34
|
+
/* c8 ignore stop */
|
|
35
|
+
const { buildQueue, graph } = await update({
|
|
36
|
+
...conf.options,
|
|
37
|
+
allowScripts,
|
|
38
|
+
});
|
|
39
|
+
return { buildQueue, graph };
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|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AS,CAAA;IACb,oBAAoB;IACpB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC;QACzC,GAAG,IAAI,CAAC,OAAO;QACf,YAAY;KACb,CAAC,CAAA;IACF,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC,CAAA","sourcesContent":["import { update } from '@vltpkg/graph'\nimport { error } from '@vltpkg/error-cause'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport { InstallReporter } from './install/reporter.ts'\nimport type { Views } from '../view.ts'\nimport type { InstallResult } from './install.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'update',\n usage: '',\n description: `Update dependencies to their latest in-range versions.\n Discards the lockfile and resolves dependencies from scratch.`,\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 update.`,\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 // Throw error if any arguments are provided\n if (conf.positionals.length > 0) {\n throw error('Arguments are not yet supported for vlt update', {\n code: 'EUSAGE',\n })\n }\n\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 update({\n ...conf.options,\n allowScripts,\n })\n return { buildQueue, graph }\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CommandFn, CommandUsage } from '../index.ts';
|
|
2
|
+
export type VersionOptions = {
|
|
3
|
+
prereleaseId?: string;
|
|
4
|
+
commit?: boolean;
|
|
5
|
+
tag?: boolean;
|
|
6
|
+
message?: string;
|
|
7
|
+
tagMessage?: string;
|
|
8
|
+
includeNameInCommit?: boolean;
|
|
9
|
+
includeNameInTag?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type CommandResultSingle = {
|
|
12
|
+
name: string;
|
|
13
|
+
oldVersion: string;
|
|
14
|
+
newVersion: string;
|
|
15
|
+
dir: string;
|
|
16
|
+
committed?: string[];
|
|
17
|
+
tag?: string;
|
|
18
|
+
};
|
|
19
|
+
export type CommandResult = CommandResultSingle | CommandResultSingle[];
|
|
20
|
+
export declare const usage: CommandUsage;
|
|
21
|
+
export declare const views: {
|
|
22
|
+
readonly json: (result: CommandResult) => CommandResult;
|
|
23
|
+
readonly human: (results: CommandResult) => string;
|
|
24
|
+
};
|
|
25
|
+
export declare const command: CommandFn<CommandResult>;
|
|
26
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAS1D,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,aAAa,GACrB,mBAAmB,GACnB,mBAAmB,EAAE,CAAA;AA2LzB,eAAO,MAAM,KAAK,EAAE,YAanB,CAAA;AAED,eAAO,MAAM,KAAK;;;CAiBuB,CAAA;AAEzC,eAAO,MAAM,OAAO,EAAE,SAAS,CAAC,aAAa,CAkE5C,CAAA"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { inc, parse as parseVersion, versionIncrements, } from '@vltpkg/semver';
|
|
2
|
+
import { is as isGit, spawn as spawn_, isClean } from '@vltpkg/git';
|
|
3
|
+
import { error } from '@vltpkg/error-cause';
|
|
4
|
+
import { asError } from '@vltpkg/types';
|
|
5
|
+
import { commandUsage } from "../config/usage.js";
|
|
6
|
+
import { dirname, resolve } from 'node:path';
|
|
7
|
+
import assert from 'node:assert';
|
|
8
|
+
import { actual } from '@vltpkg/graph';
|
|
9
|
+
import { Query } from '@vltpkg/query';
|
|
10
|
+
import { createHostContextsMap } from "../query-host-contexts.js";
|
|
11
|
+
const isValidVersionIncrement = (value) => versionIncrements.includes(value);
|
|
12
|
+
const version = async (conf, increment, cwd, {
|
|
13
|
+
// Hardcode happy path options for now.
|
|
14
|
+
// TODO: make these config definitions
|
|
15
|
+
prereleaseId = 'pre', commit = true, tag = true, message = 'v%s', tagMessage = 'v%s', includeNameInCommit = false, includeNameInTag = false, } = {}) => {
|
|
16
|
+
assert(increment, error('Version increment argument is required', {
|
|
17
|
+
code: 'EUSAGE',
|
|
18
|
+
validOptions: versionIncrements,
|
|
19
|
+
}));
|
|
20
|
+
const manifestPath = conf.options.packageJson.find(cwd);
|
|
21
|
+
assert(manifestPath, error('No package.json found', {
|
|
22
|
+
code: 'ENOENT',
|
|
23
|
+
path: cwd,
|
|
24
|
+
}));
|
|
25
|
+
const spawn = (args, opts) => spawn_(args, { cwd: manifestDir, ...opts });
|
|
26
|
+
const manifestDir = dirname(manifestPath);
|
|
27
|
+
const manifest = conf.options.packageJson.read(manifestDir);
|
|
28
|
+
assert(manifest.name, error('No name field found in package.json', {
|
|
29
|
+
path: manifestPath,
|
|
30
|
+
}));
|
|
31
|
+
assert(manifest.version, error('No version field found in package.json', {
|
|
32
|
+
path: manifestPath,
|
|
33
|
+
}));
|
|
34
|
+
const oldVersion = manifest.version;
|
|
35
|
+
let newVersion;
|
|
36
|
+
// Check if increment is a valid semver version string
|
|
37
|
+
const parsedIncrement = parseVersion(increment);
|
|
38
|
+
if (parsedIncrement) {
|
|
39
|
+
newVersion = parsedIncrement.toString();
|
|
40
|
+
}
|
|
41
|
+
else if (isValidVersionIncrement(increment)) {
|
|
42
|
+
// Use semver increment
|
|
43
|
+
const incrementType = increment;
|
|
44
|
+
try {
|
|
45
|
+
const result = inc(oldVersion, incrementType, prereleaseId);
|
|
46
|
+
newVersion = result.toString();
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
throw error(`Failed to increment version from ${oldVersion} with ${increment}`, { version: oldVersion, wanted: increment, cause: err });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw error(`Invalid version increment: ${increment}. Must be a valid semver version or one of: major, minor, patch, premajor, preminor, prepatch, prerelease`, {
|
|
54
|
+
found: increment,
|
|
55
|
+
validOptions: versionIncrements,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// Update the manifest
|
|
59
|
+
manifest.version = newVersion;
|
|
60
|
+
conf.options.packageJson.write(manifestDir, manifest);
|
|
61
|
+
const result = {
|
|
62
|
+
name: manifest.name,
|
|
63
|
+
oldVersion,
|
|
64
|
+
newVersion,
|
|
65
|
+
dir: manifestDir,
|
|
66
|
+
};
|
|
67
|
+
// Handle git operations if we're in a git repository
|
|
68
|
+
if (
|
|
69
|
+
/* c8 ignore next -- commit and tag are always true for now */
|
|
70
|
+
(commit || tag) &&
|
|
71
|
+
(await isGit({ cwd: conf.options.projectRoot }))) {
|
|
72
|
+
// Check for uncommitted changes (excluding package.json since we just modified it)
|
|
73
|
+
if (!(await isClean({ cwd: conf.options.projectRoot }))) {
|
|
74
|
+
try {
|
|
75
|
+
// Check if there are changes other than package.json
|
|
76
|
+
const gitResult = await spawn([
|
|
77
|
+
'diff',
|
|
78
|
+
'--name-only',
|
|
79
|
+
'HEAD',
|
|
80
|
+
'--',
|
|
81
|
+
'.',
|
|
82
|
+
]);
|
|
83
|
+
const changedFiles = gitResult.stdout
|
|
84
|
+
.trim()
|
|
85
|
+
.split('\n')
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.map(f => resolve(conf.options.projectRoot, f));
|
|
88
|
+
const nonPackageJsonChanges = changedFiles.filter(file => file !== resolve(manifestDir, 'package.json'));
|
|
89
|
+
assert(nonPackageJsonChanges.length === 0, error('Git working directory not clean. Please commit or stash your changes first.', { found: nonPackageJsonChanges }));
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
throw error('Git working directory not clean. Please commit or stash your changes first.', asError(err));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (commit) {
|
|
96
|
+
try {
|
|
97
|
+
// Stage package.json
|
|
98
|
+
const files = ['package.json'];
|
|
99
|
+
await spawn(['add', ...files]);
|
|
100
|
+
await spawn([
|
|
101
|
+
'commit',
|
|
102
|
+
'-m',
|
|
103
|
+
`${includeNameInCommit ? `${manifest.name}: ` : ''}${message.replace('%s', newVersion)}`,
|
|
104
|
+
]);
|
|
105
|
+
result.committed = files.map(f => resolve(manifestDir, f));
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
throw error('Failed to commit version changes', {
|
|
109
|
+
version: newVersion,
|
|
110
|
+
cause: err,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (tag) {
|
|
115
|
+
try {
|
|
116
|
+
const tagName = (includeNameInTag ?
|
|
117
|
+
`${manifest.name.replace('/', '-').replace('@', '')}-`
|
|
118
|
+
: '') + `v${newVersion}`;
|
|
119
|
+
await spawn([
|
|
120
|
+
'tag',
|
|
121
|
+
tagName,
|
|
122
|
+
'-m',
|
|
123
|
+
(includeNameInTag ? `${manifest.name}: ` : '') +
|
|
124
|
+
tagMessage.replace('%s', newVersion),
|
|
125
|
+
]);
|
|
126
|
+
result.tag = tagName;
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
throw error('Failed to create git tag', {
|
|
130
|
+
version: newVersion,
|
|
131
|
+
cause: err,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
export const usage = () => {
|
|
139
|
+
return commandUsage({
|
|
140
|
+
command: 'version',
|
|
141
|
+
usage: '[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]',
|
|
142
|
+
description: `Bump a package's version.
|
|
143
|
+
|
|
144
|
+
Run in a package directory to bump the version and write the new data back to package.json.
|
|
145
|
+
|
|
146
|
+
The \`<newversion>\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).
|
|
147
|
+
|
|
148
|
+
If run in a git repository, it will also create a version commit and tag.`,
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
export const views = {
|
|
152
|
+
json: result => result,
|
|
153
|
+
human: results => {
|
|
154
|
+
const item = (result) => {
|
|
155
|
+
let output = `${result.name}: v${result.newVersion}`;
|
|
156
|
+
if (result.committed) {
|
|
157
|
+
output += ` +commit`;
|
|
158
|
+
}
|
|
159
|
+
if (result.tag) {
|
|
160
|
+
output += ` +tag`;
|
|
161
|
+
}
|
|
162
|
+
return output;
|
|
163
|
+
};
|
|
164
|
+
return Array.isArray(results) ?
|
|
165
|
+
results.map(item).join('\n')
|
|
166
|
+
: item(results);
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
export const command = async (conf) => {
|
|
170
|
+
const { positionals, options, projectRoot } = conf;
|
|
171
|
+
const queryString = conf.get('scope');
|
|
172
|
+
const paths = conf.get('workspace');
|
|
173
|
+
const groups = conf.get('workspace-group');
|
|
174
|
+
const recursive = conf.get('recursive');
|
|
175
|
+
const locations = [];
|
|
176
|
+
if (queryString) {
|
|
177
|
+
const mainManifest = options.packageJson.maybeRead(projectRoot);
|
|
178
|
+
let graph;
|
|
179
|
+
if (mainManifest) {
|
|
180
|
+
graph = actual.load({
|
|
181
|
+
...options,
|
|
182
|
+
mainManifest,
|
|
183
|
+
monorepo: options.monorepo,
|
|
184
|
+
loadManifests: false,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
const hostContexts = await createHostContextsMap(conf);
|
|
188
|
+
const query = new Query({
|
|
189
|
+
/* c8 ignore next */
|
|
190
|
+
nodes: graph ? new Set(graph.nodes.values()) : new Set(),
|
|
191
|
+
edges: graph?.edges ?? new Set(),
|
|
192
|
+
importers: graph?.importers ?? new Set(),
|
|
193
|
+
securityArchive: undefined,
|
|
194
|
+
hostContexts,
|
|
195
|
+
});
|
|
196
|
+
const { nodes } = await query.search(queryString, {
|
|
197
|
+
signal: new AbortController().signal,
|
|
198
|
+
});
|
|
199
|
+
for (const node of nodes) {
|
|
200
|
+
const location = node.location;
|
|
201
|
+
assert(location, error(`node ${node.id} has no location`, {
|
|
202
|
+
found: node,
|
|
203
|
+
}));
|
|
204
|
+
locations.push(resolve(node.projectRoot, location));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (paths?.length || groups?.length || recursive) {
|
|
208
|
+
for (const workspace of options.monorepo ?? []) {
|
|
209
|
+
locations.push(workspace.fullpath);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const cwd = options.packageJson.find(process.cwd()) ?? projectRoot;
|
|
214
|
+
return version(conf, positionals[0], cwd);
|
|
215
|
+
}
|
|
216
|
+
assert(locations.length > 0, error('No workspaces or query results found'));
|
|
217
|
+
const results = [];
|
|
218
|
+
for (const location of locations) {
|
|
219
|
+
results.push(await version(conf, positionals[0], location, {
|
|
220
|
+
includeNameInCommit: true,
|
|
221
|
+
includeNameInTag: true,
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
return results;
|
|
225
|
+
};
|
|
226
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,KAAK,IAAI,YAAY,EACrB,iBAAiB,GAClB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,EAAE,IAAI,KAAK,EAAE,KAAK,IAAI,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAIjD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAyBjE,MAAM,uBAAuB,GAAG,CAC9B,KAAa,EACW,EAAE,CAC1B,iBAAiB,CAAC,QAAQ,CAAC,KAAsB,CAAC,CAAA;AAEpD,MAAM,OAAO,GAAG,KAAK,EACnB,IAAkB,EAClB,SAA6B,EAC7B,GAAW,EACX;AACE,uCAAuC;AACvC,sCAAsC;AACtC,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,IAAI,EACb,GAAG,GAAG,IAAI,EACV,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,KAAK,EAClB,mBAAmB,GAAG,KAAK,EAC3B,gBAAgB,GAAG,KAAK,MACN,EAAE,EACQ,EAAE;IAChC,MAAM,CACJ,SAAS,EACT,KAAK,CAAC,wCAAwC,EAAE;QAC9C,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,iBAAi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AClE,OAAO,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,MAAM,CACJ,SAAS,CAAC,MAAM,GAAG,CAAC,EACpB,KAAK,CAAC,sCAAsC,CAAC,CAC9C,CAAA;IAED,MAAM,OAAO,GAA0B,EAAE,CAAA;IACzC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CACV,MAAM,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE;YAC5C,mBAAmB,EAAE,IAAI;YACzB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import {\n inc,\n parse as parseVersion,\n versionIncrements,\n} from '@vltpkg/semver'\nimport type { IncrementType } from '@vltpkg/semver'\nimport { is as isGit, spawn as spawn_, isClean } from '@vltpkg/git'\nimport type { GitOptions } from '@vltpkg/git'\nimport { error } from '@vltpkg/error-cause'\nimport { asError } from '@vltpkg/types'\nimport { commandUsage } from '../config/usage.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { Views } from '../view.ts'\nimport type { ParsedConfig } from '../config/index.ts'\nimport { dirname, resolve } from 'node:path'\nimport assert from 'node:assert'\nimport { actual } from '@vltpkg/graph'\nimport { Query } from '@vltpkg/query'\nimport { createHostContextsMap } from '../query-host-contexts.ts'\n\nexport type VersionOptions = {\n prereleaseId?: string\n commit?: boolean\n tag?: boolean\n message?: string\n tagMessage?: string\n includeNameInCommit?: boolean\n includeNameInTag?: boolean\n}\n\nexport type CommandResultSingle = {\n name: string\n oldVersion: string\n newVersion: string\n dir: string\n committed?: string[]\n tag?: string\n}\n\nexport type CommandResult =\n | CommandResultSingle\n | CommandResultSingle[]\n\nconst isValidVersionIncrement = (\n value: string,\n): value is IncrementType =>\n versionIncrements.includes(value as IncrementType)\n\nconst version = async (\n conf: ParsedConfig,\n increment: string | undefined,\n cwd: string,\n {\n // Hardcode happy path options for now.\n // TODO: make these config definitions\n prereleaseId = 'pre',\n commit = true,\n tag = true,\n message = 'v%s',\n tagMessage = 'v%s',\n includeNameInCommit = false,\n includeNameInTag = false,\n }: VersionOptions = {},\n): Promise<CommandResultSingle> => {\n assert(\n increment,\n error('Version increment argument is required', {\n code: 'EUSAGE',\n validOptions: versionIncrements,\n }),\n )\n\n const manifestPath = conf.options.packageJson.find(cwd)\n assert(\n manifestPath,\n error('No package.json found', {\n code: 'ENOENT',\n path: cwd,\n }),\n )\n\n const spawn = (args: string[], opts?: GitOptions) =>\n spawn_(args, { cwd: manifestDir, ...opts })\n\n const manifestDir = dirname(manifestPath)\n const manifest = conf.options.packageJson.read(manifestDir)\n\n assert(\n manifest.name,\n error('No name field found in package.json', {\n path: manifestPath,\n }),\n )\n assert(\n manifest.version,\n error('No version field found in package.json', {\n path: manifestPath,\n }),\n )\n\n const oldVersion = manifest.version\n let newVersion: string\n\n // Check if increment is a valid semver version string\n const parsedIncrement = parseVersion(increment)\n if (parsedIncrement) {\n newVersion = parsedIncrement.toString()\n } else if (isValidVersionIncrement(increment)) {\n // Use semver increment\n const incrementType = increment\n try {\n const result = inc(oldVersion, incrementType, prereleaseId)\n newVersion = result.toString()\n } catch (err) {\n throw error(\n `Failed to increment version from ${oldVersion} with ${increment}`,\n { version: oldVersion, wanted: increment, cause: err },\n )\n }\n } else {\n throw error(\n `Invalid version increment: ${increment}. Must be a valid semver version or one of: major, minor, patch, premajor, preminor, prepatch, prerelease`,\n {\n found: increment,\n validOptions: versionIncrements,\n },\n )\n }\n\n // Update the manifest\n manifest.version = newVersion\n conf.options.packageJson.write(manifestDir, manifest)\n\n const result: CommandResultSingle = {\n name: manifest.name,\n oldVersion,\n newVersion,\n dir: manifestDir,\n }\n\n // Handle git operations if we're in a git repository\n if (\n /* c8 ignore next -- commit and tag are always true for now */\n (commit || tag) &&\n (await isGit({ cwd: conf.options.projectRoot }))\n ) {\n // Check for uncommitted changes (excluding package.json since we just modified it)\n if (!(await isClean({ cwd: conf.options.projectRoot }))) {\n try {\n // Check if there are changes other than package.json\n const gitResult = await spawn([\n 'diff',\n '--name-only',\n 'HEAD',\n '--',\n '.',\n ])\n const changedFiles = gitResult.stdout\n .trim()\n .split('\\n')\n .filter(Boolean)\n .map(f => resolve(conf.options.projectRoot, f))\n const nonPackageJsonChanges = changedFiles.filter(\n file => file !== resolve(manifestDir, 'package.json'),\n )\n assert(\n nonPackageJsonChanges.length === 0,\n error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n { found: nonPackageJsonChanges },\n ),\n )\n } catch (err) {\n throw error(\n 'Git working directory not clean. Please commit or stash your changes first.',\n asError(err),\n )\n }\n }\n\n if (commit) {\n try {\n // Stage package.json\n const files = ['package.json']\n await spawn(['add', ...files])\n await spawn([\n 'commit',\n '-m',\n `${includeNameInCommit ? `${manifest.name}: ` : ''}${message.replace(\n '%s',\n newVersion,\n )}`,\n ])\n result.committed = files.map(f => resolve(manifestDir, f))\n } catch (err) {\n throw error('Failed to commit version changes', {\n version: newVersion,\n cause: err,\n })\n }\n }\n\n if (tag) {\n try {\n const tagName =\n (includeNameInTag ?\n `${manifest.name.replace('/', '-').replace('@', '')}-`\n : '') + `v${newVersion}`\n await spawn([\n 'tag',\n tagName,\n '-m',\n (includeNameInTag ? `${manifest.name}: ` : '') +\n tagMessage.replace('%s', newVersion),\n ])\n result.tag = tagName\n } catch (err) {\n throw error('Failed to create git tag', {\n version: newVersion,\n cause: err,\n })\n }\n }\n }\n\n return result\n}\n\nexport const usage: CommandUsage = () => {\n return commandUsage({\n command: 'version',\n usage:\n '[<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease]',\n description: `Bump a package's version.\n\n Run in a package directory to bump the version and write the new data back to package.json.\n\n The \\`<newversion>\\` argument should be a valid semver string or a valid increment type (one of patch, minor, major, prepatch, preminor, premajor, prerelease).\n\n If run in a git repository, it will also create a version commit and tag.`,\n })\n}\n\nexport const views = {\n json: result => result,\n human: results => {\n const item = (result: CommandResultSingle) => {\n let output = `${result.name}: v${result.newVersion}`\n if (result.committed) {\n output += ` +commit`\n }\n if (result.tag) {\n output += ` +tag`\n }\n return output\n }\n return Array.isArray(results) ?\n results.map(item).join('\\n')\n : item(results)\n },\n} as const satisfies Views<CommandResult>\n\nexport const command: CommandFn<CommandResult> = async conf => {\n const { positionals, options, projectRoot } = conf\n const queryString = conf.get('scope')\n const paths = conf.get('workspace')\n const groups = conf.get('workspace-group')\n const recursive = conf.get('recursive')\n\n const locations: string[] = []\n\n if (queryString) {\n const mainManifest = options.packageJson.maybeRead(projectRoot)\n let graph\n if (mainManifest) {\n graph = actual.load({\n ...options,\n mainManifest,\n monorepo: options.monorepo,\n loadManifests: false,\n })\n }\n const hostContexts = await createHostContextsMap(conf)\n const query = new Query({\n /* c8 ignore next */\n nodes: graph ? new Set(graph.nodes.values()) : new Set(),\n edges: graph?.edges ?? new Set(),\n importers: graph?.importers ?? new Set(),\n securityArchive: undefined,\n hostContexts,\n })\n const { nodes } = await query.search(queryString, {\n signal: new AbortController().signal,\n })\n for (const node of nodes) {\n const location = node.location\n assert(\n location,\n error(`node ${node.id} has no location`, {\n found: node,\n }),\n )\n locations.push(resolve(node.projectRoot, location))\n }\n } else if (paths?.length || groups?.length || recursive) {\n for (const workspace of options.monorepo ?? []) {\n locations.push(workspace.fullpath)\n }\n } else {\n const cwd = options.packageJson.find(process.cwd()) ?? projectRoot\n return version(conf, positionals[0], cwd)\n }\n\n assert(\n locations.length > 0,\n error('No workspaces or query results found'),\n )\n\n const results: CommandResultSingle[] = []\n for (const location of locations) {\n results.push(\n await version(conf, positionals[0], location, {\n includeNameInCommit: true,\n includeNameInTag: true,\n }),\n )\n }\n return results\n}\n"]}
|