@walkeros/cli 0.4.2 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +140 -9
  3. package/dist/__tests__/bundle/bundler-helpers.test.js +0 -134
  4. package/dist/__tests__/bundle/bundler-helpers.test.js.map +1 -1
  5. package/dist/__tests__/bundle/bundler.test.js +121 -61
  6. package/dist/__tests__/bundle/bundler.test.js.map +1 -1
  7. package/dist/__tests__/bundle/programmatic.test.js +0 -2
  8. package/dist/__tests__/bundle/programmatic.test.js.map +1 -1
  9. package/dist/__tests__/config-loader.test.js +0 -2
  10. package/dist/__tests__/config-loader.test.js.map +1 -1
  11. package/dist/__tests__/simulate/server-simulate.integration.test.js +0 -1
  12. package/dist/__tests__/simulate/server-simulate.integration.test.js.map +1 -1
  13. package/dist/commands/bundle/bundler.d.ts +18 -0
  14. package/dist/commands/bundle/bundler.d.ts.map +1 -1
  15. package/dist/commands/bundle/bundler.js +193 -77
  16. package/dist/commands/bundle/bundler.js.map +1 -1
  17. package/dist/commands/run/execution.d.ts.map +1 -1
  18. package/dist/commands/run/execution.js +6 -2
  19. package/dist/commands/run/execution.js.map +1 -1
  20. package/dist/config/build-defaults.d.ts.map +1 -1
  21. package/dist/config/build-defaults.js +0 -2
  22. package/dist/config/build-defaults.js.map +1 -1
  23. package/dist/core/asset-resolver.d.ts +4 -4
  24. package/dist/core/asset-resolver.d.ts.map +1 -1
  25. package/dist/core/asset-resolver.js +6 -10
  26. package/dist/core/asset-resolver.js.map +1 -1
  27. package/dist/core/docker.d.ts.map +1 -1
  28. package/dist/core/docker.js +6 -2
  29. package/dist/core/docker.js.map +1 -1
  30. package/dist/examples/README.md +13 -1
  31. package/dist/examples/flow-order-complete.json +1 -2
  32. package/dist/examples/flow-simple.json +1 -2
  33. package/dist/examples/server-collect.json +4 -4
  34. package/dist/index.d.ts +1 -114
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +321 -386
  37. package/dist/index.js.map +1 -1
  38. package/dist/types/bundle.d.ts +0 -5
  39. package/dist/types/bundle.d.ts.map +1 -1
  40. package/dist/walker.js +1 -1
  41. package/examples/README.md +13 -1
  42. package/examples/flow-order-complete.json +1 -2
  43. package/examples/flow-simple.json +1 -2
  44. package/examples/server-collect.json +4 -4
  45. package/package.json +2 -4
  46. package/dist/__tests__/bundle/serializer.test.d.ts +0 -2
  47. package/dist/__tests__/bundle/serializer.test.d.ts.map +0 -1
  48. package/dist/__tests__/bundle/serializer.test.js +0 -173
  49. package/dist/__tests__/bundle/serializer.test.js.map +0 -1
  50. package/dist/__tests__/bundle/template-engine.test.d.ts +0 -2
  51. package/dist/__tests__/bundle/template-engine.test.d.ts.map +0 -1
  52. package/dist/__tests__/bundle/template-engine.test.js +0 -107
  53. package/dist/__tests__/bundle/template-engine.test.js.map +0 -1
  54. package/dist/commands/bundle/serializer.d.ts +0 -23
  55. package/dist/commands/bundle/serializer.d.ts.map +0 -1
  56. package/dist/commands/bundle/serializer.js +0 -127
  57. package/dist/commands/bundle/serializer.js.map +0 -1
  58. package/dist/commands/bundle/template-engine.d.ts +0 -20
  59. package/dist/commands/bundle/template-engine.d.ts.map +0 -1
  60. package/dist/commands/bundle/template-engine.js +0 -54
  61. package/dist/commands/bundle/template-engine.js.map +0 -1
  62. package/dist/templates/server.hbs +0 -29
  63. package/dist/templates/web.hbs +0 -45
  64. package/dist/types/template.d.ts +0 -108
  65. package/dist/types/template.d.ts.map +0 -1
  66. package/dist/types/template.js +0 -10
  67. package/dist/types/template.js.map +0 -1
  68. package/templates/server.hbs +0 -29
  69. package/templates/web.hbs +0 -45
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/template-engine.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIrE,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAoB;;IAUtC;;;;OAIG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAWzD;;OAEG;IACH,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAC9C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EACnD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,MAAM;IAoBT;;OAEG;IACG,OAAO,CACX,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAC9C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EACnD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC;CAWnB"}
@@ -1,54 +0,0 @@
1
- import fs from 'fs-extra';
2
- import Handlebars from 'handlebars';
3
- import { processTemplateVariables } from './serializer.js';
4
- import { resolveAsset } from '../../core/asset-resolver.js';
5
- export class TemplateEngine {
6
- handlebars;
7
- constructor() {
8
- // Create a new Handlebars instance
9
- this.handlebars = Handlebars.create();
10
- // Register equality helper for conditional window assignment
11
- this.handlebars.registerHelper('eq', (a, b) => a === b);
12
- }
13
- /**
14
- * Load template content from file path
15
- *
16
- * @param templatePath - Template path (bare name, relative, or absolute)
17
- */
18
- async loadTemplate(templatePath) {
19
- // Use unified asset resolver (works in both local and Docker)
20
- const resolvedPath = resolveAsset(templatePath, 'template');
21
- if (!(await fs.pathExists(resolvedPath))) {
22
- throw new Error(`Template file not found: ${resolvedPath}`);
23
- }
24
- return await fs.readFile(resolvedPath, 'utf-8');
25
- }
26
- /**
27
- * Apply template with user code and variable substitution
28
- */
29
- applyTemplate(template, userCode, sources, destinations, collector, build) {
30
- // Process template variables to serialize config objects
31
- const processedVariables = processTemplateVariables({
32
- sources,
33
- destinations,
34
- collector,
35
- });
36
- // Prepare template data for Handlebars
37
- const templateData = {
38
- CODE: userCode,
39
- build: build || {},
40
- ...processedVariables,
41
- };
42
- // Compile and execute the template
43
- const compiledTemplate = this.handlebars.compile(template);
44
- return compiledTemplate(templateData);
45
- }
46
- /**
47
- * Process template with user code
48
- */
49
- async process(templatePath, userCode, sources, destinations, collector, build) {
50
- const template = await this.loadTemplate(templatePath);
51
- return this.applyTemplate(template, userCode, sources, destinations, collector, build);
52
- }
53
- }
54
- //# sourceMappingURL=template-engine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-engine.js","sourceRoot":"","sources":["../../../src/commands/bundle/template-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,cAAc;IACjB,UAAU,CAAoB;IAEtC;QACE,mCAAmC;QACnC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;QAEtC,6DAA6D;QAC7D,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,YAAoB;QACrC,8DAA8D;QAC9D,MAAM,YAAY,GAAG,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;QAE5D,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,4BAA4B,YAAY,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,aAAa,CACX,QAAgB,EAChB,QAAgB,EAChB,OAA8C,EAC9C,YAAmD,EACnD,SAAkC,EAClC,KAA+B;QAE/B,yDAAyD;QACzD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;YAClD,OAAO;YACP,YAAY;YACZ,SAAS;SACV,CAAC,CAAC;QAEH,uCAAuC;QACvC,MAAM,YAAY,GAA4B;YAC5C,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,KAAK,IAAI,EAAE;YAClB,GAAG,kBAAkB;SACtB,CAAC;QAEF,mCAAmC;QACnC,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAO,CACX,YAAoB,EACpB,QAAgB,EAChB,OAA8C,EAC9C,YAAmD,EACnD,SAAkC,EAClC,KAA+B;QAE/B,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC,aAAa,CACvB,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,SAAS,EACT,KAAK,CACN,CAAC;IACJ,CAAC;CACF"}
@@ -1,29 +0,0 @@
1
- export default async function(context = {}) {
2
- const config = {
3
- sources: {
4
- {{#each sources}}
5
- {{@key}}: {
6
- code: {{{code}}},
7
- config: {{{config}}}{{#if env}},
8
- env: {{{env}}}{{/if}}
9
- },
10
- {{/each}}
11
- },
12
- destinations: {
13
- {{#each destinations}}
14
- {{@key}}: {
15
- code: {{{code}}},
16
- config: {{{config}}}{{#if env}},
17
- env: {{{env}}}{{/if}}
18
- },
19
- {{/each}}
20
- }{{#if collector}},
21
- ...{{{collector}}}{{/if}}
22
- };
23
-
24
- {{{CODE}}}
25
-
26
- const result = await startFlow(config);
27
-
28
- return result;
29
- }
@@ -1,45 +0,0 @@
1
- (async () => {
2
- // Check if we're in a browser environment
3
- const window = typeof globalThis.window !== 'undefined' ? globalThis.window : undefined;
4
- const document = typeof globalThis.document !== 'undefined' ? globalThis.document : undefined;
5
-
6
- const config = {
7
- sources: {
8
- {{#each sources}}
9
- {{@key}}: {
10
- code: {{{code}}},
11
- config: {{{config}}}{{#unless config}}{}{{/unless}}{{#if env}},
12
- env: {
13
- window,
14
- document,
15
- ...{{{env}}}
16
- }{{/if}}
17
- }{{#unless @last}},{{/unless}}
18
- {{/each}}
19
- },
20
- destinations: {
21
- {{#each destinations}}
22
- {{@key}}: {
23
- code: {{{code}}},
24
- config: {{{config}}}{{#unless config}}{}{{/unless}}{{#if env}},
25
- env: {
26
- window,
27
- document,
28
- ...{{{env}}}
29
- }{{/if}}
30
- }{{#unless @last}},{{/unless}}
31
- {{/each}}
32
- }{{#if collector}},
33
- ...{{{collector}}}{{/if}}
34
- };
35
-
36
- {{{CODE}}}
37
-
38
- const { collector, elb } = await startFlow(config);
39
-
40
- if (typeof window !== 'undefined') {
41
- {{#if build.windowCollector}}window['{{build.windowCollector}}'] = collector;
42
- {{/if}}{{#if build.windowElb}}window['{{build.windowElb}}'] = elb;
43
- {{/if}}
44
- }
45
- })();
@@ -1,108 +0,0 @@
1
- /**
2
- * Template Configuration Types
3
- *
4
- * Type definitions for template processing and serialization.
5
- * Used by the template engine and serializer.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Source or Destination configuration item for templates.
11
- *
12
- * @remarks
13
- * This type is used in template processing where config objects
14
- * are serialized to JavaScript code.
15
- */
16
- export interface SourceDestinationItem {
17
- /**
18
- * JavaScript code reference (variable name or expression)
19
- */
20
- code: string;
21
- /**
22
- * Configuration object for the source/destination
23
- */
24
- config?: unknown;
25
- /**
26
- * Environment-specific variables
27
- */
28
- env?: unknown;
29
- /**
30
- * Allow additional properties for extensibility
31
- */
32
- [key: string]: unknown;
33
- }
34
- /**
35
- * Template variables that can be used in Handlebars templates.
36
- *
37
- * @remarks
38
- * These variables are available in template files for customization.
39
- */
40
- export interface TemplateVariables {
41
- /**
42
- * Serialized sources configuration
43
- */
44
- sources: string;
45
- /**
46
- * Serialized destinations configuration
47
- */
48
- destinations: string;
49
- /**
50
- * Serialized collector configuration
51
- */
52
- collector: string;
53
- /**
54
- * User-provided code to be inserted
55
- */
56
- CODE: string;
57
- /**
58
- * Build configuration (optional)
59
- */
60
- build?: Record<string, unknown>;
61
- }
62
- /**
63
- * Processed template variables after serialization.
64
- *
65
- * @remarks
66
- * Internal type used by the serializer to represent processed configs.
67
- */
68
- export interface ProcessedTemplateVariables {
69
- /**
70
- * Processed sources with serialized configs
71
- */
72
- sources?: Record<string, TemplateSource>;
73
- /**
74
- * Processed destinations with serialized configs
75
- */
76
- destinations?: Record<string, TemplateDestination>;
77
- /**
78
- * Processed collector configuration
79
- */
80
- collector?: Record<string, unknown> | string;
81
- /**
82
- * Allow additional properties
83
- */
84
- [key: string]: unknown;
85
- }
86
- /**
87
- * Template source after processing.
88
- *
89
- * @internal
90
- */
91
- export interface TemplateSource {
92
- code: string;
93
- config?: unknown | string;
94
- env?: unknown;
95
- [key: string]: unknown;
96
- }
97
- /**
98
- * Template destination after processing.
99
- *
100
- * @internal
101
- */
102
- export interface TemplateDestination {
103
- code: string;
104
- config?: unknown | string;
105
- env?: unknown;
106
- [key: string]: unknown;
107
- }
108
- //# sourceMappingURL=template.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../src/types/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;GAMG;A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OAAO,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
@@ -1,10 +0,0 @@
1
- /**
2
- * Template Configuration Types
3
- *
4
- * Type definitions for template processing and serialization.
5
- * Used by the template engine and serializer.
6
- *
7
- * @packageDocumentation
8
- */
9
- export {};
10
- //# sourceMappingURL=template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/types/template.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -1,29 +0,0 @@
1
- export default async function(context = {}) {
2
- const config = {
3
- sources: {
4
- {{#each sources}}
5
- {{@key}}: {
6
- code: {{{code}}},
7
- config: {{{config}}}{{#if env}},
8
- env: {{{env}}}{{/if}}
9
- },
10
- {{/each}}
11
- },
12
- destinations: {
13
- {{#each destinations}}
14
- {{@key}}: {
15
- code: {{{code}}},
16
- config: {{{config}}}{{#if env}},
17
- env: {{{env}}}{{/if}}
18
- },
19
- {{/each}}
20
- }{{#if collector}},
21
- ...{{{collector}}}{{/if}}
22
- };
23
-
24
- {{{CODE}}}
25
-
26
- const result = await startFlow(config);
27
-
28
- return result;
29
- }
package/templates/web.hbs DELETED
@@ -1,45 +0,0 @@
1
- (async () => {
2
- // Check if we're in a browser environment
3
- const window = typeof globalThis.window !== 'undefined' ? globalThis.window : undefined;
4
- const document = typeof globalThis.document !== 'undefined' ? globalThis.document : undefined;
5
-
6
- const config = {
7
- sources: {
8
- {{#each sources}}
9
- {{@key}}: {
10
- code: {{{code}}},
11
- config: {{{config}}}{{#unless config}}{}{{/unless}}{{#if env}},
12
- env: {
13
- window,
14
- document,
15
- ...{{{env}}}
16
- }{{/if}}
17
- }{{#unless @last}},{{/unless}}
18
- {{/each}}
19
- },
20
- destinations: {
21
- {{#each destinations}}
22
- {{@key}}: {
23
- code: {{{code}}},
24
- config: {{{config}}}{{#unless config}}{}{{/unless}}{{#if env}},
25
- env: {
26
- window,
27
- document,
28
- ...{{{env}}}
29
- }{{/if}}
30
- }{{#unless @last}},{{/unless}}
31
- {{/each}}
32
- }{{#if collector}},
33
- ...{{{collector}}}{{/if}}
34
- };
35
-
36
- {{{CODE}}}
37
-
38
- const { collector, elb } = await startFlow(config);
39
-
40
- if (typeof window !== 'undefined') {
41
- {{#if build.windowCollector}}window['{{build.windowCollector}}'] = collector;
42
- {{/if}}{{#if build.windowElb}}window['{{build.windowElb}}'] = elb;
43
- {{/if}}
44
- }
45
- })();