a reactive (signals based) hypermedia web framework (wip)
stormlightlabs.github.io/volt/
hypermedia
frontend
signals
1import { downloadFile, getCDNUrls } from "$utils/download.js";
2import { echo } from "$utils/echo.js";
3import path from "node:path";
4
5/**
6 * Downloads VoltX.js assets (JS and/or CSS) from the CDN.
7 */
8export async function downloadCommand(
9 options: { version?: string; js?: boolean; css?: boolean; output?: string } = {},
10): Promise<void> {
11 const version = options.version || "latest";
12 const downloadJS = options.js !== false;
13 const downloadCSS = options.css !== false;
14 const outputDir = options.output || ".";
15
16 echo.title("\n⚡ Downloading VoltX.js assets...\n");
17
18 try {
19 const urls = getCDNUrls(version);
20
21 if (downloadJS) {
22 const jsPath = path.join(outputDir, "voltx.min.js");
23 echo.info(`Downloading voltx.min.js (${version})...`);
24 await downloadFile(urls.js, jsPath);
25 echo.ok(`✓ Downloaded: ${jsPath}`);
26 }
27
28 if (downloadCSS) {
29 const cssPath = path.join(outputDir, "voltx.min.css");
30 echo.info(`Downloading voltx.min.css (${version})...`);
31 await downloadFile(urls.css, cssPath);
32 echo.ok(`✓ Downloaded: ${cssPath}`);
33 }
34
35 echo.success("\n✓ Download completed successfully!\n");
36 } catch (error) {
37 echo.err("Failed to download assets:", error);
38 process.exit(1);
39 }
40}