@cucumber/cucumber 8.0.0-rc.1 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/README.md +83 -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 +65 -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/api/formatters.d.ts +16 -0
  10. package/lib/api/formatters.js +72 -0
  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/api/index.js +28 -0
  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/api/paths.js +99 -0
  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/api/runtime.d.ts +20 -0
  34. package/lib/api/runtime.js +36 -0
  35. package/lib/api/runtime.js.map +1 -0
  36. package/lib/api/support.d.ts +9 -0
  37. package/lib/api/support.js +21 -0
  38. package/lib/api/support.js.map +1 -0
  39. package/lib/api/types.d.ts +168 -0
  40. package/lib/api/types.js +3 -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 -10
  44. package/lib/cli/helpers.js +54 -38
  45. package/lib/cli/helpers.js.map +1 -1
  46. package/lib/cli/i18n.js +1 -1
  47. package/lib/cli/i18n.js.map +1 -1
  48. package/lib/cli/index.d.ts +6 -23
  49. package/lib/cli/index.js +38 -195
  50. package/lib/cli/index.js.map +1 -1
  51. package/lib/cli/install_validator.js +1 -1
  52. package/lib/cli/install_validator.js.map +1 -1
  53. package/lib/cli/publish_banner.js +6 -6
  54. package/lib/cli/publish_banner.js.map +1 -1
  55. package/lib/cli/run.js +15 -7
  56. package/lib/cli/run.js.map +1 -1
  57. package/lib/cli/validate_node_engine_version.d.ts +10 -0
  58. package/lib/cli/validate_node_engine_version.js +24 -0
  59. package/lib/cli/validate_node_engine_version.js.map +1 -0
  60. package/lib/configuration/argv_parser.d.ts +20 -0
  61. package/lib/{cli → configuration}/argv_parser.js +47 -44
  62. package/lib/configuration/argv_parser.js.map +1 -0
  63. package/lib/configuration/check_schema.d.ts +2 -0
  64. package/lib/configuration/check_schema.js +60 -0
  65. package/lib/configuration/check_schema.js.map +1 -0
  66. package/lib/configuration/default_configuration.d.ts +2 -0
  67. package/lib/configuration/default_configuration.js +27 -0
  68. package/lib/configuration/default_configuration.js.map +1 -0
  69. package/lib/configuration/from_file.d.ts +2 -0
  70. package/lib/configuration/from_file.js +68 -0
  71. package/lib/configuration/from_file.js.map +1 -0
  72. package/lib/configuration/helpers.d.ts +1 -0
  73. package/lib/configuration/helpers.js +11 -0
  74. package/lib/configuration/helpers.js.map +1 -0
  75. package/lib/configuration/index.d.ts +7 -0
  76. package/lib/configuration/index.js +29 -0
  77. package/lib/configuration/index.js.map +1 -0
  78. package/lib/configuration/locate_file.d.ts +1 -0
  79. package/lib/configuration/locate_file.js +19 -0
  80. package/lib/configuration/locate_file.js.map +1 -0
  81. package/lib/configuration/merge_configurations.d.ts +2 -0
  82. package/lib/configuration/merge_configurations.js +48 -0
  83. package/lib/configuration/merge_configurations.js.map +1 -0
  84. package/lib/configuration/option_splitter.d.ts +3 -0
  85. package/lib/{cli → configuration}/option_splitter.js +4 -3
  86. package/lib/configuration/option_splitter.js.map +1 -0
  87. package/lib/configuration/types.d.ts +25 -0
  88. package/lib/configuration/types.js +3 -0
  89. package/lib/configuration/types.js.map +1 -0
  90. package/lib/configuration/validate_configuration.d.ts +2 -0
  91. package/lib/configuration/validate_configuration.js +10 -0
  92. package/lib/configuration/validate_configuration.js.map +1 -0
  93. package/lib/formatter/builder.d.ts +3 -3
  94. package/lib/formatter/builder.js +34 -8
  95. package/lib/formatter/builder.js.map +1 -1
  96. package/lib/formatter/fixtures/typescript.d.ts +2 -0
  97. package/lib/formatter/fixtures/typescript.js +6 -0
  98. package/lib/formatter/fixtures/typescript.js.map +1 -0
  99. package/lib/formatter/get_color_fns.js +15 -16
  100. package/lib/formatter/get_color_fns.js.map +1 -1
  101. package/lib/formatter/helpers/event_data_collector.js +15 -11
  102. package/lib/formatter/helpers/event_data_collector.js.map +1 -1
  103. package/lib/formatter/helpers/gherkin_document_parser.js +6 -6
  104. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
  105. package/lib/formatter/helpers/index.js +5 -1
  106. package/lib/formatter/helpers/index.js.map +1 -1
  107. package/lib/formatter/helpers/issue_helpers.d.ts +2 -2
  108. package/lib/formatter/helpers/issue_helpers.js +4 -4
  109. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  110. package/lib/formatter/helpers/keyword_type.js +1 -1
  111. package/lib/formatter/helpers/keyword_type.js.map +1 -1
  112. package/lib/formatter/helpers/location_helpers.js +1 -1
  113. package/lib/formatter/helpers/location_helpers.js.map +1 -1
  114. package/lib/formatter/helpers/pickle_parser.js +1 -1
  115. package/lib/formatter/helpers/pickle_parser.js.map +1 -1
  116. package/lib/formatter/helpers/step_argument_formatter.js +1 -1
  117. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
  118. package/lib/formatter/helpers/summary_helpers.js +6 -2
  119. package/lib/formatter/helpers/summary_helpers.js.map +1 -1
  120. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +2 -2
  121. package/lib/formatter/helpers/test_case_attempt_formatter.js +24 -19
  122. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  123. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +1 -2
  124. package/lib/formatter/helpers/test_case_attempt_parser.js +19 -15
  125. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  126. package/lib/formatter/helpers/usage_helpers/index.d.ts +1 -2
  127. package/lib/formatter/helpers/usage_helpers/index.js +13 -9
  128. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  129. package/lib/formatter/html_formatter.js +4 -4
  130. package/lib/formatter/html_formatter.js.map +1 -1
  131. package/lib/formatter/http_stream.js +6 -6
  132. package/lib/formatter/http_stream.js.map +1 -1
  133. package/lib/formatter/index.d.ts +14 -2
  134. package/lib/formatter/index.js +2 -0
  135. package/lib/formatter/index.js.map +1 -1
  136. package/lib/formatter/json_formatter.js +18 -14
  137. package/lib/formatter/json_formatter.js.map +1 -1
  138. package/lib/formatter/progress_bar_formatter.js +16 -16
  139. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  140. package/lib/formatter/progress_formatter.js +7 -3
  141. package/lib/formatter/progress_formatter.js.map +1 -1
  142. package/lib/formatter/publish.d.ts +1 -0
  143. package/lib/formatter/publish.js +5 -0
  144. package/lib/formatter/publish.js.map +1 -0
  145. package/lib/formatter/rerun_formatter.js +10 -6
  146. package/lib/formatter/rerun_formatter.js.map +1 -1
  147. package/lib/formatter/snippets_formatter.js +7 -4
  148. package/lib/formatter/snippets_formatter.js.map +1 -1
  149. package/lib/formatter/step_definition_snippet_builder/index.js +2 -2
  150. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
  151. package/lib/formatter/summary_formatter.js +9 -9
  152. package/lib/formatter/summary_formatter.js.map +1 -1
  153. package/lib/formatter/usage_formatter.js +11 -8
  154. package/lib/formatter/usage_formatter.js.map +1 -1
  155. package/lib/formatter/usage_json_formatter.js +2 -3
  156. package/lib/formatter/usage_json_formatter.js.map +1 -1
  157. package/lib/index.d.ts +5 -0
  158. package/lib/index.js +13 -2
  159. package/lib/index.js.map +1 -1
  160. package/lib/models/pickle_order.d.ts +1 -0
  161. package/lib/models/pickle_order.js +3 -0
  162. package/lib/models/pickle_order.js.map +1 -0
  163. package/lib/models/step_definition.js +3 -3
  164. package/lib/models/step_definition.js.map +1 -1
  165. package/lib/pickle_filter.js +8 -8
  166. package/lib/pickle_filter.js.map +1 -1
  167. package/lib/runtime/assemble_test_cases.js +1 -1
  168. package/lib/runtime/assemble_test_cases.js.map +1 -1
  169. package/lib/runtime/attachment_manager/index.js +9 -5
  170. package/lib/runtime/attachment_manager/index.js.map +1 -1
  171. package/lib/runtime/helpers.js +11 -4
  172. package/lib/runtime/helpers.js.map +1 -1
  173. package/lib/runtime/index.d.ts +7 -5
  174. package/lib/runtime/index.js +8 -27
  175. package/lib/runtime/index.js.map +1 -1
  176. package/lib/runtime/parallel/command_types.d.ts +3 -2
  177. package/lib/runtime/parallel/command_types.js.map +1 -1
  178. package/lib/runtime/parallel/coordinator.d.ts +32 -11
  179. package/lib/runtime/parallel/coordinator.js +80 -28
  180. package/lib/runtime/parallel/coordinator.js.map +1 -1
  181. package/lib/runtime/parallel/run_worker.js +1 -1
  182. package/lib/runtime/parallel/run_worker.js.map +1 -1
  183. package/lib/runtime/parallel/worker.d.ts +2 -4
  184. package/lib/runtime/parallel/worker.js +14 -37
  185. package/lib/runtime/parallel/worker.js.map +1 -1
  186. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  187. package/lib/runtime/run_test_run_hooks.js +28 -0
  188. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  189. package/lib/runtime/step_runner.js +9 -5
  190. package/lib/runtime/step_runner.js.map +1 -1
  191. package/lib/runtime/stopwatch.js +9 -5
  192. package/lib/runtime/stopwatch.js.map +1 -1
  193. package/lib/runtime/test_case_runner.js +11 -7
  194. package/lib/runtime/test_case_runner.js.map +1 -1
  195. package/lib/stack_trace_filter.js +2 -2
  196. package/lib/stack_trace_filter.js.map +1 -1
  197. package/lib/step_arguments.js +2 -2
  198. package/lib/step_arguments.js.map +1 -1
  199. package/lib/support_code_library_builder/{build_helpers.d.ts → build_parameter_type.d.ts} +0 -2
  200. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  201. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  202. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  203. package/lib/support_code_library_builder/get_definition_line_and_uri.js +30 -0
  204. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  205. package/lib/support_code_library_builder/index.d.ts +4 -2
  206. package/lib/support_code_library_builder/index.js +43 -19
  207. package/lib/support_code_library_builder/index.js.map +1 -1
  208. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  209. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  210. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  211. package/lib/support_code_library_builder/types.d.ts +9 -0
  212. package/lib/support_code_library_builder/types.js.map +1 -1
  213. package/lib/time.js +5 -1
  214. package/lib/time.js.map +1 -1
  215. package/lib/user_code_runner.js +4 -4
  216. package/lib/user_code_runner.js.map +1 -1
  217. package/lib/version.d.ts +1 -0
  218. package/lib/version.js +6 -0
  219. package/lib/version.js.map +1 -0
  220. package/lib/wrapper.mjs +5 -1
  221. package/package.json +72 -49
  222. package/lib/cli/argv_parser.d.ts +0 -50
  223. package/lib/cli/argv_parser.js.map +0 -1
  224. package/lib/cli/configuration_builder.d.ts +0 -45
  225. package/lib/cli/configuration_builder.js +0 -159
  226. package/lib/cli/configuration_builder.js.map +0 -1
  227. package/lib/cli/option_splitter.d.ts +0 -4
  228. package/lib/cli/option_splitter.js.map +0 -1
  229. package/lib/cli/profile_loader.d.ts +0 -7
  230. package/lib/cli/profile_loader.js +0 -49
  231. package/lib/cli/profile_loader.js.map +0 -1
  232. package/lib/support_code_library_builder/build_helpers.js +0 -45
  233. package/lib/support_code_library_builder/build_helpers.js.map +0 -1
@@ -16,7 +16,7 @@ async function validateInstall(cwd) {
16
16
  const currentCucumberPath = require.resolve(projectPath);
17
17
  let localCucumberPath;
18
18
  try {
19
- localCucumberPath = await util_1.promisify(resolve_1.default)('@cucumber/cucumber', {
19
+ localCucumberPath = await (0, util_1.promisify)(resolve_1.default)('@cucumber/cucumber', {
20
20
  basedir: cwd,
21
21
  });
22
22
  }
@@ -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,gBAAS,CAA+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,+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"]}
@@ -3,22 +3,22 @@ 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"));
6
+ const chalk_1 = __importDefault(require("chalk"));
7
7
  const cli_table3_1 = __importDefault(require("cli-table3"));
8
- const underlineBoldCyan = (x) => safe_1.default.underline(safe_1.default.bold(safe_1.default.cyan(x)));
8
+ const underlineBoldCyan = (x) => chalk_1.default.underline(chalk_1.default.bold(chalk_1.default.cyan(x)));
9
9
  const formattedReportUrl = underlineBoldCyan('https://reports.cucumber.io');
10
- const formattedEnv = safe_1.default.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + safe_1.default.cyan('true');
10
+ const formattedEnv = chalk_1.default.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + chalk_1.default.cyan('true');
11
11
  const formattedMoreInfoUrl = underlineBoldCyan('https://cucumber.io/docs/cucumber/environment-variables/');
12
12
  const text = `\
13
13
  Share your Cucumber Report with your team at ${formattedReportUrl}
14
14
 
15
- Command line option: ${safe_1.default.cyan('--publish')}
15
+ Command line option: ${chalk_1.default.cyan('--publish')}
16
16
  Environment variable: ${formattedEnv}
17
17
 
18
18
  More information at ${formattedMoreInfoUrl}
19
19
 
20
- To disable this message, add this to your ${safe_1.default.bold('./cucumber.js')}:
21
- ${safe_1.default.bold("module.exports = { default: '--publish-quiet' }")}`;
20
+ To disable this message, add this to your ${chalk_1.default.bold('./cucumber.js')}:
21
+ ${chalk_1.default.bold("module.exports = { default: '--publish-quiet' }")}`;
22
22
  const table = new cli_table3_1.default({
23
23
  style: {
24
24
  head: [],
@@ -1 +1 @@
1
- {"version":3,"file":"publish_banner.js","sourceRoot":"","sources":["../../src/cli/publish_banner.ts"],"names":[],"mappings":";;;;;AAAA,uDAAgC;AAChC,4DAA8B;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAU,EAAE,CAC9C,cAAM,CAAC,SAAS,CAAC,cAAM,CAAC,IAAI,CAAC,cAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE/C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;AAC3E,MAAM,YAAY,GAChB,cAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,GAAG,GAAG,GAAG,cAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACrE,MAAM,oBAAoB,GAAG,iBAAiB,CAC5C,0DAA0D,CAC3D,CAAA;AAED,MAAM,IAAI,GAAG;+CACkC,kBAAkB;;0BAEvC,cAAM,CAAC,IAAI,CAAC,WAAW,CAAC;0BACxB,YAAY;;sBAEhB,oBAAoB;;4CAEE,cAAM,CAAC,IAAI,CAAC,eAAe,CAAC;EACtE,cAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,EAAE,CAAA;AAElE,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;IACtB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB;CACF,CAAC,CAAA;AAEF,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAElB,kBAAe,KAAK,CAAC,QAAQ,EAAE,CAAA","sourcesContent":["import colors from 'colors/safe'\nimport Table from 'cli-table3'\n\nconst underlineBoldCyan = (x: string): string =>\n colors.underline(colors.bold(colors.cyan(x)))\n\nconst formattedReportUrl = underlineBoldCyan('https://reports.cucumber.io')\nconst formattedEnv =\n colors.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + colors.cyan('true')\nconst formattedMoreInfoUrl = underlineBoldCyan(\n 'https://cucumber.io/docs/cucumber/environment-variables/'\n)\n\nconst text = `\\\nShare your Cucumber Report with your team at ${formattedReportUrl}\n\nCommand line option: ${colors.cyan('--publish')}\nEnvironment variable: ${formattedEnv}\n\nMore information at ${formattedMoreInfoUrl}\n\nTo disable this message, add this to your ${colors.bold('./cucumber.js')}: \n${colors.bold(\"module.exports = { default: '--publish-quiet' }\")}`\n\nconst table = new Table({\n style: {\n head: [],\n border: ['green'],\n },\n})\n\ntable.push([text])\n\nexport default table.toString()\n"]}
1
+ {"version":3,"file":"publish_banner.js","sourceRoot":"","sources":["../../src/cli/publish_banner.ts"],"names":[],"mappings":";;;;;AAAA,kDAAyB;AACzB,4DAA8B;AAE9B,MAAM,iBAAiB,GAAG,CAAC,CAAS,EAAU,EAAE,CAC9C,eAAK,CAAC,SAAS,CAAC,eAAK,CAAC,IAAI,CAAC,eAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE5C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,6BAA6B,CAAC,CAAA;AAC3E,MAAM,YAAY,GAChB,eAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,GAAG,GAAG,GAAG,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACnE,MAAM,oBAAoB,GAAG,iBAAiB,CAC5C,0DAA0D,CAC3D,CAAA;AAED,MAAM,IAAI,GAAG;+CACkC,kBAAkB;;0BAEvC,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC;0BACvB,YAAY;;sBAEhB,oBAAoB;;4CAEE,eAAK,CAAC,IAAI,CAAC,eAAe,CAAC;EACrE,eAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,EAAE,CAAA;AAEjE,MAAM,KAAK,GAAG,IAAI,oBAAK,CAAC;IACtB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,CAAC,OAAO,CAAC;KAClB;CACF,CAAC,CAAA;AAEF,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAElB,kBAAe,KAAK,CAAC,QAAQ,EAAE,CAAA","sourcesContent":["import chalk from 'chalk'\nimport Table from 'cli-table3'\n\nconst underlineBoldCyan = (x: string): string =>\n chalk.underline(chalk.bold(chalk.cyan(x)))\n\nconst formattedReportUrl = underlineBoldCyan('https://reports.cucumber.io')\nconst formattedEnv =\n chalk.cyan('CUCUMBER_PUBLISH_ENABLED') + '=' + chalk.cyan('true')\nconst formattedMoreInfoUrl = underlineBoldCyan(\n 'https://cucumber.io/docs/cucumber/environment-variables/'\n)\n\nconst text = `\\\nShare your Cucumber Report with your team at ${formattedReportUrl}\n\nCommand line option: ${chalk.cyan('--publish')}\nEnvironment variable: ${formattedEnv}\n\nMore information at ${formattedMoreInfoUrl}\n\nTo disable this message, add this to your ${chalk.bold('./cucumber.js')}: \n${chalk.bold(\"module.exports = { default: '--publish-quiet' }\")}`\n\nconst table = new Table({\n style: {\n head: [],\n border: ['green'],\n },\n})\n\ntable.push([text])\n\nexport default table.toString()\n"]}
package/lib/cli/run.js CHANGED
@@ -3,32 +3,40 @@ 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
+ /* eslint-disable no-console */
7
+ /* This is one rare place where we're fine to use process/console directly,
8
+ * but other code abstracts those to remain composable and testable. */
6
9
  const _1 = __importDefault(require("./"));
7
10
  const verror_1 = __importDefault(require("verror"));
8
11
  const publish_banner_1 = __importDefault(require("./publish_banner"));
9
- function exitWithError(error) {
10
- console.error(verror_1.default.fullStack(error)); // eslint-disable-line no-console
12
+ const validate_node_engine_version_1 = require("./validate_node_engine_version");
13
+ function logErrorMessageAndExit(message) {
14
+ console.error(message);
11
15
  process.exit(1);
12
16
  }
13
17
  function displayPublishAdvertisementBanner() {
14
18
  console.error(publish_banner_1.default);
15
19
  }
16
20
  async function run() {
17
- const cwd = process.cwd();
21
+ (0, validate_node_engine_version_1.validateNodeEngineVersion)(process.version, (error) => {
22
+ console.error(error);
23
+ process.exit(1);
24
+ }, console.warn);
18
25
  const cli = new _1.default({
19
26
  argv: process.argv,
20
- cwd,
27
+ cwd: process.cwd(),
21
28
  stdout: process.stdout,
29
+ stderr: process.stderr,
30
+ env: process.env,
22
31
  });
23
32
  let result;
24
33
  try {
25
34
  result = await cli.run();
26
35
  }
27
36
  catch (error) {
28
- exitWithError(error);
37
+ logErrorMessageAndExit(verror_1.default.fullStack(error));
29
38
  }
30
- const config = await cli.getConfiguration();
31
- if (!config.publishing && !config.suppressPublishAdvertisement) {
39
+ if (result.shouldAdvertisePublish) {
32
40
  displayPublishAdvertisementBanner();
33
41
  }
34
42
  const exitCode = result.success ? 0 : 1;
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,0CAAuC;AACvC,oDAA2B;AAC3B,sEAA4C;AAE5C,SAAS,aAAa,CAAC,KAAY;IACjC,OAAO,CAAC,KAAK,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA,CAAC,iCAAiC;IACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,SAAS,iCAAiC;IACxC,OAAO,CAAC,KAAK,CAAC,wBAAa,CAAC,CAAA;AAC9B,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IACzB,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG;QACH,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,aAAa,CAAC,KAAK,CAAC,CAAA;KACrB;IAED,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC3C,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,4BAA4B,EAAE;QAC9D,iCAAiC,EAAE,CAAA;KACpC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA1BD,sBA0BC","sourcesContent":["import Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport publishBanner from './publish_banner'\n\nfunction exitWithError(error: Error): void {\n console.error(VError.fullStack(error)) // eslint-disable-line no-console\n process.exit(1)\n}\n\nfunction displayPublishAdvertisementBanner(): void {\n console.error(publishBanner)\n}\n\nexport default async function run(): Promise<void> {\n const cwd = process.cwd()\n const cli = new Cli({\n argv: process.argv,\n cwd,\n stdout: process.stdout,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n exitWithError(error)\n }\n\n const config = await cli.getConfiguration()\n if (!config.publishing && !config.suppressPublishAdvertisement) {\n displayPublishAdvertisementBanner()\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/cli/run.ts"],"names":[],"mappings":";;;;;AAAA,+BAA+B;AAC/B;uEACuE;AACvE,0CAAuC;AACvC,oDAA2B;AAC3B,sEAA4C;AAC5C,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAED,SAAS,iCAAiC;IACxC,OAAO,CAAC,KAAK,CAAC,wBAAa,CAAC,CAAA;AAC9B,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,IAAI,MAAM,CAAC,sBAAsB,EAAE;QACjC,iCAAiC,EAAE,CAAA;KACpC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AAnCD,sBAmCC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport publishBanner from './publish_banner'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nfunction displayPublishAdvertisementBanner(): void {\n console.error(publishBanner)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n if (result.shouldAdvertisePublish) {\n displayPublishAdvertisementBanner()\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ declare type PackageJSON = {
2
+ engines: {
3
+ node: string;
4
+ };
5
+ enginesTested: {
6
+ node: string;
7
+ };
8
+ };
9
+ export declare function validateNodeEngineVersion(currentVersion: string, onError: (message: string) => void, onWarning: (message: string) => void, readPackageJSON?: () => PackageJSON): void;
10
+ export {};
@@ -0,0 +1,24 @@
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.validateNodeEngineVersion = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const semver_1 = __importDefault(require("semver"));
10
+ const readActualPackageJSON = () => JSON.parse(fs_1.default
11
+ .readFileSync(path_1.default.resolve(__dirname, '..', '..', 'package.json'))
12
+ .toString());
13
+ function validateNodeEngineVersion(currentVersion, onError, onWarning, readPackageJSON = readActualPackageJSON) {
14
+ const requiredVersions = readPackageJSON().engines.node;
15
+ const testedVersions = readPackageJSON().enginesTested.node;
16
+ if (!semver_1.default.satisfies(currentVersion, requiredVersions)) {
17
+ onError(`Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`);
18
+ }
19
+ else if (!semver_1.default.satisfies(currentVersion, testedVersions)) {
20
+ onWarning(`This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`);
21
+ }
22
+ }
23
+ exports.validateNodeEngineVersion = validateNodeEngineVersion;
24
+ //# sourceMappingURL=validate_node_engine_version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate_node_engine_version.js","sourceRoot":"","sources":["../../src/cli/validate_node_engine_version.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAO3B,MAAM,qBAAqB,GAAsB,GAAG,EAAE,CACpD,IAAI,CAAC,KAAK,CACR,YAAE;KACC,YAAY,CAAC,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;KACjE,QAAQ,EAAE,CACd,CAAA;AAEH,SAAgB,yBAAyB,CACvC,cAAsB,EACtB,OAAkC,EAClC,SAAoC,EACpC,kBAAqC,qBAAqB;IAE1D,MAAM,gBAAgB,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,IAAI,CAAA;IACvD,MAAM,cAAc,GAAG,eAAe,EAAE,CAAC,aAAa,CAAC,IAAI,CAAA;IAC3D,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,gBAAgB,CAAC,EAAE;QACvD,OAAO,CACL,6CAA6C,gBAAgB,6BAA6B,cAAc,EAAE,CAC3G,CAAA;KACF;SAAM,IAAI,CAAC,gBAAM,CAAC,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE;QAC5D,SAAS,CACP,yBAAyB,cAAc,yIAAyI,CACjL,CAAA;KACF;AACH,CAAC;AAjBD,8DAiBC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport semver from 'semver'\n\ntype PackageJSON = {\n engines: { node: string }\n enginesTested: { node: string }\n}\n\nconst readActualPackageJSON: () => PackageJSON = () =>\n JSON.parse(\n fs\n .readFileSync(path.resolve(__dirname, '..', '..', 'package.json'))\n .toString()\n )\n\nexport function validateNodeEngineVersion(\n currentVersion: string,\n onError: (message: string) => void,\n onWarning: (message: string) => void,\n readPackageJSON: () => PackageJSON = readActualPackageJSON\n): void {\n const requiredVersions = readPackageJSON().engines.node\n const testedVersions = readPackageJSON().enginesTested.node\n if (!semver.satisfies(currentVersion, requiredVersions)) {\n onError(\n `Cucumber can only run on Node.js versions ${requiredVersions}. This Node.js version is ${currentVersion}`\n )\n } else if (!semver.satisfies(currentVersion, testedVersions)) {\n onWarning(\n `This Node.js version (${currentVersion}) has not been tested with this version of Cucumber; it should work normally, but please raise an issue if you see anything unexpected.`\n )\n }\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { IConfiguration } from './types';
2
+ export interface IParsedArgvOptions {
3
+ config?: string;
4
+ i18nKeywords?: string;
5
+ i18nLanguages?: boolean;
6
+ profile: string[];
7
+ }
8
+ export interface IParsedArgv {
9
+ options: IParsedArgvOptions;
10
+ configuration: Partial<IConfiguration>;
11
+ }
12
+ declare const ArgvParser: {
13
+ collect<T>(val: T, memo?: T[]): T[];
14
+ mergeJson(option: string): (str: string, memo?: object) => object;
15
+ mergeTags(value: string, memo?: string): string;
16
+ validateCountOption(value: string, optionName: string): number;
17
+ validateLanguage(value: string): string;
18
+ parse(argv: string[]): IParsedArgv;
19
+ };
20
+ export default ArgvParser;
@@ -4,18 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const commander_1 = require("commander");
7
+ const lodash_merge_1 = __importDefault(require("lodash.merge"));
7
8
  const path_1 = __importDefault(require("path"));
8
9
  const gherkin_1 = require("@cucumber/gherkin");
9
10
  const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
10
- // Using require instead of import so compiled typescript will have the desired folder structure
11
- const { version } = require('../../package.json'); // eslint-disable-line @typescript-eslint/no-var-requires
11
+ const version_1 = require("../version");
12
12
  const ArgvParser = {
13
- collect(val, memo) {
14
- memo.push(val);
15
- return memo;
13
+ collect(val, memo = []) {
14
+ if (val) {
15
+ return [...memo, val];
16
+ }
17
+ return undefined;
16
18
  },
17
19
  mergeJson(option) {
18
- return function (str, memo) {
20
+ return function (str, memo = {}) {
19
21
  let val;
20
22
  try {
21
23
  val = JSON.parse(str);
@@ -27,11 +29,11 @@ const ArgvParser = {
27
29
  if (typeof val !== 'object' || Array.isArray(val)) {
28
30
  throw new Error(`${option} must be passed JSON of an object: ${str}`);
29
31
  }
30
- return { ...memo, ...val };
32
+ return (0, lodash_merge_1.default)(memo, val);
31
33
  };
32
34
  },
33
35
  mergeTags(value, memo) {
34
- return memo === '' ? `(${value})` : `${memo} and (${value})`;
36
+ return memo ? `${memo} and (${value})` : `(${value})`;
35
37
  },
36
38
  validateCountOption(value, optionName) {
37
39
  const numericValue = parseInt(value);
@@ -46,53 +48,54 @@ const ArgvParser = {
46
48
  }
47
49
  return value;
48
50
  },
49
- validateRetryOptions(options) {
50
- if (options.retryTagFilter !== '' && options.retry === 0) {
51
- throw new Error('a positive --retry count must be specified when setting --retry-tag-filter');
52
- }
53
- },
54
51
  parse(argv) {
55
52
  const program = new commander_1.Command(path_1.default.basename(argv[1]));
56
53
  program
57
54
  .storeOptionsAsProperties(false)
58
55
  .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')
59
- .version(version, '-v, --version')
56
+ .version(version_1.version, '-v, --version')
60
57
  .option('-b, --backtrace', 'show full backtrace for errors')
61
- .option('-c, --config <TYPE[:PATH]>', 'specify configuration file')
62
- .option('-d, --dry-run', 'invoke formatters without executing steps', false)
63
- .option('--exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit', false)
64
- .option('--fail-fast', 'abort the run on first failure', false)
58
+ .option('-c, --config <PATH>', 'specify configuration file')
59
+ .option('-d, --dry-run', 'invoke formatters without executing steps')
60
+ .option('--exit, --force-exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit')
61
+ .option('--fail-fast', 'abort the run on first failure')
65
62
  .option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
66
- formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect, [])
67
- .option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'), {})
68
- .option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage, '')
69
- .option('--i18n-languages', 'list languages', false)
70
- .option('--language <ISO 639-1>', 'provide the default language for feature files', 'en')
71
- .option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect, [])
72
- .option('--no-strict', 'succeed even if there are pending steps')
73
- .option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`', 'defined')
63
+ formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect)
64
+ .option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))
65
+ .option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)
66
+ .option('--i18n-languages', 'list languages')
67
+ .option('-i, --import <GLOB|DIR|FILE>', 'import files before executing features (repeatable)', ArgvParser.collect)
68
+ .option('--language <ISO 639-1>', 'provide the default language for feature files')
69
+ .option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect)
70
+ .option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')
74
71
  .option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
75
- .option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', (val) => ArgvParser.validateCountOption(val, '--parallel'), 0)
76
- .option('--publish', 'Publish a report to https://reports.cucumber.io', false)
77
- .option('--publish-quiet', "Don't print information banner about publishing reports", false)
78
- .option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect, [])
79
- .option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect, [])
80
- .option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', (val) => ArgvParser.validateCountOption(val, '--retry'), 0)
72
+ .option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', (val) => ArgvParser.validateCountOption(val, '--parallel'))
73
+ .option('--publish', 'Publish a report to https://reports.cucumber.io')
74
+ .option('--publish-quiet', "Don't print information banner about publishing reports")
75
+ .option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect)
76
+ .option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect)
77
+ .option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', (val) => ArgvParser.validateCountOption(val, '--retry'))
81
78
  .option('--retry-tag-filter <EXPRESSION>', `only retries the features or scenarios with tags matching the expression (repeatable).
82
- This option requires '--retry' to be specified.`, ArgvParser.mergeTags, '')
83
- .option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags, '')
84
- .option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'), {});
85
- program.on('--help', () => {
86
- /* eslint-disable no-console */
87
- console.log(' For more details please visit https://github.com/cucumber/cucumber-js/blob/master/docs/cli.md\n');
88
- /* eslint-enable no-console */
89
- });
79
+ This option requires '--retry' to be specified.`, ArgvParser.mergeTags)
80
+ .option('--strict', 'fail if there are pending steps')
81
+ .option('--no-strict', 'succeed even if there are pending steps')
82
+ .option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags)
83
+ .option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'));
84
+ program.addHelpText('afterAll', 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md');
90
85
  program.parse(argv);
91
- const options = program.opts();
92
- ArgvParser.validateRetryOptions(options);
86
+ const { config, i18nKeywords, i18nLanguages, profile, ...regularStuff } = program.opts();
87
+ const configuration = regularStuff;
88
+ if (program.args.length > 0) {
89
+ configuration.paths = program.args;
90
+ }
93
91
  return {
94
- options,
95
- args: program.args,
92
+ options: {
93
+ config,
94
+ i18nKeywords,
95
+ i18nLanguages,
96
+ profile,
97
+ },
98
+ configuration,
96
99
  };
97
100
  },
98
101
  };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts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AM,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,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.checkSchema = void 0;
27
+ const yup = __importStar(require("yup"));
28
+ const gherkin_1 = require("@cucumber/gherkin");
29
+ const schema = yup.object().shape({
30
+ backtrace: yup.boolean(),
31
+ dryRun: yup.boolean(),
32
+ exit: yup.boolean(),
33
+ failFast: yup.boolean(),
34
+ format: yup.array().of(yup.string()),
35
+ formatOptions: yup.object(),
36
+ import: yup.array().of(yup.string()),
37
+ language: yup.string().oneOf(Object.keys(gherkin_1.dialects)),
38
+ name: yup.array().of(yup.string()),
39
+ order: yup.string().oneOf(['defined', 'random']),
40
+ paths: yup.array().of(yup.string()),
41
+ parallel: yup.number().integer().min(0),
42
+ publish: yup.boolean(),
43
+ publishQuiet: yup.boolean(),
44
+ require: yup.array().of(yup.string()),
45
+ requireModule: yup.array().of(yup.string()),
46
+ retry: yup.number().integer().min(0),
47
+ retryTagFilter: yup.string(),
48
+ strict: yup.boolean(),
49
+ tags: yup.string(),
50
+ worldParameters: yup.object(),
51
+ });
52
+ function checkSchema(configuration) {
53
+ return schema.validateSync(configuration, {
54
+ abortEarly: false,
55
+ strict: true,
56
+ stripUnknown: true,
57
+ });
58
+ }
59
+ exports.checkSchema = checkSchema;
60
+ //# 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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,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,WAAqB,EAAE;IAEvB,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC7C,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;QACxB,WAAW,CAAC,OAAO,GAAG,EAAE,CAAA;KACzB;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,QAAQ,GAAG,CAAC,SAAS,CAAC,CAAA;KACvB;IACD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAC5C,QAAQ,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,sBAAsB,UAAU,iBAAiB,CAAC,CAAA;SACnE;IACH,CAAC,CAAC,CAA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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"]}
@@ -0,0 +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';
7
+ export * from './types';
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ArgvParser = void 0;
21
+ var argv_parser_1 = require("./argv_parser");
22
+ Object.defineProperty(exports, "ArgvParser", { enumerable: true, get: function () { return __importDefault(argv_parser_1).default; } });
23
+ __exportStar(require("./default_configuration"), exports);
24
+ __exportStar(require("./from_file"), exports);
25
+ __exportStar(require("./helpers"), exports);
26
+ __exportStar(require("./merge_configurations"), exports);
27
+ __exportStar(require("./option_splitter"), exports);
28
+ __exportStar(require("./types"), exports);
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"]}