@wu-framework/cli 0.1.0
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/LICENSE +21 -0
- package/README.md +162 -0
- package/bin/wu-darwin-arm64 +0 -0
- package/bin/wu-darwin-x64 +0 -0
- package/bin/wu-linux-x64 +0 -0
- package/bin/wu-win32-x64.exe +0 -0
- package/bin/wu.js +61 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Wu Framework
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# wu-cli
|
|
2
|
+
|
|
3
|
+
**One binary. One port. All your micro-apps.**
|
|
4
|
+
|
|
5
|
+
Native Zig dev server and CLI toolkit for wu-framework microfrontend applications. Replaces N Vite dev servers with a single process -- one binary that discovers, compiles, and serves every micro-app through a unified HTTP server.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Native HTTP dev server with SIMD-accelerated request parsing (16 bytes/cycle)
|
|
12
|
+
- Three-tier compilation: Native Zig JSX (0-2ms) -> Compiler Daemon (10-50ms) -> Node fallback (200-400ms)
|
|
13
|
+
- Two-level cache: in-memory (256 entries, mutex-protected) + persistent disk (`.wu-cache/`), 73-138x speedup on warm restart
|
|
14
|
+
- NPM module resolution in pure Zig (package.json `exports`, `module`, `main` fields with conditions)
|
|
15
|
+
- TypeScript stripping and bare-specifier import rewriting (`react` -> `/@modules/react`)
|
|
16
|
+
- CSS-as-module imports (`import './style.css'` injects into DOM at runtime)
|
|
17
|
+
- WebSocket (RFC 6455) + SSE-based HMR with 300ms file-watcher polling
|
|
18
|
+
- HTTP keep-alive for connection reuse across requests
|
|
19
|
+
- Interactive project scaffolding (`wu create`)
|
|
20
|
+
- Auto-discovery of micro-apps from directory structure (no config required)
|
|
21
|
+
- Framework support: React, Preact, Vue, Svelte, Solid, Lit, Angular, Vanilla JS
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g @wu-framework/cli
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then use it anywhere:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
wu create my-project
|
|
33
|
+
cd my-project
|
|
34
|
+
wu dev
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Build from source
|
|
38
|
+
|
|
39
|
+
If you prefer to build from source (requires [Zig 0.15.2+](https://ziglang.org/download/)):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/LuisPadre25/wu-cli.git
|
|
43
|
+
cd wu-cli
|
|
44
|
+
zig build
|
|
45
|
+
./zig-out/bin/wu create my-project
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Commands
|
|
49
|
+
|
|
50
|
+
| Command | Description |
|
|
51
|
+
|---------|-------------|
|
|
52
|
+
| `wu dev` | Start native dev server (default) or Vite processes (`--vite`) |
|
|
53
|
+
| `wu build` | Build all micro-apps in parallel |
|
|
54
|
+
| `wu create` | Interactive project scaffolding (name, frameworks, install) |
|
|
55
|
+
| `wu add <framework> <name>` | Add a new micro-app to an existing project |
|
|
56
|
+
| `wu info` | Show project configuration and status |
|
|
57
|
+
| `wu serve` | Production server (coming soon) |
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
wu-cli reads a `wu.config.json` file at the project root. Example:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"shell": {
|
|
66
|
+
"dir": "shell",
|
|
67
|
+
"port": 4321,
|
|
68
|
+
"framework": "astro"
|
|
69
|
+
},
|
|
70
|
+
"apps": [
|
|
71
|
+
{
|
|
72
|
+
"name": "dashboard",
|
|
73
|
+
"dir": "mf-hero",
|
|
74
|
+
"framework": "svelte",
|
|
75
|
+
"port": 5002
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "orders",
|
|
79
|
+
"dir": "mf-eventlab",
|
|
80
|
+
"framework": "react",
|
|
81
|
+
"port": 5005
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Alternatively, wu-cli auto-discovers micro-apps by scanning subdirectories for the presence of both `vite.config.js` and `package.json`. No configuration file is required for basic usage.
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
src/
|
|
93
|
+
commands/ CLI command handlers (dev, build, create, add, info, serve)
|
|
94
|
+
runtime/ Dev server core
|
|
95
|
+
config/ Configuration loading and validation
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Runtime modules
|
|
99
|
+
|
|
100
|
+
| Module | Purpose |
|
|
101
|
+
|--------|---------|
|
|
102
|
+
| **dev_server.zig** | Thread-per-connection HTTP server with keep-alive and static file serving |
|
|
103
|
+
| **http_parser.zig** | SIMD HTTP/1.1 request parser (16 bytes/cycle vectorized header scanning) |
|
|
104
|
+
| **resolve.zig** | NPM module resolution in pure Zig (zero Node.js dependency) |
|
|
105
|
+
| **transform.zig** | TypeScript erasure + bare-specifier import rewriting (line-preserving) |
|
|
106
|
+
| **jsx_transform.zig** | Native JSX to createElement transformation (React/Preact, ~0-2ms) |
|
|
107
|
+
| **compile.zig** | Three-tier framework compilation with persistent daemon process |
|
|
108
|
+
| **cache.zig** | Two-level mtime-based cache (in-memory 256 entries + disk `.wu-cache/`) |
|
|
109
|
+
| **ws_protocol.zig** | WebSocket RFC 6455 implementation (frame parsing, masking, handshake) |
|
|
110
|
+
| **mime.zig** | MIME type detection by file extension |
|
|
111
|
+
|
|
112
|
+
## Compilation Pipeline
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
.jsx/.tsx (React/Preact) ----> Native Zig JSX ----> JS (~0-2ms)
|
|
116
|
+
.jsx/.tsx (Solid) ----> Compiler Daemon ----> JS (~10-50ms)
|
|
117
|
+
.svelte ----> Compiler Daemon ----> JS (~10-50ms)
|
|
118
|
+
.vue ----> Compiler Daemon ----> JS (~10-50ms)
|
|
119
|
+
.ts ----> TS Strip ----> JS (~0-1ms)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The three tiers are tried in order. Native Zig handles React and Preact JSX with zero external processes. The Compiler Daemon keeps a long-running Node.js process for frameworks that require their own compilers (Svelte, Vue, Solid). If the daemon is unavailable, a one-shot `node -e` fallback is used.
|
|
123
|
+
|
|
124
|
+
Cache hits bypass all tiers entirely: the mtime of the source file is compared against the cached entry, and the cached output is served directly (~3ms).
|
|
125
|
+
|
|
126
|
+
## Supported Frameworks
|
|
127
|
+
|
|
128
|
+
| Framework | Extensions | Compile Tier | Native JSX |
|
|
129
|
+
|-----------|-----------|-------------|------------|
|
|
130
|
+
| React | .jsx, .tsx | Native Zig | Yes |
|
|
131
|
+
| Preact | .jsx, .tsx | Native Zig | Yes |
|
|
132
|
+
| Vue | .vue | Daemon / Node | -- |
|
|
133
|
+
| Svelte | .svelte | Daemon / Node | -- |
|
|
134
|
+
| Solid.js | .jsx, .tsx | Daemon / Node | -- |
|
|
135
|
+
| Lit | .ts, .js | TS strip only | -- |
|
|
136
|
+
| Vanilla | .js, .ts | TS strip only | -- |
|
|
137
|
+
| Angular | .ts | TS strip only | -- |
|
|
138
|
+
|
|
139
|
+
## Requirements
|
|
140
|
+
|
|
141
|
+
- **Node.js 16+** -- for installing via npm (`npm install -g @wu-framework/cli`)
|
|
142
|
+
- **Node.js 18+** -- needed at runtime for Svelte, Vue, and Solid compilation (React/Preact use native Zig JSX)
|
|
143
|
+
- **Zig 0.15.2+** -- only needed if building from source
|
|
144
|
+
|
|
145
|
+
## Project Stats
|
|
146
|
+
|
|
147
|
+
- 22 Zig source files, ~2800 lines of runtime code
|
|
148
|
+
- ~250-460KB release binary per platform (Windows, Linux, macOS x64/arm64), zero external Zig dependencies
|
|
149
|
+
- Single-process architecture replaces 8+ simultaneous Vite dev servers
|
|
150
|
+
- Part of the wu-framework microfrontend platform
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
|
155
|
+
|
|
156
|
+
## Author
|
|
157
|
+
|
|
158
|
+
Luis Garcia -- Creator of wu-framework
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development workflow and guidelines.
|
|
Binary file
|
|
Binary file
|
package/bin/wu-linux-x64
ADDED
|
Binary file
|
|
Binary file
|
package/bin/wu.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { spawnSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
const PLATFORM_MAP = {
|
|
9
|
+
'win32-x64': 'wu-win32-x64.exe',
|
|
10
|
+
'linux-x64': 'wu-linux-x64',
|
|
11
|
+
'darwin-x64': 'wu-darwin-x64',
|
|
12
|
+
'darwin-arm64': 'wu-darwin-arm64',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const platform = os.platform();
|
|
16
|
+
const arch = os.arch();
|
|
17
|
+
const key = `${platform}-${arch}`;
|
|
18
|
+
const binaryName = PLATFORM_MAP[key];
|
|
19
|
+
|
|
20
|
+
if (!binaryName) {
|
|
21
|
+
console.error(`wu-cli: unsupported platform ${platform}-${arch}`);
|
|
22
|
+
console.error(`Supported: ${Object.keys(PLATFORM_MAP).join(', ')}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const binaryPath = path.join(__dirname, binaryName);
|
|
27
|
+
|
|
28
|
+
if (!fs.existsSync(binaryPath)) {
|
|
29
|
+
console.error(`wu-cli: binary not found at ${binaryPath}`);
|
|
30
|
+
console.error('This may mean the package was not built for your platform.');
|
|
31
|
+
console.error('Try reinstalling: npm install -g wu-cli');
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const args = process.argv.slice(2);
|
|
36
|
+
|
|
37
|
+
let result = spawnSync(binaryPath, args, {
|
|
38
|
+
stdio: 'inherit',
|
|
39
|
+
env: process.env,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Handle EACCES — try chmod +x and retry (Linux/macOS)
|
|
43
|
+
if (result.error && result.error.code === 'EACCES') {
|
|
44
|
+
try {
|
|
45
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
46
|
+
result = spawnSync(binaryPath, args, {
|
|
47
|
+
stdio: 'inherit',
|
|
48
|
+
env: process.env,
|
|
49
|
+
});
|
|
50
|
+
} catch (chmodErr) {
|
|
51
|
+
console.error(`wu-cli: permission denied and could not chmod: ${chmodErr.message}`);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (result.error) {
|
|
57
|
+
console.error(`wu-cli: failed to execute binary: ${result.error.message}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
process.exit(result.status ?? 1);
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wu-framework/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lightning-fast micro-frontend CLI — scaffold, develop, and build multi-framework apps",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"wu": "bin/wu.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin/",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepublishOnly": "bash scripts/build-all.sh"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"micro-frontend",
|
|
19
|
+
"microfrontend",
|
|
20
|
+
"cli",
|
|
21
|
+
"scaffold",
|
|
22
|
+
"dev-server",
|
|
23
|
+
"react",
|
|
24
|
+
"vue",
|
|
25
|
+
"svelte",
|
|
26
|
+
"solid",
|
|
27
|
+
"preact",
|
|
28
|
+
"lit",
|
|
29
|
+
"angular",
|
|
30
|
+
"astro"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/LuisPadre25/wu-cli"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=16"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
42
|
+
}
|