@cucumber/cucumber 12.6.0 → 12.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +16 -17
  2. package/lib/{cli/helpers.d.ts → api/emit_support_code_messages.d.ts} +0 -3
  3. package/lib/{cli/helpers.js → api/emit_support_code_messages.js} +67 -101
  4. package/lib/api/emit_support_code_messages.js.map +1 -0
  5. package/lib/api/load_configuration.d.ts +1 -1
  6. package/lib/api/load_configuration.js +13 -1
  7. package/lib/api/load_configuration.js.map +1 -1
  8. package/lib/api/run_cucumber.js +7 -7
  9. package/lib/api/run_cucumber.js.map +1 -1
  10. package/lib/filter/filter_plugin.js +2 -2
  11. package/lib/filter/filter_plugin.js.map +1 -1
  12. package/lib/filter/index.d.ts +1 -0
  13. package/lib/filter/index.js +3 -0
  14. package/lib/filter/index.js.map +1 -1
  15. package/lib/filter/order_pickles.d.ts +3 -0
  16. package/lib/filter/order_pickles.js +37 -0
  17. package/lib/filter/order_pickles.js.map +1 -0
  18. package/lib/formatter/builtin/html.d.ts +1 -1
  19. package/lib/formatter/builtin/html.js +8 -50
  20. package/lib/formatter/builtin/html.js.map +1 -1
  21. package/lib/formatter/index.d.ts +1 -1
  22. package/lib/formatter/index.js.map +1 -1
  23. package/lib/models/definition.d.ts +4 -1
  24. package/lib/models/definition.js +3 -1
  25. package/lib/models/definition.js.map +1 -1
  26. package/lib/pickle_filter.js +3 -3
  27. package/lib/pickle_filter.js.map +1 -1
  28. package/lib/runtime/format_error.js +1 -1
  29. package/lib/runtime/format_error.js.map +1 -1
  30. package/lib/support_code_library_builder/get_definition_line_and_uri.js +4 -0
  31. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
  32. package/lib/support_code_library_builder/index.d.ts +5 -0
  33. package/lib/support_code_library_builder/index.js +15 -5
  34. package/lib/support_code_library_builder/index.js.map +1 -1
  35. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +4 -2
  36. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +2 -2
  37. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -1
  38. package/lib/tsconfig.node.tsbuildinfo +1 -1
  39. package/lib/version.d.ts +1 -1
  40. package/lib/version.js +1 -1
  41. package/lib/version.js.map +1 -1
  42. package/package.json +25 -24
  43. package/lib/cli/helpers.js.map +0 -1
package/LICENSE CHANGED
@@ -1,22 +1,21 @@
1
- The MIT License
1
+ MIT License
2
2
 
3
3
  Copyright (c) Julien Biezemans and contributors
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,9 +1,6 @@
1
1
  import { EventEmitter } from 'node:events';
2
2
  import { IdGenerator } from '@cucumber/messages';
3
3
  import { SupportCodeLibrary } from '../support_code_library_builder/types';
4
- import { ILogger } from '../environment';
5
- import { IPickleOrder } from '../filter';
6
- export declare function orderPickles<T = string>(pickleIds: T[], order: IPickleOrder, logger: ILogger): void;
7
4
  export declare function emitMetaMessage(eventBroadcaster: EventEmitter, env: NodeJS.ProcessEnv): Promise<void>;
8
5
  export declare function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }: {
9
6
  eventBroadcaster: EventEmitter;
@@ -36,44 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.orderPickles = orderPickles;
40
39
  exports.emitMetaMessage = emitMetaMessage;
41
40
  exports.emitSupportCodeMessages = emitSupportCodeMessages;
42
41
  const node_os_1 = __importDefault(require("node:os"));
43
- const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
44
42
  const messages = __importStar(require("@cucumber/messages"));
45
43
  const messages_1 = require("@cucumber/messages");
46
44
  const ci_environment_1 = __importDefault(require("@cucumber/ci-environment"));
47
45
  const version_1 = require("../version");
48
- // Orders the pickleIds in place - morphs input
49
- function orderPickles(pickleIds, order, logger) {
50
- const [type, seed] = splitOrder(order);
51
- switch (type) {
52
- case 'defined':
53
- break;
54
- case 'reverse':
55
- pickleIds.reverse();
56
- break;
57
- case 'random':
58
- if (seed === '') {
59
- const newSeed = Math.floor(Math.random() * 1000 * 1000).toString();
60
- logger.warn(`Random order using seed: ${newSeed}`);
61
- (0, knuth_shuffle_seeded_1.default)(pickleIds, newSeed);
62
- }
63
- else {
64
- (0, knuth_shuffle_seeded_1.default)(pickleIds, seed);
65
- }
66
- break;
67
- default:
68
- throw new Error('Unrecognized order type. Should be `defined` or `random`');
69
- }
70
- }
71
- function splitOrder(order) {
72
- if (!order.includes(':')) {
73
- return [order, ''];
74
- }
75
- return order.split(':');
76
- }
77
46
  async function emitMetaMessage(eventBroadcaster, env) {
78
47
  const meta = {
79
48
  protocolVersion: messages.version,
@@ -98,43 +67,48 @@ async function emitMetaMessage(eventBroadcaster, env) {
98
67
  meta,
99
68
  });
100
69
  }
101
- const makeSourceReference = (source) => ({
102
- uri: source.uri,
103
- location: {
104
- line: source.line,
105
- },
106
- });
107
- function emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId) {
70
+ function makeSourceReference(source) {
71
+ return {
72
+ uri: source.uri,
73
+ location: {
74
+ line: source.line,
75
+ },
76
+ };
77
+ }
78
+ function extractPatternSource(pattern) {
79
+ if (pattern instanceof RegExp) {
80
+ return pattern.flags ? pattern.toString() : pattern.source;
81
+ }
82
+ return pattern;
83
+ }
84
+ function collectParameterTypeEnvelopes(supportCodeLibrary, newId) {
85
+ const ordered = [];
108
86
  for (const parameterType of supportCodeLibrary.parameterTypeRegistry
109
87
  .parameterTypes) {
110
88
  if (parameterType.builtin) {
111
89
  continue;
112
90
  }
113
91
  const source = supportCodeLibrary.parameterTypeRegistry.lookupSource(parameterType);
114
- const envelope = {
115
- parameterType: {
116
- id: newId(),
117
- name: parameterType.name,
118
- preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,
119
- regularExpressions: parameterType.regexpStrings,
120
- useForSnippets: parameterType.useForSnippets,
121
- sourceReference: makeSourceReference(source),
92
+ ordered.push({
93
+ order: source.order,
94
+ envelope: {
95
+ parameterType: {
96
+ id: newId(),
97
+ name: parameterType.name,
98
+ preferForRegularExpressionMatch: parameterType.preferForRegexpMatch,
99
+ regularExpressions: parameterType.regexpStrings,
100
+ useForSnippets: parameterType.useForSnippets,
101
+ sourceReference: makeSourceReference(source),
102
+ },
122
103
  },
123
- };
124
- eventBroadcaster.emit('envelope', envelope);
125
- }
126
- }
127
- function emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster) {
128
- for (const undefinedParameterType of supportCodeLibrary.undefinedParameterTypes) {
129
- const envelope = {
130
- undefinedParameterType,
131
- };
132
- eventBroadcaster.emit('envelope', envelope);
104
+ });
133
105
  }
106
+ return ordered;
134
107
  }
135
- function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
136
- supportCodeLibrary.stepDefinitions.forEach((stepDefinition) => {
137
- const envelope = {
108
+ function collectStepDefinitionEnvelopes(supportCodeLibrary) {
109
+ return supportCodeLibrary.stepDefinitions.map((stepDefinition) => ({
110
+ order: stepDefinition.order,
111
+ envelope: {
138
112
  stepDefinition: {
139
113
  id: stepDefinition.id,
140
114
  pattern: {
@@ -145,19 +119,11 @@ function emitStepDefinitions(supportCodeLibrary, eventBroadcaster) {
145
119
  },
146
120
  sourceReference: makeSourceReference(stepDefinition),
147
121
  },
148
- };
149
- eventBroadcaster.emit('envelope', envelope);
150
- });
151
- }
152
- function extractPatternSource(pattern) {
153
- if (pattern instanceof RegExp) {
154
- return pattern.flags ? pattern.toString() : pattern.source;
155
- }
156
- return pattern;
122
+ },
123
+ }));
157
124
  }
158
- function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
159
- ;
160
- [
125
+ function collectHookEnvelopes(supportCodeLibrary) {
126
+ const allHooks = [
161
127
  [
162
128
  supportCodeLibrary.beforeTestCaseHookDefinitions,
163
129
  messages_1.HookType.BEFORE_TEST_CASE,
@@ -166,23 +132,6 @@ function emitTestCaseHooks(supportCodeLibrary, eventBroadcaster) {
166
132
  supportCodeLibrary.afterTestCaseHookDefinitions,
167
133
  messages_1.HookType.AFTER_TEST_CASE,
168
134
  ],
169
- ].forEach(([hooks, type]) => {
170
- hooks.forEach((hook) => {
171
- eventBroadcaster.emit('envelope', {
172
- hook: {
173
- id: hook.id,
174
- type,
175
- name: hook.name,
176
- tagExpression: hook.tagExpression,
177
- sourceReference: makeSourceReference(hook),
178
- },
179
- });
180
- });
181
- });
182
- }
183
- function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
184
- ;
185
- [
186
135
  [
187
136
  supportCodeLibrary.beforeTestRunHookDefinitions,
188
137
  messages_1.HookType.BEFORE_TEST_RUN,
@@ -191,24 +140,41 @@ function emitTestRunHooks(supportCodeLibrary, eventBroadcaster) {
191
140
  supportCodeLibrary.afterTestRunHookDefinitions,
192
141
  messages_1.HookType.AFTER_TEST_RUN,
193
142
  ],
194
- ].forEach(([hooks, type]) => {
143
+ ];
144
+ const ordered = [];
145
+ allHooks.forEach(([hooks, type]) => {
195
146
  hooks.forEach((hook) => {
196
- eventBroadcaster.emit('envelope', {
197
- hook: {
198
- id: hook.id,
199
- type,
200
- name: hook.name,
201
- sourceReference: makeSourceReference(hook),
147
+ ordered.push({
148
+ order: hook.order,
149
+ envelope: {
150
+ hook: {
151
+ id: hook.id,
152
+ type,
153
+ name: hook.name,
154
+ ...('tagExpression' in hook && {
155
+ tagExpression: hook.tagExpression,
156
+ }),
157
+ sourceReference: makeSourceReference(hook),
158
+ },
202
159
  },
203
160
  });
204
161
  });
205
162
  });
163
+ return ordered;
206
164
  }
207
165
  function emitSupportCodeMessages({ eventBroadcaster, supportCodeLibrary, newId, }) {
208
- emitParameterTypes(supportCodeLibrary, eventBroadcaster, newId);
209
- emitUndefinedParameterTypes(supportCodeLibrary, eventBroadcaster);
210
- emitStepDefinitions(supportCodeLibrary, eventBroadcaster);
211
- emitTestCaseHooks(supportCodeLibrary, eventBroadcaster);
212
- emitTestRunHooks(supportCodeLibrary, eventBroadcaster);
166
+ const orderedEnvelopes = [
167
+ ...collectParameterTypeEnvelopes(supportCodeLibrary, newId),
168
+ ...collectStepDefinitionEnvelopes(supportCodeLibrary),
169
+ ...collectHookEnvelopes(supportCodeLibrary),
170
+ ];
171
+ orderedEnvelopes
172
+ .sort((a, b) => a.order - b.order)
173
+ .forEach(({ envelope }) => eventBroadcaster.emit('envelope', envelope));
174
+ supportCodeLibrary.undefinedParameterTypes
175
+ .map((undefinedParameterType) => ({
176
+ undefinedParameterType,
177
+ }))
178
+ .forEach((envelope) => eventBroadcaster.emit('envelope', envelope));
213
179
  }
214
- //# sourceMappingURL=helpers.js.map
180
+ //# sourceMappingURL=emit_support_code_messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit_support_code_messages.js","sourceRoot":"","sources":["../../src/api/emit_support_code_messages.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,0CA0BC;AA+GD,0DAuBC;AA7KD,sDAAwB;AACxB,6DAA8C;AAC9C,iDAAoE;AACpE,8EAA0D;AAE1D,wCAAoC;AAQ7B,KAAK,UAAU,eAAe,CACnC,gBAA8B,EAC9B,GAAsB;IAEtB,MAAM,IAAI,GAAkB;QAC1B,eAAe,EAAE,QAAQ,CAAC,OAAO;QACjC,cAAc,EAAE;YACd,OAAO,EAAP,iBAAO;YACP,IAAI,EAAE,aAAa;SACpB;QACD,GAAG,EAAE;YACH,IAAI,EAAE,iBAAE,CAAC,IAAI,EAAE;SAChB;QACD,EAAE,EAAE;YACF,IAAI,EAAE,iBAAE,CAAC,QAAQ,EAAE;YACnB,OAAO,EAAE,iBAAE,CAAC,OAAO,EAAE;SACtB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;S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,EAAE,EAAE,IAAI,CAAC,EAAE;wBACX,IAAI;wBACJ,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,GAAG,CAAC,eAAe,IAAI,IAAI,IAAI;4BAC7B,aAAa,EAAE,IAAI,CAAC,aAAa;yBAClC,CAAC;wBACF,eAAe,EAAE,mBAAmB,CAAC,IAAI,CAAC;qBAC3C;iBACiB;aACrB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAgB,uBAAuB,CAAC,EACtC,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,GAKN;IACC,MAAM,gBAAgB,GAAG;QACvB,GAAG,6BAA6B,CAAC,kBAAkB,EAAE,KAAK,CAAC;QAC3D,GAAG,8BAA8B,CAAC,kBAAkB,CAAC;QACrD,GAAG,oBAAoB,CAAC,kBAAkB,CAAC;KAC5C,CAAA;IACD,gBAAgB;SACb,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;SACjC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAA;IAEzE,kBAAkB,CAAC,uBAAuB;SACvC,GAAG,CAAC,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QAChC,sBAAsB;KACvB,CAAC,CAAC;SACF,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAA;AACvE,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport os from 'node:os'\nimport * as messages from '@cucumber/messages'\nimport { Envelope, HookType, IdGenerator } from '@cucumber/messages'\nimport detectCiEnvironment from '@cucumber/ci-environment'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { version } from '../version'\nimport { ILineAndUri } from '../types'\n\ninterface OrderedEnvelope {\n order: number\n envelope: messages.Envelope\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 makeSourceReference(source: ILineAndUri) {\n return {\n uri: source.uri,\n location: {\n line: source.line,\n },\n }\n}\n\nfunction extractPatternSource(pattern: string | RegExp) {\n if (pattern instanceof RegExp) {\n return pattern.flags ? pattern.toString() : pattern.source\n }\n return pattern\n}\n\nfunction collectParameterTypeEnvelopes(\n supportCodeLibrary: SupportCodeLibrary,\n newId: IdGenerator.NewId\n): ReadonlyArray<OrderedEnvelope> {\n const ordered: Array<OrderedEnvelope> = []\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 ordered.push({\n order: source.order,\n 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 })\n }\n return ordered\n}\n\nfunction collectStepDefinitionEnvelopes(\n supportCodeLibrary: SupportCodeLibrary\n): ReadonlyArray<OrderedEnvelope> {\n return supportCodeLibrary.stepDefinitions.map((stepDefinition) => ({\n order: stepDefinition.order,\n envelope: {\n stepDefinition: {\n id: stepDefinition.id,\n pattern: {\n source: extractPatternSource(stepDefinition.pattern),\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 }))\n}\n\nfunction collectHookEnvelopes(\n supportCodeLibrary: SupportCodeLibrary\n): ReadonlyArray<OrderedEnvelope> {\n const allHooks = [\n [\n supportCodeLibrary.beforeTestCaseHookDefinitions,\n HookType.BEFORE_TEST_CASE,\n ] as const,\n [\n supportCodeLibrary.afterTestCaseHookDefinitions,\n HookType.AFTER_TEST_CASE,\n ] as const,\n [\n supportCodeLibrary.beforeTestRunHookDefinitions,\n HookType.BEFORE_TEST_RUN,\n ] as const,\n [\n supportCodeLibrary.afterTestRunHookDefinitions,\n HookType.AFTER_TEST_RUN,\n ] as const,\n ]\n const ordered: Array<OrderedEnvelope> = []\n allHooks.forEach(([hooks, type]) => {\n hooks.forEach((hook) => {\n ordered.push({\n order: hook.order,\n envelope: {\n hook: {\n id: hook.id,\n type,\n name: hook.name,\n ...('tagExpression' in hook && {\n tagExpression: hook.tagExpression,\n }),\n sourceReference: makeSourceReference(hook),\n },\n } satisfies Envelope,\n })\n })\n })\n return ordered\n}\n\nexport function emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n}: {\n eventBroadcaster: EventEmitter\n supportCodeLibrary: SupportCodeLibrary\n newId: IdGenerator.NewId\n}): void {\n const orderedEnvelopes = [\n ...collectParameterTypeEnvelopes(supportCodeLibrary, newId),\n ...collectStepDefinitionEnvelopes(supportCodeLibrary),\n ...collectHookEnvelopes(supportCodeLibrary),\n ]\n orderedEnvelopes\n .sort((a, b) => a.order - b.order)\n .forEach(({ envelope }) => eventBroadcaster.emit('envelope', envelope))\n\n supportCodeLibrary.undefinedParameterTypes\n .map((undefinedParameterType) => ({\n undefinedParameterType,\n }))\n .forEach((envelope) => eventBroadcaster.emit('envelope', envelope))\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { IRunEnvironment } from '../environment';
2
- import { IResolvedConfiguration, ILoadConfigurationOptions } from './types';
2
+ import { ILoadConfigurationOptions, IResolvedConfiguration } from './types';
3
3
  /**
4
4
  * Load user-authored configuration to be used in a test run
5
5
  *
@@ -27,7 +27,19 @@ async function loadConfiguration(options = {}, environment = {}) {
27
27
  const profileConfiguration = configFile
28
28
  ? await (0, configuration_1.fromFile)(logger, cwd, configFile, options.profiles)
29
29
  : {};
30
- const original = (0, configuration_1.mergeConfigurations)(configuration_1.DEFAULT_CONFIGURATION, profileConfiguration, (0, configuration_1.parseConfiguration)(logger, 'Provided', options.provided));
30
+ const providedConfiguration = (0, configuration_1.parseConfiguration)(logger, 'Provided', options.provided);
31
+ if (profileConfiguration.paths?.length > 0 &&
32
+ providedConfiguration.paths?.length > 0) {
33
+ const configPaths = profileConfiguration.paths;
34
+ const cliPaths = providedConfiguration.paths;
35
+ const mergedPaths = [...configPaths, ...cliPaths];
36
+ logger.warn(`You have specified paths in both your configuration file and as CLI arguments.\n` +
37
+ `In a future major version, the CLI argument will override the configuration file instead of being merged.\n` +
38
+ `To prepare for this change, see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md\n` +
39
+ ` Current result: ${mergedPaths.join(', ')}\n` +
40
+ ` Future result: ${cliPaths.join(', ')}`);
41
+ }
42
+ const original = (0, configuration_1.mergeConfigurations)(configuration_1.DEFAULT_CONFIGURATION, profileConfiguration, providedConfiguration);
31
43
  logger.debug('Resolved configuration:', original);
32
44
  (0, configuration_1.validateConfiguration)(original, logger);
33
45
  const runnable = await (0, convert_configuration_1.convertConfiguration)(logger, original, env);
@@ -1 +1 @@
1
- {"version":3,"file":"load_configuration.js","sourceRoot":"","sources":["../../src/api/load_configuration.ts"],"names":[],"mappings":";;AAmBA,8CA4BC;AA/CD,8DAAyD;AACzD,oDAMyB;AACzB,gDAAiE;AACjE,mEAA8D;AAG9D;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,UAAqC,EAAE,EACvC,cAA+B,EAAE;IAEjC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,6BAAe,EAAC,WAAW,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,wBAAU,EAAC,GAAG,CAAC,CAAA;IAClD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,sCAAsC,UAAU,GAAG,CAAC,CAAA;IACnE,CAAC;SAAM,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAChC,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAC7C,CAAC;IACD,MAAM,oBAAoB,GAAG,UAAU;QACrC,CAAC,CAAC,MAAM,IAAA,wBAAQ,EAAC,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC;QAC3D,CAAC,CAAC,EAAE,CAAA;IACN,MAAM,QAAQ,GAAG,IAAA,mCAAmB,EAClC,qCAAqB,EACrB,oBAAoB,EACpB,IAAA,kCAAkB,EAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,CACzD,CAAA;IACD,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAA;IACjD,IAAA,qCAAqB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACvC,MAAM,QAAQ,GAAG,MAAM,IAAA,4CAAoB,EAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;IAClE,OAAO;QACL,gBAAgB,EAAE,QAAQ;QAC1B,gBAAgB,EAAE,QAAQ;KAC3B,CAAA;AACH,CAAC","sourcesContent":["import { locateFile } from '../configuration/locate_file'\nimport {\n DEFAULT_CONFIGURATION,\n fromFile,\n mergeConfigurations,\n parseConfiguration,\n validateConfiguration,\n} from '../configuration'\nimport { IRunEnvironment, makeEnvironment } from '../environment'\nimport { convertConfiguration } from './convert_configuration'\nimport { IResolvedConfiguration, ILoadConfigurationOptions } from './types'\n\n/**\n * Load user-authored configuration to be used in a test run\n *\n * @public\n * @param options - Coordinates required to find configuration\n * @param environment - Project environment\n */\nexport async function loadConfiguration(\n options: ILoadConfigurationOptions = {},\n environment: IRunEnvironment = {}\n): Promise<IResolvedConfiguration> {\n const { cwd, env, logger } = makeEnvironment(environment)\n const configFile = options.file ?? locateFile(cwd)\n if (configFile) {\n logger.debug(`Configuration will be loaded from \"${configFile}\"`)\n } else if (configFile === false) {\n logger.debug('Skipping configuration file resolution')\n } else {\n logger.debug('No configuration file found')\n }\n const profileConfiguration = configFile\n ? await fromFile(logger, cwd, configFile, options.profiles)\n : {}\n const original = mergeConfigurations(\n DEFAULT_CONFIGURATION,\n profileConfiguration,\n parseConfiguration(logger, 'Provided', options.provided)\n )\n logger.debug('Resolved configuration:', original)\n validateConfiguration(original, logger)\n const runnable = await convertConfiguration(logger, original, env)\n return {\n useConfiguration: original,\n runConfiguration: runnable,\n }\n}\n"]}
1
+ {"version":3,"file":"load_configuration.js","sourceRoot":"","sources":["../../src/api/load_configuration.ts"],"names":[],"mappings":";;AAmBA,8CAgDC;AAnED,8DAAyD;AACzD,oDAMyB;AACzB,gDAAiE;AACjE,mEAA8D;AAG9D;;;;;;GAMG;AACI,KAAK,UAAU,iBAAiB,CACrC,UAAqC,EAAE,EACvC,cAA+B,EAAE;IAEjC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,IAAA,6BAAe,EAAC,WAAW,CAAC,CAAA;IACzD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,IAAA,wBAAU,EAAC,GAAG,CAAC,CAAA;IAClD,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,sCAAsC,UAAU,GAAG,CAAC,CAAA;IACnE,CAAC;SAAM,IAAI,UAAU,KAAK,KAAK,EAAE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;QACL,gBAAgB,EAAE,QAAQ;QAC1B,gBAAgB,EAAE,QAAQ;KAC3B,CAAA;AACH,CAAC","sourcesContent":["import { locateFile } from '../configuration/locate_file'\nimport {\n DEFAULT_CONFIGURATION,\n fromFile,\n mergeConfigurations,\n parseConfiguration,\n validateConfiguration,\n} from '../configuration'\nimport { IRunEnvironment, makeEnvironment } from '../environment'\nimport { convertConfiguration } from './convert_configuration'\nimport { ILoadConfigurationOptions, IResolvedConfiguration } from './types'\n\n/**\n * Load user-authored configuration to be used in a test run\n *\n * @public\n * @param options - Coordinates required to find configuration\n * @param environment - Project environment\n */\nexport async function loadConfiguration(\n options: ILoadConfigurationOptions = {},\n environment: IRunEnvironment = {}\n): Promise<IResolvedConfiguration> {\n const { cwd, env, logger } = makeEnvironment(environment)\n const configFile = options.file ?? locateFile(cwd)\n if (configFile) {\n logger.debug(`Configuration will be loaded from \"${configFile}\"`)\n } else if (configFile === false) {\n logger.debug('Skipping configuration file resolution')\n } else {\n logger.debug('No configuration file found')\n }\n const profileConfiguration = configFile\n ? await fromFile(logger, cwd, configFile, options.profiles)\n : {}\n const providedConfiguration = parseConfiguration(\n logger,\n 'Provided',\n options.provided\n )\n if (\n profileConfiguration.paths?.length > 0 &&\n providedConfiguration.paths?.length > 0\n ) {\n const configPaths = profileConfiguration.paths\n const cliPaths = providedConfiguration.paths\n const mergedPaths = [...configPaths, ...cliPaths]\n logger.warn(\n `You have specified paths in both your configuration file and as CLI arguments.\\n` +\n `In a future major version, the CLI argument will override the configuration file instead of being merged.\\n` +\n `To prepare for this change, see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md\\n` +\n ` Current result: ${mergedPaths.join(', ')}\\n` +\n ` Future result: ${cliPaths.join(', ')}`\n )\n }\n const original = mergeConfigurations(\n DEFAULT_CONFIGURATION,\n profileConfiguration,\n providedConfiguration\n )\n logger.debug('Resolved configuration:', original)\n validateConfiguration(original, logger)\n const runnable = await convertConfiguration(logger, original, env)\n return {\n useConfiguration: original,\n runConfiguration: runnable,\n }\n}\n"]}
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runCucumber = runCucumber;
4
4
  const node_events_1 = require("node:events");
5
5
  const messages_1 = require("@cucumber/messages");
6
+ const environment_1 = require("../environment");
6
7
  const helpers_1 = require("../formatter/helpers");
7
- const helpers_2 = require("../cli/helpers");
8
8
  const paths_1 = require("../paths");
9
- const version_1 = require("../version");
10
9
  const runtime_1 = require("../runtime");
11
- const environment_1 = require("../environment");
10
+ const version_1 = require("../version");
11
+ const emit_support_code_messages_1 = require("./emit_support_code_messages");
12
12
  const formatters_1 = require("./formatters");
13
- const support_1 = require("./support");
14
13
  const gherkin_1 = require("./gherkin");
15
14
  const plugins_1 = require("./plugins");
15
+ const support_1 = require("./support");
16
16
  /**
17
17
  * Execute a Cucumber test run and return the overall result
18
18
  *
@@ -75,7 +75,7 @@ Running from: ${__dirname}
75
75
  supportCodeLibrary,
76
76
  pluginManager,
77
77
  });
78
- await (0, helpers_2.emitMetaMessage)(eventBroadcaster, env);
78
+ await (0, emit_support_code_messages_1.emitMetaMessage)(eventBroadcaster, env);
79
79
  let filteredPickles = [];
80
80
  let parseErrors = [];
81
81
  if (sourcePaths.length > 0) {
@@ -101,13 +101,13 @@ Running from: ${__dirname}
101
101
  support: supportCodeLibrary,
102
102
  };
103
103
  }
104
- (0, helpers_2.emitSupportCodeMessages)({
104
+ (0, emit_support_code_messages_1.emitSupportCodeMessages)({
105
105
  eventBroadcaster,
106
106
  supportCodeLibrary,
107
107
  newId,
108
108
  });
109
109
  const runtime = await (0, runtime_1.makeRuntime)({
110
- environment,
110
+ environment: mergedEnvironment,
111
111
  logger,
112
112
  eventBroadcaster,
113
113
  sourcedPickles: filteredPickles,
@@ -1 +1 @@
1
- {"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;AAwBA,kCA6IC;AArKD,6CAA0C;AAC1C,iDAAsE;AACt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OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { resolvePaths } from '../paths'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { version } from '../version'\nimport { IFilterablePickle } from '../filter'\nimport { makeRuntime } from '../runtime'\nimport { IRunEnvironment, makeEnvironment } from '../environment'\nimport { IRunOptions, IRunResult } from './types'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { getPicklesAndErrors } from './gherkin'\nimport { initializeForRunCucumber } from './plugins'\n\n/**\n * Execute a Cucumber test run and return the overall result\n *\n * @public\n * @param options - Options for the run, obtainable via {@link loadConfiguration}\n * @param environment - Project environment\n * @param onMessage - Callback fired each time Cucumber emits a message\n */\nexport async function runCucumber(\n options: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const mergedEnvironment = makeEnvironment(environment)\n const { cwd, stdout, stderr, env, logger } = mergedEnvironment\n\n logger.debug(`Running cucumber-js ${version} \nWorking directory: ${cwd}\nRunning from: ${__dirname} \n`)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'originalCoordinates' in options.support\n ? options.support.originalCoordinates\n : Object.assign(\n {\n requireModules: [],\n requirePaths: [],\n loaders: [],\n importPaths: [],\n },\n options.support\n )\n\n const pluginManager = await initializeForRunCucumber(\n {\n ...options,\n support: supportCoordinates,\n },\n mergedEnvironment\n )\n\n const resolvedPaths = await resolvePaths(\n logger,\n cwd,\n options.sources,\n supportCoordinates\n )\n pluginManager.emit('paths:resolve', resolvedPaths)\n const { sourcePaths, requirePaths, importPaths } = resolvedPaths\n\n const supportCodeLibrary =\n 'originalCoordinates' in options.support\n ? (options.support as SupportCodeLibrary)\n : await getSupportCodeLibrary({\n logger,\n cwd,\n newId,\n requirePaths,\n requireModules: supportCoordinates.requireModules,\n importPaths,\n loaders: supportCoordinates.loaders,\n })\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) =>\n pluginManager.emit('message', value)\n )\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: options.formats,\n supportCodeLibrary,\n pluginManager,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let filteredPickles: ReadonlyArray<IFilterablePickle> = []\n let parseErrors: ParseError[] = []\n if (sourcePaths.length > 0) {\n const gherkinResult = await getPicklesAndErrors({\n newId,\n cwd,\n sourcePaths,\n coordinates: options.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n filteredPickles = await pluginManager.transform(\n 'pickles:filter',\n gherkinResult.filterablePickles\n )\n filteredPickles = await pluginManager.transform(\n 'pickles:order',\n filteredPickles\n )\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await pluginManager.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = await makeRuntime({\n environment,\n logger,\n eventBroadcaster,\n sourcedPickles: filteredPickles,\n newId,\n supportCodeLibrary,\n options: options.runtime,\n snippetOptions: options.formats.options,\n })\n const success = await runtime.run()\n await pluginManager.cleanup()\n await cleanupFormatters()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\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IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAA;IACnC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAA;IAC7B,MAAM,iBAAiB,EAAE,CAAA;IAEzB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC","sourcesContent":["import { EventEmitter } from 'node:events'\nimport { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { IRunEnvironment, makeEnvironment } from '../environment'\nimport { IFilterablePickle } from '../filter'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { resolvePaths } from '../paths'\nimport { makeRuntime } from '../runtime'\nimport { SupportCodeLibrary } from '../support_code_library_builder/types'\nimport { version } from '../version'\nimport {\n emitMetaMessage,\n emitSupportCodeMessages,\n} from './emit_support_code_messages'\nimport { initializeFormatters } from './formatters'\nimport { getPicklesAndErrors } from './gherkin'\nimport { initializeForRunCucumber } from './plugins'\nimport { getSupportCodeLibrary } from './support'\nimport { IRunOptions, IRunResult } from './types'\n\n/**\n * Execute a Cucumber test run and return the overall result\n *\n * @public\n * @param options - Options for the run, obtainable via {@link loadConfiguration}\n * @param environment - Project environment\n * @param onMessage - Callback fired each time Cucumber emits a message\n */\nexport async function runCucumber(\n options: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const mergedEnvironment = makeEnvironment(environment)\n const { cwd, stdout, stderr, env, logger } = mergedEnvironment\n\n logger.debug(`Running cucumber-js ${version} \nWorking directory: ${cwd}\nRunning from: ${__dirname} \n`)\n\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'originalCoordinates' in options.support\n ? options.support.originalCoordinates\n : Object.assign(\n {\n requireModules: [],\n requirePaths: [],\n loaders: [],\n importPaths: [],\n },\n options.support\n )\n\n const pluginManager = await initializeForRunCucumber(\n {\n ...options,\n support: supportCoordinates,\n },\n mergedEnvironment\n )\n\n const resolvedPaths = await resolvePaths(\n logger,\n cwd,\n options.sources,\n supportCoordinates\n )\n pluginManager.emit('paths:resolve', resolvedPaths)\n const { sourcePaths, requirePaths, importPaths } = resolvedPaths\n\n const supportCodeLibrary =\n 'originalCoordinates' in options.support\n ? (options.support as SupportCodeLibrary)\n : await getSupportCodeLibrary({\n logger,\n cwd,\n newId,\n requirePaths,\n requireModules: supportCoordinates.requireModules,\n importPaths,\n loaders: supportCoordinates.loaders,\n })\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) =>\n pluginManager.emit('message', value)\n )\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanupFormatters = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: options.formats,\n supportCodeLibrary,\n pluginManager,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let filteredPickles: ReadonlyArray<IFilterablePickle> = []\n let parseErrors: ParseError[] = []\n if (sourcePaths.length > 0) {\n const gherkinResult = await getPicklesAndErrors({\n newId,\n cwd,\n sourcePaths,\n coordinates: options.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n filteredPickles = await pluginManager.transform(\n 'pickles:filter',\n gherkinResult.filterablePickles\n )\n filteredPickles = await pluginManager.transform(\n 'pickles:order',\n filteredPickles\n )\n parseErrors = gherkinResult.parseErrors\n }\n if (parseErrors.length) {\n parseErrors.forEach((parseError) => {\n logger.error(\n `Parse error in \"${parseError.source.uri}\" ${parseError.message}`\n )\n })\n await cleanupFormatters()\n await pluginManager.cleanup()\n return {\n success: false,\n support: supportCodeLibrary,\n }\n }\n\n emitSupportCodeMessages({\n eventBroadcaster,\n supportCodeLibrary,\n newId,\n })\n\n const runtime = await makeRuntime({\n environment: mergedEnvironment,\n logger,\n eventBroadcaster,\n sourcedPickles: filteredPickles,\n newId,\n supportCodeLibrary,\n options: options.runtime,\n snippetOptions: options.formats.options,\n })\n const success = await runtime.run()\n await pluginManager.cleanup()\n await cleanupFormatters()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.filterPlugin = void 0;
7
7
  const pickle_filter_1 = __importDefault(require("../pickle_filter"));
8
- const helpers_1 = require("../cli/helpers");
8
+ const order_pickles_1 = require("./order_pickles");
9
9
  exports.filterPlugin = {
10
10
  type: 'plugin',
11
11
  coordinator: async ({ on, transform, options, logger, environment }) => {
@@ -24,7 +24,7 @@ exports.filterPlugin = {
24
24
  });
25
25
  transform('pickles:order', async (unorderedPickles) => {
26
26
  const orderedPickles = [...unorderedPickles];
27
- (0, helpers_1.orderPickles)(orderedPickles, options.order, logger);
27
+ (0, order_pickles_1.orderPickles)(orderedPickles, options.order, logger);
28
28
  return orderedPickles;
29
29
  });
30
30
  },
@@ -1 +1 @@
1
- {"version":3,"file":"filter_plugin.js","sourceRoot":"","sources":["../../src/filter/filter_plugin.ts"],"names":[],"mappings":";;;;;;AACA,qEAA2C;AAC3C,4CAA6C;AAEhC,QAAA,YAAY,GAAW;IAClC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE;QACrE,IAAI,qBAAqB,GAAa,EAAE,CAAA;QACxC,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC/C,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC;gBACpC,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,YAAY,EAAE,qBAAqB;gBACnC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,aAAa,EAAE,OAAO,CAAC,aAAa;aACrC,CAAC,CAAA;YAEF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACpE,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;YACpD,MAAM,cAAc,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAA;YAC5C,IAAA,sBAAY,EAAC,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YACnD,OAAO,cAAc,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { Plugin } from '../plugin'\nimport PickleFilter from '../pickle_filter'\nimport { orderPickles } from '../cli/helpers'\n\nexport const filterPlugin: Plugin = {\n type: 'plugin',\n coordinator: async ({ on, transform, options, logger, environment }) => {\n let unexpandedSourcePaths: string[] = []\n on('paths:resolve', (paths) => {\n unexpandedSourcePaths = paths.unexpandedSourcePaths\n })\n\n transform('pickles:filter', async (allPickles) => {\n const pickleFilter = new PickleFilter({\n cwd: environment.cwd,\n featurePaths: unexpandedSourcePaths,\n names: options.names,\n tagExpression: options.tagExpression,\n })\n\n return allPickles.filter((pickle) => pickleFilter.matches(pickle))\n })\n\n transform('pickles:order', async (unorderedPickles) => {\n const orderedPickles = [...unorderedPickles]\n orderPickles(orderedPickles, options.order, logger)\n return orderedPickles\n })\n },\n}\n"]}
1
+ {"version":3,"file":"filter_plugin.js","sourceRoot":"","sources":["../../src/filter/filter_plugin.ts"],"names":[],"mappings":";;;;;;AACA,qEAA2C;AAC3C,mDAA8C;AAEjC,QAAA,YAAY,GAAW;IAClC,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE;QACrE,IAAI,qBAAqB,GAAa,EAAE,CAAA;QACxC,EAAE,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,qBAAqB,GAAG,KAAK,CAAC,qBAAqB,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,gBAAgB,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE;YAC/C,MAAM,YAAY,GAAG,IAAI,uBAAY,CAAC;gBACpC,GAAG,EAAE,WAAW,CAAC,GAAG;gBACpB,YAAY,EAAE,qBAAqB;gBACnC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,aAAa,EAAE,OAAO,CAAC,aAAa;aACrC,CAAC,CAAA;YAEF,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QACpE,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE;YACpD,MAAM,cAAc,GAAG,CAAC,GAAG,gBAAgB,CAAC,CAAA;YAC5C,IAAA,4BAAY,EAAC,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;YACnD,OAAO,cAAc,CAAA;QACvB,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA","sourcesContent":["import { Plugin } from '../plugin'\nimport PickleFilter from '../pickle_filter'\nimport { orderPickles } from './order_pickles'\n\nexport const filterPlugin: Plugin = {\n type: 'plugin',\n coordinator: async ({ on, transform, options, logger, environment }) => {\n let unexpandedSourcePaths: string[] = []\n on('paths:resolve', (paths) => {\n unexpandedSourcePaths = paths.unexpandedSourcePaths\n })\n\n transform('pickles:filter', async (allPickles) => {\n const pickleFilter = new PickleFilter({\n cwd: environment.cwd,\n featurePaths: unexpandedSourcePaths,\n names: options.names,\n tagExpression: options.tagExpression,\n })\n\n return allPickles.filter((pickle) => pickleFilter.matches(pickle))\n })\n\n transform('pickles:order', async (unorderedPickles) => {\n const orderedPickles = [...unorderedPickles]\n orderPickles(orderedPickles, options.order, logger)\n return orderedPickles\n })\n },\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  import { filterPlugin } from './filter_plugin';
2
2
  export * from './types';
3
+ export { orderPickles } from './order_pickles';
3
4
  export default filterPlugin;
@@ -14,7 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.orderPickles = void 0;
17
18
  const filter_plugin_1 = require("./filter_plugin");
18
19
  __exportStar(require("./types"), exports);
20
+ var order_pickles_1 = require("./order_pickles");
21
+ Object.defineProperty(exports, "orderPickles", { enumerable: true, get: function () { return order_pickles_1.orderPickles; } });
19
22
  exports.default = filter_plugin_1.filterPlugin;
20
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAA8C;AAC9C,0CAAuB;AAEvB,kBAAe,4BAAY,CAAA","sourcesContent":["import { filterPlugin } from './filter_plugin'\nexport * from './types'\n\nexport default filterPlugin\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/filter/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAA8C;AAC9C,0CAAuB;AACvB,iDAA8C;AAArC,6GAAA,YAAY,OAAA;AAErB,kBAAe,4BAAY,CAAA","sourcesContent":["import { filterPlugin } from './filter_plugin'\nexport * from './types'\nexport { orderPickles } from './order_pickles'\n\nexport default filterPlugin\n"]}
@@ -0,0 +1,3 @@
1
+ import { ILogger } from '../environment';
2
+ import { IPickleOrder } from './types';
3
+ export declare function orderPickles<T = string>(pickleIds: T[], order: IPickleOrder, logger: ILogger): void;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.orderPickles = orderPickles;
7
+ const knuth_shuffle_seeded_1 = __importDefault(require("knuth-shuffle-seeded"));
8
+ // Orders the pickleIds in place - morphs input
9
+ function orderPickles(pickleIds, order, logger) {
10
+ const [type, seed] = splitOrder(order);
11
+ switch (type) {
12
+ case 'defined':
13
+ break;
14
+ case 'reverse':
15
+ pickleIds.reverse();
16
+ break;
17
+ case 'random':
18
+ if (seed === '') {
19
+ const newSeed = Math.floor(Math.random() * 1000 * 1000).toString();
20
+ logger.warn(`Random order using seed: ${newSeed}`);
21
+ (0, knuth_shuffle_seeded_1.default)(pickleIds, newSeed);
22
+ }
23
+ else {
24
+ (0, knuth_shuffle_seeded_1.default)(pickleIds, seed);
25
+ }
26
+ break;
27
+ default:
28
+ throw new Error('Unrecognized order type. Should be `defined` or `random`');
29
+ }
30
+ }
31
+ function splitOrder(order) {
32
+ if (!order.includes(':')) {
33
+ return [order, ''];
34
+ }
35
+ return order.split(':');
36
+ }
37
+ //# sourceMappingURL=order_pickles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order_pickles.js","sourceRoot":"","sources":["../../src/filter/order_pickles.ts"],"names":[],"mappings":";;;;;AAKA,oCA0BC;AA/BD,gFAA0C;AAI1C,+CAA+C;AAC/C,SAAgB,YAAY,CAC1B,SAAc,EACd,KAAmB,EACnB,MAAe;IAEf,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA;IACtC,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS;YACZ,MAAK;QACP,KAAK,SAAS;YACZ,SAAS,CAAC,OAAO,EAAE,CAAA;YACnB,MAAK;QACP,KAAK,QAAQ;YACX,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;gBAChB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAA;gBAClE,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,EAAE,CAAC,CAAA;gBAClD,IAAA,8BAAO,EAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YAC7B,CAAC;iBAAM,CAAC;gBACN,IAAA,8BAAO,EAAC,SAAS,EAAE,IAAI,CAAC,CAAA;YAC1B,CAAC;YACD,MAAK;QACP;YACE,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAA;IACL,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACpB,CAAC;IACD,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AACzB,CAAC","sourcesContent":["import shuffle from 'knuth-shuffle-seeded'\nimport { ILogger } from '../environment'\nimport { IPickleOrder } from './types'\n\n// Orders the pickleIds in place - morphs input\nexport function orderPickles<T = string>(\n pickleIds: T[],\n order: IPickleOrder,\n logger: ILogger\n): void {\n const [type, seed] = splitOrder(order)\n switch (type) {\n case 'defined':\n break\n case 'reverse':\n pickleIds.reverse()\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 'Unrecognized 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"]}
@@ -1,5 +1,5 @@
1
1
  interface Options {
2
- externalAttachments?: true;
2
+ externalAttachments?: boolean | ReadonlyArray<string>;
3
3
  }
4
4
  declare const _default: {
5
5
  type: "formatter";
@@ -1,72 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  const node_util_1 = require("node:util");
7
4
  const node_stream_1 = require("node:stream");
8
- const node_fs_1 = require("node:fs");
9
- const node_path_1 = __importDefault(require("node:path"));
10
5
  const html_formatter_1 = require("@cucumber/html-formatter");
11
- const mime_1 = __importDefault(require("mime"));
12
- const messages_1 = require("@cucumber/messages");
6
+ const message_streams_1 = require("@cucumber/message-streams");
13
7
  exports.default = {
14
8
  type: 'formatter',
15
9
  formatter({ on, options, write, directory }) {
16
10
  if (!directory && options.externalAttachments) {
17
11
  throw new Error('Unable to externalise attachments when formatter is not writing to a file');
18
12
  }
19
- const newId = messages_1.IdGenerator.uuid();
13
+ const externaliseStream = new message_streams_1.AttachmentExternalisingStream({
14
+ behaviour: options.externalAttachments,
15
+ directory,
16
+ });
20
17
  const htmlStream = new html_formatter_1.CucumberHtmlStream();
21
- const writeOperations = [];
18
+ externaliseStream.pipe(htmlStream);
22
19
  on('message', (message) => {
23
- if (message.attachment && options.externalAttachments) {
24
- const { attachment, writeOperation } = externaliseAttachment(newId, message.attachment, directory);
25
- htmlStream.write({
26
- ...message,
27
- attachment,
28
- });
29
- if (writeOperation) {
30
- writeOperations.push(writeOperation);
31
- }
32
- }
33
- else {
34
- htmlStream.write(message);
35
- }
20
+ externaliseStream.write(message);
36
21
  });
37
22
  htmlStream.on('data', (chunk) => write(chunk));
38
23
  return async () => {
39
- htmlStream.end();
24
+ externaliseStream.end();
40
25
  await (0, node_util_1.promisify)(node_stream_1.finished)(htmlStream);
41
- await Promise.all(writeOperations);
42
26
  };
43
27
  },
44
28
  optionsKey: 'html',
45
29
  };
46
- const alwaysInlinedTypes = ['text/x.cucumber.log+plain', 'text/uri-list'];
47
- const encodingsMap = {
48
- IDENTITY: 'utf-8',
49
- BASE64: 'base64',
50
- };
51
- function externaliseAttachment(newId, original, directory) {
52
- if (alwaysInlinedTypes.includes(original.mediaType)) {
53
- return { attachment: original };
54
- }
55
- let filename = `attachment-${newId()}`;
56
- const extension = mime_1.default.getExtension(original.mediaType);
57
- if (extension) {
58
- filename += `.${extension}`;
59
- }
60
- const writeOperation = (0, node_util_1.promisify)(node_fs_1.writeFile)(node_path_1.default.join(directory, filename), Buffer.from(original.body, encodingsMap[original.contentEncoding]));
61
- const updated = {
62
- ...original,
63
- contentEncoding: messages_1.AttachmentContentEncoding.IDENTITY,
64
- body: '',
65
- url: `./${filename}`,
66
- };
67
- return {
68
- attachment: updated,
69
- writeOperation,
70
- };
71
- }
72
30
  //# sourceMappingURL=html.js.map