@sleetch/cli 1.0.6 → 1.0.8
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/bin/index.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as create_command } from "../create-
|
|
2
|
+
import { t as create_command } from "../create-BrR9u4lK.js";
|
|
3
3
|
import { parseArgs, styleText } from "node:util";
|
|
4
|
-
import { sleetch_runtime } from "@sleetch/core/compiler";
|
|
5
4
|
//#endregion
|
|
6
5
|
//#region src/bin/index.ts
|
|
7
6
|
new class sleetch_cli {
|
|
8
|
-
runtime = new sleetch_runtime();
|
|
9
7
|
commands = [];
|
|
10
8
|
fallback;
|
|
11
|
-
constructor() {}
|
|
12
9
|
add(command) {
|
|
13
10
|
this.commands.push(command);
|
|
14
|
-
if (command.active
|
|
11
|
+
if (command.active === true && command.fallback === true) this.fallback = command;
|
|
15
12
|
return this;
|
|
16
13
|
}
|
|
17
14
|
resolve(args) {
|
|
18
|
-
if (args.length
|
|
15
|
+
if (args.length === 0) {
|
|
19
16
|
if (this.fallback) return {
|
|
20
17
|
found: true,
|
|
21
18
|
command: this.fallback,
|
|
@@ -28,8 +25,8 @@ new class sleetch_cli {
|
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
const [command_name, ...command_args] = args;
|
|
31
|
-
for (const command of this.commands) if (command_name
|
|
32
|
-
if (!command.subcommands || command.subcommands.length
|
|
28
|
+
for (const command of this.commands) if (command_name === command.name) {
|
|
29
|
+
if (!command.subcommands || command.subcommands.length === 0) {
|
|
33
30
|
if (command.active) return {
|
|
34
31
|
found: true,
|
|
35
32
|
command,
|
|
@@ -38,7 +35,7 @@ new class sleetch_cli {
|
|
|
38
35
|
else return {
|
|
39
36
|
found: false,
|
|
40
37
|
type: "bad option",
|
|
41
|
-
error:
|
|
38
|
+
error: `inactive command: ${command_name}`
|
|
42
39
|
};
|
|
43
40
|
} else {
|
|
44
41
|
const sub_cli = new sleetch_cli();
|
|
@@ -64,7 +61,7 @@ new class sleetch_cli {
|
|
|
64
61
|
}
|
|
65
62
|
run(args) {
|
|
66
63
|
const resolve = this.resolve(args);
|
|
67
|
-
if (resolve.found
|
|
64
|
+
if (resolve.found === true) {
|
|
68
65
|
const { command, args } = resolve;
|
|
69
66
|
const parsed = parseArgs({
|
|
70
67
|
args,
|
|
@@ -99,8 +96,8 @@ new class sleetch_cli {
|
|
|
99
96
|
active: true,
|
|
100
97
|
options: {},
|
|
101
98
|
fallback: true,
|
|
102
|
-
action: (
|
|
103
|
-
|
|
99
|
+
action: (_options, cli) => {
|
|
100
|
+
const lines = [
|
|
104
101
|
`${styleText("cyan", "sleetch") + styleText("cyanBright", ".dev")} is a powerful documentation framework.`,
|
|
105
102
|
"",
|
|
106
103
|
`Usage: ${styleText("cyan", "sleetch")} ${styleText("gray", "<command>")} ${styleText("cyanBright", "[...args]")}`,
|
|
@@ -144,9 +141,15 @@ new class sleetch_cli {
|
|
|
144
141
|
default: false
|
|
145
142
|
} },
|
|
146
143
|
action: async (options, cli) => {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
try {
|
|
145
|
+
const { sleetch_runtime } = await import("@sleetch/core/compiler");
|
|
146
|
+
const runtime = new sleetch_runtime();
|
|
147
|
+
await runtime.sources.load();
|
|
148
|
+
await runtime.builder.build();
|
|
149
|
+
if (options.get_boolean_option("watch")) await runtime.sources.watch();
|
|
150
|
+
} catch (error) {
|
|
151
|
+
if (error instanceof Error) cli.error("error", error.message);
|
|
152
|
+
}
|
|
150
153
|
}
|
|
151
154
|
}).add(create_command).run(process.argv.slice(2));
|
|
152
155
|
//#endregion
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { ParseArgsConfig } from "node:util";
|
|
2
|
-
import { sleetch_runtime } from "@sleetch/core/compiler";
|
|
3
2
|
//#region src/lib/cli.d.ts
|
|
4
3
|
declare class sleetch_cli {
|
|
5
|
-
runtime: sleetch_runtime;
|
|
6
4
|
commands: command[];
|
|
7
5
|
private fallback?;
|
|
8
|
-
constructor();
|
|
9
6
|
add(command: command): this;
|
|
10
7
|
resolve(args: string[]): {
|
|
11
8
|
found: true;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as create_command } from "../../create-
|
|
1
|
+
import { t as create_command } from "../../create-BrR9u4lK.js";
|
|
2
2
|
export { create_command };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createReadStream, createWriteStream, existsSync } from "node:fs";
|
|
2
|
+
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
2
5
|
import { pipeline } from "node:stream";
|
|
3
6
|
import { promisify, styleText } from "node:util";
|
|
4
7
|
import zlib from "node:zlib";
|
|
5
8
|
import tar from "tar-fs";
|
|
6
|
-
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import path from "node:path";
|
|
8
|
-
import { tmpdir } from "node:os";
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "1.0.
|
|
10
|
+
var version = "1.0.8";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/commands/create/index.ts
|
|
13
13
|
const create_command = {
|
|
@@ -15,7 +15,7 @@ const create_command = {
|
|
|
15
15
|
description: "Create.",
|
|
16
16
|
options: {},
|
|
17
17
|
active: false,
|
|
18
|
-
action: (options,
|
|
18
|
+
action: (options, _cli) => {
|
|
19
19
|
console.log("create", options);
|
|
20
20
|
},
|
|
21
21
|
subcommands: [{
|
|
@@ -42,15 +42,15 @@ const create_command = {
|
|
|
42
42
|
await mkdir(temp_directory, { recursive: true });
|
|
43
43
|
const templates = {
|
|
44
44
|
"react-router": "/sleetch-main/templates/react-router",
|
|
45
|
-
"next-
|
|
45
|
+
"next-webpack": "/sleetch-main/templates/next-webpack"
|
|
46
46
|
};
|
|
47
47
|
const name = options.get_string_option("name");
|
|
48
48
|
const framework = options.get_string_option("framework");
|
|
49
|
-
if (name
|
|
50
|
-
if (framework
|
|
51
|
-
if (!Object.keys(templates).includes(framework)) return cli.error("bad option",
|
|
49
|
+
if (name === void 0) return cli.error("missing arg", "name is missing.");
|
|
50
|
+
if (framework === void 0) return cli.error("missing arg", "framework is missing.");
|
|
51
|
+
if (!Object.keys(templates).includes(framework)) return cli.error("bad option", `framework must be : ${Object.keys(templates).join(" / ")}`);
|
|
52
52
|
const final_template_directory = path.join(cwd, name);
|
|
53
|
-
if (existsSync(final_template_directory)) return cli.error("error", final_template_directory
|
|
53
|
+
if (existsSync(final_template_directory)) return cli.error("error", `${final_template_directory} already exist on your filesystem.`);
|
|
54
54
|
await mkdir(final_template_directory, { recursive: true });
|
|
55
55
|
const response = await fetch(source_code_tarball_url);
|
|
56
56
|
if (response.ok && response.body) {
|
|
@@ -72,6 +72,7 @@ const create_command = {
|
|
|
72
72
|
lines.push("");
|
|
73
73
|
lines.push(`Check your project: cd ./${name} `);
|
|
74
74
|
lines.push(`Install the dependencies: ${styleText("cyan", "bun") + styleText("dim", "/") + styleText("white", "npm") + styleText("dim", "/") + styleText("white", "pnpm")} install`);
|
|
75
|
+
lines.push(`Note: we also have templates for: ${Object.keys(templates).filter((t) => t !== framework).join(", ")} `);
|
|
75
76
|
lines.push("");
|
|
76
77
|
lines.push(`Learn more: ${styleText("gray", "https://") + styleText("cyan", "sleetch") + styleText("cyanBright", ".dev")} `);
|
|
77
78
|
lines.push(` ${styleText("gray", "https://github.com/tornado-softwares/") + styleText("cyan", "sleetch")}`);
|
package/package.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@sleetch/cli",
|
|
3
|
+
"version": "1.0.8",
|
|
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.8",
|
|
17
|
+
"tar-fs": "^3.1.3",
|
|
18
|
+
"zod": "^4.4.3"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/tar-fs": "^2.0.4"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
"./bin": "./dist/bin/index.js",
|
|
25
|
+
"./commands/create": "./dist/commands/create/index.js",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"bin": {
|
|
29
|
+
"sleetch": "./dist/bin/index.js"
|
|
30
|
+
},
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"module": "./dist/index.js"
|
|
34
34
|
}
|