@kimesh/cli 0.1.0-nightly.20260120063147 → 0.1.1-nightly.20260120033751
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/km.mjs +0 -0
- package/dist/index.d.ts +1 -361
- package/dist/index.js +1 -80
- package/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.js +5 -2
- package/package.json +11 -32
- package/dist/_shared-CEwpPT2B.js +0 -84
- package/dist/build-Ce4Dm8mI.js +0 -34
- package/dist/commands/init.d.ts +0 -24
- package/dist/commands/init.js +0 -198
- package/dist/dev-o5sR0-kW.js +0 -75
- package/dist/generate-Dx64ract.js +0 -21
- package/dist/kit-BcEYldTS.js +0 -39
- package/dist/layer-D829AuwM.js +0 -258
- package/dist/main-CCPXvZyj.d.ts +0 -10
- package/dist/main-DncTPs_e.js +0 -47
- package/dist/prepare-DScUWnaY.js +0 -45
- package/dist/run-DCL2u7IK.js +0 -15
- package/dist/run-DiuH8yNF.d.ts +0 -8
package/dist/commands/init.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { defineCommand } from "citty";
|
|
2
|
-
import consola from "consola";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
import { join, resolve } from "node:path";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
|
|
7
|
-
//#region src/commands/init.ts
|
|
8
|
-
var init_default = defineCommand({
|
|
9
|
-
meta: {
|
|
10
|
-
name: "init",
|
|
11
|
-
description: "Initialize a new Kimesh project in the current directory"
|
|
12
|
-
},
|
|
13
|
-
args: {
|
|
14
|
-
root: {
|
|
15
|
-
type: "string",
|
|
16
|
-
alias: "r",
|
|
17
|
-
description: "Project root directory"
|
|
18
|
-
},
|
|
19
|
-
force: {
|
|
20
|
-
type: "boolean",
|
|
21
|
-
alias: "f",
|
|
22
|
-
description: "Overwrite existing files",
|
|
23
|
-
default: false
|
|
24
|
-
},
|
|
25
|
-
typescript: {
|
|
26
|
-
type: "boolean",
|
|
27
|
-
alias: "ts",
|
|
28
|
-
description: "Initialize with TypeScript",
|
|
29
|
-
default: true
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
async run({ args }) {
|
|
33
|
-
const root = resolve(args.root || process.cwd());
|
|
34
|
-
consola.info(`Initializing Kimesh project in ${pc.cyan(root)}...`);
|
|
35
|
-
if (!fs.existsSync(root)) {
|
|
36
|
-
fs.mkdirSync(root, { recursive: true });
|
|
37
|
-
consola.log(` ${pc.green("+")} Created directory: ${root}`);
|
|
38
|
-
}
|
|
39
|
-
const configPath = join(root, "kimesh.config.ts");
|
|
40
|
-
if (fs.existsSync(configPath) && !args.force) {
|
|
41
|
-
consola.warn(`${pc.yellow("kimesh.config.ts already exists.")} Use ${pc.cyan("--force")} to overwrite.`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const dirs = [
|
|
45
|
-
"routes",
|
|
46
|
-
"components",
|
|
47
|
-
"composables",
|
|
48
|
-
"utils",
|
|
49
|
-
"public"
|
|
50
|
-
];
|
|
51
|
-
for (const dir of dirs) {
|
|
52
|
-
const dirPath = join(root, dir);
|
|
53
|
-
if (!fs.existsSync(dirPath)) {
|
|
54
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
55
|
-
consola.log(` ${pc.green("+")} ${dir}/`);
|
|
56
|
-
} else consola.log(` ${pc.dim("○")} ${dir}/ (exists)`);
|
|
57
|
-
}
|
|
58
|
-
const configContent = `import { defineKmConfig } from '@kimesh/kit'
|
|
59
|
-
|
|
60
|
-
export default defineKmConfig({
|
|
61
|
-
// Application name
|
|
62
|
-
name: '${getProjectName(root)}',
|
|
63
|
-
|
|
64
|
-
// Development server options
|
|
65
|
-
dev: {
|
|
66
|
-
port: 3000,
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Components configuration
|
|
70
|
-
components: {
|
|
71
|
-
dirs: ['components'],
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// Composables configuration
|
|
75
|
-
composables: {
|
|
76
|
-
dirs: ['composables'],
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
`;
|
|
80
|
-
fs.writeFileSync(configPath, configContent);
|
|
81
|
-
consola.log(` ${pc.green("+")} kimesh.config.ts`);
|
|
82
|
-
const appVuePath = join(root, "app.vue");
|
|
83
|
-
if (!fs.existsSync(appVuePath) || args.force) {
|
|
84
|
-
const appVueContent = `<script setup lang="ts">
|
|
85
|
-
// Your app setup goes here
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<template>
|
|
89
|
-
<router-view />
|
|
90
|
-
</template>
|
|
91
|
-
|
|
92
|
-
<style>
|
|
93
|
-
:root {
|
|
94
|
-
--color-primary: #3b82f6;
|
|
95
|
-
--color-secondary: #6366f1;
|
|
96
|
-
}
|
|
97
|
-
</style>
|
|
98
|
-
`;
|
|
99
|
-
fs.writeFileSync(appVuePath, appVueContent);
|
|
100
|
-
consola.log(` ${pc.green("+")} app.vue`);
|
|
101
|
-
}
|
|
102
|
-
const indexRoutePath = join(root, "routes", "index.vue");
|
|
103
|
-
if (!fs.existsSync(indexRoutePath) || args.force) {
|
|
104
|
-
const indexRouteContent = `<script setup lang="ts">
|
|
105
|
-
// Home page
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<template>
|
|
109
|
-
<div class="home">
|
|
110
|
-
<h1>Welcome to Kimesh</h1>
|
|
111
|
-
<p>Your Vue.js application is ready!</p>
|
|
112
|
-
<p>Edit <code>routes/index.vue</code> to get started.</p>
|
|
113
|
-
</div>
|
|
114
|
-
</template>
|
|
115
|
-
|
|
116
|
-
<style scoped>
|
|
117
|
-
.home {
|
|
118
|
-
max-width: 800px;
|
|
119
|
-
margin: 0 auto;
|
|
120
|
-
padding: 2rem;
|
|
121
|
-
text-align: center;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
h1 {
|
|
125
|
-
color: var(--color-primary);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
code {
|
|
129
|
-
background: #f0f0f0;
|
|
130
|
-
padding: 0.25rem 0.5rem;
|
|
131
|
-
border-radius: 4px;
|
|
132
|
-
}
|
|
133
|
-
</style>
|
|
134
|
-
`;
|
|
135
|
-
fs.writeFileSync(indexRoutePath, indexRouteContent);
|
|
136
|
-
consola.log(` ${pc.green("+")} routes/index.vue`);
|
|
137
|
-
}
|
|
138
|
-
if (args.typescript) {
|
|
139
|
-
const tsconfigPath = join(root, "tsconfig.json");
|
|
140
|
-
if (!fs.existsSync(tsconfigPath) || args.force) {
|
|
141
|
-
const tsconfigContent = `{
|
|
142
|
-
"extends": "./.kimesh/tsconfig.json",
|
|
143
|
-
"compilerOptions": {
|
|
144
|
-
"strict": true
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
`;
|
|
148
|
-
fs.writeFileSync(tsconfigPath, tsconfigContent);
|
|
149
|
-
consola.log(` ${pc.green("+")} tsconfig.json`);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const gitignorePath = join(root, ".gitignore");
|
|
153
|
-
if (!fs.existsSync(gitignorePath) || args.force) {
|
|
154
|
-
const gitignoreContent = `# Dependencies
|
|
155
|
-
node_modules/
|
|
156
|
-
|
|
157
|
-
# Build output
|
|
158
|
-
dist/
|
|
159
|
-
.kimesh/
|
|
160
|
-
|
|
161
|
-
# Environment
|
|
162
|
-
.env
|
|
163
|
-
.env.local
|
|
164
|
-
.env.*.local
|
|
165
|
-
|
|
166
|
-
# Logs
|
|
167
|
-
*.log
|
|
168
|
-
|
|
169
|
-
# Editor
|
|
170
|
-
.vscode/
|
|
171
|
-
.idea/
|
|
172
|
-
|
|
173
|
-
# OS
|
|
174
|
-
.DS_Store
|
|
175
|
-
Thumbs.db
|
|
176
|
-
`;
|
|
177
|
-
fs.writeFileSync(gitignorePath, gitignoreContent);
|
|
178
|
-
consola.log(` ${pc.green("+")} .gitignore`);
|
|
179
|
-
}
|
|
180
|
-
consola.log("");
|
|
181
|
-
consola.success(`Kimesh project initialized!`);
|
|
182
|
-
consola.log("");
|
|
183
|
-
consola.info("Next steps:");
|
|
184
|
-
consola.log(` 1. Install dependencies: ${pc.cyan("bun install")}`);
|
|
185
|
-
consola.log(` 2. Prepare TypeScript: ${pc.cyan("kmi prepare")}`);
|
|
186
|
-
consola.log(` 3. Start dev server: ${pc.cyan("kmi dev")}`);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
/**
|
|
190
|
-
* Get project name from directory path
|
|
191
|
-
*/
|
|
192
|
-
function getProjectName(root) {
|
|
193
|
-
const basename = root.split(/[/\\]/).pop() || "my-app";
|
|
194
|
-
return basename.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
//#endregion
|
|
198
|
-
export { init_default as default };
|
package/dist/dev-o5sR0-kW.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { loadKit } from "./kit-BcEYldTS.js";
|
|
2
|
-
import { devArgs } 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/dev.ts
|
|
9
|
-
var dev_default = defineCommand({
|
|
10
|
-
meta: {
|
|
11
|
-
name: "dev",
|
|
12
|
-
description: "Start development server"
|
|
13
|
-
},
|
|
14
|
-
args: devArgs,
|
|
15
|
-
async run({ args }) {
|
|
16
|
-
const root = resolve(args.root || process.cwd());
|
|
17
|
-
const kit = await loadKit(root);
|
|
18
|
-
const { loadConfig, kimeshPlugin } = kit;
|
|
19
|
-
const kmConfig = await loadConfig({
|
|
20
|
-
root,
|
|
21
|
-
configFile: args.config
|
|
22
|
-
});
|
|
23
|
-
const enabledLayers = parseLayersArg(args.layers);
|
|
24
|
-
const excludedLayers = args["exclude-layers"] ? args["exclude-layers"].split(",").map((l) => l.trim()) : [];
|
|
25
|
-
consola.info(`Starting ${pc.cyan(kmConfig.name || "Kimesh")} dev server...`);
|
|
26
|
-
if (enabledLayers === "all") consola.info(`Layers: ${pc.green("all")}`);
|
|
27
|
-
else if (enabledLayers === "none") consola.info(`Layers: ${pc.yellow("none (host only)")}`);
|
|
28
|
-
else if (Array.isArray(enabledLayers)) consola.info(`Layers: ${pc.cyan(enabledLayers.join(", "))}`);
|
|
29
|
-
if (excludedLayers.length > 0) consola.info(`Excluded: ${pc.yellow(excludedLayers.join(", "))}`);
|
|
30
|
-
const { createServer } = await import("vite");
|
|
31
|
-
const port = args.port ? parseInt(args.port, 10) : kmConfig.dev?.port ?? 3e3;
|
|
32
|
-
const host = args.host ?? kmConfig.dev?.host ?? "localhost";
|
|
33
|
-
const open = args.open ?? kmConfig.dev?.open ?? false;
|
|
34
|
-
const server = await createServer({
|
|
35
|
-
root,
|
|
36
|
-
configFile: false,
|
|
37
|
-
plugins: [kimeshPlugin({
|
|
38
|
-
config: kmConfig,
|
|
39
|
-
layers: {
|
|
40
|
-
enabled: enabledLayers,
|
|
41
|
-
excluded: excludedLayers
|
|
42
|
-
}
|
|
43
|
-
})],
|
|
44
|
-
server: {
|
|
45
|
-
port,
|
|
46
|
-
host,
|
|
47
|
-
open
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
await server.listen();
|
|
51
|
-
server.printUrls();
|
|
52
|
-
consola.success(`Dev server started!`);
|
|
53
|
-
const cleanup = async () => {
|
|
54
|
-
consola.info("Shutting down...");
|
|
55
|
-
await server.close();
|
|
56
|
-
process.exit(0);
|
|
57
|
-
};
|
|
58
|
-
process.on("SIGINT", cleanup);
|
|
59
|
-
process.on("SIGTERM", cleanup);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
/**
|
|
63
|
-
* Parse the --layers argument
|
|
64
|
-
*/
|
|
65
|
-
function parseLayersArg(arg) {
|
|
66
|
-
const envLayers = process.env.KM_LAYERS;
|
|
67
|
-
const layersArg = arg ?? envLayers;
|
|
68
|
-
if (!layersArg) return "all";
|
|
69
|
-
if (layersArg === "all") return "all";
|
|
70
|
-
if (layersArg === "none") return "none";
|
|
71
|
-
return layersArg.split(",").map((l) => l.trim()).filter(Boolean);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
//#endregion
|
|
75
|
-
export { dev_default as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { sharedArgs } from "./_shared-CEwpPT2B.js";
|
|
2
|
-
import { defineCommand } from "citty";
|
|
3
|
-
import consola from "consola";
|
|
4
|
-
import pc from "picocolors";
|
|
5
|
-
|
|
6
|
-
//#region src/commands/generate.ts
|
|
7
|
-
var generate_default = defineCommand({
|
|
8
|
-
meta: {
|
|
9
|
-
name: "generate",
|
|
10
|
-
description: "Generate routes and types"
|
|
11
|
-
},
|
|
12
|
-
args: sharedArgs,
|
|
13
|
-
async run({ args: _args }) {
|
|
14
|
-
consola.info(`Generating routes and types...`);
|
|
15
|
-
consola.warn(pc.yellow("Route generation will be available in Phase 2"));
|
|
16
|
-
consola.success(`Generation complete!`);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { generate_default as default };
|
package/dist/kit-BcEYldTS.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import consola from "consola";
|
|
2
|
-
import { pathToFileURL } from "node:url";
|
|
3
|
-
import { resolveModulePath } from "exsolve";
|
|
4
|
-
|
|
5
|
-
//#region src/utils/kit.ts
|
|
6
|
-
let _kit;
|
|
7
|
-
/**
|
|
8
|
-
* Dynamically load @kimesh/kit from the project context
|
|
9
|
-
* Falls back to bundled version if not found
|
|
10
|
-
*/
|
|
11
|
-
async function loadKit(root = process.cwd()) {
|
|
12
|
-
if (_kit) return _kit;
|
|
13
|
-
try {
|
|
14
|
-
const kitPath = resolveModulePath("@kimesh/kit", { from: root });
|
|
15
|
-
const kitUrl = pathToFileURL(kitPath).href;
|
|
16
|
-
_kit = await import(kitUrl);
|
|
17
|
-
consola.debug(`Loaded @kimesh/kit from: ${kitPath}`);
|
|
18
|
-
} catch {
|
|
19
|
-
consola.debug("Using bundled @kimesh/kit");
|
|
20
|
-
_kit = await import("@kimesh/kit");
|
|
21
|
-
}
|
|
22
|
-
return _kit;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get cached kit instance or throw if not loaded
|
|
26
|
-
*/
|
|
27
|
-
function getKit() {
|
|
28
|
-
if (!_kit) throw new Error("@kimesh/kit not loaded. Call loadKit() first.");
|
|
29
|
-
return _kit;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Clear kit cache (useful for testing)
|
|
33
|
-
*/
|
|
34
|
-
function clearKitCache() {
|
|
35
|
-
_kit = void 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
export { clearKitCache, getKit, loadKit };
|
package/dist/layer-D829AuwM.js
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
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 };
|
package/dist/main-CCPXvZyj.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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 };
|
package/dist/main-DncTPs_e.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
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/prepare-DScUWnaY.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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 };
|