@cucumber/cucumber 7.2.1 → 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 +20 -21
- package/lib/cli/configuration_builder.js.map +1 -1
- package/lib/cli/helpers.d.ts +1 -0
- package/lib/cli/helpers.js +49 -22
- 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 +35 -29
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/profile_loader.d.ts +3 -3
- package/lib/cli/profile_loader.js +17 -10
- package/lib/cli/profile_loader.js.map +1 -1
- package/lib/cli/publish_banner.js +1 -1
- package/lib/cli/publish_banner.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/get_color_fns.d.ts +6 -2
- package/lib/formatter/get_color_fns.js +18 -12
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +15 -17
- package/lib/formatter/helpers/event_data_collector.js +19 -12
- 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.d.ts +5 -6
- package/lib/formatter/helpers/gherkin_document_parser.js +24 -40
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +6 -6
- package/lib/formatter/helpers/issue_helpers.js +6 -8
- 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.d.ts +9 -10
- package/lib/formatter/helpers/pickle_parser.js +8 -17
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -2
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +2 -2
- package/lib/formatter/helpers/summary_helpers.js +39 -20
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +34 -15
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +5 -5
- package/lib/formatter/helpers/test_case_attempt_parser.js +30 -15
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +3 -3
- package/lib/formatter/helpers/usage_helpers/index.js +48 -45
- 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 +2 -1
- 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 +22 -27
- package/lib/formatter/json_formatter.js +62 -30
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.d.ts +1 -0
- package/lib/formatter/message_formatter.js +2 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +7 -6
- package/lib/formatter/progress_bar_formatter.js +5 -4
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +3 -2
- package/lib/formatter/progress_formatter.js +30 -10
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +33 -11
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.d.ts +1 -0
- package/lib/formatter/snippets_formatter.js +22 -2
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +3 -3
- package/lib/formatter/step_definition_snippet_builder/index.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 +3 -2
- 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 +24 -5
- 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 +15 -12
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.d.ts +3 -4
- package/lib/models/data_table.js +9 -7
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +2 -2
- package/lib/models/definition.js.map +1 -1
- package/lib/models/step_definition.js +1 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +2 -2
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +2 -2
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.d.ts +9 -11
- package/lib/pickle_filter.js +9 -9
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +13 -0
- package/lib/runtime/assemble_test_cases.js +88 -0
- package/lib/runtime/assemble_test_cases.js.map +1 -0
- package/lib/runtime/attachment_manager/index.d.ts +2 -2
- package/lib/runtime/attachment_manager/index.js +23 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +3 -2
- package/lib/runtime/helpers.js +36 -1
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +3 -4
- package/lib/runtime/index.js +27 -43
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +10 -9
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +9 -9
- package/lib/runtime/parallel/coordinator.js +62 -55
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -2
- package/lib/runtime/parallel/worker.js +23 -21
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/step_runner.d.ts +3 -3
- package/lib/runtime/step_runner.js +16 -14
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.d.ts +4 -4
- package/lib/runtime/stopwatch.js +21 -2
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +51 -0
- package/lib/runtime/test_case_runner.js +253 -0
- package/lib/runtime/test_case_runner.js.map +1 -0
- package/lib/stack_trace_filter.js +4 -5
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.d.ts +4 -4
- package/lib/step_arguments.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.d.ts +9 -7
- package/lib/support_code_library_builder/index.js +10 -24
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/types.d.ts +22 -23
- 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/support_code_library_builder/world.d.ts +7 -1
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +3 -10
- package/lib/time.js +39 -48
- 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 +73 -64
- package/CHANGELOG.md +0 -1881
- package/lib/runtime/pickle_runner.d.ts +0 -67
- package/lib/runtime/pickle_runner.js +0 -305
- package/lib/runtime/pickle_runner.js.map +0 -1
- package/lib/status.d.ts +0 -3
- package/lib/status.js +0 -5
- package/lib/status.js.map +0 -1
- 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/i18n.js
CHANGED
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getKeywords = exports.getLanguages = void 0;
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
7
|
const gherkin_1 = require("@cucumber/gherkin");
|
|
9
8
|
const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
10
9
|
const capital_case_1 = require("capital-case");
|
|
11
10
|
const keywords = [
|
|
12
11
|
'feature',
|
|
12
|
+
'rule',
|
|
13
13
|
'background',
|
|
14
14
|
'scenario',
|
|
15
15
|
'scenarioOutline',
|
|
@@ -50,18 +50,18 @@ function getAsTable(header, rows) {
|
|
|
50
50
|
return table.toString();
|
|
51
51
|
}
|
|
52
52
|
function getLanguages() {
|
|
53
|
-
const rows =
|
|
53
|
+
const rows = Object.keys(gherkin_1.dialects).map((isoCode) => [
|
|
54
54
|
isoCode,
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
gherkin_1.dialects[isoCode].name,
|
|
56
|
+
gherkin_1.dialects[isoCode].native,
|
|
57
57
|
]);
|
|
58
58
|
return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows);
|
|
59
59
|
}
|
|
60
60
|
exports.getLanguages = getLanguages;
|
|
61
61
|
function getKeywords(isoCode) {
|
|
62
62
|
const language = gherkin_1.dialects[isoCode];
|
|
63
|
-
const rows =
|
|
64
|
-
const words =
|
|
63
|
+
const rows = keywords.map((keyword) => {
|
|
64
|
+
const words = language[keyword].map((s) => `"${s}"`).join(', ');
|
|
65
65
|
return [capital_case_1.capitalCase(keyword), words];
|
|
66
66
|
});
|
|
67
67
|
return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows);
|
package/lib/cli/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/cli/i18n.ts"],"names":[],"mappings":";;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../../src/cli/i18n.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA4C;AAC5C,4DAA8B;AAC9B,+CAA0C;AAE1C,MAAM,QAAQ,GAAG;IACf,SAAS;IACT,MAAM;IACN,YAAY;IACZ,UAAU;IACV,iBAAiB;IACjB,UAAU;IACV,OAAO;IACP,MAAM;IACN,MAAM;IACN,KAAK;IACL,KAAK;CACG,CAAA;AAEV,SAAS,UAAU,CAAC,MAAgB,EAAE,IAAgB;IACpD,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;QACtB,KAAK,EAAE;YACL,MAAM,EAAE,EAAE;YACV,aAAa,EAAE,EAAE;YACjB,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,GAAG,EAAE,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A;IACF,OAAO,UAAU,CAAC,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,EAAE,IAAI,CAAC,CAAA;AACjE,CAAC;AAPD,kCAOC","sourcesContent":["import { dialects } from '@cucumber/gherkin'\nimport Table from 'cli-table3'\nimport { capitalCase } from 'capital-case'\n\nconst keywords = [\n 'feature',\n 'rule',\n 'background',\n 'scenario',\n 'scenarioOutline',\n 'examples',\n 'given',\n 'when',\n 'then',\n 'and',\n 'but',\n] as const\n\nfunction getAsTable(header: string[], rows: string[][]): string {\n const table = new Table({\n chars: {\n bottom: '',\n 'bottom-left': '',\n 'bottom-mid': '',\n 'bottom-right': '',\n left: '',\n 'left-mid': '',\n mid: '',\n 'mid-mid': '',\n middle: ' | ',\n right: '',\n 'right-mid': '',\n top: '',\n 'top-left': '',\n 'top-mid': '',\n 'top-right': '',\n },\n style: {\n border: [],\n 'padding-left': 0,\n 'padding-right': 0,\n },\n })\n table.push(header)\n table.push(...rows)\n return table.toString()\n}\n\nexport function getLanguages(): string {\n const rows = Object.keys(dialects).map((isoCode) => [\n isoCode,\n dialects[isoCode].name,\n dialects[isoCode].native,\n ])\n return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows)\n}\n\nexport function getKeywords(isoCode: string): string {\n const language = dialects[isoCode]\n const rows = keywords.map((keyword) => {\n const words = language[keyword].map((s) => `\"${s}\"`).join(', ')\n return [capitalCase(keyword), words]\n })\n return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows)\n}\n"]}
|
package/lib/cli/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export default class Cli {
|
|
|
33
33
|
});
|
|
34
34
|
getConfiguration(): Promise<IConfiguration>;
|
|
35
35
|
initializeFormatters({ eventBroadcaster, eventDataCollector, formatOptions, formats, supportCodeLibrary, }: IInitializeFormattersRequest): Promise<() => Promise<void>>;
|
|
36
|
-
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary
|
|
36
|
+
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }: IGetSupportCodeLibraryRequest): Promise<ISupportCodeLibrary>;
|
|
37
37
|
run(): Promise<ICliRunResult>;
|
|
38
38
|
}
|
|
39
39
|
export {};
|
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,18 +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
|
+
for (const codePath of supportCodePaths) {
|
|
122
|
+
if (supportCodeRequiredModules.length || !helpers_2.isJavaScript(codePath)) {
|
|
123
|
+
require(codePath);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
await importer(url_1.pathToFileURL(codePath));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
121
129
|
return support_code_library_builder_1.default.finalize();
|
|
122
130
|
}
|
|
123
131
|
async run() {
|
|
@@ -131,10 +139,8 @@ class Cli {
|
|
|
131
139
|
this.stdout.write(I18n.getKeywords(configuration.listI18nKeywordsFor));
|
|
132
140
|
return { shouldExitImmediately: true, success: true };
|
|
133
141
|
}
|
|
134
|
-
const newId =
|
|
135
|
-
|
|
136
|
-
: uuid();
|
|
137
|
-
const supportCodeLibrary = this.getSupportCodeLibrary({
|
|
142
|
+
const newId = uuid();
|
|
143
|
+
const supportCodeLibrary = await this.getSupportCodeLibrary({
|
|
138
144
|
newId,
|
|
139
145
|
supportCodePaths: configuration.supportCodePaths,
|
|
140
146
|
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
|
@@ -152,15 +158,19 @@ class Cli {
|
|
|
152
158
|
const gherkinMessageStream = gherkin_streams_1.GherkinStreams.fromPaths(configuration.featurePaths, {
|
|
153
159
|
defaultDialect: configuration.featureDefaultLanguage,
|
|
154
160
|
newId,
|
|
161
|
+
relativeTo: this.cwd,
|
|
155
162
|
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
let pickleIds = [];
|
|
164
|
+
if (configuration.featurePaths.length > 0) {
|
|
165
|
+
pickleIds = await helpers_2.parseGherkinMessageStream({
|
|
166
|
+
cwd: this.cwd,
|
|
167
|
+
eventBroadcaster,
|
|
168
|
+
eventDataCollector,
|
|
169
|
+
gherkinMessageStream,
|
|
170
|
+
order: configuration.order,
|
|
171
|
+
pickleFilter: new pickle_filter_1.default(configuration.pickleFilterOptions),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
164
174
|
helpers_2.emitSupportCodeMessages({
|
|
165
175
|
eventBroadcaster,
|
|
166
176
|
supportCodeLibrary,
|
|
@@ -173,17 +183,13 @@ class Cli {
|
|
|
173
183
|
eventBroadcaster,
|
|
174
184
|
eventDataCollector,
|
|
175
185
|
options: configuration.runtimeOptions,
|
|
186
|
+
newId,
|
|
176
187
|
pickleIds,
|
|
177
188
|
supportCodeLibrary,
|
|
178
189
|
supportCodePaths: configuration.supportCodePaths,
|
|
179
190
|
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
|
180
191
|
});
|
|
181
|
-
await
|
|
182
|
-
parallelRuntimeCoordinator.run(configuration.parallel, (s) => {
|
|
183
|
-
success = s;
|
|
184
|
-
resolve();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
192
|
+
success = await parallelRuntimeCoordinator.run(configuration.parallel);
|
|
187
193
|
}
|
|
188
194
|
else {
|
|
189
195
|
const runtime = new runtime_1.default({
|
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,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,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,MAAM,QAAQ,GAAG,MAAM,yBAAe,CAAC;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAA;QACF,OAAO,MAAM,+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,kBAAkB;gBAClB,OAAO,EAAE,aAAa,CAAC,cAAc;gBACrC,SAAS;gBACT,kBAAkB;gBAClB,gBAAgB,EAAE,aAAa,CAAC,gBAAgB;gBAChD,0BAA0B,EAAE,aAAa,CAAC,0BAA0B;aACrE,CAAC,CAAA;YACF,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAClC,0BAA0B,CAAC,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBAC3D,OAAO,GAAG,CAAC,CAAA;oBACX,OAAO,EAAE,CAAA;gBACX,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACH;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;AArMD,sBAqMC","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 = (stream as TtyWriteStream).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) => require(codePath))\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 }\n )\n const 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 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 pickleIds,\n supportCodeLibrary,\n supportCodePaths: configuration.supportCodePaths,\n supportCodeRequiredModules: configuration.supportCodeRequiredModules,\n })\n await new Promise<void>((resolve) => {\n parallelRuntimeCoordinator.run(configuration.parallel, (s) => {\n success = s\n resolve()\n })\n })\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;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AQ,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,7 +1,7 @@
|
|
|
1
|
-
import { Dictionary } from 'lodash';
|
|
2
1
|
export default class ProfileLoader {
|
|
3
2
|
private readonly directory;
|
|
4
3
|
constructor(directory: string);
|
|
5
|
-
getDefinitions(): Promise<
|
|
6
|
-
|
|
4
|
+
getDefinitions(configFile?: string): Promise<Record<string, string>>;
|
|
5
|
+
loadFile(configFile: string): Record<string, string>;
|
|
6
|
+
getArgv(profiles: string[], configFile?: string): Promise<string[]>;
|
|
7
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,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElD,KAAK,CAAC,cAAc,CAAC,UAAmB;QACtC,IAAI,UAAU,EAAE;YACd,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;SACjC;QAED,MAAM,WAAW,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACtD,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CACnD,CAAA;QAED,IAAI,WAAW,EAAE;YACf,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;SAClC;QAED,OAAO,EAAE,CAAA;IACX,CAAC;IAED,QAAQ,CAAC,UAAkB;QACzB,MAAM,mBAAmB,GAAW,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QACzE,8DAA8D;QAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;QAChD,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,GAAG,mBAAmB,4BAA4B,CAAC,CAAA;SACpE;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAkB,EAAE,UAAmB;QACnD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;QACzD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,6BAAa,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YAC/D,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAA;SACvB;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACrC,IAAI,gCAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE;gBAC1C,MAAM,IAAI,KAAK,CAAC,sBAAsB,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"]}
|
|
@@ -8,7 +8,7 @@ const cli_table3_1 = __importDefault(require("cli-table3"));
|
|
|
8
8
|
const underlineBoldCyan = (x) => safe_1.default.underline(safe_1.default.bold(safe_1.default.cyan(x)));
|
|
9
9
|
const formattedReportUrl = underlineBoldCyan('https://reports.cucumber.io');
|
|
10
10
|
const formattedEnv = safe_1.default.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + safe_1.default.cyan('true');
|
|
11
|
-
const formattedMoreInfoUrl = underlineBoldCyan('https://
|
|
11
|
+
const formattedMoreInfoUrl = underlineBoldCyan('https://cucumber.io/docs/cucumber/environment-variables/');
|
|
12
12
|
const text = `\
|
|
13
13
|
Share your Cucumber Report with your team at ${formattedReportUrl}
|
|
14
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish_banner.js","sourceRoot":"","sources":["../../src/cli/publish_banner.ts"],"names":[],"mappings":";;;;;AAAA,uDAAgC;AAChC,4DAA8B;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAU,EAAE,CAC9C,cAAM,CAAC,SAAS,CAAC,cAAM,CAAC,IAAI,CAAC,cAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;AAC3E,MAAM,YAAY,GAChB,cAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,GAAG,GAAG,GAAG,cAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACrE,MAAM,oBAAoB,GAAG,iBAAiB,CAC5C,
|
|
1
|
+
{"version":3,"file":"publish_banner.js","sourceRoot":"","sources":["../../src/cli/publish_banner.ts"],"names":[],"mappings":";;;;;AAAA,uDAAgC;AAChC,4DAA8B;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAU,EAAE,CAC9C,cAAM,CAAC,SAAS,CAAC,cAAM,CAAC,IAAI,CAAC,cAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;AAC3E,MAAM,YAAY,GAChB,cAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,GAAG,GAAG,GAAG,cAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACrE,MAAM,oBAAoB,GAAG,iBAAiB,CAC5C,0DAA0D,CAC3D,CAAA;AAED,MAAM,IAAI,GAAG;+CACkC,kBAAkB;;0BAEvC,cAAM,CAAC,IAAI,CAAC,WAAW,CAAC;0BACxB,YAAY;;sBAEhB,oBAAoB;;4CAEE,cAAM,CAAC,IAAI,CAAC,eAAe,CAAC;EACtE,cAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,EAAE,CAAA;AAElE,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;IACtB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB;CACF,CAAC,CAAA;AAEF,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAElB,kBAAe,KAAK,CAAC,QAAQ,EAAE,CAAA","sourcesContent":["import colors from 'colors/safe'\nimport Table from 'cli-table3'\n\nconst underlineBoldCyan = (x: string): string =>\n colors.underline(colors.bold(colors.cyan(x)))\n\nconst formattedReportUrl = underlineBoldCyan('https://reports.cucumber.io')\nconst formattedEnv =\n colors.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + colors.cyan('true')\nconst formattedMoreInfoUrl = underlineBoldCyan(\n 'https://cucumber.io/docs/cucumber/environment-variables/'\n)\n\nconst text = `\\\nShare your Cucumber Report with your team at ${formattedReportUrl}\n\nCommand line option: ${colors.cyan('--publish')}\nEnvironment variable: ${formattedEnv}\n\nMore information at ${formattedMoreInfoUrl}\n\nTo disable this message, add this to your ${colors.bold('./cucumber.js')}: \n${colors.bold(\"module.exports = { default: '--publish-quiet' }\")}`\n\nconst table = new Table({\n style: {\n head: [],\n border: ['green'],\n },\n})\n\ntable.push([text])\n\nexport default table.toString()\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,CACtE,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QACD,MAAM,QAAQ,GAAG,uBAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAA;QACrE,MAAM,cAAc,GAClB,MAAM,gBAAgB,CAAC,+BAA+B,CAAC;YACrD,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,gBAAgB,EAAE,OAAO,CAAC,iBAAiB,CAAC,gBAAgB;YAC5D,aAAa,EAAE,OAAO,CAAC,iBAAiB,CAAC,aAAa;YACtD,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;SAC/C,CAAC,CAAA;QACJ,OAAO,IAAI,oBAAoB,CAAC;YAC9B,QAAQ;YACR,cAAc;YACd,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,IAAY,EACZ,GAAW;QAE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AI,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"]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TestStepResultStatus } from '@cucumber/messages';
|
|
2
2
|
export declare type IColorFn = (text: string) => string;
|
|
3
3
|
export interface IColorFns {
|
|
4
|
-
forStatus: (status:
|
|
4
|
+
forStatus: (status: TestStepResultStatus) => IColorFn;
|
|
5
5
|
location: IColorFn;
|
|
6
6
|
tag: IColorFn;
|
|
7
|
+
diffAdded: IColorFn;
|
|
8
|
+
diffRemoved: IColorFn;
|
|
9
|
+
errorMessage: IColorFn;
|
|
10
|
+
errorStack: IColorFn;
|
|
7
11
|
}
|
|
8
12
|
export default function getColorFns(enabled: boolean): IColorFns;
|