@sleetch/cli 1.0.7 → 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,19 +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
4
|
//#endregion
|
|
5
5
|
//#region src/bin/index.ts
|
|
6
6
|
new class sleetch_cli {
|
|
7
7
|
commands = [];
|
|
8
8
|
fallback;
|
|
9
|
-
constructor() {}
|
|
10
9
|
add(command) {
|
|
11
10
|
this.commands.push(command);
|
|
12
|
-
if (command.active
|
|
11
|
+
if (command.active === true && command.fallback === true) this.fallback = command;
|
|
13
12
|
return this;
|
|
14
13
|
}
|
|
15
14
|
resolve(args) {
|
|
16
|
-
if (args.length
|
|
15
|
+
if (args.length === 0) {
|
|
17
16
|
if (this.fallback) return {
|
|
18
17
|
found: true,
|
|
19
18
|
command: this.fallback,
|
|
@@ -26,8 +25,8 @@ new class sleetch_cli {
|
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
27
|
const [command_name, ...command_args] = args;
|
|
29
|
-
for (const command of this.commands) if (command_name
|
|
30
|
-
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) {
|
|
31
30
|
if (command.active) return {
|
|
32
31
|
found: true,
|
|
33
32
|
command,
|
|
@@ -36,7 +35,7 @@ new class sleetch_cli {
|
|
|
36
35
|
else return {
|
|
37
36
|
found: false,
|
|
38
37
|
type: "bad option",
|
|
39
|
-
error:
|
|
38
|
+
error: `inactive command: ${command_name}`
|
|
40
39
|
};
|
|
41
40
|
} else {
|
|
42
41
|
const sub_cli = new sleetch_cli();
|
|
@@ -62,7 +61,7 @@ new class sleetch_cli {
|
|
|
62
61
|
}
|
|
63
62
|
run(args) {
|
|
64
63
|
const resolve = this.resolve(args);
|
|
65
|
-
if (resolve.found
|
|
64
|
+
if (resolve.found === true) {
|
|
66
65
|
const { command, args } = resolve;
|
|
67
66
|
const parsed = parseArgs({
|
|
68
67
|
args,
|
|
@@ -97,8 +96,8 @@ new class sleetch_cli {
|
|
|
97
96
|
active: true,
|
|
98
97
|
options: {},
|
|
99
98
|
fallback: true,
|
|
100
|
-
action: (
|
|
101
|
-
|
|
99
|
+
action: (_options, cli) => {
|
|
100
|
+
const lines = [
|
|
102
101
|
`${styleText("cyan", "sleetch") + styleText("cyanBright", ".dev")} is a powerful documentation framework.`,
|
|
103
102
|
"",
|
|
104
103
|
`Usage: ${styleText("cyan", "sleetch")} ${styleText("gray", "<command>")} ${styleText("cyanBright", "[...args]")}`,
|
|
@@ -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: [{
|
|
@@ -46,11 +46,11 @@ const create_command = {
|
|
|
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
|
}
|