@booga/vcli 0.1.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.
- package/CHANGELOG.md +21 -0
- package/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/cli.js +87 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +67 -0
- package/package.json +55 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-05-24
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `vcli registry list` — enumerate every entry in `@booga/vregistry`; supports
|
|
13
|
+
`--json` and `--category <name>` filters.
|
|
14
|
+
- `vcli registry inspect <id>` — print a single entry as JSON; exits 1 on miss.
|
|
15
|
+
- `vcli ssg build <config>` — dynamically import a JS/TS/JSON config file and run
|
|
16
|
+
`@booga/vssg`'s `generate()` pipeline; prints pages/assets/duration on success,
|
|
17
|
+
exits 1 with the message on failure.
|
|
18
|
+
- Programmatic API: `registerRegistryCmd(cmd)` and `registerSsgCmd(cmd)` attach
|
|
19
|
+
the same subcommands to any host `commander` `Command`.
|
|
20
|
+
- Dual build via tsup: ESM `dist/index.js` (programmatic) + `dist/cli.js` with
|
|
21
|
+
`#!/usr/bin/env node` shebang (bound to the `vcli` binary).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bvasilenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @booga/vcli
|
|
2
|
+
|
|
3
|
+
Terminal CLI for the vsuite. Wraps `@booga/vregistry` and `@booga/vssg` so the
|
|
4
|
+
catalog and the static-site pipeline are reachable from the shell — no host app
|
|
5
|
+
required.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @booga/vcli
|
|
11
|
+
# or, ad-hoc:
|
|
12
|
+
npx @booga/vcli --help
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
### `vcli registry list`
|
|
18
|
+
|
|
19
|
+
Enumerate every entry in `@booga/vregistry` — id, category, name.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
vcli registry list # human-readable
|
|
23
|
+
vcli registry list --json # JSON, pipe-friendly
|
|
24
|
+
vcli registry list -c block # filter by category
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### `vcli registry inspect <id>`
|
|
28
|
+
|
|
29
|
+
Print one entry as JSON (schema, default props, source, dependencies).
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
vcli registry inspect hero-split
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Exits 1 if `<id>` isn't in the catalog.
|
|
36
|
+
|
|
37
|
+
### `vcli ssg build <config>`
|
|
38
|
+
|
|
39
|
+
Run `@booga/vssg`'s `generate()` against a config file. The file is JS/TS/JSON
|
|
40
|
+
with the config as its default export; the CLI imports it dynamically and
|
|
41
|
+
prints a one-line summary on success.
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
vcli ssg build vssg.config.js
|
|
45
|
+
# built 42 pages, 17 assets in 312ms
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Exits 1 with the error message if the pipeline throws.
|
|
49
|
+
|
|
50
|
+
## Programmatic API
|
|
51
|
+
|
|
52
|
+
`vCli` also exports its subcommand registrars, so a host program can compose
|
|
53
|
+
the same commands into a larger `commander` tree:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { Command } from "commander";
|
|
57
|
+
import { registerRegistryCmd, registerSsgCmd } from "@booga/vcli";
|
|
58
|
+
|
|
59
|
+
const app = new Command().name("mytool");
|
|
60
|
+
registerRegistryCmd(app);
|
|
61
|
+
registerSsgCmd(app);
|
|
62
|
+
app.parseAsync();
|
|
63
|
+
```
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { dirname, resolve, isAbsolute } from 'path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
6
|
+
import pc from 'picocolors';
|
|
7
|
+
import { findByCategory, registry, findById } from '@booga/vregistry';
|
|
8
|
+
import { generate } from '@booga/vssg';
|
|
9
|
+
|
|
10
|
+
function formatLine(e) {
|
|
11
|
+
return `${pc.cyan(e.id.padEnd(28))} ${pc.dim(e.category.padEnd(10))} ${e.name}`;
|
|
12
|
+
}
|
|
13
|
+
function registerRegistryCmd(program2) {
|
|
14
|
+
const reg = program2.command("registry").description("inspect the @booga/vregistry catalog");
|
|
15
|
+
reg.command("list").description("list every registered entry (id, category, name)").option("-c, --category <name>", "filter by category").option("--json", "emit JSON instead of human-readable text").action((opts) => {
|
|
16
|
+
const items = opts.category ? findByCategory(opts.category) : [...registry.entries];
|
|
17
|
+
if (opts.json) {
|
|
18
|
+
process.stdout.write(JSON.stringify(items, null, 2) + "\n");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (items.length === 0) {
|
|
22
|
+
process.stderr.write(
|
|
23
|
+
pc.yellow(`no entries${opts.category ? ` in category "${opts.category}"` : ""}
|
|
24
|
+
`)
|
|
25
|
+
);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
for (const e of items) process.stdout.write(formatLine(e) + "\n");
|
|
29
|
+
process.stderr.write(pc.dim(`
|
|
30
|
+
${items.length} entries (registry v${registry.version})
|
|
31
|
+
`));
|
|
32
|
+
});
|
|
33
|
+
reg.command("inspect <id>").description("print a single registry entry as JSON").action((id) => {
|
|
34
|
+
const entry = findById(id);
|
|
35
|
+
if (!entry) {
|
|
36
|
+
process.stderr.write(pc.red(`not found: ${id}
|
|
37
|
+
`));
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
process.stdout.write(JSON.stringify(entry, null, 2) + "\n");
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async function loadConfig(path) {
|
|
44
|
+
const abs = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
45
|
+
const mod = await import(pathToFileURL(abs).href);
|
|
46
|
+
return mod.default ?? mod;
|
|
47
|
+
}
|
|
48
|
+
function registerSsgCmd(program2) {
|
|
49
|
+
const ssg = program2.command("ssg").description("run the @booga/vssg static-site pipeline");
|
|
50
|
+
ssg.command("build <config>").description("build a static site from a config file (JS/TS/JSON, default export)").action(async (configPath) => {
|
|
51
|
+
try {
|
|
52
|
+
const config = await loadConfig(configPath);
|
|
53
|
+
const result = await generate(config);
|
|
54
|
+
process.stdout.write(
|
|
55
|
+
pc.green(
|
|
56
|
+
`built ${result.pages} pages, ${result.assets.length} assets in ${result.durationMs}ms
|
|
57
|
+
`
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
62
|
+
process.stderr.write(pc.red(`ssg build failed: ${msg}
|
|
63
|
+
`));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/cli.ts
|
|
70
|
+
function pkgVersion() {
|
|
71
|
+
try {
|
|
72
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
73
|
+
const pkg = JSON.parse(readFileSync(resolve(here, "..", "package.json"), "utf8"));
|
|
74
|
+
return typeof pkg.version === "string" ? pkg.version : "0.0.0";
|
|
75
|
+
} catch {
|
|
76
|
+
return "0.0.0";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
var program = new Command();
|
|
80
|
+
program.name("vcli").description("Terminal CLI for the vsuite. Wraps @booga/vregistry and @booga/vssg.").version(pkgVersion());
|
|
81
|
+
registerRegistryCmd(program);
|
|
82
|
+
registerSsgCmd(program);
|
|
83
|
+
program.parseAsync(process.argv).catch((e) => {
|
|
84
|
+
process.stderr.write(`${e instanceof Error ? e.message : String(e)}
|
|
85
|
+
`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import { findByCategory, registry, findById } from '@booga/vregistry';
|
|
3
|
+
import { isAbsolute, resolve } from 'path';
|
|
4
|
+
import { pathToFileURL } from 'url';
|
|
5
|
+
import { generate } from '@booga/vssg';
|
|
6
|
+
|
|
7
|
+
// src/commands/registry.ts
|
|
8
|
+
function formatLine(e) {
|
|
9
|
+
return `${pc.cyan(e.id.padEnd(28))} ${pc.dim(e.category.padEnd(10))} ${e.name}`;
|
|
10
|
+
}
|
|
11
|
+
function registerRegistryCmd(program) {
|
|
12
|
+
const reg = program.command("registry").description("inspect the @booga/vregistry catalog");
|
|
13
|
+
reg.command("list").description("list every registered entry (id, category, name)").option("-c, --category <name>", "filter by category").option("--json", "emit JSON instead of human-readable text").action((opts) => {
|
|
14
|
+
const items = opts.category ? findByCategory(opts.category) : [...registry.entries];
|
|
15
|
+
if (opts.json) {
|
|
16
|
+
process.stdout.write(JSON.stringify(items, null, 2) + "\n");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (items.length === 0) {
|
|
20
|
+
process.stderr.write(
|
|
21
|
+
pc.yellow(`no entries${opts.category ? ` in category "${opts.category}"` : ""}
|
|
22
|
+
`)
|
|
23
|
+
);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
for (const e of items) process.stdout.write(formatLine(e) + "\n");
|
|
27
|
+
process.stderr.write(pc.dim(`
|
|
28
|
+
${items.length} entries (registry v${registry.version})
|
|
29
|
+
`));
|
|
30
|
+
});
|
|
31
|
+
reg.command("inspect <id>").description("print a single registry entry as JSON").action((id) => {
|
|
32
|
+
const entry = findById(id);
|
|
33
|
+
if (!entry) {
|
|
34
|
+
process.stderr.write(pc.red(`not found: ${id}
|
|
35
|
+
`));
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
process.stdout.write(JSON.stringify(entry, null, 2) + "\n");
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function loadConfig(path) {
|
|
42
|
+
const abs = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
43
|
+
const mod = await import(pathToFileURL(abs).href);
|
|
44
|
+
return mod.default ?? mod;
|
|
45
|
+
}
|
|
46
|
+
function registerSsgCmd(program) {
|
|
47
|
+
const ssg = program.command("ssg").description("run the @booga/vssg static-site pipeline");
|
|
48
|
+
ssg.command("build <config>").description("build a static site from a config file (JS/TS/JSON, default export)").action(async (configPath) => {
|
|
49
|
+
try {
|
|
50
|
+
const config = await loadConfig(configPath);
|
|
51
|
+
const result = await generate(config);
|
|
52
|
+
process.stdout.write(
|
|
53
|
+
pc.green(
|
|
54
|
+
`built ${result.pages} pages, ${result.assets.length} assets in ${result.durationMs}ms
|
|
55
|
+
`
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
60
|
+
process.stderr.write(pc.red(`ssg build failed: ${msg}
|
|
61
|
+
`));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { registerRegistryCmd, registerSsgCmd };
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@booga/vcli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Terminal CLI for the vsuite — wraps @booga/vregistry and @booga/vssg.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"vcli": "./dist/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**/*",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "tsup --watch",
|
|
26
|
+
"build": "tsup",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"test": "vitest run --coverage",
|
|
30
|
+
"test:watch": "vitest"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@booga/vregistry": "^0.1.1",
|
|
34
|
+
"@booga/vssg": "^0.1.1",
|
|
35
|
+
"commander": "^12.0.0",
|
|
36
|
+
"picocolors": "^1.0.0",
|
|
37
|
+
"zod": "^3.22.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@eslint/js": "^9.0.0",
|
|
41
|
+
"@types/node": "^22.0.0",
|
|
42
|
+
"@vitest/coverage-istanbul": "^2.1.0",
|
|
43
|
+
"eslint": "^9.0.0",
|
|
44
|
+
"globals": "^15.0.0",
|
|
45
|
+
"tsup": "^8.0.0",
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"typescript-eslint": "^8.0.0",
|
|
48
|
+
"vitest": "^2.1.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"author": "bvasilenko"
|
|
55
|
+
}
|