@sleetch/cli 1.0.4
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/dist/index.d.ts +1 -0
- package/dist/index.js +77 -0
- package/package.json +29 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { styleText } from "node:util";
|
|
3
|
+
import { sleetch_runtime } from "@sleetch/core/compiler";
|
|
4
|
+
//#region src/commands/build.ts
|
|
5
|
+
const build_command = {
|
|
6
|
+
name: "build",
|
|
7
|
+
description: "Prebuild the content from sources.",
|
|
8
|
+
action: async (args, cli) => {
|
|
9
|
+
await cli.runtime.sources.load();
|
|
10
|
+
await cli.runtime.builder.build();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/commands/help.ts
|
|
15
|
+
const help_command = {
|
|
16
|
+
name: "help",
|
|
17
|
+
description: "Get available commands.",
|
|
18
|
+
fallback: true,
|
|
19
|
+
action: (args, cli) => {
|
|
20
|
+
let lines = [
|
|
21
|
+
`${styleText("green", "sleetch") + styleText("greenBright", ".net")} is a powerful documentation framework.`,
|
|
22
|
+
"",
|
|
23
|
+
`Usage: ${styleText("green", "sleetch")} ${styleText("gray", "<command>")} ${styleText("greenBright", "[...args]")}`,
|
|
24
|
+
"",
|
|
25
|
+
"Commands:",
|
|
26
|
+
""
|
|
27
|
+
];
|
|
28
|
+
for (const command of cli.commands) lines.push(` ${styleText("green", command.name)} ${styleText("gray", "-")} ${command.description}`);
|
|
29
|
+
lines.push("");
|
|
30
|
+
lines.push(`Learn more: ${styleText("gray", "https://") + styleText("green", "sleetch") + styleText("greenBright", ".net")} `);
|
|
31
|
+
lines.push(` ${styleText("gray", "https://github.com/tornado-softwares/") + styleText("green", "sleetch")}`);
|
|
32
|
+
console.log(lines.join("\n"));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/commands/watch.ts
|
|
37
|
+
const watch_command = {
|
|
38
|
+
name: "watch",
|
|
39
|
+
description: "Prebuild the content from sources.",
|
|
40
|
+
action: async (args, cli) => {
|
|
41
|
+
await cli.runtime.sources.load();
|
|
42
|
+
await cli.runtime.builder.build();
|
|
43
|
+
await cli.runtime.sources.watch();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/lib/cli.ts
|
|
48
|
+
var sleetch_cli = class {
|
|
49
|
+
runtime = new sleetch_runtime();
|
|
50
|
+
commands = [];
|
|
51
|
+
fallback;
|
|
52
|
+
constructor() {}
|
|
53
|
+
add(command) {
|
|
54
|
+
this.commands.push(command);
|
|
55
|
+
if (command.fallback == true) this.fallback = command;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
run(args) {
|
|
59
|
+
if (args.length == 0) {
|
|
60
|
+
if (this.fallback) this.fallback.action([], this);
|
|
61
|
+
else console.error(`sleetch: no command `);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const [command_name, ...command_args] = args;
|
|
65
|
+
console.log(command_name);
|
|
66
|
+
for (const command of this.commands) if (command_name == command.name) {
|
|
67
|
+
command.action(command_args, this);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
console.error(`sleetch: bad option: ${command_name}`);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/bin/index.ts
|
|
75
|
+
new sleetch_cli().add(help_command).add(build_command).add(watch_command).run(process.argv.slice(2));
|
|
76
|
+
//#endregion
|
|
77
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sleetch/cli",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsdown",
|
|
13
|
+
"dev": "tsdown --watch"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@sleetch/core": "1.0.4",
|
|
17
|
+
"zod": "^4.4.3"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./dist/index.js",
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"sleetch": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.js"
|
|
29
|
+
}
|