@kimesh/cli 0.1.0-nightly.20260119171158 → 0.1.0-nightly.20260120030901
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/kmi.mjs +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +3 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.js +7 -0
- package/package.json +11 -16
- package/bin/km.mjs +0 -2
- package/dist/build-DBrdh66Y.mjs +0 -42
- package/dist/build-SbtFzvBZ.mjs +0 -3
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs +0 -26
- package/dist/dev-BS9Wi0ha.mjs +0 -3
- package/dist/dev-C9X23BeN.mjs +0 -111
- package/dist/generate-BEf3_Td5.mjs +0 -24
- package/dist/generate-DDtc1Ah6.mjs +0 -3
- package/dist/index.d.mts +0 -68
- package/dist/index.mjs +0 -5
- package/dist/layer-C4xuYktL.mjs +0 -267
- package/dist/prepare-4Ydu9NNx.mjs +0 -59
package/bin/kmi.mjs
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { banner, buildArgs, clearKitCache, commands, devArgs, getBuildDir, getCurrentDir, getKit, isGlobalInstall, loadKit, logger, main, prepareArgs, resolveRoot, run, sharedArgs, step, success, timing, version, withSpinner } from "../../kmi/src/index";
|
|
2
|
+
export { banner, buildArgs, clearKitCache, commands, devArgs, getBuildDir, getCurrentDir, getKit, isGlobalInstall, loadKit, logger, main, prepareArgs, resolveRoot, run, sharedArgs, step, success, timing, version, withSpinner };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { banner, buildArgs, clearKitCache, commands, devArgs, getBuildDir, getCurrentDir, getKit, isGlobalInstall, loadKit, logger, main, prepareArgs, resolveRoot, run, sharedArgs, step, success, timing, version, withSpinner } from "../../kmi/src/index";
|
|
2
|
+
|
|
3
|
+
export { banner, buildArgs, clearKitCache, commands, devArgs, getBuildDir, getCurrentDir, getKit, isGlobalInstall, loadKit, logger, main, prepareArgs, resolveRoot, run, sharedArgs, step, success, timing, version, withSpinner };
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
package/dist/run.d.ts
ADDED
package/dist/run.js
ADDED
package/package.json
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimesh/cli",
|
|
3
|
-
"version": "0.1.0-nightly.
|
|
4
|
-
"description": "CLI for
|
|
3
|
+
"version": "0.1.0-nightly.20260120030901",
|
|
4
|
+
"description": "Kimesh CLI for integration with main package",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"km": "./bin/km.mjs"
|
|
8
|
-
},
|
|
9
6
|
"exports": {
|
|
10
7
|
".": {
|
|
11
8
|
"types": "./dist/index.d.mts",
|
|
12
9
|
"import": "./dist/index.mjs"
|
|
13
|
-
}
|
|
10
|
+
},
|
|
11
|
+
"./cli": "./bin/kmi.mjs"
|
|
14
12
|
},
|
|
15
13
|
"main": "./dist/index.mjs",
|
|
16
14
|
"types": "./dist/index.d.mts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"kmi": "bin/kmi.mjs",
|
|
17
|
+
"km": "bin/kmi.mjs"
|
|
18
|
+
},
|
|
17
19
|
"files": [
|
|
18
20
|
"dist",
|
|
19
21
|
"bin"
|
|
@@ -24,17 +26,10 @@
|
|
|
24
26
|
"typecheck": "tsc --noEmit"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
"citty": "^0.1.6",
|
|
29
|
-
"consola": "^3.4.2",
|
|
30
|
-
"picocolors": "^1.1.1"
|
|
29
|
+
"kmi": "0.1.0-nightly.20260120030901"
|
|
31
30
|
},
|
|
32
31
|
"devDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"typescript": "^5.
|
|
35
|
-
"tsdown": "^0.20.0-beta.3"
|
|
36
|
-
},
|
|
37
|
-
"peerDependencies": {
|
|
38
|
-
"vite": "^8.0.0-beta.8"
|
|
32
|
+
"tsdown": "^0.11.7",
|
|
33
|
+
"typescript": "^5.8.2"
|
|
39
34
|
}
|
|
40
35
|
}
|
package/bin/km.mjs
DELETED
package/dist/build-DBrdh66Y.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
|
|
5
|
-
//#region src/commands/build.ts
|
|
6
|
-
var build_default = defineCommand({
|
|
7
|
-
meta: {
|
|
8
|
-
name: "build",
|
|
9
|
-
description: "Build for production"
|
|
10
|
-
},
|
|
11
|
-
args: {
|
|
12
|
-
root: {
|
|
13
|
-
type: "string",
|
|
14
|
-
alias: "r",
|
|
15
|
-
description: "Project root directory"
|
|
16
|
-
},
|
|
17
|
-
config: {
|
|
18
|
-
type: "string",
|
|
19
|
-
alias: "c",
|
|
20
|
-
description: "Config file path"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
async run({ args }) {
|
|
24
|
-
const root = resolve(args.root || process.cwd());
|
|
25
|
-
consola.info(`Building for production...`);
|
|
26
|
-
const { loadConfig, kimeshPlugin } = await import("@kimesh/kit");
|
|
27
|
-
const kmConfig = await loadConfig({
|
|
28
|
-
root,
|
|
29
|
-
configFile: args.config
|
|
30
|
-
});
|
|
31
|
-
const { build } = await import("vite");
|
|
32
|
-
await build({
|
|
33
|
-
root,
|
|
34
|
-
configFile: false,
|
|
35
|
-
plugins: [kimeshPlugin({ config: kmConfig })]
|
|
36
|
-
});
|
|
37
|
-
consola.success(`Build complete!`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { build_default as t };
|
package/dist/build-SbtFzvBZ.mjs
DELETED
package/dist/cli.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
package/dist/cli.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { defineCommand, runMain } from "citty";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
|
|
5
|
-
//#region src/cli.ts
|
|
6
|
-
const version = "0.1.0";
|
|
7
|
-
runMain(defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "km",
|
|
10
|
-
version,
|
|
11
|
-
description: "Kimesh Framework CLI"
|
|
12
|
-
},
|
|
13
|
-
subCommands: {
|
|
14
|
-
dev: () => import("./dev-BS9Wi0ha.mjs").then((m) => m.default),
|
|
15
|
-
build: () => import("./build-SbtFzvBZ.mjs").then((m) => m.default),
|
|
16
|
-
generate: () => import("./generate-DDtc1Ah6.mjs").then((m) => m.default),
|
|
17
|
-
layer: () => import("./layer-C4xuYktL.mjs").then((m) => m.default),
|
|
18
|
-
prepare: () => import("./prepare-4Ydu9NNx.mjs").then((m) => m.default)
|
|
19
|
-
},
|
|
20
|
-
setup() {
|
|
21
|
-
consola.log(pc.cyan(`\n 🚀 Kimesh Framework v${version}\n`));
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
export { };
|
package/dist/dev-BS9Wi0ha.mjs
DELETED
package/dist/dev-C9X23BeN.mjs
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import pc from "picocolors";
|
|
5
|
-
|
|
6
|
-
//#region src/commands/dev.ts
|
|
7
|
-
var dev_default = defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "dev",
|
|
10
|
-
description: "Start development server"
|
|
11
|
-
},
|
|
12
|
-
args: {
|
|
13
|
-
port: {
|
|
14
|
-
type: "string",
|
|
15
|
-
alias: "p",
|
|
16
|
-
description: "Server port",
|
|
17
|
-
default: "3000"
|
|
18
|
-
},
|
|
19
|
-
host: {
|
|
20
|
-
type: "string",
|
|
21
|
-
alias: "h",
|
|
22
|
-
description: "Server host"
|
|
23
|
-
},
|
|
24
|
-
open: {
|
|
25
|
-
type: "boolean",
|
|
26
|
-
alias: "o",
|
|
27
|
-
description: "Open browser on start",
|
|
28
|
-
default: false
|
|
29
|
-
},
|
|
30
|
-
config: {
|
|
31
|
-
type: "string",
|
|
32
|
-
alias: "c",
|
|
33
|
-
description: "Config file path"
|
|
34
|
-
},
|
|
35
|
-
root: {
|
|
36
|
-
type: "string",
|
|
37
|
-
alias: "r",
|
|
38
|
-
description: "Project root directory"
|
|
39
|
-
},
|
|
40
|
-
layers: {
|
|
41
|
-
type: "string",
|
|
42
|
-
alias: "l",
|
|
43
|
-
description: "Comma-separated list of layers to enable (e.g., 'cms,auth') or 'all'/'none'"
|
|
44
|
-
},
|
|
45
|
-
"exclude-layers": {
|
|
46
|
-
type: "string",
|
|
47
|
-
alias: "x",
|
|
48
|
-
description: "Comma-separated list of layers to exclude"
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
async run({ args }) {
|
|
52
|
-
const root = resolve(args.root || process.cwd());
|
|
53
|
-
const { loadConfig } = await import("@kimesh/kit");
|
|
54
|
-
const kmConfig = await loadConfig({
|
|
55
|
-
root,
|
|
56
|
-
configFile: args.config
|
|
57
|
-
});
|
|
58
|
-
const enabledLayers = parseLayersArg(args.layers);
|
|
59
|
-
const excludedLayers = args["exclude-layers"] ? args["exclude-layers"].split(",").map((l) => l.trim()) : [];
|
|
60
|
-
consola.info(`Starting ${pc.cyan(kmConfig.name || "Kimesh")} dev server...`);
|
|
61
|
-
if (enabledLayers === "all") consola.info(`Layers: ${pc.green("all")}`);
|
|
62
|
-
else if (enabledLayers === "none") consola.info(`Layers: ${pc.yellow("none (host only)")}`);
|
|
63
|
-
else if (Array.isArray(enabledLayers)) consola.info(`Layers: ${pc.cyan(enabledLayers.join(", "))}`);
|
|
64
|
-
if (excludedLayers.length > 0) consola.info(`Excluded: ${pc.yellow(excludedLayers.join(", "))}`);
|
|
65
|
-
const { createServer } = await import("vite");
|
|
66
|
-
const { kimeshPlugin } = await import("@kimesh/kit");
|
|
67
|
-
const port = args.port ? parseInt(args.port, 10) : kmConfig.dev?.port ?? 3e3;
|
|
68
|
-
const host = args.host ?? kmConfig.dev?.host ?? "localhost";
|
|
69
|
-
const open = args.open ?? kmConfig.dev?.open ?? false;
|
|
70
|
-
const server = await createServer({
|
|
71
|
-
root,
|
|
72
|
-
configFile: false,
|
|
73
|
-
plugins: [kimeshPlugin({
|
|
74
|
-
config: kmConfig,
|
|
75
|
-
layers: {
|
|
76
|
-
enabled: enabledLayers,
|
|
77
|
-
excluded: excludedLayers
|
|
78
|
-
}
|
|
79
|
-
})],
|
|
80
|
-
server: {
|
|
81
|
-
port,
|
|
82
|
-
host,
|
|
83
|
-
open
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
await server.listen();
|
|
87
|
-
server.printUrls();
|
|
88
|
-
consola.success(`Dev server started!`);
|
|
89
|
-
const cleanup = async () => {
|
|
90
|
-
consola.info("Shutting down...");
|
|
91
|
-
await server.close();
|
|
92
|
-
process.exit(0);
|
|
93
|
-
};
|
|
94
|
-
process.on("SIGINT", cleanup);
|
|
95
|
-
process.on("SIGTERM", cleanup);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
/**
|
|
99
|
-
* Parse the --layers argument
|
|
100
|
-
*/
|
|
101
|
-
function parseLayersArg(arg) {
|
|
102
|
-
const envLayers = process.env.KM_LAYERS;
|
|
103
|
-
const layersArg = arg ?? envLayers;
|
|
104
|
-
if (!layersArg) return "all";
|
|
105
|
-
if (layersArg === "all") return "all";
|
|
106
|
-
if (layersArg === "none") return "none";
|
|
107
|
-
return layersArg.split(",").map((l) => l.trim()).filter(Boolean);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
//#endregion
|
|
111
|
-
export { dev_default as t };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
|
|
5
|
-
//#region src/commands/generate.ts
|
|
6
|
-
var generate_default = defineCommand({
|
|
7
|
-
meta: {
|
|
8
|
-
name: "generate",
|
|
9
|
-
description: "Generate routes and types"
|
|
10
|
-
},
|
|
11
|
-
args: { root: {
|
|
12
|
-
type: "string",
|
|
13
|
-
alias: "r",
|
|
14
|
-
description: "Project root directory"
|
|
15
|
-
} },
|
|
16
|
-
async run({ args }) {
|
|
17
|
-
consola.info(`Generating routes and types...`);
|
|
18
|
-
consola.warn(pc.yellow("Route generation will be available in Phase 2"));
|
|
19
|
-
consola.success(`Generation complete!`);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { generate_default as t };
|
package/dist/index.d.mts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as citty1 from "citty";
|
|
2
|
-
import { KimeshConfig, KimeshPluginOptions, LoadConfigOptions } from "@kimesh/kit";
|
|
3
|
-
|
|
4
|
-
//#region src/commands/dev.d.ts
|
|
5
|
-
declare const _default$1: citty1.CommandDef<{
|
|
6
|
-
port: {
|
|
7
|
-
type: "string";
|
|
8
|
-
alias: string;
|
|
9
|
-
description: string;
|
|
10
|
-
default: string;
|
|
11
|
-
};
|
|
12
|
-
host: {
|
|
13
|
-
type: "string";
|
|
14
|
-
alias: string;
|
|
15
|
-
description: string;
|
|
16
|
-
};
|
|
17
|
-
open: {
|
|
18
|
-
type: "boolean";
|
|
19
|
-
alias: string;
|
|
20
|
-
description: string;
|
|
21
|
-
default: false;
|
|
22
|
-
};
|
|
23
|
-
config: {
|
|
24
|
-
type: "string";
|
|
25
|
-
alias: string;
|
|
26
|
-
description: string;
|
|
27
|
-
};
|
|
28
|
-
root: {
|
|
29
|
-
type: "string";
|
|
30
|
-
alias: string;
|
|
31
|
-
description: string;
|
|
32
|
-
};
|
|
33
|
-
layers: {
|
|
34
|
-
type: "string";
|
|
35
|
-
alias: string;
|
|
36
|
-
description: string;
|
|
37
|
-
};
|
|
38
|
-
"exclude-layers": {
|
|
39
|
-
type: "string";
|
|
40
|
-
alias: string;
|
|
41
|
-
description: string;
|
|
42
|
-
};
|
|
43
|
-
}>;
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region src/commands/build.d.ts
|
|
46
|
-
declare const _default: citty1.CommandDef<{
|
|
47
|
-
root: {
|
|
48
|
-
type: "string";
|
|
49
|
-
alias: string;
|
|
50
|
-
description: string;
|
|
51
|
-
};
|
|
52
|
-
config: {
|
|
53
|
-
type: "string";
|
|
54
|
-
alias: string;
|
|
55
|
-
description: string;
|
|
56
|
-
};
|
|
57
|
-
}>;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/commands/generate.d.ts
|
|
60
|
-
declare const _default$2: citty1.CommandDef<{
|
|
61
|
-
root: {
|
|
62
|
-
type: "string";
|
|
63
|
-
alias: string;
|
|
64
|
-
description: string;
|
|
65
|
-
};
|
|
66
|
-
}>;
|
|
67
|
-
//#endregion
|
|
68
|
-
export { type KimeshConfig, type KimeshPluginOptions, type LoadConfigOptions, _default as buildCommand, _default$1 as devCommand, _default$2 as generateCommand };
|
package/dist/index.mjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { t as dev_default } from "./dev-C9X23BeN.mjs";
|
|
2
|
-
import { t as build_default } from "./build-DBrdh66Y.mjs";
|
|
3
|
-
import { t as generate_default } from "./generate-BEf3_Td5.mjs";
|
|
4
|
-
|
|
5
|
-
export { build_default as buildCommand, dev_default as devCommand, generate_default as generateCommand };
|
package/dist/layer-C4xuYktL.mjs
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import pc from "picocolors";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
|
|
7
|
-
//#region src/commands/layer.ts
|
|
8
|
-
var layer_default = defineCommand({
|
|
9
|
-
meta: {
|
|
10
|
-
name: "layer",
|
|
11
|
-
description: "Manage Kimesh layers"
|
|
12
|
-
},
|
|
13
|
-
subCommands: {
|
|
14
|
-
list: defineCommand({
|
|
15
|
-
meta: {
|
|
16
|
-
name: "list",
|
|
17
|
-
description: "List available layers"
|
|
18
|
-
},
|
|
19
|
-
args: { root: {
|
|
20
|
-
type: "string",
|
|
21
|
-
alias: "r",
|
|
22
|
-
description: "Project root directory"
|
|
23
|
-
} },
|
|
24
|
-
async run({ args }) {
|
|
25
|
-
const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
|
|
26
|
-
const { loadConfig } = await import("@kimesh/kit");
|
|
27
|
-
const kmConfig = await loadConfig({ root });
|
|
28
|
-
consola.info(`${pc.cyan("Available layers:")}\n`);
|
|
29
|
-
const extendsLayers = kmConfig.extends || [];
|
|
30
|
-
if (extendsLayers.length > 0) {
|
|
31
|
-
consola.log(pc.bold("From config (extends):"));
|
|
32
|
-
for (const layer of extendsLayers) {
|
|
33
|
-
const name = typeof layer === "string" ? layer : layer.name;
|
|
34
|
-
consola.log(` ${pc.green("✓")} ${name}`);
|
|
35
|
-
}
|
|
36
|
-
consola.log("");
|
|
37
|
-
}
|
|
38
|
-
const layersDir = join(root, "layers");
|
|
39
|
-
if (fs.existsSync(layersDir)) {
|
|
40
|
-
const layers = fs.readdirSync(layersDir, { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
41
|
-
if (layers.length > 0) {
|
|
42
|
-
consola.log(pc.bold("Auto-discovered (layers/):"));
|
|
43
|
-
for (const layer of layers) {
|
|
44
|
-
const layerPath = join(layersDir, layer.name);
|
|
45
|
-
const hasConfig = fs.existsSync(join(layerPath, "kimesh.config.ts"));
|
|
46
|
-
const hasRoutes = fs.existsSync(join(layerPath, "routes"));
|
|
47
|
-
const hasComponents = fs.existsSync(join(layerPath, "components"));
|
|
48
|
-
const hasComposables = fs.existsSync(join(layerPath, "composables"));
|
|
49
|
-
const features = [
|
|
50
|
-
hasConfig ? "config" : null,
|
|
51
|
-
hasRoutes ? "routes" : null,
|
|
52
|
-
hasComponents ? "components" : null,
|
|
53
|
-
hasComposables ? "composables" : null
|
|
54
|
-
].filter(Boolean).join(", ");
|
|
55
|
-
consola.log(` ${pc.green("✓")} ${layer.name} ${pc.dim(`(${features})`)}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else consola.log(pc.dim("No layers/ directory found"));
|
|
59
|
-
}
|
|
60
|
-
}),
|
|
61
|
-
info: defineCommand({
|
|
62
|
-
meta: {
|
|
63
|
-
name: "info",
|
|
64
|
-
description: "Show detailed information about a layer"
|
|
65
|
-
},
|
|
66
|
-
args: {
|
|
67
|
-
name: {
|
|
68
|
-
type: "positional",
|
|
69
|
-
description: "Layer name",
|
|
70
|
-
required: true
|
|
71
|
-
},
|
|
72
|
-
root: {
|
|
73
|
-
type: "string",
|
|
74
|
-
alias: "r",
|
|
75
|
-
description: "Project root directory"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
async run({ args }) {
|
|
79
|
-
const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
|
|
80
|
-
const layerName = args.name;
|
|
81
|
-
const layerPath = join(root, "layers", layerName);
|
|
82
|
-
if (!fs.existsSync(layerPath)) {
|
|
83
|
-
consola.error(`Layer not found: ${layerName}`);
|
|
84
|
-
consola.info(`Checked: ${layerPath}`);
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
consola.log(`\n${pc.cyan(pc.bold(`Layer: ${layerName}`))}\n`);
|
|
88
|
-
consola.log(`${pc.bold("Path:")} ${layerPath}`);
|
|
89
|
-
const structure = [];
|
|
90
|
-
const checkDir = (dir, label) => {
|
|
91
|
-
const fullPath = join(layerPath, dir);
|
|
92
|
-
if (fs.existsSync(fullPath)) {
|
|
93
|
-
const files = fs.readdirSync(fullPath);
|
|
94
|
-
structure.push(`${label}: ${files.length} files`);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
checkDir("routes", "Routes");
|
|
98
|
-
checkDir("components", "Components");
|
|
99
|
-
checkDir("composables", "Composables");
|
|
100
|
-
checkDir("utils", "Utilities");
|
|
101
|
-
checkDir("stores", "Stores");
|
|
102
|
-
if (structure.length > 0) {
|
|
103
|
-
consola.log(`\n${pc.bold("Structure:")}`);
|
|
104
|
-
for (const item of structure) consola.log(` ${pc.green("•")} ${item}`);
|
|
105
|
-
}
|
|
106
|
-
const configPath = join(layerPath, "kimesh.config.ts");
|
|
107
|
-
if (fs.existsSync(configPath)) consola.log(`\n${pc.bold("Config:")} ${pc.green("Found")}`);
|
|
108
|
-
}
|
|
109
|
-
}),
|
|
110
|
-
create: defineCommand({
|
|
111
|
-
meta: {
|
|
112
|
-
name: "create",
|
|
113
|
-
description: "Create a new layer scaffold"
|
|
114
|
-
},
|
|
115
|
-
args: {
|
|
116
|
-
name: {
|
|
117
|
-
type: "positional",
|
|
118
|
-
description: "Layer name",
|
|
119
|
-
required: true
|
|
120
|
-
},
|
|
121
|
-
root: {
|
|
122
|
-
type: "string",
|
|
123
|
-
alias: "r",
|
|
124
|
-
description: "Project root directory"
|
|
125
|
-
},
|
|
126
|
-
basePath: {
|
|
127
|
-
type: "string",
|
|
128
|
-
alias: "b",
|
|
129
|
-
description: "Base path for routes (e.g., /cms)"
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
async run({ args }) {
|
|
133
|
-
const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
|
|
134
|
-
const layerName = args.name;
|
|
135
|
-
const basePath = args.basePath || `/${layerName}`;
|
|
136
|
-
const layerPath = join(join(root, "layers"), layerName);
|
|
137
|
-
if (fs.existsSync(layerPath)) {
|
|
138
|
-
consola.error(`Layer already exists: ${layerPath}`);
|
|
139
|
-
process.exit(1);
|
|
140
|
-
}
|
|
141
|
-
consola.info(`Creating layer: ${pc.cyan(layerName)}`);
|
|
142
|
-
for (const dir of [
|
|
143
|
-
"",
|
|
144
|
-
"routes",
|
|
145
|
-
"components",
|
|
146
|
-
"composables",
|
|
147
|
-
"utils",
|
|
148
|
-
"stores"
|
|
149
|
-
]) {
|
|
150
|
-
const dirPath = join(layerPath, dir);
|
|
151
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
152
|
-
consola.log(` ${pc.green("+")} ${dir || layerName}/`);
|
|
153
|
-
}
|
|
154
|
-
const configContent = `import { defineKmConfig } from '@kimesh/kit'
|
|
155
|
-
|
|
156
|
-
export default defineKmConfig({
|
|
157
|
-
name: '${layerName}',
|
|
158
|
-
|
|
159
|
-
// Base path for all routes in this layer
|
|
160
|
-
basePath: '${basePath}',
|
|
161
|
-
|
|
162
|
-
// Routes configuration
|
|
163
|
-
routes: {
|
|
164
|
-
basePath: '${basePath}',
|
|
165
|
-
folder: 'routes',
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
// Component configuration
|
|
169
|
-
components: {
|
|
170
|
-
dirs: ['components'],
|
|
171
|
-
prefix: '${toPascalCase(layerName)}',
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
// Composable configuration
|
|
175
|
-
composables: {
|
|
176
|
-
dirs: ['composables'],
|
|
177
|
-
},
|
|
178
|
-
})
|
|
179
|
-
`;
|
|
180
|
-
fs.writeFileSync(join(layerPath, "kimesh.config.ts"), configContent);
|
|
181
|
-
consola.log(` ${pc.green("+")} kimesh.config.ts`);
|
|
182
|
-
const indexRouteContent = `<script setup lang="ts">
|
|
183
|
-
// ${layerName} layer index route
|
|
184
|
-
<\/script>
|
|
185
|
-
|
|
186
|
-
<template>
|
|
187
|
-
<div class="${layerName}-index">
|
|
188
|
-
<h1>${toPascalCase(layerName)} Layer</h1>
|
|
189
|
-
<p>Welcome to the ${layerName} layer.</p>
|
|
190
|
-
</div>
|
|
191
|
-
</template>
|
|
192
|
-
`;
|
|
193
|
-
fs.writeFileSync(join(layerPath, "routes", "index.vue"), indexRouteContent);
|
|
194
|
-
consola.log(` ${pc.green("+")} routes/index.vue`);
|
|
195
|
-
const layoutContent = `<script setup lang="ts">
|
|
196
|
-
// ${layerName} layer layout
|
|
197
|
-
<\/script>
|
|
198
|
-
|
|
199
|
-
<template>
|
|
200
|
-
<div class="${layerName}-layout">
|
|
201
|
-
<slot />
|
|
202
|
-
</div>
|
|
203
|
-
</template>
|
|
204
|
-
`;
|
|
205
|
-
fs.writeFileSync(join(layerPath, "routes", "_layout.vue"), layoutContent);
|
|
206
|
-
consola.log(` ${pc.green("+")} routes/_layout.vue`);
|
|
207
|
-
consola.success(`\nLayer created at: ${pc.cyan(layerPath)}`);
|
|
208
|
-
consola.info(`\nNext steps:`);
|
|
209
|
-
consola.log(` 1. Add to your config: extends: ['./${join("layers", layerName)}']`);
|
|
210
|
-
consola.log(` 2. Start dev server: ${pc.cyan("km dev")}`);
|
|
211
|
-
consola.log(` 3. Visit: ${pc.cyan(`http://localhost:3000${basePath}`)}`);
|
|
212
|
-
}
|
|
213
|
-
}),
|
|
214
|
-
validate: defineCommand({
|
|
215
|
-
meta: {
|
|
216
|
-
name: "validate",
|
|
217
|
-
description: "Validate layer configurations"
|
|
218
|
-
},
|
|
219
|
-
args: { root: {
|
|
220
|
-
type: "string",
|
|
221
|
-
alias: "r",
|
|
222
|
-
description: "Project root directory"
|
|
223
|
-
} },
|
|
224
|
-
async run({ args }) {
|
|
225
|
-
const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
|
|
226
|
-
consola.info("Validating layers...\n");
|
|
227
|
-
const layersDir = join(root, "layers");
|
|
228
|
-
let errors = 0;
|
|
229
|
-
let warnings = 0;
|
|
230
|
-
if (!fs.existsSync(layersDir)) {
|
|
231
|
-
consola.info("No layers/ directory found");
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const layers = fs.readdirSync(layersDir, { withFileTypes: true }).filter((e) => e.isDirectory());
|
|
235
|
-
for (const layer of layers) {
|
|
236
|
-
const layerPath = join(layersDir, layer.name);
|
|
237
|
-
consola.log(`${pc.bold(layer.name)}:`);
|
|
238
|
-
const hasRoutes = fs.existsSync(join(layerPath, "routes"));
|
|
239
|
-
const hasComponents = fs.existsSync(join(layerPath, "components"));
|
|
240
|
-
const hasComposables = fs.existsSync(join(layerPath, "composables"));
|
|
241
|
-
const hasConfig = fs.existsSync(join(layerPath, "kimesh.config.ts"));
|
|
242
|
-
if (!hasRoutes && !hasComponents && !hasComposables) {
|
|
243
|
-
consola.log(` ${pc.yellow("⚠")} No routes/, components/, or composables/ directory`);
|
|
244
|
-
warnings++;
|
|
245
|
-
} else consola.log(` ${pc.green("✓")} Valid layer structure`);
|
|
246
|
-
if (!hasConfig) consola.log(` ${pc.dim("○")} No kimesh.config.ts (using defaults)`);
|
|
247
|
-
else consola.log(` ${pc.green("✓")} Has kimesh.config.ts`);
|
|
248
|
-
consola.log("");
|
|
249
|
-
}
|
|
250
|
-
if (errors > 0) {
|
|
251
|
-
consola.error(`\n${errors} error(s) found`);
|
|
252
|
-
process.exit(1);
|
|
253
|
-
} else if (warnings > 0) consola.warn(`\n${warnings} warning(s)`);
|
|
254
|
-
else consola.success("\nAll layers valid!");
|
|
255
|
-
}
|
|
256
|
-
})
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
/**
|
|
260
|
-
* Convert string to PascalCase
|
|
261
|
-
*/
|
|
262
|
-
function toPascalCase(str) {
|
|
263
|
-
return str.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join("");
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
//#endregion
|
|
267
|
-
export { layer_default as default };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import pc from "picocolors";
|
|
5
|
-
|
|
6
|
-
//#region src/commands/prepare.ts
|
|
7
|
-
var prepare_default = defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "prepare",
|
|
10
|
-
description: "Generate .kimesh directory for TypeScript support"
|
|
11
|
-
},
|
|
12
|
-
args: {
|
|
13
|
-
root: {
|
|
14
|
-
type: "string",
|
|
15
|
-
alias: "r",
|
|
16
|
-
description: "Project root directory"
|
|
17
|
-
},
|
|
18
|
-
config: {
|
|
19
|
-
type: "string",
|
|
20
|
-
alias: "c",
|
|
21
|
-
description: "Config file path"
|
|
22
|
-
},
|
|
23
|
-
verbose: {
|
|
24
|
-
type: "boolean",
|
|
25
|
-
alias: "v",
|
|
26
|
-
description: "Enable verbose logging",
|
|
27
|
-
default: false
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
async run({ args }) {
|
|
31
|
-
const root = resolve(args.root || process.cwd());
|
|
32
|
-
const startTime = Date.now();
|
|
33
|
-
consola.info(`Preparing ${pc.cyan(root)}...`);
|
|
34
|
-
const { prepare } = await import("@kimesh/kit");
|
|
35
|
-
try {
|
|
36
|
-
const result = await prepare({
|
|
37
|
-
root,
|
|
38
|
-
configFile: args.config,
|
|
39
|
-
verbose: args.verbose
|
|
40
|
-
});
|
|
41
|
-
const duration = Date.now() - startTime;
|
|
42
|
-
consola.success(`Prepared in ${pc.cyan(`${duration}ms`)}`);
|
|
43
|
-
consola.info(` ${pc.gray("Build directory:")} ${pc.cyan(result.buildDir)}`);
|
|
44
|
-
consola.info(` ${pc.gray("Layers:")} ${pc.cyan(result.layerCount.toString())}`);
|
|
45
|
-
consola.info(` ${pc.gray("Aliases:")} ${pc.cyan(result.aliasCount.toString())}`);
|
|
46
|
-
consola.info(` ${pc.gray("Generated files:")} ${pc.cyan(result.generatedFiles.join(", "))}`);
|
|
47
|
-
consola.log("");
|
|
48
|
-
consola.info(`${pc.green("✓")} TypeScript is now ready! Your IDE should recognize path aliases.`);
|
|
49
|
-
consola.log("");
|
|
50
|
-
consola.info(`${pc.gray("Tip:")} Make sure your ${pc.cyan("tsconfig.json")} extends ${pc.cyan(".kimesh/tsconfig.json")}`);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
consola.error("Failed to prepare project:", error);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { prepare_default as default };
|