what-framework-cli 0.5.3 → 0.5.4

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.
Files changed (3) hide show
  1. package/README.md +102 -0
  2. package/package.json +2 -2
  3. package/src/cli.js +31 -1
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # what-framework-cli
2
+
3
+ CLI for [What Framework](https://whatfw.com). Provides a zero-config dev server with HMR, production builds with content hashing and gzip, preview server, and static site generation.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install what-framework-cli --save-dev
9
+ ```
10
+
11
+ Or use directly:
12
+
13
+ ```bash
14
+ npx what-framework-cli dev
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ### `what dev`
20
+
21
+ Start a development server with hot module reloading via WebSocket.
22
+
23
+ ```bash
24
+ what dev
25
+ what dev --port 8080
26
+ what dev --host 0.0.0.0
27
+ ```
28
+
29
+ Features:
30
+ - WebSocket-based HMR with automatic reconnection
31
+ - Bare import transforms (`what` -> framework modules)
32
+ - File-based routing from `src/pages/`
33
+ - SPA fallback for client-side routing
34
+ - Server action endpoint
35
+
36
+ ### `what build`
37
+
38
+ Create a production build with minification, content hashing, and gzip compression.
39
+
40
+ ```bash
41
+ what build
42
+ ```
43
+
44
+ Output:
45
+ - Minified JS and HTML
46
+ - Content-hashed filenames for cache busting
47
+ - Gzipped copies of all JS files
48
+ - `manifest.json` mapping original filenames to hashed versions
49
+ - Bundled framework runtime
50
+
51
+ ### `what preview`
52
+
53
+ Preview a production build locally.
54
+
55
+ ```bash
56
+ what preview
57
+ what preview --port 4000
58
+ ```
59
+
60
+ ### `what generate`
61
+
62
+ Static site generation. Runs a build, then pre-renders all pages.
63
+
64
+ ```bash
65
+ what generate
66
+ ```
67
+
68
+ ### `what init`
69
+
70
+ Create a new project (prefer `npx create-what` for the full scaffolding experience).
71
+
72
+ ```bash
73
+ what init my-app
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ Create a `what.config.js` in your project root:
79
+
80
+ ```js
81
+ export default {
82
+ mode: 'hybrid', // 'static' | 'server' | 'client' | 'hybrid'
83
+ pagesDir: 'src/pages', // Pages directory for file-based routing
84
+ outDir: 'dist', // Build output directory
85
+ };
86
+ ```
87
+
88
+ ## Options
89
+
90
+ | Flag | Description | Default |
91
+ |---|---|---|
92
+ | `--port` | Server port | `3000` (dev), `4000` (preview) |
93
+ | `--host` | Server host | `localhost` |
94
+
95
+ ## Links
96
+
97
+ - [Documentation](https://whatfw.com)
98
+ - [GitHub](https://github.com/zvndev/what-fw)
99
+
100
+ ## License
101
+
102
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "what-framework-cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "What Framework CLI - Dev server, build, and deployment tools",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,5 +31,5 @@
31
31
  "bugs": {
32
32
  "url": "https://github.com/zvndev/what-fw/issues"
33
33
  },
34
- "homepage": "https://whatframework.dev"
34
+ "homepage": "https://whatfw.com"
35
35
  }
package/src/cli.js CHANGED
@@ -278,12 +278,42 @@ async function dev() {
278
278
  // WebSocket server for HMR (zero dependencies)
279
279
  const wsClients = new Set();
280
280
 
281
+ // Auto-start MCP bridge if what-devtools-mcp is installed
282
+ let mcpProcess = null;
283
+ const noMcp = args.includes('--no-mcp');
284
+ if (!noMcp) {
285
+ try {
286
+ const { resolve: importResolve } = await import('node:module');
287
+ // Check if the package exists by trying to resolve it
288
+ const mcpBin = join(cwd, 'node_modules', '.bin', 'what-devtools-mcp');
289
+ const { existsSync: mcpExists } = await import('node:fs');
290
+ if (mcpExists(mcpBin)) {
291
+ const { spawn } = await import('node:child_process');
292
+ const mcpPort = getFlag('--mcp-port', 9229);
293
+ mcpProcess = spawn('node', [mcpBin], {
294
+ env: { ...process.env, WHAT_MCP_PORT: String(mcpPort) },
295
+ stdio: 'pipe',
296
+ });
297
+ mcpProcess.on('error', () => {}); // Silently ignore spawn errors
298
+ mcpProcess.on('exit', () => { mcpProcess = null; });
299
+ // Clean up on exit
300
+ process.on('exit', () => mcpProcess?.kill());
301
+ process.on('SIGINT', () => { mcpProcess?.kill(); process.exit(0); });
302
+ }
303
+ } catch {}
304
+ }
305
+
281
306
  server.listen(port, host, () => {
282
307
  console.log(`\n what dev server\n`);
283
308
  console.log(` Local: http://${host}:${port}`);
284
309
  console.log(` Mode: ${config.mode || 'hybrid'}`);
285
310
  console.log(` Pages: ${config.pagesDir || 'src/pages'}`);
286
- console.log(` HMR: WebSocket (instant reload)\n`);
311
+ console.log(` HMR: WebSocket (instant reload)`);
312
+ if (mcpProcess) {
313
+ const mcpPort = getFlag('--mcp-port', 9229);
314
+ console.log(` MCP: ws://localhost:${mcpPort} (AI debugging enabled)`);
315
+ }
316
+ console.log();
287
317
  });
288
318
 
289
319
  // Initialize WebSocket server