@aravindc26/velu 0.11.13 โ 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.
- package/package.json +1 -1
- package/src/build.ts +61 -18
- package/src/cli.ts +25 -0
package/package.json
CHANGED
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
|
|
15
|
-
const
|
|
16
|
-
const
|
|
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",
|
|
@@ -137,6 +138,9 @@ interface VeluRedirect {
|
|
|
137
138
|
|
|
138
139
|
interface VeluConfig {
|
|
139
140
|
$schema?: string;
|
|
141
|
+
name?: string;
|
|
142
|
+
title?: string;
|
|
143
|
+
description?: string;
|
|
140
144
|
theme?: string;
|
|
141
145
|
variables?: Record<string, string>;
|
|
142
146
|
colors?: VeluColors;
|
|
@@ -587,7 +591,7 @@ const STATIC_EXTENSIONS = new Set([
|
|
|
587
591
|
".zip",
|
|
588
592
|
]);
|
|
589
593
|
|
|
590
|
-
function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
594
|
+
function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
591
595
|
function walk(dir: string) {
|
|
592
596
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
593
597
|
for (const entry of entries) {
|
|
@@ -611,12 +615,49 @@ function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
|
611
615
|
}
|
|
612
616
|
}
|
|
613
617
|
|
|
614
|
-
walk(docsDir);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function
|
|
618
|
-
|
|
619
|
-
|
|
618
|
+
walk(docsDir);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function resolveProjectName(config: VeluConfig): string {
|
|
622
|
+
const fromName = typeof config.name === "string" ? config.name.trim() : "";
|
|
623
|
+
if (fromName) return fromName;
|
|
624
|
+
const fromTitle = typeof config.title === "string" ? config.title.trim() : "";
|
|
625
|
+
if (fromTitle) return fromTitle;
|
|
626
|
+
return "Documentation";
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function resolveProjectDescription(config: VeluConfig): string {
|
|
630
|
+
if (typeof config.description === "string") return config.description.trim();
|
|
631
|
+
return "";
|
|
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
|
+
|
|
647
|
+
function writeProjectConstFile(config: VeluConfig, outDir: string) {
|
|
648
|
+
const constPayload = {
|
|
649
|
+
name: resolveProjectName(config),
|
|
650
|
+
description: resolveProjectDescription(config),
|
|
651
|
+
version: resolveCliVersion(),
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
const constPath = join(outDir, "public", "const.json");
|
|
655
|
+
writeFileSync(constPath, `${JSON.stringify(constPayload, null, 2)}\n`, "utf-8");
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function toPosixPath(value: string): string {
|
|
659
|
+
return value.replace(/\\/g, "/");
|
|
660
|
+
}
|
|
620
661
|
|
|
621
662
|
function isInsideDocsRoot(docsDir: string, targetPath: string): boolean {
|
|
622
663
|
const relPath = relative(docsDir, targetPath);
|
|
@@ -1167,12 +1208,14 @@ function build(docsDir: string, outDir: string) {
|
|
|
1167
1208
|
console.log(`๐ Copied ${configName} as ${PRIMARY_CONFIG_NAME} (and legacy ${LEGACY_CONFIG_NAME})`);
|
|
1168
1209
|
|
|
1169
1210
|
// โโ 3b. Copy static assets from docs project into public/ โโโโโโโโโโโโโโโโโ
|
|
1170
|
-
copyStaticAssets(docsDir, join(outDir, "public"));
|
|
1171
|
-
writeRedirectArtifacts(config, outDir);
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1211
|
+
copyStaticAssets(docsDir, join(outDir, "public"));
|
|
1212
|
+
writeRedirectArtifacts(config, outDir);
|
|
1213
|
+
writeProjectConstFile(rawConfig, outDir);
|
|
1214
|
+
if ((config.redirects ?? []).length > 0) {
|
|
1215
|
+
console.log("โช๏ธ Generated redirect artifacts");
|
|
1216
|
+
}
|
|
1217
|
+
console.log("๐งพ Generated const.json");
|
|
1218
|
+
console.log("๐ผ๏ธ Copied static assets");
|
|
1176
1219
|
|
|
1177
1220
|
// โโ 4. Build content + metadata artifacts โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1178
1221
|
const contentDir = join(outDir, "content", "docs");
|
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
|