@cucumber/cucumber 10.6.0 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/formatters.d.ts +3 -1
- package/lib/api/formatters.js +36 -45
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/plugins.js +3 -3
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/run_cucumber.js +2 -1
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/configuration/argv_parser.js +2 -2
- package/lib/configuration/argv_parser.js.map +1 -1
- package/lib/formatter/builder.d.ts +1 -1
- package/lib/formatter/builder.js +6 -13
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/builtin/html.d.ts +6 -0
- package/lib/formatter/builtin/html.js +25 -0
- package/lib/formatter/builtin/html.js.map +1 -0
- package/lib/formatter/builtin/index.d.ts +3 -0
- package/lib/formatter/builtin/index.js +33 -0
- package/lib/formatter/builtin/index.js.map +1 -0
- package/lib/formatter/builtin/message.d.ts +6 -0
- package/lib/formatter/builtin/message.js +10 -0
- package/lib/formatter/builtin/message.js.map +1 -0
- package/lib/formatter/create_stream.d.ts +4 -0
- package/lib/formatter/create_stream.js +28 -0
- package/lib/formatter/create_stream.js.map +1 -0
- package/lib/formatter/find_class_or_plugin.d.ts +1 -0
- package/lib/formatter/find_class_or_plugin.js +25 -0
- package/lib/formatter/find_class_or_plugin.js.map +1 -0
- package/lib/formatter/helpers/formatters.d.ts +0 -1
- package/lib/formatter/helpers/formatters.js +0 -12
- package/lib/formatter/helpers/formatters.js.map +1 -1
- package/lib/formatter/import_code.d.ts +1 -0
- package/lib/formatter/import_code.js +27 -0
- package/lib/formatter/import_code.js.map +1 -0
- package/lib/formatter/index.d.ts +2 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/resolve_implementation.d.ts +2 -0
- package/lib/formatter/resolve_implementation.js +24 -0
- package/lib/formatter/resolve_implementation.js.map +1 -0
- package/lib/plugin/plugin_manager.d.ts +3 -2
- package/lib/plugin/plugin_manager.js +12 -2
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +11 -0
- package/lib/plugin/types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +1 -1
- package/lib/runtime/parallel/coordinator.js +7 -6
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +3 -2
- package/lib/formatter/html_formatter.d.ts +0 -7
- package/lib/formatter/html_formatter.js +0 -31
- package/lib/formatter/html_formatter.js.map +0 -1
- package/lib/formatter/message_formatter.d.ts +0 -5
- package/lib/formatter/message_formatter.js +0 -15
- package/lib/formatter/message_formatter.js.map +0 -1
package/lib/api/formatters.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { IFormatterStream } from '../formatter';
|
|
|
5
5
|
import { EventDataCollector } from '../formatter/helpers';
|
|
6
6
|
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
7
|
import { ILogger } from '../logger';
|
|
8
|
+
import { PluginManager } from '../plugin';
|
|
8
9
|
import { IRunOptionsFormats } from './types';
|
|
9
|
-
export declare function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }: {
|
|
10
|
+
export declare function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, pluginManager, }: {
|
|
10
11
|
env: NodeJS.ProcessEnv;
|
|
11
12
|
cwd: string;
|
|
12
13
|
stdout: IFormatterStream;
|
|
@@ -17,4 +18,5 @@ export declare function initializeFormatters({ env, cwd, stdout, logger, onStrea
|
|
|
17
18
|
eventDataCollector: EventDataCollector;
|
|
18
19
|
configuration: IRunOptionsFormats;
|
|
19
20
|
supportCodeLibrary: SupportCodeLibrary;
|
|
21
|
+
pluginManager: PluginManager;
|
|
20
22
|
}): Promise<() => Promise<void>>;
|
package/lib/api/formatters.js
CHANGED
|
@@ -5,56 +5,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.initializeFormatters = void 0;
|
|
7
7
|
const node_util_1 = require("node:util");
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const fs_1 = __importDefault(require("mz/fs"));
|
|
10
|
-
const mkdirp_1 = require("mkdirp");
|
|
11
8
|
const builder_1 = __importDefault(require("../formatter/builder"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const typeOptions = {
|
|
19
|
-
env,
|
|
20
|
-
cwd,
|
|
21
|
-
eventBroadcaster,
|
|
22
|
-
eventDataCollector,
|
|
23
|
-
log: stream.write.bind(stream),
|
|
24
|
-
parsedArgvOptions: configuration.options,
|
|
25
|
-
stream,
|
|
26
|
-
cleanup: stream === stdout
|
|
27
|
-
? async () => await Promise.resolve()
|
|
28
|
-
: (0, node_util_1.promisify)(stream.end.bind(stream)),
|
|
29
|
-
supportCodeLibrary,
|
|
30
|
-
};
|
|
31
|
-
if (type === 'progress-bar' && !stream.isTTY) {
|
|
9
|
+
const create_stream_1 = require("../formatter/create_stream");
|
|
10
|
+
const resolve_implementation_1 = require("../formatter/resolve_implementation");
|
|
11
|
+
async function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, pluginManager, }) {
|
|
12
|
+
const cleanupFns = [];
|
|
13
|
+
async function initializeFormatter(stream, target, specifier) {
|
|
14
|
+
if (specifier === 'progress-bar' && !stream.isTTY) {
|
|
32
15
|
logger.warn(`Cannot use 'progress-bar' formatter for output to '${target}' as not a TTY. Switching to 'progress' formatter.`);
|
|
33
|
-
|
|
16
|
+
specifier = 'progress';
|
|
34
17
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
18
|
+
const implementation = await (0, resolve_implementation_1.resolveImplementation)(specifier, cwd);
|
|
19
|
+
if (typeof implementation === 'function') {
|
|
20
|
+
const typeOptions = {
|
|
21
|
+
env,
|
|
22
|
+
cwd,
|
|
23
|
+
eventBroadcaster,
|
|
24
|
+
eventDataCollector,
|
|
25
|
+
log: stream.write.bind(stream),
|
|
26
|
+
parsedArgvOptions: configuration.options,
|
|
27
|
+
stream,
|
|
28
|
+
cleanup: stream === stdout
|
|
29
|
+
? async () => await Promise.resolve()
|
|
30
|
+
: (0, node_util_1.promisify)(stream.end.bind(stream)),
|
|
31
|
+
supportCodeLibrary,
|
|
32
|
+
};
|
|
33
|
+
const formatter = await builder_1.default.build(implementation, typeOptions);
|
|
34
|
+
cleanupFns.push(async () => formatter.finished());
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
await pluginManager.initFormatter(implementation, configuration.options, stream.write.bind(stream));
|
|
38
|
+
if (stream !== stdout) {
|
|
39
|
+
cleanupFns.push((0, node_util_1.promisify)(stream.end.bind(stream)));
|
|
48
40
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
await Promise.all(streamPromises);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await initializeFormatter(stdout, 'stdout', configuration.stdout);
|
|
44
|
+
for (const [target, specifier] of Object.entries(configuration.files)) {
|
|
45
|
+
await initializeFormatter(await (0, create_stream_1.createStream)(target, onStreamError, cwd, logger), target, specifier);
|
|
46
|
+
}
|
|
56
47
|
return async function () {
|
|
57
|
-
await Promise.all(
|
|
48
|
+
await Promise.all(cleanupFns.map((cleanupFn) => cleanupFn()));
|
|
58
49
|
};
|
|
59
50
|
}
|
|
60
51
|
exports.initializeFormatters = initializeFormatters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/api/formatters.ts"],"names":[],"mappings":";;;;;;AACA,yCAAqC;
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/api/formatters.ts"],"names":[],"mappings":";;;;;;AACA,yCAAqC;AAKrC,mEAAmD;AAEnD,8DAAyD;AACzD,gFAA2E;AAIpE,KAAK,UAAU,oBAAoB,CAAC,EACzC,GAAG,EACH,GAAG,EACH,MAAM,EACN,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,aAAa,GAad;IACC,MAAM,UAAU,GAA+B,EAAE,CAAA;IAEjD,KAAK,UAAU,mBAAmB,CAChC,MAAwB,EACxB,MAAc,EACd,SAAiB;QAEjB,IAAI,SAAS,KAAK,cAAc,IAAI,CAAE,MAAyB,CAAC,KAAK,EAAE;YACrE,MAAM,CAAC,IAAI,CACT,sDAAsD,MAAM,oDAAoD,CACjH,CAAA;YACD,SAAS,GAAG,UAAU,CAAA;SACvB;QACD,MAAM,cAAc,GAAG,MAAM,IAAA,8CAAqB,EAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAClE,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE;YACxC,MAAM,WAAW,GAAG;gBAClB,GAAG;gBACH,GAAG;gBACH,gBAAgB;gBAChB,kBAAkB;gBAClB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;gBAC9B,iBAAiB,EAAE,aAAa,CAAC,OAAO;gBACxC,MAAM;gBACN,OAAO,EACL,MAAM,KAAK,MAAM;oBACf,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;oBACrC,CAAC,CAAC,IAAA,qBAAS,EAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC7C,kBAAkB;aACnB,CAAA;YACD,MAAM,SAAS,GAAG,MAAM,iBAAgB,CAAC,KAAK,CAC5C,cAAc,EACd,WAAW,CACZ,CAAA;YACD,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;SAClD;aAAM;YACL,MAAM,aAAa,CAAC,aAAa,CAC/B,cAAc,EACd,aAAa,CAAC,OAAO,EACrB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAC1B,CAAA;YACD,IAAI,MAAM,KAAK,MAAM,EAAE;gBACrB,UAAU,CAAC,IAAI,CAAC,IAAA,qBAAS,EAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;aACzD;SACF;IACH,CAAC;IAED,MAAM,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACjE,KAAK,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;QACrE,MAAM,mBAAmB,CACvB,MAAM,IAAA,4BAAY,EAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,CAAC,EACtD,MAAM,EACN,SAAS,CACV,CAAA;KACF;IAED,OAAO,KAAK;QACV,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC,CAAA;IAC/D,CAAC,CAAA;AACH,CAAC;AAlFD,oDAkFC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { promisify } from 'node:util'\nimport { WriteStream as TtyWriteStream } from 'node:tty'\nimport { IFormatterStream } from '../formatter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport FormatterBuilder from '../formatter/builder'\nimport { ILogger } from '../logger'\nimport { createStream } from '../formatter/create_stream'\nimport { resolveImplementation } from '../formatter/resolve_implementation'\nimport { PluginManager } from '../plugin'\nimport { IRunOptionsFormats } from './types'\n\nexport async function initializeFormatters({\n env,\n cwd,\n stdout,\n logger,\n onStreamError,\n eventBroadcaster,\n eventDataCollector,\n configuration,\n supportCodeLibrary,\n pluginManager,\n}: {\n env: NodeJS.ProcessEnv\n cwd: string\n stdout: IFormatterStream\n stderr: IFormatterStream\n logger: ILogger\n onStreamError: () => void\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n configuration: IRunOptionsFormats\n supportCodeLibrary: SupportCodeLibrary\n pluginManager: PluginManager\n}): Promise<() => Promise<void>> {\n const cleanupFns: Array<() => Promise<void>> = []\n\n async function initializeFormatter(\n stream: IFormatterStream,\n target: string,\n specifier: string\n ): Promise<void> {\n if (specifier === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n logger.warn(\n `Cannot use 'progress-bar' formatter for output to '${target}' as not a TTY. Switching to 'progress' formatter.`\n )\n specifier = 'progress'\n }\n const implementation = await resolveImplementation(specifier, cwd)\n if (typeof implementation === 'function') {\n const typeOptions = {\n env,\n cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: configuration.options,\n stream,\n cleanup:\n stream === stdout\n ? async () => await Promise.resolve()\n : promisify<any>(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n const formatter = await FormatterBuilder.build(\n implementation,\n typeOptions\n )\n cleanupFns.push(async () => formatter.finished())\n } else {\n await pluginManager.initFormatter(\n implementation,\n configuration.options,\n stream.write.bind(stream)\n )\n if (stream !== stdout) {\n cleanupFns.push(promisify<any>(stream.end.bind(stream)))\n }\n }\n }\n\n await initializeFormatter(stdout, 'stdout', configuration.stdout)\n for (const [target, specifier] of Object.entries(configuration.files)) {\n await initializeFormatter(\n await createStream(target, onStreamError, cwd, logger),\n target,\n specifier\n )\n }\n\n return async function () {\n await Promise.all(cleanupFns.map((cleanupFn) => cleanupFn()))\n }\n}\n"]}
|
package/lib/api/plugins.js
CHANGED
|
@@ -10,7 +10,7 @@ const filter_1 = __importDefault(require("../filter"));
|
|
|
10
10
|
async function initializeForLoadSources(logger, coordinates, environment) {
|
|
11
11
|
// eventually we'll load plugin packages here
|
|
12
12
|
const pluginManager = new plugin_1.PluginManager();
|
|
13
|
-
await pluginManager.
|
|
13
|
+
await pluginManager.initCoordinator('loadSources', filter_1.default, coordinates, logger, environment);
|
|
14
14
|
return pluginManager;
|
|
15
15
|
}
|
|
16
16
|
exports.initializeForLoadSources = initializeForLoadSources;
|
|
@@ -22,8 +22,8 @@ exports.initializeForLoadSupport = initializeForLoadSupport;
|
|
|
22
22
|
async function initializeForRunCucumber(logger, configuration, environment) {
|
|
23
23
|
// eventually we'll load plugin packages here
|
|
24
24
|
const pluginManager = new plugin_1.PluginManager();
|
|
25
|
-
await pluginManager.
|
|
26
|
-
await pluginManager.
|
|
25
|
+
await pluginManager.initCoordinator('runCucumber', publish_1.default, configuration.formats.publish, logger, environment);
|
|
26
|
+
await pluginManager.initCoordinator('runCucumber', filter_1.default, configuration.sources, logger, environment);
|
|
27
27
|
return pluginManager;
|
|
28
28
|
}
|
|
29
29
|
exports.initializeForRunCucumber = initializeForRunCucumber;
|
package/lib/api/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/api/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAyC;AACzC,yDAAsC;AAEtC,uDAAoC;AAO7B,KAAK,UAAU,wBAAwB,CAC5C,MAAe,EACf,WAAgC,EAChC,WAAsC;IAEtC,6CAA6C;IAC7C,MAAM,aAAa,GAAG,IAAI,sBAAa,EAAE,CAAA;IACzC,MAAM,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/api/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAyC;AACzC,yDAAsC;AAEtC,uDAAoC;AAO7B,KAAK,UAAU,wBAAwB,CAC5C,MAAe,EACf,WAAgC,EAChC,WAAsC;IAEtC,6CAA6C;IAC7C,MAAM,aAAa,GAAG,IAAI,sBAAa,EAAE,CAAA;IACzC,MAAM,aAAa,CAAC,eAAe,CACjC,aAAa,EACb,gBAAY,EACZ,WAAW,EACX,MAAM,EACN,WAAW,CACZ,CAAA;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAfD,4DAeC;AAEM,KAAK,UAAU,wBAAwB;IAC5C,6CAA6C;IAC7C,OAAO,IAAI,sBAAa,EAAE,CAAA;AAC5B,CAAC;AAHD,4DAGC;AAEM,KAAK,UAAU,wBAAwB,CAC5C,MAAe,EACf,aAAgC,EAChC,WAAsC;IAEtC,6CAA6C;IAC7C,MAAM,aAAa,GAAG,IAAI,sBAAa,EAAE,CAAA;IACzC,MAAM,aAAa,CAAC,eAAe,CACjC,aAAa,EACb,iBAAa,EACb,aAAa,CAAC,OAAO,CAAC,OAAO,EAC7B,MAAM,EACN,WAAW,CACZ,CAAA;IACD,MAAM,aAAa,CAAC,eAAe,CACjC,aAAa,EACb,gBAAY,EACZ,aAAa,CAAC,OAAO,EACrB,MAAM,EACN,WAAW,CACZ,CAAA;IACD,OAAO,aAAa,CAAA;AACtB,CAAC;AAtBD,4DAsBC","sourcesContent":["import { PluginManager } from '../plugin'\nimport publishPlugin from '../publish'\nimport { ILogger } from '../logger'\nimport filterPlugin from '../filter'\nimport {\n IRunConfiguration,\n IRunEnvironment,\n ISourcesCoordinates,\n} from './types'\n\nexport async function initializeForLoadSources(\n logger: ILogger,\n coordinates: ISourcesCoordinates,\n environment: Required<IRunEnvironment>\n): Promise<PluginManager> {\n // eventually we'll load plugin packages here\n const pluginManager = new PluginManager()\n await pluginManager.initCoordinator(\n 'loadSources',\n filterPlugin,\n coordinates,\n logger,\n environment\n )\n return pluginManager\n}\n\nexport async function initializeForLoadSupport(): Promise<PluginManager> {\n // eventually we'll load plugin packages here\n return new PluginManager()\n}\n\nexport async function initializeForRunCucumber(\n logger: ILogger,\n configuration: IRunConfiguration,\n environment: Required<IRunEnvironment>\n): Promise<PluginManager> {\n // eventually we'll load plugin packages here\n const pluginManager = new PluginManager()\n await pluginManager.initCoordinator(\n 'runCucumber',\n publishPlugin,\n configuration.formats.publish,\n logger,\n environment\n )\n await pluginManager.initCoordinator(\n 'runCucumber',\n filterPlugin,\n configuration.sources,\n logger,\n environment\n )\n return pluginManager\n}\n"]}
|
package/lib/api/run_cucumber.js
CHANGED
|
@@ -68,6 +68,7 @@ async function runCucumber(options, environment = {}, onMessage) {
|
|
|
68
68
|
eventDataCollector,
|
|
69
69
|
configuration: options.formats,
|
|
70
70
|
supportCodeLibrary,
|
|
71
|
+
pluginManager,
|
|
71
72
|
});
|
|
72
73
|
await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
|
|
73
74
|
let pickleIds = [];
|
|
@@ -112,8 +113,8 @@ async function runCucumber(options, environment = {}, onMessage) {
|
|
|
112
113
|
options: options.runtime,
|
|
113
114
|
});
|
|
114
115
|
const success = await runtime.start();
|
|
115
|
-
await cleanupFormatters();
|
|
116
116
|
await pluginManager.cleanup();
|
|
117
|
+
await cleanupFormatters();
|
|
117
118
|
return {
|
|
118
119
|
success: success && !formatterStreamError,
|
|
119
120
|
support: supportCodeLibrary,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAC1C,iDAAsE;AACtE,kDAAyD;AACzD,4CAAyE;AACzE,oCAAuC;AAGvC,uCAAuC;AACvC,6CAAmD;AACnD,uCAAiD;AACjD,+CAAgD;AAChD,uCAA+C;AAC/C,uCAAoD;AAEpD;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAC/B,OAAoB,EACpB,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,iBAAiB,GAAG,IAAA,8BAAgB,EAAC,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CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,iBAAiB,EAAE,CAAA;QACzB,MAAM,aAAa,CAAC,OAAO,EAAE,CAAA;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC5B,CAAA;KACF;IAED,IAAA,iCAAuB,EAAC;QACtB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACN,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,GAAG;QACH,MAAM;QACN,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;QACT,KAAK;QACL,kBAAkB;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAA;IAC7B,MAAM,iBAAiB,EAAE,CAAA;IAEzB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA1ID,kCA0IC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { resolvePaths } from '../paths'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { mergeEnvironment } from './environment'\nimport { getPicklesAndErrors } from './gherkin'\nimport { initializeForRunCucumber } from './plugins'\n\n/**\n * Execute a Cucumber test run and return the overall result\n *\n * @public\n * @param options - Options for the run, obtainable via {@link loadConfiguration}\n * @param environment - Project environment\n * @param onMessage - Callback fired each time Cucumber emits a message\n */\nexport async function runCucumber(\n options: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const mergedEnvironment = mergeEnvironment(environment)\n const { cwd, stdout, stderr, env, logger } = mergedEnvironment\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'originalCoordinates' in options.support\n ? options.support.originalCoordinates\n : Object.assign(\n {\n requireModules: [],\n requirePaths: [],\n loaders: [],\n importPaths: [],\n },\n options.support\n )\n\n const pluginManager = await initializeForRunCucumber(\n logger,\n {\n ...options,\n support: supportCoordinates,\n },\n mergedEnvironment\n )\n\n const resolvedPaths = await resolvePaths(\n logger,\n cwd,\n options.sources,\n supportCoordinates\n )\n pluginManager.emit('paths:resolve', resolvedPaths)\n const { sourcePaths, requirePaths, importPaths } = resolvedPaths\n\n const supportCodeLibrary =\n 'originalCoordinates' in options.support\n ? (options.support as SupportCodeLibrary)\n : await getSupportCodeLibrary({\n logger,\n cwd,\n newId,\n requirePaths,\n requireModules: supportCoordinates.requireModules,\n importPaths,\n loaders: supportCoordinates.loaders,\n })\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) =>\n pluginManager.emit('message', value)\n )\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: options.formats,\n supportCodeLibrary,\n pluginManager,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (sourcePaths.length > 0) {\n const gherkinResult = await getPicklesAndErrors({\n newId,\n cwd,\n sourcePaths,\n coordinates: options.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n const filteredPickles = await pluginManager.transform(\n 'pickles:filter',\n gherkinResult.filterablePickles\n )\n const orderedPickles = await pluginManager.transform(\n 'pickles:order',\n filteredPickles\n )\n pickleIds = orderedPickles.map(({ pickle }) => pickle.id)\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await pluginManager.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n options: options.runtime,\n })\n const success = await runtime.start()\n await pluginManager.cleanup()\n await cleanupFormatters()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const commander_1 = require("commander");
|
|
7
7
|
const lodash_merge_1 = __importDefault(require("lodash.merge"));
|
|
8
8
|
const gherkin_1 = require("@cucumber/gherkin");
|
|
9
|
-
const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
|
|
10
9
|
const version_1 = require("../version");
|
|
10
|
+
const builtin_1 = __importDefault(require("../formatter/builtin"));
|
|
11
11
|
const ArgvParser = {
|
|
12
12
|
collect(val, memo = []) {
|
|
13
13
|
if (val) {
|
|
@@ -59,7 +59,7 @@ const ArgvParser = {
|
|
|
59
59
|
.option('--exit, --force-exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit')
|
|
60
60
|
.option('--fail-fast', 'abort the run on first failure')
|
|
61
61
|
.option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
|
|
62
|
-
|
|
62
|
+
Object.entries(builtin_1.default).reduce((previous, [key, formatter]) => previous + ` ${key}: ${formatter.documentation}\n`, ''), ArgvParser.collect)
|
|
63
63
|
.option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))
|
|
64
64
|
.option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)
|
|
65
65
|
.option('--i18n-languages', 'list languages')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,iFAAwD;AACxD,wCAAoC;AAkBpC,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,yBAAyB,CAAC,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC,CAAA;aACvE;YACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACjD,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,sCAAsC,GAAG,EAAE,CAAC,CAAA;aACtE;YACD,OAAO,IAAA,sBAAK,EAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACzB,CAAC,CAAA;IACH,CAAC;IAED,SAAS,CAAC,KAAa,EAAE,IAAa;QACpC,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,SAAS,KAAK,GAAG,CAAC,CA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oB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport Formatters from '../formatter/helpers/formatters'\nimport { version } from '../version'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
1
|
+
{"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,+CAA4C;AAC5C,wCAAoC;A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Y,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport { dialects } from '@cucumber/gherkin'\nimport { version } from '../version'\nimport builtin from '../formatter/builtin'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command('cucumber-js')\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Object.entries(builtin).reduce(\n (previous, [key, formatter]) =>\n previous + ` ${key}: ${formatter.documentation}\\n`,\n ''\n ),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '-l, --loader <NODE_MODULE>',\n 'module specifier(s) for loaders to be registered ahead of loading support code',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
|
|
@@ -27,7 +27,7 @@ export interface IBuildOptions {
|
|
|
27
27
|
supportCodeLibrary: SupportCodeLibrary;
|
|
28
28
|
}
|
|
29
29
|
declare const FormatterBuilder: {
|
|
30
|
-
build(
|
|
30
|
+
build(FormatterConstructor: string | typeof Formatter, options: IBuildOptions): Promise<Formatter>;
|
|
31
31
|
getConstructorByType(type: string, cwd: string): Promise<typeof Formatter>;
|
|
32
32
|
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): Promise<StepDefinitionSnippetBuilder>;
|
|
33
33
|
loadCustomClass(type: 'formatter' | 'syntax', descriptor: string, cwd: string): Promise<any>;
|
package/lib/formatter/builder.js
CHANGED
|
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
-
const node_url_1 = require("node:url");
|
|
8
6
|
const value_checker_1 = require("../value_checker");
|
|
9
7
|
const snippet_syntax_1 = require("./step_definition_snippet_builder/snippet_syntax");
|
|
10
8
|
const step_definition_snippet_builder_1 = __importDefault(require("./step_definition_snippet_builder"));
|
|
11
9
|
const javascript_snippet_syntax_1 = __importDefault(require("./step_definition_snippet_builder/javascript_snippet_syntax"));
|
|
12
10
|
const get_color_fns_1 = __importDefault(require("./get_color_fns"));
|
|
13
11
|
const formatters_1 = __importDefault(require("./helpers/formatters"));
|
|
12
|
+
const import_code_1 = require("./import_code");
|
|
14
13
|
const FormatterBuilder = {
|
|
15
|
-
async build(
|
|
16
|
-
|
|
14
|
+
async build(FormatterConstructor, options) {
|
|
15
|
+
if (typeof FormatterConstructor === 'string') {
|
|
16
|
+
FormatterConstructor = await FormatterBuilder.getConstructorByType(FormatterConstructor, options.cwd);
|
|
17
|
+
}
|
|
17
18
|
const colorFns = (0, get_color_fns_1.default)(options.stream, options.env, options.parsedArgvOptions.colorsEnabled);
|
|
18
19
|
const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder({
|
|
19
20
|
cwd: options.cwd,
|
|
@@ -47,15 +48,7 @@ const FormatterBuilder = {
|
|
|
47
48
|
});
|
|
48
49
|
},
|
|
49
50
|
async loadCustomClass(type, descriptor, cwd) {
|
|
50
|
-
|
|
51
|
-
if (descriptor.startsWith('.')) {
|
|
52
|
-
normalized = (0, node_url_1.pathToFileURL)(node_path_1.default.resolve(cwd, descriptor));
|
|
53
|
-
}
|
|
54
|
-
else if (descriptor.startsWith('file://')) {
|
|
55
|
-
normalized = new URL(descriptor);
|
|
56
|
-
}
|
|
57
|
-
let CustomClass = await FormatterBuilder.loadFile(normalized);
|
|
58
|
-
CustomClass = FormatterBuilder.resolveConstructor(CustomClass);
|
|
51
|
+
const CustomClass = FormatterBuilder.resolveConstructor(await (0, import_code_1.importCode)(descriptor, cwd));
|
|
59
52
|
if ((0, value_checker_1.doesHaveValue)(CustomClass)) {
|
|
60
53
|
return CustomClass;
|
|
61
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAEA,oDAAkE;AAElE,qFAAmF;AAEnF,wGAA4E;AAC5E,4HAAiG;AACjG,oEAAyC;AACzC,sEAA6C;AAC7C,+CAA0C;AA0B1C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CACT,oBAA+C,EAC/C,OAAsB;QAEtB,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE;YAC5C,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAChE,oBAAoB,EACpB,OAAO,CAAC,GAAG,CACZ,CAAA;SACF;QACD,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAC1B,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,GAAG,EACX,OAAO,CAAC,iBAAiB,CAAC,aAAa,CACxC,CAAA;QACD,MAAM,cAAc,GAClB,MAAM,gBAAgB,CAAC,+BAA+B,CAAC;YACrD,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,gBAAgB,EAAE,OAAO,C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ClC,CAAA;QACD,IAAI,IAAA,6BAAa,EAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,WAAW,CAAA;SACnB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,KAAK,UAAU,oCAAoC,CAClE,CAAA;SACF;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,SAAuB;QACpC,OAAO,MAAM,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC3C,CAAC;IAED,kBAAkB,CAAC,YAAiB;QAClC,IAAI,IAAA,gCAAgB,EAAC,YAAY,CAAC,EAAE;YAClC,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,OAAO,YAAY,KAAK,QAAQ;YAChC,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;aAAM,IACL,OAAO,YAAY,CAAC,OAAO,KAAK,QAAQ;YACxC,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,KAAK,UAAU,EAClD;YACA,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAA;SACpC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Writable as WritableStream } from 'node:stream'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport EventDataCollector from './helpers/event_data_collector'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport getColorFns from './get_color_fns'\nimport Formatters from './helpers/formatters'\nimport { importCode } from './import_code'\nimport Formatter, {\n FormatOptions,\n IFormatterCleanupFn,\n IFormatterLogFn,\n} from '.'\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: SupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n env: NodeJS.ProcessEnv\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: SupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(\n FormatterConstructor: string | typeof Formatter,\n options: IBuildOptions\n ): Promise<Formatter> {\n if (typeof FormatterConstructor === 'string') {\n FormatterConstructor = await FormatterBuilder.getConstructorByType(\n FormatterConstructor,\n options.cwd\n )\n }\n const colorFns = getColorFns(\n options.stream,\n options.env,\n options.parsedArgvOptions.colorsEnabled\n )\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n const CustomClass = FormatterBuilder.resolveConstructor(\n await importCode(descriptor, cwd)\n )\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n async loadFile(urlOrName: URL | string) {\n return await import(urlOrName.toString())\n },\n\n resolveConstructor(ImportedCode: any) {\n if (doesNotHaveValue(ImportedCode)) {\n return null\n }\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n typeof ImportedCode === 'object' &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n } else if (\n typeof ImportedCode.default === 'object' &&\n typeof ImportedCode.default.default === 'function'\n ) {\n return ImportedCode.default.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
|
+
const node_stream_1 = require("node:stream");
|
|
8
|
+
const html_formatter_1 = __importDefault(require("@cucumber/html-formatter"));
|
|
9
|
+
const resolve_pkg_1 = __importDefault(require("resolve-pkg"));
|
|
10
|
+
exports.default = {
|
|
11
|
+
type: 'formatter',
|
|
12
|
+
formatter({ on, write }) {
|
|
13
|
+
const htmlStream = new html_formatter_1.default((0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
14
|
+
'/dist/main.css', (0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
15
|
+
'/dist/main.js');
|
|
16
|
+
on('message', (message) => htmlStream.write(message));
|
|
17
|
+
htmlStream.on('data', (chunk) => write(chunk));
|
|
18
|
+
return async () => {
|
|
19
|
+
htmlStream.end();
|
|
20
|
+
await (0, node_util_1.promisify)(node_stream_1.finished)(htmlStream);
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
documentation: 'Outputs a HTML report',
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../../src/formatter/builtin/html.ts"],"names":[],"mappings":";;;;;AAAA,yCAAqC;AACrC,6CAAsC;AACtC,8EAAyD;AACzD,8DAAoC;AAGpC,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;QACrB,MAAM,UAAU,GAAG,IAAI,wBAAkB,CACvC,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,eAAe,CAClB,CAAA;QACD,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACrD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;QAE9C,OAAO,KAAK,IAAI,EAAE;YAChB,UAAU,CAAC,GAAG,EAAE,CAAA;YAChB,MAAM,IAAA,qBAAS,EAAC,sBAAQ,CAAC,CAAC,UAAU,CAAC,CAAA;QACvC,CAAC,CAAA;IACH,CAAC;IACD,aAAa,EAAE,uBAAuB;CACb,CAAA","sourcesContent":["import { promisify } from 'node:util'\nimport { finished } from 'node:stream'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport resolvePkg from 'resolve-pkg'\nimport { FormatterPlugin } from '../../plugin'\n\nexport default {\n type: 'formatter',\n formatter({ on, write }) {\n const htmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n on('message', (message) => htmlStream.write(message))\n htmlStream.on('data', (chunk) => write(chunk))\n\n return async () => {\n htmlStream.end()\n await promisify(finished)(htmlStream)\n }\n },\n documentation: 'Outputs a HTML report',\n} satisfies FormatterPlugin\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const json_formatter_1 = __importDefault(require("../json_formatter"));
|
|
7
|
+
const progress_formatter_1 = __importDefault(require("../progress_formatter"));
|
|
8
|
+
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));
|
|
9
|
+
const rerun_formatter_1 = __importDefault(require("../rerun_formatter"));
|
|
10
|
+
const snippets_formatter_1 = __importDefault(require("../snippets_formatter"));
|
|
11
|
+
const summary_formatter_1 = __importDefault(require("../summary_formatter"));
|
|
12
|
+
const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
13
|
+
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
14
|
+
const junit_formatter_1 = __importDefault(require("../junit_formatter"));
|
|
15
|
+
const message_1 = __importDefault(require("./message"));
|
|
16
|
+
const html_1 = __importDefault(require("./html"));
|
|
17
|
+
const builtin = {
|
|
18
|
+
// new plugin-based formatters
|
|
19
|
+
html: html_1.default,
|
|
20
|
+
message: message_1.default,
|
|
21
|
+
// legacy class-based formatters
|
|
22
|
+
json: json_formatter_1.default,
|
|
23
|
+
progress: progress_formatter_1.default,
|
|
24
|
+
'progress-bar': progress_bar_formatter_1.default,
|
|
25
|
+
rerun: rerun_formatter_1.default,
|
|
26
|
+
snippets: snippets_formatter_1.default,
|
|
27
|
+
summary: summary_formatter_1.default,
|
|
28
|
+
usage: usage_formatter_1.default,
|
|
29
|
+
'usage-json': usage_json_formatter_1.default,
|
|
30
|
+
junit: junit_formatter_1.default,
|
|
31
|
+
};
|
|
32
|
+
exports.default = builtin;
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/formatter/builtin/index.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,+EAAqD;AACrD,uFAA4D;AAC5D,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,yEAA+C;AAC/C,wDAAwC;AACxC,kDAAkC;AAElC,MAAM,OAAO,GAA4C;IACvD,8BAA8B;IAC9B,IAAI,EAAE,cAAa;IACnB,OAAO,EAAE,iBAAgB;IACzB,gCAAgC;IAChC,IAAI,EAAE,wBAAa;IACnB,QAAQ,EAAE,4BAAiB;IAC3B,cAAc,EAAE,gCAAoB;IACpC,KAAK,EAAE,yBAAc;IACrB,QAAQ,EAAE,4BAAiB;IAC3B,OAAO,EAAE,2BAAgB;IACzB,KAAK,EAAE,yBAAc;IACrB,YAAY,EAAE,8BAAkB;IAChC,KAAK,EAAE,yBAAc;CACtB,CAAA;AAED,kBAAe,OAAO,CAAA","sourcesContent":["import { FormatterImplementation } from '../index'\nimport JsonFormatter from '../json_formatter'\nimport ProgressFormatter from '../progress_formatter'\nimport ProgressBarFormatter from '../progress_bar_formatter'\nimport RerunFormatter from '../rerun_formatter'\nimport SnippetsFormatter from '../snippets_formatter'\nimport SummaryFormatter from '../summary_formatter'\nimport UsageFormatter from '../usage_formatter'\nimport UsageJsonFormatter from '../usage_json_formatter'\nimport JunitFormatter from '../junit_formatter'\nimport messageFormatter from './message'\nimport htmlFormatter from './html'\n\nconst builtin: Record<string, FormatterImplementation> = {\n // new plugin-based formatters\n html: htmlFormatter,\n message: messageFormatter,\n // legacy class-based formatters\n json: JsonFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n junit: JunitFormatter,\n}\n\nexport default builtin\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
type: 'formatter',
|
|
5
|
+
formatter({ on, write }) {
|
|
6
|
+
on('message', (message) => write(JSON.stringify(message) + '\n'));
|
|
7
|
+
},
|
|
8
|
+
documentation: 'Emits Cucumber messages in NDJSON format',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/formatter/builtin/message.ts"],"names":[],"mappings":";;AAEA,kBAAe;IACb,IAAI,EAAE,WAAW;IACjB,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE;QACrB,EAAE,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IACnE,CAAC;IACD,aAAa,EAAE,0CAA0C;CAChC,CAAA","sourcesContent":["import { FormatterPlugin } from '../../plugin'\n\nexport default {\n type: 'formatter',\n formatter({ on, write }) {\n on('message', (message) => write(JSON.stringify(message) + '\\n'))\n },\n documentation: 'Emits Cucumber messages in NDJSON format',\n} satisfies FormatterPlugin\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createStream = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const mkdirp_1 = require("mkdirp");
|
|
9
|
+
const fs_1 = __importDefault(require("mz/fs"));
|
|
10
|
+
async function createStream(target, onStreamError, cwd, logger) {
|
|
11
|
+
const absoluteTarget = node_path_1.default.resolve(cwd, target);
|
|
12
|
+
try {
|
|
13
|
+
await (0, mkdirp_1.mkdirp)(node_path_1.default.dirname(absoluteTarget));
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
logger.warn('Failed to ensure directory for formatter target exists');
|
|
17
|
+
}
|
|
18
|
+
const stream = fs_1.default.createWriteStream(null, {
|
|
19
|
+
fd: await fs_1.default.open(absoluteTarget, 'w'),
|
|
20
|
+
});
|
|
21
|
+
stream.on('error', (error) => {
|
|
22
|
+
logger.error(error.message);
|
|
23
|
+
onStreamError();
|
|
24
|
+
});
|
|
25
|
+
return stream;
|
|
26
|
+
}
|
|
27
|
+
exports.createStream = createStream;
|
|
28
|
+
//# sourceMappingURL=create_stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_stream.js","sourceRoot":"","sources":["../../src/formatter/create_stream.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,mCAA+B;AAC/B,+CAAsB;AAGf,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,aAAyB,EACzB,GAAW,EACX,MAAe;IAEf,MAAM,cAAc,GAAG,mBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;IAEhD,IAAI;QACF,MAAM,IAAA,eAAM,EAAC,mBAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAA;KAC3C;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAA;KACtE;IAED,MAAM,MAAM,GAAa,YAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClD,EAAE,EAAE,MAAM,YAAE,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,CAAC;KACvC,CAAC,CAAA;IAEF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC3B,aAAa,EAAE,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAxBD,oCAwBC","sourcesContent":["import path from 'node:path'\nimport { Writable } from 'node:stream'\nimport { mkdirp } from 'mkdirp'\nimport fs from 'mz/fs'\nimport { ILogger } from '../logger'\n\nexport async function createStream(\n target: string,\n onStreamError: () => void,\n cwd: string,\n logger: ILogger\n): Promise<Writable> {\n const absoluteTarget = path.resolve(cwd, target)\n\n try {\n await mkdirp(path.dirname(absoluteTarget))\n } catch (error) {\n logger.warn('Failed to ensure directory for formatter target exists')\n }\n\n const stream: Writable = fs.createWriteStream(null, {\n fd: await fs.open(absoluteTarget, 'w'),\n })\n\n stream.on('error', (error: Error) => {\n logger.error(error.message)\n onStreamError()\n })\n\n return stream\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findClassOrPlugin(imported: any): any;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findClassOrPlugin = void 0;
|
|
4
|
+
const value_checker_1 = require("../value_checker");
|
|
5
|
+
function findClassOrPlugin(imported) {
|
|
6
|
+
return findRecursive(imported, 3);
|
|
7
|
+
}
|
|
8
|
+
exports.findClassOrPlugin = findClassOrPlugin;
|
|
9
|
+
function findRecursive(thing, depth) {
|
|
10
|
+
if ((0, value_checker_1.doesNotHaveValue)(thing)) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (typeof thing === 'function') {
|
|
14
|
+
return thing;
|
|
15
|
+
}
|
|
16
|
+
if (typeof thing === 'object' && thing.type === 'formatter') {
|
|
17
|
+
return thing;
|
|
18
|
+
}
|
|
19
|
+
depth--;
|
|
20
|
+
if (depth > 0) {
|
|
21
|
+
return findRecursive(thing.default, depth);
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=find_class_or_plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_class_or_plugin.js","sourceRoot":"","sources":["../../src/formatter/find_class_or_plugin.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AAEnD,SAAgB,iBAAiB,CAAC,QAAa;IAC7C,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AACnC,CAAC;AAFD,8CAEC;AAED,SAAS,aAAa,CAAC,KAAU,EAAE,KAAa;IAC9C,IAAI,IAAA,gCAAgB,EAAC,KAAK,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;QAC/B,OAAO,KAAK,CAAA;KACb;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE;QAC3D,OAAO,KAAK,CAAA;KACb;IACD,KAAK,EAAE,CAAA;IACP,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,OAAO,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;KAC3C;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { doesNotHaveValue } from '../value_checker'\n\nexport function findClassOrPlugin(imported: any) {\n return findRecursive(imported, 3)\n}\n\nfunction findRecursive(thing: any, depth: number): any {\n if (doesNotHaveValue(thing)) {\n return null\n }\n if (typeof thing === 'function') {\n return thing\n }\n if (typeof thing === 'object' && thing.type === 'formatter') {\n return thing\n }\n depth--\n if (depth > 0) {\n return findRecursive(thing.default, depth)\n }\n return null\n}\n"]}
|
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const json_formatter_1 = __importDefault(require("../json_formatter"));
|
|
7
|
-
const message_formatter_1 = __importDefault(require("../message_formatter"));
|
|
8
7
|
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));
|
|
9
8
|
const progress_formatter_1 = __importDefault(require("../progress_formatter"));
|
|
10
9
|
const rerun_formatter_1 = __importDefault(require("../rerun_formatter"));
|
|
@@ -12,14 +11,11 @@ const snippets_formatter_1 = __importDefault(require("../snippets_formatter"));
|
|
|
12
11
|
const summary_formatter_1 = __importDefault(require("../summary_formatter"));
|
|
13
12
|
const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
14
13
|
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
15
|
-
const html_formatter_1 = __importDefault(require("../html_formatter"));
|
|
16
14
|
const junit_formatter_1 = __importDefault(require("../junit_formatter"));
|
|
17
15
|
const Formatters = {
|
|
18
16
|
getFormatters() {
|
|
19
17
|
return {
|
|
20
18
|
json: json_formatter_1.default,
|
|
21
|
-
message: message_formatter_1.default,
|
|
22
|
-
html: html_formatter_1.default,
|
|
23
19
|
progress: progress_formatter_1.default,
|
|
24
20
|
'progress-bar': progress_bar_formatter_1.default,
|
|
25
21
|
rerun: rerun_formatter_1.default,
|
|
@@ -30,14 +26,6 @@ const Formatters = {
|
|
|
30
26
|
junit: junit_formatter_1.default,
|
|
31
27
|
};
|
|
32
28
|
},
|
|
33
|
-
buildFormattersDocumentationString() {
|
|
34
|
-
let concatenatedFormattersDocumentation = '';
|
|
35
|
-
const formatters = this.getFormatters();
|
|
36
|
-
for (const formatterName in formatters) {
|
|
37
|
-
concatenatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\n`;
|
|
38
|
-
}
|
|
39
|
-
return concatenatedFormattersDocumentation;
|
|
40
|
-
},
|
|
41
29
|
};
|
|
42
30
|
exports.default = Formatters;
|
|
43
31
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,yEAA+C;AAE/C,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,QAAQ,EAAE,4BAAiB;YAC3B,cAAc,EAAE,gCAAoB;YACpC,KAAK,EAAE,yBAAc;YACrB,QAAQ,EAAE,4BAAiB;YAC3B,OAAO,EAAE,2BAAgB;YACzB,KAAK,EAAE,yBAAc;YACrB,YAAY,EAAE,8BAAkB;YAChC,KAAK,EAAE,yBAAc;SACtB,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport ProgressBarFormatter from '../progress_bar_formatter'\nimport ProgressFormatter from '../progress_formatter'\nimport RerunFormatter from '../rerun_formatter'\nimport SnippetsFormatter from '../snippets_formatter'\nimport SummaryFormatter from '../summary_formatter'\nimport UsageFormatter from '../usage_formatter'\nimport UsageJsonFormatter from '../usage_json_formatter'\nimport JunitFormatter from '../junit_formatter'\n\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n junit: JunitFormatter,\n }\n },\n}\n\nexport default Formatters\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function importCode(specifier: string, cwd: string): Promise<any>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.importCode = void 0;
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
async function importCode(specifier, cwd) {
|
|
10
|
+
try {
|
|
11
|
+
let normalized = specifier;
|
|
12
|
+
if (specifier.startsWith('.')) {
|
|
13
|
+
normalized = (0, node_url_1.pathToFileURL)(node_path_1.default.resolve(cwd, specifier));
|
|
14
|
+
}
|
|
15
|
+
else if (specifier.startsWith('file://')) {
|
|
16
|
+
normalized = new URL(specifier);
|
|
17
|
+
}
|
|
18
|
+
return await import(normalized.toString());
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new Error(`Failed to import formatter ${specifier}`, {
|
|
22
|
+
cause: e,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.importCode = importCode;
|
|
27
|
+
//# sourceMappingURL=import_code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import_code.js","sourceRoot":"","sources":["../../src/formatter/import_code.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAwC;AACxC,0DAA4B;AAErB,KAAK,UAAU,UAAU,CAAC,SAAiB,EAAE,GAAW;IAC7D,IAAI;QACF,IAAI,UAAU,GAAiB,SAAS,CAAA;QACxC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC7B,UAAU,GAAG,IAAA,wBAAa,EAAC,mBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;SACzD;aAAM,IAAI,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC1C,UAAU,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAA;SAChC;QACD,OAAO,MAAM,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAA;KAC3C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,8BAA8B,SAAS,EAAE,EAAE;YACzD,KAAK,EAAE,CAAC;SACT,CAAC,CAAA;KACH;AACH,CAAC;AAdD,gCAcC","sourcesContent":["import { pathToFileURL } from 'node:url'\nimport path from 'node:path'\n\nexport async function importCode(specifier: string, cwd: string): Promise<any> {\n try {\n let normalized: URL | string = specifier\n if (specifier.startsWith('.')) {\n normalized = pathToFileURL(path.resolve(cwd, specifier))\n } else if (specifier.startsWith('file://')) {\n normalized = new URL(specifier)\n }\n return await import(normalized.toString())\n } catch (e) {\n throw new Error(`Failed to import formatter ${specifier}`, {\n cause: e,\n })\n }\n}\n"]}
|
package/lib/formatter/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
4
|
import { EventEmitter } from 'node:events';
|
|
5
5
|
import { SupportCodeLibrary } from '../support_code_library_builder/types';
|
|
6
|
+
import { FormatterPlugin } from '../plugin';
|
|
6
7
|
import { IColorFns } from './get_color_fns';
|
|
7
8
|
import { EventDataCollector } from './helpers';
|
|
8
9
|
import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
|
|
@@ -18,6 +19,7 @@ export interface FormatOptions {
|
|
|
18
19
|
printAttachments?: boolean;
|
|
19
20
|
[customKey: string]: any;
|
|
20
21
|
}
|
|
22
|
+
export type FormatterImplementation = typeof Formatter | FormatterPlugin;
|
|
21
23
|
export type IFormatterStream = Writable;
|
|
22
24
|
export type IFormatterLogFn = (buffer: string | Uint8Array) => void;
|
|
23
25
|
export type IFormatterCleanupFn = () => Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAGA,oDAAiD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAGA,oDAAiD;AAsCjD,MAAqB,SAAS;IAClB,QAAQ,CAAW;IACnB,GAAG,CAAQ;IACX,kBAAkB,CAAoB;IACtC,GAAG,CAAiB;IACpB,cAAc,CAA8B;IAC5C,MAAM,CAAU;IAChB,kBAAkB,CAAoB;IACtC,gBAAgB,CAAS;IAClB,OAAO,CAAqB;IAC7C,MAAM,CAAU,aAAa,CAAQ;IAErC,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { Writable } from 'node:stream'\nimport { EventEmitter } from 'node:events'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { valueOrDefault } from '../value_checker'\nimport { FormatterPlugin } from '../plugin'\nimport { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport type FormatterImplementation = typeof Formatter | FormatterPlugin\nexport type IFormatterStream = Writable\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: Writable\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: SupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: Writable\n protected supportCodeLibrary: SupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveImplementation = void 0;
|
|
7
|
+
const builtin_1 = __importDefault(require("./builtin"));
|
|
8
|
+
const import_code_1 = require("./import_code");
|
|
9
|
+
const find_class_or_plugin_1 = require("./find_class_or_plugin");
|
|
10
|
+
async function resolveImplementation(specifier, cwd) {
|
|
11
|
+
if (builtin_1.default[specifier]) {
|
|
12
|
+
return builtin_1.default[specifier];
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const imported = await (0, import_code_1.importCode)(specifier, cwd);
|
|
16
|
+
const found = (0, find_class_or_plugin_1.findClassOrPlugin)(imported);
|
|
17
|
+
if (!found) {
|
|
18
|
+
throw new Error(`${specifier} does not export a function/class`);
|
|
19
|
+
}
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.resolveImplementation = resolveImplementation;
|
|
24
|
+
//# sourceMappingURL=resolve_implementation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve_implementation.js","sourceRoot":"","sources":["../../src/formatter/resolve_implementation.ts"],"names":[],"mappings":";;;;;;AAAA,wDAA+B;AAC/B,+CAA0C;AAC1C,iEAA0D;AAGnD,KAAK,UAAU,qBAAqB,CACzC,SAAiB,EACjB,GAAW;IAEX,IAAI,iBAAO,CAAC,SAAS,CAAC,EAAE;QACtB,OAAO,iBAAO,CAAC,SAAS,CAAC,CAAA;KAC1B;SAAM;QACL,MAAM,QAAQ,GAAG,MAAM,IAAA,wBAAU,EAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACjD,MAAM,KAAK,GAAG,IAAA,wCAAiB,EAAC,QAAQ,CAAC,CAAA;QACzC,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,mCAAmC,CAAC,CAAA;SACjE;QACD,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AAdD,sDAcC","sourcesContent":["import builtin from './builtin'\nimport { importCode } from './import_code'\nimport { findClassOrPlugin } from './find_class_or_plugin'\nimport { FormatterImplementation } from './index'\n\nexport async function resolveImplementation(\n specifier: string,\n cwd: string\n): Promise<FormatterImplementation> {\n if (builtin[specifier]) {\n return builtin[specifier]\n } else {\n const imported = await importCode(specifier, cwd)\n const found = findClassOrPlugin(imported)\n if (!found) {\n throw new Error(`${specifier} does not export a function/class`)\n }\n return found\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { IRunEnvironment } from '../api';
|
|
2
2
|
import { ILogger } from '../logger';
|
|
3
|
-
import { InternalPlugin, CoordinatorPluginEventValues, CoordinatorPluginEventKey, CoordinatorPluginTransformEventKey, Operation } from './types';
|
|
3
|
+
import { InternalPlugin, CoordinatorPluginEventValues, CoordinatorPluginEventKey, CoordinatorPluginTransformEventKey, Operation, FormatterPlugin } from './types';
|
|
4
4
|
export declare class PluginManager {
|
|
5
5
|
private handlers;
|
|
6
6
|
private cleanupFns;
|
|
7
7
|
private register;
|
|
8
|
-
|
|
8
|
+
initFormatter<OptionsType>(plugin: FormatterPlugin<OptionsType>, options: OptionsType, write: (buffer: string | Uint8Array) => void): Promise<void>;
|
|
9
|
+
initCoordinator<OptionsType>(operation: Operation, plugin: InternalPlugin<OptionsType>, options: OptionsType, logger: ILogger, environment: Required<IRunEnvironment>): Promise<void>;
|
|
9
10
|
emit<K extends CoordinatorPluginEventKey>(event: K, value: CoordinatorPluginEventValues[K]): void;
|
|
10
11
|
transform<K extends CoordinatorPluginTransformEventKey>(event: K, value: CoordinatorPluginEventValues[K]): Promise<CoordinatorPluginEventValues[K]>;
|
|
11
12
|
cleanup(): Promise<void>;
|
|
@@ -10,9 +10,19 @@ class PluginManager {
|
|
|
10
10
|
};
|
|
11
11
|
cleanupFns = [];
|
|
12
12
|
async register(event, handler) {
|
|
13
|
-
this.handlers[event]
|
|
13
|
+
this.handlers[event]?.push(handler);
|
|
14
14
|
}
|
|
15
|
-
async
|
|
15
|
+
async initFormatter(plugin, options, write) {
|
|
16
|
+
const cleanupFn = await plugin.formatter({
|
|
17
|
+
on: (key, handler) => this.register(key, handler),
|
|
18
|
+
options,
|
|
19
|
+
write,
|
|
20
|
+
});
|
|
21
|
+
if (typeof cleanupFn === 'function') {
|
|
22
|
+
this.cleanupFns.push(cleanupFn);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async initCoordinator(operation, plugin, options, logger, environment) {
|
|
16
26
|
const cleanupFn = await plugin.coordinator({
|
|
17
27
|
operation,
|
|
18
28
|
on: this.register.bind(this),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plugin_manager.js","sourceRoot":"","sources":["../../src/plugin/plugin_manager.ts"],"names":[],"mappings":";;;AAiBA,MAAa,aAAa;IAChB,QAAQ,GAAoB;QAClC,OAAO,EAAE,EAAE;QACX,eAAe,EAAE,EAAE;QACnB,gBAAgB,EAAE,EAAE;QACpB,eAAe,EAAE,EAAE;KACpB,CAAA;IACO,UAAU,GAAoB,EAAE,CAAA;IAEhC,KAAK,CAAC,QAAQ,CACpB,KAAQ,EACR,OAAyC;QAEzC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,MAAoC,EACpC,OAAoB,EACpB,KAA4C;QAE5C,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC;YACvC,EAAE,EAAE,CAAC,GAA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MAAM,SAAS,EAAE,CAAA;SAClB;IACH,CAAC;CACF;AA5ED,sCA4EC","sourcesContent":["import { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport {\n CoordinatorPluginEventHandler,\n InternalPlugin,\n PluginCleanup,\n CoordinatorPluginEventValues,\n CoordinatorPluginEventKey,\n CoordinatorPluginTransformEventKey,\n Operation,\n FormatterPlugin,\n} from './types'\n\ntype HandlerRegistry = {\n [K in CoordinatorPluginEventKey]: Array<CoordinatorPluginEventHandler<K>>\n}\n\nexport class PluginManager {\n private handlers: HandlerRegistry = {\n message: [],\n 'paths:resolve': [],\n 'pickles:filter': [],\n 'pickles:order': [],\n }\n private cleanupFns: PluginCleanup[] = []\n\n private async register<K extends CoordinatorPluginEventKey>(\n event: K,\n handler: CoordinatorPluginEventHandler<K>\n ) {\n this.handlers[event]?.push(handler)\n }\n\n async initFormatter<OptionsType>(\n plugin: FormatterPlugin<OptionsType>,\n options: OptionsType,\n write: (buffer: string | Uint8Array) => void\n ) {\n const cleanupFn = await plugin.formatter({\n on: (key, handler) => this.register(key, handler),\n options,\n write,\n })\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push(cleanupFn)\n }\n }\n\n async initCoordinator<OptionsType>(\n operation: Operation,\n plugin: InternalPlugin<OptionsType>,\n options: OptionsType,\n logger: ILogger,\n environment: Required<IRunEnvironment>\n ) {\n const cleanupFn = await plugin.coordinator({\n operation,\n on: this.register.bind(this),\n options,\n logger,\n environment,\n })\n if (typeof cleanupFn === 'function') {\n this.cleanupFns.push(cleanupFn)\n }\n }\n\n emit<K extends CoordinatorPluginEventKey>(\n event: K,\n value: CoordinatorPluginEventValues[K]\n ): void {\n this.handlers[event].forEach((handler) => handler(value))\n }\n\n async transform<K extends CoordinatorPluginTransformEventKey>(\n event: K,\n value: CoordinatorPluginEventValues[K]\n ): Promise<CoordinatorPluginEventValues[K]> {\n let transformed = value\n for (const handler of this.handlers[event]) {\n const returned = await handler(transformed)\n if (typeof returned !== 'undefined') {\n transformed = returned\n }\n }\n return transformed\n }\n\n async cleanup(): Promise<void> {\n for (const cleanupFn of this.cleanupFns) {\n await cleanupFn()\n }\n }\n}\n"]}
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -36,3 +36,14 @@ export interface InternalPlugin<OptionsType = any> {
|
|
|
36
36
|
type: 'plugin';
|
|
37
37
|
coordinator: CoordinatorPluginFunction<OptionsType>;
|
|
38
38
|
}
|
|
39
|
+
export interface FormatterPluginContext<OptionsType> {
|
|
40
|
+
on: (key: 'message', handler: (value: Envelope) => void) => void;
|
|
41
|
+
options: OptionsType;
|
|
42
|
+
write: (buffer: string | Uint8Array) => void;
|
|
43
|
+
}
|
|
44
|
+
export type FormatterPluginFunction<OptionsType> = (context: FormatterPluginContext<OptionsType>) => Promisable<PluginCleanup | void>;
|
|
45
|
+
export interface FormatterPlugin<OptionsType = any> {
|
|
46
|
+
type: 'formatter';
|
|
47
|
+
formatter: FormatterPluginFunction<OptionsType>;
|
|
48
|
+
documentation: string;
|
|
49
|
+
}
|
package/lib/plugin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugin/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Envelope } from '@cucumber/messages'\nimport { ArrayValues, Promisable } from 'type-fest'\nimport { IRunEnvironment } from '../api'\nimport { ILogger } from '../logger'\nimport { IFilterablePickle } from '../filter'\nimport { IResolvedPaths } from '../paths'\nimport { coordinatorTransformKeys, coordinatorVoidKeys } from './events'\n\nexport type Operation = 'loadSources' | 'loadSupport' | 'runCucumber'\n\nexport type CoordinatorPluginVoidEventKey = ArrayValues<\n typeof coordinatorVoidKeys\n>\nexport type CoordinatorPluginTransformEventKey = ArrayValues<\n typeof coordinatorTransformKeys\n>\nexport type CoordinatorPluginEventKey =\n | CoordinatorPluginVoidEventKey\n | CoordinatorPluginTransformEventKey\n\nexport type CoordinatorPluginEventValues = {\n // void\n message: Readonly<Envelope>\n 'paths:resolve': Readonly<IResolvedPaths>\n // transform\n 'pickles:filter': Readonly<Array<IFilterablePickle>>\n 'pickles:order': Readonly<Array<IFilterablePickle>>\n}\n\nexport type CoordinatorPluginEventHandler<K extends CoordinatorPluginEventKey> =\n (\n value: CoordinatorPluginEventValues[K]\n ) => K extends CoordinatorPluginTransformEventKey\n ? Promisable<CoordinatorPluginEventValues[K]>\n : void\n\nexport interface CoordinatorPluginContext<OptionsType> {\n operation: Operation\n on: <EventKey extends CoordinatorPluginEventKey>(\n event: EventKey,\n handler: CoordinatorPluginEventHandler<EventKey>\n ) => void\n options: OptionsType\n logger: ILogger\n environment: Required<IRunEnvironment>\n}\n\nexport type CoordinatorPluginFunction<OptionsType> = (\n context: CoordinatorPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport type PluginCleanup = () => Promisable<void>\n\n/**\n * A plugin to implement Cucumber built-in functionality.\n *\n * Uses the same events and mechanisms as user-authored plugins, but is free to require configuration and context from\n * inside of Cucumber as its `options`, whereas user-authored plugins will be limited to `pluginOptions` from the\n * project configuration.\n */\nexport interface InternalPlugin<OptionsType = any> {\n type: 'plugin'\n coordinator: CoordinatorPluginFunction<OptionsType>\n}\n\nexport interface FormatterPluginContext<OptionsType> {\n on: (key: 'message', handler: (value: Envelope) => void) => void\n options: OptionsType\n write: (buffer: string | Uint8Array) => void\n}\n\nexport type FormatterPluginFunction<OptionsType> = (\n context: FormatterPluginContext<OptionsType>\n) => Promisable<PluginCleanup | void>\n\nexport interface FormatterPlugin<OptionsType = any> {\n type: 'formatter'\n formatter: FormatterPluginFunction<OptionsType>\n documentation: string\n}\n"]}
|
|
@@ -57,7 +57,7 @@ export default class Coordinator implements IRuntime {
|
|
|
57
57
|
awakenWorkers(triggeringWorker: IWorker): void;
|
|
58
58
|
startWorker(id: string, total: number): void;
|
|
59
59
|
onWorkerProcessClose(exitCode: number): void;
|
|
60
|
-
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void;
|
|
60
|
+
parseTestCaseResult(testCaseFinished: messages.TestCaseFinished, workerId: string): void;
|
|
61
61
|
start(): Promise<boolean>;
|
|
62
62
|
nextPicklePlacement(): IPicklePlacement;
|
|
63
63
|
placementAt(index: number): IPicklePlacement;
|
|
@@ -52,8 +52,7 @@ class Coordinator {
|
|
|
52
52
|
const envelope = message.jsonEnvelope;
|
|
53
53
|
this.eventBroadcaster.emit('envelope', envelope);
|
|
54
54
|
if ((0, value_checker_1.doesHaveValue)(envelope.testCaseFinished)) {
|
|
55
|
-
|
|
56
|
-
this.parseTestCaseResult(envelope.testCaseFinished);
|
|
55
|
+
this.parseTestCaseResult(envelope.testCaseFinished, worker.id);
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
58
|
else {
|
|
@@ -122,11 +121,13 @@ class Coordinator {
|
|
|
122
121
|
this.onFinish(this.success);
|
|
123
122
|
}
|
|
124
123
|
}
|
|
125
|
-
parseTestCaseResult(testCaseFinished) {
|
|
124
|
+
parseTestCaseResult(testCaseFinished, workerId) {
|
|
126
125
|
const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(testCaseFinished.testCaseStartedId);
|
|
127
|
-
if (!testCaseFinished.willBeRetried
|
|
128
|
-
|
|
129
|
-
this.
|
|
126
|
+
if (!testCaseFinished.willBeRetried) {
|
|
127
|
+
delete this.inProgressPickles[workerId];
|
|
128
|
+
if ((0, helpers_1.shouldCauseFailure)(worstTestStepResult.status, this.options)) {
|
|
129
|
+
this.success = false;
|
|
130
|
+
}
|
|
130
131
|
}
|
|
131
132
|
}
|
|
132
133
|
async start() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/parallel/coordinator.ts"],"names":[],"mappings":";;;;;AAAA,2DAAuD;AACvD,0DAA4B;AAI5B,wCAAiE;AAIjE,uDAAmD;AACnD,4CAAiD;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A;QACnD,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAChE,MAAM,CAAC,GAAG,CACX,CAAA;QACD,MAAM,OAAO,GAAG,IAAA,0BAAgB,EAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5E,MAAM,UAAU,GAAmB;YACjC,GAAG,EAAE;gBACH,OAAO;gBACP,IAAI;gBACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAClC,MAAM;gBACN,QAAQ;gBACR,eAAe;aAChB;SACF,CAAA;QACD,MAAM,CAAC,KAAK,8BAAsB,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjC,CAAC;CACF;AAxPD,8BAwPC","sourcesContent":["import { ChildProcess, fork } from 'node:child_process'\nimport path from 'node:path'\nimport { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { retriesForPickle, shouldCauseFailure } from '../helpers'\nimport { EventDataCollector } from '../../formatter/helpers'\nimport { IRuntime, IRuntimeOptions } from '..'\nimport { SupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { IStopwatch, create } from '../stopwatch'\nimport { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'\nimport { ILogger } from '../../logger'\nimport { ICoordinatorReport, IWorkerCommand } from './command_types'\n\nconst runWorkerPath = path.resolve(__dirname, 'run_worker.js')\n\nexport interface INewCoordinatorOptions {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n options: IRuntimeOptions\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: SupportCodeLibrary\n numberOfWorkers: number\n}\n\nconst enum WorkerState {\n 'idle',\n 'closed',\n 'running',\n 'new',\n}\n\ninterface IWorker {\n state: WorkerState\n process: ChildProcess\n id: string\n}\n\ninterface IPicklePlacement {\n index: number\n pickle: messages.Pickle\n}\n\nexport default class Coordinator implements IRuntime {\n private readonly cwd: string\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private onFinish: (success: boolean) => void\n private readonly options: IRuntimeOptions\n private readonly newId: IdGenerator.NewId\n private readonly pickleIds: string[]\n private assembledTestCases: IAssembledTestCases\n private readonly inProgressPickles: Record<string, messages.Pickle>\n private readonly workers: Record<string, IWorker>\n private readonly supportCodeLibrary: SupportCodeLibrary\n private readonly numberOfWorkers: number\n private readonly logger: ILogger\n private success: boolean\n private idleInterventions: number\n\n constructor({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n numberOfWorkers,\n }: INewCoordinatorOptions) {\n this.cwd = cwd\n this.logger = logger\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.options = options\n this.newId = newId\n this.supportCodeLibrary = supportCodeLibrary\n this.pickleIds = Array.from(pickleIds)\n this.numberOfWorkers = numberOfWorkers\n this.success = true\n this.workers = {}\n this.inProgressPickles = {}\n this.idleInterventions = 0\n }\n\n parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void {\n if (message.ready) {\n worker.state = WorkerState.idle\n this.awakenWorkers(worker)\n } else if (doesHaveValue(message.jsonEnvelope)) {\n const envelope = message.jsonEnvelope\n this.eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.testCaseFinished)) {\n delete this.inProgressPickles[worker.id]\n this.parseTestCaseResult(envelope.testCaseFinished)\n }\n } else {\n throw new Error(\n `Unexpected message from worker: ${JSON.stringify(message)}`\n )\n }\n }\n\n awakenWorkers(triggeringWorker: IWorker): void {\n Object.values(this.workers).forEach((worker) => {\n if (worker.state === WorkerState.idle) {\n this.giveWork(worker)\n }\n return worker.state !== WorkerState.idle\n })\n\n if (\n Object.keys(this.inProgressPickles).length == 0 &&\n this.pickleIds.length > 0\n ) {\n this.giveWork(triggeringWorker, true)\n this.idleInterventions++\n }\n }\n\n startWorker(id: string, total: number): void {\n const workerProcess = fork(runWorkerPath, [], {\n cwd: this.cwd,\n env: {\n ...process.env,\n CUCUMBER_PARALLEL: 'true',\n CUCUMBER_TOTAL_WORKERS: total.toString(),\n CUCUMBER_WORKER_ID: id,\n },\n stdio: ['inherit', 'inherit', 'inherit', 'ipc'],\n })\n const worker = { state: WorkerState.new, process: workerProcess, id }\n this.workers[id] = worker\n worker.process.on('message', (message: ICoordinatorReport) => {\n this.parseWorkerMessage(worker, message)\n })\n worker.process.on('close', (exitCode) => {\n worker.state = WorkerState.closed\n this.onWorkerProcessClose(exitCode)\n })\n const initializeCommand: IWorkerCommand = {\n initialize: {\n supportCodeCoordinates: this.supportCodeLibrary.originalCoordinates,\n supportCodeIds: {\n stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map(\n (s) => s.id\n ),\n beforeTestCaseHookDefinitionIds:\n this.supportCodeLibrary.beforeTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n afterTestCaseHookDefinitionIds:\n this.supportCodeLibrary.afterTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n },\n options: this.options,\n },\n }\n worker.process.send(initializeCommand)\n }\n\n onWorkerProcessClose(exitCode: number): void {\n const success = exitCode === 0\n if (!success) {\n this.success = false\n }\n\n if (\n Object.values(this.workers).every((x) => x.state === WorkerState.closed)\n ) {\n const envelope: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success,\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.onFinish(this.success)\n }\n }\n\n parseTestCaseResult(testCaseFinished: messages.TestCaseFinished): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (\n !testCaseFinished.willBeRetried &&\n shouldCauseFailure(worstTestStepResult.status, this.options)\n ) {\n this.success = false\n }\n }\n\n async start(): Promise<boolean> {\n const envelope: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.stopwatch.start()\n this.assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n return await new Promise<boolean>((resolve) => {\n for (let i = 0; i < this.numberOfWorkers; i++) {\n this.startWorker(i.toString(), this.numberOfWorkers)\n }\n this.onFinish = (status) => {\n if (this.idleInterventions > 0) {\n this.logger.warn(\n `WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`\n )\n }\n\n resolve(status)\n }\n })\n }\n\n nextPicklePlacement(): IPicklePlacement {\n for (let index = 0; index < this.pickleIds.length; index++) {\n const placement = this.placementAt(index)\n if (\n this.supportCodeLibrary.parallelCanAssign(\n placement.pickle,\n Object.values(this.inProgressPickles)\n )\n ) {\n return placement\n }\n }\n\n return null\n }\n\n placementAt(index: number): IPicklePlacement {\n return {\n index,\n pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),\n }\n }\n\n giveWork(worker: IWorker, force: boolean = false): void {\n if (this.pickleIds.length < 1) {\n const finalizeCommand: IWorkerCommand = { finalize: true }\n worker.state = WorkerState.running\n worker.process.send(finalizeCommand)\n return\n }\n\n const picklePlacement = force\n ? this.placementAt(0)\n : this.nextPicklePlacement()\n\n if (picklePlacement === null) {\n return\n }\n\n const { index: nextPickleIndex, pickle } = picklePlacement\n\n this.pickleIds.splice(nextPickleIndex, 1)\n this.inProgressPickles[worker.id] = pickle\n const testCase = this.assembledTestCases[pickle.id]\n const gherkinDocument = this.eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const runCommand: IWorkerCommand = {\n run: {\n retries,\n skip,\n elapsed: this.stopwatch.duration(),\n pickle,\n testCase,\n gherkinDocument,\n },\n }\n worker.state = WorkerState.running\n worker.process.send(runCommand)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"coordinator.js","sourceRoot":"","sources":["../../../src/runtime/parallel/coordinator.ts"],"names":[],"mappings":";;;;;AAAA,2DAAuD;AACvD,0DAA4B;AAI5B,wCAAiE;AAIjE,uDAAmD;AACnD,4CAAiD;AACjD,gEAA+E;AAI/E,MAAM,aAAa,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;AAgC9D,MAAqB,WAAW;IACb,GAAG,CAAQ;IACX,gBAAgB,CAAc;IAC9B,kBAAkB,CAAoB;IACtC,SAAS,CAAY;IAC9B,QAAQ,CAA4B;IAC3B,OAAO,CAAiB;IACxB,KAAK,CAAmB;IACxB,SAAS,CAAU;IAC5B,kBAAkB,CAAqB;IAC9B,iBAAiB,CAAiC;IAClD,OAAO,CAAyB;IAChC,kBAAkB,CAAoB;IACtC,eAAe,CAAQ;IACvB,MAAM,CAAS;IACxB,OAAO,CAAS;IAChB,iBAAiB,CAAQ;IAEjC,YAAY,EACV,GAAG,EACH,MAAM,EACN,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,eAAe,GACQ;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,SAAS,GAAG,IAAA,kBAAM,GAAE,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG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AC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAA;QAE9B,IAAI,eAAe,KAAK,IAAI,EAAE;YAC5B,OAAM;SACP;QAED,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,eAAe,CAAA;QAE1D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAA;QACzC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACnD,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAChE,MAAM,CAAC,GAAG,CACX,CAAA;QACD,MAAM,OAAO,GAAG,IAAA,0BAAgB,EAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QACtD,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5E,MAAM,UAAU,GAAmB;YACjC,GAAG,EAAE;gBACH,OAAO;gBACP,IAAI;gBACJ,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAClC,MAAM;gBACN,QAAQ;gBACR,eAAe;aAChB;SACF,CAAA;QACD,MAAM,CAAC,KAAK,8BAAsB,CAAA;QAClC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACjC,CAAC;CACF;AA3PD,8BA2PC","sourcesContent":["import { ChildProcess, fork } from 'node:child_process'\nimport path from 'node:path'\nimport { EventEmitter } from 'node:events'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport { retriesForPickle, shouldCauseFailure } from '../helpers'\nimport { EventDataCollector } from '../../formatter/helpers'\nimport { IRuntime, IRuntimeOptions } from '..'\nimport { SupportCodeLibrary } from '../../support_code_library_builder/types'\nimport { doesHaveValue } from '../../value_checker'\nimport { IStopwatch, create } from '../stopwatch'\nimport { assembleTestCases, IAssembledTestCases } from '../assemble_test_cases'\nimport { ILogger } from '../../logger'\nimport { ICoordinatorReport, IWorkerCommand } from './command_types'\n\nconst runWorkerPath = path.resolve(__dirname, 'run_worker.js')\n\nexport interface INewCoordinatorOptions {\n cwd: string\n logger: ILogger\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n options: IRuntimeOptions\n newId: IdGenerator.NewId\n pickleIds: string[]\n supportCodeLibrary: SupportCodeLibrary\n numberOfWorkers: number\n}\n\nconst enum WorkerState {\n 'idle',\n 'closed',\n 'running',\n 'new',\n}\n\ninterface IWorker {\n state: WorkerState\n process: ChildProcess\n id: string\n}\n\ninterface IPicklePlacement {\n index: number\n pickle: messages.Pickle\n}\n\nexport default class Coordinator implements IRuntime {\n private readonly cwd: string\n private readonly eventBroadcaster: EventEmitter\n private readonly eventDataCollector: EventDataCollector\n private readonly stopwatch: IStopwatch\n private onFinish: (success: boolean) => void\n private readonly options: IRuntimeOptions\n private readonly newId: IdGenerator.NewId\n private readonly pickleIds: string[]\n private assembledTestCases: IAssembledTestCases\n private readonly inProgressPickles: Record<string, messages.Pickle>\n private readonly workers: Record<string, IWorker>\n private readonly supportCodeLibrary: SupportCodeLibrary\n private readonly numberOfWorkers: number\n private readonly logger: ILogger\n private success: boolean\n private idleInterventions: number\n\n constructor({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n options,\n newId,\n supportCodeLibrary,\n numberOfWorkers,\n }: INewCoordinatorOptions) {\n this.cwd = cwd\n this.logger = logger\n this.eventBroadcaster = eventBroadcaster\n this.eventDataCollector = eventDataCollector\n this.stopwatch = create()\n this.options = options\n this.newId = newId\n this.supportCodeLibrary = supportCodeLibrary\n this.pickleIds = Array.from(pickleIds)\n this.numberOfWorkers = numberOfWorkers\n this.success = true\n this.workers = {}\n this.inProgressPickles = {}\n this.idleInterventions = 0\n }\n\n parseWorkerMessage(worker: IWorker, message: ICoordinatorReport): void {\n if (message.ready) {\n worker.state = WorkerState.idle\n this.awakenWorkers(worker)\n } else if (doesHaveValue(message.jsonEnvelope)) {\n const envelope = message.jsonEnvelope\n this.eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.testCaseFinished)) {\n this.parseTestCaseResult(envelope.testCaseFinished, worker.id)\n }\n } else {\n throw new Error(\n `Unexpected message from worker: ${JSON.stringify(message)}`\n )\n }\n }\n\n awakenWorkers(triggeringWorker: IWorker): void {\n Object.values(this.workers).forEach((worker) => {\n if (worker.state === WorkerState.idle) {\n this.giveWork(worker)\n }\n return worker.state !== WorkerState.idle\n })\n\n if (\n Object.keys(this.inProgressPickles).length == 0 &&\n this.pickleIds.length > 0\n ) {\n this.giveWork(triggeringWorker, true)\n this.idleInterventions++\n }\n }\n\n startWorker(id: string, total: number): void {\n const workerProcess = fork(runWorkerPath, [], {\n cwd: this.cwd,\n env: {\n ...process.env,\n CUCUMBER_PARALLEL: 'true',\n CUCUMBER_TOTAL_WORKERS: total.toString(),\n CUCUMBER_WORKER_ID: id,\n },\n stdio: ['inherit', 'inherit', 'inherit', 'ipc'],\n })\n const worker = { state: WorkerState.new, process: workerProcess, id }\n this.workers[id] = worker\n worker.process.on('message', (message: ICoordinatorReport) => {\n this.parseWorkerMessage(worker, message)\n })\n worker.process.on('close', (exitCode) => {\n worker.state = WorkerState.closed\n this.onWorkerProcessClose(exitCode)\n })\n const initializeCommand: IWorkerCommand = {\n initialize: {\n supportCodeCoordinates: this.supportCodeLibrary.originalCoordinates,\n supportCodeIds: {\n stepDefinitionIds: this.supportCodeLibrary.stepDefinitions.map(\n (s) => s.id\n ),\n beforeTestCaseHookDefinitionIds:\n this.supportCodeLibrary.beforeTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n afterTestCaseHookDefinitionIds:\n this.supportCodeLibrary.afterTestCaseHookDefinitions.map(\n (h) => h.id\n ),\n },\n options: this.options,\n },\n }\n worker.process.send(initializeCommand)\n }\n\n onWorkerProcessClose(exitCode: number): void {\n const success = exitCode === 0\n if (!success) {\n this.success = false\n }\n\n if (\n Object.values(this.workers).every((x) => x.state === WorkerState.closed)\n ) {\n const envelope: messages.Envelope = {\n testRunFinished: {\n timestamp: this.stopwatch.timestamp(),\n success,\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.onFinish(this.success)\n }\n }\n\n parseTestCaseResult(\n testCaseFinished: messages.TestCaseFinished,\n workerId: string\n ): void {\n const { worstTestStepResult } = this.eventDataCollector.getTestCaseAttempt(\n testCaseFinished.testCaseStartedId\n )\n if (!testCaseFinished.willBeRetried) {\n delete this.inProgressPickles[workerId]\n\n if (shouldCauseFailure(worstTestStepResult.status, this.options)) {\n this.success = false\n }\n }\n }\n\n async start(): Promise<boolean> {\n const envelope: messages.Envelope = {\n testRunStarted: {\n timestamp: this.stopwatch.timestamp(),\n },\n }\n this.eventBroadcaster.emit('envelope', envelope)\n this.stopwatch.start()\n this.assembledTestCases = await assembleTestCases({\n eventBroadcaster: this.eventBroadcaster,\n newId: this.newId,\n pickles: this.pickleIds.map((pickleId) =>\n this.eventDataCollector.getPickle(pickleId)\n ),\n supportCodeLibrary: this.supportCodeLibrary,\n })\n return await new Promise<boolean>((resolve) => {\n for (let i = 0; i < this.numberOfWorkers; i++) {\n this.startWorker(i.toString(), this.numberOfWorkers)\n }\n this.onFinish = (status) => {\n if (this.idleInterventions > 0) {\n this.logger.warn(\n `WARNING: All workers went idle ${this.idleInterventions} time(s). Consider revising handler passed to setParallelCanAssign.`\n )\n }\n\n resolve(status)\n }\n })\n }\n\n nextPicklePlacement(): IPicklePlacement {\n for (let index = 0; index < this.pickleIds.length; index++) {\n const placement = this.placementAt(index)\n if (\n this.supportCodeLibrary.parallelCanAssign(\n placement.pickle,\n Object.values(this.inProgressPickles)\n )\n ) {\n return placement\n }\n }\n\n return null\n }\n\n placementAt(index: number): IPicklePlacement {\n return {\n index,\n pickle: this.eventDataCollector.getPickle(this.pickleIds[index]),\n }\n }\n\n giveWork(worker: IWorker, force: boolean = false): void {\n if (this.pickleIds.length < 1) {\n const finalizeCommand: IWorkerCommand = { finalize: true }\n worker.state = WorkerState.running\n worker.process.send(finalizeCommand)\n return\n }\n\n const picklePlacement = force\n ? this.placementAt(0)\n : this.nextPicklePlacement()\n\n if (picklePlacement === null) {\n return\n }\n\n const { index: nextPickleIndex, pickle } = picklePlacement\n\n this.pickleIds.splice(nextPickleIndex, 1)\n this.inProgressPickles[worker.id] = pickle\n const testCase = this.assembledTestCases[pickle.id]\n const gherkinDocument = this.eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n const retries = retriesForPickle(pickle, this.options)\n const skip = this.options.dryRun || (this.options.failFast && !this.success)\n const runCommand: IWorkerCommand = {\n run: {\n retries,\n skip,\n elapsed: this.stopwatch.duration(),\n pickle,\n testCase,\n gherkinDocument,\n },\n }\n worker.state = WorkerState.running\n worker.process.send(runCommand)\n }\n}\n"]}
|
package/lib/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "10.
|
|
1
|
+
export declare const version = "10.7.0";
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '10.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AACd,QAAA,OAAO,GAAG,QAAQ,CAAA","sourcesContent":["// Generated by genversion.\nexport const version = '10.7.0'\n"]}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"gherkin",
|
|
9
9
|
"tests"
|
|
10
10
|
],
|
|
11
|
-
"version": "10.
|
|
11
|
+
"version": "10.7.0",
|
|
12
12
|
"funding": "https://opencollective.com/cucumber",
|
|
13
13
|
"homepage": "https://github.com/cucumber/cucumber-js",
|
|
14
14
|
"author": "Julien Biezemans <jb@jbpros.com>",
|
|
@@ -164,6 +164,7 @@
|
|
|
164
164
|
"Tom V <tom@toc.com>",
|
|
165
165
|
"Tomer Ben-Rachel <tomerpacific@gmail.com>",
|
|
166
166
|
"Tristan Dunn <tristanzdunn@gmail.com>",
|
|
167
|
+
"Tristan Zander <tristan.zander@ncino.com>",
|
|
167
168
|
"unknown <jharlin@NormanDev2.telogical.com>",
|
|
168
169
|
"Valerio Innocenti Sedili <valerio.innocenti.ext@yoox.com>",
|
|
169
170
|
"Vasily Shelkov <vasilydshelkov@gmail.com>",
|
|
@@ -209,7 +210,7 @@
|
|
|
209
210
|
"node": "18 || >=20"
|
|
210
211
|
},
|
|
211
212
|
"enginesTested": {
|
|
212
|
-
"node": "18 || 20 || 21"
|
|
213
|
+
"node": "18 || 20 || 21 || 22"
|
|
213
214
|
},
|
|
214
215
|
"dependencies": {
|
|
215
216
|
"@cucumber/ci-environment": "10.0.1",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const node_stream_1 = require("node:stream");
|
|
7
|
-
const node_util_1 = require("node:util");
|
|
8
|
-
const resolve_pkg_1 = __importDefault(require("resolve-pkg"));
|
|
9
|
-
const html_formatter_1 = __importDefault(require("@cucumber/html-formatter"));
|
|
10
|
-
const _1 = __importDefault(require("."));
|
|
11
|
-
class HtmlFormatter extends _1.default {
|
|
12
|
-
_htmlStream;
|
|
13
|
-
static documentation = 'Outputs HTML report';
|
|
14
|
-
constructor(options) {
|
|
15
|
-
super(options);
|
|
16
|
-
this._htmlStream = new html_formatter_1.default((0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
17
|
-
'/dist/main.css', (0, resolve_pkg_1.default)('@cucumber/html-formatter', { cwd: __dirname }) +
|
|
18
|
-
'/dist/main.js');
|
|
19
|
-
options.eventBroadcaster.on('envelope', (envelope) => {
|
|
20
|
-
this._htmlStream.write(envelope);
|
|
21
|
-
});
|
|
22
|
-
this._htmlStream.on('data', (chunk) => this.log(chunk));
|
|
23
|
-
}
|
|
24
|
-
async finished() {
|
|
25
|
-
this._htmlStream.end();
|
|
26
|
-
await (0, node_util_1.promisify)(node_stream_1.finished)(this._htmlStream);
|
|
27
|
-
await super.finished();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.default = HtmlFormatter;
|
|
31
|
-
//# sourceMappingURL=html_formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html_formatter.js","sourceRoot":"","sources":["../../src/formatter/html_formatter.ts"],"names":[],"mappings":";;;;;AAAA,6CAAsC;AACtC,yCAAqC;AAErC,8DAAoC;AACpC,8EAAyD;AACzD,yCAAgD;AAEhD,MAAqB,aAAc,SAAQ,UAAS;IACjC,WAAW,CAAoB;IACzC,MAAM,CAAU,aAAa,GAAW,qBAAqB,CAAA;IAEpE,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAkB,CACvC,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,gBAAgB,EAClB,IAAA,qBAAU,EAAC,0BAA0B,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACxD,eAAe,CAClB,CAAA;QACD,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE;YACtE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACzD,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,IAAA,qBAAS,EAAC,sBAAQ,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC3C,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAA;IACxB,CAAC;;AAtBH,gCAuBC","sourcesContent":["import { finished } from 'node:stream'\nimport { promisify } from 'node:util'\nimport * as messages from '@cucumber/messages'\nimport resolvePkg from 'resolve-pkg'\nimport CucumberHtmlStream from '@cucumber/html-formatter'\nimport Formatter, { IFormatterOptions } from '.'\n\nexport default class HtmlFormatter extends Formatter {\n private readonly _htmlStream: CucumberHtmlStream\n public static readonly documentation: string = 'Outputs HTML report'\n\n constructor(options: IFormatterOptions) {\n super(options)\n this._htmlStream = new CucumberHtmlStream(\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.css',\n resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +\n '/dist/main.js'\n )\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {\n this._htmlStream.write(envelope)\n })\n this._htmlStream.on('data', (chunk) => this.log(chunk))\n }\n\n async finished(): Promise<void> {\n this._htmlStream.end()\n await promisify(finished)(this._htmlStream)\n await super.finished()\n }\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const _1 = __importDefault(require("."));
|
|
7
|
-
class MessageFormatter extends _1.default {
|
|
8
|
-
static documentation = 'Outputs protobuf messages';
|
|
9
|
-
constructor(options) {
|
|
10
|
-
super(options);
|
|
11
|
-
options.eventBroadcaster.on('envelope', (envelope) => this.log(JSON.stringify(envelope) + '\n'));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = MessageFormatter;
|
|
15
|
-
//# sourceMappingURL=message_formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"message_formatter.js","sourceRoot":"","sources":["../../src/formatter/message_formatter.ts"],"names":[],"mappings":";;;;;AACA,yCAAgD;AAEhD,MAAqB,gBAAiB,SAAQ,UAAS;IAC9C,MAAM,CAAU,aAAa,GAAW,2BAA2B,CAAA;IAC1E,YAAY,OAA0B;QACpC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAA2B,EAAE,EAAE,CACtE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,CAC1C,CAAA;IACH,CAAC;;AAPH,mCAQC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport Formatter, { IFormatterOptions } from '.'\n\nexport default class MessageFormatter extends Formatter {\n public static readonly documentation: string = 'Outputs protobuf messages'\n constructor(options: IFormatterOptions) {\n super(options)\n options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) =>\n this.log(JSON.stringify(envelope) + '\\n')\n )\n }\n}\n"]}
|