@walkeros/cli 0.3.1
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 +45 -0
- package/README.md +285 -0
- package/dist/__tests__/bundle/bundler-integration.test.d.ts +2 -0
- package/dist/__tests__/bundle/bundler-integration.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bundler-integration.test.js +106 -0
- package/dist/__tests__/bundle/bundler-integration.test.js.map +1 -0
- package/dist/__tests__/bundle/bundler.test.d.ts +2 -0
- package/dist/__tests__/bundle/bundler.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bundler.test.js +281 -0
- package/dist/__tests__/bundle/bundler.test.js.map +1 -0
- package/dist/__tests__/bundle/programmatic.test.d.ts +2 -0
- package/dist/__tests__/bundle/programmatic.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/programmatic.test.js +118 -0
- package/dist/__tests__/bundle/programmatic.test.js.map +1 -0
- package/dist/__tests__/bundle/serializer.test.d.ts +2 -0
- package/dist/__tests__/bundle/serializer.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/serializer.test.js +173 -0
- package/dist/__tests__/bundle/serializer.test.js.map +1 -0
- package/dist/__tests__/bundle/template-engine.test.d.ts +2 -0
- package/dist/__tests__/bundle/template-engine.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/template-engine.test.js +107 -0
- package/dist/__tests__/bundle/template-engine.test.js.map +1 -0
- package/dist/__tests__/cli-e2e.test.d.ts +8 -0
- package/dist/__tests__/cli-e2e.test.d.ts.map +1 -0
- package/dist/__tests__/cli-e2e.test.js +144 -0
- package/dist/__tests__/cli-e2e.test.js.map +1 -0
- package/dist/__tests__/cli.test.d.ts +2 -0
- package/dist/__tests__/cli.test.d.ts.map +1 -0
- package/dist/__tests__/cli.test.js +255 -0
- package/dist/__tests__/cli.test.js.map +1 -0
- package/dist/__tests__/config-loader.test.d.ts +7 -0
- package/dist/__tests__/config-loader.test.d.ts.map +1 -0
- package/dist/__tests__/config-loader.test.js +393 -0
- package/dist/__tests__/config-loader.test.js.map +1 -0
- package/dist/__tests__/core/config.test.d.ts +2 -0
- package/dist/__tests__/core/config.test.d.ts.map +1 -0
- package/dist/__tests__/core/config.test.js +72 -0
- package/dist/__tests__/core/config.test.js.map +1 -0
- package/dist/__tests__/core/logger.test.d.ts +2 -0
- package/dist/__tests__/core/logger.test.d.ts.map +1 -0
- package/dist/__tests__/core/logger.test.js +53 -0
- package/dist/__tests__/core/logger.test.js.map +1 -0
- package/dist/__tests__/simulate/programmatic.test.d.ts +2 -0
- package/dist/__tests__/simulate/programmatic.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/programmatic.test.js +51 -0
- package/dist/__tests__/simulate/programmatic.test.js.map +1 -0
- package/dist/__tests__/simulate/simulator.test.d.ts +2 -0
- package/dist/__tests__/simulate/simulator.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/simulator.test.js +29 -0
- package/dist/__tests__/simulate/simulator.test.js.map +1 -0
- package/dist/commands/bundle/bundler.d.ts +14 -0
- package/dist/commands/bundle/bundler.d.ts.map +1 -0
- package/dist/commands/bundle/bundler.js +372 -0
- package/dist/commands/bundle/bundler.js.map +1 -0
- package/dist/commands/bundle/index.d.ts +51 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/bundle/index.js +200 -0
- package/dist/commands/bundle/index.js.map +1 -0
- package/dist/commands/bundle/package-manager.d.ts +7 -0
- package/dist/commands/bundle/package-manager.d.ts.map +1 -0
- package/dist/commands/bundle/package-manager.js +170 -0
- package/dist/commands/bundle/package-manager.js.map +1 -0
- package/dist/commands/bundle/serializer.d.ts +23 -0
- package/dist/commands/bundle/serializer.d.ts.map +1 -0
- package/dist/commands/bundle/serializer.js +127 -0
- package/dist/commands/bundle/serializer.js.map +1 -0
- package/dist/commands/bundle/stats.d.ts +23 -0
- package/dist/commands/bundle/stats.d.ts.map +1 -0
- package/dist/commands/bundle/stats.js +52 -0
- package/dist/commands/bundle/stats.js.map +1 -0
- package/dist/commands/bundle/template-engine.d.ts +18 -0
- package/dist/commands/bundle/template-engine.d.ts.map +1 -0
- package/dist/commands/bundle/template-engine.js +49 -0
- package/dist/commands/bundle/template-engine.js.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts +8 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.js +53 -0
- package/dist/commands/run/__tests__/run.integration.test.js.map +1 -0
- package/dist/commands/run/__tests__/validators.test.d.ts +2 -0
- package/dist/commands/run/__tests__/validators.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/validators.test.js +80 -0
- package/dist/commands/run/__tests__/validators.test.js.map +1 -0
- package/dist/commands/run/index.d.ts +39 -0
- package/dist/commands/run/index.d.ts.map +1 -0
- package/dist/commands/run/index.js +251 -0
- package/dist/commands/run/index.js.map +1 -0
- package/dist/commands/run/types.d.ts +56 -0
- package/dist/commands/run/types.d.ts.map +1 -0
- package/dist/commands/run/types.js +7 -0
- package/dist/commands/run/types.js.map +1 -0
- package/dist/commands/run/validators.d.ts +29 -0
- package/dist/commands/run/validators.d.ts.map +1 -0
- package/dist/commands/run/validators.js +54 -0
- package/dist/commands/run/validators.js.map +1 -0
- package/dist/commands/simulate/index.d.ts +47 -0
- package/dist/commands/simulate/index.d.ts.map +1 -0
- package/dist/commands/simulate/index.js +121 -0
- package/dist/commands/simulate/index.js.map +1 -0
- package/dist/commands/simulate/simulator.d.ts +18 -0
- package/dist/commands/simulate/simulator.d.ts.map +1 -0
- package/dist/commands/simulate/simulator.js +236 -0
- package/dist/commands/simulate/simulator.js.map +1 -0
- package/dist/commands/simulate/tracker.d.ts +30 -0
- package/dist/commands/simulate/tracker.d.ts.map +1 -0
- package/dist/commands/simulate/tracker.js +96 -0
- package/dist/commands/simulate/tracker.js.map +1 -0
- package/dist/commands/simulate/types.d.ts +18 -0
- package/dist/commands/simulate/types.d.ts.map +1 -0
- package/dist/commands/simulate/types.js +2 -0
- package/dist/commands/simulate/types.js.map +1 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +73 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +16 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +74 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +136 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/parser.d.ts +64 -0
- package/dist/config/parser.d.ts.map +1 -0
- package/dist/config/parser.js +137 -0
- package/dist/config/parser.js.map +1 -0
- package/dist/config/utils.d.ts +38 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +66 -0
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validators.d.ts +23 -0
- package/dist/config/validators.d.ts.map +1 -0
- package/dist/config/validators.js +45 -0
- package/dist/config/validators.js.map +1 -0
- package/dist/core/docker.d.ts +42 -0
- package/dist/core/docker.d.ts.map +1 -0
- package/dist/core/docker.js +114 -0
- package/dist/core/docker.js.map +1 -0
- package/dist/core/execution.d.ts +33 -0
- package/dist/core/execution.d.ts.map +1 -0
- package/dist/core/execution.js +57 -0
- package/dist/core/execution.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +17 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +74 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/output.d.ts +30 -0
- package/dist/core/output.d.ts.map +1 -0
- package/dist/core/output.js +46 -0
- package/dist/core/output.js.map +1 -0
- package/dist/core/timer.d.ts +14 -0
- package/dist/core/timer.d.ts.map +1 -0
- package/dist/core/timer.js +29 -0
- package/dist/core/timer.js.map +1 -0
- package/dist/index.d.ts +614 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1940 -0
- package/dist/index.js.map +1 -0
- package/dist/types/bundle.d.ts +251 -0
- package/dist/types/bundle.d.ts.map +1 -0
- package/dist/types/bundle.js +10 -0
- package/dist/types/bundle.js.map +1 -0
- package/dist/types/global.d.ts +51 -0
- package/dist/types/global.d.ts.map +1 -0
- package/dist/types/global.js +30 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/template.d.ts +108 -0
- package/dist/types/template.d.ts.map +1 -0
- package/dist/types/template.js +10 -0
- package/dist/types/template.js.map +1 -0
- package/package.json +59 -0
- package/templates/base.hbs +44 -0
- package/templates/server.hbs +29 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @walkeros/cli
|
|
2
|
+
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 25f7e10: Fix bundle command template path resolution to support relative paths
|
|
8
|
+
|
|
9
|
+
**CLI Changes:**
|
|
10
|
+
- Template paths starting with `./` or `../` in config files are now resolved
|
|
11
|
+
relative to the config file's directory
|
|
12
|
+
- Maintains backward compatibility for other relative paths (resolved from
|
|
13
|
+
cwd)
|
|
14
|
+
- Enables portable flow configs that reference templates next to them
|
|
15
|
+
|
|
16
|
+
**Docker Changes:**
|
|
17
|
+
- Updated demo.json and express-console.json to include template and output
|
|
18
|
+
fields
|
|
19
|
+
- Flow files can now be bundled standalone using the CLI bundle command
|
|
20
|
+
- Templates are referenced using `../templates/base.hbs` relative to flow file
|
|
21
|
+
|
|
22
|
+
**Example:**
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Now works from any directory
|
|
26
|
+
node dist/index.mjs bundle -c packages/docker/flows/demo.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- hello
|
|
30
|
+
- Updated dependencies [25f7e10]
|
|
31
|
+
- Updated dependencies
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @walkeros/docker@0.1.1
|
|
34
|
+
- @walkeros/core@0.3.1
|
|
35
|
+
|
|
36
|
+
## 0.2.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- env
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies
|
|
45
|
+
- @walkeros/core@0.2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# @walkeros/cli
|
|
2
|
+
|
|
3
|
+
Command-line tools for building, testing, and running walkerOS event collection
|
|
4
|
+
flows.
|
|
5
|
+
|
|
6
|
+
## What is this?
|
|
7
|
+
|
|
8
|
+
The walkerOS CLI is a developer tool that:
|
|
9
|
+
|
|
10
|
+
- **Bundles** flow configurations into optimized JavaScript
|
|
11
|
+
- **Simulates** event processing for testing
|
|
12
|
+
- **Runs** flows locally without Docker daemon
|
|
13
|
+
|
|
14
|
+
Think of it as your development toolchain for walkerOS - from config to running
|
|
15
|
+
production bundles.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Global (recommended for CLI usage)
|
|
21
|
+
npm install -g @walkeros/cli
|
|
22
|
+
|
|
23
|
+
# Local (for programmatic usage)
|
|
24
|
+
npm install @walkeros/cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Commands
|
|
28
|
+
|
|
29
|
+
### bundle
|
|
30
|
+
|
|
31
|
+
Generate optimized JavaScript bundles from flow configurations.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
walkeros bundle --config flow.json [options]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Options:**
|
|
38
|
+
|
|
39
|
+
- `-c, --config <path>` - Flow configuration file (required)
|
|
40
|
+
- `-e, --env <name>` - Build specific environment (multi-env configs)
|
|
41
|
+
- `--all` - Build all environments
|
|
42
|
+
- `-s, --stats` - Show bundle statistics
|
|
43
|
+
- `--json` - Output stats as JSON
|
|
44
|
+
- `--no-cache` - Disable package caching
|
|
45
|
+
- `-v, --verbose` - Verbose output
|
|
46
|
+
|
|
47
|
+
**Example:**
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Bundle with stats
|
|
51
|
+
walkeros bundle --config examples/server-collect.json --stats
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The output path is specified in the config's `build.output` field.
|
|
55
|
+
|
|
56
|
+
### simulate
|
|
57
|
+
|
|
58
|
+
Test event processing with simulated events.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
walkeros simulate --config flow.json --event '{"name":"page view"}' [options]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Options:**
|
|
65
|
+
|
|
66
|
+
- `-c, --config <path>` - Bundle configuration file (required)
|
|
67
|
+
- `-e, --event <json>` - Event JSON string (required)
|
|
68
|
+
- `--json` - Output results as JSON
|
|
69
|
+
- `-v, --verbose` - Verbose output
|
|
70
|
+
|
|
71
|
+
**Example:**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Simulate page view
|
|
75
|
+
walkeros simulate \
|
|
76
|
+
--config examples/web-serve.json \
|
|
77
|
+
--event '{"name":"page view","data":{"title":"Home"}}' \
|
|
78
|
+
--json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### run
|
|
82
|
+
|
|
83
|
+
Run flows locally using @walkeros/docker as a library (no Docker daemon
|
|
84
|
+
required).
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
walkeros run <mode> --config <path> [options]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Modes:**
|
|
91
|
+
|
|
92
|
+
- `collect` - HTTP event collection server
|
|
93
|
+
- `serve` - Static file server
|
|
94
|
+
|
|
95
|
+
**Options:**
|
|
96
|
+
|
|
97
|
+
- `-c, --config <path>` - Flow config (.json) or bundle (.mjs)
|
|
98
|
+
- `-p, --port <number>` - Server port
|
|
99
|
+
- `-h, --host <host>` - Server host
|
|
100
|
+
- `--static-dir <dir>` - Static directory (serve mode)
|
|
101
|
+
- `--json` - JSON output
|
|
102
|
+
- `-v, --verbose` - Verbose output
|
|
103
|
+
|
|
104
|
+
**Examples:**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Run collection server (auto-bundles JSON)
|
|
108
|
+
walkeros run collect --config examples/server-collect.json --port 3000
|
|
109
|
+
|
|
110
|
+
# Run with pre-built bundle
|
|
111
|
+
walkeros run collect --config examples/server-collect.mjs --port 3000
|
|
112
|
+
|
|
113
|
+
# Serve static files
|
|
114
|
+
walkeros run serve --config flow.json --port 8080 --static-dir ./dist
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**How it works:**
|
|
118
|
+
|
|
119
|
+
1. JSON configs are bundled to temp `.mjs` automatically
|
|
120
|
+
2. `.mjs` bundles are used directly
|
|
121
|
+
3. Runs in current Node.js process (no containers)
|
|
122
|
+
4. Press Ctrl+C for graceful shutdown
|
|
123
|
+
|
|
124
|
+
## Flow Configuration
|
|
125
|
+
|
|
126
|
+
Minimal example:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"flow": {
|
|
131
|
+
"platform": "server",
|
|
132
|
+
"sources": {
|
|
133
|
+
"http": {
|
|
134
|
+
"code": "sourceExpress",
|
|
135
|
+
"config": {
|
|
136
|
+
"settings": {
|
|
137
|
+
"path": "/collect",
|
|
138
|
+
"port": 8080
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"destinations": {
|
|
144
|
+
"demo": {
|
|
145
|
+
"code": "destinationDemo",
|
|
146
|
+
"config": {
|
|
147
|
+
"settings": {
|
|
148
|
+
"name": "Demo"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
"collector": {
|
|
154
|
+
"run": true
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
"build": {
|
|
158
|
+
"packages": {
|
|
159
|
+
"@walkeros/collector": {
|
|
160
|
+
"version": "latest",
|
|
161
|
+
"imports": ["startFlow"]
|
|
162
|
+
},
|
|
163
|
+
"@walkeros/server-source-express": {
|
|
164
|
+
"version": "latest",
|
|
165
|
+
"imports": ["sourceExpress"]
|
|
166
|
+
},
|
|
167
|
+
"@walkeros/destination-demo": {
|
|
168
|
+
"version": "latest",
|
|
169
|
+
"imports": ["destinationDemo"]
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"code": "// Custom code here\n",
|
|
173
|
+
"output": "bundle.mjs",
|
|
174
|
+
"template": "./templates/base.hbs"
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
See [examples/](./examples/) for complete working configurations.
|
|
180
|
+
|
|
181
|
+
## Programmatic API
|
|
182
|
+
|
|
183
|
+
Use commands programmatically:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { bundle, simulate, runCommand } from '@walkeros/cli';
|
|
187
|
+
|
|
188
|
+
// Bundle
|
|
189
|
+
await bundle({
|
|
190
|
+
config: './flow.json',
|
|
191
|
+
stats: true,
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
// Simulate
|
|
195
|
+
const result = await simulate(
|
|
196
|
+
'./flow.json',
|
|
197
|
+
{ name: 'page view', data: { title: 'Test' } },
|
|
198
|
+
{ json: true },
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
// Run
|
|
202
|
+
await runCommand('collect', {
|
|
203
|
+
config: './flow.json',
|
|
204
|
+
port: 3000,
|
|
205
|
+
verbose: true,
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Examples
|
|
210
|
+
|
|
211
|
+
Working example configs in [examples/](./examples/):
|
|
212
|
+
|
|
213
|
+
- **server-collect.json** - Basic server-side collection
|
|
214
|
+
- **server-collection.json** - Advanced server setup
|
|
215
|
+
- **web-serve.json** - Web demo with API destination
|
|
216
|
+
- **web-tracking.json** - General web tracking
|
|
217
|
+
|
|
218
|
+
Try them:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Bundle example
|
|
222
|
+
walkeros bundle --config examples/server-collect.json --stats
|
|
223
|
+
|
|
224
|
+
# Simulate
|
|
225
|
+
walkeros simulate \
|
|
226
|
+
--config examples/web-serve.json \
|
|
227
|
+
--event '{"name":"product view","data":{"id":"P123"}}'
|
|
228
|
+
|
|
229
|
+
# Run server
|
|
230
|
+
walkeros run collect --config examples/server-collect.json --port 3000
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Development Workflow
|
|
234
|
+
|
|
235
|
+
Typical development cycle:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# 1. Create/edit config
|
|
239
|
+
vim my-flow.json
|
|
240
|
+
|
|
241
|
+
# 2. Bundle and check stats
|
|
242
|
+
walkeros bundle --config my-flow.json --stats
|
|
243
|
+
|
|
244
|
+
# 3. Test with simulation
|
|
245
|
+
walkeros simulate \
|
|
246
|
+
--config my-flow.json \
|
|
247
|
+
--event '{"name":"test event"}' \
|
|
248
|
+
--verbose
|
|
249
|
+
|
|
250
|
+
# 4. Run locally
|
|
251
|
+
walkeros run collect --config my-flow.json --port 3000
|
|
252
|
+
|
|
253
|
+
# 5. In another terminal, test it
|
|
254
|
+
curl -X POST http://localhost:3000/collect \
|
|
255
|
+
-H "Content-Type: application/json" \
|
|
256
|
+
-d '{"name":"page view","data":{"title":"Home"}}'
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Architecture
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
CLI (downloads packages + bundles with esbuild)
|
|
263
|
+
├─ Bundle → optimized .mjs file
|
|
264
|
+
├─ Simulate → test bundle with events
|
|
265
|
+
└─ Run → import @walkeros/docker + execute bundle
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Key principle**: CLI handles build-time, Docker handles runtime.
|
|
269
|
+
|
|
270
|
+
## Requirements
|
|
271
|
+
|
|
272
|
+
- **Node.js**: 18+ or 22+
|
|
273
|
+
- **Docker**: Not required for CLI (only for production deployment)
|
|
274
|
+
|
|
275
|
+
## Documentation
|
|
276
|
+
|
|
277
|
+
Detailed guides in [docs/](./docs/):
|
|
278
|
+
|
|
279
|
+
- [RUN_COMMAND.md](./docs/RUN_COMMAND.md) - Run command details
|
|
280
|
+
- [PUBLISHING.md](./docs/PUBLISHING.md) - Publishing guide
|
|
281
|
+
- [MANUAL_TESTING_GUIDE.md](./docs/MANUAL_TESTING_GUIDE.md) - Testing guide
|
|
282
|
+
|
|
283
|
+
## License
|
|
284
|
+
|
|
285
|
+
MIT © elbwalker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler-integration.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/bundle/bundler-integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { parseBundleConfig } from '../../config';
|
|
4
|
+
import { createLogger } from '../../core';
|
|
5
|
+
import { getId } from '@walkeros/core';
|
|
6
|
+
describe('Bundler Integration', () => {
|
|
7
|
+
const testOutputDir = path.resolve('.tmp', `bundler-integration-${Date.now()}-${getId()}`);
|
|
8
|
+
let logger;
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
// Ensure test output directory exists
|
|
11
|
+
await fs.ensureDir(testOutputDir);
|
|
12
|
+
// Create a silent logger for tests
|
|
13
|
+
logger = createLogger({ silent: true });
|
|
14
|
+
// Mock console.log to suppress output during tests
|
|
15
|
+
jest.spyOn(console, 'log').mockImplementation(() => { });
|
|
16
|
+
});
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
// Clean up test output
|
|
19
|
+
await fs.remove(testOutputDir);
|
|
20
|
+
// Restore console.log
|
|
21
|
+
jest.restoreAllMocks();
|
|
22
|
+
});
|
|
23
|
+
it('should handle configuration parsing correctly', async () => {
|
|
24
|
+
const rawConfig = {
|
|
25
|
+
flow: {
|
|
26
|
+
platform: 'web',
|
|
27
|
+
},
|
|
28
|
+
build: {
|
|
29
|
+
packages: {
|
|
30
|
+
'@walkeros/core': {
|
|
31
|
+
imports: ['getId'],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
code: 'export const test = getId(8);',
|
|
35
|
+
platform: 'browser',
|
|
36
|
+
format: 'esm',
|
|
37
|
+
output: path.join(testOutputDir, 'test-config.js'),
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
const { flowConfig, buildOptions } = parseBundleConfig(rawConfig);
|
|
41
|
+
expect(Object.keys(buildOptions.packages)).toHaveLength(1);
|
|
42
|
+
expect('@walkeros/core' in buildOptions.packages).toBe(true);
|
|
43
|
+
expect(buildOptions.code).toContain('getId');
|
|
44
|
+
expect(buildOptions.platform).toBe('browser');
|
|
45
|
+
expect(buildOptions.output).toBe(path.join(testOutputDir, 'test-config.js'));
|
|
46
|
+
});
|
|
47
|
+
it('should handle template configuration', async () => {
|
|
48
|
+
const rawConfig = {
|
|
49
|
+
flow: {
|
|
50
|
+
platform: 'web',
|
|
51
|
+
},
|
|
52
|
+
build: {
|
|
53
|
+
packages: {
|
|
54
|
+
'@walkeros/core': {
|
|
55
|
+
imports: ['getId'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
code: 'export const test = getId(8);',
|
|
59
|
+
template: 'templates/web.hbs',
|
|
60
|
+
output: path.join(testOutputDir, 'template-test.js'),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const { flowConfig, buildOptions } = parseBundleConfig(rawConfig);
|
|
64
|
+
expect(buildOptions.template).toBeDefined();
|
|
65
|
+
expect(buildOptions.template).toBe('templates/web.hbs');
|
|
66
|
+
});
|
|
67
|
+
it('should validate custom build configuration', async () => {
|
|
68
|
+
const rawConfig = {
|
|
69
|
+
flow: {
|
|
70
|
+
platform: 'server',
|
|
71
|
+
},
|
|
72
|
+
build: {
|
|
73
|
+
packages: {},
|
|
74
|
+
code: 'export const test = "hello";',
|
|
75
|
+
platform: 'node',
|
|
76
|
+
format: 'esm',
|
|
77
|
+
minify: true,
|
|
78
|
+
sourcemap: true,
|
|
79
|
+
target: 'node18',
|
|
80
|
+
output: path.join(testOutputDir, 'build-test.mjs'),
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const { flowConfig, buildOptions } = parseBundleConfig(rawConfig);
|
|
84
|
+
expect(buildOptions.platform).toBe('node');
|
|
85
|
+
expect(buildOptions.format).toBe('esm');
|
|
86
|
+
expect(buildOptions.minify).toBe(true);
|
|
87
|
+
expect(buildOptions.sourcemap).toBe(true);
|
|
88
|
+
expect(buildOptions.target).toBe('node18');
|
|
89
|
+
});
|
|
90
|
+
it('should handle error conditions gracefully', async () => {
|
|
91
|
+
// Test with invalid syntax in content
|
|
92
|
+
const { flowConfig, buildOptions } = parseBundleConfig({
|
|
93
|
+
flow: {
|
|
94
|
+
platform: 'web',
|
|
95
|
+
},
|
|
96
|
+
build: {
|
|
97
|
+
packages: {},
|
|
98
|
+
code: 'export const badCode = () => { return [1,2,3] x => x * 2; };',
|
|
99
|
+
output: path.join(testOutputDir, 'error-test.js'),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
// Should not throw during configuration parsing
|
|
103
|
+
expect(buildOptions.code).toContain('badCode');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=bundler-integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundler-integration.test.js","sourceRoot":"","sources":["../../../src/__tests__/bundle/bundler-integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAi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