@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.
- package/CHANGELOG.md +45 -0
- package/README.md +285 -0
- package/dist/__tests__/bundle/bundler-integration.test.d.ts +2 -0
- package/dist/__tests__/bundle/bundler-integration.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bundler-integration.test.js +106 -0
- package/dist/__tests__/bundle/bundler-integration.test.js.map +1 -0
- package/dist/__tests__/bundle/bundler.test.d.ts +2 -0
- package/dist/__tests__/bundle/bundler.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/bundler.test.js +281 -0
- package/dist/__tests__/bundle/bundler.test.js.map +1 -0
- package/dist/__tests__/bundle/programmatic.test.d.ts +2 -0
- package/dist/__tests__/bundle/programmatic.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/programmatic.test.js +118 -0
- package/dist/__tests__/bundle/programmatic.test.js.map +1 -0
- package/dist/__tests__/bundle/serializer.test.d.ts +2 -0
- package/dist/__tests__/bundle/serializer.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/serializer.test.js +173 -0
- package/dist/__tests__/bundle/serializer.test.js.map +1 -0
- package/dist/__tests__/bundle/template-engine.test.d.ts +2 -0
- package/dist/__tests__/bundle/template-engine.test.d.ts.map +1 -0
- package/dist/__tests__/bundle/template-engine.test.js +107 -0
- package/dist/__tests__/bundle/template-engine.test.js.map +1 -0
- package/dist/__tests__/cli-e2e.test.d.ts +8 -0
- package/dist/__tests__/cli-e2e.test.d.ts.map +1 -0
- package/dist/__tests__/cli-e2e.test.js +144 -0
- package/dist/__tests__/cli-e2e.test.js.map +1 -0
- package/dist/__tests__/cli.test.d.ts +2 -0
- package/dist/__tests__/cli.test.d.ts.map +1 -0
- package/dist/__tests__/cli.test.js +255 -0
- package/dist/__tests__/cli.test.js.map +1 -0
- package/dist/__tests__/config-loader.test.d.ts +7 -0
- package/dist/__tests__/config-loader.test.d.ts.map +1 -0
- package/dist/__tests__/config-loader.test.js +393 -0
- package/dist/__tests__/config-loader.test.js.map +1 -0
- package/dist/__tests__/core/config.test.d.ts +2 -0
- package/dist/__tests__/core/config.test.d.ts.map +1 -0
- package/dist/__tests__/core/config.test.js +72 -0
- package/dist/__tests__/core/config.test.js.map +1 -0
- package/dist/__tests__/core/logger.test.d.ts +2 -0
- package/dist/__tests__/core/logger.test.d.ts.map +1 -0
- package/dist/__tests__/core/logger.test.js +53 -0
- package/dist/__tests__/core/logger.test.js.map +1 -0
- package/dist/__tests__/simulate/programmatic.test.d.ts +2 -0
- package/dist/__tests__/simulate/programmatic.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/programmatic.test.js +51 -0
- package/dist/__tests__/simulate/programmatic.test.js.map +1 -0
- package/dist/__tests__/simulate/simulator.test.d.ts +2 -0
- package/dist/__tests__/simulate/simulator.test.d.ts.map +1 -0
- package/dist/__tests__/simulate/simulator.test.js +29 -0
- package/dist/__tests__/simulate/simulator.test.js.map +1 -0
- package/dist/commands/bundle/bundler.d.ts +14 -0
- package/dist/commands/bundle/bundler.d.ts.map +1 -0
- package/dist/commands/bundle/bundler.js +372 -0
- package/dist/commands/bundle/bundler.js.map +1 -0
- package/dist/commands/bundle/index.d.ts +51 -0
- package/dist/commands/bundle/index.d.ts.map +1 -0
- package/dist/commands/bundle/index.js +200 -0
- package/dist/commands/bundle/index.js.map +1 -0
- package/dist/commands/bundle/package-manager.d.ts +7 -0
- package/dist/commands/bundle/package-manager.d.ts.map +1 -0
- package/dist/commands/bundle/package-manager.js +170 -0
- package/dist/commands/bundle/package-manager.js.map +1 -0
- package/dist/commands/bundle/serializer.d.ts +23 -0
- package/dist/commands/bundle/serializer.d.ts.map +1 -0
- package/dist/commands/bundle/serializer.js +127 -0
- package/dist/commands/bundle/serializer.js.map +1 -0
- package/dist/commands/bundle/stats.d.ts +23 -0
- package/dist/commands/bundle/stats.d.ts.map +1 -0
- package/dist/commands/bundle/stats.js +52 -0
- package/dist/commands/bundle/stats.js.map +1 -0
- package/dist/commands/bundle/template-engine.d.ts +18 -0
- package/dist/commands/bundle/template-engine.d.ts.map +1 -0
- package/dist/commands/bundle/template-engine.js +49 -0
- package/dist/commands/bundle/template-engine.js.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts +8 -0
- package/dist/commands/run/__tests__/run.integration.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/run.integration.test.js +53 -0
- package/dist/commands/run/__tests__/run.integration.test.js.map +1 -0
- package/dist/commands/run/__tests__/validators.test.d.ts +2 -0
- package/dist/commands/run/__tests__/validators.test.d.ts.map +1 -0
- package/dist/commands/run/__tests__/validators.test.js +80 -0
- package/dist/commands/run/__tests__/validators.test.js.map +1 -0
- package/dist/commands/run/index.d.ts +39 -0
- package/dist/commands/run/index.d.ts.map +1 -0
- package/dist/commands/run/index.js +251 -0
- package/dist/commands/run/index.js.map +1 -0
- package/dist/commands/run/types.d.ts +56 -0
- package/dist/commands/run/types.d.ts.map +1 -0
- package/dist/commands/run/types.js +7 -0
- package/dist/commands/run/types.js.map +1 -0
- package/dist/commands/run/validators.d.ts +29 -0
- package/dist/commands/run/validators.d.ts.map +1 -0
- package/dist/commands/run/validators.js +54 -0
- package/dist/commands/run/validators.js.map +1 -0
- package/dist/commands/simulate/index.d.ts +47 -0
- package/dist/commands/simulate/index.d.ts.map +1 -0
- package/dist/commands/simulate/index.js +121 -0
- package/dist/commands/simulate/index.js.map +1 -0
- package/dist/commands/simulate/simulator.d.ts +18 -0
- package/dist/commands/simulate/simulator.d.ts.map +1 -0
- package/dist/commands/simulate/simulator.js +236 -0
- package/dist/commands/simulate/simulator.js.map +1 -0
- package/dist/commands/simulate/tracker.d.ts +30 -0
- package/dist/commands/simulate/tracker.d.ts.map +1 -0
- package/dist/commands/simulate/tracker.js +96 -0
- package/dist/commands/simulate/tracker.js.map +1 -0
- package/dist/commands/simulate/types.d.ts +18 -0
- package/dist/commands/simulate/types.d.ts.map +1 -0
- package/dist/commands/simulate/types.js +2 -0
- package/dist/commands/simulate/types.js.map +1 -0
- package/dist/config/defaults.d.ts +33 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +73 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +14 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +16 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +74 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +136 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/parser.d.ts +64 -0
- package/dist/config/parser.d.ts.map +1 -0
- package/dist/config/parser.js +137 -0
- package/dist/config/parser.js.map +1 -0
- package/dist/config/utils.d.ts +38 -0
- package/dist/config/utils.d.ts.map +1 -0
- package/dist/config/utils.js +66 -0
- package/dist/config/utils.js.map +1 -0
- package/dist/config/validators.d.ts +23 -0
- package/dist/config/validators.d.ts.map +1 -0
- package/dist/config/validators.js +45 -0
- package/dist/config/validators.js.map +1 -0
- package/dist/core/docker.d.ts +42 -0
- package/dist/core/docker.d.ts.map +1 -0
- package/dist/core/docker.js +114 -0
- package/dist/core/docker.js.map +1 -0
- package/dist/core/execution.d.ts +33 -0
- package/dist/core/execution.d.ts.map +1 -0
- package/dist/core/execution.js +57 -0
- package/dist/core/execution.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/logger.d.ts +17 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +74 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/output.d.ts +30 -0
- package/dist/core/output.d.ts.map +1 -0
- package/dist/core/output.js +46 -0
- package/dist/core/output.js.map +1 -0
- package/dist/core/timer.d.ts +14 -0
- package/dist/core/timer.d.ts.map +1 -0
- package/dist/core/timer.js +29 -0
- package/dist/core/timer.js.map +1 -0
- package/dist/index.d.ts +614 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1940 -0
- package/dist/index.js.map +1 -0
- package/dist/types/bundle.d.ts +251 -0
- package/dist/types/bundle.d.ts.map +1 -0
- package/dist/types/bundle.js +10 -0
- package/dist/types/bundle.js.map +1 -0
- package/dist/types/global.d.ts +51 -0
- package/dist/types/global.d.ts.map +1 -0
- package/dist/types/global.js +30 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/template.d.ts +108 -0
- package/dist/types/template.d.ts.map +1 -0
- package/dist/types/template.js +10 -0
- package/dist/types/template.js.map +1 -0
- package/package.json +59 -0
- package/templates/base.hbs +44 -0
- package/templates/server.hbs +29 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SourceDestinationItem } from '../../types/template';
|
|
2
|
+
export declare class TemplateEngine {
|
|
3
|
+
private handlebars;
|
|
4
|
+
constructor();
|
|
5
|
+
/**
|
|
6
|
+
* Load template content from file path
|
|
7
|
+
*/
|
|
8
|
+
loadTemplate(templatePath: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Apply template with user code and variable substitution
|
|
11
|
+
*/
|
|
12
|
+
applyTemplate(template: string, userCode: string, sources: Record<string, SourceDestinationItem>, destinations: Record<string, SourceDestinationItem>, collector: Record<string, unknown>, build?: Record<string, unknown>): string;
|
|
13
|
+
/**
|
|
14
|
+
* Process template with user code
|
|
15
|
+
*/
|
|
16
|
+
process(templatePath: string, userCode: string, sources: Record<string, SourceDestinationItem>, destinations: Record<string, SourceDestinationItem>, collector: Record<string, unknown>, build?: Record<string, unknown>): Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=template-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template-engine.d.ts","sourceRoot":"","sources":["../../../src/commands/bundle/template-engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlE,qBAAa,cAAc;IACzB,OAAO,CAAC,UAAU,CAAoB;;IAOtC;;OAEG;IACG,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAUzD;;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"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import Handlebars from 'handlebars';
|
|
4
|
+
import { processTemplateVariables } from './serializer';
|
|
5
|
+
export class TemplateEngine {
|
|
6
|
+
handlebars;
|
|
7
|
+
constructor() {
|
|
8
|
+
// Create a new Handlebars instance
|
|
9
|
+
this.handlebars = Handlebars.create();
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Load template content from file path
|
|
13
|
+
*/
|
|
14
|
+
async loadTemplate(templatePath) {
|
|
15
|
+
const resolvedPath = path.resolve(templatePath);
|
|
16
|
+
if (!(await fs.pathExists(resolvedPath))) {
|
|
17
|
+
throw new Error(`Template file not found: ${resolvedPath}`);
|
|
18
|
+
}
|
|
19
|
+
return await fs.readFile(resolvedPath, 'utf-8');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Apply template with user code and variable substitution
|
|
23
|
+
*/
|
|
24
|
+
applyTemplate(template, userCode, sources, destinations, collector, build) {
|
|
25
|
+
// Process template variables to serialize config objects
|
|
26
|
+
const processedVariables = processTemplateVariables({
|
|
27
|
+
sources,
|
|
28
|
+
destinations,
|
|
29
|
+
collector,
|
|
30
|
+
});
|
|
31
|
+
// Prepare template data for Handlebars
|
|
32
|
+
const templateData = {
|
|
33
|
+
CODE: userCode,
|
|
34
|
+
build: build || {},
|
|
35
|
+
...processedVariables,
|
|
36
|
+
};
|
|
37
|
+
// Compile and execute the template
|
|
38
|
+
const compiledTemplate = this.handlebars.compile(template);
|
|
39
|
+
return compiledTemplate(templateData);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Process template with user code
|
|
43
|
+
*/
|
|
44
|
+
async process(templatePath, userCode, sources, destinations, collector, build) {
|
|
45
|
+
const template = await this.loadTemplate(templatePath);
|
|
46
|
+
return this.applyTemplate(template, userCode, sources, destinations, collector, build);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=template-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,OAAO,cAAc;IACjB,UAAU,CAAoB;IAEtC;QACE,mCAAmC;QACnC,I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C;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.integration.test.d.ts","sourceRoot":"","sources":["../../../../src/commands/run/__tests__/run.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Integration Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests the CLI run command that imports @walkeros/docker as a library
|
|
5
|
+
* No Docker daemon required - runs directly in Node.js process
|
|
6
|
+
*/
|
|
7
|
+
import { runCommand } from '../index';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
10
|
+
describe('Run Command Integration', () => {
|
|
11
|
+
const projectRoot = process.cwd();
|
|
12
|
+
describe('runCommand() programmatic API', () => {
|
|
13
|
+
it('should export runCommand function', () => {
|
|
14
|
+
expect(runCommand).toBeDefined();
|
|
15
|
+
expect(typeof runCommand).toBe('function');
|
|
16
|
+
});
|
|
17
|
+
it('should accept pre-built bundle files', () => {
|
|
18
|
+
// Use the pre-built server-collect.mjs bundle
|
|
19
|
+
const bundlePath = join(projectRoot, 'examples/server-collect.mjs');
|
|
20
|
+
// Verify the bundle exists
|
|
21
|
+
expect(existsSync(bundlePath)).toBe(true);
|
|
22
|
+
// Verify it's a valid JavaScript/ESM file
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const content = fs.readFileSync(bundlePath, 'utf8');
|
|
25
|
+
expect(content).toContain('export');
|
|
26
|
+
expect(content).toContain('default');
|
|
27
|
+
});
|
|
28
|
+
it('should validate JSON config structure', async () => {
|
|
29
|
+
// Use the server-collect.json config
|
|
30
|
+
const configPath = join(projectRoot, 'examples/server-collect.json');
|
|
31
|
+
// Verify the config exists and is valid JSON
|
|
32
|
+
expect(existsSync(configPath)).toBe(true);
|
|
33
|
+
const config = require(configPath);
|
|
34
|
+
expect(config.flow).toBeDefined();
|
|
35
|
+
expect(config.build).toBeDefined();
|
|
36
|
+
expect(config.flow.platform).toBe('server');
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('Integration with @walkeros/docker', () => {
|
|
40
|
+
it('should be able to import Docker package', async () => {
|
|
41
|
+
// Verify the dependency is available
|
|
42
|
+
const dockerModule = await import('@walkeros/docker');
|
|
43
|
+
expect(dockerModule.runFlow).toBeDefined();
|
|
44
|
+
expect(dockerModule.runServeMode).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
it('should have correct types from Docker package', () => {
|
|
47
|
+
// TypeScript compilation ensures this works
|
|
48
|
+
// If this test runs, types are correctly exported
|
|
49
|
+
expect(true).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=run.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.integration.test.js","sourceRoot":"","sources":["../../../../src/commands/run/__tests__/run.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAElC,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC;YACjC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,8CAA8C;YAC9C,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;Y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Y,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QAClD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;YACvD,4CAA4C;YAC5C,kDAAkD;YAClD,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.test.d.ts","sourceRoot":"","sources":["../../../../src/commands/run/__tests__/validators.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { describe, it, expect } from '@jest/globals';
|
|
2
|
+
import { mkdirSync, writeFileSync, rmSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { validateMode, validateFlowFile, validatePort } from '../validators';
|
|
5
|
+
describe('validators', () => {
|
|
6
|
+
describe('validateMode', () => {
|
|
7
|
+
it('should accept valid modes', () => {
|
|
8
|
+
expect(() => validateMode('collect')).not.toThrow();
|
|
9
|
+
expect(() => validateMode('serve')).not.toThrow();
|
|
10
|
+
});
|
|
11
|
+
it('should reject invalid modes', () => {
|
|
12
|
+
expect(() => validateMode('invalid')).toThrow(/Invalid mode/);
|
|
13
|
+
expect(() => validateMode('bundle')).toThrow(/Invalid mode/);
|
|
14
|
+
expect(() => validateMode('COLLECT')).toThrow(/Invalid mode/);
|
|
15
|
+
expect(() => validateMode('')).toThrow(/Invalid mode/);
|
|
16
|
+
});
|
|
17
|
+
it('should provide helpful error message', () => {
|
|
18
|
+
expect(() => validateMode('invalid')).toThrow(/Valid modes: collect, serve/);
|
|
19
|
+
expect(() => validateMode('invalid')).toThrow(/Example:/);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('validateFlowFile', () => {
|
|
23
|
+
const testDir = join(process.cwd(), '.test-tmp-validators');
|
|
24
|
+
const testFile = join(testDir, 'test-flow.json');
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
// Create test directory and file
|
|
27
|
+
mkdirSync(testDir, { recursive: true });
|
|
28
|
+
writeFileSync(testFile, '{}');
|
|
29
|
+
});
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
// Cleanup
|
|
32
|
+
rmSync(testDir, { recursive: true, force: true });
|
|
33
|
+
});
|
|
34
|
+
it('should accept existing file', () => {
|
|
35
|
+
const result = validateFlowFile(testFile);
|
|
36
|
+
expect(result).toBe(testFile);
|
|
37
|
+
});
|
|
38
|
+
it('should accept relative path', () => {
|
|
39
|
+
const relativePath = '.test-tmp-validators/test-flow.json';
|
|
40
|
+
const result = validateFlowFile(relativePath);
|
|
41
|
+
expect(result).toContain('test-flow.json');
|
|
42
|
+
expect(result).not.toBe(relativePath); // Should be absolute
|
|
43
|
+
});
|
|
44
|
+
it('should return absolute path', () => {
|
|
45
|
+
const result = validateFlowFile(testFile);
|
|
46
|
+
expect(result).toMatch(/^[/\\]/); // Starts with / or \
|
|
47
|
+
});
|
|
48
|
+
it('should reject non-existent file', () => {
|
|
49
|
+
expect(() => validateFlowFile('./missing.json')).toThrow(/Flow file not found/);
|
|
50
|
+
});
|
|
51
|
+
it('should provide helpful error message', () => {
|
|
52
|
+
expect(() => validateFlowFile('./missing.json')).toThrow(/Resolved path:/);
|
|
53
|
+
expect(() => validateFlowFile('./missing.json')).toThrow(/Make sure the file exists/);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe('validatePort', () => {
|
|
57
|
+
it('should accept valid ports', () => {
|
|
58
|
+
expect(() => validatePort(1)).not.toThrow();
|
|
59
|
+
expect(() => validatePort(80)).not.toThrow();
|
|
60
|
+
expect(() => validatePort(8080)).not.toThrow();
|
|
61
|
+
expect(() => validatePort(65535)).not.toThrow();
|
|
62
|
+
});
|
|
63
|
+
it('should reject invalid ports', () => {
|
|
64
|
+
expect(() => validatePort(0)).toThrow(/Invalid port/);
|
|
65
|
+
expect(() => validatePort(-1)).toThrow(/Invalid port/);
|
|
66
|
+
expect(() => validatePort(65536)).toThrow(/Invalid port/);
|
|
67
|
+
expect(() => validatePort(99999)).toThrow(/Invalid port/);
|
|
68
|
+
});
|
|
69
|
+
it('should reject non-integer ports', () => {
|
|
70
|
+
expect(() => validatePort(8080.5)).toThrow(/Invalid port/);
|
|
71
|
+
expect(() => validatePort(NaN)).toThrow(/Invalid port/);
|
|
72
|
+
expect(() => validatePort(Infinity)).toThrow(/Invalid port/);
|
|
73
|
+
});
|
|
74
|
+
it('should provide helpful error message', () => {
|
|
75
|
+
expect(() => validatePort(99999)).toThrow(/between 1 and 65535/);
|
|
76
|
+
expect(() => validatePort(99999)).toThrow(/Example: --port 8080/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=validators.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validators.test.js","sourceRoot":"","sources":["../../../../src/commands/run/__tests__/validators.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7E,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;YACnC,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACpD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC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,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACxD,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;YAC9C,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YACjE,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs walkerOS flows using @walkeros/docker as a library
|
|
5
|
+
* No Docker daemon required - runs directly in Node.js
|
|
6
|
+
*/
|
|
7
|
+
import type { RunMode, RunCommandOptions, RunOptions, RunResult } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* CLI command function for `walkeros run`
|
|
10
|
+
*
|
|
11
|
+
* @param mode - Run mode (collect | serve)
|
|
12
|
+
* @param options - Command options
|
|
13
|
+
*/
|
|
14
|
+
export declare function runCommand(mode: string, options: RunCommandOptions): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Programmatic run function
|
|
17
|
+
*
|
|
18
|
+
* @param mode - Run mode (collect | serve)
|
|
19
|
+
* @param options - Run options
|
|
20
|
+
* @returns Run result
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Run with JSON config (bundles automatically)
|
|
25
|
+
* await run('collect', {
|
|
26
|
+
* config: './flow.json',
|
|
27
|
+
* port: 8080
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Run with pre-built bundle
|
|
31
|
+
* await run('collect', {
|
|
32
|
+
* config: './flow.mjs',
|
|
33
|
+
* port: 8080
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function run(mode: RunMode, options: RunOptions): Promise<RunResult>;
|
|
38
|
+
export type { RunMode, RunCommandOptions, RunOptions, RunResult };
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/run/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAcH,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,SAAS,EACV,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAoJf;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,GAAG,CACvB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,SAAS,CAAC,CAwGpB;AAGD,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command
|
|
3
|
+
*
|
|
4
|
+
* Runs walkerOS flows using @walkeros/docker as a library
|
|
5
|
+
* No Docker daemon required - runs directly in Node.js
|
|
6
|
+
*/
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import os from 'os';
|
|
9
|
+
import { runFlow, runServeMode, } from '@walkeros/docker';
|
|
10
|
+
import { bundle } from '../bundle';
|
|
11
|
+
import { createLogger, createTimer, executeCommand } from '../../core';
|
|
12
|
+
import { loadJsonConfig } from '../../config';
|
|
13
|
+
import { validateMode, validateFlowFile, validatePort } from './validators';
|
|
14
|
+
/**
|
|
15
|
+
* CLI command function for `walkeros run`
|
|
16
|
+
*
|
|
17
|
+
* @param mode - Run mode (collect | serve)
|
|
18
|
+
* @param options - Command options
|
|
19
|
+
*/
|
|
20
|
+
export async function runCommand(mode, options) {
|
|
21
|
+
const timer = createTimer();
|
|
22
|
+
timer.start();
|
|
23
|
+
const logger = createLogger({
|
|
24
|
+
verbose: options.verbose,
|
|
25
|
+
silent: options.silent ?? false,
|
|
26
|
+
json: options.json,
|
|
27
|
+
});
|
|
28
|
+
// Build Docker args
|
|
29
|
+
const dockerArgs = [mode, options.config];
|
|
30
|
+
if (options.port !== undefined)
|
|
31
|
+
dockerArgs.push('--port', String(options.port));
|
|
32
|
+
if (options.host)
|
|
33
|
+
dockerArgs.push('--host', options.host);
|
|
34
|
+
if (options.staticDir)
|
|
35
|
+
dockerArgs.push('--static-dir', options.staticDir);
|
|
36
|
+
if (options.json)
|
|
37
|
+
dockerArgs.push('--json');
|
|
38
|
+
if (options.verbose)
|
|
39
|
+
dockerArgs.push('--verbose');
|
|
40
|
+
if (options.silent)
|
|
41
|
+
dockerArgs.push('--silent');
|
|
42
|
+
await executeCommand(async () => {
|
|
43
|
+
try {
|
|
44
|
+
// Step 1: Validate inputs
|
|
45
|
+
validateMode(mode);
|
|
46
|
+
const configPath = validateFlowFile(options.config);
|
|
47
|
+
if (options.port !== undefined) {
|
|
48
|
+
validatePort(options.port);
|
|
49
|
+
}
|
|
50
|
+
// Step 2: Determine if config is pre-built or needs bundling
|
|
51
|
+
const isPreBuilt = configPath.endsWith('.mjs') ||
|
|
52
|
+
configPath.endsWith('.js') ||
|
|
53
|
+
configPath.endsWith('.cjs');
|
|
54
|
+
let flowPath;
|
|
55
|
+
if (isPreBuilt) {
|
|
56
|
+
// Use pre-built bundle directly
|
|
57
|
+
flowPath = path.resolve(configPath);
|
|
58
|
+
if (!options.json) {
|
|
59
|
+
logger.info(`📦 Using pre-built flow: ${path.basename(flowPath)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// Bundle JSON config first
|
|
64
|
+
if (!options.json) {
|
|
65
|
+
logger.info('🔨 Building flow bundle...');
|
|
66
|
+
}
|
|
67
|
+
// Read config and modify output path
|
|
68
|
+
const rawConfig = await loadJsonConfig(configPath);
|
|
69
|
+
const tempPath = path.join(os.tmpdir(), `walkeros-${Date.now()}-${Math.random().toString(36).slice(2, 9)}.mjs`);
|
|
70
|
+
// Ensure config has build.output set to temp path
|
|
71
|
+
const existingBuild = typeof rawConfig === 'object' &&
|
|
72
|
+
rawConfig !== null &&
|
|
73
|
+
'build' in rawConfig &&
|
|
74
|
+
typeof rawConfig.build === 'object'
|
|
75
|
+
? rawConfig.build
|
|
76
|
+
: {};
|
|
77
|
+
const configWithOutput = {
|
|
78
|
+
...rawConfig,
|
|
79
|
+
build: {
|
|
80
|
+
...existingBuild,
|
|
81
|
+
output: tempPath,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
await bundle(configWithOutput, {
|
|
85
|
+
cache: true,
|
|
86
|
+
verbose: options.verbose,
|
|
87
|
+
silent: options.json,
|
|
88
|
+
});
|
|
89
|
+
flowPath = tempPath;
|
|
90
|
+
if (!options.json) {
|
|
91
|
+
logger.success('✅ Bundle ready');
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Step 3: Run the flow using Docker package
|
|
95
|
+
if (!options.json) {
|
|
96
|
+
const modeLabel = mode === 'collect' ? 'Collector' : 'Server';
|
|
97
|
+
logger.info(`🚀 Starting ${modeLabel}...`);
|
|
98
|
+
}
|
|
99
|
+
switch (mode) {
|
|
100
|
+
case 'collect': {
|
|
101
|
+
const config = {
|
|
102
|
+
port: options.port,
|
|
103
|
+
host: options.host,
|
|
104
|
+
};
|
|
105
|
+
await runFlow(flowPath, config);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'serve': {
|
|
109
|
+
const config = {
|
|
110
|
+
port: options.port,
|
|
111
|
+
host: options.host,
|
|
112
|
+
staticDir: options.staticDir,
|
|
113
|
+
};
|
|
114
|
+
await runServeMode(config);
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
default:
|
|
118
|
+
throw new Error(`Unknown mode: ${mode}`);
|
|
119
|
+
}
|
|
120
|
+
// Note: runFlow runs forever, so we won't reach here unless it fails
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
const duration = timer.getElapsed() / 1000;
|
|
124
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
125
|
+
if (options.json) {
|
|
126
|
+
const output = {
|
|
127
|
+
success: false,
|
|
128
|
+
mode,
|
|
129
|
+
error: errorMessage,
|
|
130
|
+
duration,
|
|
131
|
+
};
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
133
|
+
console.log(JSON.stringify(output, null, 2));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
logger.error('❌ Run failed:');
|
|
137
|
+
logger.error(errorMessage);
|
|
138
|
+
}
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
}, 'run', dockerArgs, options, logger);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Programmatic run function
|
|
145
|
+
*
|
|
146
|
+
* @param mode - Run mode (collect | serve)
|
|
147
|
+
* @param options - Run options
|
|
148
|
+
* @returns Run result
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Run with JSON config (bundles automatically)
|
|
153
|
+
* await run('collect', {
|
|
154
|
+
* config: './flow.json',
|
|
155
|
+
* port: 8080
|
|
156
|
+
* });
|
|
157
|
+
*
|
|
158
|
+
* // Run with pre-built bundle
|
|
159
|
+
* await run('collect', {
|
|
160
|
+
* config: './flow.mjs',
|
|
161
|
+
* port: 8080
|
|
162
|
+
* });
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export async function run(mode, options) {
|
|
166
|
+
const startTime = Date.now();
|
|
167
|
+
try {
|
|
168
|
+
// Validate inputs
|
|
169
|
+
validateMode(mode);
|
|
170
|
+
let flowFile;
|
|
171
|
+
if (typeof options.config === 'string') {
|
|
172
|
+
flowFile = validateFlowFile(options.config);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
throw new Error('Programmatic run() requires config file path');
|
|
176
|
+
}
|
|
177
|
+
if (options.port !== undefined) {
|
|
178
|
+
validatePort(options.port);
|
|
179
|
+
}
|
|
180
|
+
// Determine if config is pre-built or needs bundling
|
|
181
|
+
const isPreBuilt = flowFile.endsWith('.mjs') ||
|
|
182
|
+
flowFile.endsWith('.js') ||
|
|
183
|
+
flowFile.endsWith('.cjs');
|
|
184
|
+
let flowPath;
|
|
185
|
+
if (isPreBuilt) {
|
|
186
|
+
flowPath = path.resolve(flowFile);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
// Bundle JSON config
|
|
190
|
+
const rawConfig = await loadJsonConfig(flowFile);
|
|
191
|
+
const tempPath = path.join(os.tmpdir(), `walkeros-${Date.now()}-${Math.random().toString(36).slice(2, 9)}.mjs`);
|
|
192
|
+
// Ensure config has build.output set to temp path
|
|
193
|
+
const existingBuild = typeof rawConfig === 'object' &&
|
|
194
|
+
rawConfig !== null &&
|
|
195
|
+
'build' in rawConfig &&
|
|
196
|
+
typeof rawConfig.build === 'object'
|
|
197
|
+
? rawConfig.build
|
|
198
|
+
: {};
|
|
199
|
+
const configWithOutput = {
|
|
200
|
+
...rawConfig,
|
|
201
|
+
build: {
|
|
202
|
+
...existingBuild,
|
|
203
|
+
output: tempPath,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
await bundle(configWithOutput, {
|
|
207
|
+
cache: true,
|
|
208
|
+
verbose: options.verbose,
|
|
209
|
+
silent: true,
|
|
210
|
+
});
|
|
211
|
+
flowPath = tempPath;
|
|
212
|
+
}
|
|
213
|
+
// Run the flow using Docker package
|
|
214
|
+
switch (mode) {
|
|
215
|
+
case 'collect': {
|
|
216
|
+
const config = {
|
|
217
|
+
port: options.port,
|
|
218
|
+
host: options.host,
|
|
219
|
+
};
|
|
220
|
+
await runFlow(flowPath, config);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
case 'serve': {
|
|
224
|
+
const config = {
|
|
225
|
+
port: options.port,
|
|
226
|
+
host: options.host,
|
|
227
|
+
staticDir: options.staticDir,
|
|
228
|
+
};
|
|
229
|
+
await runServeMode(config);
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
default:
|
|
233
|
+
throw new Error(`Unknown mode: ${mode}`);
|
|
234
|
+
}
|
|
235
|
+
// Success (though runFlow runs forever, so we typically don't reach here)
|
|
236
|
+
return {
|
|
237
|
+
success: true,
|
|
238
|
+
exitCode: 0,
|
|
239
|
+
duration: Date.now() - startTime,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
return {
|
|
244
|
+
success: false,
|
|
245
|
+
exitCode: 1,
|
|
246
|
+
duration: Date.now() - startTime,
|
|
247
|
+
error: error instanceof Error ? error.message : String(error),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/run/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EACL,OAAO,EACP,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,Y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,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAC9D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Command Types
|
|
3
|
+
*
|
|
4
|
+
* Types for running walkerOS flows via CLI using @walkeros/docker as a library
|
|
5
|
+
*/
|
|
6
|
+
import type { GlobalOptions } from '../../types';
|
|
7
|
+
/**
|
|
8
|
+
* Run mode - determines which execution mode to use
|
|
9
|
+
*/
|
|
10
|
+
export type RunMode = 'collect' | 'serve';
|
|
11
|
+
/**
|
|
12
|
+
* CLI command options for `walkeros run`
|
|
13
|
+
*/
|
|
14
|
+
export interface RunCommandOptions extends GlobalOptions {
|
|
15
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
16
|
+
config: string;
|
|
17
|
+
/** Server port (overrides flow config) */
|
|
18
|
+
port?: number;
|
|
19
|
+
/** Server host (default: 0.0.0.0) */
|
|
20
|
+
host?: string;
|
|
21
|
+
/** Static directory for serve mode */
|
|
22
|
+
staticDir?: string;
|
|
23
|
+
/** Enable JSON output */
|
|
24
|
+
json?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Programmatic run options (subset of CLI options)
|
|
28
|
+
*/
|
|
29
|
+
export interface RunOptions {
|
|
30
|
+
/** Flow configuration file path (.json or pre-built .mjs) */
|
|
31
|
+
config: string | unknown;
|
|
32
|
+
/** Server port */
|
|
33
|
+
port?: number;
|
|
34
|
+
/** Server host */
|
|
35
|
+
host?: string;
|
|
36
|
+
/** Static directory for serve mode */
|
|
37
|
+
staticDir?: string;
|
|
38
|
+
/** Suppress output */
|
|
39
|
+
silent?: boolean;
|
|
40
|
+
/** Verbose logging */
|
|
41
|
+
verbose?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Result from running a flow
|
|
45
|
+
*/
|
|
46
|
+
export interface RunResult {
|
|
47
|
+
/** Whether the flow ran successfully */
|
|
48
|
+
success: boolean;
|
|
49
|
+
/** Exit code */
|
|
50
|
+
exitCode: number;
|
|
51
|
+
/** Error message if failed */
|
|
52
|
+
error?: string;
|
|
53
|
+
/** Execution duration in milliseconds */
|
|
54
|
+
duration: number;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/run/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,yBAAyB;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEzB,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,kBAAkB;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,sBAAsB;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB,sBAAsB;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;IAEjB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IAEjB,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/commands/run/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|