@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
package/dist/index.js
CHANGED
|
@@ -2,81 +2,100 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { Command } from "commander";
|
|
5
|
+
import chalk2 from "chalk";
|
|
6
|
+
|
|
7
|
+
// src/version.ts
|
|
5
8
|
import { readFileSync } from "fs";
|
|
6
|
-
import { fileURLToPath
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
7
10
|
import { dirname, join } from "path";
|
|
8
|
-
|
|
11
|
+
var versionFilename = fileURLToPath(import.meta.url);
|
|
12
|
+
var versionDirname = dirname(versionFilename);
|
|
13
|
+
function findPackageJson() {
|
|
14
|
+
const paths = [
|
|
15
|
+
join(versionDirname, "../package.json"),
|
|
16
|
+
// dist/ or src/
|
|
17
|
+
join(versionDirname, "../../package.json")
|
|
18
|
+
// src/core/ (not used, but safe)
|
|
19
|
+
];
|
|
20
|
+
for (const p of paths) {
|
|
21
|
+
try {
|
|
22
|
+
return readFileSync(p, "utf-8");
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return JSON.stringify({ version: "0.0.0" });
|
|
27
|
+
}
|
|
28
|
+
var VERSION = JSON.parse(findPackageJson()).version;
|
|
9
29
|
|
|
10
30
|
// src/commands/bundle/index.ts
|
|
11
31
|
import path9 from "path";
|
|
12
32
|
|
|
13
33
|
// src/core/logger.ts
|
|
14
34
|
import chalk from "chalk";
|
|
35
|
+
var BRAND_COLOR = "#01b5e2";
|
|
15
36
|
function createLogger(options = {}) {
|
|
16
37
|
const { verbose = false, silent = false, json = false } = options;
|
|
17
38
|
const shouldLog = !silent && !json;
|
|
18
39
|
const shouldDebug = verbose && !silent && !json;
|
|
19
40
|
return {
|
|
20
|
-
log: (
|
|
41
|
+
log: (...args) => {
|
|
21
42
|
if (shouldLog) {
|
|
22
43
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
23
|
-
|
|
24
|
-
red: chalk.red,
|
|
25
|
-
green: chalk.green,
|
|
26
|
-
blue: chalk.blue,
|
|
27
|
-
yellow: chalk.yellow,
|
|
28
|
-
gray: chalk.gray,
|
|
29
|
-
grey: chalk.gray,
|
|
30
|
-
cyan: chalk.cyan,
|
|
31
|
-
magenta: chalk.magenta,
|
|
32
|
-
white: chalk.white,
|
|
33
|
-
black: chalk.black
|
|
34
|
-
};
|
|
35
|
-
const colorFn = colorMap[color];
|
|
36
|
-
const coloredMessage = colorFn ? colorFn(message) : message;
|
|
37
|
-
console.log(coloredMessage);
|
|
44
|
+
console.log(message);
|
|
38
45
|
}
|
|
39
46
|
},
|
|
40
|
-
|
|
47
|
+
brand: (...args) => {
|
|
41
48
|
if (shouldLog) {
|
|
42
49
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
43
|
-
console.log(chalk.
|
|
50
|
+
console.log(chalk.hex(BRAND_COLOR)(message));
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
|
-
|
|
47
|
-
if (
|
|
53
|
+
error: (...args) => {
|
|
54
|
+
if (!json) {
|
|
48
55
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
49
|
-
console.
|
|
56
|
+
console.error(chalk.red(message));
|
|
50
57
|
}
|
|
51
58
|
},
|
|
52
|
-
|
|
59
|
+
debug: (...args) => {
|
|
60
|
+
if (shouldDebug) {
|
|
61
|
+
const message = args.map((arg) => String(arg)).join(" ");
|
|
62
|
+
console.log(` ${message}`);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
json: (data) => {
|
|
66
|
+
if (!silent) {
|
|
67
|
+
console.log(JSON.stringify(data, null, 2));
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
// Backward-compatible methods (all use default terminal color per design)
|
|
71
|
+
info: (...args) => {
|
|
53
72
|
if (shouldLog) {
|
|
54
73
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
55
|
-
console.log(
|
|
74
|
+
console.log(message);
|
|
56
75
|
}
|
|
57
76
|
},
|
|
58
|
-
|
|
77
|
+
success: (...args) => {
|
|
59
78
|
if (shouldLog) {
|
|
60
79
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
61
|
-
console.log(
|
|
80
|
+
console.log(message);
|
|
62
81
|
}
|
|
63
82
|
},
|
|
64
|
-
|
|
65
|
-
if (
|
|
83
|
+
warning: (...args) => {
|
|
84
|
+
if (shouldLog) {
|
|
66
85
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
67
|
-
console.
|
|
86
|
+
console.log(message);
|
|
68
87
|
}
|
|
69
88
|
},
|
|
70
|
-
|
|
71
|
-
if (
|
|
89
|
+
warn: (...args) => {
|
|
90
|
+
if (shouldLog) {
|
|
72
91
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
73
|
-
console.log(
|
|
92
|
+
console.log(message);
|
|
74
93
|
}
|
|
75
94
|
},
|
|
76
95
|
gray: (...args) => {
|
|
77
96
|
if (shouldLog) {
|
|
78
97
|
const message = args.map((arg) => String(arg)).join(" ");
|
|
79
|
-
console.log(
|
|
98
|
+
console.log(message);
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
101
|
};
|
|
@@ -132,15 +151,26 @@ function formatBytes(bytes) {
|
|
|
132
151
|
return (bytes / 1024).toFixed(2);
|
|
133
152
|
}
|
|
134
153
|
|
|
135
|
-
// src/core/
|
|
136
|
-
import
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
// src/core/tmp.ts
|
|
155
|
+
import path from "path";
|
|
156
|
+
var DEFAULT_TMP_ROOT = ".tmp";
|
|
157
|
+
function getTmpPath(tmpDir, ...segments) {
|
|
158
|
+
const root = tmpDir || DEFAULT_TMP_ROOT;
|
|
159
|
+
const absoluteRoot = path.isAbsolute(root) ? root : path.resolve(root);
|
|
160
|
+
return path.join(absoluteRoot, ...segments);
|
|
161
|
+
}
|
|
162
|
+
function getDefaultTmpRoot() {
|
|
163
|
+
return DEFAULT_TMP_ROOT;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// src/core/asset-resolver.ts
|
|
167
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
168
|
+
import { existsSync } from "fs";
|
|
169
|
+
import path3 from "path";
|
|
139
170
|
|
|
140
171
|
// src/config/utils.ts
|
|
141
172
|
import fs from "fs-extra";
|
|
142
|
-
import
|
|
143
|
-
import os from "os";
|
|
173
|
+
import path2 from "path";
|
|
144
174
|
function isUrl(str) {
|
|
145
175
|
try {
|
|
146
176
|
const url = new URL(str);
|
|
@@ -161,12 +191,9 @@ async function downloadFromUrl(url) {
|
|
|
161
191
|
);
|
|
162
192
|
}
|
|
163
193
|
const content = await response.text();
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
const
|
|
167
|
-
const randomId = Math.random().toString(36).substring(2, 11);
|
|
168
|
-
const filename = `walkeros-download-${Date.now()}-${randomId}${extension}`;
|
|
169
|
-
const tempPath = path.join(os.tmpdir(), filename);
|
|
194
|
+
const downloadsDir = getTmpPath(void 0, "downloads");
|
|
195
|
+
await fs.ensureDir(downloadsDir);
|
|
196
|
+
const tempPath = path2.join(downloadsDir, "flow.json");
|
|
170
197
|
await fs.writeFile(tempPath, content, "utf-8");
|
|
171
198
|
return tempPath;
|
|
172
199
|
} catch (error) {
|
|
@@ -183,7 +210,7 @@ async function loadJsonConfig(configPath) {
|
|
|
183
210
|
absolutePath = await downloadFromUrl(configPath);
|
|
184
211
|
isTemporary = true;
|
|
185
212
|
} else {
|
|
186
|
-
absolutePath =
|
|
213
|
+
absolutePath = path2.resolve(configPath);
|
|
187
214
|
if (!await fs.pathExists(absolutePath)) {
|
|
188
215
|
throw new Error(`Configuration file not found: ${absolutePath}`);
|
|
189
216
|
}
|
|
@@ -204,11 +231,6 @@ async function loadJsonConfig(configPath) {
|
|
|
204
231
|
}
|
|
205
232
|
}
|
|
206
233
|
}
|
|
207
|
-
function getTempDir(tempDir = ".tmp") {
|
|
208
|
-
const randomId = Math.random().toString(36).substring(2, 11);
|
|
209
|
-
const basePath = path.isAbsolute(tempDir) ? tempDir : path.join(process.cwd(), tempDir);
|
|
210
|
-
return path.join(basePath, `cli-${Date.now()}-${randomId}`);
|
|
211
|
-
}
|
|
212
234
|
async function loadJsonFromSource(source, options) {
|
|
213
235
|
const paramName = options?.name || "input";
|
|
214
236
|
if (!source || source.trim() === "") {
|
|
@@ -239,7 +261,7 @@ async function loadJsonFromSource(source, options) {
|
|
|
239
261
|
);
|
|
240
262
|
}
|
|
241
263
|
}
|
|
242
|
-
const resolvedPath =
|
|
264
|
+
const resolvedPath = path2.resolve(trimmedSource);
|
|
243
265
|
if (await fs.pathExists(resolvedPath)) {
|
|
244
266
|
try {
|
|
245
267
|
const data = await fs.readJson(resolvedPath);
|
|
@@ -263,193 +285,11 @@ async function loadJsonFromSource(source, options) {
|
|
|
263
285
|
}
|
|
264
286
|
}
|
|
265
287
|
|
|
266
|
-
// src/core/docker.ts
|
|
267
|
-
var CLI_VERSION = true ? "0.5.0" : "0.0.0";
|
|
268
|
-
var CLI_DOCKER_IMAGE = process.env.WALKEROS_CLI_DOCKER_IMAGE || `walkeros/cli:${CLI_VERSION}`;
|
|
269
|
-
var RUNTIME_DOCKER_IMAGE = process.env.WALKEROS_RUNTIME_DOCKER_IMAGE || `walkeros/docker:${DOCKER_VERSION}`;
|
|
270
|
-
function buildCommonDockerArgs(options) {
|
|
271
|
-
const args = [options.config];
|
|
272
|
-
if (options.json) args.push("--json");
|
|
273
|
-
if (options.verbose) args.push("--verbose");
|
|
274
|
-
if (options.silent) args.push("--silent");
|
|
275
|
-
return args;
|
|
276
|
-
}
|
|
277
|
-
function buildDockerCommand(command, args, options = {}, configFile) {
|
|
278
|
-
const cwd = process.cwd();
|
|
279
|
-
const cmd = ["docker", "run", "--rm"];
|
|
280
|
-
if (configFile && !isUrl(configFile)) {
|
|
281
|
-
const configPath = path2.resolve(cwd, configFile);
|
|
282
|
-
cmd.push("-v", `${configPath}:/config/flow.json:ro`);
|
|
283
|
-
args = args.map((arg) => arg === configFile ? "/config/flow.json" : arg);
|
|
284
|
-
}
|
|
285
|
-
cmd.push("-v", `${cwd}:/workspace`);
|
|
286
|
-
cmd.push("-w", "/workspace");
|
|
287
|
-
if (process.platform !== "win32") {
|
|
288
|
-
try {
|
|
289
|
-
const uid = process.getuid?.();
|
|
290
|
-
const gid = process.getgid?.();
|
|
291
|
-
if (uid !== void 0 && gid !== void 0) {
|
|
292
|
-
cmd.push("--user", `${uid}:${gid}`);
|
|
293
|
-
}
|
|
294
|
-
} catch {
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
if (options.verbose) {
|
|
298
|
-
cmd.push("-e", "VERBOSE=true");
|
|
299
|
-
}
|
|
300
|
-
if (options.silent) {
|
|
301
|
-
cmd.push("-e", "SILENT=true");
|
|
302
|
-
}
|
|
303
|
-
cmd.push(CLI_DOCKER_IMAGE);
|
|
304
|
-
cmd.push(command, ...args);
|
|
305
|
-
return cmd;
|
|
306
|
-
}
|
|
307
|
-
async function executeInDocker(command, args, options = {}, configFile) {
|
|
308
|
-
const containerArgs = [...args, "--local"];
|
|
309
|
-
const dockerCmd = buildDockerCommand(
|
|
310
|
-
command,
|
|
311
|
-
containerArgs,
|
|
312
|
-
options,
|
|
313
|
-
configFile
|
|
314
|
-
);
|
|
315
|
-
return new Promise((resolve, reject) => {
|
|
316
|
-
const proc = spawn(dockerCmd[0], dockerCmd.slice(1), {
|
|
317
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
318
|
-
shell: false
|
|
319
|
-
});
|
|
320
|
-
proc.on("error", (error) => {
|
|
321
|
-
reject(new Error(`Docker execution failed: ${error.message}`));
|
|
322
|
-
});
|
|
323
|
-
proc.on("exit", (code) => {
|
|
324
|
-
if (code === 0) {
|
|
325
|
-
resolve();
|
|
326
|
-
} else {
|
|
327
|
-
process.exit(code || 1);
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
async function isDockerAvailable() {
|
|
333
|
-
return new Promise((resolve) => {
|
|
334
|
-
const proc = spawn("docker", ["--version"], {
|
|
335
|
-
stdio: "ignore"
|
|
336
|
-
});
|
|
337
|
-
proc.on("error", () => resolve(false));
|
|
338
|
-
proc.on("exit", (code) => resolve(code === 0));
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
function buildDockerRunCommand(mode, flowPath, options = {}) {
|
|
342
|
-
const cwd = process.cwd();
|
|
343
|
-
const cmd = ["docker", "run", "--rm"];
|
|
344
|
-
cmd.push("-e", `MODE=${mode}`);
|
|
345
|
-
if (mode === "collect" && flowPath) {
|
|
346
|
-
const absoluteFlowPath = path2.resolve(cwd, flowPath);
|
|
347
|
-
const flowDir = path2.dirname(absoluteFlowPath);
|
|
348
|
-
const flowFile = path2.basename(absoluteFlowPath);
|
|
349
|
-
cmd.push("-v", `${flowDir}:/app/dist:ro`);
|
|
350
|
-
cmd.push("-e", `FLOW=/app/dist/${flowFile}`);
|
|
351
|
-
}
|
|
352
|
-
if (mode === "serve" && flowPath) {
|
|
353
|
-
const absoluteFilePath = path2.resolve(cwd, flowPath);
|
|
354
|
-
cmd.push("-v", `${absoluteFilePath}:/app/bundle.mjs:ro`);
|
|
355
|
-
cmd.push("-e", "FILE_PATH=/app/bundle.mjs");
|
|
356
|
-
}
|
|
357
|
-
const port = options.port !== void 0 ? options.port : 8080;
|
|
358
|
-
cmd.push("-p", `${port}:${port}`);
|
|
359
|
-
cmd.push("-e", `PORT=${port}`);
|
|
360
|
-
if (options.host) {
|
|
361
|
-
cmd.push("-e", `HOST=${options.host}`);
|
|
362
|
-
}
|
|
363
|
-
if (options.serveName) {
|
|
364
|
-
cmd.push("-e", `SERVE_NAME=${options.serveName}`);
|
|
365
|
-
}
|
|
366
|
-
if (options.servePath) {
|
|
367
|
-
cmd.push("-e", `SERVE_PATH=${options.servePath}`);
|
|
368
|
-
}
|
|
369
|
-
if (process.platform !== "win32") {
|
|
370
|
-
try {
|
|
371
|
-
const uid = process.getuid?.();
|
|
372
|
-
const gid = process.getgid?.();
|
|
373
|
-
if (uid !== void 0 && gid !== void 0) {
|
|
374
|
-
cmd.push("--user", `${uid}:${gid}`);
|
|
375
|
-
}
|
|
376
|
-
} catch {
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
cmd.push(RUNTIME_DOCKER_IMAGE);
|
|
380
|
-
return cmd;
|
|
381
|
-
}
|
|
382
|
-
async function executeRunInDocker(mode, flowPath, options = {}) {
|
|
383
|
-
const dockerCmd = buildDockerRunCommand(mode, flowPath, options);
|
|
384
|
-
return new Promise((resolve, reject) => {
|
|
385
|
-
const proc = spawn(dockerCmd[0], dockerCmd.slice(1), {
|
|
386
|
-
stdio: options.silent ? "ignore" : "inherit",
|
|
387
|
-
shell: false
|
|
388
|
-
});
|
|
389
|
-
proc.on("error", (error) => {
|
|
390
|
-
reject(new Error(`Docker execution failed: ${error.message}`));
|
|
391
|
-
});
|
|
392
|
-
proc.on("exit", (code) => {
|
|
393
|
-
if (code === 0) {
|
|
394
|
-
resolve();
|
|
395
|
-
} else {
|
|
396
|
-
process.exit(code || 1);
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// src/core/execution.ts
|
|
403
|
-
function getExecutionMode(options) {
|
|
404
|
-
if (options.local || process.env.WALKEROS_CONTAINER === "true") {
|
|
405
|
-
return "local";
|
|
406
|
-
}
|
|
407
|
-
return "docker";
|
|
408
|
-
}
|
|
409
|
-
async function executeCommand(localHandler, dockerCommand, dockerArgs, options, logger2, configFile) {
|
|
410
|
-
const mode = getExecutionMode(options);
|
|
411
|
-
if (options.dryRun) {
|
|
412
|
-
if (mode === "docker") {
|
|
413
|
-
const cmd = `docker run walkeros/cli:latest ${dockerCommand} ${dockerArgs.join(" ")}`;
|
|
414
|
-
logger2?.info(`[DRY-RUN] Would execute: ${cmd}`);
|
|
415
|
-
} else {
|
|
416
|
-
logger2?.info(
|
|
417
|
-
`[DRY-RUN] Would execute locally: ${dockerCommand} ${dockerArgs.join(" ")}`
|
|
418
|
-
);
|
|
419
|
-
}
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
if (mode === "local") {
|
|
423
|
-
if (logger2 && !options.silent) {
|
|
424
|
-
logger2.info("\u{1F5A5}\uFE0F Executing locally...");
|
|
425
|
-
}
|
|
426
|
-
await localHandler();
|
|
427
|
-
} else {
|
|
428
|
-
const dockerAvailable = await isDockerAvailable();
|
|
429
|
-
if (!dockerAvailable) {
|
|
430
|
-
throw new Error(
|
|
431
|
-
"Docker is not available. Please install Docker or use --local flag to execute locally."
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
if (logger2 && !options.silent) {
|
|
435
|
-
logger2.info("\u{1F433} Executing in Docker container...");
|
|
436
|
-
}
|
|
437
|
-
await executeInDocker(dockerCommand, dockerArgs, options, configFile);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
// src/core/temp-manager.ts
|
|
442
|
-
import { getHashServer } from "@walkeros/server-core";
|
|
443
|
-
import fs2 from "fs-extra";
|
|
444
|
-
|
|
445
288
|
// src/core/asset-resolver.ts
|
|
446
|
-
import { fileURLToPath } from "url";
|
|
447
|
-
import { existsSync } from "fs";
|
|
448
|
-
import path3 from "path";
|
|
449
289
|
var cachedAssetDir;
|
|
450
290
|
function getAssetDir() {
|
|
451
291
|
if (cachedAssetDir) return cachedAssetDir;
|
|
452
|
-
const currentFile =
|
|
292
|
+
const currentFile = fileURLToPath2(import.meta.url);
|
|
453
293
|
let dir = path3.dirname(currentFile);
|
|
454
294
|
while (dir !== path3.dirname(dir)) {
|
|
455
295
|
if (existsSync(path3.join(dir, "examples"))) {
|
|
@@ -462,6 +302,9 @@ function getAssetDir() {
|
|
|
462
302
|
return cachedAssetDir;
|
|
463
303
|
}
|
|
464
304
|
function resolveAsset(assetPath, assetType, baseDir) {
|
|
305
|
+
if (isUrl(assetPath)) {
|
|
306
|
+
return assetPath;
|
|
307
|
+
}
|
|
465
308
|
if (!assetPath.includes("/") && !assetPath.includes("\\")) {
|
|
466
309
|
const assetDir = getAssetDir();
|
|
467
310
|
return path3.join(assetDir, "examples", assetPath);
|
|
@@ -479,22 +322,22 @@ function getErrorMessage(error) {
|
|
|
479
322
|
|
|
480
323
|
// src/core/local-packages.ts
|
|
481
324
|
import path4 from "path";
|
|
482
|
-
import
|
|
325
|
+
import fs2 from "fs-extra";
|
|
483
326
|
async function resolveLocalPackage(packageName, localPath, configDir, logger2) {
|
|
484
327
|
const absolutePath = path4.isAbsolute(localPath) ? localPath : path4.resolve(configDir, localPath);
|
|
485
|
-
if (!await
|
|
328
|
+
if (!await fs2.pathExists(absolutePath)) {
|
|
486
329
|
throw new Error(
|
|
487
330
|
`Local package path not found: ${localPath} (resolved to ${absolutePath})`
|
|
488
331
|
);
|
|
489
332
|
}
|
|
490
333
|
const pkgJsonPath = path4.join(absolutePath, "package.json");
|
|
491
|
-
if (!await
|
|
334
|
+
if (!await fs2.pathExists(pkgJsonPath)) {
|
|
492
335
|
throw new Error(
|
|
493
336
|
`No package.json found at ${absolutePath}. Is this a valid package directory?`
|
|
494
337
|
);
|
|
495
338
|
}
|
|
496
339
|
const distPath = path4.join(absolutePath, "dist");
|
|
497
|
-
const hasDistFolder = await
|
|
340
|
+
const hasDistFolder = await fs2.pathExists(distPath);
|
|
498
341
|
if (!hasDistFolder) {
|
|
499
342
|
logger2.warn(
|
|
500
343
|
`\u26A0\uFE0F ${packageName}: No dist/ folder found. Using package root.`
|
|
@@ -509,18 +352,18 @@ async function resolveLocalPackage(packageName, localPath, configDir, logger2) {
|
|
|
509
352
|
}
|
|
510
353
|
async function copyLocalPackage(localPkg, targetDir, logger2) {
|
|
511
354
|
const packageDir = path4.join(targetDir, "node_modules", localPkg.name);
|
|
512
|
-
await
|
|
513
|
-
await
|
|
355
|
+
await fs2.ensureDir(path4.dirname(packageDir));
|
|
356
|
+
await fs2.copy(
|
|
514
357
|
path4.join(localPkg.absolutePath, "package.json"),
|
|
515
358
|
path4.join(packageDir, "package.json")
|
|
516
359
|
);
|
|
517
360
|
if (localPkg.hasDistFolder) {
|
|
518
|
-
await
|
|
361
|
+
await fs2.copy(localPkg.distPath, path4.join(packageDir, "dist"));
|
|
519
362
|
} else {
|
|
520
|
-
const entries = await
|
|
363
|
+
const entries = await fs2.readdir(localPkg.absolutePath);
|
|
521
364
|
for (const entry of entries) {
|
|
522
365
|
if (!["node_modules", ".turbo", ".git"].includes(entry)) {
|
|
523
|
-
await
|
|
366
|
+
await fs2.copy(
|
|
524
367
|
path4.join(localPkg.absolutePath, entry),
|
|
525
368
|
path4.join(packageDir, entry)
|
|
526
369
|
);
|
|
@@ -541,8 +384,8 @@ function validateFlowSetup(data) {
|
|
|
541
384
|
const result = safeParseSetup(data);
|
|
542
385
|
if (!result.success) {
|
|
543
386
|
const errors = result.error.issues.map((issue) => {
|
|
544
|
-
const
|
|
545
|
-
return ` - ${
|
|
387
|
+
const path14 = issue.path.length > 0 ? issue.path.map(String).join(".") : "root";
|
|
388
|
+
return ` - ${path14}: ${issue.message}`;
|
|
546
389
|
}).join("\n");
|
|
547
390
|
throw new Error(`Invalid configuration:
|
|
548
391
|
${errors}`);
|
|
@@ -561,7 +404,6 @@ var WEB_BUILD_DEFAULTS = {
|
|
|
561
404
|
minify: true,
|
|
562
405
|
sourcemap: false,
|
|
563
406
|
cache: true,
|
|
564
|
-
tempDir: ".tmp",
|
|
565
407
|
windowCollector: "collector",
|
|
566
408
|
windowElb: "elb"
|
|
567
409
|
};
|
|
@@ -571,8 +413,7 @@ var SERVER_BUILD_DEFAULTS = {
|
|
|
571
413
|
target: "node20",
|
|
572
414
|
minify: true,
|
|
573
415
|
sourcemap: false,
|
|
574
|
-
cache: true
|
|
575
|
-
tempDir: ".tmp"
|
|
416
|
+
cache: true
|
|
576
417
|
};
|
|
577
418
|
var DEFAULT_OUTPUT_PATHS = {
|
|
578
419
|
web: "./dist/walker.js",
|
|
@@ -587,7 +428,7 @@ function getDefaultOutput(platform) {
|
|
|
587
428
|
|
|
588
429
|
// src/config/loader.ts
|
|
589
430
|
import path5 from "path";
|
|
590
|
-
import
|
|
431
|
+
import fs3 from "fs-extra";
|
|
591
432
|
import { getFlowConfig, getPlatform } from "@walkeros/core";
|
|
592
433
|
var DEFAULT_INCLUDE_FOLDER = "./shared";
|
|
593
434
|
function loadBundleConfig(rawConfig, options) {
|
|
@@ -603,18 +444,12 @@ function loadBundleConfig(rawConfig, options) {
|
|
|
603
444
|
}
|
|
604
445
|
const buildDefaults = getBuildDefaults(platform);
|
|
605
446
|
const packages = flowConfig.packages || {};
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
output = options.buildOverrides.output;
|
|
609
|
-
}
|
|
610
|
-
const configDir = path5.dirname(options.configPath);
|
|
611
|
-
if (!path5.isAbsolute(output)) {
|
|
612
|
-
output = path5.resolve(configDir, output);
|
|
613
|
-
}
|
|
447
|
+
const output = options.buildOverrides?.output || getDefaultOutput(platform);
|
|
448
|
+
const configDir = isUrl(options.configPath) ? process.cwd() : path5.dirname(options.configPath);
|
|
614
449
|
let includes = setup.include;
|
|
615
450
|
if (!includes) {
|
|
616
451
|
const defaultIncludePath = path5.resolve(configDir, DEFAULT_INCLUDE_FOLDER);
|
|
617
|
-
if (
|
|
452
|
+
if (fs3.pathExistsSync(defaultIncludePath)) {
|
|
618
453
|
includes = [DEFAULT_INCLUDE_FOLDER];
|
|
619
454
|
}
|
|
620
455
|
}
|
|
@@ -677,16 +512,16 @@ function loadAllFlows(rawConfig, options) {
|
|
|
677
512
|
// src/commands/bundle/bundler.ts
|
|
678
513
|
import esbuild from "esbuild";
|
|
679
514
|
import path8 from "path";
|
|
680
|
-
import
|
|
515
|
+
import fs6 from "fs-extra";
|
|
681
516
|
import { packageNameToVariable } from "@walkeros/core";
|
|
682
517
|
|
|
683
518
|
// src/commands/bundle/package-manager.ts
|
|
684
519
|
import pacote from "pacote";
|
|
685
520
|
import path6 from "path";
|
|
686
|
-
import
|
|
521
|
+
import fs4 from "fs-extra";
|
|
687
522
|
|
|
688
523
|
// src/core/cache-utils.ts
|
|
689
|
-
import { getHashServer
|
|
524
|
+
import { getHashServer } from "@walkeros/server-core";
|
|
690
525
|
var HASH_LENGTH = 12;
|
|
691
526
|
function isMutableVersion(version) {
|
|
692
527
|
return version === "latest" || version.includes("^") || version.includes("~") || version.includes("*") || version.includes("x");
|
|
@@ -699,10 +534,10 @@ async function getPackageCacheKey(packageName, version, date) {
|
|
|
699
534
|
if (isMutableVersion(version)) {
|
|
700
535
|
const dateStr = date ?? getTodayDate();
|
|
701
536
|
const input2 = `${safeName}@${version}:${dateStr}`;
|
|
702
|
-
return
|
|
537
|
+
return getHashServer(input2, HASH_LENGTH);
|
|
703
538
|
}
|
|
704
539
|
const input = `${safeName}@${version}`;
|
|
705
|
-
return
|
|
540
|
+
return getHashServer(input, HASH_LENGTH);
|
|
706
541
|
}
|
|
707
542
|
function normalizeJson(content) {
|
|
708
543
|
const parsed = JSON.parse(content);
|
|
@@ -712,21 +547,28 @@ async function getFlowConfigCacheKey(content, date) {
|
|
|
712
547
|
const dateStr = date ?? getTodayDate();
|
|
713
548
|
const normalized = normalizeJson(content);
|
|
714
549
|
const input = `${normalized}:${dateStr}`;
|
|
715
|
-
return
|
|
550
|
+
return getHashServer(input, HASH_LENGTH);
|
|
716
551
|
}
|
|
717
552
|
|
|
718
553
|
// src/commands/bundle/package-manager.ts
|
|
554
|
+
var PACKAGE_DOWNLOAD_TIMEOUT_MS = 6e4;
|
|
555
|
+
async function withTimeout(promise, ms, errorMessage) {
|
|
556
|
+
const timeout = new Promise(
|
|
557
|
+
(_, reject) => setTimeout(() => reject(new Error(errorMessage)), ms)
|
|
558
|
+
);
|
|
559
|
+
return Promise.race([promise, timeout]);
|
|
560
|
+
}
|
|
719
561
|
function getPackageDirectory(baseDir, packageName, version) {
|
|
720
562
|
return path6.join(baseDir, "node_modules", packageName);
|
|
721
563
|
}
|
|
722
|
-
async function getCachedPackagePath(pkg,
|
|
723
|
-
const cacheDir =
|
|
564
|
+
async function getCachedPackagePath(pkg, tmpDir) {
|
|
565
|
+
const cacheDir = getTmpPath(tmpDir, "cache", "packages");
|
|
724
566
|
const cacheKey = await getPackageCacheKey(pkg.name, pkg.version);
|
|
725
567
|
return path6.join(cacheDir, cacheKey);
|
|
726
568
|
}
|
|
727
|
-
async function isPackageCached(pkg,
|
|
728
|
-
const cachedPath = await getCachedPackagePath(pkg,
|
|
729
|
-
return
|
|
569
|
+
async function isPackageCached(pkg, tmpDir) {
|
|
570
|
+
const cachedPath = await getCachedPackagePath(pkg, tmpDir);
|
|
571
|
+
return fs4.pathExists(cachedPath);
|
|
730
572
|
}
|
|
731
573
|
function validateNoDuplicatePackages(packages) {
|
|
732
574
|
const packageMap = /* @__PURE__ */ new Map();
|
|
@@ -761,11 +603,11 @@ async function resolveDependencies(pkg, packageDir, logger2, visited = /* @__PUR
|
|
|
761
603
|
visited.add(pkgKey);
|
|
762
604
|
try {
|
|
763
605
|
const packageJsonPath = path6.join(packageDir, "package.json");
|
|
764
|
-
if (await
|
|
765
|
-
const
|
|
606
|
+
if (await fs4.pathExists(packageJsonPath)) {
|
|
607
|
+
const packageJson = await fs4.readJson(packageJsonPath);
|
|
766
608
|
const deps = {
|
|
767
|
-
...
|
|
768
|
-
...
|
|
609
|
+
...packageJson.dependencies,
|
|
610
|
+
...packageJson.peerDependencies
|
|
769
611
|
};
|
|
770
612
|
for (const [name, versionSpec] of Object.entries(deps)) {
|
|
771
613
|
if (typeof versionSpec === "string") {
|
|
@@ -782,6 +624,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
782
624
|
const packagePaths = /* @__PURE__ */ new Map();
|
|
783
625
|
const downloadQueue = [...packages];
|
|
784
626
|
const processed = /* @__PURE__ */ new Set();
|
|
627
|
+
const userSpecifiedPackages = new Set(packages.map((p) => p.name));
|
|
785
628
|
const localPackageMap = /* @__PURE__ */ new Map();
|
|
786
629
|
for (const pkg of packages) {
|
|
787
630
|
if (pkg.path) {
|
|
@@ -789,7 +632,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
789
632
|
}
|
|
790
633
|
}
|
|
791
634
|
validateNoDuplicatePackages(packages);
|
|
792
|
-
await
|
|
635
|
+
await fs4.ensureDir(targetDir);
|
|
793
636
|
while (downloadQueue.length > 0) {
|
|
794
637
|
const pkg = downloadQueue.shift();
|
|
795
638
|
const pkgKey = `${pkg.name}@${pkg.version}`;
|
|
@@ -820,12 +663,14 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
820
663
|
}
|
|
821
664
|
const packageSpec = `${pkg.name}@${pkg.version}`;
|
|
822
665
|
const packageDir = getPackageDirectory(targetDir, pkg.name, pkg.version);
|
|
823
|
-
const cachedPath = await getCachedPackagePath(pkg
|
|
824
|
-
if (useCache && await isPackageCached(pkg
|
|
825
|
-
|
|
666
|
+
const cachedPath = await getCachedPackagePath(pkg);
|
|
667
|
+
if (useCache && await isPackageCached(pkg)) {
|
|
668
|
+
if (userSpecifiedPackages.has(pkg.name)) {
|
|
669
|
+
logger2.debug(`Downloading ${packageSpec} (cached)`);
|
|
670
|
+
}
|
|
826
671
|
try {
|
|
827
|
-
await
|
|
828
|
-
await
|
|
672
|
+
await fs4.ensureDir(path6.dirname(packageDir));
|
|
673
|
+
await fs4.copy(cachedPath, packageDir);
|
|
829
674
|
packagePaths.set(pkg.name, packageDir);
|
|
830
675
|
const deps = await resolveDependencies(pkg, packageDir, logger2);
|
|
831
676
|
for (const dep of deps) {
|
|
@@ -841,27 +686,34 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
841
686
|
);
|
|
842
687
|
}
|
|
843
688
|
}
|
|
844
|
-
logger2.debug(`Downloading ${packageSpec}...`);
|
|
845
689
|
try {
|
|
846
|
-
await
|
|
847
|
-
const cacheDir = process.env.NPM_CACHE_DIR ||
|
|
848
|
-
await
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
690
|
+
await fs4.ensureDir(path6.dirname(packageDir));
|
|
691
|
+
const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(void 0, "cache", "npm");
|
|
692
|
+
await withTimeout(
|
|
693
|
+
pacote.extract(packageSpec, packageDir, {
|
|
694
|
+
// Force npm registry download, prevent workspace resolution
|
|
695
|
+
registry: "https://registry.npmjs.org",
|
|
696
|
+
// Force online fetching from registry (don't use cached workspace packages)
|
|
697
|
+
preferOnline: true,
|
|
698
|
+
// Cache for performance
|
|
699
|
+
cache: cacheDir,
|
|
700
|
+
// Don't resolve relative to workspace context
|
|
701
|
+
where: void 0
|
|
702
|
+
}),
|
|
703
|
+
PACKAGE_DOWNLOAD_TIMEOUT_MS,
|
|
704
|
+
`Package download timed out after ${PACKAGE_DOWNLOAD_TIMEOUT_MS / 1e3}s: ${packageSpec}`
|
|
705
|
+
);
|
|
706
|
+
if (userSpecifiedPackages.has(pkg.name)) {
|
|
707
|
+
const pkgStats = await fs4.stat(path6.join(packageDir, "package.json"));
|
|
708
|
+
const pkgJsonSize = pkgStats.size;
|
|
709
|
+
const sizeKB = (pkgJsonSize / 1024).toFixed(1);
|
|
710
|
+
logger2.debug(`Downloading ${packageSpec} (${sizeKB} KB)`);
|
|
711
|
+
}
|
|
858
712
|
if (useCache) {
|
|
859
713
|
try {
|
|
860
|
-
await
|
|
861
|
-
await
|
|
862
|
-
logger2.debug(`Cached ${packageSpec} for future use`);
|
|
714
|
+
await fs4.ensureDir(path6.dirname(cachedPath));
|
|
715
|
+
await fs4.copy(packageDir, cachedPath);
|
|
863
716
|
} catch (cacheError) {
|
|
864
|
-
logger2.debug(`Failed to cache ${packageSpec}: ${cacheError}`);
|
|
865
717
|
}
|
|
866
718
|
}
|
|
867
719
|
packagePaths.set(pkg.name, packageDir);
|
|
@@ -880,26 +732,26 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
880
732
|
}
|
|
881
733
|
|
|
882
734
|
// src/core/build-cache.ts
|
|
883
|
-
import
|
|
735
|
+
import fs5 from "fs-extra";
|
|
884
736
|
import path7 from "path";
|
|
885
|
-
|
|
886
|
-
|
|
737
|
+
async function getBuildCachePath(configContent, tmpDir) {
|
|
738
|
+
const cacheDir = getTmpPath(tmpDir, "cache", "builds");
|
|
887
739
|
const cacheKey = await getFlowConfigCacheKey(configContent);
|
|
888
740
|
return path7.join(cacheDir, `${cacheKey}.js`);
|
|
889
741
|
}
|
|
890
|
-
async function isBuildCached(configContent,
|
|
891
|
-
const cachePath = await getBuildCachePath(configContent,
|
|
892
|
-
return
|
|
742
|
+
async function isBuildCached(configContent, tmpDir) {
|
|
743
|
+
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
744
|
+
return fs5.pathExists(cachePath);
|
|
893
745
|
}
|
|
894
|
-
async function cacheBuild(configContent, buildOutput,
|
|
895
|
-
const cachePath = await getBuildCachePath(configContent,
|
|
896
|
-
await
|
|
897
|
-
await
|
|
746
|
+
async function cacheBuild(configContent, buildOutput, tmpDir) {
|
|
747
|
+
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
748
|
+
await fs5.ensureDir(path7.dirname(cachePath));
|
|
749
|
+
await fs5.writeFile(cachePath, buildOutput, "utf-8");
|
|
898
750
|
}
|
|
899
|
-
async function getCachedBuild(configContent,
|
|
900
|
-
const cachePath = await getBuildCachePath(configContent,
|
|
901
|
-
if (await
|
|
902
|
-
return await
|
|
751
|
+
async function getCachedBuild(configContent, tmpDir) {
|
|
752
|
+
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
753
|
+
if (await fs5.pathExists(cachePath)) {
|
|
754
|
+
return await fs5.readFile(cachePath, "utf-8");
|
|
903
755
|
}
|
|
904
756
|
return null;
|
|
905
757
|
}
|
|
@@ -910,8 +762,8 @@ async function copyIncludes(includes, sourceDir, outputDir, logger2) {
|
|
|
910
762
|
const sourcePath = path8.resolve(sourceDir, include);
|
|
911
763
|
const folderName = path8.basename(include);
|
|
912
764
|
const destPath = path8.join(outputDir, folderName);
|
|
913
|
-
if (await
|
|
914
|
-
await
|
|
765
|
+
if (await fs6.pathExists(sourcePath)) {
|
|
766
|
+
await fs6.copy(sourcePath, destPath);
|
|
915
767
|
logger2.debug(`Copied ${include} to output`);
|
|
916
768
|
} else {
|
|
917
769
|
logger2.debug(`Include folder not found: ${include}`);
|
|
@@ -932,21 +784,22 @@ function generateCacheKeyContent(flowConfig, buildOptions) {
|
|
|
932
784
|
}
|
|
933
785
|
async function bundleCore(flowConfig, buildOptions, logger2, showStats = false) {
|
|
934
786
|
const bundleStartTime = Date.now();
|
|
935
|
-
const TEMP_DIR = buildOptions.tempDir
|
|
787
|
+
const TEMP_DIR = buildOptions.tempDir || getTmpPath();
|
|
936
788
|
if (buildOptions.cache !== false) {
|
|
937
789
|
const configContent = generateCacheKeyContent(flowConfig, buildOptions);
|
|
938
790
|
const cached = await isBuildCached(configContent);
|
|
939
791
|
if (cached) {
|
|
940
792
|
const cachedBuild = await getCachedBuild(configContent);
|
|
941
793
|
if (cachedBuild) {
|
|
942
|
-
logger2.
|
|
794
|
+
logger2.debug("Using cached build");
|
|
943
795
|
const outputPath = path8.resolve(buildOptions.output);
|
|
944
|
-
await
|
|
945
|
-
await
|
|
946
|
-
|
|
947
|
-
|
|
796
|
+
await fs6.ensureDir(path8.dirname(outputPath));
|
|
797
|
+
await fs6.writeFile(outputPath, cachedBuild);
|
|
798
|
+
const stats = await fs6.stat(outputPath);
|
|
799
|
+
const sizeKB = (stats.size / 1024).toFixed(1);
|
|
800
|
+
logger2.log(`Output: ${outputPath} (${sizeKB} KB, cached)`);
|
|
948
801
|
if (showStats) {
|
|
949
|
-
const
|
|
802
|
+
const stats2 = await fs6.stat(outputPath);
|
|
950
803
|
const packageStats = Object.entries(buildOptions.packages).map(
|
|
951
804
|
([name, pkg]) => ({
|
|
952
805
|
name: `${name}@${pkg.version || "latest"}`,
|
|
@@ -955,7 +808,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
955
808
|
})
|
|
956
809
|
);
|
|
957
810
|
return {
|
|
958
|
-
totalSize:
|
|
811
|
+
totalSize: stats2.size,
|
|
959
812
|
packages: packageStats,
|
|
960
813
|
buildTime: Date.now() - bundleStartTime,
|
|
961
814
|
treeshakingEffective: true
|
|
@@ -966,11 +819,8 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
966
819
|
}
|
|
967
820
|
}
|
|
968
821
|
try {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
logger2.debug("Cleaned temporary directory");
|
|
973
|
-
logger2.info("\u{1F4E5} Downloading packages...");
|
|
822
|
+
await fs6.ensureDir(TEMP_DIR);
|
|
823
|
+
logger2.debug("Downloading packages");
|
|
974
824
|
const packagesArray = Object.entries(buildOptions.packages).map(
|
|
975
825
|
([name, packageConfig]) => ({
|
|
976
826
|
name,
|
|
@@ -990,7 +840,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
990
840
|
for (const [pkgName, pkgPath] of packagePaths.entries()) {
|
|
991
841
|
if (pkgName.startsWith("@walkeros/")) {
|
|
992
842
|
const pkgJsonPath = path8.join(pkgPath, "package.json");
|
|
993
|
-
const pkgJson = await
|
|
843
|
+
const pkgJson = await fs6.readJSON(pkgJsonPath);
|
|
994
844
|
if (!pkgJson.exports && pkgJson.module) {
|
|
995
845
|
pkgJson.exports = {
|
|
996
846
|
".": {
|
|
@@ -998,26 +848,28 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
998
848
|
require: pkgJson.main
|
|
999
849
|
}
|
|
1000
850
|
};
|
|
1001
|
-
await
|
|
851
|
+
await fs6.writeJSON(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
1002
852
|
}
|
|
1003
853
|
}
|
|
1004
854
|
}
|
|
1005
855
|
const packageJsonPath = path8.join(TEMP_DIR, "package.json");
|
|
1006
|
-
await
|
|
856
|
+
await fs6.writeFile(
|
|
1007
857
|
packageJsonPath,
|
|
1008
858
|
JSON.stringify({ type: "module" }, null, 2)
|
|
1009
859
|
);
|
|
1010
|
-
logger2.
|
|
860
|
+
logger2.debug("Creating entry point");
|
|
1011
861
|
const entryContent = await createEntryPoint(
|
|
1012
862
|
flowConfig,
|
|
1013
863
|
buildOptions,
|
|
1014
864
|
packagePaths
|
|
1015
865
|
);
|
|
1016
866
|
const entryPath = path8.join(TEMP_DIR, "entry.js");
|
|
1017
|
-
await
|
|
1018
|
-
logger2.
|
|
867
|
+
await fs6.writeFile(entryPath, entryContent);
|
|
868
|
+
logger2.debug(
|
|
869
|
+
`Running esbuild (target: ${buildOptions.target || "es2018"}, format: ${buildOptions.format})`
|
|
870
|
+
);
|
|
1019
871
|
const outputPath = path8.resolve(buildOptions.output);
|
|
1020
|
-
await
|
|
872
|
+
await fs6.ensureDir(path8.dirname(outputPath));
|
|
1021
873
|
const esbuildOptions = createEsbuildOptions(
|
|
1022
874
|
buildOptions,
|
|
1023
875
|
entryPath,
|
|
@@ -1034,10 +886,13 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1034
886
|
buildOptions.code || ""
|
|
1035
887
|
);
|
|
1036
888
|
}
|
|
1037
|
-
|
|
889
|
+
const outputStats = await fs6.stat(outputPath);
|
|
890
|
+
const sizeKB = (outputStats.size / 1024).toFixed(1);
|
|
891
|
+
const buildTime = ((Date.now() - bundleStartTime) / 1e3).toFixed(1);
|
|
892
|
+
logger2.log(`Output: ${outputPath} (${sizeKB} KB, ${buildTime}s)`);
|
|
1038
893
|
if (buildOptions.cache !== false) {
|
|
1039
894
|
const configContent = generateCacheKeyContent(flowConfig, buildOptions);
|
|
1040
|
-
const buildOutput = await
|
|
895
|
+
const buildOutput = await fs6.readFile(outputPath, "utf-8");
|
|
1041
896
|
await cacheBuild(configContent, buildOutput);
|
|
1042
897
|
logger2.debug("Build cached for future use");
|
|
1043
898
|
}
|
|
@@ -1059,21 +914,13 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
1059
914
|
logger2
|
|
1060
915
|
);
|
|
1061
916
|
}
|
|
1062
|
-
if (!buildOptions.tempDir) {
|
|
1063
|
-
await fs7.remove(TEMP_DIR);
|
|
1064
|
-
logger2.debug("Cleaned up temporary files");
|
|
1065
|
-
}
|
|
1066
917
|
return stats;
|
|
1067
918
|
} catch (error) {
|
|
1068
|
-
if (!buildOptions.tempDir) {
|
|
1069
|
-
await fs7.remove(TEMP_DIR).catch(() => {
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
919
|
throw error;
|
|
1073
920
|
}
|
|
1074
921
|
}
|
|
1075
922
|
async function collectBundleStats(outputPath, packages, startTime, entryContent) {
|
|
1076
|
-
const stats = await
|
|
923
|
+
const stats = await fs6.stat(outputPath);
|
|
1077
924
|
const totalSize = stats.size;
|
|
1078
925
|
const buildTime = Date.now() - startTime;
|
|
1079
926
|
const packageStats = Object.entries(packages).map(([name, pkg]) => {
|
|
@@ -1434,130 +1281,111 @@ async function bundleCommand(options) {
|
|
|
1434
1281
|
const timer = createTimer();
|
|
1435
1282
|
timer.start();
|
|
1436
1283
|
const logger2 = createCommandLogger(options);
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1284
|
+
if (options.dryRun) {
|
|
1285
|
+
logger2.log(`[DRY-RUN] Would execute bundle with config: ${options.config}`);
|
|
1286
|
+
return;
|
|
1287
|
+
}
|
|
1288
|
+
try {
|
|
1289
|
+
if (options.flow && options.all) {
|
|
1290
|
+
throw new Error("Cannot use both --flow and --all flags together");
|
|
1291
|
+
}
|
|
1292
|
+
const configPath = resolveAsset(options.config, "config");
|
|
1293
|
+
const rawConfig = await loadJsonConfig(configPath);
|
|
1294
|
+
const configsToBundle = options.all ? loadAllFlows(rawConfig, { configPath, logger: logger2 }) : [
|
|
1295
|
+
loadBundleConfig(rawConfig, {
|
|
1296
|
+
configPath,
|
|
1297
|
+
flowName: options.flow,
|
|
1298
|
+
logger: logger2
|
|
1299
|
+
})
|
|
1300
|
+
];
|
|
1301
|
+
const results = [];
|
|
1302
|
+
for (const {
|
|
1303
|
+
flowConfig,
|
|
1304
|
+
buildOptions,
|
|
1305
|
+
flowName,
|
|
1306
|
+
isMultiFlow
|
|
1307
|
+
} of configsToBundle) {
|
|
1444
1308
|
try {
|
|
1445
|
-
if (options.
|
|
1446
|
-
|
|
1309
|
+
if (options.cache !== void 0) {
|
|
1310
|
+
buildOptions.cache = options.cache;
|
|
1311
|
+
}
|
|
1312
|
+
const configBasename = path9.basename(configPath);
|
|
1313
|
+
if (isMultiFlow || options.all) {
|
|
1314
|
+
logger2.log(`Bundling ${configBasename} (flow: ${flowName})...`);
|
|
1315
|
+
} else {
|
|
1316
|
+
logger2.log(`Bundling ${configBasename}...`);
|
|
1447
1317
|
}
|
|
1448
|
-
|
|
1449
|
-
const
|
|
1450
|
-
const rawConfig = await loadJsonConfig(configPath);
|
|
1451
|
-
const configsToBundle = options.all ? loadAllFlows(rawConfig, { configPath, logger: logger2 }) : [
|
|
1452
|
-
loadBundleConfig(rawConfig, {
|
|
1453
|
-
configPath,
|
|
1454
|
-
flowName: options.flow,
|
|
1455
|
-
logger: logger2
|
|
1456
|
-
})
|
|
1457
|
-
];
|
|
1458
|
-
const results = [];
|
|
1459
|
-
for (const {
|
|
1318
|
+
const shouldCollectStats = options.stats || options.json;
|
|
1319
|
+
const stats = await bundleCore(
|
|
1460
1320
|
flowConfig,
|
|
1461
1321
|
buildOptions,
|
|
1322
|
+
logger2,
|
|
1323
|
+
shouldCollectStats
|
|
1324
|
+
);
|
|
1325
|
+
results.push({
|
|
1462
1326
|
flowName,
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
}
|
|
1469
|
-
if (isMultiFlow || options.all) {
|
|
1470
|
-
logger2.info(`
|
|
1471
|
-
\u{1F527} Building flow: ${flowName}`);
|
|
1472
|
-
} else {
|
|
1473
|
-
logger2.info("\u{1F527} Starting bundle process...");
|
|
1474
|
-
}
|
|
1475
|
-
const shouldCollectStats = options.stats || options.json;
|
|
1476
|
-
const stats = await bundleCore(
|
|
1477
|
-
flowConfig,
|
|
1478
|
-
buildOptions,
|
|
1479
|
-
logger2,
|
|
1480
|
-
shouldCollectStats
|
|
1481
|
-
);
|
|
1482
|
-
results.push({
|
|
1483
|
-
flowName,
|
|
1484
|
-
success: true,
|
|
1485
|
-
stats
|
|
1486
|
-
});
|
|
1487
|
-
if (!options.json && !options.all && options.stats && stats) {
|
|
1488
|
-
displayStats(stats, logger2);
|
|
1489
|
-
}
|
|
1490
|
-
} catch (error) {
|
|
1491
|
-
const errorMessage = getErrorMessage(error);
|
|
1492
|
-
results.push({
|
|
1493
|
-
flowName,
|
|
1494
|
-
success: false,
|
|
1495
|
-
error: errorMessage
|
|
1496
|
-
});
|
|
1497
|
-
if (!options.all) {
|
|
1498
|
-
throw error;
|
|
1499
|
-
}
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
const duration = timer.end() / 1e3;
|
|
1503
|
-
const successCount = results.filter((r) => r.success).length;
|
|
1504
|
-
const failureCount = results.filter((r) => !r.success).length;
|
|
1505
|
-
if (options.json) {
|
|
1506
|
-
const outputLogger = createLogger({ silent: false, json: false });
|
|
1507
|
-
const output = failureCount === 0 ? createSuccessOutput(
|
|
1508
|
-
{
|
|
1509
|
-
flows: results,
|
|
1510
|
-
summary: {
|
|
1511
|
-
total: results.length,
|
|
1512
|
-
success: successCount,
|
|
1513
|
-
failed: failureCount
|
|
1514
|
-
}
|
|
1515
|
-
},
|
|
1516
|
-
duration
|
|
1517
|
-
) : createErrorOutput(
|
|
1518
|
-
`${failureCount} flow(s) failed to build`,
|
|
1519
|
-
duration
|
|
1520
|
-
);
|
|
1521
|
-
outputLogger.log("white", JSON.stringify(output, null, 2));
|
|
1522
|
-
} else {
|
|
1523
|
-
if (options.all) {
|
|
1524
|
-
logger2.info(`
|
|
1525
|
-
\u{1F4CA} Build Summary:`);
|
|
1526
|
-
logger2.info(` Total: ${results.length}`);
|
|
1527
|
-
logger2.success(` \u2705 Success: ${successCount}`);
|
|
1528
|
-
if (failureCount > 0) {
|
|
1529
|
-
logger2.error(` \u274C Failed: ${failureCount}`);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
if (failureCount === 0) {
|
|
1533
|
-
logger2.success(
|
|
1534
|
-
`
|
|
1535
|
-
\u2705 Bundle created successfully in ${timer.format()}`
|
|
1536
|
-
);
|
|
1537
|
-
} else {
|
|
1538
|
-
throw new Error(`${failureCount} flow(s) failed to build`);
|
|
1539
|
-
}
|
|
1327
|
+
success: true,
|
|
1328
|
+
stats
|
|
1329
|
+
});
|
|
1330
|
+
if (!options.json && !options.all && options.stats && stats) {
|
|
1331
|
+
displayStats(stats, logger2);
|
|
1540
1332
|
}
|
|
1541
1333
|
} catch (error) {
|
|
1542
|
-
const duration = timer.getElapsed() / 1e3;
|
|
1543
1334
|
const errorMessage = getErrorMessage(error);
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1335
|
+
results.push({
|
|
1336
|
+
flowName,
|
|
1337
|
+
success: false,
|
|
1338
|
+
error: errorMessage
|
|
1339
|
+
});
|
|
1340
|
+
if (!options.all) {
|
|
1341
|
+
throw error;
|
|
1551
1342
|
}
|
|
1552
|
-
process.exit(1);
|
|
1553
1343
|
}
|
|
1554
|
-
}
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1344
|
+
}
|
|
1345
|
+
const duration = timer.end() / 1e3;
|
|
1346
|
+
const successCount = results.filter((r) => r.success).length;
|
|
1347
|
+
const failureCount = results.filter((r) => !r.success).length;
|
|
1348
|
+
if (options.json) {
|
|
1349
|
+
const output = failureCount === 0 ? createSuccessOutput(
|
|
1350
|
+
{
|
|
1351
|
+
flows: results,
|
|
1352
|
+
summary: {
|
|
1353
|
+
total: results.length,
|
|
1354
|
+
success: successCount,
|
|
1355
|
+
failed: failureCount
|
|
1356
|
+
}
|
|
1357
|
+
},
|
|
1358
|
+
duration
|
|
1359
|
+
) : createErrorOutput(
|
|
1360
|
+
`${failureCount} flow(s) failed to build`,
|
|
1361
|
+
duration
|
|
1362
|
+
);
|
|
1363
|
+
logger2.json(output);
|
|
1364
|
+
} else {
|
|
1365
|
+
if (options.all) {
|
|
1366
|
+
logger2.log(
|
|
1367
|
+
`
|
|
1368
|
+
Build Summary: ${successCount}/${results.length} succeeded`
|
|
1369
|
+
);
|
|
1370
|
+
if (failureCount > 0) {
|
|
1371
|
+
logger2.error(`Failed: ${failureCount}`);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
if (failureCount > 0) {
|
|
1375
|
+
throw new Error(`${failureCount} flow(s) failed to build`);
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
const duration = timer.getElapsed() / 1e3;
|
|
1380
|
+
const errorMessage = getErrorMessage(error);
|
|
1381
|
+
if (options.json) {
|
|
1382
|
+
const output = createErrorOutput(errorMessage, duration);
|
|
1383
|
+
logger2.json(output);
|
|
1384
|
+
} else {
|
|
1385
|
+
logger2.error(`Error: ${errorMessage}`);
|
|
1386
|
+
}
|
|
1387
|
+
process.exit(1);
|
|
1388
|
+
}
|
|
1561
1389
|
}
|
|
1562
1390
|
async function bundle(configOrPath, options = {}) {
|
|
1563
1391
|
let rawConfig;
|
|
@@ -1587,7 +1415,7 @@ async function bundle(configOrPath, options = {}) {
|
|
|
1587
1415
|
|
|
1588
1416
|
// src/commands/simulate/simulator.ts
|
|
1589
1417
|
import path10 from "path";
|
|
1590
|
-
import
|
|
1418
|
+
import fs8 from "fs-extra";
|
|
1591
1419
|
import { getPlatform as getPlatform2 } from "@walkeros/core";
|
|
1592
1420
|
|
|
1593
1421
|
// src/commands/simulate/tracker.ts
|
|
@@ -1624,9 +1452,9 @@ var CallTracker = class {
|
|
|
1624
1452
|
}
|
|
1625
1453
|
for (const fullPath of paths) {
|
|
1626
1454
|
const [destKey, ...pathParts] = fullPath.split(":");
|
|
1627
|
-
const
|
|
1628
|
-
if (!
|
|
1629
|
-
const cleanPath =
|
|
1455
|
+
const path14 = pathParts.join(":");
|
|
1456
|
+
if (!path14) continue;
|
|
1457
|
+
const cleanPath = path14.replace(/^call:/, "");
|
|
1630
1458
|
const parts = cleanPath.split(".");
|
|
1631
1459
|
let current = wrapped;
|
|
1632
1460
|
let source = env;
|
|
@@ -1670,7 +1498,7 @@ var CallTracker = class {
|
|
|
1670
1498
|
|
|
1671
1499
|
// src/commands/simulate/jsdom-executor.ts
|
|
1672
1500
|
import { JSDOM, VirtualConsole } from "jsdom";
|
|
1673
|
-
import
|
|
1501
|
+
import fs7 from "fs-extra";
|
|
1674
1502
|
function buildSandboxFromEnvs(envs, destinations, tracker) {
|
|
1675
1503
|
const baseBrowserMocks = {
|
|
1676
1504
|
Image: class MockImage {
|
|
@@ -1707,11 +1535,11 @@ function buildSandboxFromEnvs(envs, destinations, tracker) {
|
|
|
1707
1535
|
return sandbox;
|
|
1708
1536
|
}
|
|
1709
1537
|
function waitForWindowProperty(window, prop, timeout = 5e3) {
|
|
1710
|
-
return new Promise((
|
|
1538
|
+
return new Promise((resolve3, reject) => {
|
|
1711
1539
|
const start = Date.now();
|
|
1712
1540
|
const check = () => {
|
|
1713
1541
|
if (window[prop] !== void 0) {
|
|
1714
|
-
|
|
1542
|
+
resolve3();
|
|
1715
1543
|
} else if (Date.now() - start > timeout) {
|
|
1716
1544
|
reject(
|
|
1717
1545
|
new Error(
|
|
@@ -1739,7 +1567,7 @@ async function executeInJSDOM(bundlePath, destinations, event, tracker, envs, ti
|
|
|
1739
1567
|
const sandbox = buildSandboxFromEnvs(envs, destinations, tracker);
|
|
1740
1568
|
Object.assign(window, sandbox.window);
|
|
1741
1569
|
Object.assign(window.document, sandbox.document);
|
|
1742
|
-
const bundleCode = await
|
|
1570
|
+
const bundleCode = await fs7.readFile(bundlePath, "utf8");
|
|
1743
1571
|
try {
|
|
1744
1572
|
window.eval(bundleCode);
|
|
1745
1573
|
} catch (error) {
|
|
@@ -1878,10 +1706,7 @@ async function loadDestinationEnvs(destinations) {
|
|
|
1878
1706
|
simulation: envModule.simulation || []
|
|
1879
1707
|
};
|
|
1880
1708
|
}
|
|
1881
|
-
} catch
|
|
1882
|
-
console.warn(
|
|
1883
|
-
`Warning: Could not load env for destination "${destKey}": ${error instanceof Error ? error.message : String(error)}`
|
|
1884
|
-
);
|
|
1709
|
+
} catch {
|
|
1885
1710
|
}
|
|
1886
1711
|
}
|
|
1887
1712
|
return envs;
|
|
@@ -1938,7 +1763,7 @@ function formatSimulationResult(result, options = {}) {
|
|
|
1938
1763
|
async function executeSimulation(event, configPath) {
|
|
1939
1764
|
const startTime = Date.now();
|
|
1940
1765
|
let bundlePath;
|
|
1941
|
-
const tempDir =
|
|
1766
|
+
const tempDir = getTmpPath();
|
|
1942
1767
|
try {
|
|
1943
1768
|
if (!isObject(event) || !("name" in event) || typeof event.name !== "string") {
|
|
1944
1769
|
throw new Error(
|
|
@@ -1946,7 +1771,7 @@ async function executeSimulation(event, configPath) {
|
|
|
1946
1771
|
);
|
|
1947
1772
|
}
|
|
1948
1773
|
const typedEvent = event;
|
|
1949
|
-
await
|
|
1774
|
+
await fs8.ensureDir(tempDir);
|
|
1950
1775
|
const rawConfig = await loadJsonConfig(configPath);
|
|
1951
1776
|
const { flowConfig, buildOptions } = loadBundleConfig(rawConfig, {
|
|
1952
1777
|
configPath
|
|
@@ -2020,7 +1845,7 @@ async function executeSimulation(event, configPath) {
|
|
|
2020
1845
|
};
|
|
2021
1846
|
} finally {
|
|
2022
1847
|
if (tempDir) {
|
|
2023
|
-
await
|
|
1848
|
+
await fs8.remove(tempDir).catch(() => {
|
|
2024
1849
|
});
|
|
2025
1850
|
}
|
|
2026
1851
|
}
|
|
@@ -2029,59 +1854,50 @@ async function executeSimulation(event, configPath) {
|
|
|
2029
1854
|
// src/commands/simulate/index.ts
|
|
2030
1855
|
async function simulateCommand(options) {
|
|
2031
1856
|
const logger2 = createCommandLogger(options);
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
process.exit(1);
|
|
2077
|
-
}
|
|
2078
|
-
},
|
|
2079
|
-
"simulate",
|
|
2080
|
-
dockerArgs,
|
|
2081
|
-
options,
|
|
2082
|
-
logger2,
|
|
2083
|
-
options.config
|
|
2084
|
-
);
|
|
1857
|
+
if (options.dryRun) {
|
|
1858
|
+
logger2.log(
|
|
1859
|
+
`[DRY-RUN] Would execute simulate with config: ${options.config}`
|
|
1860
|
+
);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
const startTime = Date.now();
|
|
1864
|
+
try {
|
|
1865
|
+
const event = await loadJsonFromSource(options.event, {
|
|
1866
|
+
name: "event"
|
|
1867
|
+
});
|
|
1868
|
+
const result = await simulateCore(options.config, event, {
|
|
1869
|
+
json: options.json,
|
|
1870
|
+
verbose: options.verbose,
|
|
1871
|
+
silent: options.silent
|
|
1872
|
+
});
|
|
1873
|
+
const resultWithDuration = {
|
|
1874
|
+
...result,
|
|
1875
|
+
duration: (Date.now() - startTime) / 1e3
|
|
1876
|
+
};
|
|
1877
|
+
if (options.json) {
|
|
1878
|
+
logger2.json(resultWithDuration);
|
|
1879
|
+
} else {
|
|
1880
|
+
const output = formatSimulationResult(resultWithDuration, {
|
|
1881
|
+
json: false
|
|
1882
|
+
});
|
|
1883
|
+
logger2.log(output);
|
|
1884
|
+
}
|
|
1885
|
+
if (!result.success) {
|
|
1886
|
+
process.exit(1);
|
|
1887
|
+
}
|
|
1888
|
+
} catch (error) {
|
|
1889
|
+
const errorMessage = getErrorMessage(error);
|
|
1890
|
+
if (options.json) {
|
|
1891
|
+
logger2.json({
|
|
1892
|
+
success: false,
|
|
1893
|
+
error: errorMessage,
|
|
1894
|
+
duration: (Date.now() - startTime) / 1e3
|
|
1895
|
+
});
|
|
1896
|
+
} else {
|
|
1897
|
+
logger2.error(`Error: ${errorMessage}`);
|
|
1898
|
+
}
|
|
1899
|
+
process.exit(1);
|
|
1900
|
+
}
|
|
2085
1901
|
}
|
|
2086
1902
|
async function simulate(configOrPath, event, options = {}) {
|
|
2087
1903
|
if (typeof configOrPath !== "string") {
|
|
@@ -2098,153 +1914,125 @@ async function simulate(configOrPath, event, options = {}) {
|
|
|
2098
1914
|
// src/commands/push/index.ts
|
|
2099
1915
|
import path11 from "path";
|
|
2100
1916
|
import { JSDOM as JSDOM2, VirtualConsole as VirtualConsole2 } from "jsdom";
|
|
2101
|
-
import
|
|
1917
|
+
import fs9 from "fs-extra";
|
|
2102
1918
|
import { getPlatform as getPlatform3 } from "@walkeros/core";
|
|
2103
1919
|
import { schemas as schemas2 } from "@walkeros/core/dev";
|
|
2104
1920
|
async function pushCommand(options) {
|
|
2105
1921
|
const logger2 = createCommandLogger(options);
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
1922
|
+
const startTime = Date.now();
|
|
1923
|
+
try {
|
|
1924
|
+
logger2.debug("Loading event");
|
|
1925
|
+
const event = await loadJsonFromSource(options.event, {
|
|
1926
|
+
name: "event"
|
|
1927
|
+
});
|
|
1928
|
+
const eventResult = schemas2.PartialEventSchema.safeParse(event);
|
|
1929
|
+
if (!eventResult.success) {
|
|
1930
|
+
const errors = eventResult.error.issues.map((issue) => `${String(issue.path.join("."))}: ${issue.message}`).join(", ");
|
|
1931
|
+
throw new Error(`Invalid event: ${errors}`);
|
|
1932
|
+
}
|
|
1933
|
+
const parsedEvent = eventResult.data;
|
|
1934
|
+
if (!parsedEvent.name) {
|
|
1935
|
+
throw new Error('Invalid event: Missing required "name" property');
|
|
1936
|
+
}
|
|
1937
|
+
const validatedEvent = {
|
|
1938
|
+
name: parsedEvent.name,
|
|
1939
|
+
data: parsedEvent.data || {}
|
|
1940
|
+
};
|
|
1941
|
+
if (!validatedEvent.name.includes(" ")) {
|
|
1942
|
+
logger2.log(
|
|
1943
|
+
`Warning: Event name "${validatedEvent.name}" should follow "ENTITY ACTION" format (e.g., "page view")`
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
logger2.debug("Loading flow configuration");
|
|
1947
|
+
const configPath = path11.resolve(options.config);
|
|
1948
|
+
const rawConfig = await loadJsonConfig(configPath);
|
|
1949
|
+
const { flowConfig, buildOptions, flowName, isMultiFlow } = loadBundleConfig(rawConfig, {
|
|
1950
|
+
configPath: options.config,
|
|
1951
|
+
flowName: options.flow,
|
|
1952
|
+
logger: logger2
|
|
1953
|
+
});
|
|
1954
|
+
const platform = getPlatform3(flowConfig);
|
|
1955
|
+
logger2.debug("Bundling flow configuration");
|
|
1956
|
+
const configDir = path11.dirname(configPath);
|
|
1957
|
+
const tempDir = path11.join(
|
|
1958
|
+
configDir,
|
|
1959
|
+
".tmp",
|
|
1960
|
+
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
1961
|
+
);
|
|
1962
|
+
await fs9.ensureDir(tempDir);
|
|
1963
|
+
const tempPath = path11.join(
|
|
1964
|
+
tempDir,
|
|
1965
|
+
`bundle.${platform === "web" ? "js" : "mjs"}`
|
|
1966
|
+
);
|
|
1967
|
+
const pushBuildOptions = {
|
|
1968
|
+
...buildOptions,
|
|
1969
|
+
output: tempPath,
|
|
1970
|
+
// Web uses IIFE for browser-like execution, server uses ESM
|
|
1971
|
+
format: platform === "web" ? "iife" : "esm",
|
|
1972
|
+
platform: platform === "web" ? "browser" : "node",
|
|
1973
|
+
...platform === "web" && {
|
|
1974
|
+
windowCollector: "collector",
|
|
1975
|
+
windowElb: "elb"
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
await bundleCore(flowConfig, pushBuildOptions, logger2, false);
|
|
1979
|
+
logger2.debug(`Bundle created: ${tempPath}`);
|
|
1980
|
+
let result;
|
|
1981
|
+
if (platform === "web") {
|
|
1982
|
+
logger2.debug("Executing in web environment (JSDOM)");
|
|
1983
|
+
result = await executeWebPush(tempPath, validatedEvent, logger2);
|
|
1984
|
+
} else if (platform === "server") {
|
|
1985
|
+
logger2.debug("Executing in server environment (Node.js)");
|
|
1986
|
+
result = await executeServerPush(tempPath, validatedEvent, logger2);
|
|
1987
|
+
} else {
|
|
1988
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
1989
|
+
}
|
|
1990
|
+
const duration = Date.now() - startTime;
|
|
1991
|
+
if (options.json) {
|
|
1992
|
+
logger2.json({
|
|
1993
|
+
success: result.success,
|
|
1994
|
+
event: result.elbResult,
|
|
1995
|
+
duration
|
|
1996
|
+
});
|
|
1997
|
+
} else {
|
|
1998
|
+
if (result.success) {
|
|
1999
|
+
logger2.log("Event pushed successfully");
|
|
2000
|
+
if (result.elbResult && typeof result.elbResult === "object") {
|
|
2001
|
+
const pushResult = result.elbResult;
|
|
2002
|
+
if ("id" in pushResult && pushResult.id) {
|
|
2003
|
+
logger2.log(` Event ID: ${pushResult.id}`);
|
|
2165
2004
|
}
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
logger2.info("\u{1F310} Executing in web environment (JSDOM)...");
|
|
2172
|
-
result = await executeWebPush(tempPath, validatedEvent, logger2);
|
|
2173
|
-
} else if (platform === "server") {
|
|
2174
|
-
logger2.info("\u{1F5A5}\uFE0F Executing in server environment (Node.js)...");
|
|
2175
|
-
result = await executeServerPush(tempPath, validatedEvent, logger2);
|
|
2176
|
-
} else {
|
|
2177
|
-
throw new Error(`Unsupported platform: ${platform}`);
|
|
2178
|
-
}
|
|
2179
|
-
const duration = Date.now() - startTime;
|
|
2180
|
-
if (options.json) {
|
|
2181
|
-
const outputLogger = createLogger({ silent: false, json: false });
|
|
2182
|
-
outputLogger.log(
|
|
2183
|
-
"white",
|
|
2184
|
-
JSON.stringify(
|
|
2185
|
-
{
|
|
2186
|
-
success: result.success,
|
|
2187
|
-
event: result.elbResult,
|
|
2188
|
-
duration
|
|
2189
|
-
},
|
|
2190
|
-
null,
|
|
2191
|
-
2
|
|
2192
|
-
)
|
|
2193
|
-
);
|
|
2194
|
-
} else {
|
|
2195
|
-
if (result.success) {
|
|
2196
|
-
logger2.success("\u2705 Event pushed successfully");
|
|
2197
|
-
if (result.elbResult && typeof result.elbResult === "object") {
|
|
2198
|
-
const pushResult = result.elbResult;
|
|
2199
|
-
if ("id" in pushResult && pushResult.id) {
|
|
2200
|
-
logger2.info(` Event ID: ${pushResult.id}`);
|
|
2201
|
-
}
|
|
2202
|
-
if ("entity" in pushResult && pushResult.entity) {
|
|
2203
|
-
logger2.info(` Entity: ${pushResult.entity}`);
|
|
2204
|
-
}
|
|
2205
|
-
if ("action" in pushResult && pushResult.action) {
|
|
2206
|
-
logger2.info(` Action: ${pushResult.action}`);
|
|
2207
|
-
}
|
|
2208
|
-
}
|
|
2209
|
-
logger2.info(` Duration: ${duration}ms`);
|
|
2210
|
-
} else {
|
|
2211
|
-
logger2.error(`\u274C Push failed: ${result.error}`);
|
|
2212
|
-
process.exit(1);
|
|
2005
|
+
if ("entity" in pushResult && pushResult.entity) {
|
|
2006
|
+
logger2.log(` Entity: ${pushResult.entity}`);
|
|
2007
|
+
}
|
|
2008
|
+
if ("action" in pushResult && pushResult.action) {
|
|
2009
|
+
logger2.log(` Action: ${pushResult.action}`);
|
|
2213
2010
|
}
|
|
2214
2011
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
}
|
|
2219
|
-
} catch (error) {
|
|
2220
|
-
const duration = Date.now() - startTime;
|
|
2221
|
-
const errorMessage = getErrorMessage(error);
|
|
2222
|
-
if (options.json) {
|
|
2223
|
-
const outputLogger = createLogger({ silent: false, json: false });
|
|
2224
|
-
outputLogger.log(
|
|
2225
|
-
"white",
|
|
2226
|
-
JSON.stringify(
|
|
2227
|
-
{
|
|
2228
|
-
success: false,
|
|
2229
|
-
error: errorMessage,
|
|
2230
|
-
duration
|
|
2231
|
-
},
|
|
2232
|
-
null,
|
|
2233
|
-
2
|
|
2234
|
-
)
|
|
2235
|
-
);
|
|
2236
|
-
} else {
|
|
2237
|
-
logger2.error(`\u274C Push command failed: ${errorMessage}`);
|
|
2238
|
-
}
|
|
2012
|
+
logger2.log(` Duration: ${duration}ms`);
|
|
2013
|
+
} else {
|
|
2014
|
+
logger2.error(`Error: ${result.error}`);
|
|
2239
2015
|
process.exit(1);
|
|
2240
2016
|
}
|
|
2241
|
-
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2017
|
+
}
|
|
2018
|
+
try {
|
|
2019
|
+
await fs9.remove(tempDir);
|
|
2020
|
+
} catch {
|
|
2021
|
+
}
|
|
2022
|
+
} catch (error) {
|
|
2023
|
+
const duration = Date.now() - startTime;
|
|
2024
|
+
const errorMessage = getErrorMessage(error);
|
|
2025
|
+
if (options.json) {
|
|
2026
|
+
logger2.json({
|
|
2027
|
+
success: false,
|
|
2028
|
+
error: errorMessage,
|
|
2029
|
+
duration
|
|
2030
|
+
});
|
|
2031
|
+
} else {
|
|
2032
|
+
logger2.error(`Error: ${errorMessage}`);
|
|
2033
|
+
}
|
|
2034
|
+
process.exit(1);
|
|
2035
|
+
}
|
|
2248
2036
|
}
|
|
2249
2037
|
async function executeWebPush(bundlePath, event, logger2) {
|
|
2250
2038
|
const startTime = Date.now();
|
|
@@ -2258,7 +2046,7 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
2258
2046
|
});
|
|
2259
2047
|
const { window } = dom;
|
|
2260
2048
|
logger2.debug("Loading bundle...");
|
|
2261
|
-
const bundleCode = await
|
|
2049
|
+
const bundleCode = await fs9.readFile(bundlePath, "utf8");
|
|
2262
2050
|
window.eval(bundleCode);
|
|
2263
2051
|
logger2.debug("Waiting for elb...");
|
|
2264
2052
|
await waitForWindowProperty2(
|
|
@@ -2268,7 +2056,7 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
2268
2056
|
);
|
|
2269
2057
|
const windowObj = window;
|
|
2270
2058
|
const elb = windowObj.elb;
|
|
2271
|
-
logger2.
|
|
2059
|
+
logger2.log(`Pushing event: ${event.name}`);
|
|
2272
2060
|
const elbResult = await elb(event.name, event.data);
|
|
2273
2061
|
return {
|
|
2274
2062
|
success: true,
|
|
@@ -2306,7 +2094,7 @@ async function executeServerPush(bundlePath, event, logger2, timeout = 6e4) {
|
|
|
2306
2094
|
);
|
|
2307
2095
|
}
|
|
2308
2096
|
const { elb } = result;
|
|
2309
|
-
logger2.
|
|
2097
|
+
logger2.log(`Pushing event: ${event.name}`);
|
|
2310
2098
|
const elbResult = await elb(event.name, event.data);
|
|
2311
2099
|
return {
|
|
2312
2100
|
success: true,
|
|
@@ -2324,11 +2112,11 @@ async function executeServerPush(bundlePath, event, logger2, timeout = 6e4) {
|
|
|
2324
2112
|
}
|
|
2325
2113
|
}
|
|
2326
2114
|
function waitForWindowProperty2(window, prop, timeout = 5e3) {
|
|
2327
|
-
return new Promise((
|
|
2115
|
+
return new Promise((resolve3, reject) => {
|
|
2328
2116
|
const start = Date.now();
|
|
2329
2117
|
const check = () => {
|
|
2330
2118
|
if (window[prop] !== void 0) {
|
|
2331
|
-
|
|
2119
|
+
resolve3();
|
|
2332
2120
|
} else if (Date.now() - start > timeout) {
|
|
2333
2121
|
reject(
|
|
2334
2122
|
new Error(
|
|
@@ -2399,7 +2187,7 @@ function validatePort(port) {
|
|
|
2399
2187
|
|
|
2400
2188
|
// src/commands/run/utils.ts
|
|
2401
2189
|
import path12 from "path";
|
|
2402
|
-
import
|
|
2190
|
+
import fs10 from "fs-extra";
|
|
2403
2191
|
async function prepareBundleForRun(configPath, options) {
|
|
2404
2192
|
const configDir = path12.dirname(path12.resolve(configPath));
|
|
2405
2193
|
const tempDir = path12.join(
|
|
@@ -2407,7 +2195,7 @@ async function prepareBundleForRun(configPath, options) {
|
|
|
2407
2195
|
".tmp",
|
|
2408
2196
|
`run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2409
2197
|
);
|
|
2410
|
-
await
|
|
2198
|
+
await fs10.ensureDir(tempDir);
|
|
2411
2199
|
const tempPath = path12.join(tempDir, "bundle.mjs");
|
|
2412
2200
|
await bundle(configPath, {
|
|
2413
2201
|
cache: true,
|
|
@@ -2427,7 +2215,128 @@ function isPreBuiltConfig(configPath) {
|
|
|
2427
2215
|
|
|
2428
2216
|
// src/commands/run/execution.ts
|
|
2429
2217
|
import { createLogger as createLogger2, Level } from "@walkeros/core";
|
|
2430
|
-
|
|
2218
|
+
|
|
2219
|
+
// src/runtime/runner.ts
|
|
2220
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
2221
|
+
import { resolve, dirname as dirname2 } from "path";
|
|
2222
|
+
async function runFlow(file, config, logger2) {
|
|
2223
|
+
logger2.info(`Loading flow from ${file}`);
|
|
2224
|
+
try {
|
|
2225
|
+
const absolutePath = resolve(file);
|
|
2226
|
+
const flowDir = dirname2(absolutePath);
|
|
2227
|
+
process.chdir(flowDir);
|
|
2228
|
+
const fileUrl = pathToFileURL2(absolutePath).href;
|
|
2229
|
+
const module = await import(fileUrl);
|
|
2230
|
+
if (!module.default || typeof module.default !== "function") {
|
|
2231
|
+
logger2.throw(
|
|
2232
|
+
`Invalid flow bundle: ${file} must export a default function`
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
const result = await module.default(config);
|
|
2236
|
+
if (!result || !result.collector) {
|
|
2237
|
+
logger2.throw(`Invalid flow bundle: ${file} must return { collector }`);
|
|
2238
|
+
}
|
|
2239
|
+
const { collector } = result;
|
|
2240
|
+
logger2.info("Flow running");
|
|
2241
|
+
if (config?.port) {
|
|
2242
|
+
logger2.info(`Port: ${config.port}`);
|
|
2243
|
+
}
|
|
2244
|
+
const shutdown = async (signal) => {
|
|
2245
|
+
logger2.info(`Received ${signal}, shutting down gracefully...`);
|
|
2246
|
+
try {
|
|
2247
|
+
if (collector.command) {
|
|
2248
|
+
await collector.command("shutdown");
|
|
2249
|
+
}
|
|
2250
|
+
logger2.info("Shutdown complete");
|
|
2251
|
+
process.exit(0);
|
|
2252
|
+
} catch (error) {
|
|
2253
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2254
|
+
logger2.error(`Error during shutdown: ${message}`);
|
|
2255
|
+
process.exit(1);
|
|
2256
|
+
}
|
|
2257
|
+
};
|
|
2258
|
+
process.on("SIGTERM", () => shutdown("SIGTERM"));
|
|
2259
|
+
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
2260
|
+
await new Promise(() => {
|
|
2261
|
+
});
|
|
2262
|
+
} catch (error) {
|
|
2263
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2264
|
+
logger2.error(`Failed to run flow: ${message}`);
|
|
2265
|
+
if (error instanceof Error && error.stack) {
|
|
2266
|
+
logger2.debug("Stack trace:", { stack: error.stack });
|
|
2267
|
+
}
|
|
2268
|
+
throw error;
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
// src/runtime/serve.ts
|
|
2273
|
+
import express from "express";
|
|
2274
|
+
import { resolve as resolve2 } from "path";
|
|
2275
|
+
async function runServeMode(config, logger2) {
|
|
2276
|
+
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : config?.port || 8080;
|
|
2277
|
+
const host = process.env.HOST || config?.host || "0.0.0.0";
|
|
2278
|
+
const file = resolve2(process.env.FILE || config?.file || "./dist/walker.js");
|
|
2279
|
+
const serveName = process.env.SERVE_NAME || config?.serveName || "walker.js";
|
|
2280
|
+
const servePath = process.env.SERVE_PATH || config?.servePath || "";
|
|
2281
|
+
const urlPath = servePath ? `/${servePath}/${serveName}` : `/${serveName}`;
|
|
2282
|
+
logger2.info("Starting single-file server...");
|
|
2283
|
+
logger2.info(`File: ${file}`);
|
|
2284
|
+
logger2.info(`URL: http://${host}:${port}${urlPath}`);
|
|
2285
|
+
try {
|
|
2286
|
+
const app = express();
|
|
2287
|
+
app.get("/health", (req, res) => {
|
|
2288
|
+
res.json({
|
|
2289
|
+
status: "ok",
|
|
2290
|
+
version: VERSION,
|
|
2291
|
+
timestamp: Date.now(),
|
|
2292
|
+
mode: "serve",
|
|
2293
|
+
file,
|
|
2294
|
+
url: urlPath
|
|
2295
|
+
});
|
|
2296
|
+
});
|
|
2297
|
+
app.get(urlPath, (req, res) => {
|
|
2298
|
+
res.type("application/javascript");
|
|
2299
|
+
res.sendFile(file, { dotfiles: "allow" }, (err) => {
|
|
2300
|
+
if (err && !res.headersSent) {
|
|
2301
|
+
const errCode = err.code;
|
|
2302
|
+
const errStatus = err.status || err.statusCode;
|
|
2303
|
+
if (errCode !== "ECONNABORTED") {
|
|
2304
|
+
logger2.error(
|
|
2305
|
+
`sendFile error for ${file}: ${err.message} (code: ${errCode}, status: ${errStatus})`
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
if (errStatus === 404 || errCode === "ENOENT" || errCode === "EISDIR" || errCode === "ENOTDIR") {
|
|
2309
|
+
res.status(404).send("File not found");
|
|
2310
|
+
} else if (errCode !== "ECONNABORTED") {
|
|
2311
|
+
res.status(500).send("Internal server error");
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
});
|
|
2316
|
+
const server = app.listen(port, host, () => {
|
|
2317
|
+
logger2.info(`Server listening on http://${host}:${port}`);
|
|
2318
|
+
logger2.info(`GET ${urlPath} - Bundle file`);
|
|
2319
|
+
logger2.info(`GET /health - Health check`);
|
|
2320
|
+
});
|
|
2321
|
+
const shutdownHandler = (signal) => {
|
|
2322
|
+
logger2.info(`Received ${signal}, shutting down...`);
|
|
2323
|
+
server.close(() => {
|
|
2324
|
+
logger2.info("Server closed");
|
|
2325
|
+
process.exit(0);
|
|
2326
|
+
});
|
|
2327
|
+
};
|
|
2328
|
+
process.on("SIGTERM", () => shutdownHandler("SIGTERM"));
|
|
2329
|
+
process.on("SIGINT", () => shutdownHandler("SIGINT"));
|
|
2330
|
+
await new Promise(() => {
|
|
2331
|
+
});
|
|
2332
|
+
} catch (error) {
|
|
2333
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2334
|
+
logger2.error(`Server failed: ${message}`);
|
|
2335
|
+
process.exit(1);
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
// src/commands/run/execution.ts
|
|
2431
2340
|
var logLevel = process.env.VERBOSE === "true" ? Level.DEBUG : Level.INFO;
|
|
2432
2341
|
var logger = createLogger2({ level: logLevel });
|
|
2433
2342
|
async function executeRunLocal(mode, flowPath, options) {
|
|
@@ -2475,76 +2384,40 @@ async function runCommand(mode, options) {
|
|
|
2475
2384
|
if (mode === "collect") {
|
|
2476
2385
|
if (isPreBuilt) {
|
|
2477
2386
|
flowPath = path13.resolve(configPath);
|
|
2478
|
-
|
|
2479
|
-
logger2.info(`\u{1F4E6} Using pre-built flow: ${path13.basename(flowPath)}`);
|
|
2480
|
-
}
|
|
2387
|
+
logger2.debug(`Using pre-built flow: ${path13.basename(flowPath)}`);
|
|
2481
2388
|
} else {
|
|
2482
|
-
|
|
2483
|
-
logger2.info("\u{1F528} Building flow bundle...");
|
|
2484
|
-
}
|
|
2389
|
+
logger2.debug("Building flow bundle");
|
|
2485
2390
|
flowPath = await prepareBundleForRun(configPath, {
|
|
2486
2391
|
verbose: options.verbose,
|
|
2487
2392
|
silent: options.json || options.silent
|
|
2488
2393
|
});
|
|
2489
|
-
|
|
2490
|
-
logger2.success("\u2705 Bundle ready");
|
|
2491
|
-
}
|
|
2394
|
+
logger2.debug("Bundle ready");
|
|
2492
2395
|
}
|
|
2493
2396
|
}
|
|
2494
|
-
const executionMode = getExecutionMode(options);
|
|
2495
2397
|
if (options.dryRun) {
|
|
2496
|
-
|
|
2497
|
-
logger2.info(
|
|
2498
|
-
`[DRY-RUN] Would execute in Docker: run ${mode} with runtime image`
|
|
2499
|
-
);
|
|
2500
|
-
} else {
|
|
2501
|
-
logger2.info(`[DRY-RUN] Would execute locally: run ${mode}`);
|
|
2502
|
-
}
|
|
2398
|
+
logger2.log(`[DRY-RUN] Would execute locally: run ${mode}`);
|
|
2503
2399
|
return;
|
|
2504
2400
|
}
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
logger2.info("\u{1F433} Executing in production runtime container...");
|
|
2514
|
-
}
|
|
2515
|
-
await executeRunInDocker(mode, flowPath, {
|
|
2516
|
-
port: options.port,
|
|
2517
|
-
host: options.host,
|
|
2518
|
-
serveName: options.serveName,
|
|
2519
|
-
servePath: options.servePath,
|
|
2520
|
-
silent: options.silent
|
|
2521
|
-
});
|
|
2522
|
-
} else {
|
|
2523
|
-
if (!options.json && !options.silent) {
|
|
2524
|
-
const modeLabel = mode === "collect" ? "Collector" : "Server";
|
|
2525
|
-
logger2.info(`\u{1F5A5}\uFE0F Starting ${modeLabel} locally...`);
|
|
2526
|
-
}
|
|
2527
|
-
await executeRunLocal(mode, flowPath, {
|
|
2528
|
-
port: options.port,
|
|
2529
|
-
host: options.host,
|
|
2530
|
-
serveName: options.serveName,
|
|
2531
|
-
servePath: options.servePath
|
|
2532
|
-
});
|
|
2533
|
-
}
|
|
2401
|
+
const modeLabel = mode === "collect" ? "Collector" : "Server";
|
|
2402
|
+
logger2.log(`Starting ${modeLabel}...`);
|
|
2403
|
+
await executeRunLocal(mode, flowPath, {
|
|
2404
|
+
port: options.port,
|
|
2405
|
+
host: options.host,
|
|
2406
|
+
serveName: options.serveName,
|
|
2407
|
+
servePath: options.servePath
|
|
2408
|
+
});
|
|
2534
2409
|
} catch (error) {
|
|
2535
2410
|
const duration = timer.getElapsed() / 1e3;
|
|
2536
2411
|
const errorMessage = getErrorMessage(error);
|
|
2537
2412
|
if (options.json) {
|
|
2538
|
-
|
|
2413
|
+
logger2.json({
|
|
2539
2414
|
success: false,
|
|
2540
2415
|
mode,
|
|
2541
2416
|
error: errorMessage,
|
|
2542
2417
|
duration
|
|
2543
|
-
};
|
|
2544
|
-
console.log(JSON.stringify(output, null, 2));
|
|
2418
|
+
});
|
|
2545
2419
|
} else {
|
|
2546
|
-
logger2.error(
|
|
2547
|
-
logger2.error(errorMessage);
|
|
2420
|
+
logger2.error(`Error: ${errorMessage}`);
|
|
2548
2421
|
}
|
|
2549
2422
|
process.exit(1);
|
|
2550
2423
|
}
|
|
@@ -2594,56 +2467,59 @@ async function run(mode, options) {
|
|
|
2594
2467
|
}
|
|
2595
2468
|
|
|
2596
2469
|
// src/commands/cache.ts
|
|
2597
|
-
import
|
|
2598
|
-
import path14 from "path";
|
|
2599
|
-
var CACHE_DIR = path14.join(".tmp", "cache");
|
|
2470
|
+
import fs11 from "fs-extra";
|
|
2600
2471
|
function registerCacheCommand(program2) {
|
|
2601
2472
|
const cache = program2.command("cache").description("Manage the CLI cache");
|
|
2602
|
-
cache.command("clear").description("Clear all cached packages and builds").option("--packages", "Clear only package cache").option("--builds", "Clear only build cache").action(async (options) => {
|
|
2473
|
+
cache.command("clear").description("Clear all cached packages and builds").option("--packages", "Clear only package cache").option("--builds", "Clear only build cache").option("--tmp-dir <dir>", "Custom temp directory").option("--silent", "Suppress output").action(async (options) => {
|
|
2474
|
+
const logger2 = createLogger({ silent: options.silent });
|
|
2475
|
+
const tmpDir = options.tmpDir;
|
|
2603
2476
|
if (options.packages) {
|
|
2604
|
-
await
|
|
2605
|
-
|
|
2477
|
+
await fs11.remove(getTmpPath(tmpDir, "cache", "packages"));
|
|
2478
|
+
logger2.log("Package cache cleared");
|
|
2606
2479
|
} else if (options.builds) {
|
|
2607
|
-
await
|
|
2608
|
-
|
|
2480
|
+
await fs11.remove(getTmpPath(tmpDir, "cache", "builds"));
|
|
2481
|
+
logger2.log("Build cache cleared");
|
|
2609
2482
|
} else {
|
|
2610
|
-
await
|
|
2611
|
-
|
|
2483
|
+
await fs11.remove(getTmpPath(tmpDir, "cache"));
|
|
2484
|
+
logger2.log("All caches cleared");
|
|
2612
2485
|
}
|
|
2613
2486
|
});
|
|
2614
|
-
cache.command("info").description("Show cache statistics").action(async () => {
|
|
2615
|
-
const
|
|
2616
|
-
const
|
|
2487
|
+
cache.command("info").description("Show cache statistics").option("--tmp-dir <dir>", "Custom temp directory").option("--silent", "Suppress output").action(async (options) => {
|
|
2488
|
+
const logger2 = createLogger({ silent: options.silent });
|
|
2489
|
+
const tmpDir = options.tmpDir;
|
|
2490
|
+
const packagesDir = getTmpPath(tmpDir, "cache", "packages");
|
|
2491
|
+
const buildsDir = getTmpPath(tmpDir, "cache", "builds");
|
|
2617
2492
|
const packageCount = await countEntries(packagesDir);
|
|
2618
2493
|
const buildCount = await countEntries(buildsDir);
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2494
|
+
logger2.log(`Cache directory: ${getTmpPath(tmpDir, "cache")}`);
|
|
2495
|
+
logger2.log(`Cached packages: ${packageCount}`);
|
|
2496
|
+
logger2.log(`Cached builds: ${buildCount}`);
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
function registerCleanCommand(program2) {
|
|
2500
|
+
program2.command("clean").description("Clear the entire temp directory (.tmp/)").option("--tmp-dir <dir>", "Custom temp directory").option("--silent", "Suppress output").action(async (options) => {
|
|
2501
|
+
const logger2 = createLogger({ silent: options.silent });
|
|
2502
|
+
const tmpDir = options.tmpDir || getDefaultTmpRoot();
|
|
2503
|
+
await fs11.remove(tmpDir);
|
|
2504
|
+
logger2.log(`Temp directory cleared: ${tmpDir}`);
|
|
2622
2505
|
});
|
|
2623
2506
|
}
|
|
2624
2507
|
async function countEntries(dir) {
|
|
2625
|
-
if (!await
|
|
2626
|
-
const entries = await
|
|
2508
|
+
if (!await fs11.pathExists(dir)) return 0;
|
|
2509
|
+
const entries = await fs11.readdir(dir);
|
|
2627
2510
|
return entries.length;
|
|
2628
2511
|
}
|
|
2629
2512
|
|
|
2630
2513
|
// src/index.ts
|
|
2631
|
-
var __filename = fileURLToPath2(import.meta.url);
|
|
2632
|
-
var __dirname = dirname(__filename);
|
|
2633
|
-
var packageJson = JSON.parse(
|
|
2634
|
-
readFileSync(join(__dirname, "../package.json"), "utf-8")
|
|
2635
|
-
);
|
|
2636
|
-
var VERSION = packageJson.version;
|
|
2637
2514
|
var program = new Command();
|
|
2638
2515
|
program.name("walkeros").description("walkerOS CLI - Bundle and deploy walkerOS components").version(VERSION);
|
|
2639
2516
|
program.hook("preAction", (thisCommand, actionCommand) => {
|
|
2640
2517
|
const options = actionCommand.opts();
|
|
2641
2518
|
if (!options.silent && !options.json) {
|
|
2642
|
-
console.log(
|
|
2643
|
-
console.log(`\u{1F433} Using Docker runtime: walkeros/docker:${DOCKER_VERSION2}`);
|
|
2519
|
+
console.log(chalk2.hex("#01b5e2")(`walkerOS v${VERSION}`));
|
|
2644
2520
|
}
|
|
2645
2521
|
});
|
|
2646
|
-
program.command("bundle [file]").description("Bundle NPM packages with custom code").option("-f, --flow <name>", "flow to build (for multi-flow configs)").option("--all", "build all flows (for multi-flow configs)").option("-s, --stats", "show bundle statistics").option("--json", "output statistics in JSON format (implies --stats)").option("--no-cache", "disable package caching and download fresh packages").option("-v, --verbose", "verbose output").option("--
|
|
2522
|
+
program.command("bundle [file]").description("Bundle NPM packages with custom code").option("-f, --flow <name>", "flow to build (for multi-flow configs)").option("--all", "build all flows (for multi-flow configs)").option("-s, --stats", "show bundle statistics").option("--json", "output statistics in JSON format (implies --stats)").option("--no-cache", "disable package caching and download fresh packages").option("-v, --verbose", "verbose output").option("--dry-run", "preview command without executing").option("--silent", "suppress output").action(async (file, options) => {
|
|
2647
2523
|
await bundleCommand({
|
|
2648
2524
|
config: file || "bundle.config.json",
|
|
2649
2525
|
flow: options.flow,
|
|
@@ -2652,7 +2528,6 @@ program.command("bundle [file]").description("Bundle NPM packages with custom co
|
|
|
2652
2528
|
json: options.json,
|
|
2653
2529
|
cache: options.cache,
|
|
2654
2530
|
verbose: options.verbose,
|
|
2655
|
-
local: options.local,
|
|
2656
2531
|
dryRun: options.dryRun,
|
|
2657
2532
|
silent: options.silent
|
|
2658
2533
|
});
|
|
@@ -2660,13 +2535,12 @@ program.command("bundle [file]").description("Bundle NPM packages with custom co
|
|
|
2660
2535
|
program.command("simulate [file]").description("Simulate event processing and capture API calls").option(
|
|
2661
2536
|
"-e, --event <source>",
|
|
2662
2537
|
"Event to simulate (JSON string, file path, or URL)"
|
|
2663
|
-
).option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--
|
|
2538
|
+
).option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--dry-run", "preview command without executing").option("--silent", "suppress output").action(async (file, options) => {
|
|
2664
2539
|
await simulateCommand({
|
|
2665
2540
|
config: file || "bundle.config.json",
|
|
2666
2541
|
event: options.event,
|
|
2667
2542
|
json: options.json,
|
|
2668
2543
|
verbose: options.verbose,
|
|
2669
|
-
local: options.local,
|
|
2670
2544
|
dryRun: options.dryRun,
|
|
2671
2545
|
silent: options.silent
|
|
2672
2546
|
});
|
|
@@ -2674,35 +2548,33 @@ program.command("simulate [file]").description("Simulate event processing and ca
|
|
|
2674
2548
|
program.command("push [file]").description("Push an event through the flow with real API execution").requiredOption(
|
|
2675
2549
|
"-e, --event <source>",
|
|
2676
2550
|
"Event to push (JSON string, file path, or URL)"
|
|
2677
|
-
).option("--flow <name>", "Flow name (for multi-flow configs)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("-s, --silent", "Suppress output").
|
|
2551
|
+
).option("--flow <name>", "Flow name (for multi-flow configs)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("-s, --silent", "Suppress output").action(async (file, options) => {
|
|
2678
2552
|
await pushCommand({
|
|
2679
2553
|
config: file || "bundle.config.json",
|
|
2680
2554
|
event: options.event,
|
|
2681
2555
|
flow: options.flow,
|
|
2682
2556
|
json: options.json,
|
|
2683
2557
|
verbose: options.verbose,
|
|
2684
|
-
silent: options.silent
|
|
2685
|
-
local: options.local
|
|
2558
|
+
silent: options.silent
|
|
2686
2559
|
});
|
|
2687
2560
|
});
|
|
2688
2561
|
var runCmd = program.command("run").description("Run walkerOS flows in collect or serve mode");
|
|
2689
2562
|
runCmd.command("collect [file]").description(
|
|
2690
2563
|
"Run collector mode (event collection endpoint). Defaults to server-collect.mjs if no file specified."
|
|
2691
|
-
).option("-p, --port <number>", "Port to listen on (default: 8080)", parseInt).option("-h, --host <address>", "Host address (default: 0.0.0.0)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--
|
|
2564
|
+
).option("-p, --port <number>", "Port to listen on (default: 8080)", parseInt).option("-h, --host <address>", "Host address (default: 0.0.0.0)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--dry-run", "preview command without executing").option("--silent", "suppress output").action(async (file, options) => {
|
|
2692
2565
|
await runCommand("collect", {
|
|
2693
2566
|
config: file || "server-collect.mjs",
|
|
2694
2567
|
port: options.port,
|
|
2695
2568
|
host: options.host,
|
|
2696
2569
|
json: options.json,
|
|
2697
2570
|
verbose: options.verbose,
|
|
2698
|
-
local: options.local,
|
|
2699
2571
|
dryRun: options.dryRun,
|
|
2700
2572
|
silent: options.silent
|
|
2701
2573
|
});
|
|
2702
2574
|
});
|
|
2703
2575
|
runCmd.command("serve [file]").description(
|
|
2704
2576
|
"Run serve mode (single-file server for browser bundles). Defaults to baked-in web-serve.js if no file specified."
|
|
2705
|
-
).option("-p, --port <number>", "Port to listen on (default: 8080)", parseInt).option("-h, --host <address>", "Host address (default: 0.0.0.0)").option("--name <filename>", "Filename in URL (default: walker.js)").option("--path <directory>", "URL directory path (e.g., libs/v1)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--
|
|
2577
|
+
).option("-p, --port <number>", "Port to listen on (default: 8080)", parseInt).option("-h, --host <address>", "Host address (default: 0.0.0.0)").option("--name <filename>", "Filename in URL (default: walker.js)").option("--path <directory>", "URL directory path (e.g., libs/v1)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("--dry-run", "preview command without executing").option("--silent", "suppress output").action(async (file, options) => {
|
|
2706
2578
|
await runCommand("serve", {
|
|
2707
2579
|
config: file || "web-serve.js",
|
|
2708
2580
|
port: options.port,
|
|
@@ -2711,12 +2583,12 @@ runCmd.command("serve [file]").description(
|
|
|
2711
2583
|
servePath: options.path,
|
|
2712
2584
|
json: options.json,
|
|
2713
2585
|
verbose: options.verbose,
|
|
2714
|
-
local: options.local,
|
|
2715
2586
|
dryRun: options.dryRun,
|
|
2716
2587
|
silent: options.silent
|
|
2717
2588
|
});
|
|
2718
2589
|
});
|
|
2719
2590
|
registerCacheCommand(program);
|
|
2591
|
+
registerCleanCommand(program);
|
|
2720
2592
|
program.parse();
|
|
2721
2593
|
export {
|
|
2722
2594
|
bundle,
|