@walkeros/cli 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +53 -8
- package/dist/examples/flow-order-complete.json +0 -1
- package/dist/examples/flow-simple.json +0 -3
- package/dist/examples/flow.json +0 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +390 -196
- package/dist/index.js.map +1 -1
- package/dist/runtime/main.js +3 -2
- package/dist/runtime/main.js.map +1 -1
- package/examples/flow-order-complete.json +0 -1
- package/examples/flow-simple.json +0 -3
- package/examples/flow.json +0 -1
- package/package.json +2 -2
- package/dist/__tests__/bundle/bundler-helpers.test.d.ts +0 -2
- package/dist/__tests__/bundle/bundler-helpers.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/bundler-helpers.test.js +0 -151
- package/dist/__tests__/bundle/bundler-helpers.test.js.map +0 -1
- package/dist/__tests__/bundle/bundler.test.d.ts +0 -2
- package/dist/__tests__/bundle/bundler.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/bundler.test.js +0 -352
- package/dist/__tests__/bundle/bundler.test.js.map +0 -1
- package/dist/__tests__/bundle/programmatic.test.d.ts +0 -2
- package/dist/__tests__/bundle/programmatic.test.d.ts.map +0 -1
- package/dist/__tests__/bundle/programmatic.test.js +0 -148
- package/dist/__tests__/bundle/programmatic.test.js.map +0 -1
- package/dist/__tests__/cli-e2e.test.d.ts +0 -8
- package/dist/__tests__/cli-e2e.test.d.ts.map +0 -1
- package/dist/__tests__/cli-e2e.test.js +0 -145
- package/dist/__tests__/cli-e2e.test.js.map +0 -1
- package/dist/__tests__/cli.test.d.ts +0 -2
- package/dist/__tests__/cli.test.d.ts.map +0 -1
- package/dist/__tests__/cli.test.js +0 -179
- package/dist/__tests__/cli.test.js.map +0 -1
- package/dist/__tests__/config-loader.test.d.ts +0 -7
- package/dist/__tests__/config-loader.test.d.ts.map +0 -1
- package/dist/__tests__/config-loader.test.js +0 -414
- package/dist/__tests__/config-loader.test.js.map +0 -1
- package/dist/__tests__/core/asset-resolver.test.d.ts +0 -2
- package/dist/__tests__/core/asset-resolver.test.d.ts.map +0 -1
- package/dist/__tests__/core/asset-resolver.test.js +0 -14
- package/dist/__tests__/core/asset-resolver.test.js.map +0 -1
- package/dist/__tests__/core/build-cache.test.d.ts +0 -2
- package/dist/__tests__/core/build-cache.test.d.ts.map +0 -1
- package/dist/__tests__/core/build-cache.test.js +0 -55
- package/dist/__tests__/core/build-cache.test.js.map +0 -1
- package/dist/__tests__/core/cache-utils.test.d.ts +0 -2
- package/dist/__tests__/core/cache-utils.test.d.ts.map +0 -1
- package/dist/__tests__/core/cache-utils.test.js +0 -70
- package/dist/__tests__/core/cache-utils.test.js.map +0 -1
- package/dist/__tests__/core/config.test.d.ts +0 -2
- package/dist/__tests__/core/config.test.d.ts.map +0 -1
- package/dist/__tests__/core/config.test.js +0 -79
- package/dist/__tests__/core/config.test.js.map +0 -1
- package/dist/__tests__/core/logger.test.d.ts +0 -2
- package/dist/__tests__/core/logger.test.d.ts.map +0 -1
- package/dist/__tests__/core/logger.test.js +0 -53
- package/dist/__tests__/core/logger.test.js.map +0 -1
- package/dist/__tests__/integration/bundle-run.integration.test.d.ts +0 -8
- package/dist/__tests__/integration/bundle-run.integration.test.d.ts.map +0 -1
- package/dist/__tests__/integration/bundle-run.integration.test.js +0 -54
- package/dist/__tests__/integration/bundle-run.integration.test.js.map +0 -1
- package/dist/__tests__/push/push.test.d.ts +0 -7
- package/dist/__tests__/push/push.test.d.ts.map +0 -1
- package/dist/__tests__/push/push.test.js +0 -197
- package/dist/__tests__/push/push.test.js.map +0 -1
- package/dist/__tests__/simulate/env-loader.test.d.ts +0 -2
- package/dist/__tests__/simulate/env-loader.test.d.ts.map +0 -1
- package/dist/__tests__/simulate/env-loader.test.js +0 -47
- package/dist/__tests__/simulate/env-loader.test.js.map +0 -1
- package/dist/__tests__/simulate/node-executor.test.d.ts +0 -5
- package/dist/__tests__/simulate/node-executor.test.d.ts.map +0 -1
- package/dist/__tests__/simulate/node-executor.test.js +0 -25
- package/dist/__tests__/simulate/node-executor.test.js.map +0 -1
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts +0 -5
- package/dist/__tests__/simulate/server-simulate.integration.test.d.ts.map +0 -1
- package/dist/__tests__/simulate/server-simulate.integration.test.js +0 -58
- package/dist/__tests__/simulate/server-simulate.integration.test.js.map +0 -1
- package/dist/__tests__/smoke/production.smoke.test.d.ts +0 -8
- package/dist/__tests__/smoke/production.smoke.test.d.ts.map +0 -1
- package/dist/__tests__/smoke/production.smoke.test.js +0 -65
- package/dist/__tests__/smoke/production.smoke.test.js.map +0 -1
- package/dist/commands/bundle/bundler.d.ts +0 -32
- package/dist/commands/bundle/bundler.d.ts.map +0 -1
- package/dist/commands/bundle/bundler.js +0 -569
- package/dist/commands/bundle/bundler.js.map +0 -1
- package/dist/commands/bundle/index.d.ts +0 -59
- package/dist/commands/bundle/index.d.ts.map +0 -1
- package/dist/commands/bundle/index.js +0 -184
- package/dist/commands/bundle/index.js.map +0 -1
- package/dist/commands/bundle/package-manager.d.ts +0 -8
- package/dist/commands/bundle/package-manager.d.ts.map +0 -1
- package/dist/commands/bundle/package-manager.js +0 -220
- package/dist/commands/bundle/package-manager.js.map +0 -1
- package/dist/commands/bundle/stats.d.ts +0 -23
- package/dist/commands/bundle/stats.d.ts.map +0 -1
- package/dist/commands/bundle/stats.js +0 -52
- package/dist/commands/bundle/stats.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -7
- package/dist/commands/cache.d.ts.map +0 -1
- package/dist/commands/cache.js +0 -68
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/push/index.d.ts +0 -7
- package/dist/commands/push/index.d.ts.map +0 -1
- package/dist/commands/push/index.js +0 -247
- package/dist/commands/push/index.js.map +0 -1
- package/dist/commands/push/types.d.ts +0 -22
- package/dist/commands/push/types.d.ts.map +0 -1
- package/dist/commands/push/types.js +0 -2
- package/dist/commands/push/types.js.map +0 -1
- package/dist/commands/run/__tests__/run.integration.test.d.ts +0 -7
- package/dist/commands/run/__tests__/run.integration.test.d.ts.map +0 -1
- package/dist/commands/run/__tests__/run.integration.test.js +0 -51
- package/dist/commands/run/__tests__/run.integration.test.js.map +0 -1
- package/dist/commands/run/__tests__/validators.test.d.ts +0 -2
- package/dist/commands/run/__tests__/validators.test.d.ts.map +0 -1
- package/dist/commands/run/__tests__/validators.test.js +0 -80
- package/dist/commands/run/__tests__/validators.test.js.map +0 -1
- package/dist/commands/run/execution.d.ts +0 -14
- package/dist/commands/run/execution.d.ts.map +0 -1
- package/dist/commands/run/execution.js +0 -41
- package/dist/commands/run/execution.js.map +0 -1
- package/dist/commands/run/index.d.ts +0 -38
- package/dist/commands/run/index.d.ts.map +0 -1
- package/dist/commands/run/index.js +0 -154
- package/dist/commands/run/index.js.map +0 -1
- package/dist/commands/run/types.d.ts +0 -65
- package/dist/commands/run/types.d.ts.map +0 -1
- package/dist/commands/run/types.js +0 -7
- package/dist/commands/run/types.js.map +0 -1
- package/dist/commands/run/utils.d.ts +0 -29
- package/dist/commands/run/utils.d.ts.map +0 -1
- package/dist/commands/run/utils.js +0 -52
- package/dist/commands/run/utils.js.map +0 -1
- package/dist/commands/run/validators.d.ts +0 -33
- package/dist/commands/run/validators.d.ts.map +0 -1
- package/dist/commands/run/validators.js +0 -58
- package/dist/commands/run/validators.js.map +0 -1
- package/dist/commands/simulate/env-loader.d.ts +0 -19
- package/dist/commands/simulate/env-loader.d.ts.map +0 -1
- package/dist/commands/simulate/env-loader.js +0 -44
- package/dist/commands/simulate/env-loader.js.map +0 -1
- package/dist/commands/simulate/index.d.ts +0 -48
- package/dist/commands/simulate/index.d.ts.map +0 -1
- package/dist/commands/simulate/index.js +0 -113
- package/dist/commands/simulate/index.js.map +0 -1
- package/dist/commands/simulate/jsdom-executor.d.ts +0 -37
- package/dist/commands/simulate/jsdom-executor.d.ts.map +0 -1
- package/dist/commands/simulate/jsdom-executor.js +0 -137
- package/dist/commands/simulate/jsdom-executor.js.map +0 -1
- package/dist/commands/simulate/node-executor.d.ts +0 -28
- package/dist/commands/simulate/node-executor.d.ts.map +0 -1
- package/dist/commands/simulate/node-executor.js +0 -94
- package/dist/commands/simulate/node-executor.js.map +0 -1
- package/dist/commands/simulate/simulator.d.ts +0 -14
- package/dist/commands/simulate/simulator.d.ts.map +0 -1
- package/dist/commands/simulate/simulator.js +0 -163
- package/dist/commands/simulate/simulator.js.map +0 -1
- package/dist/commands/simulate/tracker.d.ts +0 -30
- package/dist/commands/simulate/tracker.d.ts.map +0 -1
- package/dist/commands/simulate/tracker.js +0 -96
- package/dist/commands/simulate/tracker.js.map +0 -1
- package/dist/commands/simulate/types.d.ts +0 -20
- package/dist/commands/simulate/types.d.ts.map +0 -1
- package/dist/commands/simulate/types.js +0 -2
- package/dist/commands/simulate/types.js.map +0 -1
- package/dist/config/build-defaults.d.ts +0 -49
- package/dist/config/build-defaults.d.ts.map +0 -1
- package/dist/config/build-defaults.js +0 -68
- package/dist/config/build-defaults.js.map +0 -1
- package/dist/config/index.d.ts +0 -13
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -15
- package/dist/config/index.js.map +0 -1
- package/dist/config/loader.d.ts +0 -81
- package/dist/config/loader.d.ts.map +0 -1
- package/dist/config/loader.js +0 -153
- package/dist/config/loader.js.map +0 -1
- package/dist/config/utils.d.ts +0 -101
- package/dist/config/utils.d.ts.map +0 -1
- package/dist/config/utils.js +0 -235
- package/dist/config/utils.js.map +0 -1
- package/dist/config/validators.d.ts +0 -52
- package/dist/config/validators.d.ts.map +0 -1
- package/dist/config/validators.js +0 -85
- package/dist/config/validators.js.map +0 -1
- package/dist/core/asset-resolver.d.ts +0 -34
- package/dist/core/asset-resolver.d.ts.map +0 -1
- package/dist/core/asset-resolver.js +0 -70
- package/dist/core/asset-resolver.js.map +0 -1
- package/dist/core/build-cache.d.ts +0 -23
- package/dist/core/build-cache.d.ts.map +0 -1
- package/dist/core/build-cache.js +0 -44
- package/dist/core/build-cache.js.map +0 -1
- package/dist/core/cache-utils.d.ts +0 -27
- package/dist/core/cache-utils.d.ts.map +0 -1
- package/dist/core/cache-utils.js +0 -60
- package/dist/core/cache-utils.js.map +0 -1
- package/dist/core/index.d.ts +0 -8
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -8
- package/dist/core/index.js.map +0 -1
- package/dist/core/local-packages.d.ts +0 -19
- package/dist/core/local-packages.d.ts.map +0 -1
- package/dist/core/local-packages.js +0 -60
- package/dist/core/local-packages.js.map +0 -1
- package/dist/core/logger.d.ts +0 -30
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -85
- package/dist/core/logger.js.map +0 -1
- package/dist/core/output.d.ts +0 -30
- package/dist/core/output.d.ts.map +0 -1
- package/dist/core/output.js +0 -46
- package/dist/core/output.js.map +0 -1
- package/dist/core/timer.d.ts +0 -14
- package/dist/core/timer.d.ts.map +0 -1
- package/dist/core/timer.js +0 -29
- package/dist/core/timer.js.map +0 -1
- package/dist/core/tmp.d.ts +0 -27
- package/dist/core/tmp.d.ts.map +0 -1
- package/dist/core/tmp.js +0 -36
- package/dist/core/tmp.js.map +0 -1
- package/dist/core/utils.d.ts +0 -10
- package/dist/core/utils.d.ts.map +0 -1
- package/dist/core/utils.js +0 -12
- package/dist/core/utils.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/runtime/index.d.ts +0 -10
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js +0 -10
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/main.d.ts.map +0 -1
- package/dist/runtime/runner.d.ts +0 -20
- package/dist/runtime/runner.d.ts.map +0 -1
- package/dist/runtime/runner.js +0 -72
- package/dist/runtime/runner.js.map +0 -1
- package/dist/runtime/serve.d.ts +0 -19
- package/dist/runtime/serve.d.ts.map +0 -1
- package/dist/runtime/serve.js +0 -97
- package/dist/runtime/serve.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -9
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/index.js +0 -9
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/primitives.d.ts +0 -37
- package/dist/schemas/primitives.d.ts.map +0 -1
- package/dist/schemas/primitives.js +0 -43
- package/dist/schemas/primitives.js.map +0 -1
- package/dist/schemas/run.d.ts +0 -23
- package/dist/schemas/run.d.ts.map +0 -1
- package/dist/schemas/run.js +0 -20
- package/dist/schemas/run.js.map +0 -1
- package/dist/types/bundle.d.ts +0 -141
- package/dist/types/bundle.d.ts.map +0 -1
- package/dist/types/bundle.js +0 -10
- package/dist/types/bundle.js.map +0 -1
- package/dist/types/global.d.ts +0 -38
- package/dist/types/global.d.ts.map +0 -1
- package/dist/types/global.js +0 -24
- package/dist/types/global.js.map +0 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/version.d.ts +0 -3
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -27
- package/dist/version.js.map +0 -1
- package/dist/walker.js +0 -1
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ var VERSION = JSON.parse(findPackageJson()).version;
|
|
|
29
29
|
|
|
30
30
|
// src/commands/bundle/index.ts
|
|
31
31
|
import path9 from "path";
|
|
32
|
+
import fs8 from "fs-extra";
|
|
32
33
|
|
|
33
34
|
// src/core/logger.ts
|
|
34
35
|
import chalk from "chalk";
|
|
@@ -108,6 +109,23 @@ function createCommandLogger(options) {
|
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
// src/core/collector-logger.ts
|
|
113
|
+
function createCollectorLoggerConfig(cliLogger, verbose) {
|
|
114
|
+
return {
|
|
115
|
+
level: verbose ? "DEBUG" : "ERROR",
|
|
116
|
+
handler: (level, message, context, scope) => {
|
|
117
|
+
const scopePath = scope.length > 0 ? `[${scope.join(":")}] ` : "";
|
|
118
|
+
const hasContext = Object.keys(context).length > 0;
|
|
119
|
+
const contextStr = hasContext ? ` ${JSON.stringify(context)}` : "";
|
|
120
|
+
if (level === 0) {
|
|
121
|
+
cliLogger.error(`${scopePath}${message}${contextStr}`);
|
|
122
|
+
} else if (verbose) {
|
|
123
|
+
cliLogger.debug(`${scopePath}${message}${contextStr}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
111
129
|
// src/core/timer.ts
|
|
112
130
|
function createTimer() {
|
|
113
131
|
let startTime = 0;
|
|
@@ -374,6 +392,33 @@ async function copyLocalPackage(localPkg, targetDir, logger2) {
|
|
|
374
392
|
return packageDir;
|
|
375
393
|
}
|
|
376
394
|
|
|
395
|
+
// src/core/input-detector.ts
|
|
396
|
+
import fs3 from "fs-extra";
|
|
397
|
+
async function detectInput(inputPath, platformOverride) {
|
|
398
|
+
const content = await loadContent(inputPath);
|
|
399
|
+
try {
|
|
400
|
+
JSON.parse(content);
|
|
401
|
+
return { type: "config", content };
|
|
402
|
+
} catch {
|
|
403
|
+
const platform = platformOverride ?? detectPlatformFromPath(inputPath);
|
|
404
|
+
return { type: "bundle", content, platform };
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function detectPlatformFromPath(inputPath) {
|
|
408
|
+
const cleanPath = inputPath.split("?")[0];
|
|
409
|
+
return cleanPath.endsWith(".mjs") ? "server" : "web";
|
|
410
|
+
}
|
|
411
|
+
async function loadContent(inputPath) {
|
|
412
|
+
if (isUrl(inputPath)) {
|
|
413
|
+
const response = await fetch(inputPath);
|
|
414
|
+
if (!response.ok) {
|
|
415
|
+
throw new Error(`Failed to fetch ${inputPath}: ${response.status}`);
|
|
416
|
+
}
|
|
417
|
+
return response.text();
|
|
418
|
+
}
|
|
419
|
+
return fs3.readFile(inputPath, "utf8");
|
|
420
|
+
}
|
|
421
|
+
|
|
377
422
|
// src/config/validators.ts
|
|
378
423
|
import { schemas } from "@walkeros/core/dev";
|
|
379
424
|
var { safeParseSetup } = schemas;
|
|
@@ -428,7 +473,7 @@ function getDefaultOutput(platform) {
|
|
|
428
473
|
|
|
429
474
|
// src/config/loader.ts
|
|
430
475
|
import path5 from "path";
|
|
431
|
-
import
|
|
476
|
+
import fs4 from "fs-extra";
|
|
432
477
|
import { getFlowConfig, getPlatform } from "@walkeros/core";
|
|
433
478
|
var DEFAULT_INCLUDE_FOLDER = "./shared";
|
|
434
479
|
function loadBundleConfig(rawConfig, options) {
|
|
@@ -449,7 +494,7 @@ function loadBundleConfig(rawConfig, options) {
|
|
|
449
494
|
let includes = setup.include;
|
|
450
495
|
if (!includes) {
|
|
451
496
|
const defaultIncludePath = path5.resolve(configDir, DEFAULT_INCLUDE_FOLDER);
|
|
452
|
-
if (
|
|
497
|
+
if (fs4.pathExistsSync(defaultIncludePath)) {
|
|
453
498
|
includes = [DEFAULT_INCLUDE_FOLDER];
|
|
454
499
|
}
|
|
455
500
|
}
|
|
@@ -508,17 +553,21 @@ function loadAllFlows(rawConfig, options) {
|
|
|
508
553
|
})
|
|
509
554
|
);
|
|
510
555
|
}
|
|
556
|
+
async function loadFlowConfig(configPath, options) {
|
|
557
|
+
const rawConfig = await loadJsonConfig(configPath);
|
|
558
|
+
return loadBundleConfig(rawConfig, { configPath, ...options });
|
|
559
|
+
}
|
|
511
560
|
|
|
512
561
|
// src/commands/bundle/bundler.ts
|
|
513
562
|
import esbuild from "esbuild";
|
|
514
563
|
import path8 from "path";
|
|
515
|
-
import
|
|
564
|
+
import fs7 from "fs-extra";
|
|
516
565
|
import { packageNameToVariable } from "@walkeros/core";
|
|
517
566
|
|
|
518
567
|
// src/commands/bundle/package-manager.ts
|
|
519
568
|
import pacote from "pacote";
|
|
520
569
|
import path6 from "path";
|
|
521
|
-
import
|
|
570
|
+
import fs5 from "fs-extra";
|
|
522
571
|
|
|
523
572
|
// src/core/cache-utils.ts
|
|
524
573
|
import { getHashServer } from "@walkeros/server-core";
|
|
@@ -568,7 +617,7 @@ async function getCachedPackagePath(pkg, tmpDir) {
|
|
|
568
617
|
}
|
|
569
618
|
async function isPackageCached(pkg, tmpDir) {
|
|
570
619
|
const cachedPath = await getCachedPackagePath(pkg, tmpDir);
|
|
571
|
-
return
|
|
620
|
+
return fs5.pathExists(cachedPath);
|
|
572
621
|
}
|
|
573
622
|
function validateNoDuplicatePackages(packages) {
|
|
574
623
|
const packageMap = /* @__PURE__ */ new Map();
|
|
@@ -603,8 +652,8 @@ async function resolveDependencies(pkg, packageDir, logger2, visited = /* @__PUR
|
|
|
603
652
|
visited.add(pkgKey);
|
|
604
653
|
try {
|
|
605
654
|
const packageJsonPath = path6.join(packageDir, "package.json");
|
|
606
|
-
if (await
|
|
607
|
-
const packageJson = await
|
|
655
|
+
if (await fs5.pathExists(packageJsonPath)) {
|
|
656
|
+
const packageJson = await fs5.readJson(packageJsonPath);
|
|
608
657
|
const deps = {
|
|
609
658
|
...packageJson.dependencies,
|
|
610
659
|
...packageJson.peerDependencies
|
|
@@ -632,7 +681,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
632
681
|
}
|
|
633
682
|
}
|
|
634
683
|
validateNoDuplicatePackages(packages);
|
|
635
|
-
await
|
|
684
|
+
await fs5.ensureDir(targetDir);
|
|
636
685
|
while (downloadQueue.length > 0) {
|
|
637
686
|
const pkg = downloadQueue.shift();
|
|
638
687
|
const pkgKey = `${pkg.name}@${pkg.version}`;
|
|
@@ -669,8 +718,8 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
669
718
|
logger2.debug(`Downloading ${packageSpec} (cached)`);
|
|
670
719
|
}
|
|
671
720
|
try {
|
|
672
|
-
await
|
|
673
|
-
await
|
|
721
|
+
await fs5.ensureDir(path6.dirname(packageDir));
|
|
722
|
+
await fs5.copy(cachedPath, packageDir);
|
|
674
723
|
packagePaths.set(pkg.name, packageDir);
|
|
675
724
|
const deps = await resolveDependencies(pkg, packageDir, logger2);
|
|
676
725
|
for (const dep of deps) {
|
|
@@ -687,7 +736,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
687
736
|
}
|
|
688
737
|
}
|
|
689
738
|
try {
|
|
690
|
-
await
|
|
739
|
+
await fs5.ensureDir(path6.dirname(packageDir));
|
|
691
740
|
const cacheDir = process.env.NPM_CACHE_DIR || getTmpPath(void 0, "cache", "npm");
|
|
692
741
|
await withTimeout(
|
|
693
742
|
pacote.extract(packageSpec, packageDir, {
|
|
@@ -704,15 +753,15 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
704
753
|
`Package download timed out after ${PACKAGE_DOWNLOAD_TIMEOUT_MS / 1e3}s: ${packageSpec}`
|
|
705
754
|
);
|
|
706
755
|
if (userSpecifiedPackages.has(pkg.name)) {
|
|
707
|
-
const pkgStats = await
|
|
756
|
+
const pkgStats = await fs5.stat(path6.join(packageDir, "package.json"));
|
|
708
757
|
const pkgJsonSize = pkgStats.size;
|
|
709
758
|
const sizeKB = (pkgJsonSize / 1024).toFixed(1);
|
|
710
759
|
logger2.debug(`Downloading ${packageSpec} (${sizeKB} KB)`);
|
|
711
760
|
}
|
|
712
761
|
if (useCache) {
|
|
713
762
|
try {
|
|
714
|
-
await
|
|
715
|
-
await
|
|
763
|
+
await fs5.ensureDir(path6.dirname(cachedPath));
|
|
764
|
+
await fs5.copy(packageDir, cachedPath);
|
|
716
765
|
} catch (cacheError) {
|
|
717
766
|
}
|
|
718
767
|
}
|
|
@@ -732,7 +781,7 @@ async function downloadPackages(packages, targetDir, logger2, useCache = true, c
|
|
|
732
781
|
}
|
|
733
782
|
|
|
734
783
|
// src/core/build-cache.ts
|
|
735
|
-
import
|
|
784
|
+
import fs6 from "fs-extra";
|
|
736
785
|
import path7 from "path";
|
|
737
786
|
async function getBuildCachePath(configContent, tmpDir) {
|
|
738
787
|
const cacheDir = getTmpPath(tmpDir, "cache", "builds");
|
|
@@ -741,17 +790,17 @@ async function getBuildCachePath(configContent, tmpDir) {
|
|
|
741
790
|
}
|
|
742
791
|
async function isBuildCached(configContent, tmpDir) {
|
|
743
792
|
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
744
|
-
return
|
|
793
|
+
return fs6.pathExists(cachePath);
|
|
745
794
|
}
|
|
746
795
|
async function cacheBuild(configContent, buildOutput, tmpDir) {
|
|
747
796
|
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
748
|
-
await
|
|
749
|
-
await
|
|
797
|
+
await fs6.ensureDir(path7.dirname(cachePath));
|
|
798
|
+
await fs6.writeFile(cachePath, buildOutput, "utf-8");
|
|
750
799
|
}
|
|
751
800
|
async function getCachedBuild(configContent, tmpDir) {
|
|
752
801
|
const cachePath = await getBuildCachePath(configContent, tmpDir);
|
|
753
|
-
if (await
|
|
754
|
-
return await
|
|
802
|
+
if (await fs6.pathExists(cachePath)) {
|
|
803
|
+
return await fs6.readFile(cachePath, "utf-8");
|
|
755
804
|
}
|
|
756
805
|
return null;
|
|
757
806
|
}
|
|
@@ -762,8 +811,8 @@ async function copyIncludes(includes, sourceDir, outputDir, logger2) {
|
|
|
762
811
|
const sourcePath = path8.resolve(sourceDir, include);
|
|
763
812
|
const folderName = path8.basename(include);
|
|
764
813
|
const destPath = path8.join(outputDir, folderName);
|
|
765
|
-
if (await
|
|
766
|
-
await
|
|
814
|
+
if (await fs7.pathExists(sourcePath)) {
|
|
815
|
+
await fs7.copy(sourcePath, destPath);
|
|
767
816
|
logger2.debug(`Copied ${include} to output`);
|
|
768
817
|
} else {
|
|
769
818
|
logger2.debug(`Include folder not found: ${include}`);
|
|
@@ -793,13 +842,13 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
793
842
|
if (cachedBuild) {
|
|
794
843
|
logger2.debug("Using cached build");
|
|
795
844
|
const outputPath = path8.resolve(buildOptions.output);
|
|
796
|
-
await
|
|
797
|
-
await
|
|
798
|
-
const stats = await
|
|
845
|
+
await fs7.ensureDir(path8.dirname(outputPath));
|
|
846
|
+
await fs7.writeFile(outputPath, cachedBuild);
|
|
847
|
+
const stats = await fs7.stat(outputPath);
|
|
799
848
|
const sizeKB = (stats.size / 1024).toFixed(1);
|
|
800
849
|
logger2.log(`Output: ${outputPath} (${sizeKB} KB, cached)`);
|
|
801
850
|
if (showStats) {
|
|
802
|
-
const stats2 = await
|
|
851
|
+
const stats2 = await fs7.stat(outputPath);
|
|
803
852
|
const packageStats = Object.entries(buildOptions.packages).map(
|
|
804
853
|
([name, pkg]) => ({
|
|
805
854
|
name: `${name}@${pkg.version || "latest"}`,
|
|
@@ -819,7 +868,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
819
868
|
}
|
|
820
869
|
}
|
|
821
870
|
try {
|
|
822
|
-
await
|
|
871
|
+
await fs7.ensureDir(TEMP_DIR);
|
|
823
872
|
logger2.debug("Downloading packages");
|
|
824
873
|
const packagesArray = Object.entries(buildOptions.packages).map(
|
|
825
874
|
([name, packageConfig]) => ({
|
|
@@ -840,7 +889,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
840
889
|
for (const [pkgName, pkgPath] of packagePaths.entries()) {
|
|
841
890
|
if (pkgName.startsWith("@walkeros/")) {
|
|
842
891
|
const pkgJsonPath = path8.join(pkgPath, "package.json");
|
|
843
|
-
const pkgJson = await
|
|
892
|
+
const pkgJson = await fs7.readJSON(pkgJsonPath);
|
|
844
893
|
if (!pkgJson.exports && pkgJson.module) {
|
|
845
894
|
pkgJson.exports = {
|
|
846
895
|
".": {
|
|
@@ -848,12 +897,12 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
848
897
|
require: pkgJson.main
|
|
849
898
|
}
|
|
850
899
|
};
|
|
851
|
-
await
|
|
900
|
+
await fs7.writeJSON(pkgJsonPath, pkgJson, { spaces: 2 });
|
|
852
901
|
}
|
|
853
902
|
}
|
|
854
903
|
}
|
|
855
904
|
const packageJsonPath = path8.join(TEMP_DIR, "package.json");
|
|
856
|
-
await
|
|
905
|
+
await fs7.writeFile(
|
|
857
906
|
packageJsonPath,
|
|
858
907
|
JSON.stringify({ type: "module" }, null, 2)
|
|
859
908
|
);
|
|
@@ -864,12 +913,12 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
864
913
|
packagePaths
|
|
865
914
|
);
|
|
866
915
|
const entryPath = path8.join(TEMP_DIR, "entry.js");
|
|
867
|
-
await
|
|
916
|
+
await fs7.writeFile(entryPath, entryContent);
|
|
868
917
|
logger2.debug(
|
|
869
918
|
`Running esbuild (target: ${buildOptions.target || "es2018"}, format: ${buildOptions.format})`
|
|
870
919
|
);
|
|
871
920
|
const outputPath = path8.resolve(buildOptions.output);
|
|
872
|
-
await
|
|
921
|
+
await fs7.ensureDir(path8.dirname(outputPath));
|
|
873
922
|
const esbuildOptions = createEsbuildOptions(
|
|
874
923
|
buildOptions,
|
|
875
924
|
entryPath,
|
|
@@ -886,13 +935,13 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
886
935
|
buildOptions.code || ""
|
|
887
936
|
);
|
|
888
937
|
}
|
|
889
|
-
const outputStats = await
|
|
938
|
+
const outputStats = await fs7.stat(outputPath);
|
|
890
939
|
const sizeKB = (outputStats.size / 1024).toFixed(1);
|
|
891
940
|
const buildTime = ((Date.now() - bundleStartTime) / 1e3).toFixed(1);
|
|
892
941
|
logger2.log(`Output: ${outputPath} (${sizeKB} KB, ${buildTime}s)`);
|
|
893
942
|
if (buildOptions.cache !== false) {
|
|
894
943
|
const configContent = generateCacheKeyContent(flowConfig, buildOptions);
|
|
895
|
-
const buildOutput = await
|
|
944
|
+
const buildOutput = await fs7.readFile(outputPath, "utf-8");
|
|
896
945
|
await cacheBuild(configContent, buildOutput);
|
|
897
946
|
logger2.debug("Build cached for future use");
|
|
898
947
|
}
|
|
@@ -920,7 +969,7 @@ async function bundleCore(flowConfig, buildOptions, logger2, showStats = false)
|
|
|
920
969
|
}
|
|
921
970
|
}
|
|
922
971
|
async function collectBundleStats(outputPath, packages, startTime, entryContent) {
|
|
923
|
-
const stats = await
|
|
972
|
+
const stats = await fs7.stat(outputPath);
|
|
924
973
|
const totalSize = stats.size;
|
|
925
974
|
const buildTime = Date.now() - startTime;
|
|
926
975
|
const packageStats = Object.entries(packages).map(([name, pkg]) => {
|
|
@@ -1248,6 +1297,11 @@ function generatePlatformWrapper(configObject, userCode, buildOptions) {
|
|
|
1248
1297
|
` : "";
|
|
1249
1298
|
return `export default async function(context = {}) {
|
|
1250
1299
|
const config = ${configObject};${codeSection}
|
|
1300
|
+
// Apply context overrides (e.g., logger config from CLI)
|
|
1301
|
+
if (context.logger) {
|
|
1302
|
+
config.logger = { ...config.logger, ...context.logger };
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1251
1305
|
return await startFlow(config);
|
|
1252
1306
|
}`;
|
|
1253
1307
|
}
|
|
@@ -1330,6 +1384,13 @@ async function bundleCommand(options) {
|
|
|
1330
1384
|
if (!options.json && !options.all && options.stats && stats) {
|
|
1331
1385
|
displayStats(stats, logger2);
|
|
1332
1386
|
}
|
|
1387
|
+
if (options.dockerfile && !options.all) {
|
|
1388
|
+
const dockerfilePath = path9.join(
|
|
1389
|
+
path9.dirname(buildOptions.output),
|
|
1390
|
+
"Dockerfile"
|
|
1391
|
+
);
|
|
1392
|
+
await generateDockerfile(dockerfilePath, buildOptions.output, logger2);
|
|
1393
|
+
}
|
|
1333
1394
|
} catch (error) {
|
|
1334
1395
|
const errorMessage = getErrorMessage(error);
|
|
1335
1396
|
results.push({
|
|
@@ -1412,10 +1473,25 @@ async function bundle(configOrPath, options = {}) {
|
|
|
1412
1473
|
options.stats ?? false
|
|
1413
1474
|
);
|
|
1414
1475
|
}
|
|
1476
|
+
async function generateDockerfile(dockerfilePath, bundleOutput, logger2) {
|
|
1477
|
+
const bundleFilename = path9.basename(bundleOutput);
|
|
1478
|
+
const dockerfile = `# Generated by walkeros CLI
|
|
1479
|
+
FROM walkeros/flow:latest
|
|
1480
|
+
|
|
1481
|
+
COPY ${bundleFilename} /app/flow/bundle.mjs
|
|
1482
|
+
|
|
1483
|
+
ENV MODE=collect
|
|
1484
|
+
ENV FLOW=/app/flow/bundle.mjs
|
|
1485
|
+
|
|
1486
|
+
EXPOSE 8080
|
|
1487
|
+
`;
|
|
1488
|
+
await fs8.writeFile(dockerfilePath, dockerfile);
|
|
1489
|
+
logger2.log(`Dockerfile: ${dockerfilePath}`);
|
|
1490
|
+
}
|
|
1415
1491
|
|
|
1416
1492
|
// src/commands/simulate/simulator.ts
|
|
1417
1493
|
import path10 from "path";
|
|
1418
|
-
import
|
|
1494
|
+
import fs10 from "fs-extra";
|
|
1419
1495
|
import { getPlatform as getPlatform2 } from "@walkeros/core";
|
|
1420
1496
|
|
|
1421
1497
|
// src/commands/simulate/tracker.ts
|
|
@@ -1498,7 +1574,7 @@ var CallTracker = class {
|
|
|
1498
1574
|
|
|
1499
1575
|
// src/commands/simulate/jsdom-executor.ts
|
|
1500
1576
|
import { JSDOM, VirtualConsole } from "jsdom";
|
|
1501
|
-
import
|
|
1577
|
+
import fs9 from "fs-extra";
|
|
1502
1578
|
function buildSandboxFromEnvs(envs, destinations, tracker) {
|
|
1503
1579
|
const baseBrowserMocks = {
|
|
1504
1580
|
Image: class MockImage {
|
|
@@ -1567,7 +1643,7 @@ async function executeInJSDOM(bundlePath, destinations, event, tracker, envs, ti
|
|
|
1567
1643
|
const sandbox = buildSandboxFromEnvs(envs, destinations, tracker);
|
|
1568
1644
|
Object.assign(window, sandbox.window);
|
|
1569
1645
|
Object.assign(window.document, sandbox.document);
|
|
1570
|
-
const bundleCode = await
|
|
1646
|
+
const bundleCode = await fs9.readFile(bundlePath, "utf8");
|
|
1571
1647
|
try {
|
|
1572
1648
|
window.eval(bundleCode);
|
|
1573
1649
|
} catch (error) {
|
|
@@ -1638,7 +1714,7 @@ function injectGlobalMocks(mocks) {
|
|
|
1638
1714
|
}
|
|
1639
1715
|
};
|
|
1640
1716
|
}
|
|
1641
|
-
async function executeInNode(bundlePath, destinations, event, tracker, envs, timeout = 3e4) {
|
|
1717
|
+
async function executeInNode(bundlePath, destinations, event, tracker, envs, timeout = 3e4, context = {}) {
|
|
1642
1718
|
const start = Date.now();
|
|
1643
1719
|
const globalMocks = buildGlobalMocksFromEnvs(envs, destinations, tracker);
|
|
1644
1720
|
const cleanupMocks = injectGlobalMocks(globalMocks);
|
|
@@ -1649,16 +1725,19 @@ async function executeInNode(bundlePath, destinations, event, tracker, envs, tim
|
|
|
1649
1725
|
if (!module.default || typeof module.default !== "function") {
|
|
1650
1726
|
throw new Error("Bundle does not export default factory function");
|
|
1651
1727
|
}
|
|
1652
|
-
const result = await module.default();
|
|
1653
|
-
if (!result || !result.
|
|
1728
|
+
const result = await module.default(context);
|
|
1729
|
+
if (!result || !result.collector || typeof result.collector.push !== "function") {
|
|
1654
1730
|
throw new Error(
|
|
1655
|
-
"Factory function did not return valid result with
|
|
1731
|
+
"Factory function did not return valid result with collector"
|
|
1656
1732
|
);
|
|
1657
1733
|
}
|
|
1658
1734
|
const { collector, elb } = result;
|
|
1659
1735
|
let elbResult;
|
|
1660
1736
|
try {
|
|
1661
|
-
elbResult = await
|
|
1737
|
+
elbResult = await collector.push({
|
|
1738
|
+
name: event.name,
|
|
1739
|
+
data: event.data
|
|
1740
|
+
});
|
|
1662
1741
|
} catch (error) {
|
|
1663
1742
|
throw new Error(`Event execution failed: ${getErrorMessage(error)}`);
|
|
1664
1743
|
}
|
|
@@ -1716,29 +1795,21 @@ async function loadDestinationEnvs(destinations) {
|
|
|
1716
1795
|
function generateId() {
|
|
1717
1796
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
1718
1797
|
}
|
|
1719
|
-
async function simulateCore(
|
|
1798
|
+
async function simulateCore(inputPath, event, options = {}) {
|
|
1720
1799
|
const logger2 = createLogger({
|
|
1721
1800
|
verbose: options.verbose || false,
|
|
1722
1801
|
silent: options.silent || false,
|
|
1723
1802
|
json: options.json || false
|
|
1724
1803
|
});
|
|
1725
1804
|
try {
|
|
1726
|
-
logger2.
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
logger2.info(`\u{1F680} Executing simulation with event: ${JSON.stringify(event)}`);
|
|
1732
|
-
const result = await executeSimulation(event, fullConfigPath);
|
|
1733
|
-
if (result.success) {
|
|
1734
|
-
logger2.info(`\u2705 Simulation completed successfully`);
|
|
1735
|
-
} else {
|
|
1736
|
-
logger2.error(`\u274C Simulation failed: ${result.error}`);
|
|
1737
|
-
}
|
|
1805
|
+
logger2.debug(`Simulating event: ${JSON.stringify(event)}`);
|
|
1806
|
+
const result = await executeSimulation(event, inputPath, options.platform, {
|
|
1807
|
+
logger: logger2,
|
|
1808
|
+
verbose: options.verbose
|
|
1809
|
+
});
|
|
1738
1810
|
return result;
|
|
1739
1811
|
} catch (error) {
|
|
1740
1812
|
const errorMessage = getErrorMessage(error);
|
|
1741
|
-
logger2.error(`\u{1F4A5} Simulation error: ${errorMessage}`);
|
|
1742
1813
|
return {
|
|
1743
1814
|
success: false,
|
|
1744
1815
|
error: errorMessage
|
|
@@ -1755,87 +1826,43 @@ function formatSimulationResult(result, options = {}) {
|
|
|
1755
1826
|
return JSON.stringify(output, null, 2);
|
|
1756
1827
|
}
|
|
1757
1828
|
if (result.success) {
|
|
1758
|
-
return "
|
|
1829
|
+
return "Simulation completed";
|
|
1759
1830
|
} else {
|
|
1760
|
-
return
|
|
1831
|
+
return `Simulation failed: ${result.error}`;
|
|
1761
1832
|
}
|
|
1762
1833
|
}
|
|
1763
|
-
async function executeSimulation(event,
|
|
1834
|
+
async function executeSimulation(event, inputPath, platformOverride, options = {}) {
|
|
1764
1835
|
const startTime = Date.now();
|
|
1765
|
-
let bundlePath;
|
|
1766
1836
|
const tempDir = getTmpPath();
|
|
1837
|
+
const collectorLoggerConfig = options.logger ? createCollectorLoggerConfig(options.logger, options.verbose) : void 0;
|
|
1767
1838
|
try {
|
|
1839
|
+
await fs10.ensureDir(tempDir);
|
|
1840
|
+
const detected = await detectInput(inputPath, platformOverride);
|
|
1768
1841
|
if (!isObject(event) || !("name" in event) || typeof event.name !== "string") {
|
|
1769
1842
|
throw new Error(
|
|
1770
1843
|
'Event must be an object with a "name" property of type string'
|
|
1771
1844
|
);
|
|
1772
1845
|
}
|
|
1773
1846
|
const typedEvent = event;
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
});
|
|
1779
|
-
const platform = getPlatform2(flowConfig);
|
|
1780
|
-
const tracker = new CallTracker();
|
|
1781
|
-
const tempOutput = path10.join(
|
|
1782
|
-
tempDir,
|
|
1783
|
-
`simulation-bundle-${generateId()}.${platform === "web" ? "js" : "mjs"}`
|
|
1784
|
-
);
|
|
1785
|
-
const destinations = flowConfig.destinations;
|
|
1786
|
-
const simulationBuildOptions = {
|
|
1787
|
-
...buildOptions,
|
|
1788
|
-
code: buildOptions.code || "",
|
|
1789
|
-
output: tempOutput,
|
|
1790
|
-
tempDir,
|
|
1791
|
-
...platform === "web" ? {
|
|
1792
|
-
format: "iife",
|
|
1793
|
-
platform: "browser",
|
|
1794
|
-
windowCollector: "collector",
|
|
1795
|
-
windowElb: "elb"
|
|
1796
|
-
} : {
|
|
1797
|
-
format: "esm",
|
|
1798
|
-
platform: "node"
|
|
1799
|
-
}
|
|
1800
|
-
};
|
|
1801
|
-
await bundleCore(
|
|
1802
|
-
flowConfig,
|
|
1803
|
-
simulationBuildOptions,
|
|
1804
|
-
createLogger({ silent: true }),
|
|
1805
|
-
false
|
|
1806
|
-
);
|
|
1807
|
-
bundlePath = tempOutput;
|
|
1808
|
-
const envs = await loadDestinationEnvs(destinations || {});
|
|
1809
|
-
let result;
|
|
1810
|
-
if (platform === "web") {
|
|
1811
|
-
result = await executeInJSDOM(
|
|
1812
|
-
tempOutput,
|
|
1813
|
-
destinations || {},
|
|
1847
|
+
if (detected.type === "config") {
|
|
1848
|
+
return await executeConfigSimulation(
|
|
1849
|
+
detected.content,
|
|
1850
|
+
inputPath,
|
|
1814
1851
|
typedEvent,
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1852
|
+
tempDir,
|
|
1853
|
+
startTime,
|
|
1854
|
+
collectorLoggerConfig
|
|
1818
1855
|
);
|
|
1819
1856
|
} else {
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1857
|
+
return await executeBundleSimulation(
|
|
1858
|
+
detected.content,
|
|
1859
|
+
detected.platform,
|
|
1823
1860
|
typedEvent,
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1861
|
+
tempDir,
|
|
1862
|
+
startTime,
|
|
1863
|
+
collectorLoggerConfig
|
|
1827
1864
|
);
|
|
1828
1865
|
}
|
|
1829
|
-
const elbResult = result.elbResult;
|
|
1830
|
-
const usage = result.usage;
|
|
1831
|
-
const duration = Date.now() - startTime;
|
|
1832
|
-
return {
|
|
1833
|
-
success: true,
|
|
1834
|
-
elbResult,
|
|
1835
|
-
usage,
|
|
1836
|
-
duration,
|
|
1837
|
-
logs: []
|
|
1838
|
-
};
|
|
1839
1866
|
} catch (error) {
|
|
1840
1867
|
const duration = Date.now() - startTime;
|
|
1841
1868
|
return {
|
|
@@ -1845,11 +1872,109 @@ async function executeSimulation(event, configPath) {
|
|
|
1845
1872
|
};
|
|
1846
1873
|
} finally {
|
|
1847
1874
|
if (tempDir) {
|
|
1848
|
-
await
|
|
1875
|
+
await fs10.remove(tempDir).catch(() => {
|
|
1849
1876
|
});
|
|
1850
1877
|
}
|
|
1851
1878
|
}
|
|
1852
1879
|
}
|
|
1880
|
+
async function executeConfigSimulation(_content, configPath, typedEvent, tempDir, startTime, loggerConfig2) {
|
|
1881
|
+
const { flowConfig, buildOptions } = await loadFlowConfig(configPath);
|
|
1882
|
+
const platform = getPlatform2(flowConfig);
|
|
1883
|
+
const tracker = new CallTracker();
|
|
1884
|
+
const tempOutput = path10.join(
|
|
1885
|
+
tempDir,
|
|
1886
|
+
`simulation-bundle-${generateId()}.${platform === "web" ? "js" : "mjs"}`
|
|
1887
|
+
);
|
|
1888
|
+
const destinations = flowConfig.destinations;
|
|
1889
|
+
const simulationBuildOptions = {
|
|
1890
|
+
...buildOptions,
|
|
1891
|
+
code: buildOptions.code || "",
|
|
1892
|
+
output: tempOutput,
|
|
1893
|
+
tempDir,
|
|
1894
|
+
...platform === "web" ? {
|
|
1895
|
+
format: "iife",
|
|
1896
|
+
platform: "browser",
|
|
1897
|
+
windowCollector: "collector",
|
|
1898
|
+
windowElb: "elb"
|
|
1899
|
+
} : {
|
|
1900
|
+
format: "esm",
|
|
1901
|
+
platform: "node"
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
await bundleCore(
|
|
1905
|
+
flowConfig,
|
|
1906
|
+
simulationBuildOptions,
|
|
1907
|
+
createLogger({ silent: true }),
|
|
1908
|
+
false
|
|
1909
|
+
);
|
|
1910
|
+
const envs = await loadDestinationEnvs(destinations || {});
|
|
1911
|
+
let result;
|
|
1912
|
+
if (platform === "web") {
|
|
1913
|
+
result = await executeInJSDOM(
|
|
1914
|
+
tempOutput,
|
|
1915
|
+
destinations || {},
|
|
1916
|
+
typedEvent,
|
|
1917
|
+
tracker,
|
|
1918
|
+
envs,
|
|
1919
|
+
1e4
|
|
1920
|
+
);
|
|
1921
|
+
} else {
|
|
1922
|
+
result = await executeInNode(
|
|
1923
|
+
tempOutput,
|
|
1924
|
+
destinations || {},
|
|
1925
|
+
typedEvent,
|
|
1926
|
+
tracker,
|
|
1927
|
+
envs,
|
|
1928
|
+
3e4,
|
|
1929
|
+
loggerConfig2 ? { logger: loggerConfig2 } : {}
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1932
|
+
const duration = Date.now() - startTime;
|
|
1933
|
+
return {
|
|
1934
|
+
success: true,
|
|
1935
|
+
elbResult: result.elbResult,
|
|
1936
|
+
usage: result.usage,
|
|
1937
|
+
duration,
|
|
1938
|
+
logs: []
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
async function executeBundleSimulation(bundleContent, platform, typedEvent, tempDir, startTime, loggerConfig2) {
|
|
1942
|
+
const tempOutput = path10.join(
|
|
1943
|
+
tempDir,
|
|
1944
|
+
`bundle-${generateId()}.${platform === "server" ? "mjs" : "js"}`
|
|
1945
|
+
);
|
|
1946
|
+
await fs10.writeFile(tempOutput, bundleContent, "utf8");
|
|
1947
|
+
const tracker = new CallTracker();
|
|
1948
|
+
let result;
|
|
1949
|
+
if (platform === "web") {
|
|
1950
|
+
result = await executeInJSDOM(
|
|
1951
|
+
tempOutput,
|
|
1952
|
+
{},
|
|
1953
|
+
typedEvent,
|
|
1954
|
+
tracker,
|
|
1955
|
+
{},
|
|
1956
|
+
1e4
|
|
1957
|
+
);
|
|
1958
|
+
} else {
|
|
1959
|
+
result = await executeInNode(
|
|
1960
|
+
tempOutput,
|
|
1961
|
+
{},
|
|
1962
|
+
typedEvent,
|
|
1963
|
+
tracker,
|
|
1964
|
+
{},
|
|
1965
|
+
3e4,
|
|
1966
|
+
loggerConfig2 ? { logger: loggerConfig2 } : {}
|
|
1967
|
+
);
|
|
1968
|
+
}
|
|
1969
|
+
const duration = Date.now() - startTime;
|
|
1970
|
+
return {
|
|
1971
|
+
success: true,
|
|
1972
|
+
elbResult: result.elbResult,
|
|
1973
|
+
usage: result.usage,
|
|
1974
|
+
duration,
|
|
1975
|
+
logs: []
|
|
1976
|
+
};
|
|
1977
|
+
}
|
|
1853
1978
|
|
|
1854
1979
|
// src/commands/simulate/index.ts
|
|
1855
1980
|
async function simulateCommand(options) {
|
|
@@ -1914,12 +2039,15 @@ async function simulate(configOrPath, event, options = {}) {
|
|
|
1914
2039
|
// src/commands/push/index.ts
|
|
1915
2040
|
import path11 from "path";
|
|
1916
2041
|
import { JSDOM as JSDOM2, VirtualConsole as VirtualConsole2 } from "jsdom";
|
|
1917
|
-
import
|
|
1918
|
-
import {
|
|
2042
|
+
import fs11 from "fs-extra";
|
|
2043
|
+
import {
|
|
2044
|
+
getPlatform as getPlatform3
|
|
2045
|
+
} from "@walkeros/core";
|
|
1919
2046
|
import { schemas as schemas2 } from "@walkeros/core/dev";
|
|
1920
2047
|
async function pushCommand(options) {
|
|
1921
2048
|
const logger2 = createCommandLogger(options);
|
|
1922
2049
|
const startTime = Date.now();
|
|
2050
|
+
let tempDir;
|
|
1923
2051
|
try {
|
|
1924
2052
|
logger2.debug("Loading event");
|
|
1925
2053
|
const event = await loadJsonFromSource(options.event, {
|
|
@@ -1943,49 +2071,33 @@ async function pushCommand(options) {
|
|
|
1943
2071
|
`Warning: Event name "${validatedEvent.name}" should follow "ENTITY ACTION" format (e.g., "page view")`
|
|
1944
2072
|
);
|
|
1945
2073
|
}
|
|
1946
|
-
logger2.debug("
|
|
1947
|
-
const
|
|
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}`);
|
|
2074
|
+
logger2.debug("Detecting input type");
|
|
2075
|
+
const detected = await detectInput(options.config, options.platform);
|
|
1980
2076
|
let result;
|
|
1981
|
-
if (
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
2077
|
+
if (detected.type === "config") {
|
|
2078
|
+
result = await executeConfigPush(
|
|
2079
|
+
options,
|
|
2080
|
+
validatedEvent,
|
|
2081
|
+
logger2,
|
|
2082
|
+
(dir) => {
|
|
2083
|
+
tempDir = dir;
|
|
2084
|
+
}
|
|
2085
|
+
);
|
|
1987
2086
|
} else {
|
|
1988
|
-
|
|
2087
|
+
const collectorLoggerConfig = createCollectorLoggerConfig(
|
|
2088
|
+
logger2,
|
|
2089
|
+
options.verbose
|
|
2090
|
+
);
|
|
2091
|
+
result = await executeBundlePush(
|
|
2092
|
+
detected.content,
|
|
2093
|
+
detected.platform,
|
|
2094
|
+
validatedEvent,
|
|
2095
|
+
logger2,
|
|
2096
|
+
(dir) => {
|
|
2097
|
+
tempDir = dir;
|
|
2098
|
+
},
|
|
2099
|
+
{ logger: collectorLoggerConfig }
|
|
2100
|
+
);
|
|
1989
2101
|
}
|
|
1990
2102
|
const duration = Date.now() - startTime;
|
|
1991
2103
|
if (options.json) {
|
|
@@ -2015,10 +2127,6 @@ async function pushCommand(options) {
|
|
|
2015
2127
|
process.exit(1);
|
|
2016
2128
|
}
|
|
2017
2129
|
}
|
|
2018
|
-
try {
|
|
2019
|
-
await fs9.remove(tempDir);
|
|
2020
|
-
} catch {
|
|
2021
|
-
}
|
|
2022
2130
|
} catch (error) {
|
|
2023
2131
|
const duration = Date.now() - startTime;
|
|
2024
2132
|
const errorMessage = getErrorMessage(error);
|
|
@@ -2032,6 +2140,81 @@ async function pushCommand(options) {
|
|
|
2032
2140
|
logger2.error(`Error: ${errorMessage}`);
|
|
2033
2141
|
}
|
|
2034
2142
|
process.exit(1);
|
|
2143
|
+
} finally {
|
|
2144
|
+
if (tempDir) {
|
|
2145
|
+
await fs11.remove(tempDir).catch(() => {
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
async function executeConfigPush(options, validatedEvent, logger2, setTempDir) {
|
|
2151
|
+
logger2.debug("Loading flow configuration");
|
|
2152
|
+
const { flowConfig, buildOptions } = await loadFlowConfig(options.config, {
|
|
2153
|
+
flowName: options.flow,
|
|
2154
|
+
logger: logger2
|
|
2155
|
+
});
|
|
2156
|
+
const platform = getPlatform3(flowConfig);
|
|
2157
|
+
logger2.debug("Bundling flow configuration");
|
|
2158
|
+
const configDir = buildOptions.configDir || process.cwd();
|
|
2159
|
+
const tempDir = path11.join(
|
|
2160
|
+
configDir,
|
|
2161
|
+
".tmp",
|
|
2162
|
+
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2163
|
+
);
|
|
2164
|
+
setTempDir(tempDir);
|
|
2165
|
+
await fs11.ensureDir(tempDir);
|
|
2166
|
+
const tempPath = path11.join(
|
|
2167
|
+
tempDir,
|
|
2168
|
+
`bundle.${platform === "web" ? "js" : "mjs"}`
|
|
2169
|
+
);
|
|
2170
|
+
const pushBuildOptions = {
|
|
2171
|
+
...buildOptions,
|
|
2172
|
+
output: tempPath,
|
|
2173
|
+
format: platform === "web" ? "iife" : "esm",
|
|
2174
|
+
platform: platform === "web" ? "browser" : "node",
|
|
2175
|
+
...platform === "web" && {
|
|
2176
|
+
windowCollector: "collector",
|
|
2177
|
+
windowElb: "elb"
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
await bundleCore(flowConfig, pushBuildOptions, logger2, false);
|
|
2181
|
+
logger2.debug(`Bundle created: ${tempPath}`);
|
|
2182
|
+
if (platform === "web") {
|
|
2183
|
+
logger2.debug("Executing in web environment (JSDOM)");
|
|
2184
|
+
return executeWebPush(tempPath, validatedEvent, logger2);
|
|
2185
|
+
} else if (platform === "server") {
|
|
2186
|
+
logger2.debug("Executing in server environment (Node.js)");
|
|
2187
|
+
const collectorLoggerConfig = createCollectorLoggerConfig(
|
|
2188
|
+
logger2,
|
|
2189
|
+
options.verbose
|
|
2190
|
+
);
|
|
2191
|
+
return executeServerPush(tempPath, validatedEvent, logger2, 6e4, {
|
|
2192
|
+
logger: collectorLoggerConfig
|
|
2193
|
+
});
|
|
2194
|
+
} else {
|
|
2195
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
async function executeBundlePush(bundleContent, platform, validatedEvent, logger2, setTempDir, context = {}) {
|
|
2199
|
+
const tempDir = path11.join(
|
|
2200
|
+
process.cwd(),
|
|
2201
|
+
".tmp",
|
|
2202
|
+
`push-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2203
|
+
);
|
|
2204
|
+
setTempDir(tempDir);
|
|
2205
|
+
await fs11.ensureDir(tempDir);
|
|
2206
|
+
const tempPath = path11.join(
|
|
2207
|
+
tempDir,
|
|
2208
|
+
`bundle.${platform === "server" ? "mjs" : "js"}`
|
|
2209
|
+
);
|
|
2210
|
+
await fs11.writeFile(tempPath, bundleContent, "utf8");
|
|
2211
|
+
logger2.debug(`Bundle written to: ${tempPath}`);
|
|
2212
|
+
if (platform === "web") {
|
|
2213
|
+
logger2.debug("Executing in web environment (JSDOM)");
|
|
2214
|
+
return executeWebPush(tempPath, validatedEvent, logger2);
|
|
2215
|
+
} else {
|
|
2216
|
+
logger2.debug("Executing in server environment (Node.js)");
|
|
2217
|
+
return executeServerPush(tempPath, validatedEvent, logger2, 6e4, context);
|
|
2035
2218
|
}
|
|
2036
2219
|
}
|
|
2037
2220
|
async function executeWebPush(bundlePath, event, logger2) {
|
|
@@ -2046,18 +2229,21 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
2046
2229
|
});
|
|
2047
2230
|
const { window } = dom;
|
|
2048
2231
|
logger2.debug("Loading bundle...");
|
|
2049
|
-
const bundleCode = await
|
|
2232
|
+
const bundleCode = await fs11.readFile(bundlePath, "utf8");
|
|
2050
2233
|
window.eval(bundleCode);
|
|
2051
|
-
logger2.debug("Waiting for
|
|
2234
|
+
logger2.debug("Waiting for collector...");
|
|
2052
2235
|
await waitForWindowProperty2(
|
|
2053
2236
|
window,
|
|
2054
|
-
"
|
|
2237
|
+
"collector",
|
|
2055
2238
|
5e3
|
|
2056
2239
|
);
|
|
2057
2240
|
const windowObj = window;
|
|
2058
|
-
const
|
|
2241
|
+
const collector = windowObj.collector;
|
|
2059
2242
|
logger2.log(`Pushing event: ${event.name}`);
|
|
2060
|
-
const elbResult = await
|
|
2243
|
+
const elbResult = await collector.push({
|
|
2244
|
+
name: event.name,
|
|
2245
|
+
data: event.data
|
|
2246
|
+
});
|
|
2061
2247
|
return {
|
|
2062
2248
|
success: true,
|
|
2063
2249
|
elbResult,
|
|
@@ -2071,7 +2257,7 @@ async function executeWebPush(bundlePath, event, logger2) {
|
|
|
2071
2257
|
};
|
|
2072
2258
|
}
|
|
2073
2259
|
}
|
|
2074
|
-
async function executeServerPush(bundlePath, event, logger2, timeout = 6e4) {
|
|
2260
|
+
async function executeServerPush(bundlePath, event, logger2, timeout = 6e4, context = {}) {
|
|
2075
2261
|
const startTime = Date.now();
|
|
2076
2262
|
try {
|
|
2077
2263
|
const timeoutPromise = new Promise((_, reject) => {
|
|
@@ -2087,15 +2273,18 @@ async function executeServerPush(bundlePath, event, logger2, timeout = 6e4) {
|
|
|
2087
2273
|
throw new Error("Bundle does not export default factory function");
|
|
2088
2274
|
}
|
|
2089
2275
|
logger2.debug("Calling factory function...");
|
|
2090
|
-
const result = await flowModule.default();
|
|
2091
|
-
if (!result || !result.
|
|
2276
|
+
const result = await flowModule.default(context);
|
|
2277
|
+
if (!result || !result.collector || typeof result.collector.push !== "function") {
|
|
2092
2278
|
throw new Error(
|
|
2093
|
-
"Factory function did not return valid result with
|
|
2279
|
+
"Factory function did not return valid result with collector"
|
|
2094
2280
|
);
|
|
2095
2281
|
}
|
|
2096
|
-
const {
|
|
2282
|
+
const { collector } = result;
|
|
2097
2283
|
logger2.log(`Pushing event: ${event.name}`);
|
|
2098
|
-
const elbResult = await
|
|
2284
|
+
const elbResult = await collector.push({
|
|
2285
|
+
name: event.name,
|
|
2286
|
+
data: event.data
|
|
2287
|
+
});
|
|
2099
2288
|
return {
|
|
2100
2289
|
success: true,
|
|
2101
2290
|
elbResult,
|
|
@@ -2187,7 +2376,7 @@ function validatePort(port) {
|
|
|
2187
2376
|
|
|
2188
2377
|
// src/commands/run/utils.ts
|
|
2189
2378
|
import path12 from "path";
|
|
2190
|
-
import
|
|
2379
|
+
import fs12 from "fs-extra";
|
|
2191
2380
|
async function prepareBundleForRun(configPath, options) {
|
|
2192
2381
|
const configDir = path12.dirname(path12.resolve(configPath));
|
|
2193
2382
|
const tempDir = path12.join(
|
|
@@ -2195,7 +2384,7 @@ async function prepareBundleForRun(configPath, options) {
|
|
|
2195
2384
|
".tmp",
|
|
2196
2385
|
`run-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`
|
|
2197
2386
|
);
|
|
2198
|
-
await
|
|
2387
|
+
await fs12.ensureDir(tempDir);
|
|
2199
2388
|
const tempPath = path12.join(tempDir, "bundle.mjs");
|
|
2200
2389
|
await bundle(configPath, {
|
|
2201
2390
|
cache: true,
|
|
@@ -2219,7 +2408,7 @@ import { createLogger as createLogger2, Level } from "@walkeros/core";
|
|
|
2219
2408
|
// src/runtime/runner.ts
|
|
2220
2409
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
2221
2410
|
import { resolve, dirname as dirname2 } from "path";
|
|
2222
|
-
async function runFlow(file, config, logger2) {
|
|
2411
|
+
async function runFlow(file, config, logger2, loggerConfig2) {
|
|
2223
2412
|
logger2.info(`Loading flow from ${file}`);
|
|
2224
2413
|
try {
|
|
2225
2414
|
const absolutePath = resolve(file);
|
|
@@ -2232,7 +2421,8 @@ async function runFlow(file, config, logger2) {
|
|
|
2232
2421
|
`Invalid flow bundle: ${file} must export a default function`
|
|
2233
2422
|
);
|
|
2234
2423
|
}
|
|
2235
|
-
const
|
|
2424
|
+
const flowContext = loggerConfig2 ? { ...config, logger: loggerConfig2 } : config;
|
|
2425
|
+
const result = await module.default(flowContext);
|
|
2236
2426
|
if (!result || !result.collector) {
|
|
2237
2427
|
logger2.throw(`Invalid flow bundle: ${file} must return { collector }`);
|
|
2238
2428
|
}
|
|
@@ -2338,7 +2528,8 @@ async function runServeMode(config, logger2) {
|
|
|
2338
2528
|
|
|
2339
2529
|
// src/commands/run/execution.ts
|
|
2340
2530
|
var logLevel = process.env.VERBOSE === "true" ? Level.DEBUG : Level.INFO;
|
|
2341
|
-
var
|
|
2531
|
+
var loggerConfig = { level: logLevel };
|
|
2532
|
+
var logger = createLogger2(loggerConfig);
|
|
2342
2533
|
async function executeRunLocal(mode, flowPath, options) {
|
|
2343
2534
|
switch (mode) {
|
|
2344
2535
|
case "collect": {
|
|
@@ -2349,7 +2540,7 @@ async function executeRunLocal(mode, flowPath, options) {
|
|
|
2349
2540
|
port: options.port,
|
|
2350
2541
|
host: options.host
|
|
2351
2542
|
};
|
|
2352
|
-
await runFlow(flowPath, config, logger.scope("runner"));
|
|
2543
|
+
await runFlow(flowPath, config, logger.scope("runner"), loggerConfig);
|
|
2353
2544
|
break;
|
|
2354
2545
|
}
|
|
2355
2546
|
case "serve": {
|
|
@@ -2467,20 +2658,20 @@ async function run(mode, options) {
|
|
|
2467
2658
|
}
|
|
2468
2659
|
|
|
2469
2660
|
// src/commands/cache.ts
|
|
2470
|
-
import
|
|
2661
|
+
import fs13 from "fs-extra";
|
|
2471
2662
|
function registerCacheCommand(program2) {
|
|
2472
2663
|
const cache = program2.command("cache").description("Manage the CLI cache");
|
|
2473
2664
|
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
2665
|
const logger2 = createLogger({ silent: options.silent });
|
|
2475
2666
|
const tmpDir = options.tmpDir;
|
|
2476
2667
|
if (options.packages) {
|
|
2477
|
-
await
|
|
2668
|
+
await fs13.remove(getTmpPath(tmpDir, "cache", "packages"));
|
|
2478
2669
|
logger2.log("Package cache cleared");
|
|
2479
2670
|
} else if (options.builds) {
|
|
2480
|
-
await
|
|
2671
|
+
await fs13.remove(getTmpPath(tmpDir, "cache", "builds"));
|
|
2481
2672
|
logger2.log("Build cache cleared");
|
|
2482
2673
|
} else {
|
|
2483
|
-
await
|
|
2674
|
+
await fs13.remove(getTmpPath(tmpDir, "cache"));
|
|
2484
2675
|
logger2.log("All caches cleared");
|
|
2485
2676
|
}
|
|
2486
2677
|
});
|
|
@@ -2500,13 +2691,13 @@ function registerCleanCommand(program2) {
|
|
|
2500
2691
|
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
2692
|
const logger2 = createLogger({ silent: options.silent });
|
|
2502
2693
|
const tmpDir = options.tmpDir || getDefaultTmpRoot();
|
|
2503
|
-
await
|
|
2694
|
+
await fs13.remove(tmpDir);
|
|
2504
2695
|
logger2.log(`Temp directory cleared: ${tmpDir}`);
|
|
2505
2696
|
});
|
|
2506
2697
|
}
|
|
2507
2698
|
async function countEntries(dir) {
|
|
2508
|
-
if (!await
|
|
2509
|
-
const entries = await
|
|
2699
|
+
if (!await fs13.pathExists(dir)) return 0;
|
|
2700
|
+
const entries = await fs13.readdir(dir);
|
|
2510
2701
|
return entries.length;
|
|
2511
2702
|
}
|
|
2512
2703
|
|
|
@@ -2519,7 +2710,7 @@ program.hook("preAction", (thisCommand, actionCommand) => {
|
|
|
2519
2710
|
console.log(chalk2.hex("#01b5e2")(`walkerOS v${VERSION}`));
|
|
2520
2711
|
}
|
|
2521
2712
|
});
|
|
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) => {
|
|
2713
|
+
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").option("--dockerfile", "generate Dockerfile alongside bundle").action(async (file, options) => {
|
|
2523
2714
|
await bundleCommand({
|
|
2524
2715
|
config: file || "bundle.config.json",
|
|
2525
2716
|
flow: options.flow,
|
|
@@ -2529,16 +2720,18 @@ program.command("bundle [file]").description("Bundle NPM packages with custom co
|
|
|
2529
2720
|
cache: options.cache,
|
|
2530
2721
|
verbose: options.verbose,
|
|
2531
2722
|
dryRun: options.dryRun,
|
|
2532
|
-
silent: options.silent
|
|
2723
|
+
silent: options.silent,
|
|
2724
|
+
dockerfile: options.dockerfile
|
|
2533
2725
|
});
|
|
2534
2726
|
});
|
|
2535
2727
|
program.command("simulate [file]").description("Simulate event processing and capture API calls").option(
|
|
2536
2728
|
"-e, --event <source>",
|
|
2537
2729
|
"Event to simulate (JSON string, file path, or URL)"
|
|
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) => {
|
|
2730
|
+
).option("-p, --platform <platform>", "Platform override (web or server)").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) => {
|
|
2539
2731
|
await simulateCommand({
|
|
2540
2732
|
config: file || "bundle.config.json",
|
|
2541
2733
|
event: options.event,
|
|
2734
|
+
platform: options.platform,
|
|
2542
2735
|
json: options.json,
|
|
2543
2736
|
verbose: options.verbose,
|
|
2544
2737
|
dryRun: options.dryRun,
|
|
@@ -2548,11 +2741,12 @@ program.command("simulate [file]").description("Simulate event processing and ca
|
|
|
2548
2741
|
program.command("push [file]").description("Push an event through the flow with real API execution").requiredOption(
|
|
2549
2742
|
"-e, --event <source>",
|
|
2550
2743
|
"Event to push (JSON string, file path, or URL)"
|
|
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) => {
|
|
2744
|
+
).option("--flow <name>", "Flow name (for multi-flow configs)").option("-p, --platform <platform>", "Platform override (web or server)").option("--json", "Output results as JSON").option("-v, --verbose", "Verbose output").option("-s, --silent", "Suppress output").action(async (file, options) => {
|
|
2552
2745
|
await pushCommand({
|
|
2553
2746
|
config: file || "bundle.config.json",
|
|
2554
2747
|
event: options.event,
|
|
2555
2748
|
flow: options.flow,
|
|
2749
|
+
platform: options.platform,
|
|
2556
2750
|
json: options.json,
|
|
2557
2751
|
verbose: options.verbose,
|
|
2558
2752
|
silent: options.silent
|