@aravindc26/velu 0.2.0 → 0.3.0

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +21 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -17,7 +17,7 @@ function printHelp() {
17
17
  velu init Scaffold a new docs project with example files
18
18
  velu lint Validate velu.json and check referenced pages
19
19
  velu run [--port N] Build site and start dev server (default: 4321)
20
- velu build Build site without starting the dev server
20
+ velu build Build a deployable static site (SSG)
21
21
 
22
22
  Options:
23
23
  --port <number> Port for the dev server (default: 4321)
@@ -109,13 +109,31 @@ async function lint(docsDir: string) {
109
109
 
110
110
  // ── build ────────────────────────────────────────────────────────────────────────
111
111
 
112
- async function buildSite(docsDir: string): Promise<string> {
112
+ async function generateProject(docsDir: string): Promise<string> {
113
113
  const { build } = await import("./build.js");
114
114
  const outDir = join(docsDir, ".velu-out");
115
115
  build(docsDir, outDir);
116
116
  return outDir;
117
117
  }
118
118
 
119
+ async function buildStatic(outDir: string) {
120
+ await new Promise<void>((res, rej) => {
121
+ const child = spawn("node", ["_server.mjs", "build"], {
122
+ cwd: outDir,
123
+ stdio: "inherit",
124
+ });
125
+ child.on("exit", (code) => (code === 0 ? res() : rej(new Error(`Build exited with ${code}`))));
126
+ });
127
+ }
128
+
129
+ async function buildSite(docsDir: string) {
130
+ const outDir = await generateProject(docsDir);
131
+ await installDeps(outDir);
132
+ await buildStatic(outDir);
133
+ const distDir = join(outDir, "dist");
134
+ console.log(`\n📁 Static site output: ${distDir}`);
135
+ }
136
+
119
137
  // ── run ──────────────────────────────────────────────────────────────────────────
120
138
 
121
139
  async function installDeps(outDir: string) {
@@ -146,7 +164,7 @@ function spawnServer(outDir: string, command: string, port: number) {
146
164
  }
147
165
 
148
166
  async function run(docsDir: string, port: number) {
149
- const outDir = await buildSite(docsDir);
167
+ const outDir = await generateProject(docsDir);
150
168
  await installDeps(outDir);
151
169
  spawnServer(outDir, "dev", port);
152
170
  }