@cucumber/cucumber 8.0.0-rc.2 → 8.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +81 -51
  2. package/api/index.d.ts +6 -0
  3. package/lib/api/convert_configuration.d.ts +4 -0
  4. package/lib/api/convert_configuration.js +64 -0
  5. package/lib/api/convert_configuration.js.map +1 -0
  6. package/lib/api/environment.d.ts +2 -0
  7. package/lib/api/environment.js +13 -0
  8. package/lib/api/environment.js.map +1 -0
  9. package/lib/{run → api}/formatters.d.ts +5 -3
  10. package/lib/{run → api}/formatters.js +13 -17
  11. package/lib/api/formatters.js.map +1 -0
  12. package/lib/api/gherkin.d.ts +21 -0
  13. package/lib/api/gherkin.js +65 -0
  14. package/lib/api/gherkin.js.map +1 -0
  15. package/lib/api/index.d.ts +11 -0
  16. package/lib/{run → api}/index.js +10 -1
  17. package/lib/api/index.js.map +1 -0
  18. package/lib/api/load_configuration.d.ts +9 -0
  19. package/lib/api/load_configuration.js +32 -0
  20. package/lib/api/load_configuration.js.map +1 -0
  21. package/lib/api/load_sources.d.ts +9 -0
  22. package/lib/api/load_sources.js +53 -0
  23. package/lib/api/load_sources.js.map +1 -0
  24. package/lib/api/load_support.d.ts +10 -0
  25. package/lib/api/load_support.js +28 -0
  26. package/lib/api/load_support.js.map +1 -0
  27. package/lib/api/paths.d.ts +7 -0
  28. package/lib/{run → api}/paths.js +25 -9
  29. package/lib/api/paths.js.map +1 -0
  30. package/lib/api/run_cucumber.d.ts +11 -0
  31. package/lib/api/run_cucumber.js +108 -0
  32. package/lib/api/run_cucumber.js.map +1 -0
  33. package/lib/{run → api}/runtime.d.ts +8 -7
  34. package/lib/api/runtime.js +36 -0
  35. package/lib/api/runtime.js.map +1 -0
  36. package/lib/{run → api}/support.d.ts +4 -3
  37. package/lib/{run → api}/support.js +5 -10
  38. package/lib/api/support.js.map +1 -0
  39. package/lib/api/types.d.ts +168 -0
  40. package/lib/{run → api}/types.js +0 -0
  41. package/lib/api/types.js.map +1 -0
  42. package/lib/api/wrapper.mjs +6 -0
  43. package/lib/cli/helpers.d.ts +16 -11
  44. package/lib/cli/helpers.js +19 -29
  45. package/lib/cli/helpers.js.map +1 -1
  46. package/lib/cli/index.d.ts +3 -1
  47. package/lib/cli/index.js +35 -19
  48. package/lib/cli/index.js.map +1 -1
  49. package/lib/cli/publish_banner.js +6 -6
  50. package/lib/cli/publish_banner.js.map +1 -1
  51. package/lib/cli/run.js +12 -3
  52. package/lib/cli/run.js.map +1 -1
  53. package/lib/cli/validate_node_engine_version.d.ts +7 -0
  54. package/lib/cli/validate_node_engine_version.js +20 -0
  55. package/lib/cli/validate_node_engine_version.js.map +1 -0
  56. package/lib/configuration/argv_parser.d.ts +20 -0
  57. package/lib/{cli → configuration}/argv_parser.js +44 -45
  58. package/lib/configuration/argv_parser.js.map +1 -0
  59. package/lib/configuration/check_schema.d.ts +2 -0
  60. package/lib/configuration/check_schema.js +56 -0
  61. package/lib/configuration/check_schema.js.map +1 -0
  62. package/lib/configuration/default_configuration.d.ts +2 -0
  63. package/lib/configuration/default_configuration.js +27 -0
  64. package/lib/configuration/default_configuration.js.map +1 -0
  65. package/lib/configuration/from_file.d.ts +2 -0
  66. package/lib/configuration/from_file.js +68 -0
  67. package/lib/configuration/from_file.js.map +1 -0
  68. package/lib/configuration/helpers.d.ts +1 -0
  69. package/lib/configuration/helpers.js +11 -0
  70. package/lib/configuration/helpers.js.map +1 -0
  71. package/lib/configuration/index.d.ts +6 -0
  72. package/lib/configuration/index.js +11 -0
  73. package/lib/configuration/index.js.map +1 -1
  74. package/lib/configuration/locate_file.d.ts +1 -0
  75. package/lib/configuration/locate_file.js +19 -0
  76. package/lib/configuration/locate_file.js.map +1 -0
  77. package/lib/configuration/merge_configurations.d.ts +2 -0
  78. package/lib/configuration/merge_configurations.js +48 -0
  79. package/lib/configuration/merge_configurations.js.map +1 -0
  80. package/lib/configuration/option_splitter.d.ts +3 -0
  81. package/lib/{cli → configuration}/option_splitter.js +2 -2
  82. package/lib/configuration/option_splitter.js.map +1 -0
  83. package/lib/configuration/types.d.ts +24 -28
  84. package/lib/configuration/types.js.map +1 -1
  85. package/lib/configuration/validate_configuration.d.ts +2 -0
  86. package/lib/configuration/validate_configuration.js +10 -0
  87. package/lib/configuration/validate_configuration.js.map +1 -0
  88. package/lib/formatter/builder.d.ts +2 -3
  89. package/lib/formatter/builder.js +8 -1
  90. package/lib/formatter/builder.js.map +1 -1
  91. package/lib/formatter/get_color_fns.js +15 -16
  92. package/lib/formatter/get_color_fns.js.map +1 -1
  93. package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
  94. package/lib/formatter/helpers/issue_helpers.js +2 -2
  95. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  96. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
  97. package/lib/formatter/helpers/test_case_attempt_formatter.js +9 -8
  98. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  99. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
  100. package/lib/formatter/helpers/test_case_attempt_parser.js +1 -1
  101. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  102. package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
  103. package/lib/formatter/helpers/usage_helpers/index.js +3 -3
  104. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  105. package/lib/formatter/index.d.ts +14 -2
  106. package/lib/formatter/index.js +2 -0
  107. package/lib/formatter/index.js.map +1 -1
  108. package/lib/formatter/json_formatter.js.map +1 -1
  109. package/lib/formatter/progress_bar_formatter.js +1 -1
  110. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  111. package/lib/formatter/snippets_formatter.js +0 -1
  112. package/lib/formatter/snippets_formatter.js.map +1 -1
  113. package/lib/formatter/summary_formatter.js +1 -1
  114. package/lib/formatter/summary_formatter.js.map +1 -1
  115. package/lib/formatter/usage_formatter.js +0 -1
  116. package/lib/formatter/usage_formatter.js.map +1 -1
  117. package/lib/formatter/usage_json_formatter.js +0 -1
  118. package/lib/formatter/usage_json_formatter.js.map +1 -1
  119. package/lib/index.d.ts +2 -0
  120. package/lib/index.js +4 -1
  121. package/lib/index.js.map +1 -1
  122. package/lib/models/pickle_order.d.ts +1 -0
  123. package/lib/models/pickle_order.js +3 -0
  124. package/lib/models/pickle_order.js.map +1 -0
  125. package/lib/runtime/index.d.ts +3 -5
  126. package/lib/runtime/index.js +7 -36
  127. package/lib/runtime/index.js.map +1 -1
  128. package/lib/runtime/parallel/command_types.d.ts +3 -2
  129. package/lib/runtime/parallel/command_types.js.map +1 -1
  130. package/lib/runtime/parallel/coordinator.d.ts +27 -8
  131. package/lib/runtime/parallel/coordinator.js +66 -19
  132. package/lib/runtime/parallel/coordinator.js.map +1 -1
  133. package/lib/runtime/parallel/worker.d.ts +2 -4
  134. package/lib/runtime/parallel/worker.js +11 -34
  135. package/lib/runtime/parallel/worker.js.map +1 -1
  136. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  137. package/lib/runtime/run_test_run_hooks.js +28 -0
  138. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  139. package/lib/support_code_library_builder/index.d.ts +4 -2
  140. package/lib/support_code_library_builder/index.js +25 -2
  141. package/lib/support_code_library_builder/index.js.map +1 -1
  142. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  143. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  144. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  145. package/lib/support_code_library_builder/types.d.ts +9 -0
  146. package/lib/support_code_library_builder/types.js.map +1 -1
  147. package/lib/version.d.ts +1 -1
  148. package/lib/version.js +1 -1
  149. package/lib/version.js.map +1 -1
  150. package/lib/wrapper.mjs +4 -0
  151. package/package.json +47 -28
  152. package/lib/cli/argv_parser.d.ts +0 -51
  153. package/lib/cli/argv_parser.js.map +0 -1
  154. package/lib/cli/configuration_builder.d.ts +0 -5
  155. package/lib/cli/configuration_builder.js +0 -71
  156. package/lib/cli/configuration_builder.js.map +0 -1
  157. package/lib/cli/option_splitter.d.ts +0 -4
  158. package/lib/cli/option_splitter.js.map +0 -1
  159. package/lib/cli/profile_loader.d.ts +0 -7
  160. package/lib/cli/profile_loader.js +0 -49
  161. package/lib/cli/profile_loader.js.map +0 -1
  162. package/lib/run/formatters.js.map +0 -1
  163. package/lib/run/index.d.ts +0 -2
  164. package/lib/run/index.js.map +0 -1
  165. package/lib/run/paths.d.ts +0 -6
  166. package/lib/run/paths.js.map +0 -1
  167. package/lib/run/runCucumber.d.ts +0 -3
  168. package/lib/run/runCucumber.js +0 -88
  169. package/lib/run/runCucumber.js.map +0 -1
  170. package/lib/run/runtime.js +0 -58
  171. package/lib/run/runtime.js.map +0 -1
  172. package/lib/run/support.js.map +0 -1
  173. package/lib/run/types.d.ts +0 -12
  174. package/lib/run/types.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":";;;;;AAAA,yCAAmC;AACnC,gEAAgC;AAChC,gDAAuB;AACvB,+CAA4C;AAC5C,iFAAwD;AACxD,wCAAoC;AAkBpC,MAAM,UAAU,GAAG;IACjB,OAAO,CAAI,GAAM,EAAE,OAAY,EAAE;QAC/B,IAAI,GAAG,EAAE;YACP,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,CAAC,CAAA;SACtB;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS,CAAC,MAAc;QACtB,OAAO,UAAU,GAAW,EAAE,OAAe,EAAE;YAC7C,IAAI,GAAW,CAAA;YACf,IAAI;gBACF,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;aACtB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,CAAC,GAAU,KAAK,CAAA;gBACtB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,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C7B,sEAAsE,EACtE,CAAC,GAAG,EAAE,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,EAAE,SAAS,CAAC,CACxD;aACA,MAAM,CACL,iCAAiC,EACjC;wDACgD,EAChD,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CAAC,UAAU,EAAE,iCAAiC,CAAC;aACrD,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;aAChE,MAAM,CACL,yBAAyB,EACzB,uFAAuF,EACvF,UAAU,CAAC,SAAS,CACrB;aACA,MAAM,CACL,2BAA2B,EAC3B,8EAA8E,EAC9E,UAAU,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAC3C,CAAA;QAEH,OAAO,CAAC,WAAW,CACjB,UAAU,EACV,6FAA6F,CAC9F,CAAA;QAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACnB,MAAM,EACJ,MAAM,EACN,YAAY,EACZ,aAAa,EACb,OAAO,EACP,GAAG,YAAY,EAChB,GAAoB,OAAO,CAAC,IAAI,EAAE,CAAA;QACnC,MAAM,aAAa,GAA4B,YAAY,CAAA;QAC3D,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,aAAa,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;SACnC;QAED,OAAO;YACL,OAAO,EAAE;gBACP,MAAM;gBACN,YAAY;gBACZ,aAAa;gBACb,OAAO;aACR;YACD,aAAa;SACd,CAAA;IACH,CAAC;CACF,CAAA;AAED,kBAAe,UAAU,CAAA","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\nimport path from 'path'\nimport { dialects } from '@cucumber/gherkin'\nimport Formatters from '../formatter/helpers/formatters'\nimport { version } from '../version'\nimport { IConfiguration } from './types'\n\nexport interface IParsedArgvOptions {\n config?: string\n i18nKeywords?: string\n i18nLanguages?: boolean\n profile: string[]\n}\n\nexport interface IParsedArgv {\n options: IParsedArgvOptions\n configuration: Partial<IConfiguration>\n}\n\ntype IRawArgvOptions = Partial<Omit<IConfiguration, 'paths'>> &\n IParsedArgvOptions\n\nconst ArgvParser = {\n collect<T>(val: T, memo: T[] = []): T[] {\n if (val) {\n return [...memo, val]\n }\n return undefined\n },\n\n mergeJson(option: string): (str: string, memo?: object) => object {\n return function (str: string, memo: object = {}) {\n let val: object\n try {\n val = JSON.parse(str)\n } catch (error) {\n const e: Error = error\n throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`)\n }\n if (typeof val !== 'object' || Array.isArray(val)) {\n throw new Error(`${option} must be passed JSON of an object: ${str}`)\n }\n return merge(memo, val)\n }\n },\n\n mergeTags(value: string, memo?: string): string {\n return memo ? `${memo} and (${value})` : `(${value})`\n },\n\n validateCountOption(value: string, optionName: string): number {\n const numericValue = parseInt(value)\n if (isNaN(numericValue) || numericValue < 0) {\n throw new Error(`${optionName} must be a non negative integer`)\n }\n return numericValue\n },\n\n validateLanguage(value: string): string {\n if (!Object.keys(dialects).includes(value)) {\n throw new Error(`Unsupported ISO 639-1: ${value}`)\n }\n return value\n },\n\n parse(argv: string[]): IParsedArgv {\n const program = new Command(path.basename(argv[1]))\n\n program\n .storeOptionsAsProperties(false)\n .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')\n .version(version, '-v, --version')\n .option('-b, --backtrace', 'show full backtrace for errors')\n .option('-c, --config <PATH>', 'specify configuration file')\n .option('-d, --dry-run', 'invoke formatters without executing steps')\n .option(\n '--exit, --force-exit',\n 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit'\n )\n .option('--fail-fast', 'abort the run on first failure')\n .option(\n '-f, --format <TYPE[:PATH]>',\n 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\\n' +\n Formatters.buildFormattersDocumentationString(),\n ArgvParser.collect\n )\n .option(\n '--format-options <JSON>',\n 'provide options for formatters (repeatable)',\n ArgvParser.mergeJson('--format-options')\n )\n .option(\n '--i18n-keywords <ISO 639-1>',\n 'list language keywords',\n ArgvParser.validateLanguage\n )\n .option('--i18n-languages', 'list languages')\n .option(\n '-i, --import <GLOB|DIR|FILE>',\n 'import files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--language <ISO 639-1>',\n 'provide the default language for feature files'\n )\n .option(\n '--name <REGEXP>',\n 'only execute the scenarios with name matching the expression (repeatable)',\n ArgvParser.collect\n )\n\n .option(\n '--order <TYPE[:SEED]>',\n 'run scenarios in the specified order. Type should be `defined` or `random`'\n )\n .option(\n '-p, --profile <NAME>',\n 'specify the profile to use (repeatable)',\n ArgvParser.collect,\n []\n )\n .option(\n '--parallel <NUMBER_OF_WORKERS>',\n 'run in parallel with the given number of workers',\n (val) => ArgvParser.validateCountOption(val, '--parallel')\n )\n .option('--publish', 'Publish a report to https://reports.cucumber.io')\n .option(\n '--publish-quiet',\n \"Don't print information banner about publishing reports\"\n )\n .option(\n '-r, --require <GLOB|DIR|FILE>',\n 'require files before executing features (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--require-module <NODE_MODULE>',\n 'require node modules before requiring files (repeatable)',\n ArgvParser.collect\n )\n .option(\n '--retry <NUMBER_OF_RETRIES>',\n 'specify the number of times to retry failing test cases (default: 0)',\n (val) => ArgvParser.validateCountOption(val, '--retry')\n )\n .option(\n '--retry-tag-filter <EXPRESSION>',\n `only retries the features or scenarios with tags matching the expression (repeatable).\n This option requires '--retry' to be specified.`,\n ArgvParser.mergeTags\n )\n .option('--strict', 'fail if there are pending steps')\n .option('--no-strict', 'succeed even if there are pending steps')\n .option(\n '-t, --tags <EXPRESSION>',\n 'only execute the features or scenarios with tags matching the expression (repeatable)',\n ArgvParser.mergeTags\n )\n .option(\n '--world-parameters <JSON>',\n 'provide parameters that will be passed to the world constructor (repeatable)',\n ArgvParser.mergeJson('--world-parameters')\n )\n\n program.addHelpText(\n 'afterAll',\n 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md'\n )\n\n program.parse(argv)\n const {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n ...regularStuff\n }: IRawArgvOptions = program.opts()\n const configuration: Partial<IConfiguration> = regularStuff\n if (program.args.length > 0) {\n configuration.paths = program.args\n }\n\n return {\n options: {\n config,\n i18nKeywords,\n i18nLanguages,\n profile,\n },\n configuration,\n }\n },\n}\n\nexport default ArgvParser\n"]}
@@ -0,0 +1,2 @@
1
+ import { IConfiguration } from './types';
2
+ export declare function checkSchema(configuration: any): Partial<IConfiguration>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.checkSchema = void 0;
23
+ const yup = __importStar(require("yup"));
24
+ const gherkin_1 = require("@cucumber/gherkin");
25
+ const schema = yup.object().shape({
26
+ backtrace: yup.boolean(),
27
+ dryRun: yup.boolean(),
28
+ exit: yup.boolean(),
29
+ failFast: yup.boolean(),
30
+ format: yup.array().of(yup.string()),
31
+ formatOptions: yup.object(),
32
+ import: yup.array().of(yup.string()),
33
+ language: yup.string().oneOf(Object.keys(gherkin_1.dialects)),
34
+ name: yup.array().of(yup.string()),
35
+ order: yup.string().oneOf(['defined', 'random']),
36
+ paths: yup.array().of(yup.string()),
37
+ parallel: yup.number().integer().min(0),
38
+ publish: yup.boolean(),
39
+ publishQuiet: yup.boolean(),
40
+ require: yup.array().of(yup.string()),
41
+ requireModule: yup.array().of(yup.string()),
42
+ retry: yup.number().integer().min(0),
43
+ retryTagFilter: yup.string(),
44
+ strict: yup.boolean(),
45
+ tags: yup.string(),
46
+ worldParameters: yup.object(),
47
+ });
48
+ function checkSchema(configuration) {
49
+ return schema.validateSync(configuration, {
50
+ abortEarly: false,
51
+ strict: true,
52
+ stripUnknown: true,
53
+ });
54
+ }
55
+ exports.checkSchema = checkSchema;
56
+ //# sourceMappingURL=check_schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check_schema.js","sourceRoot":"","sources":["../../src/configuration/check_schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA0B;AAC1B,+CAA4C;AAG5C,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC;IAChC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE;IACxB,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE;IACrB,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE;IACnB,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE;IACvB,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACpC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE;IAC3B,MAAM,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACpC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAQ,CAAC,CAAC;IACnD,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IAClC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChD,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACnC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvC,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE;IACtB,YAAY,EAAE,GAAG,CAAC,OAAO,EAAE;IAC3B,OAAO,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IACrC,aAAa,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;IAC3C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;IAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE;IACrB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE;IAClB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;CAC9B,CAAC,CAAA;AAEF,SAAgB,WAAW,CAAC,aAAkB;IAC5C,OAAO,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE;QACxC,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;KACnB,CAA4B,CAAA;AAC/B,CAAC;AAND,kCAMC","sourcesContent":["import * as yup from 'yup'\nimport { dialects } from '@cucumber/gherkin'\nimport { IConfiguration } from './types'\n\nconst schema = yup.object().shape({\n backtrace: yup.boolean(),\n dryRun: yup.boolean(),\n exit: yup.boolean(),\n failFast: yup.boolean(),\n format: yup.array().of(yup.string()),\n formatOptions: yup.object(),\n import: yup.array().of(yup.string()),\n language: yup.string().oneOf(Object.keys(dialects)),\n name: yup.array().of(yup.string()),\n order: yup.string().oneOf(['defined', 'random']),\n paths: yup.array().of(yup.string()),\n parallel: yup.number().integer().min(0),\n publish: yup.boolean(),\n publishQuiet: yup.boolean(),\n require: yup.array().of(yup.string()),\n requireModule: yup.array().of(yup.string()),\n retry: yup.number().integer().min(0),\n retryTagFilter: yup.string(),\n strict: yup.boolean(),\n tags: yup.string(),\n worldParameters: yup.object(),\n})\n\nexport function checkSchema(configuration: any): Partial<IConfiguration> {\n return schema.validateSync(configuration, {\n abortEarly: false,\n strict: true,\n stripUnknown: true,\n }) as Partial<IConfiguration>\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { IConfiguration } from './types';
2
+ export declare const DEFAULT_CONFIGURATION: IConfiguration;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_CONFIGURATION = void 0;
4
+ exports.DEFAULT_CONFIGURATION = {
5
+ backtrace: false,
6
+ dryRun: false,
7
+ forceExit: false,
8
+ failFast: false,
9
+ format: [],
10
+ formatOptions: {},
11
+ import: [],
12
+ language: 'en',
13
+ name: [],
14
+ order: 'defined',
15
+ paths: [],
16
+ parallel: 0,
17
+ publish: false,
18
+ publishQuiet: false,
19
+ require: [],
20
+ requireModule: [],
21
+ retry: 0,
22
+ retryTagFilter: '',
23
+ strict: true,
24
+ tags: '',
25
+ worldParameters: {},
26
+ };
27
+ //# sourceMappingURL=default_configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default_configuration.js","sourceRoot":"","sources":["../../src/configuration/default_configuration.ts"],"names":[],"mappings":";;;AAEa,QAAA,qBAAqB,GAAmB;IACnD,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,KAAK;IAChB,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;IACjB,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,IAAI;IACd,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,KAAK;IACnB,OAAO,EAAE,EAAE;IACX,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE,CAAC;IACR,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,EAAE;IACR,eAAe,EAAE,EAAE;CACpB,CAAA","sourcesContent":["import { IConfiguration } from './types'\n\nexport const DEFAULT_CONFIGURATION: IConfiguration = {\n backtrace: false,\n dryRun: false,\n forceExit: false,\n failFast: false,\n format: [],\n formatOptions: {},\n import: [],\n language: 'en',\n name: [],\n order: 'defined',\n paths: [],\n parallel: 0,\n publish: false,\n publishQuiet: false,\n require: [],\n requireModule: [],\n retry: 0,\n retryTagFilter: '',\n strict: true,\n tags: '',\n worldParameters: {},\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { IConfiguration } from './types';
2
+ export declare function fromFile(cwd: string, file: string, profiles?: string[]): Promise<Partial<IConfiguration>>;
@@ -0,0 +1,68 @@
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.fromFile = void 0;
7
+ const string_argv_1 = __importDefault(require("string-argv"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const url_1 = require("url");
10
+ const merge_configurations_1 = require("./merge_configurations");
11
+ const argv_parser_1 = __importDefault(require("./argv_parser"));
12
+ const check_schema_1 = require("./check_schema");
13
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
+ const { importer } = require('../importer');
15
+ async function fromFile(cwd, file, profiles = []) {
16
+ const definitions = await loadFile(cwd, file);
17
+ if (!definitions.default) {
18
+ definitions.default = {};
19
+ }
20
+ if (profiles.length < 1) {
21
+ profiles = ['default'];
22
+ }
23
+ const definedKeys = Object.keys(definitions);
24
+ profiles.forEach((profileKey) => {
25
+ if (!definedKeys.includes(profileKey)) {
26
+ throw new Error(`Requested profile "${profileKey}" doesn't exist`);
27
+ }
28
+ });
29
+ return (0, merge_configurations_1.mergeConfigurations)({}, ...profiles.map((profileKey) => extractConfiguration(profileKey, definitions[profileKey])));
30
+ }
31
+ exports.fromFile = fromFile;
32
+ async function loadFile(cwd, file) {
33
+ const filePath = path_1.default.join(cwd, file);
34
+ let definitions;
35
+ try {
36
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
37
+ definitions = require(filePath);
38
+ }
39
+ catch (error) {
40
+ if (error.code === 'ERR_REQUIRE_ESM') {
41
+ definitions = await importer((0, url_1.pathToFileURL)(filePath));
42
+ }
43
+ else {
44
+ throw error;
45
+ }
46
+ }
47
+ if (typeof definitions !== 'object') {
48
+ throw new Error(`Configuration file ${filePath} does not export an object`);
49
+ }
50
+ return definitions;
51
+ }
52
+ function extractConfiguration(name, definition) {
53
+ if (typeof definition === 'string') {
54
+ const { configuration } = argv_parser_1.default.parse([
55
+ 'node',
56
+ 'cucumber-js',
57
+ ...(0, string_argv_1.default)(definition),
58
+ ]);
59
+ return configuration;
60
+ }
61
+ try {
62
+ return (0, check_schema_1.checkSchema)(definition);
63
+ }
64
+ catch (error) {
65
+ throw new Error(`Requested profile "${name}" failed schema validation: ${error.errors.join(' ')}`);
66
+ }
67
+ }
68
+ //# sourceMappingURL=from_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAoC;AACpC,gDAAuB;AACvB,6BAAmC;AAEnC,iEAA4D;AAC5D,gEAAsC;AACtC,iDAA4C;AAE5C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAEpC,KAAK,UAAU,QAAQ,CAC5B,GAAW,EACX,IAAY,EACZ,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AAE;QACnC,MAAM,IAAI,KAAK,CAAC,sBAAsB,QAAQ,4BAA4B,CAAC,CAAA;KAC5E;IACD,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,SAAS,oBAAoB,CAC3B,IAAY,EACZ,UAAe;IAEf,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;QAClC,MAAM,EAAE,aAAa,EAAE,GAAG,qBAAU,CAAC,KAAK,CAAC;YACzC,MAAM;YACN,aAAa;YACb,GAAG,IAAA,qBAAU,EAAC,UAAU,CAAC;SAC1B,CAAC,CAAA;QACF,OAAO,aAAa,CAAA;KACrB;IACD,IAAI;QACF,OAAO,IAAA,0BAAW,EAAC,UAAU,CAAC,CAAA;KAC/B;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,+BAA+B,KAAK,CAAC,MAAM,CAAC,IAAI,CACxE,GAAG,CACJ,EAAE,CACJ,CAAA;KACF;AACH,CAAC","sourcesContent":["import stringArgv from 'string-argv'\nimport path from 'path'\nimport { pathToFileURL } from 'url'\nimport { IConfiguration } from './types'\nimport { mergeConfigurations } from './merge_configurations'\nimport ArgvParser from './argv_parser'\nimport { checkSchema } from './check_schema'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\nexport async function fromFile(\n cwd: string,\n file: string,\n profiles: string[] = []\n): Promise<Partial<IConfiguration>> {\n const definitions = await loadFile(cwd, file)\n if (!definitions.default) {\n definitions.default = {}\n }\n if (profiles.length < 1) {\n profiles = ['default']\n }\n const definedKeys = Object.keys(definitions)\n profiles.forEach((profileKey) => {\n if (!definedKeys.includes(profileKey)) {\n throw new Error(`Requested profile \"${profileKey}\" doesn't exist`)\n }\n })\n return mergeConfigurations(\n {},\n ...profiles.map((profileKey) =>\n extractConfiguration(profileKey, definitions[profileKey])\n )\n )\n}\n\nasync function loadFile(\n cwd: string,\n file: string\n): Promise<Record<string, any>> {\n const filePath: string = path.join(cwd, file)\n let definitions\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n definitions = require(filePath)\n } catch (error) {\n if (error.code === 'ERR_REQUIRE_ESM') {\n definitions = await importer(pathToFileURL(filePath))\n } else {\n throw error\n }\n }\n if (typeof definitions !== 'object') {\n throw new Error(`Configuration file ${filePath} does not export an object`)\n }\n return definitions\n}\n\nfunction extractConfiguration(\n name: string,\n definition: any\n): Partial<IConfiguration> {\n if (typeof definition === 'string') {\n const { configuration } = ArgvParser.parse([\n 'node',\n 'cucumber-js',\n ...stringArgv(definition),\n ])\n return configuration\n }\n try {\n return checkSchema(definition)\n } catch (error) {\n throw new Error(\n `Requested profile \"${name}\" failed schema validation: ${error.errors.join(\n ' '\n )}`\n )\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function isTruthyString(s: string | undefined): boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTruthyString = void 0;
4
+ function isTruthyString(s) {
5
+ if (s === undefined) {
6
+ return false;
7
+ }
8
+ return s.match(/^(false|no|0)$/i) === null;
9
+ }
10
+ exports.isTruthyString = isTruthyString;
11
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/configuration/helpers.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,CAAqB;IAClD,IAAI,CAAC,KAAK,SAAS,EAAE;QACnB,OAAO,KAAK,CAAA;KACb;IACD,OAAO,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAA;AAC5C,CAAC;AALD,wCAKC","sourcesContent":["export function isTruthyString(s: string | undefined): boolean {\n if (s === undefined) {\n return false\n }\n return s.match(/^(false|no|0)$/i) === null\n}\n"]}
@@ -1 +1,7 @@
1
+ export { default as ArgvParser } from './argv_parser';
2
+ export * from './default_configuration';
3
+ export * from './from_file';
4
+ export * from './helpers';
5
+ export * from './merge_configurations';
6
+ export * from './option_splitter';
1
7
  export * from './types';
@@ -9,6 +9,17 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
12
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ArgvParser = void 0;
17
+ var argv_parser_1 = require("./argv_parser");
18
+ Object.defineProperty(exports, "ArgvParser", { enumerable: true, get: function () { return __importDefault(argv_parser_1).default; } });
19
+ __exportStar(require("./default_configuration"), exports);
20
+ __exportStar(require("./from_file"), exports);
21
+ __exportStar(require("./helpers"), exports);
22
+ __exportStar(require("./merge_configurations"), exports);
23
+ __exportStar(require("./option_splitter"), exports);
13
24
  __exportStar(require("./types"), exports);
14
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAuB","sourcesContent":["export * from './types'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/configuration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAAqD;AAA5C,0HAAA,OAAO,OAAc;AAC9B,0DAAuC;AACvC,8CAA2B;AAC3B,4CAAyB;AACzB,yDAAsC;AACtC,oDAAiC;AACjC,0CAAuB","sourcesContent":["export { default as ArgvParser } from './argv_parser'\nexport * from './default_configuration'\nexport * from './from_file'\nexport * from './helpers'\nexport * from './merge_configurations'\nexport * from './option_splitter'\nexport * from './types'\n"]}
@@ -0,0 +1 @@
1
+ export declare function locateFile(cwd: string): string | undefined;
@@ -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.locateFile = void 0;
7
+ const fs_1 = __importDefault(require("mz/fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const DEFAULT_FILENAMES = [
10
+ 'cucumber.js',
11
+ 'cucumber.cjs',
12
+ 'cucumber.mjs',
13
+ 'cucumber.json',
14
+ ];
15
+ function locateFile(cwd) {
16
+ return DEFAULT_FILENAMES.find((filename) => fs_1.default.existsSync(path_1.default.join(cwd, filename)));
17
+ }
18
+ exports.locateFile = locateFile;
19
+ //# sourceMappingURL=locate_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate_file.js","sourceRoot":"","sources":["../../src/configuration/locate_file.ts"],"names":[],"mappings":";;;;;;AAAA,+CAAsB;AACtB,gDAAuB;AAEvB,MAAM,iBAAiB,GAAG;IACxB,aAAa;IACb,cAAc;IACd,cAAc;IACd,eAAe;CAChB,CAAA;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzC,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CACxC,CAAA;AACH,CAAC;AAJD,gCAIC","sourcesContent":["import fs from 'mz/fs'\nimport path from 'path'\n\nconst DEFAULT_FILENAMES = [\n 'cucumber.js',\n 'cucumber.cjs',\n 'cucumber.mjs',\n 'cucumber.json',\n]\n\nexport function locateFile(cwd: string): string | undefined {\n return DEFAULT_FILENAMES.find((filename) =>\n fs.existsSync(path.join(cwd, filename))\n )\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { IConfiguration } from './types';
2
+ export declare function mergeConfigurations<T = Partial<IConfiguration>>(source: T, ...configurations: Partial<IConfiguration>[]): T;
@@ -0,0 +1,48 @@
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.mergeConfigurations = void 0;
7
+ const lodash_mergewith_1 = __importDefault(require("lodash.mergewith"));
8
+ const ADDITIVE_ARRAYS = [
9
+ 'format',
10
+ 'import',
11
+ 'name',
12
+ 'paths',
13
+ 'require',
14
+ 'requireModule',
15
+ ];
16
+ const TAG_EXPRESSIONS = ['tags', 'retryTagFilter'];
17
+ function mergeArrays(objValue, srcValue) {
18
+ if (objValue && srcValue) {
19
+ return [].concat(objValue, srcValue);
20
+ }
21
+ return undefined;
22
+ }
23
+ function mergeTagExpressions(objValue, srcValue) {
24
+ if (objValue && srcValue) {
25
+ return `${wrapTagExpression(objValue)} and ${wrapTagExpression(srcValue)}`;
26
+ }
27
+ return undefined;
28
+ }
29
+ function wrapTagExpression(raw) {
30
+ if (raw.startsWith('(') && raw.endsWith(')')) {
31
+ return raw;
32
+ }
33
+ return `(${raw})`;
34
+ }
35
+ function customizer(objValue, srcValue, key) {
36
+ if (ADDITIVE_ARRAYS.includes(key)) {
37
+ return mergeArrays(objValue, srcValue);
38
+ }
39
+ if (TAG_EXPRESSIONS.includes(key)) {
40
+ return mergeTagExpressions(objValue, srcValue);
41
+ }
42
+ return undefined;
43
+ }
44
+ function mergeConfigurations(source, ...configurations) {
45
+ return (0, lodash_mergewith_1.default)({}, source, ...configurations, customizer);
46
+ }
47
+ exports.mergeConfigurations = mergeConfigurations;
48
+ //# sourceMappingURL=merge_configurations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"merge_configurations.js","sourceRoot":"","sources":["../../src/configuration/merge_configurations.ts"],"names":[],"mappings":";;;;;;AACA,wEAAwC;AAExC,MAAM,eAAe,GAAG;IACtB,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,eAAe;CAChB,CAAA;AACD,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAElD,SAAS,WAAW,CAAC,QAAe,EAAE,QAAe;IACnD,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KACrC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAgB,EAAE,QAAgB;IAC7D,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,GAAG,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAA;KAC3E;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC5C,OAAO,GAAG,CAAA;KACX;IACD,OAAO,IAAI,GAAG,GAAG,CAAA;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,QAAa,EAAE,QAAa,EAAE,GAAW;IAC3D,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,OAAO,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KACvC;IACD,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACjC,OAAO,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;KAC/C;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAgB,mBAAmB,CACjC,MAAS,EACT,GAAG,cAAyC;IAE5C,OAAO,IAAA,0BAAS,EAAC,EAAE,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,UAAU,CAAC,CAAA;AAC7D,CAAC;AALD,kDAKC","sourcesContent":["import { IConfiguration } from './types'\nimport mergeWith from 'lodash.mergewith'\n\nconst ADDITIVE_ARRAYS = [\n 'format',\n 'import',\n 'name',\n 'paths',\n 'require',\n 'requireModule',\n]\nconst TAG_EXPRESSIONS = ['tags', 'retryTagFilter']\n\nfunction mergeArrays(objValue: any[], srcValue: any[]) {\n if (objValue && srcValue) {\n return [].concat(objValue, srcValue)\n }\n return undefined\n}\n\nfunction mergeTagExpressions(objValue: string, srcValue: string) {\n if (objValue && srcValue) {\n return `${wrapTagExpression(objValue)} and ${wrapTagExpression(srcValue)}`\n }\n return undefined\n}\n\nfunction wrapTagExpression(raw: string) {\n if (raw.startsWith('(') && raw.endsWith(')')) {\n return raw\n }\n return `(${raw})`\n}\n\nfunction customizer(objValue: any, srcValue: any, key: string): any {\n if (ADDITIVE_ARRAYS.includes(key)) {\n return mergeArrays(objValue, srcValue)\n }\n if (TAG_EXPRESSIONS.includes(key)) {\n return mergeTagExpressions(objValue, srcValue)\n }\n return undefined\n}\n\nexport function mergeConfigurations<T = Partial<IConfiguration>>(\n source: T,\n ...configurations: Partial<IConfiguration>[]\n): T {\n return mergeWith({}, source, ...configurations, customizer)\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const OptionSplitter: {
2
+ split(option: string): string[];
3
+ };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const OptionSplitter = {
3
+ exports.OptionSplitter = void 0;
4
+ exports.OptionSplitter = {
4
5
  split(option) {
5
6
  option = option.replace(/"/g, '');
6
7
  const parts = option.split(/([^A-Z]):(?!\\)/);
@@ -19,5 +20,4 @@ const OptionSplitter = {
19
20
  function partNeedsRecombined(i) {
20
21
  return i % 2 === 0;
21
22
  }
22
- exports.default = OptionSplitter;
23
23
  //# sourceMappingURL=option_splitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option_splitter.js","sourceRoot":"","sources":["../../src/configuration/option_splitter.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,KAAK,CAAC,MAAc;QAClB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAEjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QAE7C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAc,EAAE,IAAY,EAAE,CAAS,EAAE,EAAE;YACtE,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;gBAC1B,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;aAC1C;YAED,OAAO,IAAI,CAAA;QACb,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACvB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;SAChB;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF,CAAA;AAED,SAAS,mBAAmB,CAAC,CAAS;IACpC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;AACpB,CAAC","sourcesContent":["export const OptionSplitter = {\n split(option: string): string[] {\n option = option.replace(/\"/g, '')\n\n const parts = option.split(/([^A-Z]):(?!\\\\)/)\n\n const result = parts.reduce((memo: string[], part: string, i: number) => {\n if (partNeedsRecombined(i)) {\n memo.push(parts.slice(i, i + 2).join(''))\n }\n\n return memo\n }, [])\n\n if (result.length === 1) {\n result.push('')\n }\n\n return result\n },\n}\n\nfunction partNeedsRecombined(i: number): boolean {\n return i % 2 === 0\n}\n"]}
@@ -1,29 +1,25 @@
1
- import { IRuntimeOptions } from '../runtime';
2
- import { IParsedArgvFormatOptions } from '../cli/argv_parser';
3
- import { PickleOrder } from '../cli/helpers';
4
- export interface IRunConfiguration {
5
- sources: {
6
- defaultDialect?: string;
7
- paths?: string[];
8
- names?: string[];
9
- tagExpression?: string;
10
- order?: PickleOrder;
11
- };
12
- support: {
13
- transpileWith: string[];
14
- paths: string[];
15
- };
16
- runtime?: Partial<IRuntimeOptions> & {
17
- parallel?: number;
18
- };
19
- formats?: IFormatterConfiguration;
20
- }
21
- export interface IFormatterConfiguration {
22
- stdout?: string;
23
- files?: Record<string, string>;
24
- publish?: {
25
- url?: string;
26
- token?: string;
27
- } | false;
28
- options?: IParsedArgvFormatOptions;
1
+ import { FormatOptions } from '../formatter';
2
+ import { PickleOrder } from '../models/pickle_order';
3
+ export interface IConfiguration {
4
+ backtrace: boolean;
5
+ dryRun: boolean;
6
+ forceExit: boolean;
7
+ failFast: boolean;
8
+ format: string[];
9
+ formatOptions: FormatOptions;
10
+ import: string[];
11
+ language: string;
12
+ name: string[];
13
+ order: PickleOrder;
14
+ paths: string[];
15
+ parallel: number;
16
+ publish: boolean;
17
+ publishQuiet: boolean;
18
+ require: string[];
19
+ requireModule: string[];
20
+ retry: number;
21
+ retryTagFilter: string;
22
+ strict: boolean;
23
+ tags: string;
24
+ worldParameters: any;
29
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/configuration/types.ts"],"names":[],"mappings":"","sourcesContent":["import { IRuntimeOptions } from '../runtime'\nimport { IParsedArgvFormatOptions } from '../cli/argv_parser'\nimport { PickleOrder } from '../cli/helpers'\n\nexport interface IRunConfiguration {\n sources: {\n defaultDialect?: string\n paths?: string[]\n names?: string[]\n tagExpression?: string\n order?: PickleOrder\n }\n support: {\n transpileWith: string[]\n paths: string[]\n }\n runtime?: Partial<IRuntimeOptions> & { parallel?: number }\n formats?: IFormatterConfiguration\n}\n\nexport interface IFormatterConfiguration {\n stdout?: string\n files?: Record<string, string>\n publish?:\n | {\n url?: string\n token?: string\n }\n | false\n options?: IParsedArgvFormatOptions\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/configuration/types.ts"],"names":[],"mappings":"","sourcesContent":["import { FormatOptions } from '../formatter'\nimport { PickleOrder } from '../models/pickle_order'\n\nexport interface IConfiguration {\n backtrace: boolean\n dryRun: boolean\n forceExit: boolean\n failFast: boolean\n format: string[]\n formatOptions: FormatOptions\n import: string[]\n language: string\n name: string[]\n order: PickleOrder\n paths: string[]\n parallel: number\n publish: boolean\n publishQuiet: boolean\n require: string[]\n requireModule: string[]\n retry: number\n retryTagFilter: string\n strict: boolean\n tags: string\n worldParameters: any\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { IConfiguration } from './types';
2
+ export declare function validateConfiguration(configuration: IConfiguration): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateConfiguration = void 0;
4
+ function validateConfiguration(configuration) {
5
+ if (configuration.retryTagFilter && !configuration.retry) {
6
+ throw new Error('a positive `retry` count must be specified when setting `retryTagFilter`');
7
+ }
8
+ }
9
+ exports.validateConfiguration = validateConfiguration;
10
+ //# sourceMappingURL=validate_configuration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate_configuration.js","sourceRoot":"","sources":["../../src/configuration/validate_configuration.ts"],"names":[],"mappings":";;;AAEA,SAAgB,qBAAqB,CAAC,aAA6B;IACjE,IAAI,aAAa,CAAC,cAAc,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE;QACxD,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAA;KACF;AACH,CAAC;AAND,sDAMC","sourcesContent":["import { IConfiguration } from './types'\n\nexport function validateConfiguration(configuration: IConfiguration): void {\n if (configuration.retryTagFilter && !configuration.retry) {\n throw new Error(\n 'a positive `retry` count must be specified when setting `retryTagFilter`'\n )\n }\n}\n"]}
@@ -1,11 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import StepDefinitionSnippetBuilder from './step_definition_snippet_builder';
3
3
  import { ISupportCodeLibrary } from '../support_code_library_builder/types';
4
- import Formatter, { IFormatterCleanupFn, IFormatterLogFn } from '.';
4
+ import Formatter, { FormatOptions, IFormatterCleanupFn, IFormatterLogFn } from '.';
5
5
  import { EventEmitter } from 'events';
6
6
  import EventDataCollector from './helpers/event_data_collector';
7
7
  import { Writable as WritableStream } from 'stream';
8
- import { IParsedArgvFormatOptions } from '../cli/argv_parser';
9
8
  import { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax';
10
9
  interface IGetStepDefinitionSnippetBuilderOptions {
11
10
  cwd: string;
@@ -18,7 +17,7 @@ export interface IBuildOptions {
18
17
  eventBroadcaster: EventEmitter;
19
18
  eventDataCollector: EventDataCollector;
20
19
  log: IFormatterLogFn;
21
- parsedArgvOptions: IParsedArgvFormatOptions;
20
+ parsedArgvOptions: FormatOptions;
22
21
  stream: WritableStream;
23
22
  cleanup: IFormatterCleanupFn;
24
23
  supportCodeLibrary: ISupportCodeLibrary;
@@ -61,13 +61,20 @@ const FormatterBuilder = {
61
61
  }
62
62
  },
63
63
  resolveConstructor(ImportedCode) {
64
+ if ((0, value_checker_1.doesNotHaveValue)(ImportedCode)) {
65
+ return null;
66
+ }
64
67
  if (typeof ImportedCode === 'function') {
65
68
  return ImportedCode;
66
69
  }
67
- else if ((0, value_checker_1.doesHaveValue)(ImportedCode) &&
70
+ else if (typeof ImportedCode === 'object' &&
68
71
  typeof ImportedCode.default === 'function') {
69
72
  return ImportedCode.default;
70
73
  }
74
+ else if (typeof ImportedCode.default === 'object' &&
75
+ typeof ImportedCode.default.default === 'function') {
76
+ return ImportedCode.default.default;
77
+ }
71
78
  return null;
72
79
  },
73
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAG5E,oDAAkE;AAKlE,qFAAmF;AACnF,6BAAmC;AACnC,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAoB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GA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ACtC,aAAa,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;YAC3C,qBAAqB,EAAE,kBAAkB,CAAC,qBAAqB;SAChE,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAA4B,EAC5B,UAAkB,EAClB,GAAW;QAEX,IAAI,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;YAC1C,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAA,mBAAa,EAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAA;QAC9B,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;QAC9D,IAAI,IAAA,6BAAa,EAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,WAAW,CAAA;SACnB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,KAAK,UAAU,oCAAoC,CAClE,CAAA;SACF;IACH,CAAC;IAED,kBAAkB,CAAC,YAAiB;QAClC,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,IAAA,6BAAa,EAAC,YAAY,CAAC;YAC3B,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import getColorFns from './get_color_fns'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, { IFormatterCleanupFn, IFormatterLogFn } from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { IParsedArgvFormatOptions } from '../cli/argv_parser'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: IParsedArgvFormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(options.parsedArgvOptions.colorsEnabled)\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n let CustomClass = descriptor.startsWith(`.`)\n ? await importer(pathToFileURL(path.resolve(cwd, descriptor)))\n : await importer(descriptor)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n resolveConstructor(ImportedCode: any) {\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n doesHaveValue(ImportedCode) &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/formatter/builder.ts"],"names":[],"mappings":";;;;;AAAA,oEAAyC;AACzC,4HAAiG;AACjG,gDAAuB;AACvB,wGAA4E;AAO5E,oDAAkE;AAIlE,qFAAmF;AACnF,6BAAmC;AACnC,sEAA6C;AAC7C,8DAA8D;AAC9D,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;AAoB3C,MAAM,gBAAgB,GAAG;IACvB,KAAK,CAAC,KAAK,CAAC,IAAY,EAAE,OAAsB;QAC9C,MAAM,oBAAoB,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CACtE,IAAI,EACJ,OAAO,CAAC,GAAG,CACZ,CAAA;QACD,MAAM,QAAQ,GAAG,IAAA,uBAAW,EAAC,OAAO,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAA;QACrE,MAAM,cAAc,GAClB,MAAM,gBAAgB,CAAC,+BAA+B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C,UAAU,CAAC,GAAG,CAAC;YAC1C,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAA,mBAAa,EAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;YAC9D,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAA;QAC9B,WAAW,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;QAC9D,IAAI,IAAA,6BAAa,EAAC,WAAW,CAAC,EAAE;YAC9B,OAAO,WAAW,CAAA;SACnB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,KAAK,UAAU,oCAAoC,CAClE,CAAA;SACF;IACH,CAAC;IAED,kBAAkB,CAAC,YAAiB;QAClC,IAAI,IAAA,gCAAgB,EAAC,YAAY,CAAC,EAAE;YAClC,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE;YACtC,OAAO,YAAY,CAAA;SACpB;aAAM,IACL,OAAO,YAAY,KAAK,QAAQ;YAChC,OAAO,YAAY,CAAC,OAAO,KAAK,UAAU,EAC1C;YACA,OAAO,YAAY,CAAC,OAAO,CAAA;SAC5B;aAAM,IACL,OAAO,YAAY,CAAC,OAAO,KAAK,QAAQ;YACxC,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,KAAK,UAAU,EAClD;YACA,OAAO,YAAY,CAAC,OAAO,CAAC,OAAO,CAAA;SACpC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAED,kBAAe,gBAAgB,CAAA","sourcesContent":["import getColorFns from './get_color_fns'\nimport JavascriptSnippetSyntax from './step_definition_snippet_builder/javascript_snippet_syntax'\nimport path from 'path'\nimport StepDefinitionSnippetBuilder from './step_definition_snippet_builder'\nimport { ISupportCodeLibrary } from '../support_code_library_builder/types'\nimport Formatter, {\n FormatOptions,\n IFormatterCleanupFn,\n IFormatterLogFn,\n} from '.'\nimport { doesHaveValue, doesNotHaveValue } from '../value_checker'\nimport { EventEmitter } from 'events'\nimport EventDataCollector from './helpers/event_data_collector'\nimport { Writable as WritableStream } from 'stream'\nimport { SnippetInterface } from './step_definition_snippet_builder/snippet_syntax'\nimport { pathToFileURL } from 'url'\nimport Formatters from './helpers/formatters'\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\ninterface IGetStepDefinitionSnippetBuilderOptions {\n cwd: string\n snippetInterface?: SnippetInterface\n snippetSyntax?: string\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nexport interface IBuildOptions {\n cwd: string\n eventBroadcaster: EventEmitter\n eventDataCollector: EventDataCollector\n log: IFormatterLogFn\n parsedArgvOptions: FormatOptions\n stream: WritableStream\n cleanup: IFormatterCleanupFn\n supportCodeLibrary: ISupportCodeLibrary\n}\n\nconst FormatterBuilder = {\n async build(type: string, options: IBuildOptions): Promise<Formatter> {\n const FormatterConstructor = await FormatterBuilder.getConstructorByType(\n type,\n options.cwd\n )\n const colorFns = getColorFns(options.parsedArgvOptions.colorsEnabled)\n const snippetBuilder =\n await FormatterBuilder.getStepDefinitionSnippetBuilder({\n cwd: options.cwd,\n snippetInterface: options.parsedArgvOptions.snippetInterface,\n snippetSyntax: options.parsedArgvOptions.snippetSyntax,\n supportCodeLibrary: options.supportCodeLibrary,\n })\n return new FormatterConstructor({\n colorFns,\n snippetBuilder,\n ...options,\n })\n },\n\n async getConstructorByType(\n type: string,\n cwd: string\n ): Promise<typeof Formatter> {\n const formatters: Record<string, typeof Formatter> =\n Formatters.getFormatters()\n\n return formatters[type]\n ? formatters[type]\n : await FormatterBuilder.loadCustomClass('formatter', type, cwd)\n },\n\n async getStepDefinitionSnippetBuilder({\n cwd,\n snippetInterface,\n snippetSyntax,\n supportCodeLibrary,\n }: IGetStepDefinitionSnippetBuilderOptions) {\n if (doesNotHaveValue(snippetInterface)) {\n snippetInterface = SnippetInterface.Synchronous\n }\n let Syntax = JavascriptSnippetSyntax\n if (doesHaveValue(snippetSyntax)) {\n Syntax = await FormatterBuilder.loadCustomClass(\n 'syntax',\n snippetSyntax,\n cwd\n )\n }\n return new StepDefinitionSnippetBuilder({\n snippetSyntax: new Syntax(snippetInterface),\n parameterTypeRegistry: supportCodeLibrary.parameterTypeRegistry,\n })\n },\n\n async loadCustomClass(\n type: 'formatter' | 'syntax',\n descriptor: string,\n cwd: string\n ) {\n let CustomClass = descriptor.startsWith(`.`)\n ? await importer(pathToFileURL(path.resolve(cwd, descriptor)))\n : await importer(descriptor)\n CustomClass = FormatterBuilder.resolveConstructor(CustomClass)\n if (doesHaveValue(CustomClass)) {\n return CustomClass\n } else {\n throw new Error(\n `Custom ${type} (${descriptor}) does not export a function/class`\n )\n }\n },\n\n resolveConstructor(ImportedCode: any) {\n if (doesNotHaveValue(ImportedCode)) {\n return null\n }\n if (typeof ImportedCode === 'function') {\n return ImportedCode\n } else if (\n typeof ImportedCode === 'object' &&\n typeof ImportedCode.default === 'function'\n ) {\n return ImportedCode.default\n } else if (\n typeof ImportedCode.default === 'object' &&\n typeof ImportedCode.default.default === 'function'\n ) {\n return ImportedCode.default.default\n }\n return null\n },\n}\n\nexport default FormatterBuilder\n"]}
@@ -3,33 +3,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const safe_1 = __importDefault(require("colors/safe"));
7
- safe_1.default.enable();
6
+ const chalk_1 = __importDefault(require("chalk"));
8
7
  function getColorFns(enabled) {
9
8
  if (enabled) {
10
9
  return {
11
10
  forStatus(status) {
12
11
  return {
13
- AMBIGUOUS: safe_1.default.red.bind(safe_1.default),
14
- FAILED: safe_1.default.red.bind(safe_1.default),
15
- PASSED: safe_1.default.green.bind(safe_1.default),
16
- PENDING: safe_1.default.yellow.bind(safe_1.default),
17
- SKIPPED: safe_1.default.cyan.bind(safe_1.default),
18
- UNDEFINED: safe_1.default.yellow.bind(safe_1.default),
19
- UNKNOWN: safe_1.default.yellow.bind(safe_1.default),
12
+ AMBIGUOUS: chalk_1.default.red.bind(chalk_1.default),
13
+ FAILED: chalk_1.default.red.bind(chalk_1.default),
14
+ PASSED: chalk_1.default.green.bind(chalk_1.default),
15
+ PENDING: chalk_1.default.yellow.bind(chalk_1.default),
16
+ SKIPPED: chalk_1.default.cyan.bind(chalk_1.default),
17
+ UNDEFINED: chalk_1.default.yellow.bind(chalk_1.default),
18
+ UNKNOWN: chalk_1.default.yellow.bind(chalk_1.default),
20
19
  }[status];
21
20
  },
22
- location: safe_1.default.gray.bind(safe_1.default),
23
- tag: safe_1.default.cyan.bind(safe_1.default),
24
- diffAdded: safe_1.default.green.bind(safe_1.default),
25
- diffRemoved: safe_1.default.red.bind(safe_1.default),
26
- errorMessage: safe_1.default.red.bind(safe_1.default),
27
- errorStack: safe_1.default.grey.bind(safe_1.default),
21
+ location: chalk_1.default.gray.bind(chalk_1.default),
22
+ tag: chalk_1.default.cyan.bind(chalk_1.default),
23
+ diffAdded: chalk_1.default.green.bind(chalk_1.default),
24
+ diffRemoved: chalk_1.default.red.bind(chalk_1.default),
25
+ errorMessage: chalk_1.default.red.bind(chalk_1.default),
26
+ errorStack: chalk_1.default.grey.bind(chalk_1.default),
28
27
  };
29
28
  }
30
29
  else {
31
30
  return {
32
- forStatus(status) {
31
+ forStatus(_status) {
33
32
  return (x) => x;
34
33
  },
35
34
  location: (x) => x,