@cucumber/cucumber 8.4.0 → 8.5.2

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 (62) hide show
  1. package/README.md +1 -0
  2. package/lib/api/convert_configuration.js.map +1 -1
  3. package/lib/api/formatters.d.ts +3 -1
  4. package/lib/api/formatters.js +1 -36
  5. package/lib/api/formatters.js.map +1 -1
  6. package/lib/api/plugins.d.ts +4 -0
  7. package/lib/api/plugins.js +19 -0
  8. package/lib/api/plugins.js.map +1 -0
  9. package/lib/api/run_cucumber.js +9 -4
  10. package/lib/api/run_cucumber.js.map +1 -1
  11. package/lib/api/runtime.d.ts +1 -0
  12. package/lib/api/types.d.ts +6 -7
  13. package/lib/api/types.js.map +1 -1
  14. package/lib/cli/helpers.d.ts +3 -0
  15. package/lib/cli/index.js +1 -1
  16. package/lib/cli/index.js.map +1 -1
  17. package/lib/cli/install_validator.d.ts +1 -1
  18. package/lib/cli/install_validator.js +8 -30
  19. package/lib/cli/install_validator.js.map +1 -1
  20. package/lib/formatter/builder.d.ts +3 -0
  21. package/lib/formatter/get_color_fns.d.ts +1 -0
  22. package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
  23. package/lib/formatter/helpers/duration_helpers.js +9 -0
  24. package/lib/formatter/helpers/duration_helpers.js.map +1 -0
  25. package/lib/formatter/index.d.ts +9 -7
  26. package/lib/formatter/index.js.map +1 -1
  27. package/lib/formatter/json_formatter.js +2 -2
  28. package/lib/formatter/json_formatter.js.map +1 -1
  29. package/lib/plugin/index.d.ts +2 -0
  30. package/lib/plugin/index.js +19 -0
  31. package/lib/plugin/index.js.map +1 -0
  32. package/lib/plugin/plugin_manager.d.ts +13 -0
  33. package/lib/plugin/plugin_manager.js +36 -0
  34. package/lib/plugin/plugin_manager.js.map +1 -0
  35. package/lib/plugin/types.d.ts +14 -0
  36. package/lib/plugin/types.js +3 -0
  37. package/lib/plugin/types.js.map +1 -0
  38. package/lib/{formatter → publish}/http_stream.d.ts +2 -0
  39. package/lib/{formatter → publish}/http_stream.js +0 -0
  40. package/lib/publish/http_stream.js.map +1 -0
  41. package/lib/publish/index.d.ts +2 -0
  42. package/lib/publish/index.js +5 -0
  43. package/lib/publish/index.js.map +1 -0
  44. package/lib/publish/publish_plugin.d.ts +2 -0
  45. package/lib/publish/publish_plugin.js +48 -0
  46. package/lib/publish/publish_plugin.js.map +1 -0
  47. package/lib/runtime/attachment_manager/index.d.ts +1 -0
  48. package/lib/runtime/parallel/coordinator.d.ts +2 -0
  49. package/lib/runtime/parallel/coordinator.js +8 -8
  50. package/lib/runtime/parallel/coordinator.js.map +1 -1
  51. package/lib/support_code_library_builder/index.js +22 -1
  52. package/lib/support_code_library_builder/index.js.map +1 -1
  53. package/lib/time.d.ts +7 -1
  54. package/lib/time.js.map +1 -1
  55. package/lib/version.d.ts +1 -1
  56. package/lib/version.js +1 -1
  57. package/lib/version.js.map +1 -1
  58. package/package.json +25 -22
  59. package/lib/formatter/http_stream.js.map +0 -1
  60. package/lib/formatter/publish.d.ts +0 -1
  61. package/lib/formatter/publish.js +0 -5
  62. package/lib/formatter/publish.js.map +0 -1
package/README.md CHANGED
@@ -87,6 +87,7 @@ If you learn best by example, we have [a repo with several example projects](htt
87
87
 
88
88
  The following documentation is for `main`, which might contain some unreleased features. See [documentation for older versions](./docs/older_versions.md) if you need it.
89
89
 
90
+ * [Installation](./docs/installation.md)
90
91
  * [CLI](./docs/cli.md)
91
92
  * [Configuration](./docs/configuration.md)
92
93
  * Support Code
@@ -1 +1 @@
1
- {"version":3,"file":"convert_configuration.js","sourceRoot":"","sources":["../../src/api/convert_configuration.ts"],"names":[],"mappings":";;;AAAA,oDAIyB;AAGlB,KAAK,UAAU,oBAAoB,CACxC,iBAAiC,EACjC,GAAsB;IAEtB,OAAO;QACL,OAAO,EAAE;YACP,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,cAAc,EAAE,iBAAiB,CAAC,QAAQ;YAC1C,KAAK,EAAE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AAI,EAAE,MAAM,CAAC,EAAE,EAAE;YACjC,OAAO;gBACL,GAAG,MAAM;gBACT,CAAC,MAAM,CAAC,EAAE,IAAI;aACf,CAAA;QACH,CAAC,EAAE,EAAE,CAAC;QACR,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,EAAE,GAAG,CAAC;QAClD,OAAO,EAAE,iBAAiB,CAAC,aAAa;KACzC,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,iBAAiC,EACjC,GAAsB;IAEtB,MAAM,OAAO,GAAG,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,KAAK,CAAA;KACb;IACD,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,oBAAoB;QAC7B,KAAK,EAAE,GAAG,CAAC,sBAAsB;KAClC,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CACnB,iBAAiC,EACjC,GAAsB;IAEtB,OAAO,CACL,iBAAiB,CAAC,OAAO;QACzB,IAAA,8BAAc,EAAC,GAAG,CAAC,wBAAwB,CAAC;QAC5C,GAAG,CAAC,sBAAsB,KAAK,SAAS,CACzC,CAAA;AACH,CAAC","sourcesContent":["import {\n IConfiguration,\n isTruthyString,\n OptionSplitter,\n} from '../configuration'\nimport { IRunConfiguration } from './types'\n\nexport async function convertConfiguration(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): Promise<IRunConfiguration> {\n return {\n sources: {\n paths: flatConfiguration.paths,\n defaultDialect: flatConfiguration.language,\n names: flatConfiguration.name,\n tagExpression: flatConfiguration.tags,\n order: flatConfiguration.order,\n },\n support: {\n requireModules: flatConfiguration.requireModule,\n requirePaths: flatConfiguration.require,\n importPaths: flatConfiguration.import,\n },\n runtime: {\n dryRun: flatConfiguration.dryRun,\n failFast: flatConfiguration.failFast,\n filterStacktraces: !flatConfiguration.backtrace,\n parallel: flatConfiguration.parallel,\n retry: flatConfiguration.retry,\n retryTagFilter: flatConfiguration.retryTagFilter,\n strict: flatConfiguration.strict,\n worldParameters: flatConfiguration.worldParameters,\n },\n formats: convertFormats(flatConfiguration, env),\n }\n}\n\nfunction convertFormats(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n) {\n const splitFormats: string[][] = flatConfiguration.format.map((item) =>\n OptionSplitter.split(item)\n )\n return {\n stdout:\n [...splitFormats].reverse().find(([, target]) => !target)?.[0] ??\n 'progress',\n files: splitFormats\n .filter(([, target]) => !!target)\n .reduce((mapped, [type, target]) => {\n return {\n ...mapped,\n [target]: type,\n }\n }, {}),\n publish: makePublishConfig(flatConfiguration, env),\n options: flatConfiguration.formatOptions,\n }\n}\n\nfunction makePublishConfig(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): any {\n const enabled = isPublishing(flatConfiguration, env)\n if (!enabled) {\n return false\n }\n return {\n url: env.CUCUMBER_PUBLISH_URL,\n token: env.CUCUMBER_PUBLISH_TOKEN,\n }\n}\n\nfunction isPublishing(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): boolean {\n return (\n flatConfiguration.publish ||\n isTruthyString(env.CUCUMBER_PUBLISH_ENABLED) ||\n env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n}\n"]}
1
+ {"version":3,"file":"convert_configuration.js","sourceRoot":"","sources":["../../src/api/convert_configuration.ts"],"names":[],"mappings":";;;AAAA,oDAIyB;AAIlB,KAAK,UAAU,oBAAoB,CACxC,iBAAiC,EACjC,GAAsB;IAEtB,OAAO;QACL,OAAO,EAAE;YACP,KAAK,EAAE,iBAAiB,CAAC,KAAK;YAC9B,cAAc,EAAE,iBAAiB,CAAC,QAAQ;YAC1C,KAAK,EAAE,iBAAiB,CAAC,IAAI;YAC7B,aAAa,EAAE,iBAAiB,CAAC,IAAI;YACrC,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B;QACD,OAAO,EAAE;YACP,cAAc,EAAE,iBAAiB,CAAC,aAAa;YAC/C,YAA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iBAAiB,EAAE,GAAG,CAAC;QAClD,OAAO,EAAE,iBAAiB,CAAC,aAAa;KACzC,CAAA;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,iBAAiC,EACjC,GAAsB;IAEtB,MAAM,OAAO,GAAG,YAAY,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;IACpD,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,KAAK,CAAA;KACb;IACD,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,oBAAoB;QAC7B,KAAK,EAAE,GAAG,CAAC,sBAAsB;KAClC,CAAA;AACH,CAAC;AAED,SAAS,YAAY,CACnB,iBAAiC,EACjC,GAAsB;IAEtB,OAAO,CACL,iBAAiB,CAAC,OAAO;QACzB,IAAA,8BAAc,EAAC,GAAG,CAAC,wBAAwB,CAAC;QAC5C,GAAG,CAAC,sBAAsB,KAAK,SAAS,CACzC,CAAA;AACH,CAAC","sourcesContent":["import {\n IConfiguration,\n isTruthyString,\n OptionSplitter,\n} from '../configuration'\nimport { IPublishConfig } from '../formatter'\nimport { IRunConfiguration } from './types'\n\nexport async function convertConfiguration(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): Promise<IRunConfiguration> {\n return {\n sources: {\n paths: flatConfiguration.paths,\n defaultDialect: flatConfiguration.language,\n names: flatConfiguration.name,\n tagExpression: flatConfiguration.tags,\n order: flatConfiguration.order,\n },\n support: {\n requireModules: flatConfiguration.requireModule,\n requirePaths: flatConfiguration.require,\n importPaths: flatConfiguration.import,\n },\n runtime: {\n dryRun: flatConfiguration.dryRun,\n failFast: flatConfiguration.failFast,\n filterStacktraces: !flatConfiguration.backtrace,\n parallel: flatConfiguration.parallel,\n retry: flatConfiguration.retry,\n retryTagFilter: flatConfiguration.retryTagFilter,\n strict: flatConfiguration.strict,\n worldParameters: flatConfiguration.worldParameters,\n },\n formats: convertFormats(flatConfiguration, env),\n }\n}\n\nfunction convertFormats(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n) {\n const splitFormats: string[][] = flatConfiguration.format.map((item) =>\n OptionSplitter.split(item)\n )\n return {\n stdout:\n [...splitFormats].reverse().find(([, target]) => !target)?.[0] ??\n 'progress',\n files: splitFormats\n .filter(([, target]) => !!target)\n .reduce((mapped, [type, target]) => {\n return {\n ...mapped,\n [target]: type,\n }\n }, {}),\n publish: makePublishConfig(flatConfiguration, env),\n options: flatConfiguration.formatOptions,\n }\n}\n\nfunction makePublishConfig(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): IPublishConfig | false {\n const enabled = isPublishing(flatConfiguration, env)\n if (!enabled) {\n return false\n }\n return {\n url: env.CUCUMBER_PUBLISH_URL,\n token: env.CUCUMBER_PUBLISH_TOKEN,\n }\n}\n\nfunction isPublishing(\n flatConfiguration: IConfiguration,\n env: NodeJS.ProcessEnv\n): boolean {\n return (\n flatConfiguration.publish ||\n isTruthyString(env.CUCUMBER_PUBLISH_ENABLED) ||\n env.CUCUMBER_PUBLISH_TOKEN !== undefined\n )\n}\n"]}
@@ -1,10 +1,12 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
  import { IFormatterStream } from '../formatter';
3
5
  import { EventEmitter } from 'events';
4
6
  import { EventDataCollector } from '../formatter/helpers';
5
7
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
6
8
  import { IRunOptionsFormats } from './types';
7
- export declare function initializeFormatters({ env, cwd, stdout, stderr, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }: {
9
+ export declare function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }: {
8
10
  env: NodeJS.ProcessEnv;
9
11
  cwd: string;
10
12
  stdout: IFormatterStream;
@@ -8,13 +8,7 @@ const util_1 = require("util");
8
8
  const builder_1 = __importDefault(require("../formatter/builder"));
9
9
  const fs_1 = __importDefault(require("mz/fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
- const publish_1 = require("../formatter/publish");
12
- const http_stream_1 = __importDefault(require("../formatter/http_stream"));
13
- const stream_1 = require("stream");
14
- const supports_color_1 = require("supports-color");
15
- const has_ansi_1 = __importDefault(require("has-ansi"));
16
- const strip_ansi_1 = __importDefault(require("strip-ansi"));
17
- async function initializeFormatters({ env, cwd, stdout, stderr, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }) {
11
+ async function initializeFormatters({ env, cwd, stdout, logger, onStreamError, eventBroadcaster, eventDataCollector, configuration, supportCodeLibrary, }) {
18
12
  async function initializeFormatter(stream, target, type) {
19
13
  stream.on('error', (error) => {
20
14
  logger.error(error.message);
@@ -47,38 +41,9 @@ async function initializeFormatters({ env, cwd, stdout, stderr, logger, onStream
47
41
  });
48
42
  formatters.push(await initializeFormatter(stream, target, type));
49
43
  }
50
- if (configuration.publish) {
51
- const { url = publish_1.DEFAULT_CUCUMBER_PUBLISH_URL, token } = configuration.publish;
52
- const headers = {};
53
- if (token !== undefined) {
54
- headers.Authorization = `Bearer ${token}`;
55
- }
56
- const stream = new http_stream_1.default(url, 'GET', headers);
57
- const readerStream = new stream_1.Writable({
58
- objectMode: true,
59
- write: function (responseBody, encoding, writeCallback) {
60
- logger.error(sanitisePublishOutput(responseBody, stderr));
61
- writeCallback();
62
- },
63
- });
64
- stream.pipe(readerStream);
65
- formatters.push(await initializeFormatter(stream, url, 'message'));
66
- }
67
44
  return async function () {
68
45
  await Promise.all(formatters.map(async (f) => await f.finished()));
69
46
  };
70
47
  }
71
48
  exports.initializeFormatters = initializeFormatters;
72
- /*
73
- This is because the Cucumber Reports service returns a pre-formatted console message
74
- including ANSI escapes, so if our stderr stream doesn't support those we need to
75
- strip them back out. Ideally we should get structured data from the service and
76
- compose the console message on this end.
77
- */
78
- function sanitisePublishOutput(raw, stderr) {
79
- if (!(0, supports_color_1.supportsColor)(stderr) && (0, has_ansi_1.default)(raw)) {
80
- return (0, strip_ansi_1.default)(raw);
81
- }
82
- return raw;
83
- }
84
49
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/api/formatters.ts"],"names":[],"mappings":";;;;;;AAIA,+BAAgC;AAEhC,mEAAmD;AACnD,+CAAsB;AACtB,gDAAuB;AACvB,kDAAmE;AACnE,2EAAiD;AACjD,mCAAiC;AACjC,mDAA8C;AAE9C,wDAA8B;AAC9B,4DAAkC;AAE3B,KAAK,UAAU,oBAAoB,CAAC,EACzC,GAAG,EACH,GAAG,EACH,MAAM,EACN,MAAM,EACN,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GAYnB;IACC,KAAK,UAAU,mBAAmB,CAChC,MAAwB,EACxB,MAAc,EACd,IAAY;QAEZ,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAC3B,aAAa,EAAE,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,MAAM,WAAW,GAAG;YAClB,GAAG;YACH,GAAG;YACH,gBAAgB;YAChB,kBAAkB;YAClB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9B,iBAAiB,EAAE,aAAa,CAAC,OAAO;YACxC,MAAM;YACN,OAAO,EACL,MAAM,KAAK,MAAM;gBACf,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,IAAA,gBAAS,EAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7C,kBAAkB;SACnB,CAAA;QACD,IAAI,IAAI,KAAK,cAAc,IAAI,CAAE,MAAyB,CAAC,KAAK,EAAE;YAChE,MAAM,CAAC,IAAI,CACT,sDAAsD,MAAM,oDAAoD,CACjH,CAAA;Y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aAAa,EAAE,CAAA;YACjB,CAAC;SACF,CAAC,CAAA;QACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACzB,UAAU,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;KACnE;IAED,OAAO,KAAK;QACV,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACpE,CAAC,CAAA;AACH,CAAC;AAzFD,oDAyFC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,GAAW,EAAE,MAAwB;IAClE,IAAI,CAAC,IAAA,8BAAa,EAAC,MAAM,CAAC,IAAI,IAAA,kBAAO,EAAC,GAAG,CAAC,EAAE;QAC1C,OAAO,IAAA,oBAAS,EAAC,GAAG,CAAC,CAAA;KACtB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import Formatter, { IFormatterStream } from '../formatter'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { promisify } from 'util'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport { DEFAULT_CUCUMBER_PUBLISH_URL } from '../formatter/publish'\nimport HttpStream from '../formatter/http_stream'\nimport { Writable } from 'stream'\nimport { supportsColor } from 'supports-color'\nimport { IRunOptionsFormats } from './types'\nimport hasAnsi from 'has-ansi'\nimport stripAnsi from 'strip-ansi'\n\nexport async function initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError,\n eventBroadcaster,\n eventDataCollector,\n configuration,\n supportCodeLibrary,\n}: {\n env: NodeJS.ProcessEnv\n cwd: string\n stdout: IFormatterStream\n stderr: IFormatterStream\n logger: Console\n onStreamError: () => void\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n configuration: IRunOptionsFormats\n supportCodeLibrary: ISupportCodeLibrary\n}): Promise<() => Promise<void>> {\n async function initializeFormatter(\n stream: IFormatterStream,\n target: string,\n type: string\n ): Promise<Formatter> {\n stream.on('error', (error: Error) => {\n logger.error(error.message)\n onStreamError()\n })\n const typeOptions = {\n env,\n cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: configuration.options,\n stream,\n cleanup:\n stream === stdout\n ? async () => await Promise.resolve()\n : promisify<any>(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n logger.warn(\n `Cannot use 'progress-bar' formatter for output to '${target}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return await FormatterBuilder.build(type, typeOptions)\n }\n\n const formatters: Formatter[] = []\n\n formatters.push(\n await initializeFormatter(stdout, 'stdout', configuration.stdout)\n )\n\n for (const [target, type] of Object.entries(configuration.files)) {\n const stream: IFormatterStream = fs.createWriteStream(null, {\n fd: await fs.open(path.resolve(cwd, target), 'w'),\n })\n formatters.push(await initializeFormatter(stream, target, type))\n }\n\n if (configuration.publish) {\n const { url = DEFAULT_CUCUMBER_PUBLISH_URL, token } = configuration.publish\n const headers: { [key: string]: string } = {}\n if (token !== undefined) {\n headers.Authorization = `Bearer ${token}`\n }\n const stream = new HttpStream(url, 'GET', headers)\n const readerStream = new Writable({\n objectMode: true,\n write: function (responseBody: string, encoding, writeCallback) {\n logger.error(sanitisePublishOutput(responseBody, stderr))\n writeCallback()\n },\n })\n stream.pipe(readerStream)\n formatters.push(await initializeFormatter(stream, url, 'message'))\n }\n\n return async function () {\n await Promise.all(formatters.map(async (f) => await f.finished()))\n }\n}\n\n/*\nThis is because the Cucumber Reports service returns a pre-formatted console message\nincluding ANSI escapes, so if our stderr stream doesn't support those we need to\nstrip them back out. Ideally we should get structured data from the service and\ncompose the console message on this end.\n */\nfunction sanitisePublishOutput(raw: string, stderr: IFormatterStream) {\n if (!supportsColor(stderr) && hasAnsi(raw)) {\n return stripAnsi(raw)\n }\n return raw\n}\n"]}
1
+ {"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../src/api/formatters.ts"],"names":[],"mappings":";;;;;;AAIA,+BAAgC;AAEhC,mEAAmD;AACnD,+CAAsB;AACtB,gDAAuB;AAGhB,KAAK,UAAU,oBAAoB,CAAC,EACzC,GAAG,EACH,GAAG,EACH,MAAM,EACN,MAAM,EACN,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GAYnB;IACC,KAAK,UAAU,mBAAmB,CAChC,MAAwB,EACxB,MAAc,EACd,IAAY;QAEZ,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAC3B,aAAa,EAAE,CAAA;QACjB,CAAC,CAAC,CAAA;QACF,MAAM,WAAW,GAAG;YAClB,GAAG;YACH,GAAG;YACH,gBAAgB;YAChB,kBAAkB;YAClB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9B,iBAAiB,EAAE,aAAa,CAAC,OAAO;YACxC,MAAM;YACN,OAAO,EACL,MAAM,KAAK,MAAM;gBACf,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE;gBACrC,CAAC,CAAC,IAAA,gBAAS,EAAM,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7C,kBAAkB;SACnB,CAAA;QACD,IAAI,IAAI,KAAK,cAAc,IAAI,CAAE,MAAyB,CAAC,KAAK,EAAE;YAChE,MAAM,CAAC,IAAI,CACT,sDAAsD,MAAM,oDAAoD,CACjH,CAAA;YACD,IAAI,GAAG,UAAU,CAAA;SAClB;QACD,OAAO,MAAM,iBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,UAAU,GAAgB,EAAE,CAAA;IAElC,UAAU,CAAC,IAAI,CACb,MAAM,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAClE,CAAA;IAED,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE;QAChE,MAAM,MAAM,GAAqB,YAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE;YAC1D,EAAE,EAAE,MAAM,YAAE,CAAC,IAAI,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC;SAClD,CAAC,CAAA;QACF,UAAU,CAAC,IAAI,CAAC,MAAM,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;KACjE;IAED,OAAO,KAAK;QACV,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IACpE,CAAC,CAAA;AACH,CAAC;AAtED,oDAsEC","sourcesContent":["import Formatter, { IFormatterStream } from '../formatter'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { promisify } from 'util'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport FormatterBuilder from '../formatter/builder'\nimport fs from 'mz/fs'\nimport path from 'path'\nimport { IRunOptionsFormats } from './types'\n\nexport async function initializeFormatters({\n env,\n cwd,\n stdout,\n logger,\n onStreamError,\n eventBroadcaster,\n eventDataCollector,\n configuration,\n supportCodeLibrary,\n}: {\n env: NodeJS.ProcessEnv\n cwd: string\n stdout: IFormatterStream\n stderr: IFormatterStream\n logger: Console\n onStreamError: () => void\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n configuration: IRunOptionsFormats\n supportCodeLibrary: ISupportCodeLibrary\n}): Promise<() => Promise<void>> {\n async function initializeFormatter(\n stream: IFormatterStream,\n target: string,\n type: string\n ): Promise<Formatter> {\n stream.on('error', (error: Error) => {\n logger.error(error.message)\n onStreamError()\n })\n const typeOptions = {\n env,\n cwd,\n eventBroadcaster,\n eventDataCollector,\n log: stream.write.bind(stream),\n parsedArgvOptions: configuration.options,\n stream,\n cleanup:\n stream === stdout\n ? async () => await Promise.resolve()\n : promisify<any>(stream.end.bind(stream)),\n supportCodeLibrary,\n }\n if (type === 'progress-bar' && !(stream as TtyWriteStream).isTTY) {\n logger.warn(\n `Cannot use 'progress-bar' formatter for output to '${target}' as not a TTY. Switching to 'progress' formatter.`\n )\n type = 'progress'\n }\n return await FormatterBuilder.build(type, typeOptions)\n }\n\n const formatters: Formatter[] = []\n\n formatters.push(\n await initializeFormatter(stdout, 'stdout', configuration.stdout)\n )\n\n for (const [target, type] of Object.entries(configuration.files)) {\n const stream: IFormatterStream = fs.createWriteStream(null, {\n fd: await fs.open(path.resolve(cwd, target), 'w'),\n })\n formatters.push(await initializeFormatter(stream, target, type))\n }\n\n return async function () {\n await Promise.all(formatters.map(async (f) => await f.finished()))\n }\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { PluginManager } from '../plugin';
3
+ import { IRunEnvironment, IRunOptions } from './types';
4
+ export declare function initializePlugins(logger: Console, configuration: IRunOptions, environment: IRunEnvironment): Promise<PluginManager>;
@@ -0,0 +1,19 @@
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.initializePlugins = void 0;
7
+ const plugin_1 = require("../plugin");
8
+ const publish_1 = __importDefault(require("../publish"));
9
+ const INTERNAL_PLUGINS = {
10
+ publish: publish_1.default,
11
+ };
12
+ async function initializePlugins(logger, configuration, environment) {
13
+ // eventually we'll load plugin packages here
14
+ const pluginManager = new plugin_1.PluginManager(Object.values(INTERNAL_PLUGINS));
15
+ await pluginManager.init(logger, configuration, environment);
16
+ return pluginManager;
17
+ }
18
+ exports.initializePlugins = initializePlugins;
19
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/api/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAiD;AACjD,yDAAsC;AAGtC,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,iBAAa;CACvB,CAAA;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAe,EACf,aAA0B,EAC1B,WAA4B;IAE5B,6CAA6C;IAC7C,MAAM,aAAa,GAAG,IAAI,sBAAa,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAA;IACxE,MAAM,aAAa,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,CAAA;IAC5D,OAAO,aAAa,CAAA;AACtB,CAAC;AATD,8CASC","sourcesContent":["import { Plugin, PluginManager } from '../plugin'\nimport publishPlugin from '../publish'\nimport { IRunEnvironment, IRunOptions } from './types'\n\nconst INTERNAL_PLUGINS: Record<string, Plugin> = {\n publish: publishPlugin,\n}\n\nexport async function initializePlugins(\n logger: Console,\n configuration: IRunOptions,\n environment: IRunEnvironment\n): Promise<PluginManager> {\n // eventually we'll load plugin packages here\n const pluginManager = new PluginManager(Object.values(INTERNAL_PLUGINS))\n await pluginManager.init(logger, configuration, environment)\n return pluginManager\n}\n"]}
@@ -12,6 +12,7 @@ const support_1 = require("./support");
12
12
  const console_1 = require("console");
13
13
  const environment_1 = require("./environment");
14
14
  const gherkin_1 = require("./gherkin");
15
+ const plugins_1 = require("./plugins");
15
16
  /**
16
17
  * Execute a Cucumber test run.
17
18
  *
@@ -22,7 +23,7 @@ const gherkin_1 = require("./gherkin");
22
23
  */
23
24
  async function runCucumber(configuration, environment = {}, onMessage) {
24
25
  const { cwd, stdout, stderr, env } = (0, environment_1.mergeEnvironment)(environment);
25
- const logger = new console_1.Console(stdout, stderr);
26
+ const logger = new console_1.Console(stderr);
26
27
  const newId = messages_1.IdGenerator.uuid();
27
28
  const supportCoordinates = 'World' in configuration.support
28
29
  ? configuration.support.originalCoordinates
@@ -37,13 +38,15 @@ async function runCucumber(configuration, environment = {}, onMessage) {
37
38
  importPaths,
38
39
  requireModules: supportCoordinates.requireModules,
39
40
  });
41
+ const plugins = await (0, plugins_1.initializePlugins)(logger, configuration, environment);
40
42
  const eventBroadcaster = new events_1.EventEmitter();
41
43
  if (onMessage) {
42
44
  eventBroadcaster.on('envelope', onMessage);
43
45
  }
46
+ eventBroadcaster.on('envelope', (value) => plugins.emit('message', value));
44
47
  const eventDataCollector = new helpers_1.EventDataCollector(eventBroadcaster);
45
48
  let formatterStreamError = false;
46
- const cleanup = await (0, formatters_1.initializeFormatters)({
49
+ const cleanupFormatters = await (0, formatters_1.initializeFormatters)({
47
50
  env,
48
51
  cwd,
49
52
  stdout,
@@ -75,7 +78,8 @@ async function runCucumber(configuration, environment = {}, onMessage) {
75
78
  parseErrors.forEach((parseError) => {
76
79
  logger.error(`Parse error in "${parseError.source.uri}" ${parseError.message}`);
77
80
  });
78
- await cleanup();
81
+ await cleanupFormatters();
82
+ await plugins.cleanup();
79
83
  return {
80
84
  success: false,
81
85
  support: supportCodeLibrary,
@@ -100,7 +104,8 @@ async function runCucumber(configuration, environment = {}, onMessage) {
100
104
  options: configuration.runtime,
101
105
  });
102
106
  const success = await runtime.start();
103
- await cleanup();
107
+ await cleanupFormatters();
108
+ await plugins.cleanup();
104
109
  return {
105
110
  success: success && !formatterStreamError,
106
111
  support: supportCodeLibrary,
@@ -1 +1 @@
1
- {"version":3,"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AC,CAAC,CAAA;QACF,MAAM,OAAO,EAAE,CAAA;QACf,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC5B,CAAA;KACF;IAED,IAAA,iCAAuB,EAAC;QACtB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACN,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,GAAG;QACH,MAAM;QACN,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;QACT,KAAK;QACL,kBAAkB;QAClB,cAAc,EAAE,kBAAkB,CAAC,cAAc;QACjD,YAAY;QACZ,WAAW;QACX,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,OAAO,EAAE,CAAA;IAEf,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AAvGD,kCAuGC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { resolvePaths } from './paths'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { Console } from 'console'\nimport { mergeEnvironment } from './environment'\nimport { getFilteredPicklesAndErrors } from './gherkin'\n\n/**\n * Execute a Cucumber test run.\n *\n * @public\n * @param configuration - Configuration loaded from `loadConfiguration`.\n * @param environment - Project environment.\n * @param onMessage - Callback fired each time Cucumber emits a message.\n */\nexport async function runCucumber(\n configuration: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const { cwd, stdout, stderr, env } = mergeEnvironment(environment)\n const logger = new Console(stdout, stderr)\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'World' in configuration.support\n ? configuration.support.originalCoordinates\n : configuration.support\n\n const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } =\n await resolvePaths(cwd, configuration.sources, supportCoordinates)\n\n const supportCodeLibrary =\n 'World' in configuration.support\n ? configuration.support\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n const eventDataCollector = new EventDataCollector(eventBroadcaster)\n\n let formatterStreamError = false\n const cleanup = await initializeFormatters({\n env,\n cwd,\n stdout,\n stderr,\n logger,\n onStreamError: () => (formatterStreamError = true),\n eventBroadcaster,\n eventDataCollector,\n configuration: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (featurePaths.length > 0) {\n const gherkinResult = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates: configuration.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id)\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 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 = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules: supportCoordinates.requireModules,\n requirePaths,\n importPaths,\n options: configuration.runtime,\n })\n const success = await runtime.start()\n await cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
1
+ {"version":3,"file":"run_cucumber.js","sourceRoot":"","sources":["../../src/api/run_cucumber.ts"],"names":[],"mappings":";;;AAAA,iDAAsE;AACtE,mCAAqC;AACrC,kDAAyD;AACzD,4CAAyE;AAEzE,mCAAsC;AACtC,uCAAuC;AACvC,6CAAmD;AACnD,uCAAiD;AACjD,qCAAiC;AACjC,+CAAgD;AAChD,uCAAuD;AACvD,uCAA6C;AAE7C;;;;;;;GAOG;AACI,KAAK,UAAU,WAAW,CAC/B,aAA0B,EAC1B,cAA+B,EAAE,EACjC,SAAuC;IAEvC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,IAAA,8BAAgB,EAAC,WAAW,CAAC,CAAA;IAClE,MAAM,MAAM,GAAG,IAAI,iBAAO,CAAC,MAAM,CAAC,CAAA;IAClC,MAAM,KAAK,GAAG,sBAAW,CAAC,IAAI,EAAE,CAAA;IAEhC,MAAM,kBAAkB,GACtB,OAAO,IAAI,aAAa,CAAC,OAAO;QAC9B,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,mBAAmB;QAC3C,CAAC,CAAC,aAAa,CAAC,OAAO,CAAA;IAE3B,MAAM,EAAE,sBAAsB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,GACvE,MAAM,IAAA,oBAAY,EAAC,GAAG,EAAE,aAAa,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;IAEpE,MAAM,kBAAkB,GACtB,OAAO,IAAI,aAAa,CAAC,OAAO;QAC9B,CAAC,CAAC,aAAa,CAAC,OAAO;QACvB,CAAC,CAAC,MAAM,IAAA,+BAAqB,EAAC;YAC1B,GAAG;YACH,KAAK;YACL,YAAY;YACZ,WAAW;YACX,cAAc,EAAE,kBAAkB,CAAC,cAAc;SAClD,CAAC,CAAA;IAER,MAAM,OAAO,GAAG,MAAM,IAAA,2BAAiB,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,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACxE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAA;KACxC;IACD,IAAI,WAAW,CAAC,MAAM,EAAE;QACtB,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjC,MAAM,CAAC,KAAK,CACV,mBAAmB,UAAU,CAAC,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC,OAAO,EAAE,CAClE,CAAA;QACH,CAAC,CAAC,CAAA;QACF,MAAM,iBAAiB,EAAE,CAAA;QACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;QACvB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kBAAkB;SAC5B,CAAA;KACF;IAED,IAAA,iCAAuB,EAAC;QACtB,gBAAgB;QAChB,kBAAkB;QAClB,KAAK;KACN,CAAC,CAAA;IAEF,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC;QAC1B,GAAG;QACH,MAAM;QACN,gBAAgB;QAChB,kBAAkB;QAClB,SAAS;QACT,KAAK;QACL,kBAAkB;QAClB,cAAc,EAAE,kBAAkB,CAAC,cAAc;QACjD,YAAY;QACZ,WAAW;QACX,OAAO,EAAE,aAAa,CAAC,OAAO;KAC/B,CAAC,CAAA;IACF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,EAAE,CAAA;IACrC,MAAM,iBAAiB,EAAE,CAAA;IACzB,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IAEvB,OAAO;QACL,OAAO,EAAE,OAAO,IAAI,CAAC,oBAAoB;QACzC,OAAO,EAAE,kBAAkB;KAC5B,CAAA;AACH,CAAC;AA5GD,kCA4GC","sourcesContent":["import { Envelope, IdGenerator, ParseError } from '@cucumber/messages'\nimport { EventEmitter } from 'events'\nimport { EventDataCollector } from '../formatter/helpers'\nimport { emitMetaMessage, emitSupportCodeMessages } from '../cli/helpers'\nimport { IRunOptions, IRunEnvironment, IRunResult } from './types'\nimport { resolvePaths } from './paths'\nimport { makeRuntime } from './runtime'\nimport { initializeFormatters } from './formatters'\nimport { getSupportCodeLibrary } from './support'\nimport { Console } from 'console'\nimport { mergeEnvironment } from './environment'\nimport { getFilteredPicklesAndErrors } from './gherkin'\nimport { initializePlugins } from './plugins'\n\n/**\n * Execute a Cucumber test run.\n *\n * @public\n * @param configuration - Configuration loaded from `loadConfiguration`.\n * @param environment - Project environment.\n * @param onMessage - Callback fired each time Cucumber emits a message.\n */\nexport async function runCucumber(\n configuration: IRunOptions,\n environment: IRunEnvironment = {},\n onMessage?: (message: Envelope) => void\n): Promise<IRunResult> {\n const { cwd, stdout, stderr, env } = mergeEnvironment(environment)\n const logger = new Console(stderr)\n const newId = IdGenerator.uuid()\n\n const supportCoordinates =\n 'World' in configuration.support\n ? configuration.support.originalCoordinates\n : configuration.support\n\n const { unexpandedFeaturePaths, featurePaths, requirePaths, importPaths } =\n await resolvePaths(cwd, configuration.sources, supportCoordinates)\n\n const supportCodeLibrary =\n 'World' in configuration.support\n ? configuration.support\n : await getSupportCodeLibrary({\n cwd,\n newId,\n requirePaths,\n importPaths,\n requireModules: supportCoordinates.requireModules,\n })\n\n const plugins = await initializePlugins(logger, configuration, environment)\n\n const eventBroadcaster = new EventEmitter()\n if (onMessage) {\n eventBroadcaster.on('envelope', onMessage)\n }\n eventBroadcaster.on('envelope', (value) => plugins.emit('message', value))\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: configuration.formats,\n supportCodeLibrary,\n })\n await emitMetaMessage(eventBroadcaster, env)\n\n let pickleIds: string[] = []\n let parseErrors: ParseError[] = []\n if (featurePaths.length > 0) {\n const gherkinResult = await getFilteredPicklesAndErrors({\n newId,\n cwd,\n logger,\n unexpandedFeaturePaths,\n featurePaths,\n coordinates: configuration.sources,\n onEnvelope: (envelope) => eventBroadcaster.emit('envelope', envelope),\n })\n pickleIds = gherkinResult.filteredPickles.map(({ pickle }) => pickle.id)\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 plugins.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 = makeRuntime({\n cwd,\n logger,\n eventBroadcaster,\n eventDataCollector,\n pickleIds,\n newId,\n supportCodeLibrary,\n requireModules: supportCoordinates.requireModules,\n requirePaths,\n importPaths,\n options: configuration.runtime,\n })\n const success = await runtime.start()\n await cleanupFormatters()\n await plugins.cleanup()\n\n return {\n success: success && !formatterStreamError,\n support: supportCodeLibrary,\n }\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IRuntime } from '../runtime';
3
4
  import { EventEmitter } from 'events';
4
5
  import { EventDataCollector } from '../formatter/helpers';
@@ -1,9 +1,11 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
3
- import { FormatOptions, IFormatterStream } from '../formatter';
4
+ import { FormatOptions, IPublishConfig } from '../formatter';
4
5
  import { PickleOrder } from '../models/pickle_order';
5
6
  import { IRuntimeOptions } from '../runtime';
6
7
  import { IConfiguration } from '../configuration';
8
+ import { Writable } from 'stream';
7
9
  /**
8
10
  * @public
9
11
  */
@@ -100,10 +102,7 @@ export interface IRunOptionsRuntime extends IRuntimeOptions {
100
102
  export interface IRunOptionsFormats {
101
103
  stdout: string;
102
104
  files: Record<string, string>;
103
- publish: {
104
- url?: string;
105
- token?: string;
106
- } | false;
105
+ publish: IPublishConfig | false;
107
106
  options: FormatOptions;
108
107
  }
109
108
  /**
@@ -141,11 +140,11 @@ export interface IRunEnvironment {
141
140
  /**
142
141
  * Writable stream where the test run's main output is written (defaults to `process.stdout` if omitted).
143
142
  */
144
- stdout?: IFormatterStream;
143
+ stdout?: Writable;
145
144
  /**
146
145
  * Writable stream where the test run's warning/error output is written (defaults to `process.stderr` if omitted).
147
146
  */
148
- stderr?: IFormatterStream;
147
+ stderr?: Writable;
149
148
  /**
150
149
  * Environment variables (defaults to `process.env` if omitted).
151
150
  */
@@ -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, IFormatterStream } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\nimport { IRuntimeOptions } from '../runtime'\nimport { IConfiguration } from '../configuration'\n\n/**\n * @public\n */\nexport interface ILoadConfigurationOptions {\n /**\n * Path to load configuration file from (defaults to `cucumber.(js|cjs|mjs|json)` if omitted).\n */\n file?: string\n /**\n * Zero or more profile names from which to source configuration (if omitted or empty, the `default` profile will be used).\n */\n profiles?: string[]\n /**\n * Ad-hoc configuration options to be applied over the top of whatever is loaded from the configuration file/profiles.\n */\n provided?: Partial<IConfiguration>\n}\n\n/**\n * @public\n */\nexport interface IResolvedConfiguration {\n /**\n * The final flat configuration object resolved from the configuration file/profiles plus any extra provided.\n */\n useConfiguration: IConfiguration\n /**\n * The format that can be passed into `runCucumber`.\n */\n runConfiguration: IRunConfiguration\n}\n\n/**\n * @public\n */\nexport interface ISourcesCoordinates {\n defaultDialect: string\n paths: string[]\n names: string[]\n tagExpression: string\n order: PickleOrder\n}\n\n/**\n * @public\n */\nexport interface IPlannedPickle {\n name: string\n uri: string\n location: {\n line: number\n column?: number\n }\n}\n\n/**\n * @public\n */\nexport interface ISourcesError {\n uri: string\n location: {\n line: number\n column?: number\n }\n message: string\n}\n\n/**\n * @public\n */\nexport interface ILoadSourcesResult {\n plan: IPlannedPickle[]\n errors: ISourcesError[]\n}\n\n/**\n * @public\n */\nexport interface ISupportCodeCoordinates {\n requireModules: string[]\n requirePaths: string[]\n importPaths: string[]\n}\n\n/**\n * @public\n */\nexport interface ILoadSupportOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsRuntime extends IRuntimeOptions {\n parallel: number\n}\n\n/**\n * @public\n */\nexport interface IRunOptionsFormats {\n stdout: string\n files: Record<string, string>\n publish:\n | {\n url?: string\n token?: string\n }\n | false\n options: FormatOptions\n}\n\n/**\n * @public\n */\nexport interface IRunConfiguration {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinates\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * @public\n */\nexport type ISupportCodeCoordinatesOrLibrary =\n | ISupportCodeCoordinates\n | ISupportCodeLibrary\n\n/**\n * @public\n */\nexport interface IRunOptions {\n sources: ISourcesCoordinates\n support: ISupportCodeCoordinatesOrLibrary\n runtime: IRunOptionsRuntime\n formats: IRunOptionsFormats\n}\n\n/**\n * Contextual data about the project environment.\n *\n * @public\n */\nexport interface IRunEnvironment {\n /**\n * Working directory for the project (defaults to `process.cwd()` if omitted).\n */\n cwd?: string\n /**\n * Writable stream where the test run's main output is written (defaults to `process.stdout` if omitted).\n */\n stdout?: IFormatterStream\n /**\n * Writable stream where the test run's warning/error output is written (defaults to `process.stderr` if omitted).\n */\n stderr?: IFormatterStream\n /**\n * Environment variables (defaults to `process.env` if omitted).\n */\n env?: NodeJS.ProcessEnv\n}\n\n/**\n * Result of a Cucumber test run.\n *\n * @public\n */\nexport interface IRunResult {\n /**\n * Whether the test run was overall successful i.e. no failed scenarios. The exact meaning can vary based on the `strict` configuration option.\n */\n success: boolean\n /**\n * The support code library that was used in the test run; can be reused in subsequent `runCucumber` calls.\n */\n support: ISupportCodeLibrary\n}\n"]}
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'\nimport { Writable } from 'stream'\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 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\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"]}
@@ -1,4 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
2
5
  import { EventEmitter } from 'events';
3
6
  import PickleFilter from '../pickle_filter';
4
7
  import { EventDataCollector } from '../formatter/helpers';
package/lib/cli/index.js CHANGED
@@ -13,7 +13,7 @@ class Cli {
13
13
  this.env = env;
14
14
  }
15
15
  async run() {
16
- await (0, install_validator_1.validateInstall)(this.cwd);
16
+ await (0, install_validator_1.validateInstall)();
17
17
  const { options, configuration: argvConfiguration } = configuration_1.ArgvParser.parse(this.argv);
18
18
  if (options.i18nLanguages) {
19
19
  this.stdout.write((0, i18n_1.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EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;QACD,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,GACzD,MAAM,IAAA,uBAAiB,EACrB;YACE,IAAI,EAAE,OAAO,CAAC,MAAM;YACpB,QAAQ,EAAE,OAAO,CAAC,OAAO;YACzB,QAAQ,EAAE,iBAAiB;SAC5B,EACD,WAAW,CACZ,CAAA;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,iBAAW,EAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACpE,OAAO;YACL,sBAAsB,EACpB,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO;gBACjC,CAAC,aAAa,CAAC,YAAY;gBAC3B,CAAC,IAAA,8BAAc,EAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC;YAClD,qBAAqB,EAAE,aAAa,CAAC,SAAS;YAC9C,OAAO;SACR,CAAA;IACH,CAAC;CACF;AAzED,sBAyEC","sourcesContent":["import { ArgvParser, isTruthyString } 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 shouldAdvertisePublish: boolean\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,\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 await validateInstall(this.cwd)\n const { options, configuration: argvConfiguration } = ArgvParser.parse(\n this.argv\n )\n if (options.i18nLanguages) {\n this.stdout.write(getLanguages())\n return {\n shouldAdvertisePublish: false,\n shouldExitImmediately: true,\n success: true,\n }\n }\n if (options.i18nKeywords) {\n this.stdout.write(getKeywords(options.i18nKeywords))\n return {\n shouldAdvertisePublish: false,\n shouldExitImmediately: true,\n success: true,\n }\n }\n const environment = {\n cwd: this.cwd,\n stdout: this.stdout,\n stderr: this.stderr,\n env: this.env,\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 shouldAdvertisePublish:\n !runConfiguration.formats.publish &&\n !configuration.publishQuiet &&\n !isTruthyString(this.env.CUCUMBER_PUBLISH_QUIET),\n shouldExitImmediately: configuration.forceExit,\n success,\n }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AAAA,oDAA6D;AAE7D,gCAAuD;AACvD,iCAAkD;AAClD,2DAAqD;AAQrD,MAAqB,GAAG;IAOtB,YAAY,EACV,IAAI,EACJ,GAAG,EACH,MAAM,EACN,MAAM,EACN,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,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAA,mCAAe,GAAE,CAAA;QACvB,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,0BAAU,CAAC,KAAK,CACpE,IAAI,CAAC,IAAI,CACV,CAAA;QACD,IAAI,OAAO,CAAC,aAAa,EAAE;YACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,mBAAY,GAAE,CAAC,CAAA;YACjC,OAAO;gBACL,sBAAsB,EAAE,KAAK;gBAC7B,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;aACd,CAAA;SACF;QACD,IAAI,OAAO,CAAC,YAAY,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,kBAAW,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;YACpD,OAAO;gBACL,sBAAsB,EAAE,KAAK;gBAC7B,qBAAqB,EAAE,IAAI;gBAC3B,OAAO,EAAE,IAAI;aACd,CAAA;SACF;QACD,MAAM,WAAW,GAAG;YAClB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;QACD,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,gBAAgB,EAAE,GACzD,MAAM,IAAA,uBAAiB,EACrB;YACE,IAAI,EAAE,OAAO,CAAC,MAAM;YACpB,QAAQ,EAAE,OAAO,CAAC,OAAO;YACzB,QAAQ,EAAE,iBAAiB;SAC5B,EACD,WAAW,CACZ,CAAA;QACH,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,iBAAW,EAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACpE,OAAO;YACL,sBAAsB,EACpB,CAAC,gBAAgB,CAAC,OAAO,CAAC,OAAO;gBACjC,CAAC,aAAa,CAAC,YAAY;gBAC3B,CAAC,IAAA,8BAAc,EAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,CAAC;YAClD,qBAAqB,EAAE,aAAa,CAAC,SAAS;YAC9C,OAAO;SACR,CAAA;IACH,CAAC;CACF;AAzED,sBAyEC","sourcesContent":["import { ArgvParser, isTruthyString } 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 shouldAdvertisePublish: boolean\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,\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 await validateInstall()\n const { options, configuration: argvConfiguration } = ArgvParser.parse(\n this.argv\n )\n if (options.i18nLanguages) {\n this.stdout.write(getLanguages())\n return {\n shouldAdvertisePublish: false,\n shouldExitImmediately: true,\n success: true,\n }\n }\n if (options.i18nKeywords) {\n this.stdout.write(getKeywords(options.i18nKeywords))\n return {\n shouldAdvertisePublish: false,\n shouldExitImmediately: true,\n success: true,\n }\n }\n const environment = {\n cwd: this.cwd,\n stdout: this.stdout,\n stderr: this.stderr,\n env: this.env,\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 shouldAdvertisePublish:\n !runConfiguration.formats.publish &&\n !configuration.publishQuiet &&\n !isTruthyString(this.env.CUCUMBER_PUBLISH_QUIET),\n shouldExitImmediately: configuration.forceExit,\n success,\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- export declare function validateInstall(cwd: string): Promise<void>;
1
+ export declare function validateInstall(): Promise<void>;
@@ -4,37 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validateInstall = void 0;
7
- const fs_1 = __importDefault(require("mz/fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const resolve_1 = __importDefault(require("resolve"));
10
- const util_1 = require("util");
11
- async function validateInstall(cwd) {
12
- const projectPath = path_1.default.join(__dirname, '..', '..');
13
- if (projectPath === cwd) {
14
- return; // cucumber testing itself
15
- }
16
- const currentCucumberPath = require.resolve(projectPath);
17
- let localCucumberPath;
18
- try {
19
- localCucumberPath = await (0, util_1.promisify)(resolve_1.default)('@cucumber/cucumber', {
20
- basedir: cwd,
21
- });
22
- }
23
- catch (e) {
24
- throw new Error('`@cucumber/cucumber` module not resolvable. Must be locally installed.');
25
- }
26
- localCucumberPath = await fs_1.default.realpath(localCucumberPath);
27
- if (localCucumberPath !== currentCucumberPath) {
28
- throw new Error(`
29
- You appear to be executing an install of cucumber (most likely a global install)
30
- that is different from your local install (the one required in your support files).
31
- For cucumber to work, you need to execute the same install that is required in your support files.
32
- Please execute the locally installed version to run your tests.
33
-
34
- Executed Path: ${currentCucumberPath}
35
- Local Path: ${localCucumberPath}
7
+ /* eslint-disable no-console */
8
+ const is_installed_globally_1 = __importDefault(require("is-installed-globally"));
9
+ async function validateInstall() {
10
+ if (is_installed_globally_1.default)
11
+ console.warn(`
12
+ It looks like you're running Cucumber from a global installation.
13
+ This won't work - you need to have Cucumber installed as a local dependency in your project.
14
+ See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations
36
15
  `);
37
- }
38
16
  }
39
17
  exports.validateInstall = validateInstall;
40
18
  //# sourceMappingURL=install_validator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"install_validator.js","sourceRoot":"","sources":["../../src/cli/install_validator.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAsB;AACtB,gDAAuB;AACvB,sDAA6B;AAC7B,+BAAgC;AAEzB,KAAK,UAAU,eAAe,CAAC,GAAW;IAC/C,MAAM,WAAW,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACpD,IAAI,WAAW,KAAK,GAAG,EAAE;QACvB,OAAM,CAAC,0BAA0B;KAClC;IACD,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACxD,IAAI,iBAAyB,CAAA;IAC7B,IAAI;QACF,iBAAiB,GAAG,MAAM,IAAA,gBAAS,EAA+B,iBAAO,CAAC,CACxE,oBAAoB,EACpB;YACE,OAAO,EAAE,GAAG;SACb,CACF,CAAA;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAA;KACF;IACD,iBAAiB,GAAG,MAAM,YAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IACxD,IAAI,iBAAiB,KAAK,mBAAmB,EAAE;QAC7C,MAAM,IAAI,KAAK,CACb;;;;;;uBAMiB,mBAAmB;uBACnB,iBAAiB;OACjC,CACF,CAAA;KACF;AACH,CAAC;AAjCD,0CAiCC","sourcesContent":["import fs from 'mz/fs'\nimport path from 'path'\nimport resolve from 'resolve'\nimport { promisify } from 'util'\n\nexport async function validateInstall(cwd: string): Promise<void> {\n const projectPath = path.join(__dirname, '..', '..')\n if (projectPath === cwd) {\n return // cucumber testing itself\n }\n const currentCucumberPath = require.resolve(projectPath)\n let localCucumberPath: string\n try {\n localCucumberPath = await promisify<string, resolve.Opts, string>(resolve)(\n '@cucumber/cucumber',\n {\n basedir: cwd,\n }\n )\n } catch (e) {\n throw new Error(\n '`@cucumber/cucumber` module not resolvable. Must be locally installed.'\n )\n }\n localCucumberPath = await fs.realpath(localCucumberPath)\n if (localCucumberPath !== currentCucumberPath) {\n throw new Error(\n `\n You appear to be executing an install of cucumber (most likely a global install)\n that is different from your local install (the one required in your support files).\n For cucumber to work, you need to execute the same install that is required in your support files.\n Please execute the locally installed version to run your tests.\n\n Executed Path: ${currentCucumberPath}\n Local Path: ${localCucumberPath}\n `\n )\n }\n}\n"]}
1
+ {"version":3,"file":"install_validator.js","sourceRoot":"","sources":["../../src/cli/install_validator.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kFAAuD;AAEhD,KAAK,UAAU,eAAe;IACnC,IAAI,+BAAmB;QACrB,OAAO,CAAC,IAAI,CACV;;;;OAIC,CACF,CAAA;AACL,CAAC;AATD,0CASC","sourcesContent":["/* eslint-disable no-console */\nimport isInstalledGlobally from 'is-installed-globally'\n\nexport async function validateInstall(): Promise<void> {\n if (isInstalledGlobally)\n console.warn(\n `\n It looks like you're running Cucumber from a global installation.\n This won't work - you need to have Cucumber installed as a local dependency in your project.\n See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations\n `\n )\n}\n"]}
@@ -1,4 +1,7 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
2
5
  import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
3
6
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
4
7
  import Formatter, { FormatOptions, IFormatterCleanupFn, IFormatterLogFn } from '.';
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { TestStepResultStatus } from '@cucumber/messages';
3
4
  import { Writable } from 'stream';
4
5
  export declare type IColorFn = (text: string) => string;
@@ -0,0 +1,2 @@
1
+ import { Duration } from '@cucumber/messages';
2
+ export declare function durationToNanoseconds(duration: Duration): number;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.durationToNanoseconds = void 0;
4
+ const NANOS_IN_SECOND = 1000000000;
5
+ function durationToNanoseconds(duration) {
6
+ return Math.floor(duration.seconds * NANOS_IN_SECOND + duration.nanos);
7
+ }
8
+ exports.durationToNanoseconds = durationToNanoseconds;
9
+ //# sourceMappingURL=duration_helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration_helpers.js","sourceRoot":"","sources":["../../../src/formatter/helpers/duration_helpers.ts"],"names":[],"mappings":";;;AAEA,MAAM,eAAe,GAAG,UAAa,CAAA;AAErC,SAAgB,qBAAqB,CAAC,QAAkB;IACtD,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,GAAG,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxE,CAAC;AAFD,sDAEC","sourcesContent":["import { Duration } from '@cucumber/messages'\n\nconst NANOS_IN_SECOND = 1_000_000_000\n\nexport function durationToNanoseconds(duration: Duration): number {\n return Math.floor(duration.seconds * NANOS_IN_SECOND + duration.nanos)\n}\n"]}
@@ -1,13 +1,11 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { IColorFns } from './get_color_fns';
3
4
  import { EventDataCollector } from './helpers';
4
5
  import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
5
- import { PassThrough, Writable as WritableStream } from 'stream';
6
+ import { Writable } from 'stream';
6
7
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
7
- import { WriteStream as FsWriteStream } from 'fs';
8
- import { WriteStream as TtyWriteStream } from 'tty';
9
8
  import { EventEmitter } from 'events';
10
- import HttpStream from './http_stream';
11
9
  import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
12
10
  export interface FormatRerunOptions {
13
11
  separator?: string;
@@ -20,7 +18,11 @@ export interface FormatOptions {
20
18
  printAttachments?: boolean;
21
19
  [customKey: string]: any;
22
20
  }
23
- export declare type IFormatterStream = FsWriteStream | TtyWriteStream | PassThrough | HttpStream;
21
+ export interface IPublishConfig {
22
+ url: string;
23
+ token: string;
24
+ }
25
+ export declare type IFormatterStream = Writable;
24
26
  export declare type IFormatterLogFn = (buffer: string | Uint8Array) => void;
25
27
  export declare type IFormatterCleanupFn = () => Promise<any>;
26
28
  export interface IFormatterOptions {
@@ -31,7 +33,7 @@ export interface IFormatterOptions {
31
33
  log: IFormatterLogFn;
32
34
  parsedArgvOptions: FormatOptions;
33
35
  snippetBuilder: StepDefinitionSnippetBuilder;
34
- stream: WritableStream;
36
+ stream: Writable;
35
37
  cleanup: IFormatterCleanupFn;
36
38
  supportCodeLibrary: ISupportCodeLibrary;
37
39
  }
@@ -41,7 +43,7 @@ export default class Formatter {
41
43
  protected eventDataCollector: EventDataCollector;
42
44
  protected log: IFormatterLogFn;
43
45
  protected snippetBuilder: StepDefinitionSnippetBuilder;
44
- protected stream: WritableStream;
46
+ protected stream: Writable;
45
47
  protected supportCodeLibrary: ISupportCodeLibrary;
46
48
  protected printAttachments: boolean;
47
49
  private readonly cleanup;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AASA,oDAAiD;AAqCjD,MAAqB,SAAS;IAY5B,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { PassThrough, Writable as WritableStream } from 'stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { WriteStream as FsWriteStream } from 'fs'\nimport { WriteStream as TtyWriteStream } from 'tty'\nimport { EventEmitter } from 'events'\nimport HttpStream from './http_stream'\nimport { valueOrDefault } from '../value_checker'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport type IFormatterStream =\n | FsWriteStream\n | TtyWriteStream\n | PassThrough\n | HttpStream\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: WritableStream\n protected supportCodeLibrary: ISupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/formatter/index.ts"],"names":[],"mappings":";;AAMA,oDAAiD;AAsCjD,MAAqB,SAAS;IAY5B,YAAY,OAA0B;QACpC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;QACtB,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAA;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,gBAAgB,GAAG,IAAA,8BAAc,EACpC,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,EAC1C,IAAI,CACL,CAAA;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;IACtB,CAAC;CACF;AA9BD,4BA8BC","sourcesContent":["import { IColorFns } from './get_color_fns'\nimport { EventDataCollector } from './helpers'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { Writable } from 'stream'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport { EventEmitter } from 'events'\nimport { valueOrDefault } from '../value_checker'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\n\nexport interface FormatRerunOptions {\n separator?: string\n}\n\nexport interface FormatOptions {\n colorsEnabled?: boolean\n rerun?: FormatRerunOptions\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n printAttachments?: boolean\n [customKey: string]: any\n}\n\nexport interface IPublishConfig {\n url: string\n token: string\n}\n\nexport type IFormatterStream = Writable\nexport type IFormatterLogFn = (buffer: string | Uint8Array) => void\nexport type IFormatterCleanupFn = () => Promise<any>\n\nexport interface IFormatterOptions {\n colorFns: IColorFns\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n snippetBuilder: StepDefinitionSnippetBuilder\n stream: Writable\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport default class Formatter {\n protected colorFns: IColorFns\n protected cwd: string\n protected eventDataCollector: EventDataCollector\n protected log: IFormatterLogFn\n protected snippetBuilder: StepDefinitionSnippetBuilder\n protected stream: Writable\n protected supportCodeLibrary: ISupportCodeLibrary\n protected printAttachments: boolean\n private readonly cleanup: IFormatterCleanupFn\n static readonly documentation: string\n\n constructor(options: IFormatterOptions) {\n this.colorFns = options.colorFns\n this.cwd = options.cwd\n this.eventDataCollector = options.eventDataCollector\n this.log = options.log\n this.snippetBuilder = options.snippetBuilder\n this.stream = options.stream\n this.supportCodeLibrary = options.supportCodeLibrary\n this.cleanup = options.cleanup\n this.printAttachments = valueOrDefault(\n options.parsedArgvOptions.printAttachments,\n true\n )\n }\n\n async finished(): Promise<void> {\n await this.cleanup()\n }\n}\n"]}
@@ -32,6 +32,7 @@ const messages = __importStar(require("@cucumber/messages"));
32
32
  const gherkin_document_parser_1 = require("./helpers/gherkin_document_parser");
33
33
  const value_checker_1 = require("../value_checker");
34
34
  const step_arguments_1 = require("../step_arguments");
35
+ const duration_helpers_1 = require("./helpers/duration_helpers");
35
36
  const { getGherkinStepMap, getGherkinScenarioMap } = helpers_1.GherkinDocumentParser;
36
37
  const { getScenarioDescription, getPickleStepMap, getStepKeyword } = helpers_1.PickleParser;
37
38
  class JsonFormatter extends _1.default {
@@ -184,8 +185,7 @@ class JsonFormatter extends _1.default {
184
185
  status: messages.TestStepResultStatus[status].toLowerCase(),
185
186
  };
186
187
  if ((0, value_checker_1.doesHaveValue)(testStepResult.duration)) {
187
- data.result.duration =
188
- messages.TimeConversion.durationToMilliseconds(testStepResult.duration) * 1000000;
188
+ data.result.duration = (0, duration_helpers_1.durationToNanoseconds)(testStepResult.duration);
189
189
  }
190
190
  if (status === messages.TestStepResultStatus.FAILED &&
191
191
  (0, value_checker_1.doesHaveValue)(message)) {