@cucumber/cucumber 7.3.2 → 8.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/lib/cli/argv_parser.d.ts +1 -2
- package/lib/cli/argv_parser.js +8 -12
- package/lib/cli/argv_parser.js.map +1 -1
- package/lib/cli/configuration_builder.d.ts +0 -1
- package/lib/cli/configuration_builder.js +18 -20
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +9 -4
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +6 -6
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +1 -1
- package/lib/cli/index.js +18 -20
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +3 -2
- package/lib/cli/profile_loader.js +17 -10
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/formatter/builder.d.ts +5 -4
- package/lib/formatter/builder.js +38 -52
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +2 -1
- package/lib/formatter/helpers/event_data_collector.js +6 -5
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/formatters.d.ts +6 -0
- package/lib/formatter/helpers/formatters.js +41 -0
- package/lib/formatter/helpers/formatters.js.map +1 -0
- package/lib/formatter/helpers/gherkin_document_parser.js +24 -37
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
- package/lib/formatter/helpers/issue_helpers.js +4 -5
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +1 -5
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js +8 -17
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +7 -6
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js +4 -7
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.js +21 -35
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.d.ts +1 -0
- package/lib/formatter/html_formatter.js +1 -0
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +1 -1
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +1 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -0
- package/lib/formatter/json_formatter.js +12 -7
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +1 -0
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +1 -0
- package/lib/formatter/progress_bar_formatter.js +2 -1
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +1 -0
- package/lib/formatter/progress_formatter.js +1 -0
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +11 -7
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.d.ts +1 -0
- package/lib/formatter/snippets_formatter.js +1 -0
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +3 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +1 -1
- package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +1 -0
- package/lib/formatter/summary_formatter.js +4 -4
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +3 -3
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.d.ts +1 -0
- package/lib/formatter/usage_json_formatter.js +1 -0
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/step_definition.js +1 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/pickle_filter.js +5 -5
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.js +2 -2
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -0
- package/lib/runtime/helpers.js +36 -1
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +0 -2
- package/lib/runtime/index.js +7 -41
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +0 -1
- package/lib/runtime/parallel/coordinator.js +11 -15
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.js +15 -7
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/step_runner.js +1 -3
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +3 -3
- package/lib/runtime/test_case_runner.js +13 -22
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/stack_trace_filter.js +4 -5
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/support_code_library_builder/build_helpers.js +14 -10
- package/lib/support_code_library_builder/build_helpers.js.map +1 -1
- package/lib/support_code_library_builder/index.js +0 -15
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +1 -0
- package/lib/support_code_library_builder/types.js.map +1 -1
- package/lib/support_code_library_builder/validate_arguments.js +14 -19
- package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
- package/lib/time.d.ts +1 -0
- package/lib/time.js +17 -2
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +7 -14
- package/lib/user_code_runner.js.map +1 -1
- package/lib/value_checker.d.ts +2 -2
- package/lib/value_checker.js.map +1 -1
- package/lib/wrapper.mjs +38 -0
- package/package.json +71 -63
- package/lib/support_code_library_builder/finalize_helpers.d.ts +0 -10
- package/lib/support_code_library_builder/finalize_helpers.js +0 -26
- package/lib/support_code_library_builder/finalize_helpers.js.map +0 -1
package/lib/cli/index.js
CHANGED
|
@@ -32,7 +32,6 @@ const builder_1 = __importDefault(require("../formatter/builder"));
|
|
|
32
32
|
const fs_1 = __importDefault(require("mz/fs"));
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
34
34
|
const pickle_filter_1 = __importDefault(require("../pickle_filter"));
|
|
35
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
36
35
|
const coordinator_1 = __importDefault(require("../runtime/parallel/coordinator"));
|
|
37
36
|
const runtime_1 = __importDefault(require("../runtime"));
|
|
38
37
|
const support_code_library_builder_1 = __importDefault(require("../support_code_library_builder"));
|
|
@@ -40,8 +39,12 @@ const messages_1 = require("@cucumber/messages");
|
|
|
40
39
|
const value_checker_1 = require("../value_checker");
|
|
41
40
|
const gherkin_streams_1 = require("@cucumber/gherkin-streams");
|
|
42
41
|
const http_stream_1 = __importDefault(require("../formatter/http_stream"));
|
|
42
|
+
const util_1 = require("util");
|
|
43
43
|
const stream_1 = require("stream");
|
|
44
|
-
const
|
|
44
|
+
const url_1 = require("url");
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
46
|
+
const { importer } = require('../importer');
|
|
47
|
+
const { uuid } = messages_1.IdGenerator;
|
|
45
48
|
class Cli {
|
|
46
49
|
constructor({ argv, cwd, stdout, }) {
|
|
47
50
|
this.argv = argv;
|
|
@@ -59,7 +62,7 @@ class Cli {
|
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
async initializeFormatters({ eventBroadcaster, eventDataCollector, formatOptions, formats, supportCodeLibrary, }) {
|
|
62
|
-
const formatters = await
|
|
65
|
+
const formatters = await Promise.all(formats.map(async ({ type, outputTo }) => {
|
|
63
66
|
let stream = this.stdout;
|
|
64
67
|
if (outputTo !== '') {
|
|
65
68
|
if (outputTo.match(/^https?:\/\//) !== null) {
|
|
@@ -95,7 +98,7 @@ class Cli {
|
|
|
95
98
|
stream,
|
|
96
99
|
cleanup: stream === this.stdout
|
|
97
100
|
? async () => await Promise.resolve()
|
|
98
|
-
:
|
|
101
|
+
: util_1.promisify(stream.end.bind(stream)),
|
|
99
102
|
supportCodeLibrary,
|
|
100
103
|
};
|
|
101
104
|
if (value_checker_1.doesNotHaveValue(formatOptions.colorsEnabled)) {
|
|
@@ -106,26 +109,23 @@ class Cli {
|
|
|
106
109
|
console.warn(`Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`);
|
|
107
110
|
type = 'progress';
|
|
108
111
|
}
|
|
109
|
-
return builder_1.default.build(type, typeOptions);
|
|
110
|
-
});
|
|
112
|
+
return await builder_1.default.build(type, typeOptions);
|
|
113
|
+
}));
|
|
111
114
|
return async function () {
|
|
112
|
-
await
|
|
113
|
-
await formatter.finished();
|
|
114
|
-
});
|
|
115
|
+
await Promise.all(formatters.map(async (f) => await f.finished()));
|
|
115
116
|
};
|
|
116
117
|
}
|
|
117
|
-
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
|
|
118
|
+
async getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
|
|
118
119
|
supportCodeRequiredModules.map((module) => require(module));
|
|
119
120
|
support_code_library_builder_1.default.reset(this.cwd, newId);
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
for (const codePath of supportCodePaths) {
|
|
122
|
+
if (supportCodeRequiredModules.length || !helpers_2.isJavaScript(codePath)) {
|
|
122
123
|
require(codePath);
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
console.error('codepath: ' + codePath);
|
|
125
|
+
else {
|
|
126
|
+
await importer(url_1.pathToFileURL(codePath));
|
|
127
127
|
}
|
|
128
|
-
}
|
|
128
|
+
}
|
|
129
129
|
return support_code_library_builder_1.default.finalize();
|
|
130
130
|
}
|
|
131
131
|
async run() {
|
|
@@ -139,10 +139,8 @@ class Cli {
|
|
|
139
139
|
this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor));
|
|
140
140
|
return { shouldExitImmediately: true, success: true };
|
|
141
141
|
}
|
|
142
|
-
const newId =
|
|
143
|
-
|
|
144
|
-
: uuid();
|
|
145
|
-
const supportCodeLibrary = this.getSupportCodeLibrary({
|
|
142
|
+
const newId = uuid();
|
|
143
|
+
const supportCodeLibrary = await this.getSupportCodeLibrary({
|
|
146
144
|
newId,
|
|
147
145
|
supportCodePaths: configuration.supportCodePaths,
|
|
148
146
|
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
package/lib/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AACzD,uCAKkB;AAClB,2DAAqD;AACrD,6CAA8B;AAC9B,oFAGgC;AAChC,mCAAqC;AACrC,mEAAmD;AACnD,+CAAsB;AACtB,gDAAuB;AACvB,qEAA2C;AAC3C,wDAA+B;AAC/B,kFAAwE;AACxE,yDAAgC;AAChC,mGAAuE;AACvE,iDAAgD;AAGhD,oDAAmD;AACnD,+DAA0D;AAG1D,2EAAiD;AACjD,mCAAiC;AAEjC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAqB1C,MA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AAA;QACf,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;YAC1D,OAAO;SACR,CAAA;IACH,CAAC;CACF;AA/MD,sBA+MC","sourcesContent":["import { EventDataCollector } from '../formatter/helpers'\nimport {\n emitMetaMessage,\n emitSupportCodeMessages,\n getExpandedArgv,\n parseGherkinMessageStream,\n} from './helpers'\nimport { validateInstall } from './install_validator'\nimport * as I18n from './i18n'\nimport ConfigurationBuilder, {\n IConfiguration,\n IConfigurationFormat,\n} from './configuration_builder'\nimport { EventEmitter } from 'events'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport PickleFilter from '../pickle_filter'\nimport bluebird from 'bluebird'\nimport ParallelRuntimeCoordinator from '../runtime/parallel/coordinator'\nimport Runtime from '../runtime'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IFormatterStream } from '../formatter'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { doesNotHaveValue } from '../value_checker'\nimport { GherkinStreams } from '@cucumber/gherkin-streams'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IParsedArgvFormatOptions } from './argv_parser'\nimport HttpStream from '../formatter/http_stream'\nimport { Writable } from 'stream'\n\nconst { incrementing, uuid } = IdGenerator\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\ninterface IInitializeFormattersRequest {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n formatOptions: IParsedArgvFormatOptions\n formats: IConfigurationFormat[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\ninterface IGetSupportCodeLibraryRequest {\n newId: IdGenerator.NewId\n supportCodeRequiredModules: string[]\n supportCodePaths: string[]\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n\n constructor({\n argv,\n cwd,\n stdout,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n }\n\n async getConfiguration(): Promise<IConfiguration> {\n const fullArgv = await getExpandedArgv({\n argv: this.argv,\n cwd: this.cwd,\n })\n return await ConfigurationBuilder.build({\n argv: fullArgv,\n cwd: this.cwd,\n })\n }\n\n async initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions,\n formats,\n supportCodeLibrary,\n }: IInitializeFormattersRequest): Promise<() => Promise<void>> {\n const formatters = await bluebird.map(\n formats,\n async ({ type, outputTo }) => {\n let stream: IFormatterStream = this.stdout\n if (outputTo !== '') {\n if (outputTo.match(/^https?:\\/\\//) !== null) {\n const headers: { [key: string]: string } = {}\n if (process.env.CUCUMBER_PUBLISH_TOKEN !== undefined) {\n headers.Authorization = `Bearer ${process.env.CUCUMBER_PUBLISH_TOKEN}`\n }\n\n stream = new HttpStream(outputTo, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n console.error(responseBody)\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n } else {\n const fd = await fs.open(path.resolve(this.cwd, outputTo), 'w')\n stream = fs.createWriteStream(null, { fd })\n }\n }\n\n stream.on('error', (error) => {\n console.error(error.message)\n process.exit(1)\n })\n\n const typeOptions = {\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: formatOptions,\n stream,\n cleanup:\n stream === this.stdout\n ? async () => await Promise.resolve()\n : bluebird.promisify(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (doesNotHaveValue(formatOptions.colorsEnabled)) {\n typeOptions.parsedArgvOptions.colorsEnabled = (\n stream as TtyWriteStream\n ).isTTY\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n const outputToName = outputTo === '' ? 'stdout' : outputTo\n console.warn(\n `Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return FormatterBuilder.build(type, typeOptions)\n }\n )\n return async function () {\n await bluebird.each(formatters, async (formatter) => {\n await formatter.finished()\n })\n }\n }\n\n getSupportCodeLibrary({\n newId,\n supportCodeRequiredModules,\n supportCodePaths,\n }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary {\n supportCodeRequiredModules.map((module) => require(module))\n supportCodeLibraryBuilder.reset(this.cwd, newId)\n supportCodePaths.forEach((codePath) => {\n try {\n require(codePath)\n } catch (e) {\n console.error(e.stack)\n console.error('codepath: ' + codePath)\n }\n })\n return supportCodeLibraryBuilder.finalize()\n }\n\n async run(): Promise<ICliRunResult> {\n await validateInstall(this.cwd)\n const configuration = await this.getConfiguration()\n if (configuration.listI18nLanguages) {\n this.stdout.write(I18n.getLanguages())\n return { shouldExitImmediately: true, success: true }\n }\n if (configuration.listI18nKeywordsFor !== '') {\n this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))\n return { shouldExitImmediately: true, success: true }\n }\n const newId =\n configuration.predictableIds && configuration.parallel <= 1\n ? incrementing()\n : uuid()\n const supportCodeLibrary = this.getSupportCodeLibrary({\n newId,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n const eventBroadcaster = new EventEmitter()\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n const cleanup = await this.initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions: configuration.formatOptions,\n formats: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster)\n const gherkinMessageStream = GherkinStreams.fromPaths(\n configuration.featurePaths,\n {\n defaultDialect: configuration.featureDefaultLanguage,\n newId,\n relativeTo: this.cwd,\n }\n )\n let pickleIds: string[] = []\n\n if (configuration.featurePaths.length > 0) {\n pickleIds = await parseGherkinMessageStream({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order: configuration.order,\n pickleFilter: new PickleFilter(configuration.pickleFilterOptions),\n })\n }\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n let success\n if (configuration.parallel > 1) {\n const parallelRuntimeCoordinator = new ParallelRuntimeCoordinator({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n success = await parallelRuntimeCoordinator.run(configuration.parallel)\n } else {\n const runtime = new Runtime({\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n })\n success = await runtime.start()\n }\n await cleanup()\n return {\n shouldExitImmediately: configuration.shouldExitImmediately,\n success,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAyD;AACzD,uCAMkB;AAClB,2DAAqD;AACrD,6CAA8B;AAC9B,oFAGgC;AAChC,mCAAqC;AACrC,mEAAmD;AACnD,+CAAsB;AACtB,gDAAuB;AACvB,qEAA2C;AAC3C,kFAAwE;AACxE,yDAAgC;AAChC,mGAAuE;AACvE,iDAAgD;AAGhD,oDAAmD;AACnD,+DAA0D;AAG1D,2EAAiD;AACjD,+BAAgC;AAChC,mCAAiC;AACjC,6BAAmC;AAEnC,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAC3C,MAAM,EAAE,IAAI,EAAE,GAAG,sBAAW,CAAA;AAqB5B,MAAqB,GAAG;IAKtB,YAAY,EACV,IAAI,EACJ,GAAG,EACH,MAAM,GAKP;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB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B,oBAAoB;gBACpB,KAAK,EAAE,aAAa,CAAC,KAAK;gBAC1B,YAAY,EAAE,IAAI,uBAAY,CAAC,aAAa,CAAC,mBAAmB,CAAC;aAClE,CAAC,CAAA;SACH;QACD,iCAAuB,CAAC;YACtB,gBAAgB;YAChB,kBAAkB;YAClB,KAAK;SACN,CAAC,CAAA;QACF,IAAI,OAAO,CAAA;QACX,IAAI,aAAa,CAAC,QAAQ,GAAG,CAAC,EAAE;YAC9B,MAAM,0BAA0B,GAAG,IAAI,qBAA0B,CAAC;gBAChE,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,gBAAgB;gBAChB,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,KAAK;gBACL,SAAS;gBACT,kBAAkB;gBAClB,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;gBAChD,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;aACrE,CAAC,CAAA;YACF,OAAO,GAAG,MAAM,0BAA0B,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;SACvE;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC;gBAC1B,gBAAgB;gBAChB,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,KAAK;gBACL,SAAS;gBACT,kBAAkB;aACnB,CAAC,CAAA;YACF,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;SAChC;QACD,MAAM,OAAO,EAAE,CAAA;QACf,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,qBAAqB;YAC1D,OAAO;SACR,CAAA;IACH,CAAC;CACF;AAxMD,sBAwMC","sourcesContent":["import { EventDataCollector } from '../formatter/helpers'\nimport {\n emitMetaMessage,\n emitSupportCodeMessages,\n getExpandedArgv,\n isJavaScript,\n parseGherkinMessageStream,\n} from './helpers'\nimport { validateInstall } from './install_validator'\nimport * as I18n from './i18n'\nimport ConfigurationBuilder, {\n IConfiguration,\n IConfigurationFormat,\n} from './configuration_builder'\nimport { EventEmitter } from 'events'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport PickleFilter from '../pickle_filter'\nimport ParallelRuntimeCoordinator from '../runtime/parallel/coordinator'\nimport Runtime from '../runtime'\nimport supportCodeLibraryBuilder from '../support_code_library_builder'\nimport { IdGenerator } from '@cucumber/messages'\nimport Formatter, { IFormatterStream } from '../formatter'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { doesNotHaveValue } from '../value_checker'\nimport { GherkinStreams } from '@cucumber/gherkin-streams'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { IParsedArgvFormatOptions } from './argv_parser'\nimport HttpStream from '../formatter/http_stream'\nimport { promisify } from 'util'\nimport { Writable } from 'stream'\nimport { pathToFileURL } from 'url'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\nconst { uuid } = IdGenerator\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\ninterface IInitializeFormattersRequest {\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n formatOptions: IParsedArgvFormatOptions\n formats: IConfigurationFormat[]\n supportCodeLibrary: ISupportCodeLibrary\n}\n\ninterface IGetSupportCodeLibraryRequest {\n newId: IdGenerator.NewId\n supportCodeRequiredModules: string[]\n supportCodePaths: string[]\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n\n constructor({\n argv,\n cwd,\n stdout,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n }\n\n async getConfiguration(): Promise<IConfiguration> {\n const fullArgv = await getExpandedArgv({\n argv: this.argv,\n cwd: this.cwd,\n })\n return await ConfigurationBuilder.build({\n argv: fullArgv,\n cwd: this.cwd,\n })\n }\n\n async initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions,\n formats,\n supportCodeLibrary,\n }: IInitializeFormattersRequest): Promise<() => Promise<void>> {\n const formatters: Formatter[] = await Promise.all(\n formats.map(async ({ type, outputTo }) => {\n let stream: IFormatterStream = this.stdout\n if (outputTo !== '') {\n if (outputTo.match(/^https?:\\/\\//) !== null) {\n const headers: { [key: string]: string } = {}\n if (process.env.CUCUMBER_PUBLISH_TOKEN !== undefined) {\n headers.Authorization = `Bearer ${process.env.CUCUMBER_PUBLISH_TOKEN}`\n }\n\n stream = new HttpStream(outputTo, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n console.error(responseBody)\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n } else {\n const fd = await fs.open(path.resolve(this.cwd, outputTo), 'w')\n stream = fs.createWriteStream(null, { fd })\n }\n }\n\n stream.on('error', (error) => {\n console.error(error.message)\n process.exit(1)\n })\n\n const typeOptions = {\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: formatOptions,\n stream,\n cleanup:\n stream === this.stdout\n ? async () => await Promise.resolve()\n : promisify<any>(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (doesNotHaveValue(formatOptions.colorsEnabled)) {\n typeOptions.parsedArgvOptions.colorsEnabled = (\n stream as TtyWriteStream\n ).isTTY\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n const outputToName = outputTo === '' ? 'stdout' : outputTo\n console.warn(\n `Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return await FormatterBuilder.build(type, typeOptions)\n })\n )\n return async function () {\n await Promise.all(formatters.map(async (f) => await f.finished()))\n }\n }\n\n async getSupportCodeLibrary({\n newId,\n supportCodeRequiredModules,\n supportCodePaths,\n }: IGetSupportCodeLibraryRequest): Promise<ISupportCodeLibrary> {\n supportCodeRequiredModules.map((module) => require(module))\n supportCodeLibraryBuilder.reset(this.cwd, newId)\n for (const codePath of supportCodePaths) {\n if (supportCodeRequiredModules.length || !isJavaScript(codePath)) {\n require(codePath)\n } else {\n await importer(pathToFileURL(codePath))\n }\n }\n return supportCodeLibraryBuilder.finalize()\n }\n\n async run(): Promise<ICliRunResult> {\n await validateInstall(this.cwd)\n const configuration = await this.getConfiguration()\n if (configuration.listI18nLanguages) {\n this.stdout.write(I18n.getLanguages())\n return { shouldExitImmediately: true, success: true }\n }\n if (configuration.listI18nKeywordsFor !== '') {\n this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor))\n return { shouldExitImmediately: true, success: true }\n }\n const newId = uuid()\n const supportCodeLibrary = await this.getSupportCodeLibrary({\n newId,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n const eventBroadcaster = new EventEmitter()\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n const cleanup = await this.initializeFormatters({\n eventBroadcaster,\n eventDataCollector,\n formatOptions: configuration.formatOptions,\n formats: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster)\n const gherkinMessageStream = GherkinStreams.fromPaths(\n configuration.featurePaths,\n {\n defaultDialect: configuration.featureDefaultLanguage,\n newId,\n relativeTo: this.cwd,\n }\n )\n let pickleIds: string[] = []\n\n if (configuration.featurePaths.length > 0) {\n pickleIds = await parseGherkinMessageStream({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order: configuration.order,\n pickleFilter: new PickleFilter(configuration.pickleFilterOptions),\n })\n }\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n let success\n if (configuration.parallel > 1) {\n const parallelRuntimeCoordinator = new ParallelRuntimeCoordinator({\n cwd: this.cwd,\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n success = await parallelRuntimeCoordinator.run(configuration.parallel)\n } else {\n const runtime = new Runtime({\n eventBroadcaster,\n eventDataCollector,\n options: configuration.runtimeOptions,\n newId,\n pickleIds,\n supportCodeLibrary,\n })\n success = await runtime.start()\n }\n await cleanup()\n return {\n shouldExitImmediately: configuration.shouldExitImmediately,\n success,\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default class ProfileLoader {
|
|
2
2
|
private readonly directory;
|
|
3
3
|
constructor(directory: string);
|
|
4
|
-
getDefinitions(): Promise<Record<string, string>>;
|
|
5
|
-
|
|
4
|
+
getDefinitions(configFile?: string): Promise<Record<string, string>>;
|
|
5
|
+
loadFile(configFile: string): Record<string, string>;
|
|
6
|
+
getArgv(profiles: string[], configFile?: string): Promise<string[]>;
|
|
6
7
|
}
|
|
@@ -3,29 +3,36 @@ 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 lodash_1 = __importDefault(require("lodash"));
|
|
7
6
|
const fs_1 = __importDefault(require("mz/fs"));
|
|
8
7
|
const path_1 = __importDefault(require("path"));
|
|
9
8
|
const string_argv_1 = __importDefault(require("string-argv"));
|
|
10
9
|
const value_checker_1 = require("../value_checker");
|
|
10
|
+
const DEFAULT_FILENAMES = ['cucumber.cjs', 'cucumber.js'];
|
|
11
11
|
class ProfileLoader {
|
|
12
12
|
constructor(directory) {
|
|
13
13
|
this.directory = directory;
|
|
14
14
|
}
|
|
15
|
-
async getDefinitions() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (!exists) {
|
|
19
|
-
return {};
|
|
15
|
+
async getDefinitions(configFile) {
|
|
16
|
+
if (configFile) {
|
|
17
|
+
return this.loadFile(configFile);
|
|
20
18
|
}
|
|
21
|
-
const
|
|
19
|
+
const defaultFile = DEFAULT_FILENAMES.find((filename) => fs_1.default.existsSync(path_1.default.join(this.directory, filename)));
|
|
20
|
+
if (defaultFile) {
|
|
21
|
+
return this.loadFile(defaultFile);
|
|
22
|
+
}
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
loadFile(configFile) {
|
|
26
|
+
const definitionsFilePath = path_1.default.join(this.directory, configFile);
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
28
|
+
const definitions = require(definitionsFilePath);
|
|
22
29
|
if (typeof definitions !== 'object') {
|
|
23
30
|
throw new Error(`${definitionsFilePath} does not export an object`);
|
|
24
31
|
}
|
|
25
32
|
return definitions;
|
|
26
33
|
}
|
|
27
|
-
async getArgv(profiles) {
|
|
28
|
-
const definitions = await this.getDefinitions();
|
|
34
|
+
async getArgv(profiles, configFile) {
|
|
35
|
+
const definitions = await this.getDefinitions(configFile);
|
|
29
36
|
if (profiles.length === 0 && value_checker_1.doesHaveValue(definitions.default)) {
|
|
30
37
|
profiles = ['default'];
|
|
31
38
|
}
|
|
@@ -35,7 +42,7 @@ class ProfileLoader {
|
|
|
35
42
|
}
|
|
36
43
|
return string_argv_1.default(definitions[profile]);
|
|
37
44
|
});
|
|
38
|
-
return
|
|
45
|
+
return argvs.flat();
|
|
39
46
|
}
|
|
40
47
|
}
|
|
41
48
|
exports.default = ProfileLoader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_loader.js","sourceRoot":"","sources":["../../src/cli/profile_loader.ts"],"names":[],"mappings":";;;;;AAAA
|
|
1
|
+
{"version":3,"file":"profile_loader.js","sourceRoot":"","sources":["../../src/cli/profile_loader.ts"],"names":[],"mappings":";;;;;AAAA,+CAAsB;AACtB,gDAAuB;AACvB,8DAAoC;AACpC,oDAAkE;AAElE,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,aAAa,CAAC,CAAA;AAEzD,MAAqB,aAAa;IAChC,YAA6B,SAAiB;QAAjB,cAAS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B,OAAO,EAAE,CAAC,CAAA;aACjD;YACD,OAAO,qBAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAA;QACzC,CAAC,CAAC,CAAA;QACF,OAAO,KAAK,CAAC,IAAI,EAAE,CAAA;IACrB,CAAC;CACF;AA1CD,gCA0CC","sourcesContent":["import fs from 'mz/fs'\nimport path from 'path'\nimport stringArgv from 'string-argv'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\n\nconst DEFAULT_FILENAMES = ['cucumber.cjs', 'cucumber.js']\n\nexport default class ProfileLoader {\n constructor(private readonly directory: string) {}\n\n async getDefinitions(configFile?: string): Promise<Record<string, string>> {\n if (configFile) {\n return this.loadFile(configFile)\n }\n\n const defaultFile = DEFAULT_FILENAMES.find((filename) =>\n fs.existsSync(path.join(this.directory, filename))\n )\n\n if (defaultFile) {\n return this.loadFile(defaultFile)\n }\n\n return {}\n }\n\n loadFile(configFile: string): Record<string, string> {\n const definitionsFilePath: string = path.join(this.directory, configFile)\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const definitions = require(definitionsFilePath)\n if (typeof definitions !== 'object') {\n throw new Error(`${definitionsFilePath} does not export an object`)\n }\n return definitions\n }\n\n async getArgv(profiles: string[], configFile?: string): Promise<string[]> {\n const definitions = await this.getDefinitions(configFile)\n if (profiles.length === 0 && doesHaveValue(definitions.default)) {\n profiles = ['default']\n }\n const argvs = profiles.map((profile) => {\n if (doesNotHaveValue(definitions[profile])) {\n throw new Error(`Undefined profile: ${profile}`)\n }\n return stringArgv(definitions[profile])\n })\n return argvs.flat()\n }\n}\n"]}
|
|
@@ -24,9 +24,10 @@ export interface IBuildOptions {
|
|
|
24
24
|
supportCodeLibrary: ISupportCodeLibrary;
|
|
25
25
|
}
|
|
26
26
|
declare const FormatterBuilder: {
|
|
27
|
-
build(type: string, options: IBuildOptions): Formatter
|
|
28
|
-
getConstructorByType(type: string, cwd: string): typeof Formatter
|
|
29
|
-
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): StepDefinitionSnippetBuilder
|
|
30
|
-
|
|
27
|
+
build(type: string, options: IBuildOptions): Promise<Formatter>;
|
|
28
|
+
getConstructorByType(type: string, cwd: string): Promise<typeof Formatter>;
|
|
29
|
+
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }: IGetStepDefinitionSnippetBuilderOptions): Promise<StepDefinitionSnippetBuilder>;
|
|
30
|
+
loadCustomClass(type: 'formatter' | 'syntax', descriptor: string, cwd: string): Promise<any>;
|
|
31
|
+
resolveConstructor(ImportedCode: any): any;
|
|
31
32
|
};
|
|
32
33
|
export default FormatterBuilder;
|
package/lib/formatter/builder.js
CHANGED
|
@@ -5,84 +5,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const get_color_fns_1 = __importDefault(require("./get_color_fns"));
|
|
7
7
|
const javascript_snippet_syntax_1 = __importDefault(require("./step_definition_snippet_builder/javascript_snippet_syntax"));
|
|
8
|
-
const json_formatter_1 = __importDefault(require("./json_formatter"));
|
|
9
|
-
const message_formatter_1 = __importDefault(require("./message_formatter"));
|
|
10
8
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const progress_bar_formatter_1 = __importDefault(require("./progress_bar_formatter"));
|
|
12
|
-
const progress_formatter_1 = __importDefault(require("./progress_formatter"));
|
|
13
|
-
const rerun_formatter_1 = __importDefault(require("./rerun_formatter"));
|
|
14
|
-
const snippets_formatter_1 = __importDefault(require("./snippets_formatter"));
|
|
15
9
|
const step_definition_snippet_builder_1 = __importDefault(require("./step_definition_snippet_builder"));
|
|
16
|
-
const summary_formatter_1 = __importDefault(require("./summary_formatter"));
|
|
17
|
-
const usage_formatter_1 = __importDefault(require("./usage_formatter"));
|
|
18
|
-
const usage_json_formatter_1 = __importDefault(require("./usage_json_formatter"));
|
|
19
10
|
const value_checker_1 = require("../value_checker");
|
|
20
11
|
const snippet_syntax_1 = require("./step_definition_snippet_builder/snippet_syntax");
|
|
21
|
-
const
|
|
22
|
-
const
|
|
12
|
+
const url_1 = require("url");
|
|
13
|
+
const formatters_1 = __importDefault(require("./helpers/formatters"));
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
15
|
+
const { importer } = require('../importer');
|
|
23
16
|
const FormatterBuilder = {
|
|
24
|
-
build(type, options) {
|
|
25
|
-
const FormatterConstructor = FormatterBuilder.getConstructorByType(type, options.cwd);
|
|
17
|
+
async build(type, options) {
|
|
18
|
+
const FormatterConstructor = await FormatterBuilder.getConstructorByType(type, options.cwd);
|
|
26
19
|
const colorFns = get_color_fns_1.default(options.parsedArgvOptions.colorsEnabled);
|
|
27
|
-
const snippetBuilder = FormatterBuilder.getStepDefinitionSnippetBuilder({
|
|
20
|
+
const snippetBuilder = await FormatterBuilder.getStepDefinitionSnippetBuilder({
|
|
28
21
|
cwd: options.cwd,
|
|
29
22
|
snippetInterface: options.parsedArgvOptions.snippetInterface,
|
|
30
23
|
snippetSyntax: options.parsedArgvOptions.snippetSyntax,
|
|
31
24
|
supportCodeLibrary: options.supportCodeLibrary,
|
|
32
25
|
});
|
|
33
|
-
return new FormatterConstructor(
|
|
34
|
-
|
|
26
|
+
return new FormatterConstructor({
|
|
27
|
+
colorFns,
|
|
28
|
+
snippetBuilder,
|
|
29
|
+
...options,
|
|
30
|
+
});
|
|
35
31
|
},
|
|
36
|
-
getConstructorByType(type, cwd) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return message_formatter_1.default;
|
|
42
|
-
case 'html':
|
|
43
|
-
return html_formatter_1.default;
|
|
44
|
-
case 'progress':
|
|
45
|
-
return progress_formatter_1.default;
|
|
46
|
-
case 'progress-bar':
|
|
47
|
-
return progress_bar_formatter_1.default;
|
|
48
|
-
case 'rerun':
|
|
49
|
-
return rerun_formatter_1.default;
|
|
50
|
-
case 'snippets':
|
|
51
|
-
return snippets_formatter_1.default;
|
|
52
|
-
case 'summary':
|
|
53
|
-
return summary_formatter_1.default;
|
|
54
|
-
case 'usage':
|
|
55
|
-
return usage_formatter_1.default;
|
|
56
|
-
case 'usage-json':
|
|
57
|
-
return usage_json_formatter_1.default;
|
|
58
|
-
default:
|
|
59
|
-
return FormatterBuilder.loadCustomFormatter(type, cwd);
|
|
60
|
-
}
|
|
32
|
+
async getConstructorByType(type, cwd) {
|
|
33
|
+
const formatters = formatters_1.default.getFormatters();
|
|
34
|
+
return formatters[type]
|
|
35
|
+
? formatters[type]
|
|
36
|
+
: await FormatterBuilder.loadCustomClass('formatter', type, cwd);
|
|
61
37
|
},
|
|
62
|
-
getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }) {
|
|
38
|
+
async getStepDefinitionSnippetBuilder({ cwd, snippetInterface, snippetSyntax, supportCodeLibrary, }) {
|
|
63
39
|
if (value_checker_1.doesNotHaveValue(snippetInterface)) {
|
|
64
40
|
snippetInterface = snippet_syntax_1.SnippetInterface.Synchronous;
|
|
65
41
|
}
|
|
66
42
|
let Syntax = javascript_snippet_syntax_1.default;
|
|
67
43
|
if (value_checker_1.doesHaveValue(snippetSyntax)) {
|
|
68
|
-
|
|
69
|
-
Syntax = require(fullSyntaxPath); // eslint-disable-line @typescript-eslint/no-var-requires
|
|
44
|
+
Syntax = await FormatterBuilder.loadCustomClass('syntax', snippetSyntax, cwd);
|
|
70
45
|
}
|
|
71
46
|
return new step_definition_snippet_builder_1.default({
|
|
72
47
|
snippetSyntax: new Syntax(snippetInterface),
|
|
73
48
|
parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,
|
|
74
49
|
});
|
|
75
50
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
51
|
+
async loadCustomClass(type, descriptor, cwd) {
|
|
52
|
+
let CustomClass = descriptor.startsWith(`.`)
|
|
53
|
+
? await importer(url_1.pathToFileURL(path_1.default.resolve(cwd, descriptor)))
|
|
54
|
+
: await importer(descriptor);
|
|
55
|
+
CustomClass = FormatterBuilder.resolveConstructor(CustomClass);
|
|
56
|
+
if (value_checker_1.doesHaveValue(CustomClass)) {
|
|
57
|
+
return CustomClass;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
throw new Error(`Custom ${type} (${descriptor}) does not export a function/class`);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
resolveConstructor(ImportedCode) {
|
|
64
|
+
if (typeof ImportedCode === 'function') {
|
|
65
|
+
return ImportedCode;
|
|
80
66
|
}
|
|
81
|
-
else if (value_checker_1.doesHaveValue(
|
|
82
|
-
typeof
|
|
83
|
-
return
|
|
67
|
+
else if (value_checker_1.doesHaveValue(ImportedCode) &&
|
|
68
|
+
typeof ImportedCode.default === 'function') {
|
|
69
|
+
return ImportedCode.default;
|
|
84
70
|
}
|
|
85
|
-
|
|
71
|
+
return null;
|
|
86
72
|
},
|
|
87
73
|
};
|
|
88
74
|
exports.default = FormatterBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAG5E,oDAAkE;AAKlE,qFAAmF;AACnF,6BAAmC;AACnC,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAoB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAC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3C,qBAAqB,EAAE,kBAAkB,CAAC,qBAAqB;SAChE,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA4B,EAC5B,UAAkB,EAClB,GAAW;QAEX,IAAI,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;YAC1C,CAAC,CAAC,MAAM,QAAQ,CAAC,mBAAa,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAA;QAC9B,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;QAC9D,IAAI,6BAAa,CAAC,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,kBAAkB,CAAC,YAAiB;QAClC,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,6BAAa,CAAC,YAAY,CAAC;YAC3B,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import getColorFns from './get_color_fns'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, { IFormatterCleanupFn, IFormatterLogFn } from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { IParsedArgvFormatOptions } from '../cli/argv_parser'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: IParsedArgvFormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(options.parsedArgvOptions.colorsEnabled)\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 let CustomClass = descriptor.startsWith(`.`)\n ? await importer(pathToFileURL(path.resolve(cwd, descriptor)))\n : await importer(descriptor)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\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 resolveConstructor(ImportedCode: any) {\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n doesHaveValue(ImportedCode) &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
|
|
@@ -3,6 +3,7 @@ import * as messages from '@cucumber/messages';
|
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
export interface ITestCaseAttempt {
|
|
5
5
|
attempt: number;
|
|
6
|
+
willBeRetried: boolean;
|
|
6
7
|
gherkinDocument: messages.GherkinDocument;
|
|
7
8
|
pickle: messages.Pickle;
|
|
8
9
|
stepAttachments: Record<string, messages.Attachment[]>;
|
|
@@ -25,5 +26,5 @@ export default class EventDataCollector {
|
|
|
25
26
|
private initTestCaseAttempt;
|
|
26
27
|
storeAttachment(attachment: messages.Attachment): void;
|
|
27
28
|
storeTestStepResult({ testCaseStartedId, testStepId, testStepResult, }: messages.TestStepFinished): void;
|
|
28
|
-
storeTestCaseResult({ testCaseStartedId }: messages.TestCaseFinished): void;
|
|
29
|
+
storeTestCaseResult({ testCaseStartedId, willBeRetried, }: messages.TestCaseFinished): void;
|
|
29
30
|
}
|
|
@@ -19,7 +19,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const lodash_1 = __importStar(require("lodash"));
|
|
23
22
|
const messages = __importStar(require("@cucumber/messages"));
|
|
24
23
|
const value_checker_1 = require("../../value_checker");
|
|
25
24
|
class EventDataCollector {
|
|
@@ -38,7 +37,7 @@ class EventDataCollector {
|
|
|
38
37
|
return this.pickleMap[pickleId];
|
|
39
38
|
}
|
|
40
39
|
getTestCaseAttempts() {
|
|
41
|
-
return
|
|
40
|
+
return Object.keys(this.testCaseAttemptDataMap).map((testCaseStartedId) => {
|
|
42
41
|
return this.getTestCaseAttempt(testCaseStartedId);
|
|
43
42
|
});
|
|
44
43
|
}
|
|
@@ -51,6 +50,7 @@ class EventDataCollector {
|
|
|
51
50
|
pickle,
|
|
52
51
|
testCase,
|
|
53
52
|
attempt: testCaseAttemptData.attempt,
|
|
53
|
+
willBeRetried: testCaseAttemptData.willBeRetried,
|
|
54
54
|
stepAttachments: testCaseAttemptData.stepAttachments,
|
|
55
55
|
stepResults: testCaseAttemptData.stepResults,
|
|
56
56
|
worstTestStepResult: testCaseAttemptData.worstTestStepResult,
|
|
@@ -86,11 +86,11 @@ class EventDataCollector {
|
|
|
86
86
|
initTestCaseAttempt(testCaseStarted) {
|
|
87
87
|
this.testCaseAttemptDataMap[testCaseStarted.id] = {
|
|
88
88
|
attempt: testCaseStarted.attempt,
|
|
89
|
+
willBeRetried: false,
|
|
89
90
|
testCaseId: testCaseStarted.testCaseId,
|
|
90
91
|
stepAttachments: {},
|
|
91
92
|
stepResults: {},
|
|
92
93
|
worstTestStepResult: {
|
|
93
|
-
willBeRetried: false,
|
|
94
94
|
duration: { seconds: 0, nanos: 0 },
|
|
95
95
|
status: messages.TestStepResultStatus.UNKNOWN,
|
|
96
96
|
},
|
|
@@ -111,10 +111,11 @@ class EventDataCollector {
|
|
|
111
111
|
this.testCaseAttemptDataMap[testCaseStartedId].stepResults[testStepId] =
|
|
112
112
|
testStepResult;
|
|
113
113
|
}
|
|
114
|
-
storeTestCaseResult({ testCaseStartedId }) {
|
|
115
|
-
const stepResults =
|
|
114
|
+
storeTestCaseResult({ testCaseStartedId, willBeRetried, }) {
|
|
115
|
+
const stepResults = Object.values(this.testCaseAttemptDataMap[testCaseStartedId].stepResults);
|
|
116
116
|
this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult =
|
|
117
117
|
messages.getWorstTestStepResult(stepResults);
|
|
118
|
+
this.testCaseAttemptDataMap[testCaseStartedId].willBeRetried = willBeRetried;
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
exports.default = EventDataCollector;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event_data_collector.js","sourceRoot":"","sources":["../../../src/formatter/helpers/event_data_collector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"event_data_collector.js","sourceRoot":"","sources":["../../../src/formatter/helpers/event_data_collector.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6DAA8C;AAC9C,uDAAqE;AAuBrE,MAAqB,kBAAkB;IAOrC,YAAY,gBAA8B;QANlC,uBAAkB,GAA6C,EAAE,CAAA;QACjE,cAAS,GAAoC,EAAE,CAAA;QAC/C,gBAAW,GAAsC,EAAE,CAAA;QACnD,2BAAsB,GAAyC,EAAE,CAAA;QAChE,4BAAuB,GAAsC,EAAE,CAAA;QAGtE,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAChE,CAAC;IAED,kBAAkB,CAAC,GAAW;QAC5B,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;IAED,SAAS,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;IAED,mBAAmB;QACjB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC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Aa,CAAC,iBAAiB,CAAC,IAAI,6BAAa,CAAC,UAAU,CAAC,EAAE;YACjE,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAA;YAC1E,IAAI,gCAAgB,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,EAAE;gBACjD,eAAe,CAAC,UAAU,CAAC,GAAG,EAAE,CAAA;aACjC;YACD,eAAe,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;SAC7C;IACH,CAAC;IAED,mBAAmB,CAAC,EAClB,iBAAiB,EACjB,UAAU,EACV,cAAc,GACY;QAC1B,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,WAAW,CAAC,UAAU,CAAC;YACpE,cAAc,CAAA;IAClB,CAAC;IAED,mBAAmB,CAAC,EAClB,iBAAiB,EACjB,aAAa,GACa;QAC1B,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAC/B,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,WAAW,CAC3D,CAAA;QACD,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,mBAAmB;YAChE,QAAQ,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAA;QAC9C,IAAI,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC,aAAa,GAAG,aAAa,CAAA;IAC9E,CAAC;CACF;AA5GD,qCA4GC","sourcesContent":["import * as messages from '@cucumber/messages'\nimport { doesHaveValue, doesNotHaveValue } from '../../value_checker'\nimport { EventEmitter } from 'events'\n\ninterface ITestCaseAttemptData {\n attempt: number\n willBeRetried: boolean\n testCaseId: string\n stepAttachments: Record<string, messages.Attachment[]>\n stepResults: Record<string, messages.TestStepResult>\n worstTestStepResult: messages.TestStepResult\n}\n\nexport interface ITestCaseAttempt {\n attempt: number\n willBeRetried: boolean\n gherkinDocument: messages.GherkinDocument\n pickle: messages.Pickle\n stepAttachments: Record<string, messages.Attachment[]>\n stepResults: Record<string, messages.TestStepResult>\n testCase: messages.TestCase\n worstTestStepResult: messages.TestStepResult\n}\n\nexport default class EventDataCollector {\n private gherkinDocumentMap: Record<string, messages.GherkinDocument> = {}\n private pickleMap: Record<string, messages.Pickle> = {}\n private testCaseMap: Record<string, messages.TestCase> = {}\n private testCaseAttemptDataMap: Record<string, ITestCaseAttemptData> = {}\n readonly undefinedParameterTypes: messages.UndefinedParameterType[] = []\n\n constructor(eventBroadcaster: EventEmitter) {\n eventBroadcaster.on('envelope', this.parseEnvelope.bind(this))\n }\n\n getGherkinDocument(uri: string): messages.GherkinDocument {\n return this.gherkinDocumentMap[uri]\n }\n\n getPickle(pickleId: string): messages.Pickle {\n return this.pickleMap[pickleId]\n }\n\n getTestCaseAttempts(): ITestCaseAttempt[] {\n return Object.keys(this.testCaseAttemptDataMap).map((testCaseStartedId) => {\n return this.getTestCaseAttempt(testCaseStartedId)\n })\n }\n\n getTestCaseAttempt(testCaseStartedId: string): ITestCaseAttempt {\n const testCaseAttemptData = this.testCaseAttemptDataMap[testCaseStartedId]\n const testCase = this.testCaseMap[testCaseAttemptData.testCaseId]\n const pickle = this.pickleMap[testCase.pickleId]\n return {\n gherkinDocument: this.gherkinDocumentMap[pickle.uri],\n pickle,\n testCase,\n attempt: testCaseAttemptData.attempt,\n willBeRetried: testCaseAttemptData.willBeRetried,\n stepAttachments: testCaseAttemptData.stepAttachments,\n stepResults: testCaseAttemptData.stepResults,\n worstTestStepResult: testCaseAttemptData.worstTestStepResult,\n }\n }\n\n parseEnvelope(envelope: messages.Envelope): void {\n if (doesHaveValue(envelope.gherkinDocument)) {\n this.gherkinDocumentMap[envelope.gherkinDocument.uri] =\n envelope.gherkinDocument\n } else if (doesHaveValue(envelope.pickle)) {\n this.pickleMap[envelope.pickle.id] = envelope.pickle\n } else if (doesHaveValue(envelope.undefinedParameterType)) {\n this.undefinedParameterTypes.push(envelope.undefinedParameterType)\n } else if (doesHaveValue(envelope.testCase)) {\n this.testCaseMap[envelope.testCase.id] = envelope.testCase\n } else if (doesHaveValue(envelope.testCaseStarted)) {\n this.initTestCaseAttempt(envelope.testCaseStarted)\n } else if (doesHaveValue(envelope.attachment)) {\n this.storeAttachment(envelope.attachment)\n } else if (doesHaveValue(envelope.testStepFinished)) {\n this.storeTestStepResult(envelope.testStepFinished)\n } else if (doesHaveValue(envelope.testCaseFinished)) {\n this.storeTestCaseResult(envelope.testCaseFinished)\n }\n }\n\n private initTestCaseAttempt(testCaseStarted: messages.TestCaseStarted): void {\n this.testCaseAttemptDataMap[testCaseStarted.id] = {\n attempt: testCaseStarted.attempt,\n willBeRetried: false,\n testCaseId: testCaseStarted.testCaseId,\n stepAttachments: {},\n stepResults: {},\n worstTestStepResult: {\n duration: { seconds: 0, nanos: 0 },\n status: messages.TestStepResultStatus.UNKNOWN,\n },\n }\n }\n\n storeAttachment(attachment: messages.Attachment): void {\n const { testCaseStartedId, testStepId } = attachment\n // TODO: we shouldn't have to check if these properties have values - they are non-nullable\n if (doesHaveValue(testCaseStartedId) && doesHaveValue(testStepId)) {\n const { stepAttachments } = this.testCaseAttemptDataMap[testCaseStartedId]\n if (doesNotHaveValue(stepAttachments[testStepId])) {\n stepAttachments[testStepId] = []\n }\n stepAttachments[testStepId].push(attachment)\n }\n }\n\n storeTestStepResult({\n testCaseStartedId,\n testStepId,\n testStepResult,\n }: messages.TestStepFinished): void {\n this.testCaseAttemptDataMap[testCaseStartedId].stepResults[testStepId] =\n testStepResult\n }\n\n storeTestCaseResult({\n testCaseStartedId,\n willBeRetried,\n }: messages.TestCaseFinished): void {\n const stepResults = Object.values(\n this.testCaseAttemptDataMap[testCaseStartedId].stepResults\n )\n this.testCaseAttemptDataMap[testCaseStartedId].worstTestStepResult =\n messages.getWorstTestStepResult(stepResults)\n this.testCaseAttemptDataMap[testCaseStartedId].willBeRetried = willBeRetried\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 message_formatter_1 = __importDefault(require("../message_formatter"));
|
|
8
|
+
const progress_bar_formatter_1 = __importDefault(require("../progress_bar_formatter"));
|
|
9
|
+
const progress_formatter_1 = __importDefault(require("../progress_formatter"));
|
|
10
|
+
const rerun_formatter_1 = __importDefault(require("../rerun_formatter"));
|
|
11
|
+
const snippets_formatter_1 = __importDefault(require("../snippets_formatter"));
|
|
12
|
+
const summary_formatter_1 = __importDefault(require("../summary_formatter"));
|
|
13
|
+
const usage_formatter_1 = __importDefault(require("../usage_formatter"));
|
|
14
|
+
const usage_json_formatter_1 = __importDefault(require("../usage_json_formatter"));
|
|
15
|
+
const html_formatter_1 = __importDefault(require("../html_formatter"));
|
|
16
|
+
const Formatters = {
|
|
17
|
+
getFormatters() {
|
|
18
|
+
return {
|
|
19
|
+
json: json_formatter_1.default,
|
|
20
|
+
message: message_formatter_1.default,
|
|
21
|
+
html: html_formatter_1.default,
|
|
22
|
+
progress: progress_formatter_1.default,
|
|
23
|
+
'progress-bar': progress_bar_formatter_1.default,
|
|
24
|
+
rerun: rerun_formatter_1.default,
|
|
25
|
+
snippets: snippets_formatter_1.default,
|
|
26
|
+
summary: summary_formatter_1.default,
|
|
27
|
+
usage: usage_formatter_1.default,
|
|
28
|
+
'usage-json': usage_json_formatter_1.default,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
buildFormattersDocumentationString() {
|
|
32
|
+
let concatanatedFormattersDocumentation = '';
|
|
33
|
+
const formatters = this.getFormatters();
|
|
34
|
+
for (const formatterName in formatters) {
|
|
35
|
+
concatanatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\n`;
|
|
36
|
+
}
|
|
37
|
+
return concatanatedFormattersDocumentation;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
exports.default = Formatters;
|
|
41
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/formatter/helpers/formatters.ts"],"names":[],"mappings":";;;;;AACA,uEAA6C;AAC7C,6EAAmD;AACnD,uFAA4D;AAC5D,+EAAqD;AACrD,yEAA+C;AAC/C,+EAAqD;AACrD,6EAAmD;AACnD,yEAA+C;AAC/C,mFAAwD;AACxD,uEAA6C;AAE7C,MAAM,UAAU,GAAG;IACjB,aAAa;QACX,OAAO;YACL,IAAI,EAAE,wBAAa;YACnB,OAAO,EAAE,2BAAgB;YACzB,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;SACjC,CAAA;IACH,CAAC;IACD,kCAAkC;QAChC,IAAI,mCAAmC,GAAW,EAAE,CAAA;QACpD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACvC,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE;YACtC,mCAAmC,IAAI,OAAO,aAAa,KAAK,UAAU,CAAC,aAAa,CAAC,CAAC,aAAa,IAAI,CAAA;SAC5G;QAED,OAAO,mCAAmC,CAAA;IAC5C,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import Formatter from '../.'\nimport JsonFormatter from '../json_formatter'\nimport MessageFormatter from '../message_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 HtmlFormatter from '../html_formatter'\n\nconst Formatters = {\n getFormatters(): Record<string, typeof Formatter> {\n return {\n json: JsonFormatter,\n message: MessageFormatter,\n html: HtmlFormatter,\n progress: ProgressFormatter,\n 'progress-bar': ProgressBarFormatter,\n rerun: RerunFormatter,\n snippets: SnippetsFormatter,\n summary: SummaryFormatter,\n usage: UsageFormatter,\n 'usage-json': UsageJsonFormatter,\n }\n },\n buildFormattersDocumentationString(): string {\n let concatanatedFormattersDocumentation: string = ''\n const formatters = this.getFormatters()\n for (const formatterName in formatters) {\n concatanatedFormattersDocumentation += ` ${formatterName}: ${formatters[formatterName].documentation}\\n`\n }\n\n return concatanatedFormattersDocumentation\n },\n}\n\nexport default Formatters\n"]}
|