@cucumber/cucumber 9.6.0 → 10.0.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 +2 -2
- package/lib/api/console_logger.d.ts +1 -1
- package/lib/api/console_logger.js +5 -2
- package/lib/api/console_logger.js.map +1 -1
- package/lib/api/convert_configuration.d.ts +1 -1
- package/lib/api/convert_configuration.js +2 -2
- package/lib/api/convert_configuration.js.map +1 -1
- package/lib/api/formatters.d.ts +2 -2
- package/lib/api/formatters.js +6 -6
- package/lib/api/formatters.js.map +1 -1
- package/lib/api/gherkin.d.ts +1 -1
- package/lib/api/gherkin.js +1 -1
- package/lib/api/gherkin.js.map +1 -1
- package/lib/api/load_configuration.js +1 -2
- package/lib/api/load_configuration.js.map +1 -1
- package/lib/api/load_sources.js +1 -1
- package/lib/api/load_sources.js.map +1 -1
- package/lib/api/load_support.d.ts +1 -1
- package/lib/api/load_support.js.map +1 -1
- package/lib/api/paths.d.ts +1 -1
- package/lib/api/paths.js +18 -17
- package/lib/api/paths.js.map +1 -1
- package/lib/api/plugins.d.ts +1 -1
- package/lib/api/plugins.js.map +1 -1
- package/lib/api/run_cucumber.js +2 -2
- package/lib/api/run_cucumber.js.map +1 -1
- package/lib/api/runtime.d.ts +3 -3
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/support.js +2 -4
- package/lib/api/support.js.map +1 -1
- package/lib/api/test_helpers.js +8 -8
- package/lib/api/test_helpers.js.map +1 -1
- package/lib/api/types.d.ts +1 -1
- package/lib/api/types.js.map +1 -1
- package/lib/cli/helpers.d.ts +4 -4
- package/lib/cli/helpers.js +5 -5
- package/lib/cli/helpers.js.map +1 -1
- package/lib/cli/index.js +6 -1
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/run.js +1 -1
- package/lib/cli/run.js.map +1 -1
- package/lib/cli/validate_node_engine_version.js +4 -4
- package/lib/cli/validate_node_engine_version.js.map +1 -1
- package/lib/configuration/from_file.d.ts +1 -1
- package/lib/configuration/from_file.js +41 -21
- package/lib/configuration/from_file.js.map +1 -1
- package/lib/configuration/locate_file.js +2 -2
- package/lib/configuration/locate_file.js.map +1 -1
- package/lib/configuration/merge_configurations.js.map +1 -1
- package/lib/configuration/validate_configuration.d.ts +1 -1
- package/lib/configuration/validate_configuration.js +3 -0
- package/lib/configuration/validate_configuration.js.map +1 -1
- package/lib/filter_stack_trace.js +4 -4
- package/lib/filter_stack_trace.js.map +1 -1
- package/lib/formatter/builder.d.ts +5 -5
- package/lib/formatter/builder.js +11 -24
- package/lib/formatter/builder.js.map +1 -1
- package/lib/formatter/get_color_fns.d.ts +1 -1
- package/lib/formatter/get_color_fns.js.map +1 -1
- package/lib/formatter/helpers/event_data_collector.d.ts +1 -1
- package/lib/formatter/helpers/event_data_collector.js +5 -5
- package/lib/formatter/helpers/event_data_collector.js.map +1 -1
- package/lib/formatter/helpers/issue_helpers.js.map +1 -1
- package/lib/formatter/helpers/location_helpers.js +2 -2
- package/lib/formatter/helpers/location_helpers.js.map +1 -1
- package/lib/formatter/helpers/pickle_parser.js.map +1 -1
- package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
- package/lib/formatter/helpers/summary_helpers.d.ts +1 -1
- package/lib/formatter/helpers/summary_helpers.js +1 -1
- package/lib/formatter/helpers/summary_helpers.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js +1 -1
- package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -1
- package/lib/formatter/helpers/test_case_attempt_parser.js +3 -3
- package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
- package/lib/formatter/helpers/usage_helpers/index.js +1 -1
- package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
- package/lib/formatter/html_formatter.js +6 -5
- package/lib/formatter/html_formatter.js.map +1 -1
- package/lib/formatter/index.d.ts +3 -3
- package/lib/formatter/index.js +10 -0
- package/lib/formatter/index.js.map +1 -1
- package/lib/formatter/json_formatter.d.ts +1 -1
- package/lib/formatter/json_formatter.js +10 -8
- package/lib/formatter/json_formatter.js.map +1 -1
- package/lib/formatter/junit_formatter.js +11 -12
- package/lib/formatter/junit_formatter.js.map +1 -1
- package/lib/formatter/message_formatter.js +1 -1
- package/lib/formatter/message_formatter.js.map +1 -1
- package/lib/formatter/progress_bar_formatter.d.ts +1 -1
- package/lib/formatter/progress_bar_formatter.js +8 -4
- package/lib/formatter/progress_bar_formatter.js.map +1 -1
- package/lib/formatter/progress_formatter.d.ts +1 -1
- package/lib/formatter/progress_formatter.js +3 -3
- package/lib/formatter/progress_formatter.js.map +1 -1
- package/lib/formatter/rerun_formatter.js +5 -4
- package/lib/formatter/rerun_formatter.js.map +1 -1
- package/lib/formatter/snippets_formatter.js +4 -4
- package/lib/formatter/snippets_formatter.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/index.d.ts +2 -2
- package/lib/formatter/step_definition_snippet_builder/index.js +3 -1
- package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +1 -0
- package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
- package/lib/formatter/summary_formatter.d.ts +1 -1
- package/lib/formatter/summary_formatter.js +4 -4
- package/lib/formatter/summary_formatter.js.map +1 -1
- package/lib/formatter/usage_formatter.js +4 -4
- package/lib/formatter/usage_formatter.js.map +1 -1
- package/lib/formatter/usage_json_formatter.js +2 -2
- package/lib/formatter/usage_json_formatter.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/models/data_table.js +1 -0
- package/lib/models/data_table.js.map +1 -1
- package/lib/models/definition.d.ts +1 -1
- package/lib/models/definition.js +6 -0
- package/lib/models/definition.js.map +1 -1
- package/lib/models/step_definition.d.ts +1 -1
- package/lib/models/step_definition.js +5 -2
- package/lib/models/step_definition.js.map +1 -1
- package/lib/models/test_case_hook_definition.d.ts +1 -1
- package/lib/models/test_case_hook_definition.js +3 -0
- package/lib/models/test_case_hook_definition.js.map +1 -1
- package/lib/models/test_step_hook_definition.d.ts +1 -1
- package/lib/models/test_step_hook_definition.js +2 -0
- package/lib/models/test_step_hook_definition.js.map +1 -1
- package/lib/pickle_filter.js +11 -5
- package/lib/pickle_filter.js.map +1 -1
- package/lib/plugin/plugin_manager.d.ts +1 -1
- package/lib/plugin/plugin_manager.js +3 -2
- package/lib/plugin/plugin_manager.js.map +1 -1
- package/lib/plugin/types.d.ts +1 -1
- package/lib/plugin/types.js.map +1 -1
- package/lib/publish/http_stream.d.ts +2 -2
- package/lib/publish/http_stream.js +14 -9
- package/lib/publish/http_stream.js.map +1 -1
- package/lib/publish/publish_plugin.js +3 -3
- package/lib/publish/publish_plugin.js.map +1 -1
- package/lib/runtime/assemble_test_cases.d.ts +1 -1
- package/lib/runtime/assemble_test_cases.js.map +1 -1
- package/lib/runtime/attachment_manager/index.d.ts +1 -1
- package/lib/runtime/attachment_manager/index.js +1 -0
- package/lib/runtime/attachment_manager/index.js.map +1 -1
- package/lib/runtime/format_error.js +1 -1
- package/lib/runtime/format_error.js.map +1 -1
- package/lib/runtime/helpers.d.ts +1 -1
- package/lib/runtime/helpers.js +2 -2
- package/lib/runtime/helpers.js.map +1 -1
- package/lib/runtime/index.d.ts +1 -1
- package/lib/runtime/index.js +9 -0
- package/lib/runtime/index.js.map +1 -1
- package/lib/runtime/parallel/coordinator.d.ts +4 -4
- package/lib/runtime/parallel/coordinator.js +24 -5
- 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.js +14 -6
- package/lib/runtime/parallel/worker.js.map +1 -1
- package/lib/runtime/run_test_run_hooks.js +1 -1
- package/lib/runtime/run_test_run_hooks.js.map +1 -1
- package/lib/runtime/step_runner.js +2 -2
- package/lib/runtime/step_runner.js.map +1 -1
- package/lib/runtime/stopwatch.js +2 -0
- package/lib/runtime/stopwatch.js.map +1 -1
- package/lib/runtime/test_case_runner.d.ts +1 -1
- package/lib/runtime/test_case_runner.js +19 -3
- package/lib/runtime/test_case_runner.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/get_definition_line_and_uri.js +2 -2
- package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
- package/lib/support_code_library_builder/index.d.ts +1 -1
- package/lib/support_code_library_builder/index.js +24 -8
- package/lib/support_code_library_builder/index.js.map +1 -1
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js +1 -4
- package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -1
- package/lib/support_code_library_builder/world.js +3 -0
- package/lib/support_code_library_builder/world.js.map +1 -1
- package/lib/time.d.ts +1 -1
- package/lib/time.js +2 -2
- package/lib/time.js.map +1 -1
- package/lib/user_code_runner.js +3 -3
- package/lib/user_code_runner.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +16 -14
- package/lib/formatter/fixtures/typescript.d.ts +0 -2
- package/lib/formatter/fixtures/typescript.js +0 -6
- package/lib/formatter/fixtures/typescript.js.map +0 -1
- package/lib/importer.js +0 -13
package/lib/api/test_helpers.js
CHANGED
|
@@ -4,24 +4,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.teardownEnvironment = exports.setupEnvironment = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const node_stream_1 = require("node:stream");
|
|
8
9
|
const fs_1 = __importDefault(require("mz/fs"));
|
|
9
10
|
const reindent_template_literals_1 = require("reindent-template-literals");
|
|
10
|
-
const stream_1 = require("stream");
|
|
11
11
|
const messages_1 = require("@cucumber/messages");
|
|
12
12
|
const newId = messages_1.IdGenerator.uuid();
|
|
13
13
|
async function setupEnvironment() {
|
|
14
|
-
const cwd =
|
|
15
|
-
await fs_1.default.mkdir(
|
|
16
|
-
await fs_1.default.writeFile(
|
|
14
|
+
const cwd = node_path_1.default.join(__dirname, '..', '..', 'tmp', `api_${newId()}`);
|
|
15
|
+
await fs_1.default.mkdir(node_path_1.default.join(cwd, 'features'), { recursive: true });
|
|
16
|
+
await fs_1.default.writeFile(node_path_1.default.join(cwd, 'features', 'test.feature'), (0, reindent_template_literals_1.reindent)(`Feature: test fixture
|
|
17
17
|
Scenario: one
|
|
18
18
|
Given a step
|
|
19
19
|
Then another step`));
|
|
20
|
-
await fs_1.default.writeFile(
|
|
20
|
+
await fs_1.default.writeFile(node_path_1.default.join(cwd, 'features', 'steps.ts'), (0, reindent_template_literals_1.reindent)(`import { Given, Then } from '../../../src'
|
|
21
21
|
Given('a step', function () {})
|
|
22
22
|
Then('another step', function () {})`));
|
|
23
|
-
await fs_1.default.writeFile(
|
|
24
|
-
const stdout = new
|
|
23
|
+
await fs_1.default.writeFile(node_path_1.default.join(cwd, 'cucumber.mjs'), `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`);
|
|
24
|
+
const stdout = new node_stream_1.PassThrough();
|
|
25
25
|
return { cwd, stdout };
|
|
26
26
|
}
|
|
27
27
|
exports.setupEnvironment = setupEnvironment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_helpers.js","sourceRoot":"","sources":["../../src/api/test_helpers.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"test_helpers.js","sourceRoot":"","sources":["../../src/api/test_helpers.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,6CAAyC;AACzC,+CAAsB;AACtB,2EAAqD;AACrD,iDAAgD;AAGhD,MAAM,KA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["import path from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport fs from 'mz/fs'\nimport { reindent } from 'reindent-template-literals'\nimport { IdGenerator } from '@cucumber/messages'\nimport { IRunEnvironment } from './types'\n\nconst newId = IdGenerator.uuid()\n\nexport async function setupEnvironment(): Promise<Partial<IRunEnvironment>> {\n const cwd = path.join(__dirname, '..', '..', 'tmp', `api_${newId()}`)\n await fs.mkdir(path.join(cwd, 'features'), { recursive: true })\n await fs.writeFile(\n path.join(cwd, 'features', 'test.feature'),\n reindent(`Feature: test fixture\n Scenario: one\n Given a step\n Then another step`)\n )\n await fs.writeFile(\n path.join(cwd, 'features', 'steps.ts'),\n reindent(`import { Given, Then } from '../../../src'\n Given('a step', function () {})\n Then('another step', function () {})`)\n )\n await fs.writeFile(\n path.join(cwd, 'cucumber.mjs'),\n `export default {paths: ['features/test.feature'], requireModule: ['ts-node/register'], require: ['features/steps.ts']}`\n )\n const stdout = new PassThrough()\n return { cwd, stdout }\n}\n\nexport async function teardownEnvironment(environment: IRunEnvironment) {\n return new Promise((resolve) => {\n fs.rm(environment.cwd, { recursive: true }, resolve)\n }).then(() => {\n environment.stdout.end()\n })\n}\n"]}
|
package/lib/api/types.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
3
4
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
4
5
|
import { FormatOptions, IPublishConfig } from '../formatter';
|
|
5
6
|
import { PickleOrder } from '../models/pickle_order';
|
|
6
7
|
import { IRuntimeOptions } from '../runtime';
|
|
7
8
|
import { IConfiguration } from '../configuration';
|
|
8
|
-
import { Writable } from 'stream';
|
|
9
9
|
/**
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
package/lib/api/types.js.map
CHANGED
|
@@ -1 +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, IPublishConfig } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\nimport { IRuntimeOptions } from '../runtime'\nimport { IConfiguration } from '../configuration'\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Writable } from 'node:stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { FormatOptions, IPublishConfig } 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: IPublishConfig | 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 type { 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?: Writable\n /**\n * Writable stream where the test run's warning/error output is written (defaults to `process.stderr` if omitted).\n */\n stderr?: Writable\n /**\n * Environment variables (defaults to `process.env` if omitted).\n */\n env?: NodeJS.ProcessEnv\n /**\n * Whether debug logging is enabled.\n */\n debug?: boolean\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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import
|
|
6
|
-
import { EventDataCollector } from '../formatter/helpers';
|
|
7
|
-
import { Readable } from 'stream';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { Readable } from 'node:stream';
|
|
8
6
|
import { IdGenerator } from '@cucumber/messages';
|
|
7
|
+
import { EventDataCollector } from '../formatter/helpers';
|
|
8
|
+
import PickleFilter from '../pickle_filter';
|
|
9
9
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
10
10
|
import { PickleOrder } from '../models/pickle_order';
|
|
11
11
|
import { ILogger } from '../logger';
|
package/lib/cli/helpers.js
CHANGED
|
@@ -27,11 +27,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.emitSupportCodeMessages = exports.emitMetaMessage = exports.orderPickles = exports.parseGherkinMessageStream = void 0;
|
|
30
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
30
31
|
const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
|
|
31
|
-
const value_checker_1 = require("../value_checker");
|
|
32
|
-
const os_1 = __importDefault(require("os"));
|
|
33
32
|
const messages = __importStar(require("@cucumber/messages"));
|
|
34
33
|
const ci_environment_1 = __importDefault(require("@cucumber/ci-environment"));
|
|
34
|
+
const value_checker_1 = require("../value_checker");
|
|
35
35
|
const version_1 = require("../version");
|
|
36
36
|
/**
|
|
37
37
|
* Process a stream of envelopes from Gherkin and resolve to an array of filtered, ordered pickle Ids
|
|
@@ -99,11 +99,11 @@ async function emitMetaMessage(eventBroadcaster, env) {
|
|
|
99
99
|
name: 'cucumber-js',
|
|
100
100
|
},
|
|
101
101
|
cpu: {
|
|
102
|
-
name:
|
|
102
|
+
name: node_os_1.default.arch(),
|
|
103
103
|
},
|
|
104
104
|
os: {
|
|
105
|
-
name:
|
|
106
|
-
version:
|
|
105
|
+
name: node_os_1.default.platform(),
|
|
106
|
+
version: node_os_1.default.release(),
|
|
107
107
|
},
|
|
108
108
|
runtime: {
|
|
109
109
|
name: 'node.js',
|
package/lib/cli/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gFAA0C;AAI1C,oDAAgD;AAEhD,4CAAmB;AACnB,6DAA8C;AAE9C,8EAA0D;AAK1D,wCAAoC;AAapC;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAAC,EAC9C,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,YAAY,GACsB;IAClC,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAA2B,EAAE,EAAE;YAC9D,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3C,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAA;gBAC1B,MAAM,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAC3D,MAAM,CAAC,GAAG,CACX,CAAA;gBACD,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE;oBACrD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;iBACtB;aACF;QACH,CAAC,CAAC,CAAA;QACF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAClC,YAAY,CAAC,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sBAAsB,CAAC,IAAI;gBACjC,aAAa,EAAE,sBAAsB,CAAC,aAAa;gBACnD,eAAe,EAAE,mBAAmB,CAAC,sBAAsB,CAAC;aAC7D;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,mBAAmB,CAAC,qBAAqB,CAAC;aAC5D;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 { 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 { version } from '../version'\nimport { ILogger } from '../logger'\nimport { ILineAndUri } from '../types'\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 * @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: ILogger\n): void {\n const [type, seed] = splitOrder(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\nfunction splitOrder(order: string) {\n if (!order.includes(':')) {\n return [order, '']\n }\n return order.split(':')\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\nconst makeSourceReference = (source: ILineAndUri) => ({\n uri: source.uri,\n location: {\n line: source.line,\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 (parameterType.builtin) {\n continue\n }\n const source =\n supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType)\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 sourceReference: makeSourceReference(source),\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: makeSourceReference(stepDefinition),\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 name: testCaseHookDefinition.name,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: makeSourceReference(testCaseHookDefinition),\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: makeSourceReference(testRunHookDefinition),\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
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/cli/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sDAAwB;AACxB,gFAA0C;AAC1C,6DAA8C;AAE9C,8EAA0D;AAC1D,oDAAgD;AAOhD,wCAAoC;AAapC;;;;;;;;GAQG;AACI,KAAK,UAAU,yBAAyB,CAAC,EAC9C,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,YAAY,GACsB;IAClC,OAAO,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrD,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAA2B,EAAE,EAAE;YAC9D,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;YAC3C,IAAI,IAAA,6BAAa,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;gBAC9B,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAA;gBAC1B,MAAM,eAAe,GAAG,kBAAkB,CAAC,kBAAkB,CAC3D,MAAM,CAAC,GAAG,CACX,CAAA;gBACD,IAAI,YAAY,CAAC,OAAO,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,EAAE;oBACrD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;iBACtB;aACF;QACH,CAAC,CAAC,CAAA;QACF,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YAClC,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;YACpC,OAAO,CAAC,MAAM,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,oBAAoB,C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D;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,mBAAmB,CAAC,qBAAqB,CAAC;aAC5D;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 { EventEmitter } from 'node:events'\nimport { Readable } from 'node:stream'\nimport os from 'node:os'\nimport shuffle from 'knuth-shuffle-seeded'\nimport * as messages from '@cucumber/messages'\nimport { IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { doesHaveValue } from '../value_checker'\nimport { EventDataCollector } from '../formatter/helpers'\nimport PickleFilter from '../pickle_filter'\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 { version } from '../version'\nimport { ILogger } from '../logger'\nimport { ILineAndUri } from '../types'\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 * @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: ILogger\n): void {\n const [type, seed] = splitOrder(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\nfunction splitOrder(order: string) {\n if (!order.includes(':')) {\n return [order, '']\n }\n return order.split(':')\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\nconst makeSourceReference = (source: ILineAndUri) => ({\n uri: source.uri,\n location: {\n line: source.line,\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 (parameterType.builtin) {\n continue\n }\n const source =\n supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType)\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 sourceReference: makeSourceReference(source),\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: makeSourceReference(stepDefinition),\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 name: testCaseHookDefinition.name,\n tagExpression: testCaseHookDefinition.tagExpression,\n sourceReference: makeSourceReference(testCaseHookDefinition),\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: makeSourceReference(testRunHookDefinition),\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/index.js
CHANGED
|
@@ -3,12 +3,17 @@ 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 debug_1 = __importDefault(require("debug"));
|
|
6
7
|
const configuration_1 = require("../configuration");
|
|
7
8
|
const api_1 = require("../api");
|
|
8
9
|
const i18n_1 = require("./i18n");
|
|
9
10
|
const install_validator_1 = require("./install_validator");
|
|
10
|
-
const debug_1 = __importDefault(require("debug"));
|
|
11
11
|
class Cli {
|
|
12
|
+
argv;
|
|
13
|
+
cwd;
|
|
14
|
+
stdout;
|
|
15
|
+
stderr;
|
|
16
|
+
env;
|
|
12
17
|
constructor({ argv, cwd, stdout, stderr = process.stderr, env, }) {
|
|
13
18
|
this.argv = argv;
|
|
14
19
|
this.cwd = cwd;
|
package/lib/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;AAAA,oDAA6C;AAE7C,gCAAuD;AACvD,iCAAkD;AAClD,2DAAqD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,oDAA6C;AAE7C,gCAAuD;AACvD,iCAAkD;AAClD,2DAAqD;AAOrD,MAAqB,GAAG;IACL,IAAI,CAAU;IACd,GAAG,CAAQ;IACX,MAAM,CAAkB;IACxB,MAAM,CAAkB;IACxB,GAAG,CAAmB;IAEvC,YAAY,EACV,IAAI,EACJ,GAAG,EACH,MAAM,EACN,MAAM,GAAG,OAAO,CAAC,MAAM,EACvB,GAAG,GAOJ;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAA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WAAW,CAAC,CAAA;QACpE,OAAO;YACL,qBAAqB,EAAE,aAAa,CAAC,SAAS;YAC9C,OAAO;SACR,CAAA;IACH,CAAC;CACF;AAxED,sBAwEC","sourcesContent":["import debug from 'debug'\nimport { ArgvParser } from '../configuration'\nimport { IFormatterStream } from '../formatter'\nimport { loadConfiguration, runCucumber } from '../api'\nimport { getKeywords, getLanguages } from './i18n'\nimport { validateInstall } from './install_validator'\n\nexport interface ICliRunResult {\n shouldExitImmediately: boolean\n success: boolean\n}\n\nexport default class Cli {\n private readonly argv: string[]\n private readonly cwd: string\n private readonly stdout: IFormatterStream\n private readonly stderr: IFormatterStream\n private readonly env: NodeJS.ProcessEnv\n\n constructor({\n argv,\n cwd,\n stdout,\n stderr = process.stderr,\n env,\n }: {\n argv: string[]\n cwd: string\n stdout: IFormatterStream\n stderr?: IFormatterStream\n env: NodeJS.ProcessEnv\n }) {\n this.argv = argv\n this.cwd = cwd\n this.stdout = stdout\n this.stderr = stderr\n this.env = env\n }\n\n async run(): Promise<ICliRunResult> {\n const debugEnabled = debug.enabled('cucumber')\n if (debugEnabled) {\n await validateInstall()\n }\n const { options, configuration: argvConfiguration } = ArgvParser.parse(\n this.argv\n )\n if (options.i18nLanguages) {\n this.stdout.write(getLanguages())\n return {\n shouldExitImmediately: true,\n success: true,\n }\n }\n if (options.i18nKeywords) {\n this.stdout.write(getKeywords(options.i18nKeywords))\n return {\n shouldExitImmediately: true,\n success: true,\n }\n }\n\n const environment = {\n cwd: this.cwd,\n stdout: this.stdout,\n stderr: this.stderr,\n env: this.env,\n debug: debugEnabled,\n }\n const { useConfiguration: configuration, runConfiguration } =\n await loadConfiguration(\n {\n file: options.config,\n profiles: options.profile,\n provided: argvConfiguration,\n },\n environment\n )\n const { success } = await runCucumber(runConfiguration, environment)\n return {\n shouldExitImmediately: configuration.forceExit,\n success,\n }\n }\n}\n"]}
|
package/lib/cli/run.js
CHANGED
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
/* eslint-disable no-console */
|
|
7
7
|
/* This is one rare place where we're fine to use process/console directly,
|
|
8
8
|
* but other code abstracts those to remain composable and testable. */
|
|
9
|
-
const _1 = __importDefault(require("./"));
|
|
10
9
|
const verror_1 = __importDefault(require("verror"));
|
|
11
10
|
const validate_node_engine_version_1 = require("./validate_node_engine_version");
|
|
11
|
+
const _1 = __importDefault(require("./"));
|
|
12
12
|
function logErrorMessageAndExit(message) {
|
|
13
13
|
console.error(message);
|
|
14
14
|
process.exit(1);
|
package/lib/cli/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,oDAA2B;AAC3B,iFAA0E;AAC1E,0CAAuC;AAEvC,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\nimport Cli, { ICliRunResult } from './'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
|
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateNodeEngineVersion = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const semver_1 = __importDefault(require("semver"));
|
|
10
|
-
const readActualPackageJSON = () => JSON.parse(
|
|
11
|
-
.readFileSync(
|
|
10
|
+
const readActualPackageJSON = () => JSON.parse(node_fs_1.default
|
|
11
|
+
.readFileSync(node_path_1.default.resolve(__dirname, '..', '..', 'package.json'))
|
|
12
12
|
.toString());
|
|
13
13
|
function validateNodeEngineVersion(currentVersion, onError, onWarning, readPackageJSON = readActualPackageJSON) {
|
|
14
14
|
const requiredVersions = readPackageJSON().engines.node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwB;AACxB,0DAA4B;AAC5B,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,iBAAE;KACC,YAAY,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,SAAS,CACP,yBAAyB,cAAc,yIAAyI,CACjL,CAAA;KACF;AACH,CAAC;AAjBD,8DAiBC","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport semver from 'semver'\n\ntype PackageJSON = {\n engines: { node: string }\n enginesTested: { node: string }\n}\n\nconst readActualPackageJSON: () => PackageJSON = () =>\n JSON.parse(\n fs\n .readFileSync(path.resolve(__dirname, '..', '..', 'package.json'))\n .toString()\n )\n\nexport function validateNodeEngineVersion(\n currentVersion: string,\n onError: (message: string) => void,\n onWarning: (message: string) => void,\n readPackageJSON: () => PackageJSON = readActualPackageJSON\n): void {\n const requiredVersions = readPackageJSON().engines.node\n const testedVersions = readPackageJSON().enginesTested.node\n if (!semver.satisfies(currentVersion, requiredVersions)) {\n onError(\n `Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`\n )\n } else if (!semver.satisfies(currentVersion, testedVersions)) {\n onWarning(\n `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`\n )\n }\n}\n"]}
|
|
@@ -4,19 +4,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fromFile = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const node_util_1 = require("node:util");
|
|
10
|
+
const node_url_1 = require("node:url");
|
|
7
11
|
const string_argv_1 = __importDefault(require("string-argv"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
12
|
const yaml_1 = __importDefault(require("yaml"));
|
|
11
|
-
const
|
|
12
|
-
const url_1 = require("url");
|
|
13
|
+
const read_pkg_up_1 = __importDefault(require("read-pkg-up"));
|
|
13
14
|
const merge_configurations_1 = require("./merge_configurations");
|
|
14
15
|
const argv_parser_1 = __importDefault(require("./argv_parser"));
|
|
15
16
|
const check_schema_1 = require("./check_schema");
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
|
-
const { importer } = require('../importer');
|
|
18
17
|
async function fromFile(logger, cwd, file, profiles = []) {
|
|
19
|
-
const definitions = await loadFile(cwd, file);
|
|
18
|
+
const definitions = await loadFile(logger, cwd, file);
|
|
20
19
|
if (!definitions.default) {
|
|
21
20
|
logger.debug('No default profile defined in configuration file');
|
|
22
21
|
definitions.default = {};
|
|
@@ -34,37 +33,58 @@ async function fromFile(logger, cwd, file, profiles = []) {
|
|
|
34
33
|
return (0, merge_configurations_1.mergeConfigurations)({}, ...profiles.map((profileKey) => extractConfiguration(logger, profileKey, definitions[profileKey])));
|
|
35
34
|
}
|
|
36
35
|
exports.fromFile = fromFile;
|
|
37
|
-
async function loadFile(cwd, file) {
|
|
38
|
-
const filePath =
|
|
39
|
-
const extension =
|
|
36
|
+
async function loadFile(logger, cwd, file) {
|
|
37
|
+
const filePath = node_path_1.default.join(cwd, file);
|
|
38
|
+
const extension = node_path_1.default.extname(filePath);
|
|
40
39
|
let definitions;
|
|
41
40
|
switch (extension) {
|
|
42
41
|
case '.json':
|
|
43
|
-
definitions = JSON.parse(await (0,
|
|
42
|
+
definitions = JSON.parse(await (0, node_util_1.promisify)(node_fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
|
|
44
43
|
break;
|
|
45
44
|
case '.yaml':
|
|
46
45
|
case '.yml':
|
|
47
|
-
definitions = yaml_1.default.parse(await (0,
|
|
46
|
+
definitions = yaml_1.default.parse(await (0, node_util_1.promisify)(node_fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
|
|
48
47
|
break;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
case '.cjs':
|
|
49
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on extension`);
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
51
|
+
definitions = require(filePath);
|
|
52
|
+
break;
|
|
53
|
+
case '.mjs':
|
|
54
|
+
logger.debug(`Loading configuration file "${file}" as ESM based on extension`);
|
|
55
|
+
definitions = await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
56
|
+
break;
|
|
57
|
+
case '.js':
|
|
58
|
+
{
|
|
59
|
+
const parentPackage = await readPackageJson(filePath);
|
|
60
|
+
if (!parentPackage) {
|
|
61
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on absence of a parent package`);
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
63
|
+
definitions = require(filePath);
|
|
64
|
+
}
|
|
65
|
+
else if (parentPackage.type === 'module') {
|
|
66
|
+
logger.debug(`Loading configuration file "${file}" as ESM based on "${parentPackage.name}" package type`);
|
|
67
|
+
definitions = await import((0, node_url_1.pathToFileURL)(filePath).toString());
|
|
57
68
|
}
|
|
58
69
|
else {
|
|
59
|
-
|
|
70
|
+
logger.debug(`Loading configuration file "${file}" as CommonJS based on "${parentPackage.name}" package type`);
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
72
|
+
definitions = require(filePath);
|
|
60
73
|
}
|
|
61
74
|
}
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
throw new Error(`Unsupported configuration file extension "${extension}"`);
|
|
62
78
|
}
|
|
63
79
|
if (typeof definitions !== 'object') {
|
|
64
80
|
throw new Error(`Configuration file ${filePath} does not export an object`);
|
|
65
81
|
}
|
|
66
82
|
return definitions;
|
|
67
83
|
}
|
|
84
|
+
async function readPackageJson(filePath) {
|
|
85
|
+
const parentPackage = await (0, read_pkg_up_1.default)({ cwd: node_path_1.default.dirname(filePath) });
|
|
86
|
+
return parentPackage?.packageJson;
|
|
87
|
+
}
|
|
68
88
|
function extractConfiguration(logger, name, definition) {
|
|
69
89
|
if (typeof definition === 'string') {
|
|
70
90
|
logger.debug(`Profile "${name}" value is a string; parsing as argv`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwB;AACxB,0DAA4B;AAC5B,yCAAqC;AACrC,uCAAwC;AACxC,8DAAoC;AACpC,gDAAuB;AACvB,8DAAmC;AAGnC,iEAA4D;AAC5D,gEAAsC;AACtC,iDAA4C;AAErC,KAAK,UAAU,QAAQ,CAC5B,MAAe,EACf,GAAW,EACX,IAAY,EACZ,WAAqB,EAAE;IAEvB,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IACrD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxB,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;QAChE,WAAW,CAAC,OAAO,GAAG,EAAE,CAAA;KACzB;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAA;QAC5D,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAA;KACvB;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC5C,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,sBAAsB,UAAU,iBAAiB,CAAC,CAAA;SACnE;IACH,CAAC,CAAC,CA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,CAAC,KAAK,CAAC,YAAY,IAAI,sCAAsC,CAAC,CAAA;QACpE,MAAM,EAAE,aAAa,EAAE,GAAG,qBAAU,CAAC,KAAK,CAAC;YACzC,MAAM;YACN,aAAa;YACb,GAAG,IAAA,qBAAU,EAAC,UAAU,CAAC;SAC1B,CAAC,CAAA;QACF,OAAO,aAAa,CAAA;KACrB;IACD,IAAI;QACF,OAAO,IAAA,0BAAW,EAAC,UAAU,CAAC,CAAA;KAC/B;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,+BAA+B,KAAK,CAAC,MAAM,CAAC,IAAI,CACxE,GAAG,CACJ,EAAE,CACJ,CAAA;KACF;AACH,CAAC","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { promisify } from 'node:util'\nimport { pathToFileURL } from 'node:url'\nimport stringArgv from 'string-argv'\nimport YAML from 'yaml'\nimport readPkgUp from 'read-pkg-up'\nimport { ILogger } from '../logger'\nimport { IConfiguration } from './types'\nimport { mergeConfigurations } from './merge_configurations'\nimport ArgvParser from './argv_parser'\nimport { checkSchema } from './check_schema'\n\nexport async function fromFile(\n logger: ILogger,\n cwd: string,\n file: string,\n profiles: string[] = []\n): Promise<Partial<IConfiguration>> {\n const definitions = await loadFile(logger, cwd, file)\n if (!definitions.default) {\n logger.debug('No default profile defined in configuration file')\n definitions.default = {}\n }\n if (profiles.length < 1) {\n logger.debug('No profiles specified; using default profile')\n profiles = ['default']\n }\n const definedKeys = Object.keys(definitions)\n profiles.forEach((profileKey) => {\n if (!definedKeys.includes(profileKey)) {\n throw new Error(`Requested profile \"${profileKey}\" doesn't exist`)\n }\n })\n return mergeConfigurations(\n {},\n ...profiles.map((profileKey) =>\n extractConfiguration(logger, profileKey, definitions[profileKey])\n )\n )\n}\n\nasync function loadFile(\n logger: ILogger,\n cwd: string,\n file: string\n): Promise<Record<string, any>> {\n const filePath: string = path.join(cwd, file)\n const extension = path.extname(filePath)\n let definitions\n switch (extension) {\n case '.json':\n definitions = JSON.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n case '.yaml':\n case '.yml':\n definitions = YAML.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n case '.cjs':\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on extension`\n )\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n definitions = require(filePath)\n break\n case '.mjs':\n logger.debug(\n `Loading configuration file \"${file}\" as ESM based on extension`\n )\n definitions = await import(pathToFileURL(filePath).toString())\n break\n case '.js':\n {\n const parentPackage = await readPackageJson(filePath)\n if (!parentPackage) {\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on absence of a parent package`\n )\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n definitions = require(filePath)\n } else if (parentPackage.type === 'module') {\n logger.debug(\n `Loading configuration file \"${file}\" as ESM based on \"${parentPackage.name}\" package type`\n )\n definitions = await import(pathToFileURL(filePath).toString())\n } else {\n logger.debug(\n `Loading configuration file \"${file}\" as CommonJS based on \"${parentPackage.name}\" package type`\n )\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n definitions = require(filePath)\n }\n }\n break\n default:\n throw new Error(`Unsupported configuration file extension \"${extension}\"`)\n }\n if (typeof definitions !== 'object') {\n throw new Error(`Configuration file ${filePath} does not export an object`)\n }\n return definitions\n}\n\nasync function readPackageJson(filePath: string) {\n const parentPackage = await readPkgUp({ cwd: path.dirname(filePath) })\n return parentPackage?.packageJson\n}\n\nfunction extractConfiguration(\n logger: ILogger,\n name: string,\n definition: any\n): Partial<IConfiguration> {\n if (typeof definition === 'string') {\n logger.debug(`Profile \"${name}\" value is a string; parsing as argv`)\n const { configuration } = ArgvParser.parse([\n 'node',\n 'cucumber-js',\n ...stringArgv(definition),\n ])\n return configuration\n }\n try {\n return checkSchema(definition)\n } catch (error) {\n throw new Error(\n `Requested profile \"${name}\" failed schema validation: ${error.errors.join(\n ' '\n )}`\n )\n }\n}\n"]}
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.locateFile = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
7
8
|
const fs_1 = __importDefault(require("mz/fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const DEFAULT_FILENAMES = [
|
|
10
10
|
'cucumber.js',
|
|
11
11
|
'cucumber.cjs',
|
|
@@ -15,7 +15,7 @@ const DEFAULT_FILENAMES = [
|
|
|
15
15
|
'cucumber.yml',
|
|
16
16
|
];
|
|
17
17
|
function locateFile(cwd) {
|
|
18
|
-
return DEFAULT_FILENAMES.find((filename) => fs_1.default.existsSync(
|
|
18
|
+
return DEFAULT_FILENAMES.find((filename) => fs_1.default.existsSync(node_path_1.default.join(cwd, filename)));
|
|
19
19
|
}
|
|
20
20
|
exports.locateFile = locateFile;
|
|
21
21
|
//# sourceMappingURL=locate_file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locate_file.js","sourceRoot":"","sources":["../../src/configuration/locate_file.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAsB;
|
|
1
|
+
{"version":3,"file":"locate_file.js","sourceRoot":"","sources":["../../src/configuration/locate_file.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,+CAAsB;AAEtB,MAAM,iBAAiB,GAAG;IACxB,aAAa;IACb,cAAc;IACd,cAAc;IACd,eAAe;IACf,eAAe;IACf,cAAc;CACf,CAAA;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzC,YAAE,CAAC,UAAU,CAAC,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CACxC,CAAA;AACH,CAAC;AAJD,gCAIC","sourcesContent":["import path from 'node:path'\nimport fs from 'mz/fs'\n\nconst DEFAULT_FILENAMES = [\n 'cucumber.js',\n 'cucumber.cjs',\n 'cucumber.mjs',\n 'cucumber.json',\n 'cucumber.yaml',\n 'cucumber.yml',\n]\n\nexport function locateFile(cwd: string): string | undefined {\n return DEFAULT_FILENAMES.find((filename) =>\n fs.existsSync(path.join(cwd, filename))\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge_configurations.js","sourceRoot":"","sources":["../../src/configuration/merge_configurations.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"merge_configurations.js","sourceRoot":"","sources":["../../src/configuration/merge_configurations.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAwC;AAGxC,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,eAAe;CAChB,CAAA;AACD,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAElD,SAAS,WAAW,CAAC,QAAe,EAAE,QAAe;IACnD,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KACrC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB,EAAE,QAAgB;IAC7D,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAA;KAC3E;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAA;KACX;IACD,OAAO,IAAI,GAAG,GAAG,CAAA;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,QAAa,EAAE,QAAa,EAAE,GAAW;IAC3D,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,OAAO,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KACvC;IACD,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,OAAO,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KAC/C;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAgB,mBAAmB,CACjC,MAAS,EACT,GAAG,cAAyC;IAE5C,OAAO,IAAA,0BAAS,EAAC,EAAE,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,UAAU,CAAC,CAAA;AAC7D,CAAC;AALD,kDAKC","sourcesContent":["import mergeWith from 'lodash.mergewith'\nimport { IConfiguration } from './types'\n\nconst ADDITIVE_ARRAYS = [\n 'format',\n 'import',\n 'name',\n 'paths',\n 'require',\n 'requireModule',\n]\nconst TAG_EXPRESSIONS = ['tags', 'retryTagFilter']\n\nfunction mergeArrays(objValue: any[], srcValue: any[]) {\n if (objValue && srcValue) {\n return [].concat(objValue, srcValue)\n }\n return undefined\n}\n\nfunction mergeTagExpressions(objValue: string, srcValue: string) {\n if (objValue && srcValue) {\n return `${wrapTagExpression(objValue)} and ${wrapTagExpression(srcValue)}`\n }\n return undefined\n}\n\nfunction wrapTagExpression(raw: string) {\n if (raw.startsWith('(') && raw.endsWith(')')) {\n return raw\n }\n return `(${raw})`\n}\n\nfunction customizer(objValue: any, srcValue: any, key: string): any {\n if (ADDITIVE_ARRAYS.includes(key)) {\n return mergeArrays(objValue, srcValue)\n }\n if (TAG_EXPRESSIONS.includes(key)) {\n return mergeTagExpressions(objValue, srcValue)\n }\n return undefined\n}\n\nexport function mergeConfigurations<T = Partial<IConfiguration>>(\n source: T,\n ...configurations: Partial<IConfiguration>[]\n): T {\n return mergeWith({}, source, ...configurations, customizer)\n}\n"]}
|
|
@@ -5,6 +5,9 @@ function validateConfiguration(configuration, logger) {
|
|
|
5
5
|
if (configuration.publishQuiet) {
|
|
6
6
|
logger.warn('`publishQuiet` option is no longer needed, you can remove it from your configuration; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md');
|
|
7
7
|
}
|
|
8
|
+
if (configuration.requireModule.length && !configuration.require.length) {
|
|
9
|
+
logger.warn('Use of `require-module` option normally means you should specify your support code paths with `require`; see https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md#finding-your-code');
|
|
10
|
+
}
|
|
8
11
|
if (configuration.retryTagFilter && !configuration.retry) {
|
|
9
12
|
throw new Error('a positive `retry` count must be specified when setting `retryTagFilter`');
|
|
10
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate_configuration.js","sourceRoot":"","sources":["../../src/configuration/validate_configuration.ts"],"names":[],"mappings":";;;AAGA,SAAgB,qBAAqB,CACnC,aAA6B,EAC7B,MAAe;IAEf,IAAI,aAAa,CAAC,YAAY,EAAE;QAC9B,MAAM,CAAC,IAAI,CACT,kKAAkK,CACnK,CAAA;KACF;IACD,IAAI,aAAa,CAAC,cAAc,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;QACxD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAA;KACF;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"validate_configuration.js","sourceRoot":"","sources":["../../src/configuration/validate_configuration.ts"],"names":[],"mappings":";;;AAGA,SAAgB,qBAAqB,CACnC,aAA6B,EAC7B,MAAe;IAEf,IAAI,aAAa,CAAC,YAAY,EAAE;QAC9B,MAAM,CAAC,IAAI,CACT,kKAAkK,CACnK,CAAA;KACF;IACD,IAAI,aAAa,CAAC,aAAa,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE;QACvE,MAAM,CAAC,IAAI,CACT,wMAAwM,CACzM,CAAA;KACF;IACD,IAAI,aAAa,CAAC,cAAc,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;QACxD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAA;KACF;AACH,CAAC;AAnBD,sDAmBC","sourcesContent":["import { ILogger } from '../logger'\nimport { IConfiguration } from './types'\n\nexport function validateConfiguration(\n configuration: IConfiguration,\n logger: ILogger\n): void {\n if (configuration.publishQuiet) {\n logger.warn(\n '`publishQuiet` option is no longer needed, you can remove it from your configuration; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md'\n )\n }\n if (configuration.requireModule.length && !configuration.require.length) {\n logger.warn(\n 'Use of `require-module` option normally means you should specify your support code paths with `require`; see https://github.com/cucumber/cucumber-js/blob/main/docs/configuration.md#finding-your-code'\n )\n }\n if (configuration.retryTagFilter && !configuration.retry) {\n throw new Error(\n 'a positive `retry` count must be specified when setting `retryTagFilter`'\n )\n }\n}\n"]}
|
|
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.filterStackTrace = exports.isFileNameInCucumber = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const value_checker_1 = require("./value_checker");
|
|
9
|
-
const projectRootPath =
|
|
9
|
+
const projectRootPath = node_path_1.default.join(__dirname, '..');
|
|
10
10
|
const projectChildDirs = ['src', 'lib', 'node_modules'];
|
|
11
11
|
function isFileNameInCucumber(fileName) {
|
|
12
|
-
return projectChildDirs.some((dir) => fileName.startsWith(
|
|
12
|
+
return projectChildDirs.some((dir) => fileName.startsWith(node_path_1.default.join(projectRootPath, dir)));
|
|
13
13
|
}
|
|
14
14
|
exports.isFileNameInCucumber = isFileNameInCucumber;
|
|
15
15
|
function filterStackTrace(frames) {
|
|
@@ -33,6 +33,6 @@ function isFrameInCucumber(frame) {
|
|
|
33
33
|
}
|
|
34
34
|
function isFrameInNode(frame) {
|
|
35
35
|
const fileName = (0, value_checker_1.valueOrDefault)(frame.getFileName(), '');
|
|
36
|
-
return !fileName.includes(
|
|
36
|
+
return !fileName.includes(node_path_1.default.sep);
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=filter_stack_trace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter_stack_trace.js","sourceRoot":"","sources":["../src/filter_stack_trace.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"filter_stack_trace.js","sourceRoot":"","sources":["../src/filter_stack_trace.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,mDAAgD;AAEhD,MAAM,eAAe,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAClD,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,CAAC,CAAA;AAEvD,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CACnC,QAAQ,CAAC,UAAU,CAAC,mBAAI,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,CACrD,CAAA;AACH,CAAC;AAJD,oDAIC;AAED,SAAgB,gBAAgB,CAAC,MAAoB;IACnD,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE;QAC7B,OAAO,MAAM,CAAA;KACd;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3D,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;QAChB,OAAO,MAAM,CAAA;KACd;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;AAC/B,CAAC;AATD,4CASC;AAED,SAAS,iBAAiB,CAAC,MAAoB;IAC7C,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAA;IAC9D,OAAO,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,iBAAiB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAiB;IAC1C,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;IACxD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAA;AACvC,CAAC;AAED,SAAS,aAAa,CAAC,KAAiB;IACtC,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAA;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC","sourcesContent":["import path from 'node:path'\nimport { StackFrame } from 'error-stack-parser'\nimport { valueOrDefault } from './value_checker'\n\nconst projectRootPath = path.join(__dirname, '..')\nconst projectChildDirs = ['src', 'lib', 'node_modules']\n\nexport function isFileNameInCucumber(fileName: string): boolean {\n return projectChildDirs.some((dir) =>\n fileName.startsWith(path.join(projectRootPath, dir))\n )\n}\n\nexport function filterStackTrace(frames: StackFrame[]): StackFrame[] {\n if (isErrorInCucumber(frames)) {\n return frames\n }\n const index = frames.findIndex((x) => isFrameInCucumber(x))\n if (index === -1) {\n return frames\n }\n return frames.slice(0, index)\n}\n\nfunction isErrorInCucumber(frames: StackFrame[]): boolean {\n const filteredFrames = frames.filter((x) => !isFrameInNode(x))\n return filteredFrames.length > 0 && isFrameInCucumber(filteredFrames[0])\n}\n\nfunction isFrameInCucumber(frame: StackFrame): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return isFileNameInCucumber(fileName)\n}\n\nfunction isFrameInNode(frame: StackFrame): boolean {\n const fileName = valueOrDefault(frame.getFileName(), '')\n return !fileName.includes(path.sep)\n}\n"]}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
/// <reference types="node" />
|
|
5
|
-
import
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
6
|
+
import { Writable as WritableStream } from 'node:stream';
|
|
6
7
|
import { ISupportCodeLibrary } from '../support_code_library_builder/types';
|
|
7
|
-
import Formatter, { FormatOptions, IFormatterCleanupFn, IFormatterLogFn } from '.';
|
|
8
|
-
import { EventEmitter } from 'events';
|
|
9
|
-
import EventDataCollector from './helpers/event_data_collector';
|
|
10
|
-
import { Writable as WritableStream } from 'stream';
|
|
11
8
|
import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
|
|
9
|
+
import EventDataCollector from './helpers/event_data_collector';
|
|
10
|
+
import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
|
|
11
|
+
import Formatter, { FormatOptions, IFormatterCleanupFn, IFormatterLogFn } from '.';
|
|
12
12
|
interface IGetStepDefinitionSnippetBuilderOptions {
|
|
13
13
|
cwd: string;
|
|
14
14
|
snippetInterface?: SnippetInterface;
|