@walkeros/cli 0.4.2 → 0.5.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/CHANGELOG.md +13 -0
- package/README.md +140 -9
- package/dist/__tests__/bundle/bundler-helpers.test.js +0 -134
- package/dist/__tests__/bundle/bundler-helpers.test.js.map +1 -1
- package/dist/__tests__/bundle/bundler.test.js +121 -61
- package/dist/__tests__/bundle/bundler.test.js.map +1 -1
- package/dist/__tests__/bundle/programmatic.test.js +0 -2
- package/dist/__tests__/bundle/programmatic.test.js.map +1 -1
- package/dist/__tests__/config-loader.test.js +0 -2
- package/dist/__tests__/config-loader.test.js.map +1 -1
- package/dist/__tests__/simulate/server-simulate.integration.test.js +0 -1
- package/dist/__tests__/simulate/server-simulate.integration.test.js.map +1 -1
- package/dist/commands/bundle/bundler.d.ts +18 -0
- package/dist/commands/bundle/bundler.d.ts.map +1 -1
- package/dist/commands/bundle/bundler.js +193 -77
- package/dist/commands/bundle/bundler.js.map +1 -1
- package/dist/commands/run/execution.d.ts.map +1 -1
- package/dist/commands/run/execution.js +6 -2
- package/dist/commands/run/execution.js.map +1 -1
- package/dist/config/build-defaults.d.ts.map +1 -1
- package/dist/config/build-defaults.js +0 -2
- package/dist/config/build-defaults.js.map +1 -1
- package/dist/core/asset-resolver.d.ts +4 -4
- package/dist/core/asset-resolver.d.ts.map +1 -1
- package/dist/core/asset-resolver.js +6 -10
- package/dist/core/asset-resolver.js.map +1 -1
- package/dist/core/docker.d.ts.map +1 -1
- package/dist/core/docker.js +6 -2
- package/dist/core/docker.js.map +1 -1
- package/dist/examples/README.md +13 -1
- package/dist/examples/flow-order-complete.json +1 -2
- package/dist/examples/flow-simple.json +1 -2
- package/dist/examples/server-collect.json +4 -4
- package/dist/index.d.ts +1 -114
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +321 -386
- package/dist/index.js.map +1 -1
- package/dist/types/bundle.d.ts +0 -5
- package/dist/types/bundle.d.ts.map +1 -1
- package/dist/walker.js +1 -1
- package/examples/README.md +13 -1
- package/examples/flow-order-complete.json +1 -2
- package/examples/flow-simple.json +1 -2
- package/examples/server-collect.json +4 -4
- package/package.json +2 -4
- package/dist/__tests__/bundle/serializer.test.d.ts +0 -2
- package/dist/__tests__/bundle/serializer.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/serializer.test.js +0 -173
- package/dist/__tests__/bundle/serializer.test.js.map +0 -1
- package/dist/__tests__/bundle/template-engine.test.d.ts +0 -2
- package/dist/__tests__/bundle/template-engine.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/template-engine.test.js +0 -107
- package/dist/__tests__/bundle/template-engine.test.js.map +0 -1
- package/dist/commands/bundle/serializer.d.ts +0 -23
- package/dist/commands/bundle/serializer.d.ts.map +0 -1
- package/dist/commands/bundle/serializer.js +0 -127
- package/dist/commands/bundle/serializer.js.map +0 -1
- package/dist/commands/bundle/template-engine.d.ts +0 -20
- package/dist/commands/bundle/template-engine.d.ts.map +0 -1
- package/dist/commands/bundle/template-engine.js +0 -54
- package/dist/commands/bundle/template-engine.js.map +0 -1
- package/dist/templates/server.hbs +0 -29
- package/dist/templates/web.hbs +0 -45
- package/dist/types/template.d.ts +0 -108
- package/dist/types/template.d.ts.map +0 -1
- package/dist/types/template.js +0 -10
- package/dist/types/template.js.map +0 -1
- package/templates/server.hbs +0 -29
- package/templates/web.hbs +0 -45
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -24,6 +24,22 @@ npm install -g @walkeros/cli
|
|
|
24
24
|
npm install @walkeros/cli
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Bundle a flow configuration
|
|
31
|
+
walkeros bundle flow.json
|
|
32
|
+
|
|
33
|
+
# Test with simulated events (no real API calls)
|
|
34
|
+
walkeros simulate flow.json --event '{"name":"page view"}'
|
|
35
|
+
|
|
36
|
+
# Push real events to destinations
|
|
37
|
+
walkeros push flow.json --event '{"name":"page view"}'
|
|
38
|
+
|
|
39
|
+
# Run a collection server locally
|
|
40
|
+
walkeros run collect flow.json --port 3000
|
|
41
|
+
```
|
|
42
|
+
|
|
27
43
|
## Commands
|
|
28
44
|
|
|
29
45
|
### bundle
|
|
@@ -86,6 +102,49 @@ walkeros simulate \
|
|
|
86
102
|
--json
|
|
87
103
|
```
|
|
88
104
|
|
|
105
|
+
### push
|
|
106
|
+
|
|
107
|
+
Execute your flow with real API calls to configured destinations. Unlike
|
|
108
|
+
`simulate` which mocks API calls, `push` performs actual HTTP requests.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
walkeros push <config-file> --event '<json>' [options]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Options:**
|
|
115
|
+
|
|
116
|
+
- `-e, --event <source>` - Event to push (JSON string, file path, or URL)
|
|
117
|
+
**Required**
|
|
118
|
+
- `--flow <name>` - Flow name (for multi-flow configs)
|
|
119
|
+
- `--json` - Output results as JSON
|
|
120
|
+
- `-v, --verbose` - Verbose output
|
|
121
|
+
- `-s, --silent` - Suppress output (for CI/CD)
|
|
122
|
+
- `--local` - Execute locally without Docker
|
|
123
|
+
|
|
124
|
+
**Event input formats:**
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# Inline JSON
|
|
128
|
+
walkeros push flow.json --event '{"name":"page view","data":{"title":"Home"}}'
|
|
129
|
+
|
|
130
|
+
# File path
|
|
131
|
+
walkeros push flow.json --event ./events/order.json
|
|
132
|
+
|
|
133
|
+
# URL
|
|
134
|
+
walkeros push flow.json --event https://example.com/sample-event.json
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Push vs Simulate:**
|
|
138
|
+
|
|
139
|
+
| Feature | `push` | `simulate` |
|
|
140
|
+
| ------------ | ----------------------------------- | ------------------ |
|
|
141
|
+
| API Calls | Real HTTP requests | Mocked (captured) |
|
|
142
|
+
| Use Case | Integration testing | Safe local testing |
|
|
143
|
+
| Side Effects | Full (writes to DBs, sends to APIs) | None |
|
|
144
|
+
|
|
145
|
+
Use `simulate` first to validate configuration safely, then `push` to verify
|
|
146
|
+
real integrations.
|
|
147
|
+
|
|
89
148
|
### run
|
|
90
149
|
|
|
91
150
|
Run flows locally using @walkeros/docker as a library (no Docker daemon
|
|
@@ -176,12 +235,12 @@ Flow configs use the `Flow.Setup` format with `version` and `flows`:
|
|
|
176
235
|
"server": {},
|
|
177
236
|
"packages": {
|
|
178
237
|
"@walkeros/collector": { "imports": ["startFlow"] },
|
|
179
|
-
"@walkeros/server-source-express": {
|
|
180
|
-
"@walkeros/destination-demo": {
|
|
238
|
+
"@walkeros/server-source-express": {},
|
|
239
|
+
"@walkeros/destination-demo": {}
|
|
181
240
|
},
|
|
182
241
|
"sources": {
|
|
183
242
|
"http": {
|
|
184
|
-
"
|
|
243
|
+
"package": "@walkeros/server-source-express",
|
|
185
244
|
"config": {
|
|
186
245
|
"settings": { "path": "/collect", "port": 8080 }
|
|
187
246
|
}
|
|
@@ -189,7 +248,7 @@ Flow configs use the `Flow.Setup` format with `version` and `flows`:
|
|
|
189
248
|
},
|
|
190
249
|
"destinations": {
|
|
191
250
|
"demo": {
|
|
192
|
-
"
|
|
251
|
+
"package": "@walkeros/destination-demo",
|
|
193
252
|
"config": {
|
|
194
253
|
"settings": { "name": "Demo" }
|
|
195
254
|
}
|
|
@@ -203,6 +262,76 @@ Flow configs use the `Flow.Setup` format with `version` and `flows`:
|
|
|
203
262
|
|
|
204
263
|
Platform is determined by the `web: {}` or `server: {}` key presence.
|
|
205
264
|
|
|
265
|
+
### Package Configuration Patterns
|
|
266
|
+
|
|
267
|
+
The CLI automatically resolves imports based on how you configure packages:
|
|
268
|
+
|
|
269
|
+
**1. Default exports (recommended for single-export packages):**
|
|
270
|
+
|
|
271
|
+
```json
|
|
272
|
+
{
|
|
273
|
+
"packages": {
|
|
274
|
+
"@walkeros/server-destination-api": {}
|
|
275
|
+
},
|
|
276
|
+
"destinations": {
|
|
277
|
+
"api": {
|
|
278
|
+
"package": "@walkeros/server-destination-api"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
The CLI generates:
|
|
285
|
+
`import _walkerosServerDestinationApi from '@walkeros/server-destination-api';`
|
|
286
|
+
|
|
287
|
+
**2. Named exports (for multi-export packages):**
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{
|
|
291
|
+
"packages": {
|
|
292
|
+
"@walkeros/server-destination-gcp": {}
|
|
293
|
+
},
|
|
294
|
+
"destinations": {
|
|
295
|
+
"bigquery": {
|
|
296
|
+
"package": "@walkeros/server-destination-gcp",
|
|
297
|
+
"code": "destinationBigQuery"
|
|
298
|
+
},
|
|
299
|
+
"analytics": {
|
|
300
|
+
"package": "@walkeros/server-destination-gcp",
|
|
301
|
+
"code": "destinationAnalytics"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
The CLI generates:
|
|
308
|
+
`import { destinationBigQuery, destinationAnalytics } from '@walkeros/server-destination-gcp';`
|
|
309
|
+
|
|
310
|
+
**3. Utility imports (for helper functions):**
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{
|
|
314
|
+
"packages": {
|
|
315
|
+
"lodash": { "imports": ["get", "set"] }
|
|
316
|
+
},
|
|
317
|
+
"mappings": {
|
|
318
|
+
"custom": {
|
|
319
|
+
"data": "({ data }) => get(data, 'user.email')"
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
The CLI generates: `import { get, set } from 'lodash';`
|
|
326
|
+
|
|
327
|
+
**Key points:**
|
|
328
|
+
|
|
329
|
+
- Omit `packages.imports` for destinations/sources - the default export is used
|
|
330
|
+
automatically
|
|
331
|
+
- Only specify `code` when using a specific named export from a multi-export
|
|
332
|
+
package
|
|
333
|
+
- Use `packages.imports` only for utilities needed in mappings or custom code
|
|
334
|
+
|
|
206
335
|
### Local Packages
|
|
207
336
|
|
|
208
337
|
Use local packages instead of npm for development or testing unpublished
|
|
@@ -364,13 +493,15 @@ walkeros bundle config.json
|
|
|
364
493
|
- **Node.js**: 18+ or 22+
|
|
365
494
|
- **Docker**: Not required for CLI (only for production deployment)
|
|
366
495
|
|
|
367
|
-
##
|
|
496
|
+
## Type Definitions
|
|
497
|
+
|
|
498
|
+
See [src/types.ts](./src/types.ts) for TypeScript interfaces.
|
|
368
499
|
|
|
369
|
-
|
|
500
|
+
## Related
|
|
370
501
|
|
|
371
|
-
- [
|
|
372
|
-
- [
|
|
373
|
-
- [
|
|
502
|
+
- [Website Documentation](https://www.walkeros.io/docs/cli/)
|
|
503
|
+
- [Flow Configuration](https://www.walkeros.io/docs/getting-started/flow/)
|
|
504
|
+
- [Docker Package](../docker/) - Production runtime
|
|
374
505
|
|
|
375
506
|
## License
|
|
376
507
|
|
|
@@ -110,139 +110,6 @@ describe('Bundler Helper Functions', () => {
|
|
|
110
110
|
expect(packages).toBeDefined();
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
-
describe('processTemplate', () => {
|
|
114
|
-
it('should return code directly when no template', async () => {
|
|
115
|
-
const flowConfig = {};
|
|
116
|
-
const buildOptions = {
|
|
117
|
-
code: 'console.log("test");',
|
|
118
|
-
template: undefined,
|
|
119
|
-
};
|
|
120
|
-
// Expected: returns code as-is
|
|
121
|
-
expect(buildOptions.template).toBeUndefined();
|
|
122
|
-
expect(buildOptions.code).toBe('console.log("test");');
|
|
123
|
-
});
|
|
124
|
-
it('should process template when configured', async () => {
|
|
125
|
-
const flowConfig = {
|
|
126
|
-
sources: {},
|
|
127
|
-
destinations: {},
|
|
128
|
-
collector: {},
|
|
129
|
-
};
|
|
130
|
-
const buildOptions = {
|
|
131
|
-
code: 'custom code',
|
|
132
|
-
template: 'flow-template',
|
|
133
|
-
};
|
|
134
|
-
// Expected: calls TemplateEngine.process with all parameters
|
|
135
|
-
expect(buildOptions.template).toBe('flow-template');
|
|
136
|
-
});
|
|
137
|
-
it('should handle empty code', async () => {
|
|
138
|
-
const flowConfig = {};
|
|
139
|
-
const buildOptions = {
|
|
140
|
-
code: undefined,
|
|
141
|
-
template: undefined,
|
|
142
|
-
};
|
|
143
|
-
// Expected: returns empty string
|
|
144
|
-
expect(buildOptions.code).toBeUndefined();
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
describe('wrapCodeForFormat', () => {
|
|
148
|
-
it('should not wrap code when template is used', () => {
|
|
149
|
-
const code = 'const flow = startFlow();';
|
|
150
|
-
const format = 'esm';
|
|
151
|
-
const hasTemplate = true;
|
|
152
|
-
// Expected: returns code as-is
|
|
153
|
-
expect(hasTemplate).toBe(true);
|
|
154
|
-
});
|
|
155
|
-
it('should wrap ESM code without exports', () => {
|
|
156
|
-
const code = 'const flow = startFlow();';
|
|
157
|
-
const format = 'esm';
|
|
158
|
-
const hasTemplate = false;
|
|
159
|
-
// Expected: export default const flow = startFlow();
|
|
160
|
-
expect(format).toBe('esm');
|
|
161
|
-
expect(hasTemplate).toBe(false);
|
|
162
|
-
expect(code).not.toMatch(/^\s*export\s/m);
|
|
163
|
-
});
|
|
164
|
-
it('should not wrap ESM code that already has exports', () => {
|
|
165
|
-
const code = 'export const flow = startFlow();';
|
|
166
|
-
const format = 'esm';
|
|
167
|
-
const hasTemplate = false;
|
|
168
|
-
// Expected: returns code as-is (already has export)
|
|
169
|
-
expect(code).toMatch(/^\s*export\s/m);
|
|
170
|
-
});
|
|
171
|
-
it('should not wrap non-ESM formats', () => {
|
|
172
|
-
const code = 'const flow = startFlow();';
|
|
173
|
-
const format = 'cjs';
|
|
174
|
-
const hasTemplate = false;
|
|
175
|
-
// Expected: returns code as-is
|
|
176
|
-
expect(format).toBe('cjs');
|
|
177
|
-
});
|
|
178
|
-
it('should not wrap IIFE format', () => {
|
|
179
|
-
const code = 'const flow = startFlow();';
|
|
180
|
-
const format = 'iife';
|
|
181
|
-
const hasTemplate = false;
|
|
182
|
-
// Expected: returns code as-is
|
|
183
|
-
expect(format).toBe('iife');
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
describe('assembleFinalCode', () => {
|
|
187
|
-
it('should combine imports, examples, and code', () => {
|
|
188
|
-
const importStatements = [
|
|
189
|
-
"import { getId } from '@walkeros/core';",
|
|
190
|
-
"import { startFlow } from '@walkeros/collector';",
|
|
191
|
-
];
|
|
192
|
-
const examplesObject = 'const examples = {\n gtag: gtag_examples\n};\n\n';
|
|
193
|
-
const wrappedCode = 'export default startFlow();';
|
|
194
|
-
const format = 'esm';
|
|
195
|
-
// Expected: imports + examples + code
|
|
196
|
-
expect(importStatements).toHaveLength(2);
|
|
197
|
-
expect(examplesObject).toContain('const examples');
|
|
198
|
-
expect(wrappedCode).toContain('export default');
|
|
199
|
-
});
|
|
200
|
-
it('should handle empty imports', () => {
|
|
201
|
-
const importStatements = [];
|
|
202
|
-
const examplesObject = '';
|
|
203
|
-
const wrappedCode = 'export default startFlow();';
|
|
204
|
-
const format = 'esm';
|
|
205
|
-
// Expected: just the code
|
|
206
|
-
expect(importStatements).toHaveLength(0);
|
|
207
|
-
});
|
|
208
|
-
it('should add examples export for ESM with examples', () => {
|
|
209
|
-
const importStatements = ["import { getId } from '@walkeros/core';"];
|
|
210
|
-
const examplesObject = 'const examples = {\n gtag: gtag_examples\n};\n\n';
|
|
211
|
-
const wrappedCode = 'export default startFlow();';
|
|
212
|
-
const format = 'esm';
|
|
213
|
-
// Expected to include: export { examples };
|
|
214
|
-
expect(format).toBe('esm');
|
|
215
|
-
expect(examplesObject).toContain('const examples');
|
|
216
|
-
});
|
|
217
|
-
it('should not add examples export for non-ESM formats', () => {
|
|
218
|
-
const importStatements = ["import { getId } from '@walkeros/core';"];
|
|
219
|
-
const examplesObject = 'const examples = {\n gtag: gtag_examples\n};\n\n';
|
|
220
|
-
const wrappedCode = 'startFlow();';
|
|
221
|
-
const format = 'cjs';
|
|
222
|
-
// Should not include: export { examples };
|
|
223
|
-
expect(format).not.toBe('esm');
|
|
224
|
-
});
|
|
225
|
-
it('should not add examples export when no examples', () => {
|
|
226
|
-
const importStatements = ["import { getId } from '@walkeros/core';"];
|
|
227
|
-
const examplesObject = '';
|
|
228
|
-
const wrappedCode = 'export default startFlow();';
|
|
229
|
-
const format = 'esm';
|
|
230
|
-
// Should not include: export { examples };
|
|
231
|
-
expect(examplesObject).toBe('');
|
|
232
|
-
});
|
|
233
|
-
it('should handle multiple import statements', () => {
|
|
234
|
-
const importStatements = [
|
|
235
|
-
"import walkerCore from '@walkeros/core';",
|
|
236
|
-
"import { getId, trim } from '@walkeros/core';",
|
|
237
|
-
"import { startFlow } from '@walkeros/collector';",
|
|
238
|
-
];
|
|
239
|
-
const examplesObject = '';
|
|
240
|
-
const wrappedCode = 'export default startFlow();';
|
|
241
|
-
const format = 'esm';
|
|
242
|
-
// Expected: all imports joined with newlines
|
|
243
|
-
expect(importStatements).toHaveLength(3);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
113
|
describe('Integration: createEntryPoint refactored behavior', () => {
|
|
247
114
|
it('should maintain backward compatibility with original implementation', () => {
|
|
248
115
|
// This test documents that the refactored version should produce
|
|
@@ -265,7 +132,6 @@ describe('Bundler Helper Functions', () => {
|
|
|
265
132
|
},
|
|
266
133
|
},
|
|
267
134
|
code: 'export const flow = startFlow();',
|
|
268
|
-
template: undefined,
|
|
269
135
|
format: 'esm',
|
|
270
136
|
platform: 'browser',
|
|
271
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-helpers.test.js","sourceRoot":"","sources":["../../../src/__tests__/bundle/bundler-helpers.test.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,6EAA6E;AAC7E,gDAAgD;AAChD,oEAAoE;AAEpE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACzC,EAAE,CAAC,gE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AAwF;YACxF,0BAA0B;YAC1B,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACzC,MAAM,QAAQ,GAA6B;gBACzC,gBAAgB,EAAE;oBAChB,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC;iBACpC;aACF,CAAC;YAEF,uEAAuE;YACvE,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"bundler-helpers.test.js","sourceRoot":"","sources":["../../../src/__tests__/bundle/bundler-helpers.test.ts"],"names":[],"mappings":"AAGA,+DAA+D;AAC/D,6EAA6E;AAC7E,gDAAgD;AAChD,oEAAoE;AAEpE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACzC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;YACxE,MAAM,UAAU,GAAgB;gBAC9B,YAAY,EAAE;oBACZ,IAAI,EAAE;wBACJ,OAAO,EAAE,gCAAgC;wBACzC,MAAM,EAAE,EAAE;qBACX;oBACD,GAAG,EAAE;wBACH,OAAO,EAAE,+BAA+B;wBACxC,MAAM,EAAE,EAAE;qBACX;iBACF;aACwB,CAAC;YAE5B,qDAAqD;YACrD,0DAA0D;YAC1D,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gDAAgD,EAAE,GAAG,EAAE;YACxD,MAAM,UAAU,GAAgB;gBAC9B,YAAY,EAAE;oBACZ,MAAM,EAAE;wBACN,mBAAmB;wBACnB,MAAM,EAAE,EAAE;qBACX;iBACF;aACwB,CAAC;YAE5B,MAA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AgB;gBAC9B,YAAY,EAAE;oBACZ,IAAI,EAAE;wBACJ,OAAO,EAAE,gCAAgC;qBAC1C;iBACF;aACwB,CAAC;YAE5B,MAAM,YAAY,GAAG;gBACnB,QAAQ,EAAE;oBACR,gBAAgB,EAAE;wBAChB,OAAO,EAAE,CAAC,OAAO,CAAC;qBACnB;oBACD,gCAAgC,EAAE;wBAChC,OAAO,EAAE,CAAC,iBAAiB,EAAE,0BAA0B,CAAC;qBACzD;iBACF;gBACD,IAAI,EAAE,kCAAkC;gBACxC,MAAM,EAAE,KAAc;gBACtB,QAAQ,EAAE,SAAkB;aACF,CAAC;YAE7B,0CAA0C;YAC1C,oEAAoE;YACpE,8DAA8D;YAC9D,8CAA8C;YAC9C,iDAAiD;YACjD,yDAAyD;YACzD,+DAA+D;YAE/D,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACxC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { bundleCore as bundle } from '../../commands/bundle/bundler.js';
|
|
3
|
+
import { bundleCore as bundle, buildConfigObject, generatePlatformWrapper, createEntryPoint, } from '../../commands/bundle/bundler.js';
|
|
4
4
|
import { loadBundleConfig } from '../../config/index.js';
|
|
5
5
|
import { createLogger } from '../../core/index.js';
|
|
6
6
|
import { getId } from '@walkeros/core';
|
|
@@ -77,7 +77,6 @@ describe('Bundler', () => {
|
|
|
77
77
|
const buildOptions = createBuildOptions({
|
|
78
78
|
packages: flowConfig.packages || {},
|
|
79
79
|
code: 'export const test = getId(8);',
|
|
80
|
-
template: '',
|
|
81
80
|
platform: 'browser',
|
|
82
81
|
format: 'esm',
|
|
83
82
|
output: path.join(testOutputDir, 'minimal.js'),
|
|
@@ -96,7 +95,6 @@ describe('Bundler', () => {
|
|
|
96
95
|
const buildOptions = createBuildOptions({
|
|
97
96
|
packages: flowConfig.packages || {},
|
|
98
97
|
code: 'export default { processText: (text) => trim(text) };',
|
|
99
|
-
template: '',
|
|
100
98
|
platform: 'node',
|
|
101
99
|
format: 'esm',
|
|
102
100
|
output: path.join(testOutputDir, 'server-bundle.mjs'),
|
|
@@ -115,7 +113,6 @@ describe('Bundler', () => {
|
|
|
115
113
|
const buildOptions = createBuildOptions({
|
|
116
114
|
packages: flowConfig.packages || {},
|
|
117
115
|
code: "export function processData(data) {\n return data.map(item => ({\n ...item,\n id: getId(8),\n timestamp: new Date().toISOString().split('T')[0],\n processed: true\n }));\n}\n\nexport function extractNestedValues(data, path) {\n return data.map(item => getByPath(item, path, null)).filter(val => val !== null);\n}\n\nexport function deepCloneData(data) {\n return clone(data);\n}\n\nexport function cleanStringData(data) {\n return data.map(item => ({\n ...item,\n name: typeof item.name === 'string' ? trim(item.name) : item.name\n }));\n}\n\n// Re-export walkerOS utilities\nexport { getId, getByPath, clone, trim, isObject };",
|
|
118
|
-
template: '',
|
|
119
116
|
platform: 'browser',
|
|
120
117
|
format: 'esm',
|
|
121
118
|
target: 'es2020',
|
|
@@ -138,7 +135,6 @@ describe('Bundler', () => {
|
|
|
138
135
|
const buildOptions = createBuildOptions({
|
|
139
136
|
packages: flowConfig.packages || {},
|
|
140
137
|
code: 'export const test = getId(8);',
|
|
141
|
-
template: '',
|
|
142
138
|
format: 'esm',
|
|
143
139
|
output: path.join(testOutputDir, 'stats-test.js'),
|
|
144
140
|
});
|
|
@@ -158,7 +154,6 @@ describe('Bundler', () => {
|
|
|
158
154
|
const buildOptions = createBuildOptions({
|
|
159
155
|
packages: flowConfig.packages || {},
|
|
160
156
|
code: 'import * as walkerCore from "@walkeros/core";\nexport const test = walkerCore.getId;',
|
|
161
|
-
template: '',
|
|
162
157
|
format: 'esm',
|
|
163
158
|
output: path.join(testOutputDir, 'test.js'),
|
|
164
159
|
});
|
|
@@ -177,7 +172,6 @@ describe('Bundler', () => {
|
|
|
177
172
|
const buildOptions = createBuildOptions({
|
|
178
173
|
packages: flowConfig.packages || {},
|
|
179
174
|
code: 'export const test = getId(8);',
|
|
180
|
-
template: '',
|
|
181
175
|
format: 'esm',
|
|
182
176
|
output: path.join(testOutputDir, 'no-stats.js'),
|
|
183
177
|
});
|
|
@@ -185,58 +179,6 @@ describe('Bundler', () => {
|
|
|
185
179
|
expect(result).toBeUndefined();
|
|
186
180
|
});
|
|
187
181
|
});
|
|
188
|
-
describe('Template System', () => {
|
|
189
|
-
it('should handle template configuration', async () => {
|
|
190
|
-
// Create a test template file
|
|
191
|
-
const templatePath = path.join(testOutputDir, 'test.hbs');
|
|
192
|
-
await fs.writeFile(templatePath, '{{{CODE}}}\n// Template footer');
|
|
193
|
-
const flowConfig = {
|
|
194
|
-
web: {},
|
|
195
|
-
packages: {
|
|
196
|
-
'@walkeros/core': { imports: ['getId'] },
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
const buildOptions = createBuildOptions({
|
|
200
|
-
packages: flowConfig.packages || {},
|
|
201
|
-
code: 'export const generateId = () => getId(8);',
|
|
202
|
-
template: templatePath,
|
|
203
|
-
output: path.join(testOutputDir, 'template-test.js'),
|
|
204
|
-
});
|
|
205
|
-
await expect(bundle(flowConfig, buildOptions, logger)).resolves.not.toThrow();
|
|
206
|
-
});
|
|
207
|
-
it('should handle missing template variables gracefully', async () => {
|
|
208
|
-
const flowConfig = {
|
|
209
|
-
web: {},
|
|
210
|
-
packages: {
|
|
211
|
-
'@walkeros/core': { imports: ['trim'] },
|
|
212
|
-
},
|
|
213
|
-
};
|
|
214
|
-
const buildOptions = createBuildOptions({
|
|
215
|
-
packages: flowConfig.packages || {},
|
|
216
|
-
code: 'export const test = trim("hello");',
|
|
217
|
-
template: '',
|
|
218
|
-
format: 'esm',
|
|
219
|
-
output: path.join(testOutputDir, 'missing-vars.js'),
|
|
220
|
-
});
|
|
221
|
-
await expect(bundle(flowConfig, buildOptions, logger)).resolves.not.toThrow();
|
|
222
|
-
});
|
|
223
|
-
it('should append bundle code when placeholder not found', async () => {
|
|
224
|
-
const flowConfig = {
|
|
225
|
-
web: {},
|
|
226
|
-
packages: {
|
|
227
|
-
'@walkeros/core': { imports: ['getId'] },
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
const buildOptions = createBuildOptions({
|
|
231
|
-
packages: flowConfig.packages || {},
|
|
232
|
-
code: 'export const test = getId(6);',
|
|
233
|
-
template: '',
|
|
234
|
-
format: 'esm',
|
|
235
|
-
output: path.join(testOutputDir, 'append-test.js'),
|
|
236
|
-
});
|
|
237
|
-
await expect(bundle(flowConfig, buildOptions, logger)).resolves.not.toThrow();
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
182
|
describe('Configuration Scenarios', () => {
|
|
241
183
|
it('should handle custom temp directory configuration', async () => {
|
|
242
184
|
const flowConfig = {
|
|
@@ -248,7 +190,6 @@ describe('Bundler', () => {
|
|
|
248
190
|
const buildOptions = createBuildOptions({
|
|
249
191
|
packages: flowConfig.packages || {},
|
|
250
192
|
code: 'export const test = getId();',
|
|
251
|
-
template: '',
|
|
252
193
|
format: 'esm',
|
|
253
194
|
tempDir: '/tmp/my-custom-bundler-temp',
|
|
254
195
|
output: path.join(testOutputDir, 'custom-temp-example.js'),
|
|
@@ -265,7 +206,6 @@ describe('Bundler', () => {
|
|
|
265
206
|
const buildOptions = createBuildOptions({
|
|
266
207
|
packages: flowConfig.packages || {},
|
|
267
208
|
code: '// Test version pinning\nexport const test = getId();',
|
|
268
|
-
template: '',
|
|
269
209
|
platform: 'browser',
|
|
270
210
|
format: 'esm',
|
|
271
211
|
target: 'es2020',
|
|
@@ -289,5 +229,125 @@ describe('Bundler', () => {
|
|
|
289
229
|
}).toThrow(/Invalid configuration/);
|
|
290
230
|
});
|
|
291
231
|
});
|
|
232
|
+
describe('buildConfigObject', () => {
|
|
233
|
+
it('uses explicit code for named imports', () => {
|
|
234
|
+
const flowConfig = {
|
|
235
|
+
server: {},
|
|
236
|
+
sources: {
|
|
237
|
+
http: {
|
|
238
|
+
package: '@walkeros/server-source-express',
|
|
239
|
+
code: 'sourceExpress',
|
|
240
|
+
config: { settings: { port: 8080 } },
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
destinations: {
|
|
244
|
+
demo: {
|
|
245
|
+
package: '@walkeros/destination-demo',
|
|
246
|
+
code: 'destinationDemo',
|
|
247
|
+
config: { settings: { name: 'Test' } },
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
const explicitCodeImports = new Map([
|
|
252
|
+
['@walkeros/server-source-express', new Set(['sourceExpress'])],
|
|
253
|
+
['@walkeros/destination-demo', new Set(['destinationDemo'])],
|
|
254
|
+
]);
|
|
255
|
+
const result = buildConfigObject(flowConfig, explicitCodeImports);
|
|
256
|
+
expect(result).toContain('code: sourceExpress');
|
|
257
|
+
expect(result).toContain('code: destinationDemo');
|
|
258
|
+
expect(result).toContain('"port": 8080');
|
|
259
|
+
expect(result).toContain('"name": "Test"');
|
|
260
|
+
});
|
|
261
|
+
it('uses default import variable when no explicit code', () => {
|
|
262
|
+
const flowConfig = {
|
|
263
|
+
server: {},
|
|
264
|
+
sources: {
|
|
265
|
+
http: {
|
|
266
|
+
package: '@walkeros/server-source-express',
|
|
267
|
+
config: { settings: { port: 8080 } },
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
destinations: {},
|
|
271
|
+
};
|
|
272
|
+
const explicitCodeImports = new Map(); // No explicit imports
|
|
273
|
+
const result = buildConfigObject(flowConfig, explicitCodeImports);
|
|
274
|
+
expect(result).toContain('code: _walkerosServerSourceExpress');
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
describe('generatePlatformWrapper', () => {
|
|
278
|
+
it('generates web IIFE wrapper', () => {
|
|
279
|
+
const config = '{ sources: {}, destinations: {} }';
|
|
280
|
+
const userCode = 'console.log("custom code");';
|
|
281
|
+
const buildOptions = {
|
|
282
|
+
platform: 'browser',
|
|
283
|
+
windowCollector: 'collector',
|
|
284
|
+
windowElb: 'elb',
|
|
285
|
+
};
|
|
286
|
+
const result = generatePlatformWrapper(config, userCode, buildOptions);
|
|
287
|
+
expect(result).toContain('(async () => {');
|
|
288
|
+
expect(result).toContain('const config = { sources: {}, destinations: {} };');
|
|
289
|
+
expect(result).toContain('console.log("custom code");');
|
|
290
|
+
expect(result).toContain('await startFlow(config)');
|
|
291
|
+
expect(result).toContain("window['collector'] = collector");
|
|
292
|
+
expect(result).toContain("window['elb'] = elb");
|
|
293
|
+
});
|
|
294
|
+
it('generates server export default wrapper', () => {
|
|
295
|
+
const config = '{ sources: {}, destinations: {} }';
|
|
296
|
+
const userCode = '';
|
|
297
|
+
const buildOptions = { platform: 'node' };
|
|
298
|
+
const result = generatePlatformWrapper(config, userCode, buildOptions);
|
|
299
|
+
expect(result).toContain('export default async function');
|
|
300
|
+
expect(result).toContain('const config = { sources: {}, destinations: {} };');
|
|
301
|
+
expect(result).toContain('return await startFlow(config)');
|
|
302
|
+
expect(result).not.toContain('window');
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
describe('createEntryPoint integration', () => {
|
|
306
|
+
it('generates complete entry point with explicit code', async () => {
|
|
307
|
+
const flowConfig = {
|
|
308
|
+
server: {},
|
|
309
|
+
packages: {
|
|
310
|
+
'@walkeros/collector': { imports: ['startFlow'] },
|
|
311
|
+
'@walkeros/server-source-express': {},
|
|
312
|
+
'@walkeros/destination-demo': {},
|
|
313
|
+
},
|
|
314
|
+
sources: {
|
|
315
|
+
http: {
|
|
316
|
+
package: '@walkeros/server-source-express',
|
|
317
|
+
code: 'sourceExpress',
|
|
318
|
+
config: { settings: { port: 8080 } },
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
destinations: {
|
|
322
|
+
demo: {
|
|
323
|
+
package: '@walkeros/destination-demo',
|
|
324
|
+
code: 'destinationDemo',
|
|
325
|
+
config: { settings: { name: 'Test' } },
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
const buildOptions = {
|
|
330
|
+
platform: 'node',
|
|
331
|
+
format: 'esm',
|
|
332
|
+
packages: {
|
|
333
|
+
'@walkeros/collector': { imports: ['startFlow'] },
|
|
334
|
+
'@walkeros/server-source-express': {},
|
|
335
|
+
'@walkeros/destination-demo': {},
|
|
336
|
+
},
|
|
337
|
+
output: './dist/bundle.mjs',
|
|
338
|
+
code: '',
|
|
339
|
+
};
|
|
340
|
+
const result = await createEntryPoint(flowConfig, buildOptions, new Map());
|
|
341
|
+
// Should have named imports
|
|
342
|
+
expect(result).toContain("import { startFlow } from '@walkeros/collector'");
|
|
343
|
+
expect(result).toContain("import { sourceExpress } from '@walkeros/server-source-express'");
|
|
344
|
+
expect(result).toContain("import { destinationDemo } from '@walkeros/destination-demo'");
|
|
345
|
+
// Should use those imports in config
|
|
346
|
+
expect(result).toContain('code: sourceExpress');
|
|
347
|
+
expect(result).toContain('code: destinationDemo');
|
|
348
|
+
// Should have server wrapper
|
|
349
|
+
expect(result).toContain('export default async function');
|
|
350
|
+
});
|
|
351
|
+
});
|
|
292
352
|
});
|
|
293
353
|
//# sourceMappingURL=bundler.test.js.map
|