@couch-kit/cli 0.3.5 → 0.3.6
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/README.md +48 -2
- package/dist/index.js +12 -11
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ bun add -d @couch-kit/cli
|
|
|
14
14
|
|
|
15
15
|
### `init`
|
|
16
16
|
|
|
17
|
-
Scaffolds a
|
|
17
|
+
Scaffolds a web controller project (Vite + React + TypeScript) to add to an existing host app. This creates only the phone/tablet side — for a full game project (host + client + shared), clone the [Buzz starter](https://github.com/faluciano/buzz-tv-party-game).
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
bunx couch-kit init web-controller
|
|
@@ -22,7 +22,7 @@ bunx couch-kit init web-controller
|
|
|
22
22
|
|
|
23
23
|
### `bundle`
|
|
24
24
|
|
|
25
|
-
Builds the web controller and copies the assets into your Android project's `assets/www` folder. This is used
|
|
25
|
+
Builds the web controller and copies the assets into your Android project's `assets/www` folder, along with a `manifest.json` listing all files. This manifest is used by `useExtractAssets()` on the host to extract assets at runtime.
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
28
|
# Default (looks for ./web-controller and copies to android/app/src/main/assets/www)
|
|
@@ -32,6 +32,16 @@ bunx couch-kit bundle
|
|
|
32
32
|
bunx couch-kit bundle --source ./my-web-app --output ./android/app/src/main/assets/www
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
Output structure:
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
android/app/src/main/assets/www/
|
|
39
|
+
├── manifest.json ← import this in your host app
|
|
40
|
+
├── index.html
|
|
41
|
+
├── assets/
|
|
42
|
+
│ └── ...
|
|
43
|
+
```
|
|
44
|
+
|
|
35
45
|
### `simulate`
|
|
36
46
|
|
|
37
47
|
Spawns headless WebSocket bots to simulate players (useful for load testing and quick iteration).
|
|
@@ -46,3 +56,39 @@ bunx couch-kit simulate --url ws://192.168.1.99:8082 --count 8
|
|
|
46
56
|
# Action interval (ms)
|
|
47
57
|
bunx couch-kit simulate --interval 250
|
|
48
58
|
```
|
|
59
|
+
|
|
60
|
+
### `replay`
|
|
61
|
+
|
|
62
|
+
Replays a recorded game session against a reducer, validating state transitions. Useful for debugging, regression testing, and reproducing bugs from recordings captured with `useActionRecorder`.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Replay a recording against your reducer
|
|
66
|
+
bunx couch-kit replay ./session.json ./shared/reducer.ts
|
|
67
|
+
|
|
68
|
+
# With intermediate state snapshots
|
|
69
|
+
bunx couch-kit replay ./session.json ./shared/reducer.ts --snapshots
|
|
70
|
+
|
|
71
|
+
# JSON output (for piping to other tools)
|
|
72
|
+
bunx couch-kit replay ./session.json ./shared/reducer.ts --json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The reducer module must export a `default` or a named `reducer` function. If your shared file exports `gameReducer`, add a re-export:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// shared/reducer.ts (or any entry point for replay)
|
|
79
|
+
export { gameReducer as default } from "./types";
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### `dev`
|
|
83
|
+
|
|
84
|
+
Starts a Vite dev server on the LAN so phones can load the controller from your laptop during development.
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Default: port 5173, exposed to LAN
|
|
88
|
+
bunx couch-kit dev
|
|
89
|
+
|
|
90
|
+
# Custom port
|
|
91
|
+
bunx couch-kit dev --port 3000
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Prints the LAN URL (e.g., `http://192.168.1.50:5173`) so you can pass it as `devServerUrl` to `GameHostProvider`. Requires `vite` as a dev dependency in your web controller project.
|
package/dist/index.js
CHANGED
|
@@ -2160,16 +2160,16 @@ var init_init = __esm(() => {
|
|
|
2160
2160
|
preview: "vite preview"
|
|
2161
2161
|
},
|
|
2162
2162
|
dependencies: {
|
|
2163
|
-
react: "^
|
|
2164
|
-
"react-dom": "^
|
|
2165
|
-
"@couch-kit/client": "^0.
|
|
2163
|
+
react: "^19.0.0",
|
|
2164
|
+
"react-dom": "^19.0.0",
|
|
2165
|
+
"@couch-kit/client": "^0.8.0"
|
|
2166
2166
|
},
|
|
2167
2167
|
devDependencies: {
|
|
2168
|
-
"@types/react": "^
|
|
2169
|
-
"@types/react-dom": "^
|
|
2170
|
-
"@vitejs/plugin-react": "^
|
|
2171
|
-
typescript: "^5.
|
|
2172
|
-
vite: "^
|
|
2168
|
+
"@types/react": "^19.0.0",
|
|
2169
|
+
"@types/react-dom": "^19.0.0",
|
|
2170
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
2171
|
+
typescript: "^5.7.0",
|
|
2172
|
+
vite: "^6.0.0"
|
|
2173
2173
|
}
|
|
2174
2174
|
};
|
|
2175
2175
|
fs2.writeFileSync(path2.join(targetDir, "package.json"), JSON.stringify(packageJson, null, 2) + `
|
|
@@ -2248,11 +2248,12 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
|
2248
2248
|
`);
|
|
2249
2249
|
fs2.writeFileSync(path2.join(targetDir, "src/App.tsx"), `
|
|
2250
2250
|
import { useGameClient } from '@couch-kit/client';
|
|
2251
|
+
import { gameReducer, initialState } from './reducer';
|
|
2251
2252
|
|
|
2252
2253
|
function App() {
|
|
2253
2254
|
const { status, playerId, sendAction } = useGameClient({
|
|
2254
|
-
initialState
|
|
2255
|
-
reducer:
|
|
2255
|
+
initialState,
|
|
2256
|
+
reducer: gameReducer,
|
|
2256
2257
|
});
|
|
2257
2258
|
|
|
2258
2259
|
return (
|
|
@@ -2260,7 +2261,7 @@ function App() {
|
|
|
2260
2261
|
<h1>Controller</h1>
|
|
2261
2262
|
<p>Status: {status}</p>
|
|
2262
2263
|
<p>ID: {playerId || 'Connecting...'}</p>
|
|
2263
|
-
<button onClick={() => sendAction({ type: '
|
|
2264
|
+
<button onClick={() => sendAction({ type: 'SCORE' })}
|
|
2264
2265
|
style={{ fontSize: 24, padding: '20px 40px', width: '100%' }}>
|
|
2265
2266
|
BUZZ!
|
|
2266
2267
|
</button>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@couch-kit/cli",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -43,6 +43,6 @@
|
|
|
43
43
|
"commander": "^12.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"typescript": "^
|
|
46
|
+
"typescript": "^6.0.0"
|
|
47
47
|
}
|
|
48
48
|
}
|