@dev-blinq/cucumber-js 1.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 (345) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +124 -0
  3. package/api/index.d.ts +6 -0
  4. package/bin/cucumber-js +3 -0
  5. package/bin/cucumber.js +3 -0
  6. package/lib/api/console_logger.d.ts +12 -0
  7. package/lib/api/console_logger.js +24 -0
  8. package/lib/api/console_logger.js.map +1 -0
  9. package/lib/api/convert_configuration.d.ts +4 -0
  10. package/lib/api/convert_configuration.js +65 -0
  11. package/lib/api/convert_configuration.js.map +1 -0
  12. package/lib/api/environment.d.ts +2 -0
  13. package/lib/api/environment.js +14 -0
  14. package/lib/api/environment.js.map +1 -0
  15. package/lib/api/formatters.d.ts +20 -0
  16. package/lib/api/formatters.js +61 -0
  17. package/lib/api/formatters.js.map +1 -0
  18. package/lib/api/gherkin.d.ts +21 -0
  19. package/lib/api/gherkin.js +65 -0
  20. package/lib/api/gherkin.js.map +1 -0
  21. package/lib/api/index.d.ts +12 -0
  22. package/lib/api/index.js +28 -0
  23. package/lib/api/index.js.map +1 -0
  24. package/lib/api/load_configuration.d.ts +9 -0
  25. package/lib/api/load_configuration.js +41 -0
  26. package/lib/api/load_configuration.js.map +1 -0
  27. package/lib/api/load_sources.d.ts +9 -0
  28. package/lib/api/load_sources.js +53 -0
  29. package/lib/api/load_sources.js.map +1 -0
  30. package/lib/api/load_support.d.ts +10 -0
  31. package/lib/api/load_support.js +30 -0
  32. package/lib/api/load_support.js.map +1 -0
  33. package/lib/api/paths.d.ts +8 -0
  34. package/lib/api/paths.js +102 -0
  35. package/lib/api/paths.js.map +1 -0
  36. package/lib/api/plugins.d.ts +4 -0
  37. package/lib/api/plugins.js +19 -0
  38. package/lib/api/plugins.js.map +1 -0
  39. package/lib/api/run_cucumber.d.ts +11 -0
  40. package/lib/api/run_cucumber.js +115 -0
  41. package/lib/api/run_cucumber.js.map +1 -0
  42. package/lib/api/runtime.d.ts +21 -0
  43. package/lib/api/runtime.js +36 -0
  44. package/lib/api/runtime.js.map +1 -0
  45. package/lib/api/support.d.ts +9 -0
  46. package/lib/api/support.js +26 -0
  47. package/lib/api/support.js.map +1 -0
  48. package/lib/api/test_helpers.d.ts +3 -0
  49. package/lib/api/test_helpers.js +36 -0
  50. package/lib/api/test_helpers.js.map +1 -0
  51. package/lib/api/types.d.ts +175 -0
  52. package/lib/api/types.js +3 -0
  53. package/lib/api/types.js.map +1 -0
  54. package/lib/api/wrapper.mjs +6 -0
  55. package/lib/cli/helpers.d.ts +37 -0
  56. package/lib/cli/helpers.js +203 -0
  57. package/lib/cli/helpers.js.map +1 -0
  58. package/lib/cli/i18n.d.ts +2 -0
  59. package/lib/cli/i18n.js +70 -0
  60. package/lib/cli/i18n.js.map +1 -0
  61. package/lib/cli/index.d.ts +21 -0
  62. package/lib/cli/index.js +59 -0
  63. package/lib/cli/index.js.map +1 -0
  64. package/lib/cli/install_validator.d.ts +1 -0
  65. package/lib/cli/install_validator.js +18 -0
  66. package/lib/cli/install_validator.js.map +1 -0
  67. package/lib/cli/run.d.ts +1 -0
  68. package/lib/cli/run.js +44 -0
  69. package/lib/cli/run.js.map +1 -0
  70. package/lib/cli/validate_node_engine_version.d.ts +10 -0
  71. package/lib/cli/validate_node_engine_version.js +24 -0
  72. package/lib/cli/validate_node_engine_version.js.map +1 -0
  73. package/lib/configuration/argv_parser.d.ts +20 -0
  74. package/lib/configuration/argv_parser.js +102 -0
  75. package/lib/configuration/argv_parser.js.map +1 -0
  76. package/lib/configuration/check_schema.d.ts +2 -0
  77. package/lib/configuration/check_schema.js +60 -0
  78. package/lib/configuration/check_schema.js.map +1 -0
  79. package/lib/configuration/default_configuration.d.ts +2 -0
  80. package/lib/configuration/default_configuration.js +27 -0
  81. package/lib/configuration/default_configuration.js.map +1 -0
  82. package/lib/configuration/from_file.d.ts +3 -0
  83. package/lib/configuration/from_file.js +85 -0
  84. package/lib/configuration/from_file.js.map +1 -0
  85. package/lib/configuration/helpers.d.ts +1 -0
  86. package/lib/configuration/helpers.js +11 -0
  87. package/lib/configuration/helpers.js.map +1 -0
  88. package/lib/configuration/index.d.ts +7 -0
  89. package/lib/configuration/index.js +29 -0
  90. package/lib/configuration/index.js.map +1 -0
  91. package/lib/configuration/locate_file.d.ts +1 -0
  92. package/lib/configuration/locate_file.js +21 -0
  93. package/lib/configuration/locate_file.js.map +1 -0
  94. package/lib/configuration/merge_configurations.d.ts +2 -0
  95. package/lib/configuration/merge_configurations.js +48 -0
  96. package/lib/configuration/merge_configurations.js.map +1 -0
  97. package/lib/configuration/option_splitter.d.ts +3 -0
  98. package/lib/configuration/option_splitter.js +23 -0
  99. package/lib/configuration/option_splitter.js.map +1 -0
  100. package/lib/configuration/types.d.ts +28 -0
  101. package/lib/configuration/types.js +3 -0
  102. package/lib/configuration/types.js.map +1 -0
  103. package/lib/configuration/validate_configuration.d.ts +3 -0
  104. package/lib/configuration/validate_configuration.js +13 -0
  105. package/lib/configuration/validate_configuration.js.map +1 -0
  106. package/lib/filter_stack_trace.d.ts +3 -0
  107. package/lib/filter_stack_trace.js +38 -0
  108. package/lib/filter_stack_trace.js.map +1 -0
  109. package/lib/formatter/builder.d.ts +37 -0
  110. package/lib/formatter/builder.js +101 -0
  111. package/lib/formatter/builder.js.map +1 -0
  112. package/lib/formatter/fixtures/typescript.d.ts +2 -0
  113. package/lib/formatter/fixtures/typescript.js +6 -0
  114. package/lib/formatter/fixtures/typescript.js.map +1 -0
  115. package/lib/formatter/get_color_fns.d.ts +15 -0
  116. package/lib/formatter/get_color_fns.js +56 -0
  117. package/lib/formatter/get_color_fns.js.map +1 -0
  118. package/lib/formatter/helpers/duration_helpers.d.ts +2 -0
  119. package/lib/formatter/helpers/duration_helpers.js +9 -0
  120. package/lib/formatter/helpers/duration_helpers.js.map +1 -0
  121. package/lib/formatter/helpers/event_data_collector.d.ts +30 -0
  122. package/lib/formatter/helpers/event_data_collector.js +126 -0
  123. package/lib/formatter/helpers/event_data_collector.js.map +1 -0
  124. package/lib/formatter/helpers/formatters.d.ts +6 -0
  125. package/lib/formatter/helpers/formatters.js +43 -0
  126. package/lib/formatter/helpers/formatters.js.map +1 -0
  127. package/lib/formatter/helpers/gherkin_document_parser.d.ts +5 -0
  128. package/lib/formatter/helpers/gherkin_document_parser.js +66 -0
  129. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -0
  130. package/lib/formatter/helpers/index.d.ts +10 -0
  131. package/lib/formatter/helpers/index.js +52 -0
  132. package/lib/formatter/helpers/index.js.map +1 -0
  133. package/lib/formatter/helpers/issue_helpers.d.ts +19 -0
  134. package/lib/formatter/helpers/issue_helpers.js +59 -0
  135. package/lib/formatter/helpers/issue_helpers.js.map +1 -0
  136. package/lib/formatter/helpers/keyword_type.d.ts +11 -0
  137. package/lib/formatter/helpers/keyword_type.js +32 -0
  138. package/lib/formatter/helpers/keyword_type.js.map +1 -0
  139. package/lib/formatter/helpers/location_helpers.d.ts +2 -0
  140. package/lib/formatter/helpers/location_helpers.js +17 -0
  141. package/lib/formatter/helpers/location_helpers.js.map +1 -0
  142. package/lib/formatter/helpers/pickle_parser.d.ts +17 -0
  143. package/lib/formatter/helpers/pickle_parser.js +28 -0
  144. package/lib/formatter/helpers/pickle_parser.js.map +1 -0
  145. package/lib/formatter/helpers/step_argument_formatter.d.ts +2 -0
  146. package/lib/formatter/helpers/step_argument_formatter.js +48 -0
  147. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -0
  148. package/lib/formatter/helpers/summary_helpers.d.ts +9 -0
  149. package/lib/formatter/helpers/summary_helpers.js +96 -0
  150. package/lib/formatter/helpers/summary_helpers.js.map +1 -0
  151. package/lib/formatter/helpers/test_case_attempt_formatter.d.ts +12 -0
  152. package/lib/formatter/helpers/test_case_attempt_formatter.js +114 -0
  153. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -0
  154. package/lib/formatter/helpers/test_case_attempt_parser.d.ts +32 -0
  155. package/lib/formatter/helpers/test_case_attempt_parser.js +135 -0
  156. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -0
  157. package/lib/formatter/helpers/usage_helpers/index.d.ts +23 -0
  158. package/lib/formatter/helpers/usage_helpers/index.js +111 -0
  159. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -0
  160. package/lib/formatter/html_formatter.d.ts +7 -0
  161. package/lib/formatter/html_formatter.js +30 -0
  162. package/lib/formatter/html_formatter.js.map +1 -0
  163. package/lib/formatter/index.d.ts +53 -0
  164. package/lib/formatter/index.js +21 -0
  165. package/lib/formatter/index.js.map +1 -0
  166. package/lib/formatter/json_formatter.d.ts +78 -0
  167. package/lib/formatter/json_formatter.js +230 -0
  168. package/lib/formatter/json_formatter.js.map +1 -0
  169. package/lib/formatter/junit_formatter.d.ts +17 -0
  170. package/lib/formatter/junit_formatter.js +181 -0
  171. package/lib/formatter/junit_formatter.js.map +1 -0
  172. package/lib/formatter/message_formatter.d.ts +5 -0
  173. package/lib/formatter/message_formatter.js +15 -0
  174. package/lib/formatter/message_formatter.js.map +1 -0
  175. package/lib/formatter/progress_bar_formatter.d.ts +18 -0
  176. package/lib/formatter/progress_bar_formatter.js +99 -0
  177. package/lib/formatter/progress_bar_formatter.js.map +1 -0
  178. package/lib/formatter/progress_formatter.d.ts +9 -0
  179. package/lib/formatter/progress_formatter.js +59 -0
  180. package/lib/formatter/progress_formatter.js.map +1 -0
  181. package/lib/formatter/rerun_formatter.d.ts +13 -0
  182. package/lib/formatter/rerun_formatter.js +80 -0
  183. package/lib/formatter/rerun_formatter.js.map +1 -0
  184. package/lib/formatter/snippets_formatter.d.ts +6 -0
  185. package/lib/formatter/snippets_formatter.js +61 -0
  186. package/lib/formatter/snippets_formatter.js.map +1 -0
  187. package/lib/formatter/step_definition_snippet_builder/index.d.ts +20 -0
  188. package/lib/formatter/step_definition_snippet_builder/index.js +46 -0
  189. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -0
  190. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.d.ts +7 -0
  191. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js +46 -0
  192. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -0
  193. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.d.ts +16 -0
  194. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +11 -0
  195. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -0
  196. package/lib/formatter/summary_formatter.d.ts +14 -0
  197. package/lib/formatter/summary_formatter.js +68 -0
  198. package/lib/formatter/summary_formatter.js.map +1 -0
  199. package/lib/formatter/usage_formatter.d.ts +6 -0
  200. package/lib/formatter/usage_formatter.js +98 -0
  201. package/lib/formatter/usage_formatter.js.map +1 -0
  202. package/lib/formatter/usage_json_formatter.d.ts +7 -0
  203. package/lib/formatter/usage_json_formatter.js +34 -0
  204. package/lib/formatter/usage_json_formatter.js.map +1 -0
  205. package/lib/importer.js +13 -0
  206. package/lib/index.d.ts +58 -0
  207. package/lib/index.js +109 -0
  208. package/lib/index.js.map +1 -0
  209. package/lib/logger.d.ts +5 -0
  210. package/lib/logger.js +3 -0
  211. package/lib/logger.js.map +1 -0
  212. package/lib/models/data_table.d.ts +10 -0
  213. package/lib/models/data_table.js +46 -0
  214. package/lib/models/data_table.js.map +1 -0
  215. package/lib/models/definition.d.ts +55 -0
  216. package/lib/models/definition.js +22 -0
  217. package/lib/models/definition.js.map +1 -0
  218. package/lib/models/gherkin_step_keyword.d.ts +1 -0
  219. package/lib/models/gherkin_step_keyword.js +3 -0
  220. package/lib/models/gherkin_step_keyword.js.map +1 -0
  221. package/lib/models/pickle_order.d.ts +1 -0
  222. package/lib/models/pickle_order.js +3 -0
  223. package/lib/models/pickle_order.js.map +1 -0
  224. package/lib/models/step_definition.d.ts +11 -0
  225. package/lib/models/step_definition.js +37 -0
  226. package/lib/models/step_definition.js.map +1 -0
  227. package/lib/models/test_case_hook_definition.d.ts +10 -0
  228. package/lib/models/test_case_hook_definition.js +27 -0
  229. package/lib/models/test_case_hook_definition.js.map +1 -0
  230. package/lib/models/test_run_hook_definition.d.ts +3 -0
  231. package/lib/models/test_run_hook_definition.js +10 -0
  232. package/lib/models/test_run_hook_definition.js.map +1 -0
  233. package/lib/models/test_step_hook_definition.d.ts +9 -0
  234. package/lib/models/test_step_hook_definition.js +26 -0
  235. package/lib/models/test_step_hook_definition.js.map +1 -0
  236. package/lib/pickle_filter.d.ts +42 -0
  237. package/lib/pickle_filter.js +99 -0
  238. package/lib/pickle_filter.js.map +1 -0
  239. package/lib/plugin/index.d.ts +2 -0
  240. package/lib/plugin/index.js +19 -0
  241. package/lib/plugin/index.js.map +1 -0
  242. package/lib/plugin/plugin_manager.d.ts +13 -0
  243. package/lib/plugin/plugin_manager.js +36 -0
  244. package/lib/plugin/plugin_manager.js.map +1 -0
  245. package/lib/plugin/types.d.ts +14 -0
  246. package/lib/plugin/types.js +3 -0
  247. package/lib/plugin/types.js.map +1 -0
  248. package/lib/publish/http_stream.d.ts +30 -0
  249. package/lib/publish/http_stream.js +112 -0
  250. package/lib/publish/http_stream.js.map +1 -0
  251. package/lib/publish/index.d.ts +2 -0
  252. package/lib/publish/index.js +5 -0
  253. package/lib/publish/index.js.map +1 -0
  254. package/lib/publish/publish_plugin.d.ts +2 -0
  255. package/lib/publish/publish_plugin.js +48 -0
  256. package/lib/publish/publish_plugin.js.map +1 -0
  257. package/lib/runtime/assemble_test_cases.d.ts +13 -0
  258. package/lib/runtime/assemble_test_cases.js +88 -0
  259. package/lib/runtime/assemble_test_cases.js.map +1 -0
  260. package/lib/runtime/attachment_manager/index.d.ts +33 -0
  261. package/lib/runtime/attachment_manager/index.js +119 -0
  262. package/lib/runtime/attachment_manager/index.js.map +1 -0
  263. package/lib/runtime/format_error.d.ts +2 -0
  264. package/lib/runtime/format_error.js +36 -0
  265. package/lib/runtime/format_error.js.map +1 -0
  266. package/lib/runtime/helpers.d.ts +6 -0
  267. package/lib/runtime/helpers.js +101 -0
  268. package/lib/runtime/helpers.js.map +1 -0
  269. package/lib/runtime/index.d.ts +40 -0
  270. package/lib/runtime/index.js +76 -0
  271. package/lib/runtime/index.js.map +1 -0
  272. package/lib/runtime/parallel/command_types.d.ts +32 -0
  273. package/lib/runtime/parallel/command_types.js +3 -0
  274. package/lib/runtime/parallel/command_types.js.map +1 -0
  275. package/lib/runtime/parallel/coordinator.d.ts +72 -0
  276. package/lib/runtime/parallel/coordinator.js +222 -0
  277. package/lib/runtime/parallel/coordinator.js.map +1 -0
  278. package/lib/runtime/parallel/run_worker.d.ts +1 -0
  279. package/lib/runtime/parallel/run_worker.js +29 -0
  280. package/lib/runtime/parallel/run_worker.js.map +1 -0
  281. package/lib/runtime/parallel/worker.d.ts +26 -0
  282. package/lib/runtime/parallel/worker.js +87 -0
  283. package/lib/runtime/parallel/worker.js.map +1 -0
  284. package/lib/runtime/run_test_run_hooks.d.ts +3 -0
  285. package/lib/runtime/run_test_run_hooks.js +28 -0
  286. package/lib/runtime/run_test_run_hooks.js.map +1 -0
  287. package/lib/runtime/step_runner.d.ts +16 -0
  288. package/lib/runtime/step_runner.js +88 -0
  289. package/lib/runtime/step_runner.js.map +1 -0
  290. package/lib/runtime/stopwatch.d.ts +12 -0
  291. package/lib/runtime/stopwatch.js +34 -0
  292. package/lib/runtime/stopwatch.js.map +1 -0
  293. package/lib/runtime/test_case_runner.d.ts +54 -0
  294. package/lib/runtime/test_case_runner.js +268 -0
  295. package/lib/runtime/test_case_runner.js.map +1 -0
  296. package/lib/step_arguments.d.ts +6 -0
  297. package/lib/step_arguments.js +19 -0
  298. package/lib/step_arguments.js.map +1 -0
  299. package/lib/support_code_library_builder/build_parameter_type.d.ts +3 -0
  300. package/lib/support_code_library_builder/build_parameter_type.js +13 -0
  301. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -0
  302. package/lib/support_code_library_builder/get_definition_line_and_uri.d.ts +3 -0
  303. package/lib/support_code_library_builder/get_definition_line_and_uri.js +29 -0
  304. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -0
  305. package/lib/support_code_library_builder/index.d.ts +74 -0
  306. package/lib/support_code_library_builder/index.js +304 -0
  307. package/lib/support_code_library_builder/index.js.map +1 -0
  308. package/lib/support_code_library_builder/parallel_can_assign_helpers.d.ts +2 -0
  309. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +16 -0
  310. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -0
  311. package/lib/support_code_library_builder/sourced_parameter_type_registry.d.ts +7 -0
  312. package/lib/support_code_library_builder/sourced_parameter_type_registry.js +19 -0
  313. package/lib/support_code_library_builder/sourced_parameter_type_registry.js.map +1 -0
  314. package/lib/support_code_library_builder/types.d.ts +88 -0
  315. package/lib/support_code_library_builder/types.js +3 -0
  316. package/lib/support_code_library_builder/types.js.map +1 -0
  317. package/lib/support_code_library_builder/validate_arguments.d.ts +12 -0
  318. package/lib/support_code_library_builder/validate_arguments.js +73 -0
  319. package/lib/support_code_library_builder/validate_arguments.js.map +1 -0
  320. package/lib/support_code_library_builder/world.d.ts +18 -0
  321. package/lib/support_code_library_builder/world.js +11 -0
  322. package/lib/support_code_library_builder/world.js.map +1 -0
  323. package/lib/time.d.ts +18 -0
  324. package/lib/time.js +61 -0
  325. package/lib/time.js.map +1 -0
  326. package/lib/try_require.d.ts +7 -0
  327. package/lib/try_require.js +26 -0
  328. package/lib/try_require.js.map +1 -0
  329. package/lib/types/index.d.ts +4 -0
  330. package/lib/types/index.js +3 -0
  331. package/lib/types/index.js.map +1 -0
  332. package/lib/uncaught_exception_manager.d.ts +7 -0
  333. package/lib/uncaught_exception_manager.js +12 -0
  334. package/lib/uncaught_exception_manager.js.map +1 -0
  335. package/lib/user_code_runner.d.ts +14 -0
  336. package/lib/user_code_runner.js +82 -0
  337. package/lib/user_code_runner.js.map +1 -0
  338. package/lib/value_checker.d.ts +3 -0
  339. package/lib/value_checker.js +19 -0
  340. package/lib/value_checker.js.map +1 -0
  341. package/lib/version.d.ts +1 -0
  342. package/lib/version.js +6 -0
  343. package/lib/version.js.map +1 -0
  344. package/lib/wrapper.mjs +44 -0
  345. package/package.json +189 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install_validator.js","sourceRoot":"","sources":["../../src/cli/install_validator.ts"],"names":[],"mappings":";;;;;;AAAA,+BAA+B;AAC/B,kFAAuD;AAEhD,KAAK,UAAU,eAAe;IACnC,IAAI,+BAAmB;QACrB,OAAO,CAAC,IAAI,CACV;;;;OAIC,CACF,CAAA;AACL,CAAC;AATD,0CASC","sourcesContent":["/* eslint-disable no-console */\nimport isInstalledGlobally from 'is-installed-globally'\n\nexport async function validateInstall(): Promise<void> {\n if (isInstalledGlobally)\n console.warn(\n `\n It looks like you're running Cucumber from a global installation.\n If so, you'll likely see issues - you need to have Cucumber installed as a local dependency in your project.\n See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations\n `\n )\n}\n"]}
@@ -0,0 +1 @@
1
+ export default function run(): Promise<void>;
package/lib/cli/run.js ADDED
@@ -0,0 +1,44 @@
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
+ /* 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. */
9
+ const _1 = __importDefault(require("./"));
10
+ const verror_1 = __importDefault(require("verror"));
11
+ const validate_node_engine_version_1 = require("./validate_node_engine_version");
12
+ function logErrorMessageAndExit(message) {
13
+ console.error(message);
14
+ process.exit(1);
15
+ }
16
+ async function run() {
17
+ (0, validate_node_engine_version_1.validateNodeEngineVersion)(process.version, (error) => {
18
+ console.error(error);
19
+ process.exit(1);
20
+ }, console.warn);
21
+ const cli = new _1.default({
22
+ argv: process.argv,
23
+ cwd: process.cwd(),
24
+ stdout: process.stdout,
25
+ stderr: process.stderr,
26
+ env: process.env,
27
+ });
28
+ let result;
29
+ try {
30
+ result = await cli.run();
31
+ }
32
+ catch (error) {
33
+ logErrorMessageAndExit(verror_1.default.fullStack(error));
34
+ }
35
+ const exitCode = result.success ? 0 : 1;
36
+ if (result.shouldExitImmediately) {
37
+ process.exit(exitCode);
38
+ }
39
+ else {
40
+ process.exitCode = exitCode;
41
+ }
42
+ }
43
+ exports.default = run;
44
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
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,iFAA0E;AAE1E,SAAS,sBAAsB,CAAC,OAAe;IAC7C,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC;AAEc,KAAK,UAAU,GAAG;IAC/B,IAAA,wDAAyB,EACvB,OAAO,CAAC,OAAO,EACf,CAAC,KAAK,EAAE,EAAE;QACR,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACpB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,EACD,OAAO,CAAC,IAAI,CACb,CAAA;IAED,MAAM,GAAG,GAAG,IAAI,UAAG,CAAC;QAClB,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;QAClB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC,CAAA;IAEF,IAAI,MAAqB,CAAA;IACzB,IAAI;QACF,MAAM,GAAG,MAAM,GAAG,CAAC,GAAG,EAAE,CAAA;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,sBAAsB,CAAC,gBAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,qBAAqB,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KACvB;SAAM;QACL,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA;KAC5B;AACH,CAAC;AA/BD,sBA+BC","sourcesContent":["/* eslint-disable no-console */\n/* This is one rare place where we're fine to use process/console directly,\n * but other code abstracts those to remain composable and testable. */\nimport Cli, { ICliRunResult } from './'\nimport VError from 'verror'\nimport { validateNodeEngineVersion } from './validate_node_engine_version'\n\nfunction logErrorMessageAndExit(message: string): void {\n console.error(message)\n process.exit(1)\n}\n\nexport default async function run(): Promise<void> {\n validateNodeEngineVersion(\n process.version,\n (error) => {\n console.error(error)\n process.exit(1)\n },\n console.warn\n )\n\n const cli = new Cli({\n argv: process.argv,\n cwd: process.cwd(),\n stdout: process.stdout,\n stderr: process.stderr,\n env: process.env,\n })\n\n let result: ICliRunResult\n try {\n result = await cli.run()\n } catch (error) {\n logErrorMessageAndExit(VError.fullStack(error))\n }\n\n const exitCode = result.success ? 0 : 1\n if (result.shouldExitImmediately) {\n process.exit(exitCode)\n } else {\n process.exitCode = exitCode\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ 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;
@@ -0,0 +1,102 @@
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
+ const commander_1 = require("commander");
7
+ const lodash_merge_1 = __importDefault(require("lodash.merge"));
8
+ const gherkin_1 = require("@cucumber/gherkin");
9
+ const formatters_1 = __importDefault(require("../formatter/helpers/formatters"));
10
+ const version_1 = require("../version");
11
+ const ArgvParser = {
12
+ collect(val, memo = []) {
13
+ if (val) {
14
+ return [...memo, val];
15
+ }
16
+ return undefined;
17
+ },
18
+ mergeJson(option) {
19
+ return function (str, memo = {}) {
20
+ let val;
21
+ try {
22
+ val = JSON.parse(str);
23
+ }
24
+ catch (error) {
25
+ const e = error;
26
+ throw new Error(`${option} passed invalid JSON: ${e.message}: ${str}`);
27
+ }
28
+ if (typeof val !== 'object' || Array.isArray(val)) {
29
+ throw new Error(`${option} must be passed JSON of an object: ${str}`);
30
+ }
31
+ return (0, lodash_merge_1.default)(memo, val);
32
+ };
33
+ },
34
+ mergeTags(value, memo) {
35
+ return memo ? `${memo} and (${value})` : `(${value})`;
36
+ },
37
+ validateCountOption(value, optionName) {
38
+ const numericValue = parseInt(value);
39
+ if (isNaN(numericValue) || numericValue < 0) {
40
+ throw new Error(`${optionName} must be a non negative integer`);
41
+ }
42
+ return numericValue;
43
+ },
44
+ validateLanguage(value) {
45
+ if (!Object.keys(gherkin_1.dialects).includes(value)) {
46
+ throw new Error(`Unsupported ISO 639-1: ${value}`);
47
+ }
48
+ return value;
49
+ },
50
+ parse(argv) {
51
+ const program = new commander_1.Command('cucumber-js');
52
+ program
53
+ .storeOptionsAsProperties(false)
54
+ .usage('[options] [<GLOB|DIR|FILE[:LINE]>...]')
55
+ .version(version_1.version, '-v, --version')
56
+ .option('-b, --backtrace', 'show full backtrace for errors')
57
+ .option('-c, --config <PATH>', 'specify configuration file')
58
+ .option('-d, --dry-run', 'invoke formatters without executing steps')
59
+ .option('--exit, --force-exit', 'force shutdown of the event loop when the test run has finished: cucumber will call process.exit')
60
+ .option('--fail-fast', 'abort the run on first failure')
61
+ .option('-f, --format <TYPE[:PATH]>', 'specify the output format, optionally supply PATH to redirect formatter output (repeatable). Available formats:\n' +
62
+ formatters_1.default.buildFormattersDocumentationString(), ArgvParser.collect)
63
+ .option('--format-options <JSON>', 'provide options for formatters (repeatable)', ArgvParser.mergeJson('--format-options'))
64
+ .option('--i18n-keywords <ISO 639-1>', 'list language keywords', ArgvParser.validateLanguage)
65
+ .option('--i18n-languages', 'list languages')
66
+ .option('-i, --import <GLOB|DIR|FILE>', 'import files before executing features (repeatable)', ArgvParser.collect)
67
+ .option('--language <ISO 639-1>', 'provide the default language for feature files')
68
+ .option('--name <REGEXP>', 'only execute the scenarios with name matching the expression (repeatable)', ArgvParser.collect)
69
+ .option('--order <TYPE[:SEED]>', 'run scenarios in the specified order. Type should be `defined` or `random`')
70
+ .option('-p, --profile <NAME>', 'specify the profile to use (repeatable)', ArgvParser.collect, [])
71
+ .option('--parallel <NUMBER_OF_WORKERS>', 'run in parallel with the given number of workers', (val) => ArgvParser.validateCountOption(val, '--parallel'))
72
+ .option('--publish', 'Publish a report to https://reports.cucumber.io')
73
+ .option('--publish-quiet', "Don't print information banner about publishing reports")
74
+ .option('-r, --require <GLOB|DIR|FILE>', 'require files before executing features (repeatable)', ArgvParser.collect)
75
+ .option('--require-module <NODE_MODULE>', 'require node modules before requiring files (repeatable)', ArgvParser.collect)
76
+ .option('--retry <NUMBER_OF_RETRIES>', 'specify the number of times to retry failing test cases (default: 0)', (val) => ArgvParser.validateCountOption(val, '--retry'))
77
+ .option('--retry-tag-filter <EXPRESSION>', `only retries the features or scenarios with tags matching the expression (repeatable).
78
+ This option requires '--retry' to be specified.`, ArgvParser.mergeTags)
79
+ .option('--strict', 'fail if there are pending steps')
80
+ .option('--no-strict', 'succeed even if there are pending steps')
81
+ .option('-t, --tags <EXPRESSION>', 'only execute the features or scenarios with tags matching the expression (repeatable)', ArgvParser.mergeTags)
82
+ .option('--world-parameters <JSON>', 'provide parameters that will be passed to the world constructor (repeatable)', ArgvParser.mergeJson('--world-parameters'));
83
+ program.addHelpText('afterAll', 'For more details please visit https://github.com/cucumber/cucumber-js/blob/main/docs/cli.md');
84
+ program.parse(argv);
85
+ const { config, i18nKeywords, i18nLanguages, profile, ...regularStuff } = program.opts();
86
+ const configuration = regularStuff;
87
+ if (program.args.length > 0) {
88
+ configuration.paths = program.args;
89
+ }
90
+ return {
91
+ options: {
92
+ config,
93
+ i18nKeywords,
94
+ i18nLanguages,
95
+ profile,
96
+ },
97
+ configuration,
98
+ };
99
+ },
100
+ };
101
+ exports.default = ArgvParser;
102
+ //# sourceMappingURL=argv_parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv_parser.js","sourceRoot":"","sources":["../../src/configuration/argv_parser.ts"],"names":[],"mappings":"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","sourcesContent":["import { Command } from 'commander'\nimport merge from 'lodash.merge'\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('cucumber-js')\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,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,3 @@
1
+ import { IConfiguration } from './types';
2
+ import { ILogger } from '../logger';
3
+ export declare function fromFile(logger: ILogger, cwd: string, file: string, profiles?: string[]): Promise<Partial<IConfiguration>>;
@@ -0,0 +1,85 @@
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 fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const yaml_1 = __importDefault(require("yaml"));
11
+ const util_1 = require("util");
12
+ const url_1 = require("url");
13
+ const merge_configurations_1 = require("./merge_configurations");
14
+ const argv_parser_1 = __importDefault(require("./argv_parser"));
15
+ const check_schema_1 = require("./check_schema");
16
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
17
+ const { importer } = require('../importer');
18
+ async function fromFile(logger, cwd, file, profiles = []) {
19
+ const definitions = await loadFile(cwd, file);
20
+ if (!definitions.default) {
21
+ logger.debug('No default profile defined in configuration file');
22
+ definitions.default = {};
23
+ }
24
+ if (profiles.length < 1) {
25
+ logger.debug('No profiles specified; using default profile');
26
+ profiles = ['default'];
27
+ }
28
+ const definedKeys = Object.keys(definitions);
29
+ profiles.forEach((profileKey) => {
30
+ if (!definedKeys.includes(profileKey)) {
31
+ throw new Error(`Requested profile "${profileKey}" doesn't exist`);
32
+ }
33
+ });
34
+ return (0, merge_configurations_1.mergeConfigurations)({}, ...profiles.map((profileKey) => extractConfiguration(logger, profileKey, definitions[profileKey])));
35
+ }
36
+ exports.fromFile = fromFile;
37
+ async function loadFile(cwd, file) {
38
+ const filePath = path_1.default.join(cwd, file);
39
+ const extension = path_1.default.extname(filePath);
40
+ let definitions;
41
+ switch (extension) {
42
+ case '.json':
43
+ definitions = JSON.parse(await (0, util_1.promisify)(fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
44
+ break;
45
+ case '.yaml':
46
+ case '.yml':
47
+ definitions = yaml_1.default.parse(await (0, util_1.promisify)(fs_1.default.readFile)(filePath, { encoding: 'utf-8' }));
48
+ break;
49
+ default:
50
+ try {
51
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
52
+ definitions = require(filePath);
53
+ }
54
+ catch (error) {
55
+ if (error.code === 'ERR_REQUIRE_ESM') {
56
+ definitions = await importer((0, url_1.pathToFileURL)(filePath));
57
+ }
58
+ else {
59
+ throw error;
60
+ }
61
+ }
62
+ }
63
+ if (typeof definitions !== 'object') {
64
+ throw new Error(`Configuration file ${filePath} does not export an object`);
65
+ }
66
+ return definitions;
67
+ }
68
+ function extractConfiguration(logger, name, definition) {
69
+ if (typeof definition === 'string') {
70
+ logger.debug(`Profile "${name}" value is a string; parsing as argv`);
71
+ const { configuration } = argv_parser_1.default.parse([
72
+ 'node',
73
+ 'cucumber-js',
74
+ ...(0, string_argv_1.default)(definition),
75
+ ]);
76
+ return configuration;
77
+ }
78
+ try {
79
+ return (0, check_schema_1.checkSchema)(definition);
80
+ }
81
+ catch (error) {
82
+ throw new Error(`Requested profile "${name}" failed schema validation: ${error.errors.join(' ')}`);
83
+ }
84
+ }
85
+ //# sourceMappingURL=from_file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from_file.js","sourceRoot":"","sources":["../../src/configuration/from_file.ts"],"names":[],"mappings":"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","sourcesContent":["import stringArgv from 'string-argv'\nimport fs from 'fs'\nimport path from 'path'\nimport YAML from 'yaml'\nimport { promisify } from 'util'\nimport { pathToFileURL } from 'url'\nimport { IConfiguration } from './types'\nimport { mergeConfigurations } from './merge_configurations'\nimport ArgvParser from './argv_parser'\nimport { checkSchema } from './check_schema'\nimport { ILogger } from '../logger'\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst { importer } = require('../importer')\n\nexport async function fromFile(\n logger: ILogger,\n cwd: string,\n file: string,\n profiles: string[] = []\n): Promise<Partial<IConfiguration>> {\n const definitions = await loadFile(cwd, file)\n if (!definitions.default) {\n logger.debug('No default profile defined in configuration file')\n definitions.default = {}\n }\n if (profiles.length < 1) {\n logger.debug('No profiles specified; using default profile')\n profiles = ['default']\n }\n const definedKeys = Object.keys(definitions)\n profiles.forEach((profileKey) => {\n if (!definedKeys.includes(profileKey)) {\n throw new Error(`Requested profile \"${profileKey}\" doesn't exist`)\n }\n })\n return mergeConfigurations(\n {},\n ...profiles.map((profileKey) =>\n extractConfiguration(logger, profileKey, definitions[profileKey])\n )\n )\n}\n\nasync function loadFile(\n cwd: string,\n file: string\n): Promise<Record<string, any>> {\n const filePath: string = path.join(cwd, file)\n const extension = path.extname(filePath)\n let definitions\n switch (extension) {\n case '.json':\n definitions = JSON.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n case '.yaml':\n case '.yml':\n definitions = YAML.parse(\n await promisify(fs.readFile)(filePath, { encoding: 'utf-8' })\n )\n break\n default:\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 }\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 logger: ILogger,\n name: string,\n definition: any\n): Partial<IConfiguration> {\n if (typeof definition === 'string') {\n logger.debug(`Profile \"${name}\" value is a string; parsing as argv`)\n const { configuration } = ArgvParser.parse([\n 'node',\n 'cucumber-js',\n ...stringArgv(definition),\n ])\n return configuration\n }\n try {\n return checkSchema(definition)\n } catch (error) {\n throw new Error(\n `Requested profile \"${name}\" failed schema validation: ${error.errors.join(\n ' '\n )}`\n )\n }\n}\n"]}
@@ -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"]}
@@ -0,0 +1 @@
1
+ export declare function locateFile(cwd: string): string | undefined;
@@ -0,0 +1,21 @@
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
+ 'cucumber.yaml',
15
+ 'cucumber.yml',
16
+ ];
17
+ function locateFile(cwd) {
18
+ return DEFAULT_FILENAMES.find((filename) => fs_1.default.existsSync(path_1.default.join(cwd, filename)));
19
+ }
20
+ exports.locateFile = locateFile;
21
+ //# 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;IACf,eAAe;IACf,cAAc;CACf,CAAA;AAED,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzC,YAAE,CAAC,UAAU,CAAC,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 'cucumber.yaml',\n 'cucumber.yml',\n]\n\nexport function locateFile(cwd: string): string | undefined {\n return DEFAULT_FILENAMES.find((filename) =>\n fs.existsSync(path.join(cwd, filename))\n )\n}\n"]}
@@ -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
+ };