UNPKG

iles

Version:

Vite & Vue powered static site generator with partial hydration

58 lines (57 loc) 2.07 kB
import { n as VERSION } from "./constants-DUVbDEPQ.mjs"; import { version as viteVersion } from "vite"; import pc from "picocolors"; import minimist from "minimist"; //#region src/node/cli.ts const argv = minimist(process.argv.slice(2)); const command = argv._[0]; const root = argv._[command ? 1 : 0]; if (root) argv.root = root; const getVersion = () => pc.cyan(`iles v${VERSION}`) + pc.yellow(` vite v${viteVersion}`); const printVersion = () => console.info(getVersion()); executeCommand(!command || command === "dev" ? "serve" : command).catch((error) => { throw error; }); async function executeCommand(command) { if (command === "serve") { const { createServer } = await import("./plugin-Ctdahe_A.mjs").then((n) => n.n); createServer(root, argv).then(async ({ server }) => { await server.listen(); const { config: { logger } } = server; logger.info(getVersion() + pc.green(" dev server running at:\n"), { clear: !logger.hasWarned }); server.printUrls(); }).catch((err) => { console.error(pc.red("error starting server:\n"), err); process.exit(1); }); } else if (command === "build") { printVersion(); const { build } = await import("./build-Dq8MZ4xb.mjs").then((n) => n.n); build(root).catch((err) => { console.error(pc.red("build error:\n"), err); process.exit(1); }); } else if (command === "preview") { printVersion(); const { preview } = await import("./preview-DZAkDtEs.mjs"); preview(root, argv).catch((err) => { console.error(pc.red("error starting preview:\n"), err); process.exit(1); }); } else if (command === "info") printVersion(); else if (command === "test") { const { CONFIG_PATH } = await import("./alias-Cyp8pcW6.mjs").then((n) => n.p); const { spawn } = await import("child_process"); spawn("vp", [ "test", "--config", CONFIG_PATH, ...process.argv.slice(2 + argv._.length) ], { stdio: "inherit" }).on("exit", (code) => process.exit(code || 0)); } else { console.error(pc.red(`unknown command "${command}".`)); process.exit(1); } } //#endregion export {};