vlt
Version:
The vlt CLI
151 lines (147 loc) • 4.06 kB
JavaScript
var global = globalThis;
import {Buffer} from "node:buffer";
import {setTimeout,clearTimeout,setImmediate,clearImmediate,setInterval,clearInterval} from "node:timers";
import {createRequire as _vlt_createRequire} from "node:module";
var require = _vlt_createRequire(import.meta.filename);
import {
startGUI
} from "./chunk-VNU3TPBK.js";
import {
vlxResolve
} from "./chunk-N47CDNRA.js";
import {
ExecCommand
} from "./chunk-ZCZ3GGEV.js";
import "./chunk-3X64PWHW.js";
import "./chunk-4ADJWTGC.js";
import "./chunk-PVOBL7T7.js";
import {
stdout,
styleTextStdout
} from "./chunk-KNHO4BUR.js";
import "./chunk-BQNTW6JU.js";
import "./chunk-YESBS37V.js";
import "./chunk-J25GTXK2.js";
import "./chunk-3VS4XBYN.js";
import "./chunk-YF5FZDHL.js";
import "./chunk-GGPZGJ5H.js";
import "./chunk-OTLTOVZN.js";
import {
exec,
execFG,
onExit
} from "./chunk-QALMFIGC.js";
import "./chunk-6RYZ5N3C.js";
import {
commandUsage
} from "./chunk-L3E552CT.js";
import "./chunk-GTAUGWLW.js";
import "./chunk-U5J4TCIV.js";
import "./chunk-KPA4XNCN.js";
import "./chunk-VYJVN3B6.js";
import "./chunk-B4MAUXR2.js";
import "./chunk-W7RMFRDJ.js";
import "./chunk-O57KIW5U.js";
import "./chunk-JBBINXAZ.js";
import "./chunk-OAYCZMD4.js";
import "./chunk-QOAKZNUG.js";
import "./chunk-BA67AKYJ.js";
import {
error
} from "./chunk-KVH5ECIG.js";
import "./chunk-AECDW3EJ.js";
// ../../src/cli-sdk/src/commands/serve.ts
var usage = () => commandUsage({
command: "serve",
usage: "",
description: `Start a local development server that runs both the browser-based
UI server and the VSR (vlt serverless registry) registry instance.
The UI server will start first on port 8000 (or the next
available port), and then the VSR registry will start on
port 1337.
This allows you to develop and test the full vlt ecosystem
locally, including package publishing and installation from
your local registry.`,
options: {
port: {
value: "<number>",
description: "Port for the broser-based UI server (default: 8000)"
},
"registry-port": {
value: "<number>",
description: "Port for the VSR registry (default: 1337)"
}
}
});
var views = {
human: (result) => {
stdout("");
stdout(
styleTextStdout(
["bgWhiteBright", "black", "bold"],
" vlt serve running "
)
);
stdout("");
stdout(`UI Server: ${result.uiURL}`);
stdout(`VSR Registry: ${result.registryURL}`);
stdout("");
stdout("Press Ctrl+C to stop both servers");
},
json: (result) => result
};
var command = async (conf) => {
const registryPort = Number(conf.get("registry-port") ?? 1337);
stdout("Starting UI server...");
const server = await startGUI(conf);
const actualGuiPort = server.port;
if (!actualGuiPort) {
throw error("missing ui server port");
}
stdout("Starting VSR registry...");
const registryEnv = {
ARG_DAEMON: "true",
DAEMON_START_SERVER: "false",
DAEMON_PORT: String(actualGuiPort),
DAEMON_URL: `http://localhost:${actualGuiPort}`
};
const allowScripts = conf.get("allow-scripts") ? String(conf.get("allow-scripts")) : ":not(*)";
const arg0 = await vlxResolve(
["@vltpkg/vsr"],
{
...conf.options,
query: void 0,
allowScripts
},
async () => "y"
);
if (arg0) {
conf.positionals[0] = arg0;
}
delete conf.options["script-shell"];
const ex = new ExecCommand(conf, exec, execFG);
ex.env = registryEnv;
await ex.run();
const cleanup = () => {
stdout("\nShutting down servers...");
try {
void server.close();
stdout("UI server stopped");
} catch {
}
};
onExit(cleanup);
const result = {
guiPort: actualGuiPort,
registryPort,
uiURL: `http://localhost:${actualGuiPort}`,
registryURL: `http://localhost:${registryPort}`
};
return result;
};
export {
command,
usage,
views
};
//# sourceMappingURL=serve-WGTZD43D.js.map