@aravindc26/velu 0.11.14 → 0.11.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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/build.ts +20 -5
  3. package/src/cli.ts +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.11.14",
3
+ "version": "0.11.15",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/build.ts CHANGED
@@ -9,11 +9,12 @@ import { normalizeConfigNavigation } from "./navigation-normalize.js";
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
11
11
  const PACKAGED_ENGINE_DIR = join(__dirname, "engine");
12
- const DEV_ENGINE_DIR = join(__dirname, "..", "src", "engine");
13
- const ENGINE_DIR = existsSync(DEV_ENGINE_DIR) ? DEV_ENGINE_DIR : PACKAGED_ENGINE_DIR;
14
- const PRIMARY_CONFIG_NAME = "docs.json";
15
- const LEGACY_CONFIG_NAME = "velu.json";
16
- const SOURCE_MIRROR_DIR = "velu-imports";
12
+ const DEV_ENGINE_DIR = join(__dirname, "..", "src", "engine");
13
+ const ENGINE_DIR = existsSync(DEV_ENGINE_DIR) ? DEV_ENGINE_DIR : PACKAGED_ENGINE_DIR;
14
+ const CLI_PACKAGE_JSON_PATH = join(__dirname, "..", "package.json");
15
+ const PRIMARY_CONFIG_NAME = "docs.json";
16
+ const LEGACY_CONFIG_NAME = "velu.json";
17
+ const SOURCE_MIRROR_DIR = "velu-imports";
17
18
 
18
19
  const SOURCE_MIRROR_EXTENSIONS = new Set([
19
20
  ".md", ".mdx", ".jsx", ".js", ".tsx", ".ts",
@@ -630,10 +631,24 @@ function resolveProjectDescription(config: VeluConfig): string {
630
631
  return "";
631
632
  }
632
633
 
634
+ function resolveCliVersion(): string {
635
+ try {
636
+ const raw = readFileSync(CLI_PACKAGE_JSON_PATH, "utf-8");
637
+ const parsed = JSON.parse(raw) as { version?: unknown };
638
+ if (typeof parsed.version === "string" && parsed.version.trim().length > 0) {
639
+ return parsed.version.trim();
640
+ }
641
+ } catch {
642
+ // ignore and fallback
643
+ }
644
+ return "unknown";
645
+ }
646
+
633
647
  function writeProjectConstFile(config: VeluConfig, outDir: string) {
634
648
  const constPayload = {
635
649
  name: resolveProjectName(config),
636
650
  description: resolveProjectDescription(config),
651
+ version: resolveCliVersion(),
637
652
  };
638
653
 
639
654
  const constPath = join(outDir, "public", "const.json");
package/src/cli.ts CHANGED
@@ -35,6 +35,7 @@ function printHelp() {
35
35
  velu — documentation site generator
36
36
 
37
37
  Usage:
38
+ velu version Print Velu CLI version
38
39
  velu init Scaffold a new docs project with example files
39
40
  velu lint Validate docs.json (or velu.json) and check referenced pages
40
41
  velu run [--port N] Build site and start dev server (default: 4321)
@@ -42,6 +43,7 @@ function printHelp() {
42
43
  velu paths Output navigation paths and source files as JSON (grouped by language)
43
44
 
44
45
  Options:
46
+ --version Show Velu CLI version
45
47
  --port <number> Port for the dev server (default: 4321)
46
48
  --help Show this help message
47
49
 
@@ -49,6 +51,24 @@ function printHelp() {
49
51
  `);
50
52
  }
51
53
 
54
+ function getCliVersion(): string {
55
+ try {
56
+ const pkgPath = join(PACKAGE_ROOT, "package.json");
57
+ const raw = readFileSync(pkgPath, "utf-8");
58
+ const parsed = JSON.parse(raw) as { version?: unknown };
59
+ if (typeof parsed.version === "string" && parsed.version.trim().length > 0) {
60
+ return parsed.version.trim();
61
+ }
62
+ } catch {
63
+ // ignore and fallback
64
+ }
65
+ return "unknown";
66
+ }
67
+
68
+ function printVersion() {
69
+ console.log(getCliVersion());
70
+ }
71
+
52
72
  // ── init ────────────────────────────────────────────────────────────────────────
53
73
 
54
74
  function init(targetDir: string) {
@@ -495,6 +515,11 @@ if (!command || command === "--help" || command === "-h") {
495
515
  process.exit(0);
496
516
  }
497
517
 
518
+ if (command === "version" || command === "--version" || command === "-v") {
519
+ printVersion();
520
+ process.exit(0);
521
+ }
522
+
498
523
  const docsDir = process.cwd();
499
524
 
500
525
  // init doesn't require docs.json