@kimesh/cli 0.1.1 → 0.2.0-nightly.20260120083917

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 CHANGED
File without changes
@@ -0,0 +1,84 @@
1
+ //#region src/commands/_shared.ts
2
+ /**
3
+ * Shared arguments used across multiple commands
4
+ */
5
+ const sharedArgs = {
6
+ root: {
7
+ type: "string",
8
+ alias: "r",
9
+ description: "Project root directory"
10
+ },
11
+ config: {
12
+ type: "string",
13
+ alias: "c",
14
+ description: "Config file path"
15
+ },
16
+ logLevel: {
17
+ type: "string",
18
+ description: "Log level (silent, info, verbose)"
19
+ }
20
+ };
21
+ /**
22
+ * Dev command specific arguments
23
+ */
24
+ const devArgs = {
25
+ ...sharedArgs,
26
+ port: {
27
+ type: "string",
28
+ alias: "p",
29
+ description: "Server port",
30
+ default: "3000"
31
+ },
32
+ host: {
33
+ type: "string",
34
+ alias: "h",
35
+ description: "Server host"
36
+ },
37
+ open: {
38
+ type: "boolean",
39
+ alias: "o",
40
+ description: "Open browser on start",
41
+ default: false
42
+ },
43
+ layers: {
44
+ type: "string",
45
+ alias: "l",
46
+ description: "Comma-separated list of layers or all/none"
47
+ },
48
+ "exclude-layers": {
49
+ type: "string",
50
+ alias: "x",
51
+ description: "Comma-separated list of layers to exclude"
52
+ }
53
+ };
54
+ /**
55
+ * Build command specific arguments
56
+ */
57
+ const buildArgs = {
58
+ ...sharedArgs,
59
+ minify: {
60
+ type: "boolean",
61
+ description: "Minify output",
62
+ default: true
63
+ },
64
+ sourcemap: {
65
+ type: "boolean",
66
+ description: "Generate sourcemaps",
67
+ default: false
68
+ }
69
+ };
70
+ /**
71
+ * Prepare command specific arguments
72
+ */
73
+ const prepareArgs = {
74
+ ...sharedArgs,
75
+ verbose: {
76
+ type: "boolean",
77
+ alias: "v",
78
+ description: "Enable verbose logging",
79
+ default: false
80
+ }
81
+ };
82
+
83
+ //#endregion
84
+ export { buildArgs, devArgs, prepareArgs, sharedArgs };
@@ -0,0 +1,34 @@
1
+ import { loadKit } from "./kit-BcEYldTS.js";
2
+ import { buildArgs } from "./_shared-CEwpPT2B.js";
3
+ import { defineCommand } from "citty";
4
+ import consola from "consola";
5
+ import { resolve } from "node:path";
6
+
7
+ //#region src/commands/build.ts
8
+ var build_default = defineCommand({
9
+ meta: {
10
+ name: "build",
11
+ description: "Build for production"
12
+ },
13
+ args: buildArgs,
14
+ async run({ args }) {
15
+ const root = resolve(args.root || process.cwd());
16
+ consola.info(`Building for production...`);
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 { build } = await import("vite");
24
+ await build({
25
+ root,
26
+ configFile: false,
27
+ plugins: [kimeshPlugin({ config: kmConfig })]
28
+ });
29
+ consola.success(`Build complete!`);
30
+ }
31
+ });
32
+
33
+ //#endregion
34
+ export { build_default as default };
@@ -0,0 +1,24 @@
1
+ import * as citty1 from "citty";
2
+
3
+ //#region src/commands/init.d.ts
4
+ declare const _default: citty1.CommandDef<{
5
+ root: {
6
+ type: "string";
7
+ alias: string;
8
+ description: string;
9
+ };
10
+ force: {
11
+ type: "boolean";
12
+ alias: string;
13
+ description: string;
14
+ default: false;
15
+ };
16
+ typescript: {
17
+ type: "boolean";
18
+ alias: string;
19
+ description: string;
20
+ default: true;
21
+ };
22
+ }>;
23
+ //#endregion
24
+ export { _default as default };
@@ -0,0 +1,198 @@
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 };
@@ -0,0 +1,75 @@
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 };
@@ -0,0 +1,21 @@
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 };