@kimesh/cli 0.1.0-nightly.20260120033244 → 0.1.0-nightly.20260120082346

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.
@@ -0,0 +1,258 @@
1
+ import { loadKit } from "./kit-BcEYldTS.js";
2
+ import { sharedArgs } from "./_shared-CEwpPT2B.js";
3
+ import { defineCommand } from "citty";
4
+ import consola from "consola";
5
+ import pc from "picocolors";
6
+ import { join, resolve } from "node:path";
7
+ import * as fs from "node:fs";
8
+
9
+ //#region src/commands/layer.ts
10
+ var layer_default = defineCommand({
11
+ meta: {
12
+ name: "layer",
13
+ description: "Manage Kimesh layers"
14
+ },
15
+ subCommands: {
16
+ list: defineCommand({
17
+ meta: {
18
+ name: "list",
19
+ description: "List available layers"
20
+ },
21
+ args: sharedArgs,
22
+ async run({ args }) {
23
+ const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
24
+ const kit = await loadKit(root);
25
+ const { loadConfig } = kit;
26
+ const kmConfig = await loadConfig({ root });
27
+ consola.info(`${pc.cyan("Available layers:")}\n`);
28
+ const extendsLayers = kmConfig.extends || [];
29
+ if (extendsLayers.length > 0) {
30
+ consola.log(pc.bold("From config (extends):"));
31
+ for (const layer of extendsLayers) {
32
+ const name = typeof layer === "string" ? layer : layer.name;
33
+ consola.log(` ${pc.green("✓")} ${name}`);
34
+ }
35
+ consola.log("");
36
+ }
37
+ const layersDir = join(root, "layers");
38
+ if (fs.existsSync(layersDir)) {
39
+ const entries = fs.readdirSync(layersDir, { withFileTypes: true });
40
+ const layers = entries.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
+ ...sharedArgs
73
+ },
74
+ async run({ args }) {
75
+ const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
76
+ const layerName = args.name;
77
+ const layerPath = join(root, "layers", layerName);
78
+ if (!fs.existsSync(layerPath)) {
79
+ consola.error(`Layer not found: ${layerName}`);
80
+ consola.info(`Checked: ${layerPath}`);
81
+ process.exit(1);
82
+ }
83
+ consola.log(`\n${pc.cyan(pc.bold(`Layer: ${layerName}`))}\n`);
84
+ consola.log(`${pc.bold("Path:")} ${layerPath}`);
85
+ const structure = [];
86
+ const checkDir = (dir, label) => {
87
+ const fullPath = join(layerPath, dir);
88
+ if (fs.existsSync(fullPath)) {
89
+ const files = fs.readdirSync(fullPath);
90
+ structure.push(`${label}: ${files.length} files`);
91
+ }
92
+ };
93
+ checkDir("routes", "Routes");
94
+ checkDir("components", "Components");
95
+ checkDir("composables", "Composables");
96
+ checkDir("utils", "Utilities");
97
+ checkDir("stores", "Stores");
98
+ if (structure.length > 0) {
99
+ consola.log(`\n${pc.bold("Structure:")}`);
100
+ for (const item of structure) consola.log(` ${pc.green("•")} ${item}`);
101
+ }
102
+ const configPath = join(layerPath, "kimesh.config.ts");
103
+ if (fs.existsSync(configPath)) consola.log(`\n${pc.bold("Config:")} ${pc.green("Found")}`);
104
+ }
105
+ }),
106
+ create: defineCommand({
107
+ meta: {
108
+ name: "create",
109
+ description: "Create a new layer scaffold"
110
+ },
111
+ args: {
112
+ name: {
113
+ type: "positional",
114
+ description: "Layer name",
115
+ required: true
116
+ },
117
+ basePath: {
118
+ type: "string",
119
+ alias: "b",
120
+ description: "Base path for routes (e.g., /cms)"
121
+ },
122
+ ...sharedArgs
123
+ },
124
+ async run({ args }) {
125
+ const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
126
+ const layerName = args.name;
127
+ const basePath = args.basePath || `/${layerName}`;
128
+ const layersDir = join(root, "layers");
129
+ const layerPath = join(layersDir, layerName);
130
+ if (fs.existsSync(layerPath)) {
131
+ consola.error(`Layer already exists: ${layerPath}`);
132
+ process.exit(1);
133
+ }
134
+ consola.info(`Creating layer: ${pc.cyan(layerName)}`);
135
+ const dirs = [
136
+ "",
137
+ "routes",
138
+ "components",
139
+ "composables",
140
+ "utils",
141
+ "stores"
142
+ ];
143
+ for (const dir of dirs) {
144
+ const dirPath = join(layerPath, dir);
145
+ fs.mkdirSync(dirPath, { recursive: true });
146
+ consola.log(` ${pc.green("+")} ${dir || layerName}/`);
147
+ }
148
+ const configContent = `import { defineKmConfig } from '@kimesh/kit'
149
+
150
+ export default defineKmConfig({
151
+ name: '${layerName}',
152
+
153
+ // Base path for all routes in this layer
154
+ basePath: '${basePath}',
155
+
156
+ // Routes configuration
157
+ routes: {
158
+ basePath: '${basePath}',
159
+ folder: 'routes',
160
+ },
161
+
162
+ // Component configuration
163
+ components: {
164
+ dirs: ['components'],
165
+ prefix: '${toPascalCase(layerName)}',
166
+ },
167
+
168
+ // Composable configuration
169
+ composables: {
170
+ dirs: ['composables'],
171
+ },
172
+ })
173
+ `;
174
+ fs.writeFileSync(join(layerPath, "kimesh.config.ts"), configContent);
175
+ consola.log(` ${pc.green("+")} kimesh.config.ts`);
176
+ const indexRouteContent = `<script setup lang="ts">
177
+ // ${layerName} layer index route
178
+ </script>
179
+
180
+ <template>
181
+ <div class="${layerName}-index">
182
+ <h1>${toPascalCase(layerName)} Layer</h1>
183
+ <p>Welcome to the ${layerName} layer.</p>
184
+ </div>
185
+ </template>
186
+ `;
187
+ fs.writeFileSync(join(layerPath, "routes", "index.vue"), indexRouteContent);
188
+ consola.log(` ${pc.green("+")} routes/index.vue`);
189
+ const layoutContent = `<script setup lang="ts">
190
+ // ${layerName} layer layout
191
+ </script>
192
+
193
+ <template>
194
+ <div class="${layerName}-layout">
195
+ <slot />
196
+ </div>
197
+ </template>
198
+ `;
199
+ fs.writeFileSync(join(layerPath, "routes", "_layout.vue"), layoutContent);
200
+ consola.log(` ${pc.green("+")} routes/_layout.vue`);
201
+ consola.success(`\nLayer created at: ${pc.cyan(layerPath)}`);
202
+ consola.info(`\nNext steps:`);
203
+ consola.log(` 1. Add to your config: extends: ['./${join("layers", layerName)}']`);
204
+ consola.log(` 2. Start dev server: ${pc.cyan("kmi dev")}`);
205
+ consola.log(` 3. Visit: ${pc.cyan(`http://localhost:3000${basePath}`)}`);
206
+ }
207
+ }),
208
+ validate: defineCommand({
209
+ meta: {
210
+ name: "validate",
211
+ description: "Validate layer configurations"
212
+ },
213
+ args: sharedArgs,
214
+ async run({ args }) {
215
+ const root = resolve(typeof args.root === "string" ? args.root : process.cwd());
216
+ consola.info("Validating layers...\n");
217
+ const layersDir = join(root, "layers");
218
+ let errors = 0;
219
+ let warnings = 0;
220
+ if (!fs.existsSync(layersDir)) {
221
+ consola.info("No layers/ directory found");
222
+ return;
223
+ }
224
+ const entries = fs.readdirSync(layersDir, { withFileTypes: true });
225
+ const layers = entries.filter((e) => e.isDirectory());
226
+ for (const layer of layers) {
227
+ const layerPath = join(layersDir, layer.name);
228
+ consola.log(`${pc.bold(layer.name)}:`);
229
+ const hasRoutes = fs.existsSync(join(layerPath, "routes"));
230
+ const hasComponents = fs.existsSync(join(layerPath, "components"));
231
+ const hasComposables = fs.existsSync(join(layerPath, "composables"));
232
+ const hasConfig = fs.existsSync(join(layerPath, "kimesh.config.ts"));
233
+ if (!hasRoutes && !hasComponents && !hasComposables) {
234
+ consola.log(` ${pc.yellow("⚠")} No routes/, components/, or composables/ directory`);
235
+ warnings++;
236
+ } else consola.log(` ${pc.green("✓")} Valid layer structure`);
237
+ if (!hasConfig) consola.log(` ${pc.dim("○")} No kimesh.config.ts (using defaults)`);
238
+ else consola.log(` ${pc.green("✓")} Has kimesh.config.ts`);
239
+ consola.log("");
240
+ }
241
+ if (errors > 0) {
242
+ consola.error(`\n${errors} error(s) found`);
243
+ process.exit(1);
244
+ } else if (warnings > 0) consola.warn(`\n${warnings} warning(s)`);
245
+ else consola.success("\nAll layers valid!");
246
+ }
247
+ })
248
+ }
249
+ });
250
+ /**
251
+ * Convert string to PascalCase
252
+ */
253
+ function toPascalCase(str) {
254
+ return str.split(/[-_]/).map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()).join("");
255
+ }
256
+
257
+ //#endregion
258
+ export { layer_default as default };
@@ -0,0 +1,10 @@
1
+ import * as citty0 from "citty";
2
+
3
+ //#region src/main.d.ts
4
+ declare const version = "0.1.0";
5
+ /**
6
+ * Main CLI command definition
7
+ */
8
+ declare const main: citty0.CommandDef<citty0.ArgsDef>;
9
+ //#endregion
10
+ export { main as main$1, version as version$1 };
@@ -0,0 +1,47 @@
1
+ import { defineCommand } from "citty";
2
+ import consola from "consola";
3
+ import pc from "picocolors";
4
+
5
+ //#region src/commands/index.ts
6
+ /**
7
+ * Command registry with lazy loading
8
+ * Commands are only imported when actually used
9
+ */
10
+ const commands = {
11
+ dev: () => import("./dev-o5sR0-kW.js").then((m) => m.default),
12
+ build: () => import("./build-Ce4Dm8mI.js").then((m) => m.default),
13
+ generate: () => import("./generate-Dx64ract.js").then((m) => m.default),
14
+ prepare: () => import("./prepare-DScUWnaY.js").then((m) => m.default),
15
+ layer: () => import("./layer-D829AuwM.js").then((m) => m.default),
16
+ init: () => import("./commands/init.js").then((m) => m.default),
17
+ start: () => import("./dev-o5sR0-kW.js").then((m) => m.default)
18
+ };
19
+
20
+ //#endregion
21
+ //#region src/main.ts
22
+ const version = "0.1.0";
23
+ /**
24
+ * Main CLI command definition
25
+ */
26
+ const main = defineCommand({
27
+ meta: {
28
+ name: "kmi",
29
+ version,
30
+ description: "Kimesh Framework CLI"
31
+ },
32
+ subCommands: {
33
+ dev: commands.dev,
34
+ build: commands.build,
35
+ generate: commands.generate,
36
+ prepare: commands.prepare,
37
+ layer: commands.layer,
38
+ init: commands.init,
39
+ start: commands.start
40
+ },
41
+ setup() {
42
+ consola.log(pc.cyan(`\n 🚀 Kimesh Framework v${version}\n`));
43
+ }
44
+ });
45
+
46
+ //#endregion
47
+ export { commands, main, version };
package/dist/main.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { main, version } from "../../km/src/index";
1
+ import { main$1 as main, version$1 as version } from "./main-CCPXvZyj.js";
2
2
  export { main, version };
package/dist/main.js CHANGED
@@ -1,3 +1,3 @@
1
- import { main, version } from "../../km/src/index";
1
+ import { main, version } from "./main-DncTPs_e.js";
2
2
 
3
3
  export { main, version };
@@ -0,0 +1,45 @@
1
+ import { loadKit } from "./kit-BcEYldTS.js";
2
+ import { prepareArgs } from "./_shared-CEwpPT2B.js";
3
+ import { defineCommand } from "citty";
4
+ import consola from "consola";
5
+ import pc from "picocolors";
6
+ import { resolve } from "node:path";
7
+
8
+ //#region src/commands/prepare.ts
9
+ var prepare_default = defineCommand({
10
+ meta: {
11
+ name: "prepare",
12
+ description: "Generate .kimesh directory for TypeScript support"
13
+ },
14
+ args: prepareArgs,
15
+ async run({ args }) {
16
+ const root = resolve(args.root || process.cwd());
17
+ const startTime = Date.now();
18
+ consola.info(`Preparing ${pc.cyan(root)}...`);
19
+ const kit = await loadKit(root);
20
+ const { prepare } = kit;
21
+ try {
22
+ const result = await prepare({
23
+ root,
24
+ configFile: args.config,
25
+ verbose: args.verbose
26
+ });
27
+ const duration = Date.now() - startTime;
28
+ consola.success(`Prepared in ${pc.cyan(`${duration}ms`)}`);
29
+ consola.info(` ${pc.gray("Build directory:")} ${pc.cyan(result.buildDir)}`);
30
+ consola.info(` ${pc.gray("Layers:")} ${pc.cyan(result.layerCount.toString())}`);
31
+ consola.info(` ${pc.gray("Aliases:")} ${pc.cyan(result.aliasCount.toString())}`);
32
+ consola.info(` ${pc.gray("Generated files:")} ${pc.cyan(result.generatedFiles.join(", "))}`);
33
+ consola.log("");
34
+ consola.info(`${pc.green("✓")} TypeScript is now ready! Your IDE should recognize path aliases.`);
35
+ consola.log("");
36
+ consola.info(`${pc.gray("Tip:")} Make sure your ${pc.cyan("tsconfig.json")} extends ${pc.cyan(".kimesh/tsconfig.json")}`);
37
+ } catch (error) {
38
+ consola.error("Failed to prepare project:", error);
39
+ process.exit(1);
40
+ }
41
+ }
42
+ });
43
+
44
+ //#endregion
45
+ export { prepare_default as default };
@@ -0,0 +1,15 @@
1
+ import { main } from "./main-DncTPs_e.js";
2
+ import { runMain } from "citty";
3
+
4
+ //#region src/run.ts
5
+ /**
6
+ * Run the CLI
7
+ * This is the entry point when the CLI is invoked directly
8
+ */
9
+ function run() {
10
+ runMain(main);
11
+ }
12
+ run();
13
+
14
+ //#endregion
15
+ export { run };
@@ -0,0 +1,8 @@
1
+ //#region src/run.d.ts
2
+ /**
3
+ * Run the CLI
4
+ * This is the entry point when the CLI is invoked directly
5
+ */
6
+ declare function run(): void;
7
+ //#endregion
8
+ export { run as run$1 };
package/dist/run.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { run } from "../../km/src/index";
1
+ import { run$1 as run } from "./run-DiuH8yNF.js";
2
2
  export { run };
package/dist/run.js CHANGED
@@ -1,7 +1,4 @@
1
- import { run } from "../../km/src/index";
1
+ import "./main-DncTPs_e.js";
2
+ import { run } from "./run-DCL2u7IK.js";
2
3
 
3
- //#region src/run.ts
4
- run();
5
-
6
- //#endregion
7
4
  export { run };
package/package.json CHANGED
@@ -1,20 +1,28 @@
1
1
  {
2
2
  "name": "@kimesh/cli",
3
- "version": "0.1.0-nightly.20260120033244",
4
- "description": "Kimesh CLI for integration with main package",
3
+ "version": "0.1.0-nightly.20260120082346",
4
+ "description": "Kimesh Framework CLI",
5
5
  "type": "module",
6
+ "bin": {
7
+ "km": "./bin/km.mjs",
8
+ "kimesh": "./bin/km.mjs"
9
+ },
6
10
  "exports": {
7
11
  ".": {
8
- "types": "./dist/index.d.mts",
9
- "import": "./dist/index.mjs"
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
10
14
  },
11
- "./cli": "./bin/km.mjs"
12
- },
13
- "main": "./dist/index.mjs",
14
- "types": "./dist/index.d.mts",
15
- "bin": {
16
- "km": "bin/km.mjs"
15
+ "./cli": {
16
+ "types": "./dist/run.d.ts",
17
+ "import": "./dist/run.js"
18
+ },
19
+ "./commands/init": {
20
+ "types": "./dist/commands/init.d.ts",
21
+ "import": "./dist/commands/init.js"
22
+ }
17
23
  },
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
18
26
  "files": [
19
27
  "dist",
20
28
  "bin"
@@ -25,10 +33,23 @@
25
33
  "typecheck": "tsc --noEmit"
26
34
  },
27
35
  "dependencies": {
28
- "@kimesh/km": "0.1.0-nightly.20260120033244"
36
+ "@kimesh/kit": "0.1.0-nightly.20260120082346",
37
+ "citty": "^0.1.6",
38
+ "consola": "^3.4.2",
39
+ "exsolve": "^1.0.8",
40
+ "picocolors": "^1.1.1"
29
41
  },
30
42
  "devDependencies": {
43
+ "@types/node": "^22.13.1",
31
44
  "tsdown": "^0.11.7",
32
45
  "typescript": "^5.8.2"
46
+ },
47
+ "peerDependencies": {
48
+ "vite": "^6.0.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "vite": {
52
+ "optional": true
53
+ }
33
54
  }
34
55
  }