@vutex/vutex 0.0.0 → 0.0.1
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/bin/vutex.mjs +11 -11
- package/locales/en-US/cli.json +18 -18
- package/locales/locales.json +1 -1
- package/package.json +11 -6
- package/readme.md +18 -18
- package/src/cli/cli.ts +21 -21
- package/src/cli/commands/inspect.ts +33 -33
- package/src/cli/commands/package.ts +99 -99
- package/src/cli/commands/render.ts +38 -38
- package/src/cli/context.ts +27 -27
- package/src/cli/diagnostics.ts +23 -23
- package/src/cli/exit-codes.ts +5 -5
- package/src/cli/main.ts +5 -5
- package/src/index.ts +36 -36
- package/src/node/index.ts +1 -1
- package/src/node/load.ts +50 -50
- package/src/packages/lockfile.ts +35 -35
- package/src/packages/manager.ts +119 -119
- package/src/packages/manifest.ts +28 -28
- package/src/runtime.ts +87 -87
- package/src/types.ts +121 -121
package/bin/vutex.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { createJiti } from "jiti";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
9
|
-
const { runCli } = await jiti.import(join(here, "../src/cli/main.ts"));
|
|
10
|
-
|
|
11
|
-
process.exit(await runCli(process.argv.slice(2)));
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createJiti } from "jiti";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const jiti = createJiti(import.meta.url, { interopDefault: true });
|
|
9
|
+
const { runCli } = await jiti.import(join(here, "../src/cli/main.ts"));
|
|
10
|
+
|
|
11
|
+
process.exit(await runCli(process.argv.slice(2)));
|
package/locales/en-US/cli.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cli.intro": "vutex — language-neutral document typesetting and rendering",
|
|
3
|
-
"cli.cmd.render": "Render a document to the configured output format",
|
|
4
|
-
"cli.cmd.inspect": "Inspect input format and document metadata",
|
|
5
|
-
"cli.cmd.package": "Manage VuTeX resource packages (fonts, templates, profiles)",
|
|
6
|
-
"cli.cmd.package.list": "List resource packages from manifest and lockfile",
|
|
7
|
-
"cli.cmd.package.add": "Add a resource package alias to vutex.toml",
|
|
8
|
-
"cli.cmd.package.remove": "Remove a resource package alias from vutex.toml",
|
|
9
|
-
"cli.cmd.package.install": "Resolve and install resource packages into the project cache",
|
|
10
|
-
"cli.cmd.package.update": "Refresh the resource package lockfile",
|
|
11
|
-
"cli.cmd.package.doctor": "Check manifest, lockfile, and package cache health",
|
|
12
|
-
"cli.opt.output": "Output file path, or format id when writing to stdout",
|
|
13
|
-
"cli.opt.profile": "Named language profile from vutex.toml",
|
|
14
|
-
"cli.opt.input-format": "Override input format id",
|
|
15
|
-
"cli.opt.json": "Emit machine-readable JSON on stdout",
|
|
16
|
-
"cli.opt.package-name": "Resource package name to install",
|
|
17
|
-
"cli.opt.package-version": "Requested package version range"
|
|
18
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"cli.intro": "vutex — language-neutral document typesetting and rendering",
|
|
3
|
+
"cli.cmd.render": "Render a document to the configured output format",
|
|
4
|
+
"cli.cmd.inspect": "Inspect input format and document metadata",
|
|
5
|
+
"cli.cmd.package": "Manage VuTeX resource packages (fonts, templates, profiles)",
|
|
6
|
+
"cli.cmd.package.list": "List resource packages from manifest and lockfile",
|
|
7
|
+
"cli.cmd.package.add": "Add a resource package alias to vutex.toml",
|
|
8
|
+
"cli.cmd.package.remove": "Remove a resource package alias from vutex.toml",
|
|
9
|
+
"cli.cmd.package.install": "Resolve and install resource packages into the project cache",
|
|
10
|
+
"cli.cmd.package.update": "Refresh the resource package lockfile",
|
|
11
|
+
"cli.cmd.package.doctor": "Check manifest, lockfile, and package cache health",
|
|
12
|
+
"cli.opt.output": "Output file path, or format id when writing to stdout",
|
|
13
|
+
"cli.opt.profile": "Named language profile from vutex.toml",
|
|
14
|
+
"cli.opt.input-format": "Override input format id",
|
|
15
|
+
"cli.opt.json": "Emit machine-readable JSON on stdout",
|
|
16
|
+
"cli.opt.package-name": "Resource package name to install",
|
|
17
|
+
"cli.opt.package-version": "Requested package version range"
|
|
18
|
+
}
|
package/locales/locales.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
["en-US"]
|
|
1
|
+
["en-US"]
|
package/package.json
CHANGED
|
@@ -30,19 +30,24 @@
|
|
|
30
30
|
"license": "MPL-2.0",
|
|
31
31
|
"name": "@vutex/vutex",
|
|
32
32
|
"optionalDependencies": {
|
|
33
|
-
"@vutex/vutex-darwin-arm64": "0.0.
|
|
34
|
-
"@vutex/vutex-darwin-x64": "0.0.
|
|
35
|
-
"@vutex/vutex-linux-arm64": "0.0.
|
|
36
|
-
"@vutex/vutex-linux-x64": "0.0.
|
|
37
|
-
"@vutex/vutex-win32-x64": "0.0.
|
|
33
|
+
"@vutex/vutex-darwin-arm64": "0.0.1",
|
|
34
|
+
"@vutex/vutex-darwin-x64": "0.0.1",
|
|
35
|
+
"@vutex/vutex-linux-arm64": "0.0.1",
|
|
36
|
+
"@vutex/vutex-linux-x64": "0.0.1",
|
|
37
|
+
"@vutex/vutex-win32-x64": "0.0.1"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"directory": "projects/packages/vutex",
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/notedge/VuTeX.git"
|
|
46
|
+
},
|
|
42
47
|
"scripts": {
|
|
43
48
|
"test": "tsx --test tests/package-manager.test.ts",
|
|
44
49
|
"typecheck": "tsc --noEmit"
|
|
45
50
|
},
|
|
46
51
|
"type": "module",
|
|
47
|
-
"version": "0.0.
|
|
52
|
+
"version": "0.0.1"
|
|
48
53
|
}
|
package/readme.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# @vutex/vutex
|
|
2
|
-
|
|
3
|
-
VuTeX TypeScript runtime facade and official CLI.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
vutex render sample.nd --output out.svg
|
|
7
|
-
vutex inspect sample.nd
|
|
8
|
-
vutex package doctor
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import { createVuTeX } from "@vutex/vutex";
|
|
13
|
-
|
|
14
|
-
const vutex = await createVuTeX({ projectRoot: process.cwd() });
|
|
15
|
-
const result = await vutex.render("sample.nd", { output: "svg" });
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Resource packages (fonts, templates, profiles) are managed by the VuTeX package manager via `vutex.toml`, not npm.
|
|
1
|
+
# @vutex/vutex
|
|
2
|
+
|
|
3
|
+
VuTeX TypeScript runtime facade and official CLI.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
vutex render sample.nd --output out.svg
|
|
7
|
+
vutex inspect sample.nd
|
|
8
|
+
vutex package doctor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { createVuTeX } from "@vutex/vutex";
|
|
13
|
+
|
|
14
|
+
const vutex = await createVuTeX({ projectRoot: process.cwd() });
|
|
15
|
+
const result = await vutex.render("sample.nd", { output: "svg" });
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Resource packages (fonts, templates, profiles) are managed by the VuTeX package manager via `vutex.toml`, not npm.
|
package/src/cli/cli.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { dirname, join } from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
|
-
import { createCli } from "@vmz/commander";
|
|
5
|
-
|
|
6
|
-
import { registerInspectCommand } from "./commands/inspect.js";
|
|
7
|
-
import { registerPackageCommands } from "./commands/package.js";
|
|
8
|
-
import { registerRenderCommand } from "./commands/render.js";
|
|
9
|
-
|
|
10
|
-
export function buildVuTeXCli() {
|
|
11
|
-
const localesRoot = join(dirname(fileURLToPath(import.meta.url)), "../../locales");
|
|
12
|
-
const cli = createCli("vutex")
|
|
13
|
-
.locales(localesRoot, { envKeys: ["VUTEX_LOCALE", "LOCALE", "LANG", "LC_ALL"] })
|
|
14
|
-
.intro("cli.intro");
|
|
15
|
-
|
|
16
|
-
registerRenderCommand(cli);
|
|
17
|
-
registerInspectCommand(cli);
|
|
18
|
-
registerPackageCommands(cli);
|
|
19
|
-
|
|
20
|
-
return cli;
|
|
21
|
-
}
|
|
1
|
+
import { dirname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
import { createCli } from "@vmz/commander";
|
|
5
|
+
|
|
6
|
+
import { registerInspectCommand } from "./commands/inspect.js";
|
|
7
|
+
import { registerPackageCommands } from "./commands/package.js";
|
|
8
|
+
import { registerRenderCommand } from "./commands/render.js";
|
|
9
|
+
|
|
10
|
+
export function buildVuTeXCli() {
|
|
11
|
+
const localesRoot = join(dirname(fileURLToPath(import.meta.url)), "../../locales");
|
|
12
|
+
const cli = createCli("vutex")
|
|
13
|
+
.locales(localesRoot, { envKeys: ["VUTEX_LOCALE", "LOCALE", "LANG", "LC_ALL"] })
|
|
14
|
+
.intro("cli.intro");
|
|
15
|
+
|
|
16
|
+
registerRenderCommand(cli);
|
|
17
|
+
registerInspectCommand(cli);
|
|
18
|
+
registerPackageCommands(cli);
|
|
19
|
+
|
|
20
|
+
return cli;
|
|
21
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
-
|
|
3
|
-
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
-
import { emitJson, presentDiagnostics } from "../diagnostics.js";
|
|
5
|
-
import { ExitCode } from "../exit-codes.js";
|
|
6
|
-
|
|
7
|
-
export function registerInspectCommand(cli: Cli): void {
|
|
8
|
-
cli.command("inspect", "cli.cmd.inspect")
|
|
9
|
-
.option("--json", "cli.opt.json")
|
|
10
|
-
.action(async (options: ParsedOptions) => {
|
|
11
|
-
const inputPath = options._[0];
|
|
12
|
-
if (!inputPath || typeof inputPath !== "string") {
|
|
13
|
-
return ExitCode.InvalidArgs;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const runtime = await createVuTeXRuntime();
|
|
17
|
-
const result = await runtime.inspect(inputPath);
|
|
18
|
-
|
|
19
|
-
if (options.json === true) {
|
|
20
|
-
emitJson(result);
|
|
21
|
-
} else {
|
|
22
|
-
console.log(`${result.inputFormat}\t${result.path}`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (result.diagnostics.length > 0) {
|
|
26
|
-
presentDiagnostics(result.diagnostics, options.json === true);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return result.diagnostics.some((item) => item.severity === "error")
|
|
30
|
-
? ExitCode.ActionFailed
|
|
31
|
-
: ExitCode.Ok;
|
|
32
|
-
});
|
|
33
|
-
}
|
|
1
|
+
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
+
|
|
3
|
+
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
+
import { emitJson, presentDiagnostics } from "../diagnostics.js";
|
|
5
|
+
import { ExitCode } from "../exit-codes.js";
|
|
6
|
+
|
|
7
|
+
export function registerInspectCommand(cli: Cli): void {
|
|
8
|
+
cli.command("inspect", "cli.cmd.inspect")
|
|
9
|
+
.option("--json", "cli.opt.json")
|
|
10
|
+
.action(async (options: ParsedOptions) => {
|
|
11
|
+
const inputPath = options._[0];
|
|
12
|
+
if (!inputPath || typeof inputPath !== "string") {
|
|
13
|
+
return ExitCode.InvalidArgs;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const runtime = await createVuTeXRuntime();
|
|
17
|
+
const result = await runtime.inspect(inputPath);
|
|
18
|
+
|
|
19
|
+
if (options.json === true) {
|
|
20
|
+
emitJson(result);
|
|
21
|
+
} else {
|
|
22
|
+
console.log(`${result.inputFormat}\t${result.path}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (result.diagnostics.length > 0) {
|
|
26
|
+
presentDiagnostics(result.diagnostics, options.json === true);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return result.diagnostics.some((item) => item.severity === "error")
|
|
30
|
+
? ExitCode.ActionFailed
|
|
31
|
+
: ExitCode.Ok;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
-
|
|
3
|
-
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
-
import { emitHuman, emitJson } from "../diagnostics.js";
|
|
5
|
-
import { ExitCode } from "../exit-codes.js";
|
|
6
|
-
|
|
7
|
-
function readName(options: ParsedOptions): string | undefined {
|
|
8
|
-
const value = options._[0] ?? options.name;
|
|
9
|
-
return typeof value === "string" ? value : undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function registerPackageCommands(cli: Cli): void {
|
|
13
|
-
const group = cli.command("package", "cli.cmd.package");
|
|
14
|
-
|
|
15
|
-
group
|
|
16
|
-
.command("list", "cli.cmd.package.list")
|
|
17
|
-
.option("--json", "cli.opt.json")
|
|
18
|
-
.action(async (options: ParsedOptions) => {
|
|
19
|
-
const runtime = await createVuTeXRuntime();
|
|
20
|
-
const items = await runtime.packages.list();
|
|
21
|
-
if (options.json === true) {
|
|
22
|
-
emitJson({ packages: items });
|
|
23
|
-
} else {
|
|
24
|
-
for (const item of items) {
|
|
25
|
-
emitHuman(`${item.name}\t${item.version}\t${item.source}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return ExitCode.Ok;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
group
|
|
32
|
-
.command("add", "cli.cmd.package.add")
|
|
33
|
-
.action(async (options: ParsedOptions) => {
|
|
34
|
-
const name = readName(options);
|
|
35
|
-
if (!name) {
|
|
36
|
-
return ExitCode.InvalidArgs;
|
|
37
|
-
}
|
|
38
|
-
const runtime = await createVuTeXRuntime();
|
|
39
|
-
await runtime.packages.add(name, {
|
|
40
|
-
version: typeof options.version === "string" ? options.version : undefined,
|
|
41
|
-
});
|
|
42
|
-
return ExitCode.Ok;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
group
|
|
46
|
-
.command("remove", "cli.cmd.package.remove")
|
|
47
|
-
.action(async (options: ParsedOptions) => {
|
|
48
|
-
const name = readName(options);
|
|
49
|
-
if (!name) {
|
|
50
|
-
return ExitCode.InvalidArgs;
|
|
51
|
-
}
|
|
52
|
-
const runtime = await createVuTeXRuntime();
|
|
53
|
-
await runtime.packages.remove(name);
|
|
54
|
-
return ExitCode.Ok;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
group
|
|
58
|
-
.command("install", "cli.cmd.package.install")
|
|
59
|
-
.option("--name <name>", "cli.opt.package-name")
|
|
60
|
-
.option("--version <version>", "cli.opt.package-version")
|
|
61
|
-
.action(async (options: ParsedOptions) => {
|
|
62
|
-
const runtime = await createVuTeXRuntime();
|
|
63
|
-
await runtime.packages.install({
|
|
64
|
-
name: typeof options.name === "string" ? options.name : undefined,
|
|
65
|
-
version: typeof options.version === "string" ? options.version : undefined,
|
|
66
|
-
});
|
|
67
|
-
return ExitCode.Ok;
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
group
|
|
71
|
-
.command("update", "cli.cmd.package.update")
|
|
72
|
-
.action(async () => {
|
|
73
|
-
const runtime = await createVuTeXRuntime();
|
|
74
|
-
await runtime.packages.update();
|
|
75
|
-
return ExitCode.Ok;
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
group
|
|
79
|
-
.command("doctor", "cli.cmd.package.doctor")
|
|
80
|
-
.option("--json", "cli.opt.json")
|
|
81
|
-
.action(async (options: ParsedOptions) => {
|
|
82
|
-
const runtime = await createVuTeXRuntime();
|
|
83
|
-
const report = await runtime.packages.doctor();
|
|
84
|
-
if (options.json === true) {
|
|
85
|
-
emitJson(report);
|
|
86
|
-
} else if (report.ok) {
|
|
87
|
-
emitHuman("VuTeX resource packages look healthy");
|
|
88
|
-
for (const check of report.checks) {
|
|
89
|
-
emitHuman(` ok ${check.id}: ${check.message}`);
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
emitHuman("VuTeX resource packages have issues");
|
|
93
|
-
for (const check of report.checks) {
|
|
94
|
-
emitHuman(` ${check.ok ? "ok" : "fail"} ${check.id}: ${check.message}`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return report.ok ? ExitCode.Ok : ExitCode.ActionFailed;
|
|
98
|
-
});
|
|
99
|
-
}
|
|
1
|
+
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
+
|
|
3
|
+
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
+
import { emitHuman, emitJson } from "../diagnostics.js";
|
|
5
|
+
import { ExitCode } from "../exit-codes.js";
|
|
6
|
+
|
|
7
|
+
function readName(options: ParsedOptions): string | undefined {
|
|
8
|
+
const value = options._[0] ?? options.name;
|
|
9
|
+
return typeof value === "string" ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function registerPackageCommands(cli: Cli): void {
|
|
13
|
+
const group = cli.command("package", "cli.cmd.package");
|
|
14
|
+
|
|
15
|
+
group
|
|
16
|
+
.command("list", "cli.cmd.package.list")
|
|
17
|
+
.option("--json", "cli.opt.json")
|
|
18
|
+
.action(async (options: ParsedOptions) => {
|
|
19
|
+
const runtime = await createVuTeXRuntime();
|
|
20
|
+
const items = await runtime.packages.list();
|
|
21
|
+
if (options.json === true) {
|
|
22
|
+
emitJson({ packages: items });
|
|
23
|
+
} else {
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
emitHuman(`${item.name}\t${item.version}\t${item.source}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return ExitCode.Ok;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
group
|
|
32
|
+
.command("add", "cli.cmd.package.add")
|
|
33
|
+
.action(async (options: ParsedOptions) => {
|
|
34
|
+
const name = readName(options);
|
|
35
|
+
if (!name) {
|
|
36
|
+
return ExitCode.InvalidArgs;
|
|
37
|
+
}
|
|
38
|
+
const runtime = await createVuTeXRuntime();
|
|
39
|
+
await runtime.packages.add(name, {
|
|
40
|
+
version: typeof options.version === "string" ? options.version : undefined,
|
|
41
|
+
});
|
|
42
|
+
return ExitCode.Ok;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
group
|
|
46
|
+
.command("remove", "cli.cmd.package.remove")
|
|
47
|
+
.action(async (options: ParsedOptions) => {
|
|
48
|
+
const name = readName(options);
|
|
49
|
+
if (!name) {
|
|
50
|
+
return ExitCode.InvalidArgs;
|
|
51
|
+
}
|
|
52
|
+
const runtime = await createVuTeXRuntime();
|
|
53
|
+
await runtime.packages.remove(name);
|
|
54
|
+
return ExitCode.Ok;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
group
|
|
58
|
+
.command("install", "cli.cmd.package.install")
|
|
59
|
+
.option("--name <name>", "cli.opt.package-name")
|
|
60
|
+
.option("--version <version>", "cli.opt.package-version")
|
|
61
|
+
.action(async (options: ParsedOptions) => {
|
|
62
|
+
const runtime = await createVuTeXRuntime();
|
|
63
|
+
await runtime.packages.install({
|
|
64
|
+
name: typeof options.name === "string" ? options.name : undefined,
|
|
65
|
+
version: typeof options.version === "string" ? options.version : undefined,
|
|
66
|
+
});
|
|
67
|
+
return ExitCode.Ok;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
group
|
|
71
|
+
.command("update", "cli.cmd.package.update")
|
|
72
|
+
.action(async () => {
|
|
73
|
+
const runtime = await createVuTeXRuntime();
|
|
74
|
+
await runtime.packages.update();
|
|
75
|
+
return ExitCode.Ok;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
group
|
|
79
|
+
.command("doctor", "cli.cmd.package.doctor")
|
|
80
|
+
.option("--json", "cli.opt.json")
|
|
81
|
+
.action(async (options: ParsedOptions) => {
|
|
82
|
+
const runtime = await createVuTeXRuntime();
|
|
83
|
+
const report = await runtime.packages.doctor();
|
|
84
|
+
if (options.json === true) {
|
|
85
|
+
emitJson(report);
|
|
86
|
+
} else if (report.ok) {
|
|
87
|
+
emitHuman("VuTeX resource packages look healthy");
|
|
88
|
+
for (const check of report.checks) {
|
|
89
|
+
emitHuman(` ok ${check.id}: ${check.message}`);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
emitHuman("VuTeX resource packages have issues");
|
|
93
|
+
for (const check of report.checks) {
|
|
94
|
+
emitHuman(` ${check.ok ? "ok" : "fail"} ${check.id}: ${check.message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return report.ok ? ExitCode.Ok : ExitCode.ActionFailed;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
-
|
|
3
|
-
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
-
import { emitJson, presentDiagnostics } from "../diagnostics.js";
|
|
5
|
-
import { ExitCode } from "../exit-codes.js";
|
|
6
|
-
|
|
7
|
-
export function registerRenderCommand(cli: Cli): void {
|
|
8
|
-
cli.command("render", "cli.cmd.render")
|
|
9
|
-
.option("-o, --output <file>", "cli.opt.output")
|
|
10
|
-
.option("--profile <name>", "cli.opt.profile")
|
|
11
|
-
.option("--input <format>", "cli.opt.input-format")
|
|
12
|
-
.option("--json", "cli.opt.json")
|
|
13
|
-
.action(async (options: ParsedOptions) => {
|
|
14
|
-
const inputPath = options._[0];
|
|
15
|
-
if (!inputPath || typeof inputPath !== "string") {
|
|
16
|
-
return ExitCode.InvalidArgs;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const runtime = await createVuTeXRuntime();
|
|
20
|
-
const result = await runtime.render(inputPath, {
|
|
21
|
-
output: typeof options.output === "string" ? options.output : undefined,
|
|
22
|
-
profile: typeof options.profile === "string" ? options.profile : undefined,
|
|
23
|
-
input: typeof options.input === "string" ? options.input : undefined,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
if (options.json === true) {
|
|
27
|
-
emitJson(result);
|
|
28
|
-
} else if (result.svg) {
|
|
29
|
-
console.log(result.svg);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (result.diagnostics.length > 0) {
|
|
33
|
-
presentDiagnostics(result.diagnostics, options.json === true);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return result.exitCode === 0 ? ExitCode.Ok : ExitCode.ActionFailed;
|
|
37
|
-
});
|
|
38
|
-
}
|
|
1
|
+
import type { Cli, ParsedOptions } from "@vmz/commander";
|
|
2
|
+
|
|
3
|
+
import { createVuTeXRuntime } from "../context.js";
|
|
4
|
+
import { emitJson, presentDiagnostics } from "../diagnostics.js";
|
|
5
|
+
import { ExitCode } from "../exit-codes.js";
|
|
6
|
+
|
|
7
|
+
export function registerRenderCommand(cli: Cli): void {
|
|
8
|
+
cli.command("render", "cli.cmd.render")
|
|
9
|
+
.option("-o, --output <file>", "cli.opt.output")
|
|
10
|
+
.option("--profile <name>", "cli.opt.profile")
|
|
11
|
+
.option("--input <format>", "cli.opt.input-format")
|
|
12
|
+
.option("--json", "cli.opt.json")
|
|
13
|
+
.action(async (options: ParsedOptions) => {
|
|
14
|
+
const inputPath = options._[0];
|
|
15
|
+
if (!inputPath || typeof inputPath !== "string") {
|
|
16
|
+
return ExitCode.InvalidArgs;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const runtime = await createVuTeXRuntime();
|
|
20
|
+
const result = await runtime.render(inputPath, {
|
|
21
|
+
output: typeof options.output === "string" ? options.output : undefined,
|
|
22
|
+
profile: typeof options.profile === "string" ? options.profile : undefined,
|
|
23
|
+
input: typeof options.input === "string" ? options.input : undefined,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (options.json === true) {
|
|
27
|
+
emitJson(result);
|
|
28
|
+
} else if (result.svg) {
|
|
29
|
+
console.log(result.svg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (result.diagnostics.length > 0) {
|
|
33
|
+
presentDiagnostics(result.diagnostics, options.json === true);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result.exitCode === 0 ? ExitCode.Ok : ExitCode.ActionFailed;
|
|
37
|
+
});
|
|
38
|
+
}
|
package/src/cli/context.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { createVuTeX, type VuTeXRuntime } from "../index.js";
|
|
2
|
-
import { loadVuTeXNode } from "../node/load.js";
|
|
3
|
-
|
|
4
|
-
export type CliContext = {
|
|
5
|
-
runtime: VuTeXRuntime | null;
|
|
6
|
-
toolVersion: string;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export async function createVuTeXRuntime(projectRoot?: string): Promise<VuTeXRuntime> {
|
|
10
|
-
return createVuTeX({ projectRoot: projectRoot ?? process.cwd(), host: "node", backend: "native" });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function loadBindings(): ReturnType<typeof loadVuTeXNode> | null {
|
|
14
|
-
try {
|
|
15
|
-
return loadVuTeXNode();
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function createContext(projectRoot?: string): Promise<CliContext> {
|
|
22
|
-
const bindings = loadBindings();
|
|
23
|
-
return {
|
|
24
|
-
runtime: bindings ? await createVuTeX({ projectRoot: projectRoot ?? process.cwd() }) : null,
|
|
25
|
-
toolVersion: bindings?.vutexVersion() ?? "0.0.0",
|
|
26
|
-
};
|
|
27
|
-
}
|
|
1
|
+
import { createVuTeX, type VuTeXRuntime } from "../index.js";
|
|
2
|
+
import { loadVuTeXNode } from "../node/load.js";
|
|
3
|
+
|
|
4
|
+
export type CliContext = {
|
|
5
|
+
runtime: VuTeXRuntime | null;
|
|
6
|
+
toolVersion: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export async function createVuTeXRuntime(projectRoot?: string): Promise<VuTeXRuntime> {
|
|
10
|
+
return createVuTeX({ projectRoot: projectRoot ?? process.cwd(), host: "node", backend: "native" });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function loadBindings(): ReturnType<typeof loadVuTeXNode> | null {
|
|
14
|
+
try {
|
|
15
|
+
return loadVuTeXNode();
|
|
16
|
+
} catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function createContext(projectRoot?: string): Promise<CliContext> {
|
|
22
|
+
const bindings = loadBindings();
|
|
23
|
+
return {
|
|
24
|
+
runtime: bindings ? await createVuTeX({ projectRoot: projectRoot ?? process.cwd() }) : null,
|
|
25
|
+
toolVersion: bindings?.vutexVersion() ?? "0.0.0",
|
|
26
|
+
};
|
|
27
|
+
}
|
package/src/cli/diagnostics.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import type { VuTeXDiagnostic } from "../types.js";
|
|
2
|
-
|
|
3
|
-
export function emitHuman(message: string): void {
|
|
4
|
-
console.error(message);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function emitJson(value: unknown): void {
|
|
8
|
-
console.log(JSON.stringify(value, null, 2));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function presentDiagnostics(
|
|
12
|
-
diagnostics: VuTeXDiagnostic[],
|
|
13
|
-
json: boolean,
|
|
14
|
-
): void {
|
|
15
|
-
if (json) {
|
|
16
|
-
emitJson({ diagnostics });
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
for (const item of diagnostics) {
|
|
20
|
-
const stage = item.stage ? `[${item.stage}] ` : "";
|
|
21
|
-
emitHuman(`${stage}${item.severity}: ${item.code} — ${item.message}`);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
import type { VuTeXDiagnostic } from "../types.js";
|
|
2
|
+
|
|
3
|
+
export function emitHuman(message: string): void {
|
|
4
|
+
console.error(message);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function emitJson(value: unknown): void {
|
|
8
|
+
console.log(JSON.stringify(value, null, 2));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function presentDiagnostics(
|
|
12
|
+
diagnostics: VuTeXDiagnostic[],
|
|
13
|
+
json: boolean,
|
|
14
|
+
): void {
|
|
15
|
+
if (json) {
|
|
16
|
+
emitJson({ diagnostics });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
for (const item of diagnostics) {
|
|
20
|
+
const stage = item.stage ? `[${item.stage}] ` : "";
|
|
21
|
+
emitHuman(`${stage}${item.severity}: ${item.code} — ${item.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/cli/exit-codes.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const ExitCode = {
|
|
2
|
-
Ok: 0,
|
|
3
|
-
ActionFailed: 1,
|
|
4
|
-
InvalidArgs: 2,
|
|
5
|
-
} as const;
|
|
1
|
+
export const ExitCode = {
|
|
2
|
+
Ok: 0,
|
|
3
|
+
ActionFailed: 1,
|
|
4
|
+
InvalidArgs: 2,
|
|
5
|
+
} as const;
|
package/src/cli/main.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildVuTeXCli } from "./cli.js";
|
|
2
|
-
|
|
3
|
-
export async function runCli(argv: string[]): Promise<number> {
|
|
4
|
-
return await buildVuTeXCli().parse(argv);
|
|
5
|
-
}
|
|
1
|
+
import { buildVuTeXCli } from "./cli.js";
|
|
2
|
+
|
|
3
|
+
export async function runCli(argv: string[]): Promise<number> {
|
|
4
|
+
return await buildVuTeXCli().parse(argv);
|
|
5
|
+
}
|