Skip to content

Commit dac70f9

Browse files
flow
1 parent b487e43 commit dac70f9

File tree

28 files changed

+927
-863
lines changed

28 files changed

+927
-863
lines changed

packages/cli/README.md

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ walkeros bundle https://example.com/config.json # Remote URL
4343

4444
**Options:**
4545

46-
- `-e, --env <name>` - Build specific environment (multi-env configs)
47-
- `--all` - Build all environments
46+
- `-f, --flow <name>` - Build specific flow (multi-flow configs)
47+
- `--all` - Build all flows
4848
- `-s, --stats` - Show bundle statistics
4949
- `--json` - Output stats as JSON
5050
- `--no-cache` - Disable package caching
@@ -58,7 +58,8 @@ walkeros bundle https://example.com/config.json # Remote URL
5858
walkeros bundle examples/server-collect.json --stats
5959
```
6060

61-
The output path is specified in the config's `build.output` field.
61+
The output path uses convention-based defaults: `./dist/bundle.mjs` for server,
62+
`./dist/walker.js` for web.
6263

6364
### simulate
6465

@@ -165,59 +166,43 @@ walkeros bundle flow.json --no-cache
165166

166167
## Flow Configuration
167168

168-
Minimal example:
169+
Flow configs use the `Flow.Setup` format with `version` and `flows`:
169170

170171
```json
171172
{
172-
"flow": {
173-
"platform": "server",
174-
"sources": {
175-
"http": {
176-
"code": "sourceExpress",
177-
"config": {
178-
"settings": {
179-
"path": "/collect",
180-
"port": 8080
173+
"version": 1,
174+
"flows": {
175+
"default": {
176+
"server": {},
177+
"packages": {
178+
"@walkeros/collector": { "imports": ["startFlow"] },
179+
"@walkeros/server-source-express": { "imports": ["sourceExpress"] },
180+
"@walkeros/destination-demo": { "imports": ["destinationDemo"] }
181+
},
182+
"sources": {
183+
"http": {
184+
"code": "sourceExpress",
185+
"config": {
186+
"settings": { "path": "/collect", "port": 8080 }
181187
}
182188
}
183-
}
184-
},
185-
"destinations": {
186-
"demo": {
187-
"code": "destinationDemo",
188-
"config": {
189-
"settings": {
190-
"name": "Demo"
189+
},
190+
"destinations": {
191+
"demo": {
192+
"code": "destinationDemo",
193+
"config": {
194+
"settings": { "name": "Demo" }
191195
}
192196
}
193-
}
194-
},
195-
"collector": {
196-
"run": true
197-
}
198-
},
199-
"build": {
200-
"packages": {
201-
"@walkeros/collector": {
202-
"version": "latest",
203-
"imports": ["startFlow"]
204197
},
205-
"@walkeros/server-source-express": {
206-
"version": "latest",
207-
"imports": ["sourceExpress"]
208-
},
209-
"@walkeros/destination-demo": {
210-
"version": "latest",
211-
"imports": ["destinationDemo"]
212-
}
213-
},
214-
"code": "// Custom code here\n",
215-
"output": "bundle.mjs",
216-
"template": "./templates/base.hbs"
198+
"collector": { "run": true }
199+
}
217200
}
218201
}
219202
```
220203

204+
Platform is determined by the `web: {}` or `server: {}` key presence.
205+
221206
See [examples/](./examples/) for complete working configurations.
222207

223208
## Programmatic API

packages/cli/examples/README.md

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -229,44 +229,57 @@ Browser → destinationAPI (POST /collect) → sourceExpress → destinationData
229229

230230
### Flow Configuration Structure
231231

232+
Flow configs use the `Flow.Setup` format:
233+
232234
```json
233235
{
234-
"flow": {
235-
"platform": "web" | "server",
236-
"sources": {
237-
"<source_name>": {
238-
"code": "<imported_function_name>",
239-
"config": { "settings": { /* source config */ } }
240-
}
241-
},
242-
"destinations": {
243-
"<destination_name>": {
244-
"code": "<imported_function_name>",
245-
"config": {
246-
"settings": { /* destination config */ },
247-
"mapping": { /* event mappings */ }
236+
"version": 1,
237+
"flows": {
238+
"default": {
239+
"web": {},
240+
"packages": {
241+
"<package_name>": { "imports": ["<function_name>"] }
242+
},
243+
"sources": {
244+
"<source_name>": {
245+
"code": "<imported_function_name>",
246+
"config": {
247+
"settings": {
248+
/* source config */
249+
}
250+
}
251+
}
252+
},
253+
"destinations": {
254+
"<destination_name>": {
255+
"code": "<imported_function_name>",
256+
"config": {
257+
"settings": {
258+
/* destination config */
259+
},
260+
"mapping": {
261+
/* event mappings */
262+
}
263+
}
264+
}
265+
},
266+
"collector": {
267+
"run": true,
268+
"globals": {
269+
/* global properties */
248270
}
249271
}
250-
},
251-
"collector": {
252-
"run": true,
253-
"globals": { /* global properties */ }
254272
}
255-
},
256-
"build": {
257-
"packages": {
258-
"<package_name>": {
259-
"version": "latest",
260-
"imports": ["<function_name>"]
261-
}
262-
},
263-
"code": "// Optional custom code\n",
264-
"template": "templates/base.hbs",
265-
"output": "./dist/bundle.js"
266273
}
267274
}
268275
```
269276

277+
**Key points:**
278+
279+
- Platform via `web: {}` or `server: {}` key (not `platform: "web"`)
280+
- Output path is convention-based: `./dist/walker.js` (web) or
281+
`./dist/bundle.mjs` (server)
282+
270283
### Available Sources
271284

272285
**Web**:

packages/cli/examples/flow-order-complete.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"environments": {
3+
"flows": {
44
"default": {
55
"web": {},
66
"packages": {

packages/cli/examples/flow-simple.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"environments": {
3+
"flows": {
44
"default": {
55
"web": {},
66
"packages": {

packages/cli/examples/flow.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"environments": {
3+
"flows": {
44
"default": {
55
"web": {},
66
"packages": {

packages/cli/examples/server-collect.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"environments": {
3+
"flows": {
44
"default": {
55
"server": {},
66
"packages": {

packages/cli/examples/web-serve.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": 1,
3-
"environments": {
3+
"flows": {
44
"default": {
55
"web": {
66
"windowCollector": "collector",

packages/cli/src/__tests__/bundle/bundler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function createFlowSetup(
1717
): Flow.Setup {
1818
return {
1919
version: 1,
20-
environments: {
20+
flows: {
2121
default: {
2222
...(platform === 'web' ? { web: {} } : { server: {} }),
2323
packages,

packages/cli/src/__tests__/bundle/programmatic.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('Programmatic Bundle API', () => {
3838
it('should bundle with Flow.Setup config object', async () => {
3939
const config: Flow.Setup = {
4040
version: 1,
41-
environments: {
41+
flows: {
4242
default: {
4343
web: {},
4444
packages: {
@@ -66,7 +66,7 @@ describe('Programmatic Bundle API', () => {
6666
it('should return stats when requested', async () => {
6767
const config: Flow.Setup = {
6868
version: 1,
69-
environments: {
69+
flows: {
7070
default: {
7171
web: {},
7272
packages: {
@@ -87,7 +87,7 @@ describe('Programmatic Bundle API', () => {
8787
it('should return undefined when stats not requested', async () => {
8888
const config: Flow.Setup = {
8989
version: 1,
90-
environments: {
90+
flows: {
9191
default: {
9292
web: {},
9393
packages: {
@@ -105,7 +105,7 @@ describe('Programmatic Bundle API', () => {
105105
it('should handle cache option', async () => {
106106
const config: Flow.Setup = {
107107
version: 1,
108-
environments: {
108+
flows: {
109109
default: {
110110
web: {},
111111
packages: {
@@ -123,7 +123,7 @@ describe('Programmatic Bundle API', () => {
123123
it('should handle verbose option', async () => {
124124
const config: Flow.Setup = {
125125
version: 1,
126-
environments: {
126+
flows: {
127127
default: {
128128
web: {},
129129
packages: {
@@ -146,10 +146,10 @@ describe('Programmatic Bundle API', () => {
146146
);
147147
});
148148

149-
it('should select environment from multi-env config', async () => {
149+
it('should select flow from multi-flow config', async () => {
150150
const config: Flow.Setup = {
151151
version: 1,
152-
environments: {
152+
flows: {
153153
production: {
154154
web: {},
155155
packages: {
@@ -166,7 +166,7 @@ describe('Programmatic Bundle API', () => {
166166
};
167167

168168
await expect(
169-
bundle(config, { silent: true, environment: 'production' }),
169+
bundle(config, { silent: true, flowName: 'production' }),
170170
).resolves.not.toThrow();
171171
});
172172

packages/cli/src/__tests__/cli.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('CLI Bundle Command', () => {
5151
// Flow.Setup format
5252
const testConfig = {
5353
version: 1,
54-
environments: {
54+
flows: {
5555
default: {
5656
web: {},
5757
packages: {
@@ -71,9 +71,9 @@ describe('CLI Bundle Command', () => {
7171
expect(output).toMatchObject({
7272
success: true,
7373
data: {
74-
environments: expect.arrayContaining([
74+
flows: expect.arrayContaining([
7575
{
76-
environment: 'default',
76+
flowName: 'default',
7777
success: true,
7878
stats: {
7979
totalSize: expect.any(Number),
@@ -92,8 +92,8 @@ describe('CLI Bundle Command', () => {
9292
duration: expect.any(Number),
9393
});
9494

95-
expect(output.data.environments[0].stats.packages).toHaveLength(1);
96-
expect(output.data.environments[0].stats.packages[0].name).toBe(
95+
expect(output.data.flows[0].stats.packages).toHaveLength(1);
96+
expect(output.data.flows[0].stats.packages[0].name).toBe(
9797
'@walkeros/core@latest',
9898
);
9999
});
@@ -102,7 +102,7 @@ describe('CLI Bundle Command', () => {
102102
// Flow.Setup format - but bundler will fail on invalid destination code
103103
const testConfig = {
104104
version: 1,
105-
environments: {
105+
flows: {
106106
default: {
107107
web: {},
108108
packages: {
@@ -142,7 +142,7 @@ describe('CLI Bundle Command', () => {
142142
// Flow.Setup format
143143
const testConfig = {
144144
version: 1,
145-
environments: {
145+
flows: {
146146
default: {
147147
web: {},
148148
packages: {
@@ -160,14 +160,14 @@ describe('CLI Bundle Command', () => {
160160

161161
const output = JSON.parse(result.stdout);
162162
expect(output.success).toBe(true);
163-
expect(output.data.environments[0].stats.treeshakingEffective).toBe(true);
163+
expect(output.data.flows[0].stats.treeshakingEffective).toBe(true);
164164
});
165165

166166
it('should suppress decorative output in JSON mode', async () => {
167167
// Flow.Setup format
168168
const testConfig = {
169169
version: 1,
170-
environments: {
170+
flows: {
171171
default: {
172172
web: {},
173173
packages: {

0 commit comments

Comments
 (0)