@walkeros/cli 0.5.1-next.0 → 0.6.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 +35 -0
- package/README.md +51 -28
- package/dist/__tests__/bundle/bundler-helpers.test.d.ts +2 -0
- package/dist/__tests__/bundle/bundler-helpers.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bundler-helpers.test.js +151 -0
- package/dist/__tests__/bundle/bundler-helpers.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 +352 -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 +148 -0
- package/dist/__tests__/bundle/programmatic.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 +145 -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 +179 -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 +414 -0
- package/dist/__tests__/config-loader.test.js.map +1 -0
- package/dist/__tests__/core/asset-resolver.test.d.ts +2 -0
- package/dist/__tests__/core/asset-resolver.test.d.ts.map +1 -0
- package/dist/__tests__/core/asset-resolver.test.js +14 -0
- package/dist/__tests__/core/asset-resolver.test.js.map +1 -0
- package/dist/__tests__/core/build-cache.test.d.ts +2 -0
- package/dist/__tests__/core/build-cache.test.d.ts.map +1 -0
- package/dist/__tests__/core/build-cache.test.js +55 -0
- package/dist/__tests__/core/build-cache.test.js.map +1 -0
- package/dist/__tests__/core/cache-utils.test.d.ts +2 -0
- package/dist/__tests__/core/cache-utils.test.d.ts.map +1 -0
- package/dist/__tests__/core/cache-utils.test.js +70 -0
- package/dist/__tests__/core/cache-utils.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 +79 -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__/integration/bundle-run.integration.test.d.ts +8 -0
- package/dist/__tests__/integration/bundle-run.integration.test.d.ts.map +1 -0
- package/dist/__tests__/integration/bundle-run.integration.test.js +54 -0
- package/dist/__tests__/integration/bundle-run.integration.test.js.map +1 -0
- package/dist/__tests__/push/push.test.d.ts +7 -0
- package/dist/__tests__/push/push.test.d.ts.map +1 -0
- package/dist/__tests__/push/push.test.js +197 -0
- package/dist/__tests__/push/push.test.js.map +1 -0
- package/dist/__tests__/simulate/env-loader.test.d.ts +2 -0
- package/dist/__tests__/simulate/env-loader.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/env-loader.test.js +47 -0
- package/dist/__tests__/simulate/env-loader.test.js.map +1 -0
- package/dist/__tests__/simulate/node-executor.test.d.ts +5 -0
- package/dist/__tests__/simulate/node-executor.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/node-executor.test.js +25 -0
- package/dist/__tests__/simulate/node-executor.test.js.map +1 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts +5 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.js +58 -0
- package/dist/__tests__/simulate/server-simulate.integration.test.js.map +1 -0
- package/dist/__tests__/smoke/production.smoke.test.d.ts +8 -0
- package/dist/__tests__/smoke/production.smoke.test.d.ts.map +1 -0
- package/dist/__tests__/smoke/production.smoke.test.js +65 -0
- package/dist/__tests__/smoke/production.smoke.test.js.map +1 -0
- package/dist/commands/bundle/bundler.d.ts +32 -0
- package/dist/commands/bundle/bundler.d.ts.map +1 -0
- package/dist/commands/bundle/bundler.js +569 -0
- package/dist/commands/bundle/bundler.js.map +1 -0
- package/dist/commands/bundle/index.d.ts +59 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/bundle/index.js +184 -0
- package/dist/commands/bundle/index.js.map +1 -0
- package/dist/commands/bundle/package-manager.d.ts +8 -0
- package/dist/commands/bundle/package-manager.d.ts.map +1 -0
- package/dist/commands/bundle/package-manager.js +220 -0
- package/dist/commands/bundle/package-manager.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/cache.d.ts +7 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +68 -0
- package/dist/commands/cache.js.map +1 -0
- package/dist/commands/push/index.d.ts +7 -0
- package/dist/commands/push/index.d.ts.map +1 -0
- package/dist/commands/push/index.js +247 -0
- package/dist/commands/push/index.js.map +1 -0
- package/dist/commands/push/types.d.ts +22 -0
- package/dist/commands/push/types.d.ts.map +1 -0
- package/dist/commands/push/types.js +2 -0
- package/dist/commands/push/types.js.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts +7 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.js +51 -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/execution.d.ts +14 -0
- package/dist/commands/run/execution.d.ts.map +1 -0
- package/dist/commands/run/execution.js +41 -0
- package/dist/commands/run/execution.js.map +1 -0
- package/dist/commands/run/index.d.ts +38 -0
- package/dist/commands/run/index.d.ts.map +1 -0
- package/dist/commands/run/index.js +154 -0
- package/dist/commands/run/index.js.map +1 -0
- package/dist/commands/run/types.d.ts +65 -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/utils.d.ts +29 -0
- package/dist/commands/run/utils.d.ts.map +1 -0
- package/dist/commands/run/utils.js +52 -0
- package/dist/commands/run/utils.js.map +1 -0
- package/dist/commands/run/validators.d.ts +33 -0
- package/dist/commands/run/validators.d.ts.map +1 -0
- package/dist/commands/run/validators.js +58 -0
- package/dist/commands/run/validators.js.map +1 -0
- package/dist/commands/simulate/env-loader.d.ts +19 -0
- package/dist/commands/simulate/env-loader.d.ts.map +1 -0
- package/dist/commands/simulate/env-loader.js +44 -0
- package/dist/commands/simulate/env-loader.js.map +1 -0
- package/dist/commands/simulate/index.d.ts +48 -0
- package/dist/commands/simulate/index.d.ts.map +1 -0
- package/dist/commands/simulate/index.js +113 -0
- package/dist/commands/simulate/index.js.map +1 -0
- package/dist/commands/simulate/jsdom-executor.d.ts +37 -0
- package/dist/commands/simulate/jsdom-executor.d.ts.map +1 -0
- package/dist/commands/simulate/jsdom-executor.js +137 -0
- package/dist/commands/simulate/jsdom-executor.js.map +1 -0
- package/dist/commands/simulate/node-executor.d.ts +28 -0
- package/dist/commands/simulate/node-executor.d.ts.map +1 -0
- package/dist/commands/simulate/node-executor.js +94 -0
- package/dist/commands/simulate/node-executor.js.map +1 -0
- package/dist/commands/simulate/simulator.d.ts +14 -0
- package/dist/commands/simulate/simulator.d.ts.map +1 -0
- package/dist/commands/simulate/simulator.js +163 -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 +20 -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/build-defaults.d.ts +49 -0
- package/dist/config/build-defaults.d.ts.map +1 -0
- package/dist/config/build-defaults.js +68 -0
- package/dist/config/build-defaults.js.map +1 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +15 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +81 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +153 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/utils.d.ts +101 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +235 -0
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validators.d.ts +52 -0
- package/dist/config/validators.d.ts.map +1 -0
- package/dist/config/validators.js +85 -0
- package/dist/config/validators.js.map +1 -0
- package/dist/core/asset-resolver.d.ts +34 -0
- package/dist/core/asset-resolver.d.ts.map +1 -0
- package/dist/core/asset-resolver.js +70 -0
- package/dist/core/asset-resolver.js.map +1 -0
- package/dist/core/build-cache.d.ts +23 -0
- package/dist/core/build-cache.d.ts.map +1 -0
- package/dist/core/build-cache.js +44 -0
- package/dist/core/build-cache.js.map +1 -0
- package/dist/core/cache-utils.d.ts +27 -0
- package/dist/core/cache-utils.d.ts.map +1 -0
- package/dist/core/cache-utils.js +60 -0
- package/dist/core/cache-utils.js.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +8 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/local-packages.d.ts +19 -0
- package/dist/core/local-packages.d.ts.map +1 -0
- package/dist/core/local-packages.js +60 -0
- package/dist/core/local-packages.js.map +1 -0
- package/dist/core/logger.d.ts +30 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +85 -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/core/tmp.d.ts +27 -0
- package/dist/core/tmp.d.ts.map +1 -0
- package/dist/core/tmp.js +36 -0
- package/dist/core/tmp.js.map +1 -0
- package/dist/core/utils.d.ts +10 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/core/utils.js +12 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/index.d.ts +20 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +633 -761
- package/dist/index.js.map +1 -1
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/main.d.ts +2 -0
- package/dist/runtime/main.d.ts.map +1 -0
- package/dist/runtime/main.js +268 -0
- package/dist/runtime/main.js.map +1 -0
- package/dist/runtime/runner.d.ts +20 -0
- package/dist/runtime/runner.d.ts.map +1 -0
- package/dist/runtime/runner.js +72 -0
- package/dist/runtime/runner.js.map +1 -0
- package/dist/runtime/serve.d.ts +19 -0
- package/dist/runtime/serve.d.ts.map +1 -0
- package/dist/runtime/serve.js +97 -0
- package/dist/runtime/serve.js.map +1 -0
- package/dist/schemas/index.d.ts +9 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +9 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/primitives.d.ts +37 -0
- package/dist/schemas/primitives.d.ts.map +1 -0
- package/dist/schemas/primitives.js +43 -0
- package/dist/schemas/primitives.js.map +1 -0
- package/dist/schemas/run.d.ts +23 -0
- package/dist/schemas/run.d.ts.map +1 -0
- package/dist/schemas/run.js +20 -0
- package/dist/schemas/run.js.map +1 -0
- package/dist/types/bundle.d.ts +141 -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 +38 -0
- package/dist/types/global.d.ts.map +1 -0
- package/dist/types/global.js +24 -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/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +27 -0
- package/dist/version.js.map +1 -0
- package/dist/walker.js +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs walkerOS flows using local runtime
|
|
5
|
+
*/
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { createCommandLogger, createTimer, getErrorMessage, } from '../../core/index.js';
|
|
8
|
+
import { validateMode, validateFlowFile, validatePort } from './validators.js';
|
|
9
|
+
import { prepareBundleForRun, isPreBuiltConfig } from './utils.js';
|
|
10
|
+
import { executeRunLocal } from './execution.js';
|
|
11
|
+
/**
|
|
12
|
+
* CLI command function for `walkeros run`
|
|
13
|
+
*
|
|
14
|
+
* @param mode - Run mode (collect | serve)
|
|
15
|
+
* @param options - Command options
|
|
16
|
+
*/
|
|
17
|
+
export async function runCommand(mode, options) {
|
|
18
|
+
const timer = createTimer();
|
|
19
|
+
timer.start();
|
|
20
|
+
const logger = createCommandLogger(options);
|
|
21
|
+
try {
|
|
22
|
+
// Step 1: Validate inputs
|
|
23
|
+
validateMode(mode);
|
|
24
|
+
const configPath = validateFlowFile(options.config);
|
|
25
|
+
if (options.port !== undefined) {
|
|
26
|
+
validatePort(options.port);
|
|
27
|
+
}
|
|
28
|
+
// Step 2: Determine if config is pre-built or needs bundling
|
|
29
|
+
const isPreBuilt = isPreBuiltConfig(configPath);
|
|
30
|
+
let flowPath = null;
|
|
31
|
+
if (mode === 'collect') {
|
|
32
|
+
if (isPreBuilt) {
|
|
33
|
+
// Use pre-built bundle directly
|
|
34
|
+
flowPath = path.resolve(configPath);
|
|
35
|
+
logger.debug(`Using pre-built flow: ${path.basename(flowPath)}`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// Bundle JSON config first
|
|
39
|
+
logger.debug('Building flow bundle');
|
|
40
|
+
flowPath = await prepareBundleForRun(configPath, {
|
|
41
|
+
verbose: options.verbose,
|
|
42
|
+
silent: options.json || options.silent,
|
|
43
|
+
});
|
|
44
|
+
logger.debug('Bundle ready');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Step 3: Execute locally
|
|
48
|
+
// Handle dry-run
|
|
49
|
+
if (options.dryRun) {
|
|
50
|
+
logger.log(`[DRY-RUN] Would execute locally: run ${mode}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// Execute locally using runtime module
|
|
54
|
+
const modeLabel = mode === 'collect' ? 'Collector' : 'Server';
|
|
55
|
+
logger.log(`Starting ${modeLabel}...`);
|
|
56
|
+
await executeRunLocal(mode, flowPath, {
|
|
57
|
+
port: options.port,
|
|
58
|
+
host: options.host,
|
|
59
|
+
serveName: options.serveName,
|
|
60
|
+
servePath: options.servePath,
|
|
61
|
+
});
|
|
62
|
+
// Note: Server runs forever, so we won't reach here unless it fails
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
const duration = timer.getElapsed() / 1000;
|
|
66
|
+
const errorMessage = getErrorMessage(error);
|
|
67
|
+
if (options.json) {
|
|
68
|
+
logger.json({
|
|
69
|
+
success: false,
|
|
70
|
+
mode,
|
|
71
|
+
error: errorMessage,
|
|
72
|
+
duration,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
logger.error(`Error: ${errorMessage}`);
|
|
77
|
+
}
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Programmatic run function
|
|
83
|
+
*
|
|
84
|
+
* @param mode - Run mode (collect | serve)
|
|
85
|
+
* @param options - Run options
|
|
86
|
+
* @returns Run result
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Run with JSON config (bundles automatically)
|
|
91
|
+
* await run('collect', {
|
|
92
|
+
* config: './flow.json',
|
|
93
|
+
* port: 8080
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // Run with pre-built bundle
|
|
97
|
+
* await run('collect', {
|
|
98
|
+
* config: './flow.mjs',
|
|
99
|
+
* port: 8080
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export async function run(mode, options) {
|
|
104
|
+
const startTime = Date.now();
|
|
105
|
+
try {
|
|
106
|
+
// Validate inputs
|
|
107
|
+
validateMode(mode);
|
|
108
|
+
let flowFile;
|
|
109
|
+
if (typeof options.config === 'string') {
|
|
110
|
+
flowFile = validateFlowFile(options.config);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new Error('Programmatic run() requires config file path');
|
|
114
|
+
}
|
|
115
|
+
if (options.port !== undefined) {
|
|
116
|
+
validatePort(options.port);
|
|
117
|
+
}
|
|
118
|
+
// Determine if config is pre-built or needs bundling
|
|
119
|
+
const isPreBuilt = isPreBuiltConfig(flowFile);
|
|
120
|
+
let flowPath;
|
|
121
|
+
if (isPreBuilt) {
|
|
122
|
+
flowPath = path.resolve(flowFile);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
// Bundle JSON config
|
|
126
|
+
flowPath = await prepareBundleForRun(flowFile, {
|
|
127
|
+
verbose: options.verbose,
|
|
128
|
+
silent: true,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
// Run the flow using local runtime
|
|
132
|
+
await executeRunLocal(mode, flowPath, {
|
|
133
|
+
port: options.port,
|
|
134
|
+
host: options.host,
|
|
135
|
+
serveName: options.serveName,
|
|
136
|
+
servePath: options.servePath,
|
|
137
|
+
});
|
|
138
|
+
// Success (though server runs forever, so we typically don't reach here)
|
|
139
|
+
return {
|
|
140
|
+
success: true,
|
|
141
|
+
exitCode: 0,
|
|
142
|
+
duration: Date.now() - startTime,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
return {
|
|
147
|
+
success: false,
|
|
148
|
+
exitCode: 1,
|
|
149
|
+
duration: Date.now() - startTime,
|
|
150
|
+
error: getErrorMessage(error),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/run/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQjD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAY,EACZ,OAA0B;IAE1B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;IAC5B,KAAK,CAAC,KAAK,EAAE,CAAC;IAEd,MAAM,MAAM,GAAG,mBAAmB,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
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Run mode - determines which execution mode to use
|
|
8
|
+
*/
|
|
9
|
+
export type RunMode = 'collect' | 'serve';
|
|
10
|
+
/**
|
|
11
|
+
* CLI command options for `walkeros run`
|
|
12
|
+
*/
|
|
13
|
+
export interface RunCommandOptions {
|
|
14
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
15
|
+
config: string;
|
|
16
|
+
/** Server port (overrides flow config) */
|
|
17
|
+
port?: number;
|
|
18
|
+
/** Server host (default: 0.0.0.0) */
|
|
19
|
+
host?: string;
|
|
20
|
+
/** Serve path (URL directory path, e.g., 'libs/v1') */
|
|
21
|
+
servePath?: string;
|
|
22
|
+
/** Serve name (filename in URL, default: walker.js) */
|
|
23
|
+
serveName?: string;
|
|
24
|
+
/** Enable JSON output */
|
|
25
|
+
json?: boolean;
|
|
26
|
+
/** Verbose logging */
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
/** Dry-run mode */
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
/** Suppress output */
|
|
31
|
+
silent?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Programmatic run options (subset of CLI options)
|
|
35
|
+
*/
|
|
36
|
+
export interface RunOptions {
|
|
37
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
38
|
+
config: string | unknown;
|
|
39
|
+
/** Server port */
|
|
40
|
+
port?: number;
|
|
41
|
+
/** Server host */
|
|
42
|
+
host?: string;
|
|
43
|
+
/** Serve path (URL directory path, e.g., 'libs/v1') */
|
|
44
|
+
servePath?: string;
|
|
45
|
+
/** Serve name (filename in URL, default: walker.js) */
|
|
46
|
+
serveName?: string;
|
|
47
|
+
/** Suppress output */
|
|
48
|
+
silent?: boolean;
|
|
49
|
+
/** Verbose logging */
|
|
50
|
+
verbose?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Result from running a flow
|
|
54
|
+
*/
|
|
55
|
+
export interface RunResult {
|
|
56
|
+
/** Whether the flow ran successfully */
|
|
57
|
+
success: boolean;
|
|
58
|
+
/** Exit code */
|
|
59
|
+
exitCode: number;
|
|
60
|
+
/** Error message if failed */
|
|
61
|
+
error?: string;
|
|
62
|
+
/** Execution duration in milliseconds */
|
|
63
|
+
duration: number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/run/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,mBAAmB;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,sBAAsB;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEzB,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sBAAsB;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IAEjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/run/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for the run command
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Prepares a JSON config file for execution by bundling it to a temporary location.
|
|
8
|
+
*
|
|
9
|
+
* Creates bundle in .tmp/ directory relative to config file (not /tmp)
|
|
10
|
+
* so Node.js module resolution finds node_modules.
|
|
11
|
+
*
|
|
12
|
+
* @param configPath - Path to the JSON configuration file
|
|
13
|
+
* @param options - Bundle options
|
|
14
|
+
* @param options.verbose - Enable verbose logging
|
|
15
|
+
* @param options.silent - Suppress output
|
|
16
|
+
* @returns Path to the bundled output file
|
|
17
|
+
*/
|
|
18
|
+
export declare function prepareBundleForRun(configPath: string, options: {
|
|
19
|
+
verbose?: boolean;
|
|
20
|
+
silent?: boolean;
|
|
21
|
+
}): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a config file is pre-built or needs bundling
|
|
24
|
+
*
|
|
25
|
+
* @param configPath - Path to configuration file
|
|
26
|
+
* @returns True if file is pre-built (js/mjs/cjs), false if needs bundling (json)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isPreBuiltConfig(configPath: string): boolean;
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commands/run/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAM5D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for the run command
|
|
5
|
+
*/
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
import { bundle } from '../bundle/index.js';
|
|
9
|
+
/**
|
|
10
|
+
* Prepares a JSON config file for execution by bundling it to a temporary location.
|
|
11
|
+
*
|
|
12
|
+
* Creates bundle in .tmp/ directory relative to config file (not /tmp)
|
|
13
|
+
* so Node.js module resolution finds node_modules.
|
|
14
|
+
*
|
|
15
|
+
* @param configPath - Path to the JSON configuration file
|
|
16
|
+
* @param options - Bundle options
|
|
17
|
+
* @param options.verbose - Enable verbose logging
|
|
18
|
+
* @param options.silent - Suppress output
|
|
19
|
+
* @returns Path to the bundled output file
|
|
20
|
+
*/
|
|
21
|
+
export async function prepareBundleForRun(configPath, options) {
|
|
22
|
+
// Create temp directory relative to config (ensures node_modules is findable)
|
|
23
|
+
const configDir = path.dirname(path.resolve(configPath));
|
|
24
|
+
const tempDir = path.join(configDir, '.tmp', `run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`);
|
|
25
|
+
await fs.ensureDir(tempDir);
|
|
26
|
+
// Generate output path in temp directory
|
|
27
|
+
const tempPath = path.join(tempDir, 'bundle.mjs');
|
|
28
|
+
// Bundle with proper output override
|
|
29
|
+
await bundle(configPath, {
|
|
30
|
+
cache: true,
|
|
31
|
+
verbose: options.verbose,
|
|
32
|
+
silent: options.silent,
|
|
33
|
+
buildOverrides: {
|
|
34
|
+
output: tempPath,
|
|
35
|
+
format: 'esm',
|
|
36
|
+
platform: 'node',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return tempPath;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks if a config file is pre-built or needs bundling
|
|
43
|
+
*
|
|
44
|
+
* @param configPath - Path to configuration file
|
|
45
|
+
* @returns True if file is pre-built (js/mjs/cjs), false if needs bundling (json)
|
|
46
|
+
*/
|
|
47
|
+
export function isPreBuiltConfig(configPath) {
|
|
48
|
+
return (configPath.endsWith('.mjs') ||
|
|
49
|
+
configPath.endsWith('.js') ||
|
|
50
|
+
configPath.endsWith('.cjs'));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/commands/run/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,OAGC;IAED,8EAA8E;IAC9E,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CACvB,SAAS,EACT,MAAM,EACN,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAC9D,CAAC;IACF,MAAM,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAE5B,yCAAyC;IACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAElD,qCAAqC;IACrC,MAAM,MAAM,CAAC,UAAU,EAAE;QACvB,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,cAAc,EAAE;YACd,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,MAAM;SACjB;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,UAAkB;IACjD,OAAO,CACL,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC3B,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC1B,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Validators
|
|
3
|
+
*
|
|
4
|
+
* Validation logic for run command inputs.
|
|
5
|
+
* Uses Zod schemas for type-safe validation.
|
|
6
|
+
*/
|
|
7
|
+
import { type RunMode } from '../../schemas/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Validates run mode using Zod schema.
|
|
10
|
+
*
|
|
11
|
+
* @param mode - Mode to validate
|
|
12
|
+
* @throws Error if mode is invalid
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateMode(mode: string): asserts mode is RunMode;
|
|
15
|
+
/**
|
|
16
|
+
* Validates flow file exists.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* File existence cannot be validated by Zod, so this remains a custom check.
|
|
20
|
+
*
|
|
21
|
+
* @param filePath - Path to flow configuration file (bare name, relative, or absolute)
|
|
22
|
+
* @returns Absolute path to flow file
|
|
23
|
+
* @throws Error if file doesn't exist
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateFlowFile(filePath: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Validates port number using Zod schema.
|
|
28
|
+
*
|
|
29
|
+
* @param port - Port number to validate
|
|
30
|
+
* @throws Error if port is invalid
|
|
31
|
+
*/
|
|
32
|
+
export declare function validatePort(port: number): void;
|
|
33
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/commands/run/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAGL,KAAK,OAAO,EACb,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CASlE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAazD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAS/C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Validators
|
|
3
|
+
*
|
|
4
|
+
* Validation logic for run command inputs.
|
|
5
|
+
* Uses Zod schemas for type-safe validation.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { resolveAsset } from '../../core/asset-resolver.js';
|
|
9
|
+
import { RunModeSchema, PortSchema, } from '../../schemas/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Validates run mode using Zod schema.
|
|
12
|
+
*
|
|
13
|
+
* @param mode - Mode to validate
|
|
14
|
+
* @throws Error if mode is invalid
|
|
15
|
+
*/
|
|
16
|
+
export function validateMode(mode) {
|
|
17
|
+
const result = RunModeSchema.safeParse(mode);
|
|
18
|
+
if (!result.success) {
|
|
19
|
+
throw new Error(`Invalid mode: "${mode}"\n` +
|
|
20
|
+
` Valid modes: collect, serve\n` +
|
|
21
|
+
` Example: walkeros run collect ./flow.json`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Validates flow file exists.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* File existence cannot be validated by Zod, so this remains a custom check.
|
|
29
|
+
*
|
|
30
|
+
* @param filePath - Path to flow configuration file (bare name, relative, or absolute)
|
|
31
|
+
* @returns Absolute path to flow file
|
|
32
|
+
* @throws Error if file doesn't exist
|
|
33
|
+
*/
|
|
34
|
+
export function validateFlowFile(filePath) {
|
|
35
|
+
// Use asset resolver to handle bare names, relative paths, and absolute paths
|
|
36
|
+
const absolutePath = resolveAsset(filePath, 'bundle');
|
|
37
|
+
if (!existsSync(absolutePath)) {
|
|
38
|
+
throw new Error(`Flow file not found: ${filePath}\n` +
|
|
39
|
+
` Resolved path: ${absolutePath}\n` +
|
|
40
|
+
` Make sure the file exists and the path is correct`);
|
|
41
|
+
}
|
|
42
|
+
return absolutePath;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validates port number using Zod schema.
|
|
46
|
+
*
|
|
47
|
+
* @param port - Port number to validate
|
|
48
|
+
* @throws Error if port is invalid
|
|
49
|
+
*/
|
|
50
|
+
export function validatePort(port) {
|
|
51
|
+
const result = PortSchema.safeParse(port);
|
|
52
|
+
if (!result.success) {
|
|
53
|
+
throw new Error(`Invalid port: ${port}\n` +
|
|
54
|
+
` Port must be an integer between 1 and 65535\n` +
|
|
55
|
+
` Example: --port 8080`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/commands/run/validators.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,UAAU,GAEX,MAAM,wBAAwB,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,KAAK;YACzB,kCAAkC;YAClC,8CAA8C,CACjD,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,8EAA8E;IAC9E,MAAM,YAAY,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEtD,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAQ,IAAI;YAClC,qBAAqB,YAAY,IAAI;YACrC,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,IAAI;YACvB,kDAAkD;YAClD,yBAAyB,CAC5B,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface DestinationEnv {
|
|
2
|
+
init?: Record<string, unknown>;
|
|
3
|
+
push: Record<string, unknown>;
|
|
4
|
+
simulation?: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Dynamically loads env examples from destination packages.
|
|
8
|
+
*
|
|
9
|
+
* Imports from `/dev` subpath (e.g., '@walkeros/web-destination-gtag/dev')
|
|
10
|
+
* and extracts the `env` object which contains:
|
|
11
|
+
* - push: Mock environment with API functions (gtag, fbq, etc.)
|
|
12
|
+
* - simulation: Array of tracking paths for call verification
|
|
13
|
+
*
|
|
14
|
+
* @param destinations - Destination configuration from flow config
|
|
15
|
+
* @returns Map of destination key to env object
|
|
16
|
+
*/
|
|
17
|
+
export declare function loadDestinationEnvs(destinations: Record<string, unknown>): Promise<Record<string, DestinationEnv>>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=env-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-loader.d.ts","sourceRoot":"","sources":["../../../src/commands/simulate/env-loader.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAOD;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAqCzC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically loads env examples from destination packages.
|
|
3
|
+
*
|
|
4
|
+
* Imports from `/dev` subpath (e.g., '@walkeros/web-destination-gtag/dev')
|
|
5
|
+
* and extracts the `env` object which contains:
|
|
6
|
+
* - push: Mock environment with API functions (gtag, fbq, etc.)
|
|
7
|
+
* - simulation: Array of tracking paths for call verification
|
|
8
|
+
*
|
|
9
|
+
* @param destinations - Destination configuration from flow config
|
|
10
|
+
* @returns Map of destination key to env object
|
|
11
|
+
*/
|
|
12
|
+
export async function loadDestinationEnvs(destinations) {
|
|
13
|
+
const envs = {};
|
|
14
|
+
for (const [destKey, destConfig] of Object.entries(destinations)) {
|
|
15
|
+
const typedConfig = destConfig;
|
|
16
|
+
// Skip if no package field
|
|
17
|
+
if (!typedConfig.package) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
// Determine import path
|
|
22
|
+
const packageName = typedConfig.package;
|
|
23
|
+
const isDemoPackage = packageName.includes('-demo');
|
|
24
|
+
const importPath = isDemoPackage ? packageName : `${packageName}/dev`;
|
|
25
|
+
// Dynamic import
|
|
26
|
+
const module = await import(importPath);
|
|
27
|
+
// Extract env from examples
|
|
28
|
+
const examplesModule = module.examples || module.default?.examples;
|
|
29
|
+
const envModule = examplesModule?.env;
|
|
30
|
+
if (envModule?.push) {
|
|
31
|
+
envs[destKey] = {
|
|
32
|
+
init: envModule.init,
|
|
33
|
+
push: envModule.push,
|
|
34
|
+
simulation: envModule.simulation || [],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Silently skip destinations without env or invalid packages
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return envs;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=env-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-loader.js","sourceRoot":"","sources":["../../../src/commands/simulate/env-loader.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,YAAqC;IAErC,MAAM,IAAI,GAAmC,EAAE,CAAC;IAEhD,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;QACjE,MAAM,WAAW,GAAG,UAA+B,CAAC;QAEpD,2BAA2B;QAC3B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,SAAS;QACX,CAAC;QAED,IAAI,CAAC;YACH,wBAAwB;YACxB,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC;YACxC,MAAM,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACpD,MAAM,UAAU,GAAG,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,MAAM,CAAC;YAEtE,iBAAiB;YACjB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;YAExC,4BAA4B;YAC5B,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC;YACnE,MAAM,SAAS,GAAG,cAAc,EAAE,GAAG,CAAC;YAEtC,IAAI,SAAS,EAAE,IAAI,EAAE,CAAC;gBACpB,IAAI,CAAC,OAAO,CAAC,GAAG;oBACd,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,IAAI,EAAE,SAAS,CAAC,IAAI;oBACpB,UAAU,EAAE,SAAS,CAAC,UAAU,IAAI,EAAE;iBACvC,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,6DAA6D;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SimulateCommandOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* CLI command handler for simulate command
|
|
4
|
+
*/
|
|
5
|
+
export declare function simulateCommand(options: SimulateCommandOptions): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* High-level simulate function for programmatic usage.
|
|
8
|
+
*
|
|
9
|
+
* Handles configuration loading internally and returns structured results.
|
|
10
|
+
*
|
|
11
|
+
* @param configOrPath - Bundle configuration object or path to config file
|
|
12
|
+
* @param event - Event object to simulate
|
|
13
|
+
* @param options - Simulation options
|
|
14
|
+
* @param options.silent - Suppress all output (default: false)
|
|
15
|
+
* @param options.verbose - Enable verbose logging (default: false)
|
|
16
|
+
* @param options.json - Format output as JSON (default: false)
|
|
17
|
+
* @returns Simulation result with success status, elb result, and usage data
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // With config file
|
|
22
|
+
* const result = await simulate('./walker.config.json', {
|
|
23
|
+
* name: 'page view',
|
|
24
|
+
* data: { title: 'Home Page', path: '/', url: 'https://example.com' }
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // With config object
|
|
28
|
+
* const result = await simulate(
|
|
29
|
+
* {
|
|
30
|
+
* platform: 'web',
|
|
31
|
+
* packages: { '@walkeros/collector': { imports: ['startFlow'] } },
|
|
32
|
+
* code: '...',
|
|
33
|
+
* output: './bundle.js'
|
|
34
|
+
* },
|
|
35
|
+
* { name: 'page view' },
|
|
36
|
+
* { silent: true }
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function simulate(configOrPath: string | unknown, event: unknown, options?: {
|
|
41
|
+
silent?: boolean;
|
|
42
|
+
verbose?: boolean;
|
|
43
|
+
json?: boolean;
|
|
44
|
+
}): Promise<import('./types').SimulationResult>;
|
|
45
|
+
export * from './types.js';
|
|
46
|
+
export * from './simulator.js';
|
|
47
|
+
export { executeInNode } from './node-executor.js';
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/simulate/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Df;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,MAAM,GAAG,OAAO,EAC9B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CACX,GACL,OAAO,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,CAgB7C;AAGD,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|