@walkeros/cli 0.5.1-next.0 → 0.7.0-next.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 +19 -0
- 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 +353 -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 +130 -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 +180 -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 +72 -0
- package/dist/__tests__/core/config.test.js.map +1 -0
- package/dist/__tests__/core/docker-url.test.d.ts +2 -0
- package/dist/__tests__/core/docker-url.test.d.ts.map +1 -0
- package/dist/__tests__/core/docker-url.test.js +54 -0
- package/dist/__tests__/core/docker-url.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 +583 -0
- package/dist/commands/bundle/bundler.js.map +1 -0
- package/dist/commands/bundle/index.d.ts +57 -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 +8 -0
- package/dist/commands/bundle/package-manager.d.ts.map +1 -0
- package/dist/commands/bundle/package-manager.js +197 -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 +3 -0
- package/dist/commands/cache.d.ts.map +1 -0
- package/dist/commands/cache.js +44 -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 +257 -0
- package/dist/commands/push/index.js.map +1 -0
- package/dist/commands/push/types.d.ts +21 -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 +8 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.js +52 -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 +39 -0
- package/dist/commands/run/index.d.ts.map +1 -0
- package/dist/commands/run/index.js +191 -0
- package/dist/commands/run/index.js.map +1 -0
- package/dist/commands/run/types.d.ts +60 -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 +46 -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 +116 -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 +162 -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/build-defaults.d.ts +49 -0
- package/dist/config/build-defaults.d.ts.map +1 -0
- package/dist/config/build-defaults.js +70 -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 +155 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/utils.d.ts +114 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +257 -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 +43 -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/docker.d.ts +102 -0
- package/dist/core/docker.d.ts.map +1 -0
- package/dist/core/docker.js +278 -0
- package/dist/core/docker.js.map +1 -0
- package/dist/core/execution.d.ts +34 -0
- package/dist/core/execution.d.ts.map +1 -0
- package/dist/core/execution.js +64 -0
- package/dist/core/execution.js.map +1 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +10 -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 +28 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +88 -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/temp-manager.d.ts +51 -0
- package/dist/core/temp-manager.d.ts.map +1 -0
- package/dist/core/temp-manager.js +73 -0
- package/dist/core/temp-manager.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/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.map +1 -0
- package/dist/index.js +128 -96
- package/dist/index.js.map +1 -1
- 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 +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/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 +2 -2
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs walkerOS flows using @walkeros/docker as a library
|
|
5
|
+
* No Docker daemon required - runs directly in Node.js
|
|
6
|
+
*/
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { createCommandLogger, createTimer, getExecutionMode, getErrorMessage, executeRunInDocker, isDockerAvailable, } from '../../core/index.js';
|
|
9
|
+
import { validateMode, validateFlowFile, validatePort } from './validators.js';
|
|
10
|
+
import { prepareBundleForRun, isPreBuiltConfig } from './utils.js';
|
|
11
|
+
import { executeRunLocal } from './execution.js';
|
|
12
|
+
/**
|
|
13
|
+
* CLI command function for `walkeros run`
|
|
14
|
+
*
|
|
15
|
+
* @param mode - Run mode (collect | serve)
|
|
16
|
+
* @param options - Command options
|
|
17
|
+
*/
|
|
18
|
+
export async function runCommand(mode, options) {
|
|
19
|
+
const timer = createTimer();
|
|
20
|
+
timer.start();
|
|
21
|
+
const logger = createCommandLogger(options);
|
|
22
|
+
try {
|
|
23
|
+
// Step 1: Validate inputs
|
|
24
|
+
validateMode(mode);
|
|
25
|
+
const configPath = validateFlowFile(options.config);
|
|
26
|
+
if (options.port !== undefined) {
|
|
27
|
+
validatePort(options.port);
|
|
28
|
+
}
|
|
29
|
+
// Step 2: Determine if config is pre-built or needs bundling
|
|
30
|
+
const isPreBuilt = isPreBuiltConfig(configPath);
|
|
31
|
+
let flowPath = null;
|
|
32
|
+
if (mode === 'collect') {
|
|
33
|
+
if (isPreBuilt) {
|
|
34
|
+
// Use pre-built bundle directly
|
|
35
|
+
flowPath = path.resolve(configPath);
|
|
36
|
+
if (!options.json && !options.silent) {
|
|
37
|
+
logger.info(`📦 Using pre-built flow: ${path.basename(flowPath)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Bundle JSON config first
|
|
42
|
+
if (!options.json && !options.silent) {
|
|
43
|
+
logger.info('🔨 Building flow bundle...');
|
|
44
|
+
}
|
|
45
|
+
flowPath = await prepareBundleForRun(configPath, {
|
|
46
|
+
verbose: options.verbose,
|
|
47
|
+
silent: options.json || options.silent,
|
|
48
|
+
});
|
|
49
|
+
if (!options.json && !options.silent) {
|
|
50
|
+
logger.success('✅ Bundle ready');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Step 3: Execute based on mode
|
|
55
|
+
const executionMode = getExecutionMode(options);
|
|
56
|
+
// Handle dry-run
|
|
57
|
+
if (options.dryRun) {
|
|
58
|
+
if (executionMode === 'docker') {
|
|
59
|
+
logger.info(`[DRY-RUN] Would execute in Docker: run ${mode} with runtime image`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
logger.info(`[DRY-RUN] Would execute locally: run ${mode}`);
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (executionMode === 'docker') {
|
|
67
|
+
// Docker mode: Use production runtime image
|
|
68
|
+
const dockerAvailable = await isDockerAvailable();
|
|
69
|
+
if (!dockerAvailable) {
|
|
70
|
+
throw new Error('Docker is not available. Please install Docker or use --local flag to execute locally.');
|
|
71
|
+
}
|
|
72
|
+
if (!options.json && !options.silent) {
|
|
73
|
+
logger.info('🐳 Executing in production runtime container...');
|
|
74
|
+
}
|
|
75
|
+
await executeRunInDocker(mode, flowPath, {
|
|
76
|
+
port: options.port,
|
|
77
|
+
host: options.host,
|
|
78
|
+
serveName: options.serveName,
|
|
79
|
+
servePath: options.servePath,
|
|
80
|
+
silent: options.silent,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// Local mode: Use library functions
|
|
85
|
+
if (!options.json && !options.silent) {
|
|
86
|
+
const modeLabel = mode === 'collect' ? 'Collector' : 'Server';
|
|
87
|
+
logger.info(`🖥️ Starting ${modeLabel} locally...`);
|
|
88
|
+
}
|
|
89
|
+
await executeRunLocal(mode, flowPath, {
|
|
90
|
+
port: options.port,
|
|
91
|
+
host: options.host,
|
|
92
|
+
serveName: options.serveName,
|
|
93
|
+
servePath: options.servePath,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Note: Both Docker and local modes run forever, so we won't reach here unless they fail
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const duration = timer.getElapsed() / 1000;
|
|
100
|
+
const errorMessage = getErrorMessage(error);
|
|
101
|
+
if (options.json) {
|
|
102
|
+
const output = {
|
|
103
|
+
success: false,
|
|
104
|
+
mode,
|
|
105
|
+
error: errorMessage,
|
|
106
|
+
duration,
|
|
107
|
+
};
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.log(JSON.stringify(output, null, 2));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
logger.error('❌ Run failed:');
|
|
113
|
+
logger.error(errorMessage);
|
|
114
|
+
}
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Programmatic run function
|
|
120
|
+
*
|
|
121
|
+
* @param mode - Run mode (collect | serve)
|
|
122
|
+
* @param options - Run options
|
|
123
|
+
* @returns Run result
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* // Run with JSON config (bundles automatically)
|
|
128
|
+
* await run('collect', {
|
|
129
|
+
* config: './flow.json',
|
|
130
|
+
* port: 8080
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* // Run with pre-built bundle
|
|
134
|
+
* await run('collect', {
|
|
135
|
+
* config: './flow.mjs',
|
|
136
|
+
* port: 8080
|
|
137
|
+
* });
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export async function run(mode, options) {
|
|
141
|
+
const startTime = Date.now();
|
|
142
|
+
try {
|
|
143
|
+
// Validate inputs
|
|
144
|
+
validateMode(mode);
|
|
145
|
+
let flowFile;
|
|
146
|
+
if (typeof options.config === 'string') {
|
|
147
|
+
flowFile = validateFlowFile(options.config);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw new Error('Programmatic run() requires config file path');
|
|
151
|
+
}
|
|
152
|
+
if (options.port !== undefined) {
|
|
153
|
+
validatePort(options.port);
|
|
154
|
+
}
|
|
155
|
+
// Determine if config is pre-built or needs bundling
|
|
156
|
+
const isPreBuilt = isPreBuiltConfig(flowFile);
|
|
157
|
+
let flowPath;
|
|
158
|
+
if (isPreBuilt) {
|
|
159
|
+
flowPath = path.resolve(flowFile);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// Bundle JSON config
|
|
163
|
+
flowPath = await prepareBundleForRun(flowFile, {
|
|
164
|
+
verbose: options.verbose,
|
|
165
|
+
silent: true,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
// Run the flow using Docker package
|
|
169
|
+
await executeRunLocal(mode, flowPath, {
|
|
170
|
+
port: options.port,
|
|
171
|
+
host: options.host,
|
|
172
|
+
serveName: options.serveName,
|
|
173
|
+
servePath: options.servePath,
|
|
174
|
+
});
|
|
175
|
+
// Success (though runFlow runs forever, so we typically don't reach here)
|
|
176
|
+
return {
|
|
177
|
+
success: true,
|
|
178
|
+
exitCode: 0,
|
|
179
|
+
duration: Date.now() - startTime,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
exitCode: 1,
|
|
186
|
+
duration: Date.now() - startTime,
|
|
187
|
+
error: getErrorMessage(error),
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/run/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,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,CAAC,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC;QACH,0BAA0B;QAC1B,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEpD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;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qD;QACrD,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,QAAgB,CAAC;QAErB,IAAI,UAAU,EAAE,CAAC;YACf,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,qBAAqB;YACrB,QAAQ,GAAG,MAAM,mBAAmB,CAAC,QAAQ,EAAE;gBAC7C,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;QACL,CAAC;QAED,oCAAoC;QACpC,MAAM,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;SAC7B,CAAC,CAAC;QAEH,0EAA0E;QAC1E,OAAO;YACL,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;SACjC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,CAAC;YACX,QAAQ,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;YAChC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC;SAC9B,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Types
|
|
3
|
+
*
|
|
4
|
+
* Types for running walkerOS flows via CLI using @walkeros/docker as a library
|
|
5
|
+
*/
|
|
6
|
+
import type { GlobalOptions } from '../../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Run mode - determines which execution mode to use
|
|
9
|
+
*/
|
|
10
|
+
export type RunMode = 'collect' | 'serve';
|
|
11
|
+
/**
|
|
12
|
+
* CLI command options for `walkeros run`
|
|
13
|
+
*/
|
|
14
|
+
export interface RunCommandOptions extends GlobalOptions {
|
|
15
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
16
|
+
config: string;
|
|
17
|
+
/** Server port (overrides flow config) */
|
|
18
|
+
port?: number;
|
|
19
|
+
/** Server host (default: 0.0.0.0) */
|
|
20
|
+
host?: string;
|
|
21
|
+
/** Serve path (URL directory path, e.g., 'libs/v1') */
|
|
22
|
+
servePath?: string;
|
|
23
|
+
/** Serve name (filename in URL, default: walker.js) */
|
|
24
|
+
serveName?: string;
|
|
25
|
+
/** Enable JSON output */
|
|
26
|
+
json?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Programmatic run options (subset of CLI options)
|
|
30
|
+
*/
|
|
31
|
+
export interface RunOptions {
|
|
32
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
33
|
+
config: string | unknown;
|
|
34
|
+
/** Server port */
|
|
35
|
+
port?: number;
|
|
36
|
+
/** Server host */
|
|
37
|
+
host?: string;
|
|
38
|
+
/** Serve path (URL directory path, e.g., 'libs/v1') */
|
|
39
|
+
servePath?: string;
|
|
40
|
+
/** Serve name (filename in URL, default: walker.js) */
|
|
41
|
+
serveName?: string;
|
|
42
|
+
/** Suppress output */
|
|
43
|
+
silent?: boolean;
|
|
44
|
+
/** Verbose logging */
|
|
45
|
+
verbose?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Result from running a flow
|
|
49
|
+
*/
|
|
50
|
+
export interface RunResult {
|
|
51
|
+
/** Whether the flow ran successfully */
|
|
52
|
+
success: boolean;
|
|
53
|
+
/** Exit code */
|
|
54
|
+
exitCode: number;
|
|
55
|
+
/** Error message if failed */
|
|
56
|
+
error?: string;
|
|
57
|
+
/** Execution duration in milliseconds */
|
|
58
|
+
duration: number;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=types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E,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,CAyCzC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 (error) {
|
|
39
|
+
// Silently skip destinations without env or invalid packages
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.warn(`Warning: Could not load env for destination "${destKey}": ${error instanceof Error ? error.message : String(error)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return envs;
|
|
45
|
+
}
|
|
46
|
+
//# 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,OAAO,KAAK,EAAE,CAAC;YACf,6DAA6D;YAC7D,sCAAsC;YACtC,OAAO,CAAC,IAAI,CACV,gDAAgD,OAAO,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACtH,CAAC;QACJ,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":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAyEf;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"}
|