@cucumber/cucumber 11.1.1 → 11.3.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 (231) hide show
  1. package/README.md +9 -7
  2. package/lib/api/convert_configuration.d.ts +1 -2
  3. package/lib/api/convert_configuration.js +1 -2
  4. package/lib/api/convert_configuration.js.map +1 -1
  5. package/lib/api/formatters.d.ts +1 -3
  6. package/lib/api/formatters.js +2 -3
  7. package/lib/api/formatters.js.map +1 -1
  8. package/lib/api/gherkin.js +1 -2
  9. package/lib/api/gherkin.js.map +1 -1
  10. package/lib/api/index.d.ts +1 -0
  11. package/lib/api/index.js.map +1 -1
  12. package/lib/api/load_configuration.d.ts +2 -1
  13. package/lib/api/load_configuration.js +3 -4
  14. package/lib/api/load_configuration.js.map +1 -1
  15. package/lib/api/load_sources.d.ts +2 -1
  16. package/lib/api/load_sources.js +4 -5
  17. package/lib/api/load_sources.js.map +1 -1
  18. package/lib/api/load_support.d.ts +2 -1
  19. package/lib/api/load_support.js +4 -5
  20. package/lib/api/load_support.js.map +1 -1
  21. package/lib/api/plugins.d.ts +5 -5
  22. package/lib/api/plugins.js +12 -13
  23. package/lib/api/plugins.js.map +1 -1
  24. package/lib/api/run_cucumber.d.ts +2 -1
  25. package/lib/api/run_cucumber.js +4 -5
  26. package/lib/api/run_cucumber.js.map +1 -1
  27. package/lib/api/support.d.ts +1 -1
  28. package/lib/api/support.js +1 -2
  29. package/lib/api/support.js.map +1 -1
  30. package/lib/api/test_helpers.d.ts +1 -1
  31. package/lib/api/test_helpers.js +2 -3
  32. package/lib/api/test_helpers.js.map +1 -1
  33. package/lib/api/types.d.ts +0 -35
  34. package/lib/api/types.js.map +1 -1
  35. package/lib/assemble/assemble_test_cases.d.ts +1 -7
  36. package/lib/assemble/assemble_test_cases.js +3 -3
  37. package/lib/assemble/assemble_test_cases.js.map +1 -1
  38. package/lib/cli/helpers.d.ts +1 -3
  39. package/lib/cli/helpers.js +61 -33
  40. package/lib/cli/helpers.js.map +1 -1
  41. package/lib/cli/i18n.js +2 -3
  42. package/lib/cli/i18n.js.map +1 -1
  43. package/lib/cli/index.d.ts +0 -1
  44. package/lib/cli/index.js.map +1 -1
  45. package/lib/cli/install_validator.js +1 -2
  46. package/lib/cli/install_validator.js.map +1 -1
  47. package/lib/cli/run.js +1 -1
  48. package/lib/cli/run.js.map +1 -1
  49. package/lib/cli/validate_node_engine_version.js +1 -2
  50. package/lib/cli/validate_node_engine_version.js.map +1 -1
  51. package/lib/configuration/argv_parser.js.map +1 -1
  52. package/lib/configuration/check_schema.js +18 -9
  53. package/lib/configuration/check_schema.js.map +1 -1
  54. package/lib/configuration/from_file.d.ts +1 -1
  55. package/lib/configuration/from_file.js +3 -4
  56. package/lib/configuration/from_file.js.map +1 -1
  57. package/lib/configuration/helpers.js +1 -2
  58. package/lib/configuration/helpers.js.map +1 -1
  59. package/lib/configuration/locate_file.js +1 -2
  60. package/lib/configuration/locate_file.js.map +1 -1
  61. package/lib/configuration/merge_configurations.js +1 -2
  62. package/lib/configuration/merge_configurations.js.map +1 -1
  63. package/lib/configuration/parse_configuration.d.ts +1 -1
  64. package/lib/configuration/parse_configuration.js +1 -2
  65. package/lib/configuration/parse_configuration.js.map +1 -1
  66. package/lib/configuration/split_format_descriptor.d.ts +1 -1
  67. package/lib/configuration/split_format_descriptor.js +1 -2
  68. package/lib/configuration/split_format_descriptor.js.map +1 -1
  69. package/lib/configuration/validate_configuration.d.ts +1 -1
  70. package/lib/configuration/validate_configuration.js +1 -2
  71. package/lib/configuration/validate_configuration.js.map +1 -1
  72. package/lib/environment/console_logger.d.ts +11 -0
  73. package/lib/{api → environment}/console_logger.js +6 -6
  74. package/lib/environment/console_logger.js.map +1 -0
  75. package/lib/environment/index.d.ts +2 -0
  76. package/lib/environment/index.js +19 -0
  77. package/lib/environment/index.js.map +1 -0
  78. package/lib/environment/make_environment.d.ts +2 -0
  79. package/lib/{api/environment.js → environment/make_environment.js} +3 -4
  80. package/lib/environment/make_environment.js.map +1 -0
  81. package/lib/environment/types.d.ts +41 -0
  82. package/lib/{logger.js → environment/types.js} +1 -1
  83. package/lib/environment/types.js.map +1 -0
  84. package/lib/filter_stack_trace.js +2 -3
  85. package/lib/filter_stack_trace.js.map +1 -1
  86. package/lib/formatter/builder.d.ts +1 -5
  87. package/lib/formatter/builder.js.map +1 -1
  88. package/lib/formatter/builtin/html.js +1 -4
  89. package/lib/formatter/builtin/html.js.map +1 -1
  90. package/lib/formatter/builtin/index.d.ts +1 -1
  91. package/lib/formatter/create_stream.d.ts +1 -2
  92. package/lib/formatter/create_stream.js +1 -2
  93. package/lib/formatter/create_stream.js.map +1 -1
  94. package/lib/formatter/find_class_or_plugin.js +1 -2
  95. package/lib/formatter/find_class_or_plugin.js.map +1 -1
  96. package/lib/formatter/get_color_fns.d.ts +0 -2
  97. package/lib/formatter/get_color_fns.js +1 -1
  98. package/lib/formatter/get_color_fns.js.map +1 -1
  99. package/lib/formatter/helpers/duration_helpers.js +2 -3
  100. package/lib/formatter/helpers/duration_helpers.js.map +1 -1
  101. package/lib/formatter/helpers/event_data_collector.d.ts +0 -1
  102. package/lib/formatter/helpers/event_data_collector.js +17 -7
  103. package/lib/formatter/helpers/event_data_collector.js.map +1 -1
  104. package/lib/formatter/helpers/gherkin_document_parser.js +4 -5
  105. package/lib/formatter/helpers/gherkin_document_parser.js.map +1 -1
  106. package/lib/formatter/helpers/index.js +17 -7
  107. package/lib/formatter/helpers/index.js.map +1 -1
  108. package/lib/formatter/helpers/issue_helpers.js +6 -7
  109. package/lib/formatter/helpers/issue_helpers.js.map +1 -1
  110. package/lib/formatter/helpers/keyword_type.js +3 -3
  111. package/lib/formatter/helpers/keyword_type.js.map +1 -1
  112. package/lib/formatter/helpers/location_helpers.js +1 -2
  113. package/lib/formatter/helpers/location_helpers.js.map +1 -1
  114. package/lib/formatter/helpers/pickle_parser.js +4 -5
  115. package/lib/formatter/helpers/pickle_parser.js.map +1 -1
  116. package/lib/formatter/helpers/step_argument_formatter.js +1 -2
  117. package/lib/formatter/helpers/step_argument_formatter.js.map +1 -1
  118. package/lib/formatter/helpers/summary_helpers.js +18 -9
  119. package/lib/formatter/helpers/summary_helpers.js.map +1 -1
  120. package/lib/formatter/helpers/test_case_attempt_formatter.js +18 -9
  121. package/lib/formatter/helpers/test_case_attempt_formatter.js.map +1 -1
  122. package/lib/formatter/helpers/test_case_attempt_parser.js +18 -9
  123. package/lib/formatter/helpers/test_case_attempt_parser.js.map +1 -1
  124. package/lib/formatter/helpers/usage_helpers/index.js +18 -9
  125. package/lib/formatter/helpers/usage_helpers/index.js.map +1 -1
  126. package/lib/formatter/import_code.js +1 -2
  127. package/lib/formatter/import_code.js.map +1 -1
  128. package/lib/formatter/index.d.ts +0 -2
  129. package/lib/formatter/json_formatter.js +17 -7
  130. package/lib/formatter/json_formatter.js.map +1 -1
  131. package/lib/formatter/progress_bar_formatter.js.map +1 -1
  132. package/lib/formatter/progress_formatter.js +17 -7
  133. package/lib/formatter/progress_formatter.js.map +1 -1
  134. package/lib/formatter/rerun_formatter.js +17 -7
  135. package/lib/formatter/rerun_formatter.js.map +1 -1
  136. package/lib/formatter/resolve_implementation.js +1 -2
  137. package/lib/formatter/resolve_implementation.js.map +1 -1
  138. package/lib/formatter/snippets_formatter.js +17 -7
  139. package/lib/formatter/snippets_formatter.js.map +1 -1
  140. package/lib/formatter/step_definition_snippet_builder/index.js.map +1 -1
  141. package/lib/formatter/step_definition_snippet_builder/javascript_snippet_syntax.js.map +1 -1
  142. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js +1 -1
  143. package/lib/formatter/step_definition_snippet_builder/snippet_syntax.js.map +1 -1
  144. package/lib/formatter/summary_formatter.js.map +1 -1
  145. package/lib/formatter/usage_formatter.js +17 -7
  146. package/lib/formatter/usage_formatter.js.map +1 -1
  147. package/lib/formatter/usage_json_formatter.js.map +1 -1
  148. package/lib/index.d.ts +4 -4
  149. package/lib/index.js +17 -7
  150. package/lib/index.js.map +1 -1
  151. package/lib/models/data_table.js.map +1 -1
  152. package/lib/models/step_definition.js.map +1 -1
  153. package/lib/paths/paths.d.ts +1 -1
  154. package/lib/paths/paths.js +1 -2
  155. package/lib/paths/paths.js.map +1 -1
  156. package/lib/pickle_filter.js.map +1 -1
  157. package/lib/plugin/plugin_manager.d.ts +5 -4
  158. package/lib/plugin/plugin_manager.js +14 -6
  159. package/lib/plugin/plugin_manager.js.map +1 -1
  160. package/lib/plugin/types.d.ts +4 -3
  161. package/lib/plugin/types.js.map +1 -1
  162. package/lib/publish/publish_plugin.js +46 -16
  163. package/lib/publish/publish_plugin.js.map +1 -1
  164. package/lib/runtime/attachment_manager/index.d.ts +0 -2
  165. package/lib/runtime/attachment_manager/index.js +17 -7
  166. package/lib/runtime/attachment_manager/index.js.map +1 -1
  167. package/lib/runtime/coordinator.d.ts +0 -1
  168. package/lib/runtime/coordinator.js +4 -6
  169. package/lib/runtime/coordinator.js.map +1 -1
  170. package/lib/runtime/format_error.js +1 -2
  171. package/lib/runtime/format_error.js.map +1 -1
  172. package/lib/runtime/helpers.js +20 -11
  173. package/lib/runtime/helpers.js.map +1 -1
  174. package/lib/runtime/make_runtime.d.ts +3 -3
  175. package/lib/runtime/make_runtime.js +1 -2
  176. package/lib/runtime/make_runtime.js.map +1 -1
  177. package/lib/runtime/parallel/adapter.d.ts +2 -4
  178. package/lib/runtime/parallel/adapter.js.map +1 -1
  179. package/lib/runtime/parallel/run_worker.js.map +1 -1
  180. package/lib/runtime/parallel/worker.js.map +1 -1
  181. package/lib/runtime/run_test_run_hooks.js.map +1 -1
  182. package/lib/runtime/scope/make_proxy.js +1 -2
  183. package/lib/runtime/scope/make_proxy.js.map +1 -1
  184. package/lib/runtime/scope/test_case_scope.js +2 -2
  185. package/lib/runtime/scope/test_case_scope.js.map +1 -1
  186. package/lib/runtime/scope/test_run_scope.js +2 -2
  187. package/lib/runtime/scope/test_run_scope.js.map +1 -1
  188. package/lib/runtime/serial/adapter.d.ts +0 -1
  189. package/lib/runtime/serial/adapter.js.map +1 -1
  190. package/lib/runtime/step_runner.js +24 -13
  191. package/lib/runtime/step_runner.js.map +1 -1
  192. package/lib/runtime/stopwatch.js.map +1 -1
  193. package/lib/runtime/test_case_runner.d.ts +0 -1
  194. package/lib/runtime/test_case_runner.js +17 -7
  195. package/lib/runtime/test_case_runner.js.map +1 -1
  196. package/lib/runtime/worker.d.ts +0 -1
  197. package/lib/runtime/worker.js.map +1 -1
  198. package/lib/step_arguments.js +1 -2
  199. package/lib/step_arguments.js.map +1 -1
  200. package/lib/support_code_library_builder/build_parameter_type.js +1 -2
  201. package/lib/support_code_library_builder/build_parameter_type.js.map +1 -1
  202. package/lib/support_code_library_builder/get_definition_line_and_uri.js +1 -2
  203. package/lib/support_code_library_builder/get_definition_line_and_uri.js.map +1 -1
  204. package/lib/support_code_library_builder/index.js.map +1 -1
  205. package/lib/support_code_library_builder/parallel_can_assign_helpers.js +1 -2
  206. package/lib/support_code_library_builder/parallel_can_assign_helpers.js.map +1 -1
  207. package/lib/support_code_library_builder/validate_arguments.js +1 -1
  208. package/lib/support_code_library_builder/validate_arguments.js.map +1 -1
  209. package/lib/time.d.ts +0 -2
  210. package/lib/time.js +19 -10
  211. package/lib/time.js.map +1 -1
  212. package/lib/try_require.js +1 -1
  213. package/lib/try_require.js.map +1 -1
  214. package/lib/tsconfig.node.tsbuildinfo +1 -0
  215. package/lib/uncaught_exception_manager.d.ts +0 -1
  216. package/lib/user_code_runner.js.map +1 -1
  217. package/lib/value_checker.js +3 -4
  218. package/lib/value_checker.js.map +1 -1
  219. package/lib/version.d.ts +1 -1
  220. package/lib/version.js +1 -1
  221. package/lib/version.js.map +1 -1
  222. package/package.json +53 -55
  223. package/lib/api/console_logger.d.ts +0 -12
  224. package/lib/api/console_logger.js.map +0 -1
  225. package/lib/api/environment.d.ts +0 -7
  226. package/lib/api/environment.js.map +0 -1
  227. package/lib/logger.d.ts +0 -5
  228. package/lib/logger.js.map +0 -1
  229. package/lib/publish/http_stream.d.ts +0 -30
  230. package/lib/publish/http_stream.js +0 -117
  231. package/lib/publish/http_stream.js.map +0 -1
@@ -1,30 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { Transform } from 'node:stream';
5
- import http from 'node:http';
6
- type HttpMethod = 'GET' | 'POST' | 'PUT';
7
- /**
8
- * This Writable writes data to a HTTP/HTTPS URL.
9
- *
10
- * It has special handling for https://reports.cucumber.io/
11
- * which uses an API where the first request is a `GET`,
12
- * and if the response is 202 with a Location header, issues
13
- * a PUT request to that URL.
14
- *
15
- * 3xx redirects are not currently followed.
16
- */
17
- export default class HttpStream extends Transform {
18
- private readonly url;
19
- private readonly method;
20
- private readonly headers;
21
- private tempFilePath;
22
- private tempFile;
23
- constructor(url: string, method: HttpMethod, headers: http.OutgoingHttpHeaders);
24
- _write(chunk: any, encoding: BufferEncoding, callback: (err?: Error | null) => void): void;
25
- _final(callback: (error?: Error | null) => void): void;
26
- private pushResponseBody;
27
- private emitErrorUnlessHttp2xx;
28
- private sendHttpRequest;
29
- }
30
- export {};
@@ -1,117 +0,0 @@
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 node_stream_1 = require("node:stream");
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_http_1 = __importDefault(require("node:http"));
9
- const node_https_1 = __importDefault(require("node:https"));
10
- const tmp_1 = __importDefault(require("tmp"));
11
- const value_checker_1 = require("../value_checker");
12
- /**
13
- * This Writable writes data to a HTTP/HTTPS URL.
14
- *
15
- * It has special handling for https://reports.cucumber.io/
16
- * which uses an API where the first request is a `GET`,
17
- * and if the response is 202 with a Location header, issues
18
- * a PUT request to that URL.
19
- *
20
- * 3xx redirects are not currently followed.
21
- */
22
- class HttpStream extends node_stream_1.Transform {
23
- url;
24
- method;
25
- headers;
26
- tempFilePath;
27
- tempFile;
28
- constructor(url, method, headers) {
29
- super({
30
- readableObjectMode: true,
31
- });
32
- this.url = url;
33
- this.method = method;
34
- this.headers = headers;
35
- }
36
- _write(chunk, encoding, callback) {
37
- if (this.tempFile === undefined) {
38
- tmp_1.default.file((err, name, fd) => {
39
- if ((0, value_checker_1.doesHaveValue)(err))
40
- return callback(err);
41
- this.tempFilePath = name;
42
- this.tempFile = node_fs_1.default.createWriteStream(name, { fd });
43
- this.tempFile.write(chunk, encoding, callback);
44
- });
45
- }
46
- else {
47
- this.tempFile.write(chunk, encoding, callback);
48
- }
49
- }
50
- _final(callback) {
51
- this.tempFile.end(() => {
52
- this.sendHttpRequest(this.url, this.method, this.headers, (err1, res1) => {
53
- if ((0, value_checker_1.doesHaveValue)(err1))
54
- return callback(err1);
55
- this.pushResponseBody(res1, () => {
56
- this.emitErrorUnlessHttp2xx(res1, this.url, this.method);
57
- if (res1.statusCode === 202 &&
58
- res1.headers.location !== undefined) {
59
- this.sendHttpRequest(res1.headers.location, 'PUT', {}, (err2, res2) => {
60
- if ((0, value_checker_1.doesHaveValue)(err2))
61
- return callback(err2);
62
- this.emitErrorUnlessHttp2xx(res2, res1.headers.location, 'PUT');
63
- callback();
64
- });
65
- }
66
- else {
67
- callback();
68
- }
69
- });
70
- });
71
- });
72
- }
73
- pushResponseBody(res, done) {
74
- let body = Buffer.alloc(0);
75
- res.on('data', (chunk) => {
76
- body = Buffer.concat([body, chunk]);
77
- });
78
- res.on('end', () => {
79
- this.push(body.toString('utf-8'));
80
- done();
81
- });
82
- }
83
- emitErrorUnlessHttp2xx(res, url, method) {
84
- if (res.statusCode >= 300)
85
- this.emit('error', new Error(`Unexpected http status ${res.statusCode} from ${method} ${url}`));
86
- }
87
- sendHttpRequest(url, method, headers, callback) {
88
- const httpx = (0, value_checker_1.doesHaveValue)(url.match(/^https:/)) ? node_https_1.default : node_http_1.default;
89
- const additionalHttpHeaders = {};
90
- const upload = method === 'PUT' || method === 'POST';
91
- if (upload) {
92
- additionalHttpHeaders['Content-Length'] = node_fs_1.default.statSync(this.tempFilePath).size;
93
- }
94
- const allHeaders = { ...headers, ...additionalHttpHeaders };
95
- const req = httpx.request(url, {
96
- method,
97
- headers: allHeaders,
98
- });
99
- req.on('error', (err) => this.emit('error', err));
100
- req.on('response', (res) => {
101
- res.on('error', (err) => this.emit('error', err));
102
- callback(null, res);
103
- });
104
- if (upload) {
105
- (0, node_stream_1.pipeline)(node_fs_1.default.createReadStream(this.tempFilePath), req, (err) => {
106
- if ((0, value_checker_1.doesHaveValue)(err)) {
107
- this.emit('error', err);
108
- }
109
- });
110
- }
111
- else {
112
- req.end();
113
- }
114
- }
115
- }
116
- exports.default = HttpStream;
117
- //# sourceMappingURL=http_stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http_stream.js","sourceRoot":"","sources":["../../src/publish/http_stream.ts"],"names":[],"mappings":";;;;;AAAA,6CAA2D;AAC3D,sDAAwB;AACxB,0DAA4B;AAC5B,4DAA8B;AAC9B,8CAAqB;AACrB,oDAAgD;AAIhD;;;;;;;;;GASG;AACH,MAAqB,UAAW,SAAQ,uBAAS;IAK5B;IACA;IACA;IANX,YAAY,CAAQ;IACpB,QAAQ,CAAU;IAE1B,YACmB,GAAW,EACX,MAAkB,EAClB,OAAiC;QAElD,KAAK,CAAC;YACJ,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAA;QANe,QAAG,GAAH,GAAG,CAAQ;QACX,WAAM,GAAN,MAAM,CAAY;QAClB,YAAO,GAAP,OAAO,CAA0B;IAKpD,CAAC;IAED,MAAM,CACJ,KAAU,EACV,QAAwB,EACxB,QAAsC;QAEtC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC/B,aAAG,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACzB,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC;oBAAE,OAAO,QAAQ,CAAC,GAAG,CAAC,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D,IAAI,MAAM,EAAE;YACV,qBAAqB,CAAC,gBAAgB,CAAC,GAAG,iBAAE,CAAC,QAAQ,CACnD,IAAI,CAAC,YAAY,CAClB,CAAC,IAAI,CAAA;SACP;QAED,MAAM,UAAU,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,qBAAqB,EAAE,CAAA;QAC3D,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;YAC7B,MAAM;YACN,OAAO,EAAE,UAAU;SACpB,CAAC,CAAA;QACF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;QACjD,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;YACjD,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACrB,CAAC,CAAC,CAAA;QAEF,IAAI,MAAM,EAAE;YACV,IAAA,sBAAQ,EAAC,iBAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;gBAC5D,IAAI,IAAA,6BAAa,EAAC,GAAG,CAAC,EAAE;oBACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;iBACxB;YACH,CAAC,CAAC,CAAA;SACH;aAAM;YACL,GAAG,CAAC,GAAG,EAAE,CAAA;SACV;IACH,CAAC;CACF;AAlID,6BAkIC","sourcesContent":["import { pipeline, Transform, Writable } from 'node:stream'\nimport fs from 'node:fs'\nimport http from 'node:http'\nimport https from 'node:https'\nimport tmp from 'tmp'\nimport { doesHaveValue } from '../value_checker'\n\ntype HttpMethod = 'GET' | 'POST' | 'PUT'\n\n/**\n * This Writable writes data to a HTTP/HTTPS URL.\n *\n * It has special handling for https://reports.cucumber.io/\n * which uses an API where the first request is a `GET`,\n * and if the response is 202 with a Location header, issues\n * a PUT request to that URL.\n *\n * 3xx redirects are not currently followed.\n */\nexport default class HttpStream extends Transform {\n private tempFilePath: string\n private tempFile: Writable\n\n constructor(\n private readonly url: string,\n private readonly method: HttpMethod,\n private readonly headers: http.OutgoingHttpHeaders\n ) {\n super({\n readableObjectMode: true,\n })\n }\n\n _write(\n chunk: any,\n encoding: BufferEncoding,\n callback: (err?: Error | null) => void\n ): void {\n if (this.tempFile === undefined) {\n tmp.file((err, name, fd) => {\n if (doesHaveValue(err)) return callback(err)\n this.tempFilePath = name\n this.tempFile = fs.createWriteStream(name, { fd })\n this.tempFile.write(chunk, encoding, callback)\n })\n } else {\n this.tempFile.write(chunk, encoding, callback)\n }\n }\n\n _final(callback: (error?: Error | null) => void): void {\n this.tempFile.end(() => {\n this.sendHttpRequest(\n this.url,\n this.method,\n this.headers,\n (err1, res1) => {\n if (doesHaveValue(err1)) return callback(err1)\n this.pushResponseBody(res1, () => {\n this.emitErrorUnlessHttp2xx(res1, this.url, this.method)\n if (\n res1.statusCode === 202 &&\n res1.headers.location !== undefined\n ) {\n this.sendHttpRequest(\n res1.headers.location,\n 'PUT',\n {},\n (err2, res2) => {\n if (doesHaveValue(err2)) return callback(err2)\n this.emitErrorUnlessHttp2xx(\n res2,\n res1.headers.location,\n 'PUT'\n )\n callback()\n }\n )\n } else {\n callback()\n }\n })\n }\n )\n })\n }\n\n private pushResponseBody(res: http.IncomingMessage, done: () => void): void {\n let body = Buffer.alloc(0)\n res.on('data', (chunk) => {\n body = Buffer.concat([body, chunk])\n })\n res.on('end', () => {\n this.push(body.toString('utf-8'))\n done()\n })\n }\n\n private emitErrorUnlessHttp2xx(\n res: http.IncomingMessage,\n url: string,\n method: string\n ): void {\n if (res.statusCode >= 300)\n this.emit(\n 'error',\n new Error(\n `Unexpected http status ${res.statusCode} from ${method} ${url}`\n )\n )\n }\n\n private sendHttpRequest(\n url: string,\n method: HttpMethod,\n headers: http.OutgoingHttpHeaders,\n callback: (err?: Error | null, res?: http.IncomingMessage) => void\n ): void {\n const httpx = doesHaveValue(url.match(/^https:/)) ? https : http\n const additionalHttpHeaders: http.OutgoingHttpHeaders = {}\n\n const upload = method === 'PUT' || method === 'POST'\n if (upload) {\n additionalHttpHeaders['Content-Length'] = fs.statSync(\n this.tempFilePath\n ).size\n }\n\n const allHeaders = { ...headers, ...additionalHttpHeaders }\n const req = httpx.request(url, {\n method,\n headers: allHeaders,\n })\n req.on('error', (err) => this.emit('error', err))\n req.on('response', (res) => {\n res.on('error', (err) => this.emit('error', err))\n callback(null, res)\n })\n\n if (upload) {\n pipeline(fs.createReadStream(this.tempFilePath), req, (err) => {\n if (doesHaveValue(err)) {\n this.emit('error', err)\n }\n })\n } else {\n req.end()\n }\n }\n}\n"]}