@cucumber/cucumber 7.3.2 → 8.0.0-rc.3
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 +88 -51
- package/api/index.d.ts +6 -0
- package/lib/api/convert_configuration.d.ts +4 -0
- package/lib/api/convert_configuration.js +64 -0
- package/lib/api/convert_configuration.js.map +1 -0
- package/lib/api/environment.d.ts +2 -0
- package/lib/api/environment.js +13 -0
- package/lib/api/environment.js.map +1 -0
- package/lib/api/formatters.d.ts +16 -0
- package/lib/api/formatters.js +72 -0
- package/lib/api/formatters.js.map +1 -0
- package/lib/api/gherkin.d.ts +21 -0
- package/lib/api/gherkin.js +65 -0
- package/lib/api/gherkin.js.map +1 -0
- package/lib/api/index.d.ts +11 -0
- package/lib/api/index.js +24 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/load_configuration.d.ts +9 -0
- package/lib/api/load_configuration.js +32 -0
- package/lib/api/load_configuration.js.map +1 -0
- package/lib/api/load_sources.d.ts +9 -0
- package/lib/api/load_sources.js +53 -0
- package/lib/api/load_sources.js.map +1 -0
- package/lib/api/load_support.d.ts +10 -0
- package/lib/api/load_support.js +28 -0
- package/lib/api/load_support.js.map +1 -0
- package/lib/api/paths.d.ts +7 -0
- package/lib/api/paths.js +99 -0
- package/lib/api/paths.js.map +1 -0
- package/lib/api/run_cucumber.d.ts +11 -0
- package/lib/api/run_cucumber.js +108 -0
- package/lib/api/run_cucumber.js.map +1 -0
- package/lib/api/runtime.d.ts +20 -0
- package/lib/api/runtime.js +36 -0
- package/lib/api/runtime.js.map +1 -0
- package/lib/api/support.d.ts +9 -0
- package/lib/api/support.js +21 -0
- package/lib/api/support.js.map +1 -0
- package/lib/api/types.d.ts +168 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/api/wrapper.mjs +6 -0
- package/lib/cli/helpers.d.ts +16 -9
- package/lib/cli/helpers.js +49 -32
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/i18n.js +7 -7
- package/lib/cli/i18n.js.map +1 -1
- package/lib/cli/index.d.ts +6 -23
- package/lib/cli/index.js +38 -197
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/install_validator.js +1 -1
- package/lib/cli/install_validator.js.map +1 -1
- package/lib/cli/publish_banner.js +6 -6
- package/lib/cli/publish_banner.js.map +1 -1
- package/lib/cli/run.js +15 -7
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.d.ts +7 -0
- package/lib/cli/validate_node_engine_version.js +20 -0
- package/lib/cli/validate_node_engine_version.js.map +1 -0
- package/lib/configuration/argv_parser.d.ts +20 -0
- package/lib/{cli → configuration}/argv_parser.js +52 -53
- package/lib/configuration/argv_parser.js.map +1 -0
- package/lib/configuration/check_schema.d.ts +2 -0
- package/lib/configuration/check_schema.js +56 -0
- package/lib/configuration/check_schema.js.map +1 -0
- package/lib/configuration/default_configuration.d.ts +2 -0
- package/lib/configuration/default_configuration.js +27 -0
- package/lib/configuration/default_configuration.js.map +1 -0
- package/lib/configuration/from_file.d.ts +2 -0
- package/lib/configuration/from_file.js +68 -0
- package/lib/configuration/from_file.js.map +1 -0
- package/lib/configuration/helpers.d.ts +1 -0
- package/lib/configuration/helpers.js +11 -0
- package/lib/configuration/helpers.js.map +1 -0
- package/lib/configuration/index.d.ts +7 -0
- package/lib/configuration/index.js +25 -0
- package/lib/configuration/index.js.map +1 -0
- package/lib/configuration/locate_file.d.ts +1 -0
- package/lib/configuration/locate_file.js +19 -0
- package/lib/configuration/locate_file.js.map +1 -0
- package/lib/configuration/merge_configurations.d.ts +2 -0
- package/lib/configuration/merge_configurations.js +48 -0
- package/lib/configuration/merge_configurations.js.map +1 -0
- package/lib/configuration/option_splitter.d.ts +3 -0
- package/lib/{cli → configuration}/option_splitter.js +3 -2
- package/lib/configuration/option_splitter.js.map +1 -0
- package/lib/configuration/types.d.ts +25 -0
- package/lib/configuration/types.js +3 -0
- package/lib/configuration/types.js.map +1 -0
- package/lib/configuration/validate_configuration.d.ts +2 -0
- package/lib/configuration/validate_configuration.js +10 -0
- package/lib/configuration/validate_configuration.js.map +1 -0
- package/lib/formatter/builder.d.ts +7 -7
- package/lib/formatter/builder.js +48 -55
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.js +15 -16
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +2 -1
- package/lib/formatter/helpers/event_data_collector.js +16 -15
- 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 +29 -42
- package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.d.ts +4 -4
- package/lib/formatter/helpers/issue_helpers.js +8 -9
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/keyword_type.js +2 -6
- package/lib/formatter/helpers/keyword_type.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +1 -1
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js +9 -18
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.js +8 -7
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
- package/lib/formatter/helpers/test_case_attempt_formatter.js +20 -19
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
- package/lib/formatter/helpers/test_case_attempt_parser.js +18 -21
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
- package/lib/formatter/helpers/usage_helpers/index.js +29 -43
- 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 +5 -4
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/http_stream.js +7 -7
- package/lib/formatter/http_stream.js.map +1 -1
- package/lib/formatter/index.d.ts +15 -2
- package/lib/formatter/index.js +2 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -0
- package/lib/formatter/json_formatter.js +25 -20
- 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 +18 -17
- 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 +3 -2
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/publish.d.ts +1 -0
- package/lib/formatter/publish.js +5 -0
- package/lib/formatter/publish.js.map +1 -0
- package/lib/formatter/rerun_formatter.d.ts +1 -0
- package/lib/formatter/rerun_formatter.js +15 -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 +3 -3
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
- 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 +1 -0
- package/lib/formatter/summary_formatter.js +11 -11
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.d.ts +1 -0
- package/lib/formatter/usage_formatter.js +9 -10
- 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 +3 -3
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/importer.js +13 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +9 -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/pickle_order.d.ts +1 -0
- package/lib/models/pickle_order.js +3 -0
- package/lib/models/pickle_order.js.map +1 -0
- package/lib/models/step_definition.js +4 -5
- package/lib/models/step_definition.js.map +1 -1
- package/lib/pickle_filter.js +13 -13
- package/lib/pickle_filter.js.map +1 -1
- package/lib/runtime/assemble_test_cases.js +3 -3
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.js +4 -4
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -0
- package/lib/runtime/helpers.js +42 -4
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +7 -7
- package/lib/runtime/index.js +12 -65
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/command_types.d.ts +3 -2
- package/lib/runtime/parallel/command_types.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +32 -12
- package/lib/runtime/parallel/coordinator.js +82 -38
- package/lib/runtime/parallel/coordinator.js.map +1 -1
- package/lib/runtime/parallel/run_worker.js +1 -1
- package/lib/runtime/parallel/run_worker.js.map +1 -1
- package/lib/runtime/parallel/worker.d.ts +2 -4
- package/lib/runtime/parallel/worker.js +18 -33
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.d.ts +3 -0
- package/lib/runtime/run_test_run_hooks.js +28 -0
- package/lib/runtime/run_test_run_hooks.js.map +1 -0
- package/lib/runtime/step_runner.js +5 -7
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +4 -4
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +3 -3
- package/lib/runtime/test_case_runner.js +19 -28
- package/lib/runtime/test_case_runner.js.map +1 -1
- package/lib/stack_trace_filter.js +6 -7
- package/lib/stack_trace_filter.js.map +1 -1
- package/lib/step_arguments.js +2 -2
- package/lib/step_arguments.js.map +1 -1
- package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
- package/lib/support_code_library_builder/build_parameter_type.js +13 -0
- package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
- package/lib/support_code_library_builder/index.d.ts +4 -2
- package/lib/support_code_library_builder/index.js +43 -34
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
- package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
- package/lib/support_code_library_builder/types.d.ts +10 -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 +10 -17
- 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/version.d.ts +1 -0
- package/lib/version.js +6 -0
- package/lib/version.js.map +1 -0
- package/lib/wrapper.mjs +42 -0
- package/package.json +98 -70
- package/lib/cli/argv_parser.d.ts +0 -51
- package/lib/cli/argv_parser.js.map +0 -1
- package/lib/cli/configuration_builder.d.ts +0 -46
- package/lib/cli/configuration_builder.js +0 -161
- package/lib/cli/configuration_builder.js.map +0 -1
- package/lib/cli/option_splitter.d.ts +0 -4
- package/lib/cli/option_splitter.js.map +0 -1
- package/lib/cli/profile_loader.d.ts +0 -6
- package/lib/cli/profile_loader.js +0 -42
- package/lib/cli/profile_loader.js.map +0 -1
- package/lib/support_code_library_builder/build_helpers.js +0 -41
- package/lib/support_code_library_builder/build_helpers.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { FormatOptions, IFormatterStream } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\nimport { IRuntimeOptions } from '../runtime'\nimport { IConfiguration } from '../configuration'\n\n/**\n * @public\n */\nexport interface ILoadConfigurationOptions {\n /**\n * Path to load configuration file from (defaults to `cucumber.(js|cjs|mjs|json)` if omitted).\n */\n file?: string\n /**\n * Zero or more profile names from which to source configuration (if omitted or empty, the `default` profile will be used).\n */\n profiles?: string[]\n /**\n * Ad-hoc configuration options to be applied over the top of whatever is loaded from the configuration file/profiles.\n */\n provided?: Partial<IConfiguration>\n}\n\n/**\n * @public\n */\nexport interface IResolvedConfiguration {\n /**\n * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\n */\n useConfiguration: IConfiguration\n /**\n * The format that can be passed into `runCucumber`.\n */\n runConfiguration: IRunConfiguration\n}\n\n/**\n * @public\n */\nexport interface ISourcesCoordinates {\n defaultDialect: string\n paths: string[]\n names: string[]\n tagExpression: string\n order: PickleOrder\n}\n\n/**\n * @public\n */\nexport interface IPlannedPickle {\n name: string\n uri: string\n location: {\n line: number\n column?: number\n }\n}\n\n/**\n * @public\n */\nexport interface ISourcesError {\n uri: string\n location: {\n line: number\n column?: number\n }\n message: string\n}\n\n/**\n * @public\n */\nexport interface ILoadSourcesResult {\n plan: IPlannedPickle[]\n errors: ISourcesError[]\n}\n\n/**\n * @public\n */\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\n/**\n * @public\n */\nexport interface ILoadSupportOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsRuntime extends IRuntimeOptions {\n parallel: number\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsFormats {\n stdout: string\n files: Record<string, string>\n publish:\n | {\n url?: string\n token?: string\n }\n | false\n options: FormatOptions\n}\n\n/**\n * @public\n */\nexport interface IRunConfiguration {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * @public\n */\nexport type ISupportCodeCoordinatesOrLibrary =\n | ISupportCodeCoordinates\n | ISupportCodeLibrary\n\n/**\n * @public\n */\nexport interface IRunOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinatesOrLibrary\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * Contextual data about the project environment.\n *\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project (defaults to `process.cwd()` if omitted).\n */\n cwd?: string\n /**\n * Writable stream where the test run's main output is written (defaults to `process.stdout` if omitted).\n */\n stdout?: IFormatterStream\n /**\n * Writable stream where the test run's warning/error output is written (defaults to `process.stderr` if omitted).\n */\n stderr?: IFormatterStream\n /**\n * Environment variables (defaults to `process.env` if omitted).\n */\n env?: NodeJS.ProcessEnv\n}\n\n/**\n * Result of a Cucumber test run.\n *\n * @public\n */\nexport interface IRunResult {\n /**\n * Whether the test run was overall successful i.e. no failed scenarios. The exact meaning can vary based on the `strict` configuration option.\n */\n success: boolean\n /**\n * The support code library that was used in the test run; can be reused in subsequent `runCucumber` calls.\n */\n support: ISupportCodeLibrary\n}\n"]}
|
package/lib/cli/helpers.d.ts
CHANGED
|
@@ -5,22 +5,29 @@ import { EventDataCollector } from '../formatter/helpers';
|
|
|
5
5
|
import { Readable } from 'stream';
|
|
6
6
|
import { IdGenerator } from '@cucumber/messages';
|
|
7
7
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
-
|
|
9
|
-
argv: string[];
|
|
10
|
-
cwd: string;
|
|
11
|
-
}
|
|
12
|
-
export declare function getExpandedArgv({ argv, cwd, }: IGetExpandedArgvRequest): Promise<string[]>;
|
|
8
|
+
import { PickleOrder } from '../models/pickle_order';
|
|
13
9
|
interface IParseGherkinMessageStreamRequest {
|
|
14
|
-
cwd
|
|
10
|
+
cwd?: string;
|
|
15
11
|
eventBroadcaster: EventEmitter;
|
|
16
12
|
eventDataCollector: EventDataCollector;
|
|
17
13
|
gherkinMessageStream: Readable;
|
|
18
14
|
order: string;
|
|
19
15
|
pickleFilter: PickleFilter;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
19
|
+
*
|
|
20
|
+
* @deprecated use `loadSources` instead
|
|
21
|
+
*
|
|
22
|
+
* @param eventBroadcaster
|
|
23
|
+
* @param eventDataCollector
|
|
24
|
+
* @param gherkinMessageStream
|
|
25
|
+
* @param order
|
|
26
|
+
* @param pickleFilter
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }: IParseGherkinMessageStreamRequest): Promise<string[]>;
|
|
29
|
+
export declare function orderPickles<T = string>(pickleIds: T[], order: PickleOrder, logger: Console): void;
|
|
30
|
+
export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv): Promise<void>;
|
|
24
31
|
export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
|
|
25
32
|
eventBroadcaster: EventEmitter;
|
|
26
33
|
supportCodeLibrary: ISupportCodeLibrary;
|
package/lib/cli/helpers.js
CHANGED
|
@@ -22,32 +22,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.
|
|
26
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
27
|
-
const argv_parser_1 = __importDefault(require("./argv_parser"));
|
|
28
|
-
const profile_loader_1 = __importDefault(require("./profile_loader"));
|
|
25
|
+
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles = exports.parseGherkinMessageStream = void 0;
|
|
29
26
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
30
27
|
const value_checker_1 = require("../value_checker");
|
|
31
|
-
const
|
|
28
|
+
const configuration_1 = require("../configuration");
|
|
29
|
+
const os_1 = __importDefault(require("os"));
|
|
32
30
|
const messages = __importStar(require("@cucumber/messages"));
|
|
33
|
-
const
|
|
31
|
+
const ci_environment_1 = __importDefault(require("@cucumber/ci-environment"));
|
|
34
32
|
const support_code_library_builder_1 = require("../support_code_library_builder");
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
const version_1 = require("../version");
|
|
34
|
+
/**
|
|
35
|
+
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
36
|
+
*
|
|
37
|
+
* @deprecated use `loadSources` instead
|
|
38
|
+
*
|
|
39
|
+
* @param eventBroadcaster
|
|
40
|
+
* @param eventDataCollector
|
|
41
|
+
* @param gherkinMessageStream
|
|
42
|
+
* @param order
|
|
43
|
+
* @param pickleFilter
|
|
44
|
+
*/
|
|
45
|
+
async function parseGherkinMessageStream({ eventBroadcaster, eventDataCollector, gherkinMessageStream, order, pickleFilter, }) {
|
|
46
46
|
return await new Promise((resolve, reject) => {
|
|
47
47
|
const result = [];
|
|
48
48
|
gherkinMessageStream.on('data', (envelope) => {
|
|
49
49
|
eventBroadcaster.emit('envelope', envelope);
|
|
50
|
-
if (value_checker_1.doesHaveValue(envelope.pickle)) {
|
|
50
|
+
if ((0, value_checker_1.doesHaveValue)(envelope.pickle)) {
|
|
51
51
|
const pickle = envelope.pickle;
|
|
52
52
|
const pickleId = pickle.id;
|
|
53
53
|
const gherkinDocument = eventDataCollector.getGherkinDocument(pickle.uri);
|
|
@@ -55,12 +55,9 @@ async function parseGherkinMessageStream({ cwd, eventBroadcaster, eventDataColle
|
|
|
55
55
|
result.push(pickleId);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
if (value_checker_1.doesHaveValue(envelope.parseError)) {
|
|
59
|
-
reject(new Error(`Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`));
|
|
60
|
-
}
|
|
61
58
|
});
|
|
62
59
|
gherkinMessageStream.on('end', () => {
|
|
63
|
-
|
|
60
|
+
orderPickles(result, order, console);
|
|
64
61
|
resolve(result);
|
|
65
62
|
});
|
|
66
63
|
gherkinMessageStream.on('error', reject);
|
|
@@ -68,28 +65,48 @@ async function parseGherkinMessageStream({ cwd, eventBroadcaster, eventDataColle
|
|
|
68
65
|
}
|
|
69
66
|
exports.parseGherkinMessageStream = parseGherkinMessageStream;
|
|
70
67
|
// Orders the pickleIds in place - morphs input
|
|
71
|
-
function
|
|
72
|
-
|
|
68
|
+
function orderPickles(pickleIds, order, logger) {
|
|
69
|
+
const [type, seed] = configuration_1.OptionSplitter.split(order);
|
|
73
70
|
switch (type) {
|
|
74
71
|
case 'defined':
|
|
75
72
|
break;
|
|
76
73
|
case 'random':
|
|
77
74
|
if (seed === '') {
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
const newSeed = Math.floor(Math.random() * 1000 * 1000).toString();
|
|
76
|
+
logger.warn(`Random order using seed: ${newSeed}`);
|
|
77
|
+
(0, knuth_shuffle_seeded_1.default)(pickleIds, newSeed);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
(0, knuth_shuffle_seeded_1.default)(pickleIds, seed);
|
|
80
81
|
}
|
|
81
|
-
knuth_shuffle_seeded_1.default(pickleIds, seed);
|
|
82
82
|
break;
|
|
83
83
|
default:
|
|
84
84
|
throw new Error('Unrecgonized order type. Should be `defined` or `random`');
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
-
exports.
|
|
88
|
-
async function emitMetaMessage(eventBroadcaster) {
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
exports.orderPickles = orderPickles;
|
|
88
|
+
async function emitMetaMessage(eventBroadcaster, env) {
|
|
89
|
+
const meta = {
|
|
90
|
+
protocolVersion: messages.version,
|
|
91
|
+
implementation: {
|
|
92
|
+
version: version_1.version,
|
|
93
|
+
name: 'cucumber-js',
|
|
94
|
+
},
|
|
95
|
+
cpu: {
|
|
96
|
+
name: os_1.default.arch(),
|
|
97
|
+
},
|
|
98
|
+
os: {
|
|
99
|
+
name: os_1.default.platform(),
|
|
100
|
+
version: os_1.default.release(),
|
|
101
|
+
},
|
|
102
|
+
runtime: {
|
|
103
|
+
name: 'node.js',
|
|
104
|
+
version: process.versions.node,
|
|
105
|
+
},
|
|
106
|
+
ci: (0, ci_environment_1.default)(env),
|
|
107
|
+
};
|
|
91
108
|
eventBroadcaster.emit('envelope', {
|
|
92
|
-
meta
|
|
109
|
+
meta,
|
|
93
110
|
});
|
|
94
111
|
}
|
|
95
112
|
exports.emitMetaMess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C;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAS,gBAAgB,CACvB,kBAAuC,EACvC,gBAA8B;IAE9B,CAAC;IAAA,EAAE;SACA,MAAM,CACL,kBAAkB,CAAC,4BAA4B,EAC/C,kBAAkB,CAAC,2BAA2B,CAC/C;SACA,OAAO,CAAC,CAAC,qBAA4C,EAAE,EAAE;QACxD,MAAM,QAAQ,GAAsB;YAClC,IAAI,EAAE;gBACJ,EAAE,EAAE,qBAAqB,CAAC,EAAE;gBAC5B,eAAe,EAAE;oBACf,GAAG,EAAE,qBAAqB,CAAC,GAAG;oBAC9B,QAAQ,EAAE;wBACR,IAAI,EAAE,qBAAqB,CAAC,IAAI;qBACjC;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC;AAdD,0DAcC","sourcesContent":["import _ from 'lodash'\nimport ArgvParser from './argv_parser'\nimport ProfileLoader from './profile_loader'\nimport shuffle from 'knuth-shuffle-seeded'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport OptionSplitter from './option_splitter'\nimport { Readable } from 'stream'\nimport { IdGenerator } from '@cucumber/messages'\nimport * as messages from '@cucumber/messages'\nimport createMeta from '@cucumber/create-meta'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { builtinParameterTypes } from '../support_code_library_builder'\n\nexport interface IGetExpandedArgvRequest {\n argv: string[]\n cwd: string\n}\n\nexport async function getExpandedArgv({\n argv,\n cwd,\n}: IGetExpandedArgvRequest): Promise<string[]> {\n const { options } = ArgvParser.parse(argv)\n let fullArgv = argv\n const profileArgv = await new ProfileLoader(cwd).getArgv(options.profile)\n if (profileArgv.length > 0) {\n fullArgv = _.concat(argv.slice(0, 2), profileArgv, argv.slice(2))\n }\n return fullArgv\n}\n\ninterface IParseGherkinMessageStreamRequest {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\nexport async function parseGherkinMessageStream({\n cwd,\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n if (doesHaveValue(envelope.parseError)) {\n reject(\n new Error(\n `Parse error in '${envelope.parseError.source.uri}': ${envelope.parseError.message}`\n )\n )\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickleIds(result, order)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickleIds(pickleIds: string[], order: string): void {\n let [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n seed = Math.floor(Math.random() * 1000 * 1000).toString()\n console.warn(`Random order using seed: ${seed}`)\n }\n shuffle(pickleIds, seed)\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter\n): Promise<void> {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const { version } = require('../../package.json')\n eventBroadcaster.emit('envelope', {\n meta: createMeta('cucumber-js', version, process.env),\n })\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
|
1
|
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;gBAC5B,eAAe,EAAE;oBACf,GAAG,EAAE,qBAAqB,CAAC,GAAG;oBAC9B,QAAQ,EAAE;wBACR,IAAI,EAAE,qBAAqB,CAAC,IAAI;qBACjC;iBACF;aACF;SACF,CAAA;QACD,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,kBAAkB,CAAC,kBAAkB,EAAE,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC/D,2BAA2B,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACjE,mBAAmB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACzD,iBAAiB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;IACvD,gBAAgB,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAA;AACxD,CAAC;AAdD,0DAcC","sourcesContent":["import shuffle from 'knuth-shuffle-seeded'\nimport { EventEmitter } from 'events'\nimport PickleFilter from '../pickle_filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { doesHaveValue } from '../value_checker'\nimport { OptionSplitter } from '../configuration'\nimport { Readable } from 'stream'\nimport os from 'os'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport TestCaseHookDefinition from '../models/test_case_hook_definition'\nimport TestRunHookDefinition from '../models/test_run_hook_definition'\nimport { PickleOrder } from '../models/pickle_order'\nimport { builtinParameterTypes } from '../support_code_library_builder'\nimport { version } from '../version'\n\ninterface IParseGherkinMessageStreamRequest {\n cwd?: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n gherkinMessageStream: Readable\n order: string\n pickleFilter: PickleFilter\n}\n\n/**\n * Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids\n *\n * @deprecated use `loadSources` instead\n *\n * @param eventBroadcaster\n * @param eventDataCollector\n * @param gherkinMessageStream\n * @param order\n * @param pickleFilter\n */\nexport async function parseGherkinMessageStream({\n eventBroadcaster,\n eventDataCollector,\n gherkinMessageStream,\n order,\n pickleFilter,\n}: IParseGherkinMessageStreamRequest): Promise<string[]> {\n return await new Promise<string[]>((resolve, reject) => {\n const result: string[] = []\n gherkinMessageStream.on('data', (envelope: messages.Envelope) => {\n eventBroadcaster.emit('envelope', envelope)\n if (doesHaveValue(envelope.pickle)) {\n const pickle = envelope.pickle\n const pickleId = pickle.id\n const gherkinDocument = eventDataCollector.getGherkinDocument(\n pickle.uri\n )\n if (pickleFilter.matches({ gherkinDocument, pickle })) {\n result.push(pickleId)\n }\n }\n })\n gherkinMessageStream.on('end', () => {\n orderPickles(result, order, console)\n resolve(result)\n })\n gherkinMessageStream.on('error', reject)\n })\n}\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: PickleOrder,\n logger: Console\n): void {\n const [type, seed] = OptionSplitter.split(order)\n switch (type) {\n case 'defined':\n break\n case 'random':\n if (seed === '') {\n const newSeed = Math.floor(Math.random() * 1000 * 1000).toString()\n logger.warn(`Random order using seed: ${newSeed}`)\n shuffle(pickleIds, newSeed)\n } else {\n shuffle(pickleIds, seed)\n }\n break\n default:\n throw new Error(\n 'Unrecgonized order type. Should be `defined` or `random`'\n )\n }\n}\n\nexport async function emitMetaMessage(\n eventBroadcaster: EventEmitter,\n env: NodeJS.ProcessEnv\n): Promise<void> {\n const meta: messages.Meta = {\n protocolVersion: messages.version,\n implementation: {\n version,\n name: 'cucumber-js',\n },\n cpu: {\n name: os.arch(),\n },\n os: {\n name: os.platform(),\n version: os.release(),\n },\n runtime: {\n name: 'node.js',\n version: process.versions.node,\n },\n ci: detectCiEnvironment(env),\n }\n eventBroadcaster.emit('envelope', {\n meta,\n })\n}\n\nfunction emitParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter,\n newId: IdGenerator.NewId\n): void {\n for (const parameterType of supportCodeLibrary.parameterTypeRegistry\n .parameterTypes) {\n if (builtinParameterTypes.includes(parameterType.name)) {\n continue\n }\n const envelope: messages.Envelope = {\n parameterType: {\n id: newId(),\n name: parameterType.name,\n preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,\n regularExpressions: parameterType.regexpStrings,\n useForSnippets: parameterType.useForSnippets,\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitUndefinedParameterTypes(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {\n const envelope: messages.Envelope = {\n undefinedParameterType,\n }\n eventBroadcaster.emit('envelope', envelope)\n }\n}\n\nfunction emitStepDefinitions(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {\n const envelope: messages.Envelope = {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: stepDefinition.pattern.toString(),\n type:\n typeof stepDefinition.pattern === 'string'\n ? messages.StepDefinitionPatternType.CUCUMBER_EXPRESSION\n : messages.StepDefinitionPatternType.REGULAR_EXPRESSION,\n },\n sourceReference: {\n uri: stepDefinition.uri,\n location: {\n line: stepDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestCaseHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n supportCodeLibrary.afterTestCaseHookDefinitions\n )\n .forEach((testCaseHookDefinition: TestCaseHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testCaseHookDefinition.id,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: {\n uri: testCaseHookDefinition.uri,\n location: {\n line: testCaseHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nfunction emitTestRunHooks(\n supportCodeLibrary: ISupportCodeLibrary,\n eventBroadcaster: EventEmitter\n): void {\n ;[]\n .concat(\n supportCodeLibrary.beforeTestRunHookDefinitions,\n supportCodeLibrary.afterTestRunHookDefinitions\n )\n .forEach((testRunHookDefinition: TestRunHookDefinition) => {\n const envelope: messages.Envelope = {\n hook: {\n id: testRunHookDefinition.id,\n sourceReference: {\n uri: testRunHookDefinition.uri,\n location: {\n line: testRunHookDefinition.line,\n },\n },\n },\n }\n eventBroadcaster.emit('envelope', envelope)\n })\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: ISupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId)\n emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster)\n emitStepDefinitions(supportCodeLibrary, eventBroadcaster)\n emitTestCaseHooks(supportCodeLibrary, eventBroadcaster)\n emitTestRunHooks(supportCodeLibrary, eventBroadcaster)\n}\n"]}
|
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,19 +50,19 @@ 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 =
|
|
65
|
-
return [capital_case_1.capitalCase(keyword), words];
|
|
63
|
+
const rows = keywords.map((keyword) => {
|
|
64
|
+
const words = language[keyword].map((s) => `"${s}"`).join(', ');
|
|
65
|
+
return [(0, capital_case_1.capitalCase)(keyword), words];
|
|
66
66
|
});
|
|
67
67
|
return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows);
|
|
68
68
|
}
|
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,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K,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/D,OAAO,CAAC,IAAA,0BAAW,EAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;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
|
@@ -1,39 +1,22 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
3
|
-
import { IConfiguration, IConfigurationFormat } from './configuration_builder';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import { IdGenerator } from '@cucumber/messages';
|
|
6
2
|
import { IFormatterStream } from '../formatter';
|
|
7
|
-
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
8
|
-
import { IParsedArgvFormatOptions } from './argv_parser';
|
|
9
3
|
export interface ICliRunResult {
|
|
4
|
+
shouldAdvertisePublish: boolean;
|
|
10
5
|
shouldExitImmediately: boolean;
|
|
11
6
|
success: boolean;
|
|
12
7
|
}
|
|
13
|
-
interface IInitializeFormattersRequest {
|
|
14
|
-
eventBroadcaster: EventEmitter;
|
|
15
|
-
eventDataCollector: EventDataCollector;
|
|
16
|
-
formatOptions: IParsedArgvFormatOptions;
|
|
17
|
-
formats: IConfigurationFormat[];
|
|
18
|
-
supportCodeLibrary: ISupportCodeLibrary;
|
|
19
|
-
}
|
|
20
|
-
interface IGetSupportCodeLibraryRequest {
|
|
21
|
-
newId: IdGenerator.NewId;
|
|
22
|
-
supportCodeRequiredModules: string[];
|
|
23
|
-
supportCodePaths: string[];
|
|
24
|
-
}
|
|
25
8
|
export default class Cli {
|
|
26
9
|
private readonly argv;
|
|
27
10
|
private readonly cwd;
|
|
28
11
|
private readonly stdout;
|
|
29
|
-
|
|
12
|
+
private readonly stderr;
|
|
13
|
+
private readonly env;
|
|
14
|
+
constructor({ argv, cwd, stdout, stderr, env, }: {
|
|
30
15
|
argv: string[];
|
|
31
16
|
cwd: string;
|
|
32
17
|
stdout: IFormatterStream;
|
|
18
|
+
stderr: IFormatterStream;
|
|
19
|
+
env: NodeJS.ProcessEnv;
|
|
33
20
|
});
|
|
34
|
-
getConfiguration(): Promise<IConfiguration>;
|
|
35
|
-
initializeFormatters({ eventBroadcaster, eventDataCollector, formatOptions, formats, supportCodeLibrary, }: IInitializeFormattersRequest): Promise<() => Promise<void>>;
|
|
36
|
-
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }: IGetSupportCodeLibraryRequest): ISupportCodeLibrary;
|
|
37
21
|
run(): Promise<ICliRunResult>;
|
|
38
22
|
}
|
|
39
|
-
export {};
|
package/lib/cli/index.js
CHANGED
|
@@ -1,212 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
const
|
|
26
|
-
const
|
|
3
|
+
const configuration_1 = require("../configuration");
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const i18n_1 = require("./i18n");
|
|
27
6
|
const install_validator_1 = require("./install_validator");
|
|
28
|
-
const I18n = __importStar(require("./i18n"));
|
|
29
|
-
const configuration_builder_1 = __importDefault(require("./configuration_builder"));
|
|
30
|
-
const events_1 = require("events");
|
|
31
|
-
const builder_1 = __importDefault(require("../formatter/builder"));
|
|
32
|
-
const fs_1 = __importDefault(require("mz/fs"));
|
|
33
|
-
const path_1 = __importDefault(require("path"));
|
|
34
|
-
const pickle_filter_1 = __importDefault(require("../pickle_filter"));
|
|
35
|
-
const bluebird_1 = __importDefault(require("bluebird"));
|
|
36
|
-
const coordinator_1 = __importDefault(require("../runtime/parallel/coordinator"));
|
|
37
|
-
const runtime_1 = __importDefault(require("../runtime"));
|
|
38
|
-
const support_code_library_builder_1 = __importDefault(require("../support_code_library_builder"));
|
|
39
|
-
const messages_1 = require("@cucumber/messages");
|
|
40
|
-
const value_checker_1 = require("../value_checker");
|
|
41
|
-
const gherkin_streams_1 = require("@cucumber/gherkin-streams");
|
|
42
|
-
const http_stream_1 = __importDefault(require("../formatter/http_stream"));
|
|
43
|
-
const stream_1 = require("stream");
|
|
44
|
-
const { incrementing, uuid } = messages_1.IdGenerator;
|
|
45
7
|
class Cli {
|
|
46
|
-
constructor({ argv, cwd, stdout, }) {
|
|
8
|
+
constructor({ argv, cwd, stdout, stderr, env, }) {
|
|
47
9
|
this.argv = argv;
|
|
48
10
|
this.cwd = cwd;
|
|
49
11
|
this.stdout = stdout;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const fullArgv = await helpers_2.getExpandedArgv({
|
|
53
|
-
argv: this.argv,
|
|
54
|
-
cwd: this.cwd,
|
|
55
|
-
});
|
|
56
|
-
return await configuration_builder_1.default.build({
|
|
57
|
-
argv: fullArgv,
|
|
58
|
-
cwd: this.cwd,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
async initializeFormatters({ eventBroadcaster, eventDataCollector, formatOptions, formats, supportCodeLibrary, }) {
|
|
62
|
-
const formatters = await bluebird_1.default.map(formats, async ({ type, outputTo }) => {
|
|
63
|
-
let stream = this.stdout;
|
|
64
|
-
if (outputTo !== '') {
|
|
65
|
-
if (outputTo.match(/^https?:\/\//) !== null) {
|
|
66
|
-
const headers = {};
|
|
67
|
-
if (process.env.CUCUMBER_PUBLISH_TOKEN !== undefined) {
|
|
68
|
-
headers.Authorization = `Bearer ${process.env.CUCUMBER_PUBLISH_TOKEN}`;
|
|
69
|
-
}
|
|
70
|
-
stream = new http_stream_1.default(outputTo, 'GET', headers);
|
|
71
|
-
const readerStream = new stream_1.Writable({
|
|
72
|
-
objectMode: true,
|
|
73
|
-
write: function (responseBody, encoding, writeCallback) {
|
|
74
|
-
console.error(responseBody);
|
|
75
|
-
writeCallback();
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
stream.pipe(readerStream);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
const fd = await fs_1.default.open(path_1.default.resolve(this.cwd, outputTo), 'w');
|
|
82
|
-
stream = fs_1.default.createWriteStream(null, { fd });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
stream.on('error', (error) => {
|
|
86
|
-
console.error(error.message);
|
|
87
|
-
process.exit(1);
|
|
88
|
-
});
|
|
89
|
-
const typeOptions = {
|
|
90
|
-
cwd: this.cwd,
|
|
91
|
-
eventBroadcaster,
|
|
92
|
-
eventDataCollector,
|
|
93
|
-
log: stream.write.bind(stream),
|
|
94
|
-
parsedArgvOptions: formatOptions,
|
|
95
|
-
stream,
|
|
96
|
-
cleanup: stream === this.stdout
|
|
97
|
-
? async () => await Promise.resolve()
|
|
98
|
-
: bluebird_1.default.promisify(stream.end.bind(stream)),
|
|
99
|
-
supportCodeLibrary,
|
|
100
|
-
};
|
|
101
|
-
if (value_checker_1.doesNotHaveValue(formatOptions.colorsEnabled)) {
|
|
102
|
-
typeOptions.parsedArgvOptions.colorsEnabled = stream.isTTY;
|
|
103
|
-
}
|
|
104
|
-
if (type === 'progress-bar' && !stream.isTTY) {
|
|
105
|
-
const outputToName = outputTo === '' ? 'stdout' : outputTo;
|
|
106
|
-
console.warn(`Cannot use 'progress-bar' formatter for output to '${outputToName}' as not a TTY. Switching to 'progress' formatter.`);
|
|
107
|
-
type = 'progress';
|
|
108
|
-
}
|
|
109
|
-
return builder_1.default.build(type, typeOptions);
|
|
110
|
-
});
|
|
111
|
-
return async function () {
|
|
112
|
-
await bluebird_1.default.each(formatters, async (formatter) => {
|
|
113
|
-
await formatter.finished();
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
getSupportCodeLibrary({ newId, supportCodeRequiredModules, supportCodePaths, }) {
|
|
118
|
-
supportCodeRequiredModules.map((module) => require(module));
|
|
119
|
-
support_code_library_builder_1.default.reset(this.cwd, newId);
|
|
120
|
-
supportCodePaths.forEach((codePath) => {
|
|
121
|
-
try {
|
|
122
|
-
require(codePath);
|
|
123
|
-
}
|
|
124
|
-
catch (e) {
|
|
125
|
-
console.error(e.stack);
|
|
126
|
-
console.error('codepath: ' + codePath);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
return support_code_library_builder_1.default.finalize();
|
|
12
|
+
this.stderr = stderr;
|
|
13
|
+
this.env = env;
|
|
130
14
|
}
|
|
131
15
|
async run() {
|
|
132
|
-
await install_validator_1.validateInstall(this.cwd);
|
|
133
|
-
const configuration =
|
|
134
|
-
if (
|
|
135
|
-
this.stdout.write(
|
|
136
|
-
return {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
const newId = configuration.predictableIds && configuration.parallel <= 1
|
|
143
|
-
? incrementing()
|
|
144
|
-
: uuid();
|
|
145
|
-
const supportCodeLibrary = this.getSupportCodeLibrary({
|
|
146
|
-
newId,
|
|
147
|
-
supportCodePaths: configuration.supportCodePaths,
|
|
148
|
-
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
|
149
|
-
});
|
|
150
|
-
const eventBroadcaster = new events_1.EventEmitter();
|
|
151
|
-
const eventDataCollector = new helpers_1.EventDataCollector(eventBroadcaster);
|
|
152
|
-
const cleanup = await this.initializeFormatters({
|
|
153
|
-
eventBroadcaster,
|
|
154
|
-
eventDataCollector,
|
|
155
|
-
formatOptions: configuration.formatOptions,
|
|
156
|
-
formats: configuration.formats,
|
|
157
|
-
supportCodeLibrary,
|
|
158
|
-
});
|
|
159
|
-
await helpers_2.emitMetaMessage(eventBroadcaster);
|
|
160
|
-
const gherkinMessageStream = gherkin_streams_1.GherkinStreams.fromPaths(configuration.featurePaths, {
|
|
161
|
-
defaultDialect: configuration.featureDefaultLanguage,
|
|
162
|
-
newId,
|
|
163
|
-
relativeTo: this.cwd,
|
|
164
|
-
});
|
|
165
|
-
let pickleIds = [];
|
|
166
|
-
if (configuration.featurePaths.length > 0) {
|
|
167
|
-
pickleIds = await helpers_2.parseGherkinMessageStream({
|
|
168
|
-
cwd: this.cwd,
|
|
169
|
-
eventBroadcaster,
|
|
170
|
-
eventDataCollector,
|
|
171
|
-
gherkinMessageStream,
|
|
172
|
-
order: configuration.order,
|
|
173
|
-
pickleFilter: new pickle_filter_1.default(configuration.pickleFilterOptions),
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
helpers_2.emitSupportCodeMessages({
|
|
177
|
-
eventBroadcaster,
|
|
178
|
-
supportCodeLibrary,
|
|
179
|
-
newId,
|
|
180
|
-
});
|
|
181
|
-
let success;
|
|
182
|
-
if (configuration.parallel > 1) {
|
|
183
|
-
const parallelRuntimeCoordinator = new coordinator_1.default({
|
|
184
|
-
cwd: this.cwd,
|
|
185
|
-
eventBroadcaster,
|
|
186
|
-
eventDataCollector,
|
|
187
|
-
options: configuration.runtimeOptions,
|
|
188
|
-
newId,
|
|
189
|
-
pickleIds,
|
|
190
|
-
supportCodeLibrary,
|
|
191
|
-
supportCodePaths: configuration.supportCodePaths,
|
|
192
|
-
supportCodeRequiredModules: configuration.supportCodeRequiredModules,
|
|
193
|
-
});
|
|
194
|
-
success = await parallelRuntimeCoordinator.run(configuration.parallel);
|
|
16
|
+
await (0, install_validator_1.validateInstall)(this.cwd);
|
|
17
|
+
const { options, configuration: argvConfiguration } = configuration_1.ArgvParser.parse(this.argv);
|
|
18
|
+
if (options.i18nLanguages) {
|
|
19
|
+
this.stdout.write((0, i18n_1.getLanguages)());
|
|
20
|
+
return {
|
|
21
|
+
shouldAdvertisePublish: false,
|
|
22
|
+
shouldExitImmediately: true,
|
|
23
|
+
success: true,
|
|
24
|
+
};
|
|
195
25
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
supportCodeLibrary,
|
|
204
|
-
});
|
|
205
|
-
success = await runtime.start();
|
|
26
|
+
if (options.i18nKeywords) {
|
|
27
|
+
this.stdout.write((0, i18n_1.getKeywords)(options.i18nKeywords));
|
|
28
|
+
return {
|
|
29
|
+
shouldAdvertisePublish: false,
|
|
30
|
+
shouldExitImmediately: true,
|
|
31
|
+
success: true,
|
|
32
|
+
};
|
|
206
33
|
}
|
|
207
|
-
|
|
34
|
+
const environment = {
|
|
35
|
+
cwd: this.cwd,
|
|
36
|
+
stdout: this.stdout,
|
|
37
|
+
stderr: this.stderr,
|
|
38
|
+
env: this.env,
|
|
39
|
+
};
|
|
40
|
+
const { useConfiguration: configuration, runConfiguration } = await (0, api_1.loadConfiguration)({
|
|
41
|
+
file: options.config,
|
|
42
|
+
profiles: options.profile,
|
|
43
|
+
provided: argvConfiguration,
|
|
44
|
+
}, environment);
|
|
45
|
+
const { success } = await (0, api_1.runCucumber)(runConfiguration, environment);
|
|
208
46
|
return {
|
|
209
|
-
|
|
47
|
+
shouldAdvertisePublish: !runConfiguration.formats.publish &&
|
|
48
|
+
!configuration.publishQuiet &&
|
|
49
|
+
!(0, configuration_1.isTruthyString)(this.env.CUCUMBER_PUBLISH_QUIET),
|
|
50
|
+
shouldExitImmediately: configuration.forceExit,
|
|
210
51
|
success,
|
|
211
52
|
};
|
|
212
53
|
}
|