@platformatic/basic 2.0.0-alpha.4 → 2.0.0-alpha.6

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 (103) hide show
  1. package/NOTICE +13 -0
  2. package/README.md +13 -0
  3. package/config.d.ts +1 -149
  4. package/index.js +78 -88
  5. package/lib/base.js +13 -9
  6. package/lib/schema.js +26 -33
  7. package/lib/utils.js +1 -5
  8. package/lib/worker/child-manager.js +21 -6
  9. package/lib/worker/child-process.js +66 -0
  10. package/package.json +6 -13
  11. package/schema.json +2 -512
  12. package/test/helper.js +43 -13
  13. package/lib/next.js +0 -105
  14. package/lib/server.js +0 -134
  15. package/lib/vite.js +0 -105
  16. package/lib/worker/next-loader.js +0 -137
  17. package/test/express.test.js +0 -34
  18. package/test/fastify.test.js +0 -34
  19. package/test/fixtures/express/no-build/index.js +0 -16
  20. package/test/fixtures/express/no-build/package.json +0 -7
  21. package/test/fixtures/express/no-build/platformatic.app.json +0 -3
  22. package/test/fixtures/express/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  23. package/test/fixtures/express/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  24. package/test/fixtures/express/with-build/index.js +0 -17
  25. package/test/fixtures/express/with-build/package.json +0 -7
  26. package/test/fixtures/express/with-build/platformatic.app.json +0 -3
  27. package/test/fixtures/express/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  28. package/test/fixtures/express/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  29. package/test/fixtures/fastify/no-build/index.js +0 -14
  30. package/test/fixtures/fastify/no-build/package.json +0 -7
  31. package/test/fixtures/fastify/no-build/platformatic.app.json +0 -3
  32. package/test/fixtures/fastify/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  33. package/test/fixtures/fastify/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  34. package/test/fixtures/fastify/with-build/index.js +0 -15
  35. package/test/fixtures/fastify/with-build/package.json +0 -7
  36. package/test/fixtures/fastify/with-build/platformatic.app.json +0 -3
  37. package/test/fixtures/fastify/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  38. package/test/fixtures/fastify/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  39. package/test/fixtures/next/composer-autodetect-prefix/next.config.mjs +0 -5
  40. package/test/fixtures/next/composer-autodetect-prefix/package.json +0 -15
  41. package/test/fixtures/next/composer-autodetect-prefix/platformatic.application.json +0 -8
  42. package/test/fixtures/next/composer-autodetect-prefix/platformatic.runtime.json +0 -21
  43. package/test/fixtures/next/composer-autodetect-prefix/src/app/layout.js +0 -7
  44. package/test/fixtures/next/composer-autodetect-prefix/src/app/page.js +0 -5
  45. package/test/fixtures/next/composer-with-prefix/next.config.js +0 -1
  46. package/test/fixtures/next/composer-with-prefix/package.json +0 -15
  47. package/test/fixtures/next/composer-with-prefix/platformatic.application.json +0 -11
  48. package/test/fixtures/next/composer-with-prefix/platformatic.runtime.json +0 -21
  49. package/test/fixtures/next/composer-with-prefix/src/app/layout.js +0 -7
  50. package/test/fixtures/next/composer-with-prefix/src/app/page.js +0 -5
  51. package/test/fixtures/next/composer-without-prefix/next.config.mjs +0 -3
  52. package/test/fixtures/next/composer-without-prefix/package.json +0 -15
  53. package/test/fixtures/next/composer-without-prefix/platformatic.application.json +0 -8
  54. package/test/fixtures/next/composer-without-prefix/platformatic.runtime.json +0 -21
  55. package/test/fixtures/next/composer-without-prefix/src/app/layout.js +0 -7
  56. package/test/fixtures/next/composer-without-prefix/src/app/page.js +0 -5
  57. package/test/fixtures/next/standalone/next.config.mjs +0 -3
  58. package/test/fixtures/next/standalone/package.json +0 -15
  59. package/test/fixtures/next/standalone/platformatic.runtime.json +0 -18
  60. package/test/fixtures/next/standalone/src/app/layout.js +0 -7
  61. package/test/fixtures/next/standalone/src/app/page.js +0 -5
  62. package/test/fixtures/nodejs/no-build/index.js +0 -21
  63. package/test/fixtures/nodejs/no-build/package.json +0 -7
  64. package/test/fixtures/nodejs/no-build/platformatic.app.json +0 -3
  65. package/test/fixtures/nodejs/no-build/platformatic.as-entrypoint.runtime.json +0 -19
  66. package/test/fixtures/nodejs/no-build/platformatic.no-entrypoint.runtime.json +0 -16
  67. package/test/fixtures/nodejs/no-configuration/index.js +0 -21
  68. package/test/fixtures/nodejs/no-configuration/platformatic.as-entrypoint.runtime.json +0 -18
  69. package/test/fixtures/nodejs/no-configuration/platformatic.no-entrypoint.runtime.json +0 -16
  70. package/test/fixtures/nodejs/with-build/index.js +0 -20
  71. package/test/fixtures/nodejs/with-build/package.json +0 -7
  72. package/test/fixtures/nodejs/with-build/platformatic.app.json +0 -3
  73. package/test/fixtures/nodejs/with-build/platformatic.as-entrypoint.runtime.json +0 -19
  74. package/test/fixtures/nodejs/with-build/platformatic.no-entrypoint.runtime.json +0 -16
  75. package/test/fixtures/platformatic-composer/platformatic.composer.json +0 -20
  76. package/test/fixtures/platformatic-composer/platformatic.no-prefix.composer.json +0 -23
  77. package/test/fixtures/platformatic-composer/plugin.js +0 -9
  78. package/test/fixtures/platformatic-service/platformatic.service.json +0 -15
  79. package/test/fixtures/platformatic-service/plugin.js +0 -12
  80. package/test/fixtures/vite/composer-autodetect-prefix/custom.vite.config.js +0 -3
  81. package/test/fixtures/vite/composer-autodetect-prefix/index.html +0 -13
  82. package/test/fixtures/vite/composer-autodetect-prefix/main.js +0 -3
  83. package/test/fixtures/vite/composer-autodetect-prefix/package.json +0 -14
  84. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.application.json +0 -11
  85. package/test/fixtures/vite/composer-autodetect-prefix/platformatic.runtime.json +0 -21
  86. package/test/fixtures/vite/composer-with-prefix/index.html +0 -13
  87. package/test/fixtures/vite/composer-with-prefix/main.js +0 -3
  88. package/test/fixtures/vite/composer-with-prefix/package.json +0 -14
  89. package/test/fixtures/vite/composer-with-prefix/platformatic.application.json +0 -11
  90. package/test/fixtures/vite/composer-with-prefix/platformatic.runtime.json +0 -21
  91. package/test/fixtures/vite/composer-without-prefix/index.html +0 -13
  92. package/test/fixtures/vite/composer-without-prefix/main.js +0 -3
  93. package/test/fixtures/vite/composer-without-prefix/package.json +0 -14
  94. package/test/fixtures/vite/composer-without-prefix/platformatic.application.json +0 -8
  95. package/test/fixtures/vite/composer-without-prefix/platformatic.runtime.json +0 -21
  96. package/test/fixtures/vite/standalone/custom.vite.config.js +0 -3
  97. package/test/fixtures/vite/standalone/index.html +0 -13
  98. package/test/fixtures/vite/standalone/main.js +0 -3
  99. package/test/fixtures/vite/standalone/package.json +0 -14
  100. package/test/fixtures/vite/standalone/platformatic.runtime.json +0 -18
  101. package/test/next.test.js +0 -85
  102. package/test/node.test.js +0 -66
  103. package/test/vite.test.js +0 -89
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/basic",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,17 +15,13 @@
15
15
  },
16
16
  "homepage": "https://github.com/platformatic/platformatic#readme",
17
17
  "dependencies": {
18
- "@babel/generator": "^7.25.0",
19
- "@babel/parser": "^7.25.3",
20
- "@babel/traverse": "^7.25.3",
21
- "@babel/types": "^7.25.2",
22
18
  "@fastify/error": "^4.0.0",
23
- "light-my-request": "^5.13.0",
24
19
  "pino": "^9.3.2",
25
20
  "semver": "^7.6.3",
26
21
  "undici": "^6.19.5",
27
- "@platformatic/config": "2.0.0-alpha.4",
28
- "@platformatic/itc": "2.0.0-alpha.4"
22
+ "@platformatic/config": "2.0.0-alpha.6",
23
+ "@platformatic/itc": "2.0.0-alpha.6",
24
+ "@platformatic/utils": "2.0.0-alpha.6"
29
25
  },
30
26
  "devDependencies": {
31
27
  "borp": "^0.17.0",
@@ -40,13 +36,10 @@
40
36
  "typescript": "^5.5.4",
41
37
  "vite": "^5.4.0",
42
38
  "ws": "^8.18.0",
43
- "@platformatic/composer": "2.0.0-alpha.4",
44
- "@platformatic/utils": "2.0.0-alpha.4",
45
- "@platformatic/service": "2.0.0-alpha.4"
39
+ "@platformatic/composer": "2.0.0-alpha.6",
40
+ "@platformatic/service": "2.0.0-alpha.6"
46
41
  },
47
42
  "scripts": {
48
- "test": "npm run lint && borp --concurrency=1 --timeout=180000",
49
- "coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout=180000",
50
43
  "gen-schema": "node lib/schema.js > schema.json",
51
44
  "gen-types": "json2ts > config.d.ts < schema.json",
52
45
  "build": "pnpm run gen-schema && pnpm run gen-types",
package/schema.json CHANGED
@@ -1,522 +1,12 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.4.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/basic/2.0.0-alpha.6.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Stackable",
5
5
  "type": "object",
6
6
  "properties": {
7
7
  "$schema": {
8
8
  "type": "string"
9
- },
10
- "server": {
11
- "type": "object",
12
- "properties": {
13
- "hostname": {
14
- "type": "string"
15
- },
16
- "port": {
17
- "anyOf": [
18
- {
19
- "type": "integer"
20
- },
21
- {
22
- "type": "string"
23
- }
24
- ]
25
- },
26
- "pluginTimeout": {
27
- "type": "integer"
28
- },
29
- "healthCheck": {
30
- "anyOf": [
31
- {
32
- "type": "boolean"
33
- },
34
- {
35
- "type": "object",
36
- "properties": {
37
- "enabled": {
38
- "type": "boolean"
39
- },
40
- "interval": {
41
- "type": "integer"
42
- }
43
- },
44
- "additionalProperties": true
45
- }
46
- ]
47
- },
48
- "ignoreTrailingSlash": {
49
- "type": "boolean"
50
- },
51
- "ignoreDuplicateSlashes": {
52
- "type": "boolean"
53
- },
54
- "connectionTimeout": {
55
- "type": "integer"
56
- },
57
- "keepAliveTimeout": {
58
- "type": "integer",
59
- "default": 5000
60
- },
61
- "maxRequestsPerSocket": {
62
- "type": "integer"
63
- },
64
- "forceCloseConnections": {
65
- "anyOf": [
66
- {
67
- "type": "boolean"
68
- },
69
- {
70
- "type": "string",
71
- "pattern": "^idle$"
72
- }
73
- ]
74
- },
75
- "requestTimeout": {
76
- "type": "integer"
77
- },
78
- "bodyLimit": {
79
- "type": "integer"
80
- },
81
- "maxParamLength": {
82
- "type": "integer"
83
- },
84
- "disableRequestLogging": {
85
- "type": "boolean"
86
- },
87
- "exposeHeadRoutes": {
88
- "type": "boolean"
89
- },
90
- "logger": {
91
- "anyOf": [
92
- {
93
- "type": "boolean"
94
- },
95
- {
96
- "type": "object",
97
- "properties": {
98
- "level": {
99
- "type": "string"
100
- },
101
- "transport": {
102
- "anyOf": [
103
- {
104
- "type": "object",
105
- "properties": {
106
- "target": {
107
- "type": "string",
108
- "resolveModule": true
109
- },
110
- "options": {
111
- "type": "object"
112
- }
113
- },
114
- "additionalProperties": false
115
- },
116
- {
117
- "type": "object",
118
- "properties": {
119
- "targets": {
120
- "type": "array",
121
- "items": {
122
- "type": "object",
123
- "properties": {
124
- "target": {
125
- "type": "string",
126
- "resolveModule": true
127
- },
128
- "options": {
129
- "type": "object"
130
- },
131
- "level": {
132
- "type": "string"
133
- },
134
- "additionalProperties": false
135
- }
136
- }
137
- },
138
- "options": {
139
- "type": "object"
140
- }
141
- },
142
- "additionalProperties": false
143
- }
144
- ]
145
- },
146
- "pipeline": {
147
- "type": "object",
148
- "properties": {
149
- "target": {
150
- "type": "string",
151
- "resolveModule": true
152
- },
153
- "options": {
154
- "type": "object"
155
- }
156
- },
157
- "additionalProperties": false
158
- }
159
- },
160
- "additionalProperties": true
161
- }
162
- ]
163
- },
164
- "serializerOpts": {
165
- "type": "object",
166
- "properties": {
167
- "schema": {
168
- "type": "object"
169
- },
170
- "ajv": {
171
- "type": "object"
172
- },
173
- "rounding": {
174
- "type": "string",
175
- "enum": [
176
- "floor",
177
- "ceil",
178
- "round",
179
- "trunc"
180
- ],
181
- "default": "trunc"
182
- },
183
- "debugMode": {
184
- "type": "boolean"
185
- },
186
- "mode": {
187
- "type": "string",
188
- "enum": [
189
- "debug",
190
- "standalone"
191
- ]
192
- },
193
- "largeArraySize": {
194
- "anyOf": [
195
- {
196
- "type": "integer"
197
- },
198
- {
199
- "type": "string"
200
- }
201
- ],
202
- "default": 20000
203
- },
204
- "largeArrayMechanism": {
205
- "type": "string",
206
- "enum": [
207
- "default",
208
- "json-stringify"
209
- ],
210
- "default": "default"
211
- }
212
- }
213
- },
214
- "caseSensitive": {
215
- "type": "boolean"
216
- },
217
- "requestIdHeader": {
218
- "anyOf": [
219
- {
220
- "type": "string"
221
- },
222
- {
223
- "type": "boolean",
224
- "const": false
225
- }
226
- ]
227
- },
228
- "requestIdLogLabel": {
229
- "type": "string"
230
- },
231
- "jsonShorthand": {
232
- "type": "boolean"
233
- },
234
- "trustProxy": {
235
- "anyOf": [
236
- {
237
- "type": "boolean"
238
- },
239
- {
240
- "type": "string"
241
- },
242
- {
243
- "type": "array",
244
- "items": {
245
- "type": "string"
246
- }
247
- },
248
- {
249
- "type": "integer"
250
- }
251
- ]
252
- },
253
- "http2": {
254
- "type": "boolean"
255
- },
256
- "https": {
257
- "type": "object",
258
- "properties": {
259
- "allowHTTP1": {
260
- "type": "boolean"
261
- },
262
- "key": {
263
- "anyOf": [
264
- {
265
- "type": "string"
266
- },
267
- {
268
- "type": "object",
269
- "properties": {
270
- "path": {
271
- "type": "string",
272
- "resolvePath": true
273
- }
274
- },
275
- "additionalProperties": false
276
- },
277
- {
278
- "type": "array",
279
- "items": {
280
- "anyOf": [
281
- {
282
- "type": "string"
283
- },
284
- {
285
- "type": "object",
286
- "properties": {
287
- "path": {
288
- "type": "string",
289
- "resolvePath": true
290
- }
291
- },
292
- "additionalProperties": false
293
- }
294
- ]
295
- }
296
- }
297
- ]
298
- },
299
- "cert": {
300
- "anyOf": [
301
- {
302
- "type": "string"
303
- },
304
- {
305
- "type": "object",
306
- "properties": {
307
- "path": {
308
- "type": "string",
309
- "resolvePath": true
310
- }
311
- },
312
- "additionalProperties": false
313
- },
314
- {
315
- "type": "array",
316
- "items": {
317
- "anyOf": [
318
- {
319
- "type": "string"
320
- },
321
- {
322
- "type": "object",
323
- "properties": {
324
- "path": {
325
- "type": "string",
326
- "resolvePath": true
327
- }
328
- },
329
- "additionalProperties": false
330
- }
331
- ]
332
- }
333
- }
334
- ]
335
- },
336
- "requestCert": {
337
- "type": "boolean"
338
- },
339
- "rejectUnauthorized": {
340
- "type": "boolean"
341
- }
342
- },
343
- "additionalProperties": false,
344
- "required": [
345
- "key",
346
- "cert"
347
- ]
348
- },
349
- "cors": {
350
- "type": "object",
351
- "$comment": "See https://github.com/fastify/fastify-cors",
352
- "properties": {
353
- "origin": {
354
- "anyOf": [
355
- {
356
- "type": "boolean"
357
- },
358
- {
359
- "type": "string"
360
- },
361
- {
362
- "type": "array",
363
- "items": {
364
- "anyOf": [
365
- {
366
- "type": "string"
367
- },
368
- {
369
- "type": "object",
370
- "properties": {
371
- "regexp": {
372
- "type": "string"
373
- }
374
- },
375
- "required": [
376
- "regexp"
377
- ]
378
- }
379
- ]
380
- }
381
- },
382
- {
383
- "type": "object",
384
- "properties": {
385
- "regexp": {
386
- "type": "string"
387
- }
388
- },
389
- "required": [
390
- "regexp"
391
- ]
392
- }
393
- ]
394
- },
395
- "methods": {
396
- "type": "array",
397
- "items": {
398
- "type": "string"
399
- }
400
- },
401
- "allowedHeaders": {
402
- "type": "string",
403
- "description": "Comma separated string of allowed headers."
404
- },
405
- "exposedHeaders": {
406
- "anyOf": [
407
- {
408
- "type": "array",
409
- "items": {
410
- "type": "string"
411
- }
412
- },
413
- {
414
- "type": "string",
415
- "description": "Comma separated string of exposed headers."
416
- }
417
- ]
418
- },
419
- "credentials": {
420
- "type": "boolean"
421
- },
422
- "maxAge": {
423
- "type": "integer"
424
- },
425
- "preflightContinue": {
426
- "type": "boolean",
427
- "default": false
428
- },
429
- "optionsSuccessStatus": {
430
- "type": "integer",
431
- "default": 204
432
- },
433
- "preflight": {
434
- "type": "boolean",
435
- "default": true
436
- },
437
- "strictPreflight": {
438
- "type": "boolean",
439
- "default": true
440
- },
441
- "hideOptionsRoute": {
442
- "type": "boolean",
443
- "default": true
444
- }
445
- },
446
- "additionalProperties": false
447
- }
448
- },
449
- "additionalProperties": false
450
- },
451
- "watch": {
452
- "anyOf": [
453
- {
454
- "type": "object",
455
- "properties": {
456
- "enabled": {
457
- "default": true,
458
- "anyOf": [
459
- {
460
- "type": "boolean"
461
- },
462
- {
463
- "type": "string"
464
- }
465
- ]
466
- },
467
- "allow": {
468
- "type": "array",
469
- "items": {
470
- "type": "string"
471
- },
472
- "minItems": 1,
473
- "nullable": true,
474
- "default": null
475
- },
476
- "ignore": {
477
- "type": "array",
478
- "items": {
479
- "type": "string"
480
- },
481
- "nullable": true,
482
- "default": null
483
- }
484
- },
485
- "additionalProperties": false
486
- },
487
- {
488
- "type": "boolean"
489
- },
490
- {
491
- "type": "string"
492
- }
493
- ]
494
- },
495
- "application": {
496
- "type": "object",
497
- "properties": {
498
- "base": {
499
- "type": "string"
500
- }
501
- },
502
- "additionalProperties": false
503
- },
504
- "vite": {
505
- "type": "object",
506
- "properties": {
507
- "configFile": {
508
- "oneOf": [
509
- {
510
- "type": "string"
511
- },
512
- {
513
- "type": "boolean"
514
- }
515
- ]
516
- }
517
- },
518
- "additionalProperties": false
519
9
  }
520
10
  },
521
- "additionalProperties": false
11
+ "additionalProperties": true
522
12
  }
package/test/helper.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createDirectory, withResolvers } from '@platformatic/utils'
2
2
  import { deepStrictEqual, ok, strictEqual } from 'node:assert'
3
- import { writeFile } from 'node:fs/promises'
3
+ import { existsSync } from 'node:fs'
4
+ import { readFile, symlink, writeFile } from 'node:fs/promises'
4
5
  import { dirname, resolve } from 'node:path'
5
6
  import { setTimeout as sleep } from 'node:timers/promises'
6
7
  import { Client, request } from 'undici'
@@ -10,11 +11,40 @@ import { buildServer, platformaticRuntime } from '../../runtime/index.js'
10
11
 
11
12
  export { setTimeout as sleep } from 'node:timers/promises'
12
13
 
14
+ const HMR_TIMEOUT = process.env.CI ? 20000 : 10000
13
15
  let hrmVersion = Date.now()
14
- export const fixturesDir = resolve(import.meta.dirname, './fixtures')
16
+ export let fixturesDir
15
17
 
16
- export async function createRuntime (t, path) {
18
+ export function setFixturesDir (directory) {
19
+ fixturesDir = directory
20
+ }
21
+
22
+ // This is used to debug tests
23
+ export function pause (url, timeout = 300000) {
24
+ console.log(`Server is listening at ${url}`)
25
+ return sleep(timeout)
26
+ }
27
+
28
+ export async function ensureDependency (directory, pkg, source) {
29
+ const [namespace, name] = pkg.includes('/') ? pkg.split('/') : ['', pkg]
30
+ const basedir = resolve(fixturesDir, directory, `node_modules/${namespace}`)
31
+ const destination = resolve(basedir, name)
32
+
33
+ await createDirectory(basedir)
34
+ if (!existsSync(destination)) {
35
+ await symlink(source, destination, 'dir')
36
+ }
37
+ }
38
+
39
+ export async function createRuntime (t, path, packageRoot) {
17
40
  const configFile = resolve(fixturesDir, path)
41
+
42
+ if (packageRoot) {
43
+ const packageName = JSON.parse(await readFile(resolve(packageRoot, 'package.json'), 'utf-8')).name
44
+ const root = dirname(configFile)
45
+ await ensureDependency(root, packageName, packageRoot)
46
+ }
47
+
18
48
  const config = await loadConfig({}, ['-c', configFile], platformaticRuntime)
19
49
  const runtime = await buildServer(config.configManager.current)
20
50
  const url = await runtime.start()
@@ -30,12 +60,12 @@ export async function getLogs (app) {
30
60
  const client = new Client(
31
61
  {
32
62
  hostname: 'localhost',
33
- protocol: 'http:',
63
+ protocol: 'http:'
34
64
  },
35
65
  {
36
66
  socketPath: app.getManagementApiUrl(),
37
67
  keepAliveTimeout: 10,
38
- keepAliveMaxTimeout: 10,
68
+ keepAliveMaxTimeout: 10
39
69
  }
40
70
  )
41
71
 
@@ -44,7 +74,7 @@ export async function getLogs (app) {
44
74
 
45
75
  const { statusCode, body } = await client.request({
46
76
  method: 'GET',
47
- path: '/api/v1/logs/all',
77
+ path: '/api/v1/logs/all'
48
78
  })
49
79
 
50
80
  strictEqual(statusCode, 200)
@@ -58,8 +88,8 @@ export async function getLogs (app) {
58
88
  .map(m => JSON.parse(m))
59
89
  }
60
90
 
61
- export async function updateHMRVersion () {
62
- const versionFile = resolve(fixturesDir, '../tmp/version.js')
91
+ export async function updateHMRVersion (versionFile) {
92
+ versionFile ??= resolve(fixturesDir, '../tmp/version.js')
63
93
  await createDirectory(dirname(versionFile))
64
94
  await writeFile(versionFile, `export const version = ${hrmVersion++}\n`, 'utf-8')
65
95
  }
@@ -81,10 +111,10 @@ export async function verifyHTMLViaHTTP (baseUrl, path, contents) {
81
111
  const html = await body.text()
82
112
 
83
113
  deepStrictEqual(statusCode, 200)
84
- ok(headers['content-type'].startsWith('text/html'))
114
+ ok(headers['content-type']?.startsWith('text/html'))
85
115
 
86
116
  for (const content of contents) {
87
- ok(html.includes(content))
117
+ ok(content instanceof RegExp ? content.test(html) : html.includes(content), content)
88
118
  }
89
119
  }
90
120
 
@@ -95,15 +125,15 @@ export async function verifyHTMLViaInject (app, serviceId, url, contents) {
95
125
  ok(headers['content-type'].startsWith('text/html'))
96
126
 
97
127
  for (const content of contents) {
98
- ok(html.includes(content))
128
+ ok(content instanceof RegExp ? content.test(html) : html.includes(content), content)
99
129
  }
100
130
  }
101
131
 
102
- export async function verifyHMR (baseUrl, path, versionFile, protocol, handler) {
132
+ export async function verifyHMR (baseUrl, path, protocol, handler) {
103
133
  const connection = withResolvers()
104
134
  const reload = withResolvers()
105
135
  const ac = new AbortController()
106
- const timeout = sleep(10000, 'timeout', { signal: ac.signal })
136
+ const timeout = sleep(HMR_TIMEOUT, 'timeout', { signal: ac.signal })
107
137
 
108
138
  const url = baseUrl.replace('http:', 'ws:') + path
109
139
  const webSocket = new WebSocket(url, protocol)