@walkeros/cli 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +285 -0
  3. package/dist/__tests__/bundle/bundler-integration.test.d.ts +2 -0
  4. package/dist/__tests__/bundle/bundler-integration.test.d.ts.map +1 -0
  5. package/dist/__tests__/bundle/bundler-integration.test.js +106 -0
  6. package/dist/__tests__/bundle/bundler-integration.test.js.map +1 -0
  7. package/dist/__tests__/bundle/bundler.test.d.ts +2 -0
  8. package/dist/__tests__/bundle/bundler.test.d.ts.map +1 -0
  9. package/dist/__tests__/bundle/bundler.test.js +281 -0
  10. package/dist/__tests__/bundle/bundler.test.js.map +1 -0
  11. package/dist/__tests__/bundle/programmatic.test.d.ts +2 -0
  12. package/dist/__tests__/bundle/programmatic.test.d.ts.map +1 -0
  13. package/dist/__tests__/bundle/programmatic.test.js +118 -0
  14. package/dist/__tests__/bundle/programmatic.test.js.map +1 -0
  15. package/dist/__tests__/bundle/serializer.test.d.ts +2 -0
  16. package/dist/__tests__/bundle/serializer.test.d.ts.map +1 -0
  17. package/dist/__tests__/bundle/serializer.test.js +173 -0
  18. package/dist/__tests__/bundle/serializer.test.js.map +1 -0
  19. package/dist/__tests__/bundle/template-engine.test.d.ts +2 -0
  20. package/dist/__tests__/bundle/template-engine.test.d.ts.map +1 -0
  21. package/dist/__tests__/bundle/template-engine.test.js +107 -0
  22. package/dist/__tests__/bundle/template-engine.test.js.map +1 -0
  23. package/dist/__tests__/cli-e2e.test.d.ts +8 -0
  24. package/dist/__tests__/cli-e2e.test.d.ts.map +1 -0
  25. package/dist/__tests__/cli-e2e.test.js +144 -0
  26. package/dist/__tests__/cli-e2e.test.js.map +1 -0
  27. package/dist/__tests__/cli.test.d.ts +2 -0
  28. package/dist/__tests__/cli.test.d.ts.map +1 -0
  29. package/dist/__tests__/cli.test.js +255 -0
  30. package/dist/__tests__/cli.test.js.map +1 -0
  31. package/dist/__tests__/config-loader.test.d.ts +7 -0
  32. package/dist/__tests__/config-loader.test.d.ts.map +1 -0
  33. package/dist/__tests__/config-loader.test.js +393 -0
  34. package/dist/__tests__/config-loader.test.js.map +1 -0
  35. package/dist/__tests__/core/config.test.d.ts +2 -0
  36. package/dist/__tests__/core/config.test.d.ts.map +1 -0
  37. package/dist/__tests__/core/config.test.js +72 -0
  38. package/dist/__tests__/core/config.test.js.map +1 -0
  39. package/dist/__tests__/core/logger.test.d.ts +2 -0
  40. package/dist/__tests__/core/logger.test.d.ts.map +1 -0
  41. package/dist/__tests__/core/logger.test.js +53 -0
  42. package/dist/__tests__/core/logger.test.js.map +1 -0
  43. package/dist/__tests__/simulate/programmatic.test.d.ts +2 -0
  44. package/dist/__tests__/simulate/programmatic.test.d.ts.map +1 -0
  45. package/dist/__tests__/simulate/programmatic.test.js +51 -0
  46. package/dist/__tests__/simulate/programmatic.test.js.map +1 -0
  47. package/dist/__tests__/simulate/simulator.test.d.ts +2 -0
  48. package/dist/__tests__/simulate/simulator.test.d.ts.map +1 -0
  49. package/dist/__tests__/simulate/simulator.test.js +29 -0
  50. package/dist/__tests__/simulate/simulator.test.js.map +1 -0
  51. package/dist/commands/bundle/bundler.d.ts +14 -0
  52. package/dist/commands/bundle/bundler.d.ts.map +1 -0
  53. package/dist/commands/bundle/bundler.js +372 -0
  54. package/dist/commands/bundle/bundler.js.map +1 -0
  55. package/dist/commands/bundle/index.d.ts +51 -0
  56. package/dist/commands/bundle/index.d.ts.map +1 -0
  57. package/dist/commands/bundle/index.js +200 -0
  58. package/dist/commands/bundle/index.js.map +1 -0
  59. package/dist/commands/bundle/package-manager.d.ts +7 -0
  60. package/dist/commands/bundle/package-manager.d.ts.map +1 -0
  61. package/dist/commands/bundle/package-manager.js +170 -0
  62. package/dist/commands/bundle/package-manager.js.map +1 -0
  63. package/dist/commands/bundle/serializer.d.ts +23 -0
  64. package/dist/commands/bundle/serializer.d.ts.map +1 -0
  65. package/dist/commands/bundle/serializer.js +127 -0
  66. package/dist/commands/bundle/serializer.js.map +1 -0
  67. package/dist/commands/bundle/stats.d.ts +23 -0
  68. package/dist/commands/bundle/stats.d.ts.map +1 -0
  69. package/dist/commands/bundle/stats.js +52 -0
  70. package/dist/commands/bundle/stats.js.map +1 -0
  71. package/dist/commands/bundle/template-engine.d.ts +18 -0
  72. package/dist/commands/bundle/template-engine.d.ts.map +1 -0
  73. package/dist/commands/bundle/template-engine.js +49 -0
  74. package/dist/commands/bundle/template-engine.js.map +1 -0
  75. package/dist/commands/run/__tests__/run.integration.test.d.ts +8 -0
  76. package/dist/commands/run/__tests__/run.integration.test.d.ts.map +1 -0
  77. package/dist/commands/run/__tests__/run.integration.test.js +53 -0
  78. package/dist/commands/run/__tests__/run.integration.test.js.map +1 -0
  79. package/dist/commands/run/__tests__/validators.test.d.ts +2 -0
  80. package/dist/commands/run/__tests__/validators.test.d.ts.map +1 -0
  81. package/dist/commands/run/__tests__/validators.test.js +80 -0
  82. package/dist/commands/run/__tests__/validators.test.js.map +1 -0
  83. package/dist/commands/run/index.d.ts +39 -0
  84. package/dist/commands/run/index.d.ts.map +1 -0
  85. package/dist/commands/run/index.js +251 -0
  86. package/dist/commands/run/index.js.map +1 -0
  87. package/dist/commands/run/types.d.ts +56 -0
  88. package/dist/commands/run/types.d.ts.map +1 -0
  89. package/dist/commands/run/types.js +7 -0
  90. package/dist/commands/run/types.js.map +1 -0
  91. package/dist/commands/run/validators.d.ts +29 -0
  92. package/dist/commands/run/validators.d.ts.map +1 -0
  93. package/dist/commands/run/validators.js +54 -0
  94. package/dist/commands/run/validators.js.map +1 -0
  95. package/dist/commands/simulate/index.d.ts +47 -0
  96. package/dist/commands/simulate/index.d.ts.map +1 -0
  97. package/dist/commands/simulate/index.js +121 -0
  98. package/dist/commands/simulate/index.js.map +1 -0
  99. package/dist/commands/simulate/simulator.d.ts +18 -0
  100. package/dist/commands/simulate/simulator.d.ts.map +1 -0
  101. package/dist/commands/simulate/simulator.js +236 -0
  102. package/dist/commands/simulate/simulator.js.map +1 -0
  103. package/dist/commands/simulate/tracker.d.ts +30 -0
  104. package/dist/commands/simulate/tracker.d.ts.map +1 -0
  105. package/dist/commands/simulate/tracker.js +96 -0
  106. package/dist/commands/simulate/tracker.js.map +1 -0
  107. package/dist/commands/simulate/types.d.ts +18 -0
  108. package/dist/commands/simulate/types.d.ts.map +1 -0
  109. package/dist/commands/simulate/types.js +2 -0
  110. package/dist/commands/simulate/types.js.map +1 -0
  111. package/dist/config/defaults.d.ts +33 -0
  112. package/dist/config/defaults.d.ts.map +1 -0
  113. package/dist/config/defaults.js +73 -0
  114. package/dist/config/defaults.js.map +1 -0
  115. package/dist/config/index.d.ts +14 -0
  116. package/dist/config/index.d.ts.map +1 -0
  117. package/dist/config/index.js +16 -0
  118. package/dist/config/index.js.map +1 -0
  119. package/dist/config/loader.d.ts +74 -0
  120. package/dist/config/loader.d.ts.map +1 -0
  121. package/dist/config/loader.js +136 -0
  122. package/dist/config/loader.js.map +1 -0
  123. package/dist/config/parser.d.ts +64 -0
  124. package/dist/config/parser.d.ts.map +1 -0
  125. package/dist/config/parser.js +137 -0
  126. package/dist/config/parser.js.map +1 -0
  127. package/dist/config/utils.d.ts +38 -0
  128. package/dist/config/utils.d.ts.map +1 -0
  129. package/dist/config/utils.js +66 -0
  130. package/dist/config/utils.js.map +1 -0
  131. package/dist/config/validators.d.ts +23 -0
  132. package/dist/config/validators.d.ts.map +1 -0
  133. package/dist/config/validators.js +45 -0
  134. package/dist/config/validators.js.map +1 -0
  135. package/dist/core/docker.d.ts +42 -0
  136. package/dist/core/docker.d.ts.map +1 -0
  137. package/dist/core/docker.js +114 -0
  138. package/dist/core/docker.js.map +1 -0
  139. package/dist/core/execution.d.ts +33 -0
  140. package/dist/core/execution.d.ts.map +1 -0
  141. package/dist/core/execution.js +57 -0
  142. package/dist/core/execution.js.map +1 -0
  143. package/dist/core/index.d.ts +6 -0
  144. package/dist/core/index.d.ts.map +1 -0
  145. package/dist/core/index.js +6 -0
  146. package/dist/core/index.js.map +1 -0
  147. package/dist/core/logger.d.ts +17 -0
  148. package/dist/core/logger.d.ts.map +1 -0
  149. package/dist/core/logger.js +74 -0
  150. package/dist/core/logger.js.map +1 -0
  151. package/dist/core/output.d.ts +30 -0
  152. package/dist/core/output.d.ts.map +1 -0
  153. package/dist/core/output.js +46 -0
  154. package/dist/core/output.js.map +1 -0
  155. package/dist/core/timer.d.ts +14 -0
  156. package/dist/core/timer.d.ts.map +1 -0
  157. package/dist/core/timer.js +29 -0
  158. package/dist/core/timer.js.map +1 -0
  159. package/dist/index.d.ts +614 -0
  160. package/dist/index.d.ts.map +1 -0
  161. package/dist/index.js +1940 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/types/bundle.d.ts +251 -0
  164. package/dist/types/bundle.d.ts.map +1 -0
  165. package/dist/types/bundle.js +10 -0
  166. package/dist/types/bundle.js.map +1 -0
  167. package/dist/types/global.d.ts +51 -0
  168. package/dist/types/global.d.ts.map +1 -0
  169. package/dist/types/global.js +30 -0
  170. package/dist/types/global.js.map +1 -0
  171. package/dist/types/index.d.ts +8 -0
  172. package/dist/types/index.d.ts.map +1 -0
  173. package/dist/types/index.js +8 -0
  174. package/dist/types/index.js.map +1 -0
  175. package/dist/types/template.d.ts +108 -0
  176. package/dist/types/template.d.ts.map +1 -0
  177. package/dist/types/template.js +10 -0
  178. package/dist/types/template.js.map +1 -0
  179. package/package.json +59 -0
  180. package/templates/base.hbs +44 -0
  181. package/templates/server.hbs +29 -0
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Run Command Validators
3
+ *
4
+ * Validation logic for run command inputs
5
+ */
6
+ import type { RunMode } from './types';
7
+ /**
8
+ * Validates run mode
9
+ *
10
+ * @param mode - Mode to validate
11
+ * @throws Error if mode is invalid
12
+ */
13
+ export declare function validateMode(mode: string): asserts mode is RunMode;
14
+ /**
15
+ * Validates flow file exists
16
+ *
17
+ * @param filePath - Path to flow configuration file
18
+ * @returns Absolute path to flow file
19
+ * @throws Error if file doesn't exist
20
+ */
21
+ export declare function validateFlowFile(filePath: string): string;
22
+ /**
23
+ * Validates port number
24
+ *
25
+ * @param port - Port number to validate
26
+ * @throws Error if port is invalid
27
+ */
28
+ export declare function validatePort(port: number): void;
29
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../../src/commands/run/validators.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAOvC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,IAAI,OAAO,CAQlE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYzD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAQ/C"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Run Command Validators
3
+ *
4
+ * Validation logic for run command inputs
5
+ */
6
+ import { existsSync } from 'fs';
7
+ import { resolve } from 'path';
8
+ /**
9
+ * Valid run modes
10
+ */
11
+ const VALID_MODES = ['collect', 'serve'];
12
+ /**
13
+ * Validates run mode
14
+ *
15
+ * @param mode - Mode to validate
16
+ * @throws Error if mode is invalid
17
+ */
18
+ export function validateMode(mode) {
19
+ if (!VALID_MODES.includes(mode)) {
20
+ throw new Error(`Invalid mode: "${mode}"\n` +
21
+ ` Valid modes: ${VALID_MODES.join(', ')}\n` +
22
+ ` Example: walkeros run collect ./flow.json`);
23
+ }
24
+ }
25
+ /**
26
+ * Validates flow file exists
27
+ *
28
+ * @param filePath - Path to flow configuration file
29
+ * @returns Absolute path to flow file
30
+ * @throws Error if file doesn't exist
31
+ */
32
+ export function validateFlowFile(filePath) {
33
+ const absolutePath = resolve(filePath);
34
+ if (!existsSync(absolutePath)) {
35
+ throw new Error(`Flow file not found: ${filePath}\n` +
36
+ ` Resolved path: ${absolutePath}\n` +
37
+ ` Make sure the file exists and the path is correct`);
38
+ }
39
+ return absolutePath;
40
+ }
41
+ /**
42
+ * Validates port number
43
+ *
44
+ * @param port - Port number to validate
45
+ * @throws Error if port is invalid
46
+ */
47
+ export function validatePort(port) {
48
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
49
+ throw new Error(`Invalid port: ${port}\n` +
50
+ ` Port must be an integer between 1 and 65535\n` +
51
+ ` Example: --port 8080`);
52
+ }
53
+ }
54
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../src/commands/run/validators.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/B;;GAEG;AACH,MAAM,WAAW,GAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAe,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,kBAAkB,IAAI,KAAK;YACzB,mBAAmB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC7C,8CAA8C,CACjD,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEvC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,wBAAwB,QAAQ,IAAI;YAClC,qBAAqB,YAAY,IAAI;YACrC,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CACb,iBAAiB,IAAI,IAAI;YACvB,kDAAkD;YAClD,yBAAyB,CAC5B,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { SimulateCommandOptions } from './types';
2
+ /**
3
+ * CLI command handler for simulate command
4
+ */
5
+ export declare function simulateCommand(options: SimulateCommandOptions): Promise<void>;
6
+ /**
7
+ * High-level simulate function for programmatic usage.
8
+ *
9
+ * Handles configuration loading internally and returns structured results.
10
+ *
11
+ * @param configOrPath - Bundle configuration object or path to config file
12
+ * @param event - Event object to simulate
13
+ * @param options - Simulation options
14
+ * @param options.silent - Suppress all output (default: false)
15
+ * @param options.verbose - Enable verbose logging (default: false)
16
+ * @param options.json - Format output as JSON (default: false)
17
+ * @returns Simulation result with success status, elb result, and usage data
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * // With config file
22
+ * const result = await simulate('./walker.config.json', {
23
+ * name: 'page view',
24
+ * data: { title: 'Home Page', path: '/', url: 'https://example.com' }
25
+ * });
26
+ *
27
+ * // With config object
28
+ * const result = await simulate(
29
+ * {
30
+ * platform: 'web',
31
+ * packages: { '@walkeros/collector': { imports: ['startFlow'] } },
32
+ * code: '...',
33
+ * output: './bundle.js'
34
+ * },
35
+ * { name: 'page view' },
36
+ * { silent: true }
37
+ * );
38
+ * ```
39
+ */
40
+ export declare function simulate(configOrPath: string | unknown, event: unknown, options?: {
41
+ silent?: boolean;
42
+ verbose?: boolean;
43
+ json?: boolean;
44
+ }): Promise<import('./types').SimulationResult>;
45
+ export * from './types';
46
+ export * from './simulator';
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/simulate/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Ef;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,MAAM,GAAG,OAAO,EAC9B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE;IACP,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;CACX,GACL,OAAO,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,CAgB7C;AAGD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,121 @@
1
+ import { simulateCore, parseEventInput, formatSimulationResult, } from './simulator';
2
+ import { createLogger, executeCommand } from '../../core';
3
+ /**
4
+ * CLI command handler for simulate command
5
+ */
6
+ export async function simulateCommand(options) {
7
+ const logger = createLogger({
8
+ verbose: options.verbose,
9
+ silent: options.silent ?? false,
10
+ json: options.json,
11
+ });
12
+ // Build Docker args
13
+ const dockerArgs = [options.config];
14
+ if (options.event)
15
+ dockerArgs.push('--event', options.event);
16
+ if (options.json)
17
+ dockerArgs.push('--json');
18
+ if (options.verbose)
19
+ dockerArgs.push('--verbose');
20
+ if (options.silent)
21
+ dockerArgs.push('--silent');
22
+ await executeCommand(async () => {
23
+ const startTime = Date.now();
24
+ try {
25
+ // Parse event input
26
+ const event = parseEventInput(options.event);
27
+ // Execute simulation
28
+ const result = await simulateCore(options.config, event, {
29
+ json: options.json,
30
+ verbose: options.verbose,
31
+ silent: options.silent,
32
+ });
33
+ // Add duration to result
34
+ const resultWithDuration = {
35
+ ...result,
36
+ duration: (Date.now() - startTime) / 1000,
37
+ };
38
+ // Output results - create output logger that always logs
39
+ const outputLogger = createLogger({ silent: false, json: false });
40
+ const output = formatSimulationResult(resultWithDuration, {
41
+ json: options.json,
42
+ });
43
+ outputLogger.log('white', output);
44
+ // Exit with error code if simulation failed
45
+ if (!result.success) {
46
+ process.exit(1);
47
+ }
48
+ }
49
+ catch (error) {
50
+ const errorMessage = error instanceof Error ? error.message : String(error);
51
+ if (options.json) {
52
+ // JSON error output - create output logger that always logs
53
+ const outputLogger = createLogger({ silent: false, json: false });
54
+ const errorOutput = JSON.stringify({
55
+ success: false,
56
+ error: errorMessage,
57
+ duration: (Date.now() - startTime) / 1000,
58
+ }, null, 2);
59
+ outputLogger.log('white', errorOutput);
60
+ }
61
+ else {
62
+ // Error output - create error logger that always logs
63
+ const errorLogger = createLogger({ silent: false, json: false });
64
+ errorLogger.error(`❌ Simulate command failed: ${errorMessage}`);
65
+ }
66
+ process.exit(1);
67
+ }
68
+ }, 'simulate', dockerArgs, options, logger);
69
+ }
70
+ /**
71
+ * High-level simulate function for programmatic usage.
72
+ *
73
+ * Handles configuration loading internally and returns structured results.
74
+ *
75
+ * @param configOrPath - Bundle configuration object or path to config file
76
+ * @param event - Event object to simulate
77
+ * @param options - Simulation options
78
+ * @param options.silent - Suppress all output (default: false)
79
+ * @param options.verbose - Enable verbose logging (default: false)
80
+ * @param options.json - Format output as JSON (default: false)
81
+ * @returns Simulation result with success status, elb result, and usage data
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * // With config file
86
+ * const result = await simulate('./walker.config.json', {
87
+ * name: 'page view',
88
+ * data: { title: 'Home Page', path: '/', url: 'https://example.com' }
89
+ * });
90
+ *
91
+ * // With config object
92
+ * const result = await simulate(
93
+ * {
94
+ * platform: 'web',
95
+ * packages: { '@walkeros/collector': { imports: ['startFlow'] } },
96
+ * code: '...',
97
+ * output: './bundle.js'
98
+ * },
99
+ * { name: 'page view' },
100
+ * { silent: true }
101
+ * );
102
+ * ```
103
+ */
104
+ export async function simulate(configOrPath, event, options = {}) {
105
+ // simulateCore currently only accepts file paths, so we need to handle that
106
+ // For now, if configOrPath is not a string, throw an error with guidance
107
+ if (typeof configOrPath !== 'string') {
108
+ throw new Error('simulate() currently only supports config file paths. ' +
109
+ 'Config object support will be added in a future version. ' +
110
+ 'Please provide a path to a configuration file.');
111
+ }
112
+ // Call core simulator
113
+ return await simulateCore(configOrPath, event, {
114
+ json: options.json ?? false,
115
+ verbose: options.verbose ?? false,
116
+ });
117
+ }
118
+ // Re-export types and utilities for testing
119
+ export * from './types';
120
+ export * from './simulator';
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/simulate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,eAAe,EACf,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG1D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAA+B;IAE/B,MAAM,MAAM,GAAG,YAAY,CAAC;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;QAC/B,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC,CAAC;IAEH,oBAAoB;IACpB,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,OAAO,CAAC,KAAK;QAAE,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,IAAI;QAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,OAAO,CAAC,OAAO;QAAE,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,MAA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AClC,CAAC,CAAC;AACL,CAAC;AAED,4CAA4C;AAC5C,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { SimulateCommandOptions, SimulationResult } from './types';
2
+ /**
3
+ * Main simulation orchestrator
4
+ */
5
+ export declare function simulateCore(configPath: string, event: unknown, options?: Pick<SimulateCommandOptions, 'json' | 'verbose' | 'silent'>): Promise<SimulationResult>;
6
+ /**
7
+ * Parse event input - handles both strings and JSON objects
8
+ */
9
+ export declare function parseEventInput(eventString?: string): unknown;
10
+ /**
11
+ * Simple result formatting
12
+ */
13
+ export declare function formatSimulationResult(result: SimulationResult, options?: Pick<SimulateCommandOptions, 'json'>): string;
14
+ /**
15
+ * Execute simulation using destination-provided mock environments
16
+ */
17
+ export declare function executeSimulation(event: unknown, configPath: string): Promise<SimulationResult>;
18
+ //# sourceMappingURL=simulator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator.d.ts","sourceRoot":"","sources":["../../../src/commands/simulate/simulator.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AASxE;;GAEG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAM,GACxE,OAAO,CAAC,gBAAgB,CAAC,CAqC3B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,GAAE,MAAW,GAAG,OAAO,CAajE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAM,GACjD,MAAM,CAeR;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,gBAAgB,CAAC,CA4L3B"}
@@ -0,0 +1,236 @@
1
+ import path from 'path';
2
+ import fs from 'fs-extra';
3
+ import { createLogger } from '../../core';
4
+ import { loadJsonConfig, getTempDir, isObject, parseBundleConfig, } from '../../config';
5
+ import { bundleCore } from '../bundle/bundler';
6
+ import { downloadPackages } from '../bundle/package-manager';
7
+ import { CallTracker } from './tracker';
8
+ /**
9
+ * Generate a unique ID for temp files
10
+ */
11
+ function generateId() {
12
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
13
+ }
14
+ /**
15
+ * Main simulation orchestrator
16
+ */
17
+ export async function simulateCore(configPath, event, options = {}) {
18
+ const logger = createLogger({
19
+ verbose: options.verbose || false,
20
+ silent: options.silent || false,
21
+ json: options.json || false,
22
+ });
23
+ try {
24
+ logger.info('🎯 Starting walkerOS simulation...');
25
+ // Load and validate configuration
26
+ logger.info('📦 Loading bundle configuration...');
27
+ const fullConfigPath = path.resolve(configPath);
28
+ const rawConfig = await loadJsonConfig(fullConfigPath);
29
+ parseBundleConfig(rawConfig); // Validate config format
30
+ // Execute simulation
31
+ logger.info(`🚀 Executing simulation with event: ${JSON.stringify(event)}`);
32
+ const result = await executeSimulation(event, fullConfigPath);
33
+ // Report results
34
+ if (result.success) {
35
+ logger.info(`✅ Simulation completed successfully`);
36
+ }
37
+ else {
38
+ logger.error(`❌ Simulation failed: ${result.error}`);
39
+ }
40
+ return result;
41
+ }
42
+ catch (error) {
43
+ const errorMessage = error instanceof Error ? error.message : String(error);
44
+ logger.error(`💥 Simulation error: ${errorMessage}`);
45
+ return {
46
+ success: false,
47
+ error: errorMessage,
48
+ };
49
+ }
50
+ }
51
+ /**
52
+ * Parse event input - handles both strings and JSON objects
53
+ */
54
+ export function parseEventInput(eventString = '') {
55
+ if (!eventString) {
56
+ return {};
57
+ }
58
+ // Try to parse as JSON first
59
+ try {
60
+ const parsed = JSON.parse(eventString);
61
+ return isObject(parsed) ? parsed : {};
62
+ }
63
+ catch {
64
+ // If JSON parsing fails, treat as event name string
65
+ return { name: eventString };
66
+ }
67
+ }
68
+ /**
69
+ * Simple result formatting
70
+ */
71
+ export function formatSimulationResult(result, options = {}) {
72
+ if (options.json) {
73
+ const output = {
74
+ result: result.elbResult,
75
+ usage: result.usage,
76
+ duration: result.duration,
77
+ };
78
+ return JSON.stringify(output, null, 2);
79
+ }
80
+ if (result.success) {
81
+ return '✅ Simulation completed successfully';
82
+ }
83
+ else {
84
+ return `❌ Simulation failed: ${result.error}`;
85
+ }
86
+ }
87
+ /**
88
+ * Execute simulation using destination-provided mock environments
89
+ */
90
+ export async function executeSimulation(event, configPath) {
91
+ const startTime = Date.now();
92
+ let bundlePath;
93
+ const tempDir = getTempDir();
94
+ try {
95
+ // Ensure temp directory exists
96
+ await fs.ensureDir(tempDir);
97
+ // 1. Load config
98
+ const rawConfig = await loadJsonConfig(configPath);
99
+ const { flowConfig, buildOptions } = parseBundleConfig(rawConfig);
100
+ // 2. Download packages to temp directory
101
+ // This ensures we use clean npm packages, not workspace packages
102
+ const packagesArray = Object.entries(buildOptions.packages).map(([name, packageConfig]) => ({
103
+ name,
104
+ version: (typeof packageConfig === 'object' &&
105
+ packageConfig !== null &&
106
+ 'version' in packageConfig &&
107
+ typeof packageConfig.version === 'string'
108
+ ? packageConfig.version
109
+ : undefined) || 'latest',
110
+ }));
111
+ const packagePaths = await downloadPackages(packagesArray, tempDir, // downloadPackages will add 'node_modules' subdirectory itself
112
+ createLogger({ silent: true }), buildOptions.cache);
113
+ // 3. Create tracker
114
+ const tracker = new CallTracker();
115
+ // 4. Prepare env setup code to inject into bundle
116
+ // The bundle will import examples, so we can reference them directly in the injected code
117
+ const envSetupCode = [];
118
+ const destinations = flowConfig.destinations;
119
+ if (destinations) {
120
+ for (const [key, dest] of Object.entries(destinations)) {
121
+ // Generate code to wrap env using examples imported IN THE BUNDLE
122
+ const destName = key.replace(/-/g, '_');
123
+ envSetupCode.push(`
124
+ // Inject tracked env for destination '${key}' using examples from bundle
125
+ if (examples && examples['${key}'] && examples['${key}'].env) {
126
+ const mockEnv = examples['${key}'].env.push;
127
+ const trackPaths = examples['${key}'].env.simulation || [];
128
+ if (mockEnv) {
129
+ const wrappedPaths = trackPaths.map((p) => '${key}:' + p);
130
+ const trackedEnv = __simulationTracker.wrapEnv(mockEnv, wrappedPaths);
131
+ if (config.destinations && config.destinations['${key}']) {
132
+ config.destinations['${key}'].env = trackedEnv;
133
+ }
134
+ }
135
+ }
136
+ `);
137
+ }
138
+ }
139
+ // 5. Inject env setup code BEFORE startFlow
140
+ // Note: __simulationTracker will be provided via factory function parameter
141
+ const modifiedCode = `
142
+ // Inject tracked envs into destination configs
143
+ ${envSetupCode.join('\n')}
144
+
145
+ ${buildOptions.code || ''}
146
+ `;
147
+ // 7. Create temporary bundle with downloaded packages
148
+ const tempOutput = path.join(tempDir, `simulation-bundle-${generateId()}.mjs`);
149
+ // Create modified build options for simulation
150
+ const simulationBuildOptions = {
151
+ ...buildOptions,
152
+ code: modifiedCode,
153
+ output: tempOutput,
154
+ tempDir, // Use same temp dir for bundle
155
+ format: 'esm',
156
+ // Force node platform for simulation since we're running in Node.js
157
+ platform: 'node',
158
+ };
159
+ // 8. Bundle with downloaded packages (they're already in tempDir/node_modules)
160
+ await bundleCore(flowConfig, simulationBuildOptions, createLogger({ silent: true }), false);
161
+ bundlePath = tempOutput;
162
+ // 9. Inject minimal globals for Node simulation environment
163
+ // This allows destinations to reference window/document without errors
164
+ const globalWithSim = globalThis;
165
+ if (!globalWithSim.window) {
166
+ globalWithSim.window = {};
167
+ }
168
+ if (!globalWithSim.document) {
169
+ globalWithSim.document = {};
170
+ }
171
+ // 10. Dynamic import the bundle
172
+ const timestamp = Date.now();
173
+ const moduleUrl = `file://${bundlePath}?t=${timestamp}`;
174
+ const module = await import(moduleUrl);
175
+ // 11. Populate globals with destination-specific mocks from examples
176
+ // This happens AFTER import so we can access the exported examples
177
+ const importedExamples = module.examples;
178
+ const destinations2 = flowConfig.destinations;
179
+ if (importedExamples && destinations2) {
180
+ for (const [key, dest] of Object.entries(destinations2)) {
181
+ const destEnv = importedExamples[key]?.env?.push;
182
+ if (destEnv) {
183
+ if (destEnv.window &&
184
+ typeof globalWithSim.window === 'object' &&
185
+ globalWithSim.window !== null) {
186
+ Object.assign(globalWithSim.window, destEnv.window);
187
+ }
188
+ if (destEnv.document &&
189
+ typeof globalWithSim.document === 'object' &&
190
+ globalWithSim.document !== null) {
191
+ Object.assign(globalWithSim.document, destEnv.document);
192
+ }
193
+ }
194
+ }
195
+ }
196
+ // 12. Call bundle factory function with tracker
197
+ const flowResult = await module.default({ tracker });
198
+ if (!flowResult || typeof flowResult.elb !== 'function') {
199
+ throw new Error('Bundle did not export valid flow object with elb function');
200
+ }
201
+ const { elb } = flowResult;
202
+ // 13. Execute the event
203
+ const elbResult = await elb(event);
204
+ // 14. Retrieve tracked calls from tracker instance
205
+ const usage = tracker.getCalls();
206
+ const duration = Date.now() - startTime;
207
+ return {
208
+ success: true,
209
+ elbResult,
210
+ usage,
211
+ duration,
212
+ logs: [],
213
+ };
214
+ }
215
+ catch (error) {
216
+ const duration = Date.now() - startTime;
217
+ return {
218
+ success: false,
219
+ error: error instanceof Error ? error.message : String(error),
220
+ duration,
221
+ };
222
+ }
223
+ finally {
224
+ // Cleanup temp directory and all its contents
225
+ if (tempDir) {
226
+ await fs.remove(tempDir).catch(() => {
227
+ // Ignore cleanup errors - temp dirs will be cleaned eventually
228
+ });
229
+ }
230
+ // Cleanup injected globals
231
+ const globalWithSim = globalThis;
232
+ delete globalWithSim.window;
233
+ delete globalWithSim.document;
234
+ }
235
+ }
236
+ //# sourceMappingURL=simulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"simulator.js","sourceRoot":"","sources":["../../../src/commands/simulate/simulator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE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C,GAAG,EAAE;gBAClC,+DAA+D;YACjE,CAAC,CAAC,CAAC;QACL,CAAC;QAED,2BAA2B;QAC3B,MAAM,aAAa,GAAG,UAAqC,CAAC;QAC5D,OAAO,aAAa,CAAC,MAAM,CAAC;QAC5B,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Call Tracker for Simulation
3
+ *
4
+ * Wraps mock environment functions to track API calls.
5
+ * Used with destination-provided examples/env.ts mocks.
6
+ */
7
+ export interface ApiCall {
8
+ type: 'call';
9
+ path: string;
10
+ args: unknown[];
11
+ timestamp: number;
12
+ }
13
+ export declare class CallTracker {
14
+ private calls;
15
+ /**
16
+ * Wrap a function to track its calls
17
+ */
18
+ wrapFunction(name: string, fn?: (...args: unknown[]) => unknown): (...args: unknown[]) => unknown;
19
+ /**
20
+ * Wrap an environment object, tracking specified paths
21
+ *
22
+ * @param env - Environment object (from destination's examples/env.ts)
23
+ * @param paths - Paths to track (e.g., ['gtag:window.gtag', 'gtag:window.dataLayer.push'])
24
+ */
25
+ wrapEnv<T extends Record<string, unknown>>(env: T, paths: string[]): T;
26
+ private logCall;
27
+ getCalls(): Record<string, ApiCall[]>;
28
+ reset(): void;
29
+ }
30
+ //# sourceMappingURL=tracker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker.d.ts","sourceRoot":"","sources":["../../../src/commands/simulate/tracker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAqC;IAElD;;OAEG;IACH,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,EAAE,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,GACnC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO;IAYlC;;;;;OAKG;IACH,OAAO,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC;IA4DtE,OAAO,CAAC,OAAO;IAiBf,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;IAIrC,KAAK,IAAI,IAAI;CAGd"}