@vltpkg/cli-sdk 1.0.0-rc.13 → 1.0.0-rc.15

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.
@@ -1,14 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,103 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"serve.js","sourceRoot":"","sources":["../../src/commands/serve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,GAAG,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAK1C,MAAM,CAAC,MAAM,KAAK,GAAiB,GAAG,EAAE,CACtC,YAAY,CAAC;IACX,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,EAAE;IACT,WAAW,EAAE;;;;;;;;;uCASsB;IACnC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,KAAK,EAAE,UAAU;YACjB,WAAW,EACT,qDAAqD;SACxD;QACD,eAAe,EAAE;YACf,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,2CAA2C;SACzD;KACF;CACF,CAAC,CAAA;AASJ,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,MAAmB,EAAE,EAA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AI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,CAAC,CAAC,SAAS,CAAA;IACb,oBAAoB;IACpB,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,OAAO,CAC5B,CAAC,aAAa,CAAC,EACf;QACE,GAAG,IAAI,CAAC,OAAO;QACf,KAAK,EAAE,SAAS;QAChB,YAAY;KACb,EACD,KAAK,IAAI,EAAE,CAAC,GAAG,CAChB,CAAA;IACD,IAAI,IAAI,EAAE,CAAC;QACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IACnC,MAAM,EAAE,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC9C,EAAE,CAAC,GAAG,GAAG,WAAW,CAAA;IACpB,MAAM,EAAE,CAAC,GAAG,EAAE,CAAA;IAEd,6BAA6B;IAC7B,qBAAqB;IACrB,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,CAAC,4BAA4B,CAAC,CAAA;QACpC,IAAI,CAAC;YACH,KAAK,MAAM,CAAC,KAAK,EAAE,CAAA;YACnB,MAAM,CAAC,mBAAmB,CAAC,CAAA;QAC7B,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC,CAAA;IACD,MAAM,CAAC,OAAO,CAAC,CAAA;IACf,oBAAoB;IAEpB,gCAAgC;IAChC,MAAM,MAAM,GAAgB;QAC1B,OAAO,EAAE,aAAa;QACtB,YAAY;QACZ,KAAK,EAAE,oBAAoB,aAAa,EAAE;QAC1C,WAAW,EAAE,oBAAoB,YAAY,EAAE;KAChD,CAAA;IAED,sEAAsE;IACtE,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { onExit } from 'signal-exit'\nimport { error } from '@vltpkg/error-cause'\nimport { exec, execFG } from '@vltpkg/run'\nimport * as vlx from '@vltpkg/vlx'\nimport { ExecCommand } from '../exec-command.ts'\nimport { commandUsage } from '../config/usage.ts'\nimport { stdout, styleTextStdout } from '../output.ts'\nimport { startGUI } from '../start-gui.ts'\nimport type { CommandFn, CommandUsage } from '../index.ts'\nimport type { LoadedConfig } from '../config/index.ts'\nimport type { Views } from '../view.ts'\n\nexport const usage: CommandUsage = () =>\n commandUsage({\n command: 'serve',\n usage: '',\n description: `Start a local development server that runs both the browser-based\n UI server and the VSR (vlt serverless registry) registry instance.\n\n The UI server will start first on port 8000 (or the next\n available port), and then the VSR registry will start on\n port 1337.\n\n This allows you to develop and test the full vlt ecosystem\n locally, including package publishing and installation from\n your local registry.`,\n options: {\n port: {\n value: '<number>',\n description:\n 'Port for the broser-based UI server (default: 8000)',\n },\n 'registry-port': {\n value: '<number>',\n description: 'Port for the VSR registry (default: 1337)',\n },\n },\n })\n\nexport type ServeResult = {\n guiPort: number\n registryPort: number\n uiURL: string\n registryURL: string\n}\n\nexport const views = {\n human: (result: ServeResult) => {\n stdout('')\n stdout(\n styleTextStdout(\n ['bgWhiteBright', 'black', 'bold'],\n ' vlt serve running ',\n ),\n )\n stdout('')\n stdout(`UI Server: ${result.uiURL}`)\n stdout(`VSR Registry: ${result.registryURL}`)\n stdout('')\n stdout('Press Ctrl+C to stop both servers')\n },\n json: (result: ServeResult) => result,\n} as const satisfies Views<ServeResult>\n\nexport const command: CommandFn<ServeResult> = async (\n conf: LoadedConfig,\n) => {\n const registryPort = Number(conf.get('registry-port') ?? 1337)\n\n // Start the GUI server first\n stdout('Starting UI server...')\n const server = await startGUI(conf)\n const actualGuiPort = server.port\n\n if (!actualGuiPort) {\n throw error('missing ui server port')\n }\n\n // Start the VSR registry with the GUI server port\n stdout('Starting VSR registry...')\n\n // Prepare environment for VSR registry\n const registryEnv = {\n ARG_DAEMON: 'true',\n DAEMON_START_SERVER: 'false',\n DAEMON_PORT: String(actualGuiPort),\n DAEMON_URL: `http://localhost:${actualGuiPort}`,\n }\n\n // runs the exec command internally\n /* c8 ignore start */\n const allowScripts =\n conf.get('allow-scripts') ?\n String(conf.get('allow-scripts'))\n : ':not(*)'\n /* c8 ignore stop */\n const arg0 = await vlx.resolve(\n ['@vltpkg/vsr'],\n {\n ...conf.options,\n query: undefined,\n allowScripts,\n },\n async () => 'y',\n )\n if (arg0) {\n conf.positionals[0] = arg0\n }\n delete conf.options['script-shell']\n const ex = new ExecCommand(conf, exec, execFG)\n ex.env = registryEnv\n await ex.run()\n\n // Handle process termination\n /* c8 ignore start */\n const cleanup = () => {\n stdout('\\nShutting down servers...')\n try {\n void server.close()\n stdout('UI server stopped')\n } catch {}\n }\n onExit(cleanup)\n /* c8 ignore stop */\n\n // Return the server information\n const result: ServeResult = {\n guiPort: actualGuiPort,\n registryPort,\n uiURL: `http://localhost:${actualGuiPort}`,\n registryURL: `http://localhost:${registryPort}`,\n }\n\n // This return will never be reached due to the infinite promise above\n return result\n}\n"]}
@@ -1,10 +0,0 @@
1
- import type { PathScurry } from 'path-scurry';
2
- import type { LoadedConfig } from './config/index.ts';
3
- export declare const getDefaultStartingRoute: (options: {
4
- queryString?: string;
5
- startingRoute?: string;
6
- projectRoot: string;
7
- scurry: PathScurry;
8
- }) => Promise<string>;
9
- export declare const startGUI: (conf: LoadedConfig, startingRoute?: string) => Promise<import("@vltpkg/server").VltServer>;
10
- //# sourceMappingURL=start-gui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-gui.d.ts","sourceRoot":"","sources":["../src/start-gui.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAGrD,eAAO,MAAM,uBAAuB,YAAmB;IACrD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,UAAU,CAAA;CACnB,oBAcA,CAAA;AAaD,eAAO,MAAM,QAAQ,SACb,YAAY,kBACF,MAAM,gDA0CvB,CAAA"}
package/dist/start-gui.js DELETED
@@ -1,60 +0,0 @@
1
- import { resolve } from 'node:path';
2
- import LZString from 'lz-string';
3
- import { createServer } from '@vltpkg/server';
4
- import { urlOpen } from '@vltpkg/url-open';
5
- import { stdout } from "./output.js";
6
- export const getDefaultStartingRoute = async (options) => {
7
- const { queryString = ':root', startingRoute, projectRoot, scurry, } = options;
8
- if (startingRoute)
9
- return startingRoute;
10
- const stat = await scurry.lstat(`${projectRoot}/package.json`);
11
- const res = stat?.isFile() && !stat.isSymbolicLink() ?
12
- `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`
13
- : '/dashboard';
14
- return res;
15
- };
16
- const getAssetsDir = () => {
17
- /* c8 ignore start */
18
- if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {
19
- return resolve(import.meta.dirname, process.env.__VLT_INTERNAL_GUI_ASSETS_DIR);
20
- }
21
- /* c8 ignore stop */
22
- };
23
- export const startGUI = async (conf, startingRoute) => {
24
- /* c8 ignore start */
25
- const allowScripts = conf.get('allow-scripts') ?
26
- String(conf.get('allow-scripts'))
27
- : ':not(*)';
28
- /* c8 ignore stop */
29
- const server = createServer({
30
- ...conf.options,
31
- assetsDir: getAssetsDir(),
32
- loadedConfig: conf,
33
- allowScripts,
34
- });
35
- server.on('needConfigUpdate', async (dir) => {
36
- conf.resetOptions(dir);
37
- const listeningServer = server;
38
- listeningServer.updateOptions({ ...conf.options, allowScripts });
39
- await conf
40
- .reloadFromDisk()
41
- .then(() => {
42
- listeningServer.updateOptions({
43
- ...conf.options,
44
- allowScripts,
45
- });
46
- })
47
- .catch(() => { });
48
- });
49
- const { projectRoot, scurry } = conf.options;
50
- await server.start();
51
- stdout(`⚡️ vlt UI running at ${server.address()}`);
52
- void urlOpen(server.address(await getDefaultStartingRoute({
53
- queryString: conf.values.target,
54
- startingRoute,
55
- projectRoot,
56
- scurry,
57
- })));
58
- return server;
59
- };
60
- //# sourceMappingURL=start-gui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-gui.js","sourceRoot":"","sources":["../src/start-gui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAKpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAE,OAK7C,EAAE,EAAE;IACH,MAAM,EACJ,WAAW,GAAG,OAAO,EACrB,aAAa,EACb,WAAW,EACX,MAAM,GACP,GAAG,OAAO,CAAA;IACX,IAAI,aAAa;QAAE,OAAO,aAAa,CAAA;IACvC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,WAAW,eAAe,CAAC,CAAA;IAC9D,MAAM,GAAG,GACP,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QACxC,YAAY,QAAQ,CAAC,6BAA6B,CAAC,WAAW,CAAC,WAAW;QAC5E,CAAC,CAAC,YAAY,CAAA;IAChB,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,qBAAqB;IACrB,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;QAC9C,OAAO,OAAO,CACZ,MAAM,CAAC,IAAI,CAAC,OAAO,EACnB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAC1C,CAAA;IACH,CAAC;IACD,oBAAoB;AACtB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,IAAkB,EAClB,aAAsB,EACtB,EAAE;IACF,qBAAq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Content":["import { resolve } from 'node:path'\nimport LZString from 'lz-string'\nimport { createServer } from '@vltpkg/server'\nimport { urlOpen } from '@vltpkg/url-open'\nimport { stdout } from './output.ts'\nimport type { PathScurry } from 'path-scurry'\nimport type { LoadedConfig } from './config/index.ts'\nimport type { VltServerListening } from '@vltpkg/server'\n\nexport const getDefaultStartingRoute = async (options: {\n queryString?: string\n startingRoute?: string\n projectRoot: string\n scurry: PathScurry\n}) => {\n const {\n queryString = ':root',\n startingRoute,\n projectRoot,\n scurry,\n } = options\n if (startingRoute) return startingRoute\n const stat = await scurry.lstat(`${projectRoot}/package.json`)\n const res =\n stat?.isFile() && !stat.isSymbolicLink() ?\n `/explore/${LZString.compressToEncodedURIComponent(queryString)}/overview`\n : '/dashboard'\n return res\n}\n\nconst getAssetsDir = () => {\n /* c8 ignore start */\n if (process.env.__VLT_INTERNAL_GUI_ASSETS_DIR) {\n return resolve(\n import.meta.dirname,\n process.env.__VLT_INTERNAL_GUI_ASSETS_DIR,\n )\n }\n /* c8 ignore stop */\n}\n\nexport const startGUI = async (\n conf: LoadedConfig,\n startingRoute?: string,\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 server = createServer({\n ...conf.options,\n assetsDir: getAssetsDir(),\n loadedConfig: conf,\n allowScripts,\n })\n server.on('needConfigUpdate', async dir => {\n conf.resetOptions(dir)\n const listeningServer = server as VltServerListening\n listeningServer.updateOptions({ ...conf.options, allowScripts })\n await conf\n .reloadFromDisk()\n .then(() => {\n listeningServer.updateOptions({\n ...conf.options,\n allowScripts,\n })\n })\n .catch(() => {})\n })\n const { projectRoot, scurry } = conf.options\n await server.start()\n stdout(`⚡️ vlt UI running at ${server.address()}`)\n void urlOpen(\n server.address(\n await getDefaultStartingRoute({\n queryString: conf.values.target,\n startingRoute,\n projectRoot,\n scurry,\n }),\n ),\n )\n return server\n}\n"]}