@jsenv/core 30.4.2 → 31.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.
- package/dist/js/supervisor.js +1 -1
- package/dist/js/v8_coverage.js +29 -22
- package/dist/main.js +533 -809
- package/package.json +5 -5
- package/src/build/build.js +26 -3
- package/src/build/start_build_server.js +2 -6
- package/src/dev/start_dev_server.js +28 -15
- package/src/execute/execute.js +1 -1
- package/src/execute/run.js +2 -2
- package/src/execute/runtimes/browsers/from_playwright.js +5 -5
- package/src/execute/runtimes/node/node_child_process.js +6 -6
- package/src/execute/runtimes/node/node_worker_thread.js +6 -6
- package/src/plugins/supervisor/client/supervisor.js +1 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_library.js +1 -4
- package/src/test/execute_plan.js +4 -4
- package/src/test/execute_test_plan.js +57 -39
- package/src/test/execution_colors.js +1 -1
- package/src/test/logs_file_execution.js +7 -7
package/dist/main.js
CHANGED
|
@@ -9,9 +9,9 @@ import os, { networkInterfaces } from "node:os";
|
|
|
9
9
|
import tty from "node:tty";
|
|
10
10
|
import stringWidth from "string-width";
|
|
11
11
|
import net, { createServer, isIP } from "node:net";
|
|
12
|
-
import http from "node:http";
|
|
13
12
|
import cluster from "node:cluster";
|
|
14
13
|
import { performance as performance$1 } from "node:perf_hooks";
|
|
14
|
+
import http from "node:http";
|
|
15
15
|
import { Readable, Stream, Writable } from "node:stream";
|
|
16
16
|
import { Http2ServerResponse } from "node:http2";
|
|
17
17
|
import { lookup } from "node:dns";
|
|
@@ -592,7 +592,7 @@ const urlToFileSystemPath = url => {
|
|
|
592
592
|
return fileSystemPath;
|
|
593
593
|
};
|
|
594
594
|
|
|
595
|
-
const
|
|
595
|
+
const validateDirectoryUrl = value => {
|
|
596
596
|
let urlString;
|
|
597
597
|
if (value instanceof URL) {
|
|
598
598
|
urlString = value.href;
|
|
@@ -603,19 +603,45 @@ const assertAndNormalizeDirectoryUrl = value => {
|
|
|
603
603
|
try {
|
|
604
604
|
urlString = String(new URL(value));
|
|
605
605
|
} catch (e) {
|
|
606
|
-
|
|
606
|
+
return {
|
|
607
|
+
valid: false,
|
|
608
|
+
value,
|
|
609
|
+
message: `must be a valid url`
|
|
610
|
+
};
|
|
607
611
|
}
|
|
608
612
|
}
|
|
609
613
|
} else {
|
|
610
|
-
|
|
614
|
+
return {
|
|
615
|
+
valid: false,
|
|
616
|
+
value,
|
|
617
|
+
message: `must be a string or an url`
|
|
618
|
+
};
|
|
611
619
|
}
|
|
612
620
|
if (!urlString.startsWith("file://")) {
|
|
613
|
-
|
|
621
|
+
return {
|
|
622
|
+
valid: false,
|
|
623
|
+
value,
|
|
624
|
+
message: 'must start with "file://"'
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
valid: true,
|
|
629
|
+
value: ensurePathnameTrailingSlash(urlString)
|
|
630
|
+
};
|
|
631
|
+
};
|
|
632
|
+
const assertAndNormalizeDirectoryUrl = directoryUrl => {
|
|
633
|
+
const {
|
|
634
|
+
valid,
|
|
635
|
+
message,
|
|
636
|
+
value
|
|
637
|
+
} = validateDirectoryUrl(directoryUrl);
|
|
638
|
+
if (!valid) {
|
|
639
|
+
throw new TypeError(`directoryUrl ${message}, got ${value}`);
|
|
614
640
|
}
|
|
615
|
-
return
|
|
641
|
+
return value;
|
|
616
642
|
};
|
|
617
643
|
|
|
618
|
-
const
|
|
644
|
+
const validateFileUrl = (value, baseUrl) => {
|
|
619
645
|
let urlString;
|
|
620
646
|
if (value instanceof URL) {
|
|
621
647
|
urlString = value.href;
|
|
@@ -626,16 +652,42 @@ const assertAndNormalizeFileUrl = (value, baseUrl) => {
|
|
|
626
652
|
try {
|
|
627
653
|
urlString = String(new URL(value, baseUrl));
|
|
628
654
|
} catch (e) {
|
|
629
|
-
|
|
655
|
+
return {
|
|
656
|
+
valid: false,
|
|
657
|
+
value,
|
|
658
|
+
message: "must be a valid url"
|
|
659
|
+
};
|
|
630
660
|
}
|
|
631
661
|
}
|
|
632
662
|
} else {
|
|
633
|
-
|
|
663
|
+
return {
|
|
664
|
+
valid: false,
|
|
665
|
+
value,
|
|
666
|
+
message: "must be a string or an url"
|
|
667
|
+
};
|
|
634
668
|
}
|
|
635
669
|
if (!urlString.startsWith("file://")) {
|
|
636
|
-
|
|
670
|
+
return {
|
|
671
|
+
valid: false,
|
|
672
|
+
value,
|
|
673
|
+
message: 'must start with "file://"'
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
return {
|
|
677
|
+
valid: true,
|
|
678
|
+
value: urlString
|
|
679
|
+
};
|
|
680
|
+
};
|
|
681
|
+
const assertAndNormalizeFileUrl = (fileUrl, baseUrl) => {
|
|
682
|
+
const {
|
|
683
|
+
valid,
|
|
684
|
+
message,
|
|
685
|
+
value
|
|
686
|
+
} = validateFileUrl(fileUrl, baseUrl);
|
|
687
|
+
if (!valid) {
|
|
688
|
+
throw new TypeError(`fileUrl ${message}, got ${fileUrl}`);
|
|
637
689
|
}
|
|
638
|
-
return
|
|
690
|
+
return value;
|
|
639
691
|
};
|
|
640
692
|
|
|
641
693
|
const statsToType = stats => {
|
|
@@ -2264,16 +2316,16 @@ const writeFileSync = (destination, content = "") => {
|
|
|
2264
2316
|
}
|
|
2265
2317
|
};
|
|
2266
2318
|
|
|
2267
|
-
const LOG_LEVEL_OFF
|
|
2268
|
-
const LOG_LEVEL_DEBUG
|
|
2269
|
-
const LOG_LEVEL_INFO
|
|
2270
|
-
const LOG_LEVEL_WARN
|
|
2271
|
-
const LOG_LEVEL_ERROR
|
|
2319
|
+
const LOG_LEVEL_OFF = "off";
|
|
2320
|
+
const LOG_LEVEL_DEBUG = "debug";
|
|
2321
|
+
const LOG_LEVEL_INFO = "info";
|
|
2322
|
+
const LOG_LEVEL_WARN = "warn";
|
|
2323
|
+
const LOG_LEVEL_ERROR = "error";
|
|
2272
2324
|
|
|
2273
|
-
const createLogger
|
|
2274
|
-
logLevel = LOG_LEVEL_INFO
|
|
2325
|
+
const createLogger = ({
|
|
2326
|
+
logLevel = LOG_LEVEL_INFO
|
|
2275
2327
|
} = {}) => {
|
|
2276
|
-
if (logLevel === LOG_LEVEL_DEBUG
|
|
2328
|
+
if (logLevel === LOG_LEVEL_DEBUG) {
|
|
2277
2329
|
return {
|
|
2278
2330
|
level: "debug",
|
|
2279
2331
|
levels: {
|
|
@@ -2282,13 +2334,13 @@ const createLogger$1 = ({
|
|
|
2282
2334
|
warn: true,
|
|
2283
2335
|
error: true
|
|
2284
2336
|
},
|
|
2285
|
-
debug
|
|
2286
|
-
info
|
|
2287
|
-
warn
|
|
2288
|
-
error
|
|
2337
|
+
debug,
|
|
2338
|
+
info,
|
|
2339
|
+
warn,
|
|
2340
|
+
error
|
|
2289
2341
|
};
|
|
2290
2342
|
}
|
|
2291
|
-
if (logLevel === LOG_LEVEL_INFO
|
|
2343
|
+
if (logLevel === LOG_LEVEL_INFO) {
|
|
2292
2344
|
return {
|
|
2293
2345
|
level: "info",
|
|
2294
2346
|
levels: {
|
|
@@ -2297,13 +2349,13 @@ const createLogger$1 = ({
|
|
|
2297
2349
|
warn: true,
|
|
2298
2350
|
error: true
|
|
2299
2351
|
},
|
|
2300
|
-
debug: debugDisabled
|
|
2301
|
-
info
|
|
2302
|
-
warn
|
|
2303
|
-
error
|
|
2352
|
+
debug: debugDisabled,
|
|
2353
|
+
info,
|
|
2354
|
+
warn,
|
|
2355
|
+
error
|
|
2304
2356
|
};
|
|
2305
2357
|
}
|
|
2306
|
-
if (logLevel === LOG_LEVEL_WARN
|
|
2358
|
+
if (logLevel === LOG_LEVEL_WARN) {
|
|
2307
2359
|
return {
|
|
2308
2360
|
level: "warn",
|
|
2309
2361
|
levels: {
|
|
@@ -2312,13 +2364,13 @@ const createLogger$1 = ({
|
|
|
2312
2364
|
warn: true,
|
|
2313
2365
|
error: true
|
|
2314
2366
|
},
|
|
2315
|
-
debug: debugDisabled
|
|
2316
|
-
info: infoDisabled
|
|
2317
|
-
warn
|
|
2318
|
-
error
|
|
2367
|
+
debug: debugDisabled,
|
|
2368
|
+
info: infoDisabled,
|
|
2369
|
+
warn,
|
|
2370
|
+
error
|
|
2319
2371
|
};
|
|
2320
2372
|
}
|
|
2321
|
-
if (logLevel === LOG_LEVEL_ERROR
|
|
2373
|
+
if (logLevel === LOG_LEVEL_ERROR) {
|
|
2322
2374
|
return {
|
|
2323
2375
|
level: "error",
|
|
2324
2376
|
levels: {
|
|
@@ -2327,13 +2379,13 @@ const createLogger$1 = ({
|
|
|
2327
2379
|
warn: false,
|
|
2328
2380
|
error: true
|
|
2329
2381
|
},
|
|
2330
|
-
debug: debugDisabled
|
|
2331
|
-
info: infoDisabled
|
|
2332
|
-
warn: warnDisabled
|
|
2333
|
-
error
|
|
2382
|
+
debug: debugDisabled,
|
|
2383
|
+
info: infoDisabled,
|
|
2384
|
+
warn: warnDisabled,
|
|
2385
|
+
error
|
|
2334
2386
|
};
|
|
2335
2387
|
}
|
|
2336
|
-
if (logLevel === LOG_LEVEL_OFF
|
|
2388
|
+
if (logLevel === LOG_LEVEL_OFF) {
|
|
2337
2389
|
return {
|
|
2338
2390
|
level: "off",
|
|
2339
2391
|
levels: {
|
|
@@ -2342,60 +2394,60 @@ const createLogger$1 = ({
|
|
|
2342
2394
|
warn: false,
|
|
2343
2395
|
error: false
|
|
2344
2396
|
},
|
|
2345
|
-
debug: debugDisabled
|
|
2346
|
-
info: infoDisabled
|
|
2347
|
-
warn: warnDisabled
|
|
2348
|
-
error: errorDisabled
|
|
2397
|
+
debug: debugDisabled,
|
|
2398
|
+
info: infoDisabled,
|
|
2399
|
+
warn: warnDisabled,
|
|
2400
|
+
error: errorDisabled
|
|
2349
2401
|
};
|
|
2350
2402
|
}
|
|
2351
2403
|
throw new Error(`unexpected logLevel.
|
|
2352
2404
|
--- logLevel ---
|
|
2353
2405
|
${logLevel}
|
|
2354
2406
|
--- allowed log levels ---
|
|
2355
|
-
${LOG_LEVEL_OFF
|
|
2356
|
-
${LOG_LEVEL_ERROR
|
|
2357
|
-
${LOG_LEVEL_WARN
|
|
2358
|
-
${LOG_LEVEL_INFO
|
|
2359
|
-
${LOG_LEVEL_DEBUG
|
|
2360
|
-
};
|
|
2361
|
-
const debug
|
|
2362
|
-
const debugDisabled
|
|
2363
|
-
const info
|
|
2364
|
-
const infoDisabled
|
|
2365
|
-
const warn
|
|
2366
|
-
const warnDisabled
|
|
2367
|
-
const error
|
|
2368
|
-
const errorDisabled
|
|
2407
|
+
${LOG_LEVEL_OFF}
|
|
2408
|
+
${LOG_LEVEL_ERROR}
|
|
2409
|
+
${LOG_LEVEL_WARN}
|
|
2410
|
+
${LOG_LEVEL_INFO}
|
|
2411
|
+
${LOG_LEVEL_DEBUG}`);
|
|
2412
|
+
};
|
|
2413
|
+
const debug = (...args) => console.debug(...args);
|
|
2414
|
+
const debugDisabled = () => {};
|
|
2415
|
+
const info = (...args) => console.info(...args);
|
|
2416
|
+
const infoDisabled = () => {};
|
|
2417
|
+
const warn = (...args) => console.warn(...args);
|
|
2418
|
+
const warnDisabled = () => {};
|
|
2419
|
+
const error = (...args) => console.error(...args);
|
|
2420
|
+
const errorDisabled = () => {};
|
|
2369
2421
|
|
|
2370
2422
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
2371
2423
|
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
2372
|
-
function hasFlag
|
|
2424
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
|
|
2373
2425
|
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
2374
2426
|
const position = argv.indexOf(prefix + flag);
|
|
2375
2427
|
const terminatorPosition = argv.indexOf('--');
|
|
2376
2428
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2377
2429
|
}
|
|
2378
2430
|
const {
|
|
2379
|
-
env
|
|
2431
|
+
env
|
|
2380
2432
|
} = process$1;
|
|
2381
|
-
let flagForceColor
|
|
2382
|
-
if (hasFlag
|
|
2383
|
-
flagForceColor
|
|
2384
|
-
} else if (hasFlag
|
|
2385
|
-
flagForceColor
|
|
2433
|
+
let flagForceColor;
|
|
2434
|
+
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
2435
|
+
flagForceColor = 0;
|
|
2436
|
+
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
2437
|
+
flagForceColor = 1;
|
|
2386
2438
|
}
|
|
2387
|
-
function envForceColor
|
|
2388
|
-
if ('FORCE_COLOR' in env
|
|
2389
|
-
if (env
|
|
2439
|
+
function envForceColor() {
|
|
2440
|
+
if ('FORCE_COLOR' in env) {
|
|
2441
|
+
if (env.FORCE_COLOR === 'true') {
|
|
2390
2442
|
return 1;
|
|
2391
2443
|
}
|
|
2392
|
-
if (env
|
|
2444
|
+
if (env.FORCE_COLOR === 'false') {
|
|
2393
2445
|
return 0;
|
|
2394
2446
|
}
|
|
2395
|
-
return env
|
|
2447
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
2396
2448
|
}
|
|
2397
2449
|
}
|
|
2398
|
-
function translateLevel
|
|
2450
|
+
function translateLevel(level) {
|
|
2399
2451
|
if (level === 0) {
|
|
2400
2452
|
return false;
|
|
2401
2453
|
}
|
|
@@ -2406,37 +2458,37 @@ function translateLevel$1(level) {
|
|
|
2406
2458
|
has16m: level >= 3
|
|
2407
2459
|
};
|
|
2408
2460
|
}
|
|
2409
|
-
function _supportsColor
|
|
2461
|
+
function _supportsColor(haveStream, {
|
|
2410
2462
|
streamIsTTY,
|
|
2411
2463
|
sniffFlags = true
|
|
2412
2464
|
} = {}) {
|
|
2413
|
-
const noFlagForceColor = envForceColor
|
|
2465
|
+
const noFlagForceColor = envForceColor();
|
|
2414
2466
|
if (noFlagForceColor !== undefined) {
|
|
2415
|
-
flagForceColor
|
|
2467
|
+
flagForceColor = noFlagForceColor;
|
|
2416
2468
|
}
|
|
2417
|
-
const forceColor = sniffFlags ? flagForceColor
|
|
2469
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
2418
2470
|
if (forceColor === 0) {
|
|
2419
2471
|
return 0;
|
|
2420
2472
|
}
|
|
2421
2473
|
if (sniffFlags) {
|
|
2422
|
-
if (hasFlag
|
|
2474
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
2423
2475
|
return 3;
|
|
2424
2476
|
}
|
|
2425
|
-
if (hasFlag
|
|
2477
|
+
if (hasFlag('color=256')) {
|
|
2426
2478
|
return 2;
|
|
2427
2479
|
}
|
|
2428
2480
|
}
|
|
2429
2481
|
|
|
2430
2482
|
// Check for Azure DevOps pipelines.
|
|
2431
2483
|
// Has to be above the `!streamIsTTY` check.
|
|
2432
|
-
if ('TF_BUILD' in env
|
|
2484
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
2433
2485
|
return 1;
|
|
2434
2486
|
}
|
|
2435
2487
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2436
2488
|
return 0;
|
|
2437
2489
|
}
|
|
2438
2490
|
const min = forceColor || 0;
|
|
2439
|
-
if (env
|
|
2491
|
+
if (env.TERM === 'dumb') {
|
|
2440
2492
|
return min;
|
|
2441
2493
|
}
|
|
2442
2494
|
if (process$1.platform === 'win32') {
|
|
@@ -2448,27 +2500,27 @@ function _supportsColor$1(haveStream, {
|
|
|
2448
2500
|
}
|
|
2449
2501
|
return 1;
|
|
2450
2502
|
}
|
|
2451
|
-
if ('CI' in env
|
|
2452
|
-
if ('GITHUB_ACTIONS' in env
|
|
2503
|
+
if ('CI' in env) {
|
|
2504
|
+
if ('GITHUB_ACTIONS' in env) {
|
|
2453
2505
|
return 3;
|
|
2454
2506
|
}
|
|
2455
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env
|
|
2507
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
2456
2508
|
return 1;
|
|
2457
2509
|
}
|
|
2458
2510
|
return min;
|
|
2459
2511
|
}
|
|
2460
|
-
if ('TEAMCITY_VERSION' in env
|
|
2461
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env
|
|
2512
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
2513
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2462
2514
|
}
|
|
2463
|
-
if (env
|
|
2515
|
+
if (env.COLORTERM === 'truecolor') {
|
|
2464
2516
|
return 3;
|
|
2465
2517
|
}
|
|
2466
|
-
if (env
|
|
2518
|
+
if (env.TERM === 'xterm-kitty') {
|
|
2467
2519
|
return 3;
|
|
2468
2520
|
}
|
|
2469
|
-
if ('TERM_PROGRAM' in env
|
|
2470
|
-
const version = Number.parseInt((env
|
|
2471
|
-
switch (env
|
|
2521
|
+
if ('TERM_PROGRAM' in env) {
|
|
2522
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2523
|
+
switch (env.TERM_PROGRAM) {
|
|
2472
2524
|
case 'iTerm.app':
|
|
2473
2525
|
{
|
|
2474
2526
|
return version >= 3 ? 3 : 2;
|
|
@@ -2481,34 +2533,34 @@ function _supportsColor$1(haveStream, {
|
|
|
2481
2533
|
}
|
|
2482
2534
|
}
|
|
2483
2535
|
|
|
2484
|
-
if (/-256(color)?$/i.test(env
|
|
2536
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
2485
2537
|
return 2;
|
|
2486
2538
|
}
|
|
2487
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env
|
|
2539
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
2488
2540
|
return 1;
|
|
2489
2541
|
}
|
|
2490
|
-
if ('COLORTERM' in env
|
|
2542
|
+
if ('COLORTERM' in env) {
|
|
2491
2543
|
return 1;
|
|
2492
2544
|
}
|
|
2493
2545
|
return min;
|
|
2494
2546
|
}
|
|
2495
|
-
function createSupportsColor
|
|
2496
|
-
const level = _supportsColor
|
|
2547
|
+
function createSupportsColor(stream, options = {}) {
|
|
2548
|
+
const level = _supportsColor(stream, {
|
|
2497
2549
|
streamIsTTY: stream && stream.isTTY,
|
|
2498
2550
|
...options
|
|
2499
2551
|
});
|
|
2500
|
-
return translateLevel
|
|
2552
|
+
return translateLevel(level);
|
|
2501
2553
|
}
|
|
2502
2554
|
({
|
|
2503
|
-
stdout: createSupportsColor
|
|
2555
|
+
stdout: createSupportsColor({
|
|
2504
2556
|
isTTY: tty.isatty(1)
|
|
2505
2557
|
}),
|
|
2506
|
-
stderr: createSupportsColor
|
|
2558
|
+
stderr: createSupportsColor({
|
|
2507
2559
|
isTTY: tty.isatty(2)
|
|
2508
2560
|
})
|
|
2509
2561
|
});
|
|
2510
2562
|
|
|
2511
|
-
const processSupportsBasicColor = createSupportsColor
|
|
2563
|
+
const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
|
|
2512
2564
|
let canUseColors = processSupportsBasicColor;
|
|
2513
2565
|
|
|
2514
2566
|
// GitHub workflow does support ANSI but "supports-color" returns false
|
|
@@ -2588,7 +2640,7 @@ const UNICODE = {
|
|
|
2588
2640
|
supported: canUseUnicode
|
|
2589
2641
|
};
|
|
2590
2642
|
|
|
2591
|
-
const createDetailedMessage$
|
|
2643
|
+
const createDetailedMessage$1 = (message, details = {}) => {
|
|
2592
2644
|
let string = `${message}`;
|
|
2593
2645
|
Object.keys(details).forEach(key => {
|
|
2594
2646
|
const value = details[key];
|
|
@@ -2852,86 +2904,86 @@ const distributePercentages = (namedNumbers, {
|
|
|
2852
2904
|
return percentages;
|
|
2853
2905
|
};
|
|
2854
2906
|
|
|
2855
|
-
const ESC
|
|
2856
|
-
const OSC
|
|
2857
|
-
const BEL
|
|
2858
|
-
const SEP
|
|
2907
|
+
const ESC = '\u001B[';
|
|
2908
|
+
const OSC = '\u001B]';
|
|
2909
|
+
const BEL = '\u0007';
|
|
2910
|
+
const SEP = ';';
|
|
2859
2911
|
|
|
2860
2912
|
/* global window */
|
|
2861
2913
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
2862
|
-
const isTerminalApp
|
|
2914
|
+
const isTerminalApp = !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
2863
2915
|
const isWindows = !isBrowser && process$1.platform === 'win32';
|
|
2864
2916
|
const cwdFunction = isBrowser ? () => {
|
|
2865
2917
|
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
2866
2918
|
} : process$1.cwd;
|
|
2867
|
-
const ansiEscapes
|
|
2868
|
-
ansiEscapes
|
|
2919
|
+
const ansiEscapes = {};
|
|
2920
|
+
ansiEscapes.cursorTo = (x, y) => {
|
|
2869
2921
|
if (typeof x !== 'number') {
|
|
2870
2922
|
throw new TypeError('The `x` argument is required');
|
|
2871
2923
|
}
|
|
2872
2924
|
if (typeof y !== 'number') {
|
|
2873
|
-
return ESC
|
|
2925
|
+
return ESC + (x + 1) + 'G';
|
|
2874
2926
|
}
|
|
2875
|
-
return ESC
|
|
2927
|
+
return ESC + (y + 1) + SEP + (x + 1) + 'H';
|
|
2876
2928
|
};
|
|
2877
|
-
ansiEscapes
|
|
2929
|
+
ansiEscapes.cursorMove = (x, y) => {
|
|
2878
2930
|
if (typeof x !== 'number') {
|
|
2879
2931
|
throw new TypeError('The `x` argument is required');
|
|
2880
2932
|
}
|
|
2881
2933
|
let returnValue = '';
|
|
2882
2934
|
if (x < 0) {
|
|
2883
|
-
returnValue += ESC
|
|
2935
|
+
returnValue += ESC + -x + 'D';
|
|
2884
2936
|
} else if (x > 0) {
|
|
2885
|
-
returnValue += ESC
|
|
2937
|
+
returnValue += ESC + x + 'C';
|
|
2886
2938
|
}
|
|
2887
2939
|
if (y < 0) {
|
|
2888
|
-
returnValue += ESC
|
|
2940
|
+
returnValue += ESC + -y + 'A';
|
|
2889
2941
|
} else if (y > 0) {
|
|
2890
|
-
returnValue += ESC
|
|
2942
|
+
returnValue += ESC + y + 'B';
|
|
2891
2943
|
}
|
|
2892
2944
|
return returnValue;
|
|
2893
2945
|
};
|
|
2894
|
-
ansiEscapes
|
|
2895
|
-
ansiEscapes
|
|
2896
|
-
ansiEscapes
|
|
2897
|
-
ansiEscapes
|
|
2898
|
-
ansiEscapes
|
|
2899
|
-
ansiEscapes
|
|
2900
|
-
ansiEscapes
|
|
2901
|
-
ansiEscapes
|
|
2902
|
-
ansiEscapes
|
|
2903
|
-
ansiEscapes
|
|
2904
|
-
ansiEscapes
|
|
2905
|
-
ansiEscapes
|
|
2906
|
-
ansiEscapes
|
|
2946
|
+
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
|
|
2947
|
+
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
|
|
2948
|
+
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
|
|
2949
|
+
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
|
|
2950
|
+
ansiEscapes.cursorLeft = ESC + 'G';
|
|
2951
|
+
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
|
|
2952
|
+
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
|
|
2953
|
+
ansiEscapes.cursorGetPosition = ESC + '6n';
|
|
2954
|
+
ansiEscapes.cursorNextLine = ESC + 'E';
|
|
2955
|
+
ansiEscapes.cursorPrevLine = ESC + 'F';
|
|
2956
|
+
ansiEscapes.cursorHide = ESC + '?25l';
|
|
2957
|
+
ansiEscapes.cursorShow = ESC + '?25h';
|
|
2958
|
+
ansiEscapes.eraseLines = count => {
|
|
2907
2959
|
let clear = '';
|
|
2908
2960
|
for (let i = 0; i < count; i++) {
|
|
2909
|
-
clear += ansiEscapes
|
|
2961
|
+
clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
|
|
2910
2962
|
}
|
|
2911
2963
|
if (count) {
|
|
2912
|
-
clear += ansiEscapes
|
|
2964
|
+
clear += ansiEscapes.cursorLeft;
|
|
2913
2965
|
}
|
|
2914
2966
|
return clear;
|
|
2915
2967
|
};
|
|
2916
|
-
ansiEscapes
|
|
2917
|
-
ansiEscapes
|
|
2918
|
-
ansiEscapes
|
|
2919
|
-
ansiEscapes
|
|
2920
|
-
ansiEscapes
|
|
2921
|
-
ansiEscapes
|
|
2922
|
-
ansiEscapes
|
|
2923
|
-
ansiEscapes
|
|
2924
|
-
ansiEscapes
|
|
2925
|
-
ansiEscapes
|
|
2968
|
+
ansiEscapes.eraseEndLine = ESC + 'K';
|
|
2969
|
+
ansiEscapes.eraseStartLine = ESC + '1K';
|
|
2970
|
+
ansiEscapes.eraseLine = ESC + '2K';
|
|
2971
|
+
ansiEscapes.eraseDown = ESC + 'J';
|
|
2972
|
+
ansiEscapes.eraseUp = ESC + '1J';
|
|
2973
|
+
ansiEscapes.eraseScreen = ESC + '2J';
|
|
2974
|
+
ansiEscapes.scrollUp = ESC + 'S';
|
|
2975
|
+
ansiEscapes.scrollDown = ESC + 'T';
|
|
2976
|
+
ansiEscapes.clearScreen = '\u001Bc';
|
|
2977
|
+
ansiEscapes.clearTerminal = isWindows ? `${ansiEscapes.eraseScreen}${ESC}0f`
|
|
2926
2978
|
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
2927
2979
|
// 2. Erases the whole screen including scrollback buffer
|
|
2928
2980
|
// 3. Moves cursor to the top-left position
|
|
2929
2981
|
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
2930
|
-
: `${ansiEscapes
|
|
2931
|
-
ansiEscapes
|
|
2932
|
-
ansiEscapes
|
|
2933
|
-
ansiEscapes
|
|
2934
|
-
let returnValue = `${OSC
|
|
2982
|
+
: `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
|
|
2983
|
+
ansiEscapes.beep = BEL;
|
|
2984
|
+
ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
|
|
2985
|
+
ansiEscapes.image = (buffer, options = {}) => {
|
|
2986
|
+
let returnValue = `${OSC}1337;File=inline=1`;
|
|
2935
2987
|
if (options.width) {
|
|
2936
2988
|
returnValue += `;width=${options.width}`;
|
|
2937
2989
|
}
|
|
@@ -2941,12 +2993,12 @@ ansiEscapes$1.image = (buffer, options = {}) => {
|
|
|
2941
2993
|
if (options.preserveAspectRatio === false) {
|
|
2942
2994
|
returnValue += ';preserveAspectRatio=0';
|
|
2943
2995
|
}
|
|
2944
|
-
return returnValue + ':' + buffer.toString('base64') + BEL
|
|
2996
|
+
return returnValue + ':' + buffer.toString('base64') + BEL;
|
|
2945
2997
|
};
|
|
2946
|
-
ansiEscapes
|
|
2947
|
-
setCwd: (cwd = cwdFunction()) => `${OSC
|
|
2998
|
+
ansiEscapes.iTerm = {
|
|
2999
|
+
setCwd: (cwd = cwdFunction()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
2948
3000
|
annotation(message, options = {}) {
|
|
2949
|
-
let returnValue = `${OSC
|
|
3001
|
+
let returnValue = `${OSC}1337;`;
|
|
2950
3002
|
const hasX = typeof options.x !== 'undefined';
|
|
2951
3003
|
const hasY = typeof options.y !== 'undefined';
|
|
2952
3004
|
if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
|
|
@@ -2959,7 +3011,7 @@ ansiEscapes$1.iTerm = {
|
|
|
2959
3011
|
} else {
|
|
2960
3012
|
returnValue += message;
|
|
2961
3013
|
}
|
|
2962
|
-
return returnValue + BEL
|
|
3014
|
+
return returnValue + BEL;
|
|
2963
3015
|
}
|
|
2964
3016
|
};
|
|
2965
3017
|
|
|
@@ -3034,7 +3086,7 @@ const createLog = ({
|
|
|
3034
3086
|
return "";
|
|
3035
3087
|
}
|
|
3036
3088
|
clearAttemptResult = true;
|
|
3037
|
-
return ansiEscapes
|
|
3089
|
+
return ansiEscapes.eraseLines(visualLineCount);
|
|
3038
3090
|
};
|
|
3039
3091
|
const spyStream = () => {
|
|
3040
3092
|
if (stream === process.stdout) {
|
|
@@ -3082,511 +3134,139 @@ const createLog = ({
|
|
|
3082
3134
|
const destroy = () => {
|
|
3083
3135
|
if (streamOutputSpy) {
|
|
3084
3136
|
streamOutputSpy(); // this uninstalls the spy
|
|
3085
|
-
streamOutputSpy = null;
|
|
3086
|
-
lastOutput = "";
|
|
3087
|
-
}
|
|
3088
|
-
};
|
|
3089
|
-
Object.assign(log, {
|
|
3090
|
-
write,
|
|
3091
|
-
dynamicWrite,
|
|
3092
|
-
destroy
|
|
3093
|
-
});
|
|
3094
|
-
return log;
|
|
3095
|
-
};
|
|
3096
|
-
const noopStreamSpy = () => "";
|
|
3097
|
-
|
|
3098
|
-
// could be inlined but vscode do not correctly
|
|
3099
|
-
// expand/collapse template strings, so I put it at the bottom
|
|
3100
|
-
const addNewLines = (string, newLine) => {
|
|
3101
|
-
if (newLine === "before") {
|
|
3102
|
-
return `
|
|
3103
|
-
${string}`;
|
|
3104
|
-
}
|
|
3105
|
-
if (newLine === "after") {
|
|
3106
|
-
return `${string}
|
|
3107
|
-
`;
|
|
3108
|
-
}
|
|
3109
|
-
if (newLine === "around") {
|
|
3110
|
-
return `
|
|
3111
|
-
${string}
|
|
3112
|
-
`;
|
|
3113
|
-
}
|
|
3114
|
-
return string;
|
|
3115
|
-
};
|
|
3116
|
-
|
|
3117
|
-
const startSpinner = ({
|
|
3118
|
-
log,
|
|
3119
|
-
frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
|
|
3120
|
-
fps = 20,
|
|
3121
|
-
keepProcessAlive = false,
|
|
3122
|
-
stopOnWriteFromOutside = true,
|
|
3123
|
-
stopOnVerticalOverflow = true,
|
|
3124
|
-
render = () => "",
|
|
3125
|
-
effect = () => {}
|
|
3126
|
-
}) => {
|
|
3127
|
-
let frameIndex = 0;
|
|
3128
|
-
let interval;
|
|
3129
|
-
let running = true;
|
|
3130
|
-
const spinner = {
|
|
3131
|
-
message: undefined
|
|
3132
|
-
};
|
|
3133
|
-
const update = message => {
|
|
3134
|
-
spinner.message = running ? `${frames[frameIndex]} ${message}` : message;
|
|
3135
|
-
return spinner.message;
|
|
3136
|
-
};
|
|
3137
|
-
spinner.update = update;
|
|
3138
|
-
let cleanup;
|
|
3139
|
-
if (ANSI.supported) {
|
|
3140
|
-
running = true;
|
|
3141
|
-
cleanup = effect();
|
|
3142
|
-
log.write(update(render()));
|
|
3143
|
-
interval = setInterval(() => {
|
|
3144
|
-
frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
|
|
3145
|
-
log.dynamicWrite(({
|
|
3146
|
-
outputFromOutside
|
|
3147
|
-
}) => {
|
|
3148
|
-
if (outputFromOutside && stopOnWriteFromOutside) {
|
|
3149
|
-
stop();
|
|
3150
|
-
return "";
|
|
3151
|
-
}
|
|
3152
|
-
return update(render());
|
|
3153
|
-
});
|
|
3154
|
-
}, 1000 / fps);
|
|
3155
|
-
if (!keepProcessAlive) {
|
|
3156
|
-
interval.unref();
|
|
3157
|
-
}
|
|
3158
|
-
} else {
|
|
3159
|
-
log.write(update(render()));
|
|
3160
|
-
}
|
|
3161
|
-
const stop = message => {
|
|
3162
|
-
running = false;
|
|
3163
|
-
if (interval) {
|
|
3164
|
-
clearInterval(interval);
|
|
3165
|
-
interval = null;
|
|
3166
|
-
}
|
|
3167
|
-
if (cleanup) {
|
|
3168
|
-
cleanup();
|
|
3169
|
-
cleanup = null;
|
|
3170
|
-
}
|
|
3171
|
-
if (log && message) {
|
|
3172
|
-
log.write(update(message));
|
|
3173
|
-
log = null;
|
|
3174
|
-
}
|
|
3175
|
-
};
|
|
3176
|
-
spinner.stop = stop;
|
|
3177
|
-
if (stopOnVerticalOverflow) {
|
|
3178
|
-
log.onVerticalOverflow = stop;
|
|
3179
|
-
}
|
|
3180
|
-
return spinner;
|
|
3181
|
-
};
|
|
3182
|
-
|
|
3183
|
-
const createTaskLog = (label, {
|
|
3184
|
-
disabled = false,
|
|
3185
|
-
stopOnWriteFromOutside
|
|
3186
|
-
} = {}) => {
|
|
3187
|
-
if (disabled) {
|
|
3188
|
-
return {
|
|
3189
|
-
setRightText: () => {},
|
|
3190
|
-
done: () => {},
|
|
3191
|
-
happen: () => {},
|
|
3192
|
-
fail: () => {}
|
|
3193
|
-
};
|
|
3194
|
-
}
|
|
3195
|
-
const startMs = Date.now();
|
|
3196
|
-
const log = createLog();
|
|
3197
|
-
let message = label;
|
|
3198
|
-
const taskSpinner = startSpinner({
|
|
3199
|
-
log,
|
|
3200
|
-
render: () => message,
|
|
3201
|
-
stopOnWriteFromOutside
|
|
3202
|
-
});
|
|
3203
|
-
return {
|
|
3204
|
-
setRightText: value => {
|
|
3205
|
-
message = `${label} ${value}`;
|
|
3206
|
-
},
|
|
3207
|
-
done: () => {
|
|
3208
|
-
const msEllapsed = Date.now() - startMs;
|
|
3209
|
-
taskSpinner.stop(`${UNICODE.OK} ${label} (done in ${msAsDuration(msEllapsed)})`);
|
|
3210
|
-
},
|
|
3211
|
-
happen: message => {
|
|
3212
|
-
taskSpinner.stop(`${UNICODE.INFO} ${message} (at ${new Date().toLocaleTimeString()})`);
|
|
3213
|
-
},
|
|
3214
|
-
fail: (message = `failed to ${label}`) => {
|
|
3215
|
-
taskSpinner.stop(`${UNICODE.FAILURE} ${message}`);
|
|
3216
|
-
}
|
|
3217
|
-
};
|
|
3218
|
-
};
|
|
3219
|
-
|
|
3220
|
-
const LOG_LEVEL_OFF = "off";
|
|
3221
|
-
const LOG_LEVEL_DEBUG = "debug";
|
|
3222
|
-
const LOG_LEVEL_INFO = "info";
|
|
3223
|
-
const LOG_LEVEL_WARN = "warn";
|
|
3224
|
-
const LOG_LEVEL_ERROR = "error";
|
|
3225
|
-
|
|
3226
|
-
const createLogger = ({
|
|
3227
|
-
logLevel = LOG_LEVEL_INFO
|
|
3228
|
-
} = {}) => {
|
|
3229
|
-
if (logLevel === LOG_LEVEL_DEBUG) {
|
|
3230
|
-
return {
|
|
3231
|
-
level: "debug",
|
|
3232
|
-
levels: {
|
|
3233
|
-
debug: true,
|
|
3234
|
-
info: true,
|
|
3235
|
-
warn: true,
|
|
3236
|
-
error: true
|
|
3237
|
-
},
|
|
3238
|
-
debug,
|
|
3239
|
-
info,
|
|
3240
|
-
warn,
|
|
3241
|
-
error
|
|
3242
|
-
};
|
|
3243
|
-
}
|
|
3244
|
-
if (logLevel === LOG_LEVEL_INFO) {
|
|
3245
|
-
return {
|
|
3246
|
-
level: "info",
|
|
3247
|
-
levels: {
|
|
3248
|
-
debug: false,
|
|
3249
|
-
info: true,
|
|
3250
|
-
warn: true,
|
|
3251
|
-
error: true
|
|
3252
|
-
},
|
|
3253
|
-
debug: debugDisabled,
|
|
3254
|
-
info,
|
|
3255
|
-
warn,
|
|
3256
|
-
error
|
|
3257
|
-
};
|
|
3258
|
-
}
|
|
3259
|
-
if (logLevel === LOG_LEVEL_WARN) {
|
|
3260
|
-
return {
|
|
3261
|
-
level: "warn",
|
|
3262
|
-
levels: {
|
|
3263
|
-
debug: false,
|
|
3264
|
-
info: false,
|
|
3265
|
-
warn: true,
|
|
3266
|
-
error: true
|
|
3267
|
-
},
|
|
3268
|
-
debug: debugDisabled,
|
|
3269
|
-
info: infoDisabled,
|
|
3270
|
-
warn,
|
|
3271
|
-
error
|
|
3272
|
-
};
|
|
3273
|
-
}
|
|
3274
|
-
if (logLevel === LOG_LEVEL_ERROR) {
|
|
3275
|
-
return {
|
|
3276
|
-
level: "error",
|
|
3277
|
-
levels: {
|
|
3278
|
-
debug: false,
|
|
3279
|
-
info: false,
|
|
3280
|
-
warn: false,
|
|
3281
|
-
error: true
|
|
3282
|
-
},
|
|
3283
|
-
debug: debugDisabled,
|
|
3284
|
-
info: infoDisabled,
|
|
3285
|
-
warn: warnDisabled,
|
|
3286
|
-
error
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
if (logLevel === LOG_LEVEL_OFF) {
|
|
3290
|
-
return {
|
|
3291
|
-
level: "off",
|
|
3292
|
-
levels: {
|
|
3293
|
-
debug: false,
|
|
3294
|
-
info: false,
|
|
3295
|
-
warn: false,
|
|
3296
|
-
error: false
|
|
3297
|
-
},
|
|
3298
|
-
debug: debugDisabled,
|
|
3299
|
-
info: infoDisabled,
|
|
3300
|
-
warn: warnDisabled,
|
|
3301
|
-
error: errorDisabled
|
|
3302
|
-
};
|
|
3303
|
-
}
|
|
3304
|
-
throw new Error(`unexpected logLevel.
|
|
3305
|
-
--- logLevel ---
|
|
3306
|
-
${logLevel}
|
|
3307
|
-
--- allowed log levels ---
|
|
3308
|
-
${LOG_LEVEL_OFF}
|
|
3309
|
-
${LOG_LEVEL_ERROR}
|
|
3310
|
-
${LOG_LEVEL_WARN}
|
|
3311
|
-
${LOG_LEVEL_INFO}
|
|
3312
|
-
${LOG_LEVEL_DEBUG}`);
|
|
3313
|
-
};
|
|
3314
|
-
const debug = (...args) => console.debug(...args);
|
|
3315
|
-
const debugDisabled = () => {};
|
|
3316
|
-
const info = (...args) => console.info(...args);
|
|
3317
|
-
const infoDisabled = () => {};
|
|
3318
|
-
const warn = (...args) => console.warn(...args);
|
|
3319
|
-
const warnDisabled = () => {};
|
|
3320
|
-
const error = (...args) => console.error(...args);
|
|
3321
|
-
const errorDisabled = () => {};
|
|
3322
|
-
|
|
3323
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
3324
|
-
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
3325
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
|
|
3326
|
-
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
3327
|
-
const position = argv.indexOf(prefix + flag);
|
|
3328
|
-
const terminatorPosition = argv.indexOf('--');
|
|
3329
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
3330
|
-
}
|
|
3331
|
-
const {
|
|
3332
|
-
env
|
|
3333
|
-
} = process$1;
|
|
3334
|
-
let flagForceColor;
|
|
3335
|
-
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
3336
|
-
flagForceColor = 0;
|
|
3337
|
-
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
3338
|
-
flagForceColor = 1;
|
|
3339
|
-
}
|
|
3340
|
-
function envForceColor() {
|
|
3341
|
-
if ('FORCE_COLOR' in env) {
|
|
3342
|
-
if (env.FORCE_COLOR === 'true') {
|
|
3343
|
-
return 1;
|
|
3344
|
-
}
|
|
3345
|
-
if (env.FORCE_COLOR === 'false') {
|
|
3346
|
-
return 0;
|
|
3347
|
-
}
|
|
3348
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
function translateLevel(level) {
|
|
3352
|
-
if (level === 0) {
|
|
3353
|
-
return false;
|
|
3354
|
-
}
|
|
3355
|
-
return {
|
|
3356
|
-
level,
|
|
3357
|
-
hasBasic: true,
|
|
3358
|
-
has256: level >= 2,
|
|
3359
|
-
has16m: level >= 3
|
|
3360
|
-
};
|
|
3361
|
-
}
|
|
3362
|
-
function _supportsColor(haveStream, {
|
|
3363
|
-
streamIsTTY,
|
|
3364
|
-
sniffFlags = true
|
|
3365
|
-
} = {}) {
|
|
3366
|
-
const noFlagForceColor = envForceColor();
|
|
3367
|
-
if (noFlagForceColor !== undefined) {
|
|
3368
|
-
flagForceColor = noFlagForceColor;
|
|
3369
|
-
}
|
|
3370
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
3371
|
-
if (forceColor === 0) {
|
|
3372
|
-
return 0;
|
|
3373
|
-
}
|
|
3374
|
-
if (sniffFlags) {
|
|
3375
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
3376
|
-
return 3;
|
|
3377
|
-
}
|
|
3378
|
-
if (hasFlag('color=256')) {
|
|
3379
|
-
return 2;
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
// Check for Azure DevOps pipelines.
|
|
3384
|
-
// Has to be above the `!streamIsTTY` check.
|
|
3385
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
3386
|
-
return 1;
|
|
3387
|
-
}
|
|
3388
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
3389
|
-
return 0;
|
|
3390
|
-
}
|
|
3391
|
-
const min = forceColor || 0;
|
|
3392
|
-
if (env.TERM === 'dumb') {
|
|
3393
|
-
return min;
|
|
3394
|
-
}
|
|
3395
|
-
if (process$1.platform === 'win32') {
|
|
3396
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
3397
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
3398
|
-
const osRelease = os.release().split('.');
|
|
3399
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
|
|
3400
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
3401
|
-
}
|
|
3402
|
-
return 1;
|
|
3403
|
-
}
|
|
3404
|
-
if ('CI' in env) {
|
|
3405
|
-
if ('GITHUB_ACTIONS' in env) {
|
|
3406
|
-
return 3;
|
|
3407
|
-
}
|
|
3408
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
3409
|
-
return 1;
|
|
3410
|
-
}
|
|
3411
|
-
return min;
|
|
3412
|
-
}
|
|
3413
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
3414
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
3415
|
-
}
|
|
3416
|
-
if (env.COLORTERM === 'truecolor') {
|
|
3417
|
-
return 3;
|
|
3418
|
-
}
|
|
3419
|
-
if (env.TERM === 'xterm-kitty') {
|
|
3420
|
-
return 3;
|
|
3421
|
-
}
|
|
3422
|
-
if ('TERM_PROGRAM' in env) {
|
|
3423
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
3424
|
-
switch (env.TERM_PROGRAM) {
|
|
3425
|
-
case 'iTerm.app':
|
|
3426
|
-
{
|
|
3427
|
-
return version >= 3 ? 3 : 2;
|
|
3428
|
-
}
|
|
3429
|
-
case 'Apple_Terminal':
|
|
3430
|
-
{
|
|
3431
|
-
return 2;
|
|
3432
|
-
}
|
|
3433
|
-
// No default
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
|
|
3437
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
3438
|
-
return 2;
|
|
3439
|
-
}
|
|
3440
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
3441
|
-
return 1;
|
|
3442
|
-
}
|
|
3443
|
-
if ('COLORTERM' in env) {
|
|
3444
|
-
return 1;
|
|
3445
|
-
}
|
|
3446
|
-
return min;
|
|
3447
|
-
}
|
|
3448
|
-
function createSupportsColor(stream, options = {}) {
|
|
3449
|
-
const level = _supportsColor(stream, {
|
|
3450
|
-
streamIsTTY: stream && stream.isTTY,
|
|
3451
|
-
...options
|
|
3452
|
-
});
|
|
3453
|
-
return translateLevel(level);
|
|
3454
|
-
}
|
|
3455
|
-
({
|
|
3456
|
-
stdout: createSupportsColor({
|
|
3457
|
-
isTTY: tty.isatty(1)
|
|
3458
|
-
}),
|
|
3459
|
-
stderr: createSupportsColor({
|
|
3460
|
-
isTTY: tty.isatty(2)
|
|
3461
|
-
})
|
|
3462
|
-
});
|
|
3463
|
-
|
|
3464
|
-
createSupportsColor(process.stdout).hasBasic;
|
|
3465
|
-
|
|
3466
|
-
// GitHub workflow does support ANSI but "supports-color" returns false
|
|
3467
|
-
// because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
|
|
3468
|
-
if (process.env.GITHUB_WORKFLOW) {
|
|
3469
|
-
// Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
|
|
3470
|
-
if (process.env.FORCE_COLOR !== "false") ;
|
|
3471
|
-
}
|
|
3472
|
-
|
|
3473
|
-
// see also https://github.com/sindresorhus/figures
|
|
3474
|
-
isUnicodeSupported();
|
|
3475
|
-
|
|
3476
|
-
const createDetailedMessage$1 = (message, details = {}) => {
|
|
3477
|
-
let string = `${message}`;
|
|
3478
|
-
Object.keys(details).forEach(key => {
|
|
3479
|
-
const value = details[key];
|
|
3480
|
-
string += `
|
|
3481
|
-
--- ${key} ---
|
|
3482
|
-
${Array.isArray(value) ? value.join(`
|
|
3483
|
-
`) : value}`;
|
|
3484
|
-
});
|
|
3485
|
-
return string;
|
|
3486
|
-
};
|
|
3487
|
-
|
|
3488
|
-
const ESC = '\u001B[';
|
|
3489
|
-
const OSC = '\u001B]';
|
|
3490
|
-
const BEL = '\u0007';
|
|
3491
|
-
const SEP = ';';
|
|
3492
|
-
const isTerminalApp = process$1.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
3493
|
-
const ansiEscapes = {};
|
|
3494
|
-
ansiEscapes.cursorTo = (x, y) => {
|
|
3495
|
-
if (typeof x !== 'number') {
|
|
3496
|
-
throw new TypeError('The `x` argument is required');
|
|
3497
|
-
}
|
|
3498
|
-
if (typeof y !== 'number') {
|
|
3499
|
-
return ESC + (x + 1) + 'G';
|
|
3500
|
-
}
|
|
3501
|
-
return ESC + (y + 1) + SEP + (x + 1) + 'H';
|
|
3502
|
-
};
|
|
3503
|
-
ansiEscapes.cursorMove = (x, y) => {
|
|
3504
|
-
if (typeof x !== 'number') {
|
|
3505
|
-
throw new TypeError('The `x` argument is required');
|
|
3506
|
-
}
|
|
3507
|
-
let returnValue = '';
|
|
3508
|
-
if (x < 0) {
|
|
3509
|
-
returnValue += ESC + -x + 'D';
|
|
3510
|
-
} else if (x > 0) {
|
|
3511
|
-
returnValue += ESC + x + 'C';
|
|
3512
|
-
}
|
|
3513
|
-
if (y < 0) {
|
|
3514
|
-
returnValue += ESC + -y + 'A';
|
|
3515
|
-
} else if (y > 0) {
|
|
3516
|
-
returnValue += ESC + y + 'B';
|
|
3517
|
-
}
|
|
3518
|
-
return returnValue;
|
|
3519
|
-
};
|
|
3520
|
-
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
|
|
3521
|
-
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
|
|
3522
|
-
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
|
|
3523
|
-
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
|
|
3524
|
-
ansiEscapes.cursorLeft = ESC + 'G';
|
|
3525
|
-
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
|
|
3526
|
-
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
|
|
3527
|
-
ansiEscapes.cursorGetPosition = ESC + '6n';
|
|
3528
|
-
ansiEscapes.cursorNextLine = ESC + 'E';
|
|
3529
|
-
ansiEscapes.cursorPrevLine = ESC + 'F';
|
|
3530
|
-
ansiEscapes.cursorHide = ESC + '?25l';
|
|
3531
|
-
ansiEscapes.cursorShow = ESC + '?25h';
|
|
3532
|
-
ansiEscapes.eraseLines = count => {
|
|
3533
|
-
let clear = '';
|
|
3534
|
-
for (let i = 0; i < count; i++) {
|
|
3535
|
-
clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
|
|
3536
|
-
}
|
|
3537
|
-
if (count) {
|
|
3538
|
-
clear += ansiEscapes.cursorLeft;
|
|
3539
|
-
}
|
|
3540
|
-
return clear;
|
|
3137
|
+
streamOutputSpy = null;
|
|
3138
|
+
lastOutput = "";
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
Object.assign(log, {
|
|
3142
|
+
write,
|
|
3143
|
+
dynamicWrite,
|
|
3144
|
+
destroy
|
|
3145
|
+
});
|
|
3146
|
+
return log;
|
|
3541
3147
|
};
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
ansiEscapes.clearScreen = '\u001Bc';
|
|
3551
|
-
ansiEscapes.clearTerminal = process$1.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f`
|
|
3552
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
3553
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
3554
|
-
// 3. Moves cursor to the top-left position
|
|
3555
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
3556
|
-
: `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
|
|
3557
|
-
ansiEscapes.beep = BEL;
|
|
3558
|
-
ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
|
|
3559
|
-
ansiEscapes.image = (buffer, options = {}) => {
|
|
3560
|
-
let returnValue = `${OSC}1337;File=inline=1`;
|
|
3561
|
-
if (options.width) {
|
|
3562
|
-
returnValue += `;width=${options.width}`;
|
|
3148
|
+
const noopStreamSpy = () => "";
|
|
3149
|
+
|
|
3150
|
+
// could be inlined but vscode do not correctly
|
|
3151
|
+
// expand/collapse template strings, so I put it at the bottom
|
|
3152
|
+
const addNewLines = (string, newLine) => {
|
|
3153
|
+
if (newLine === "before") {
|
|
3154
|
+
return `
|
|
3155
|
+
${string}`;
|
|
3563
3156
|
}
|
|
3564
|
-
if (
|
|
3565
|
-
|
|
3157
|
+
if (newLine === "after") {
|
|
3158
|
+
return `${string}
|
|
3159
|
+
`;
|
|
3566
3160
|
}
|
|
3567
|
-
if (
|
|
3568
|
-
|
|
3161
|
+
if (newLine === "around") {
|
|
3162
|
+
return `
|
|
3163
|
+
${string}
|
|
3164
|
+
`;
|
|
3569
3165
|
}
|
|
3570
|
-
return
|
|
3166
|
+
return string;
|
|
3571
3167
|
};
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3168
|
+
|
|
3169
|
+
const startSpinner = ({
|
|
3170
|
+
log,
|
|
3171
|
+
frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
|
|
3172
|
+
fps = 20,
|
|
3173
|
+
keepProcessAlive = false,
|
|
3174
|
+
stopOnWriteFromOutside = true,
|
|
3175
|
+
stopOnVerticalOverflow = true,
|
|
3176
|
+
render = () => "",
|
|
3177
|
+
effect = () => {}
|
|
3178
|
+
}) => {
|
|
3179
|
+
let frameIndex = 0;
|
|
3180
|
+
let interval;
|
|
3181
|
+
let running = true;
|
|
3182
|
+
const spinner = {
|
|
3183
|
+
message: undefined
|
|
3184
|
+
};
|
|
3185
|
+
const update = message => {
|
|
3186
|
+
spinner.message = running ? `${frames[frameIndex]} ${message}` : message;
|
|
3187
|
+
return spinner.message;
|
|
3188
|
+
};
|
|
3189
|
+
spinner.update = update;
|
|
3190
|
+
let cleanup;
|
|
3191
|
+
if (ANSI.supported) {
|
|
3192
|
+
running = true;
|
|
3193
|
+
cleanup = effect();
|
|
3194
|
+
log.write(update(render()));
|
|
3195
|
+
interval = setInterval(() => {
|
|
3196
|
+
frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
|
|
3197
|
+
log.dynamicWrite(({
|
|
3198
|
+
outputFromOutside
|
|
3199
|
+
}) => {
|
|
3200
|
+
if (outputFromOutside && stopOnWriteFromOutside) {
|
|
3201
|
+
stop();
|
|
3202
|
+
return "";
|
|
3203
|
+
}
|
|
3204
|
+
return update(render());
|
|
3205
|
+
});
|
|
3206
|
+
}, 1000 / fps);
|
|
3207
|
+
if (!keepProcessAlive) {
|
|
3208
|
+
interval.unref();
|
|
3580
3209
|
}
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3210
|
+
} else {
|
|
3211
|
+
log.write(update(render()));
|
|
3212
|
+
}
|
|
3213
|
+
const stop = message => {
|
|
3214
|
+
running = false;
|
|
3215
|
+
if (interval) {
|
|
3216
|
+
clearInterval(interval);
|
|
3217
|
+
interval = null;
|
|
3587
3218
|
}
|
|
3588
|
-
|
|
3219
|
+
if (cleanup) {
|
|
3220
|
+
cleanup();
|
|
3221
|
+
cleanup = null;
|
|
3222
|
+
}
|
|
3223
|
+
if (log && message) {
|
|
3224
|
+
log.write(update(message));
|
|
3225
|
+
log = null;
|
|
3226
|
+
}
|
|
3227
|
+
};
|
|
3228
|
+
spinner.stop = stop;
|
|
3229
|
+
if (stopOnVerticalOverflow) {
|
|
3230
|
+
log.onVerticalOverflow = stop;
|
|
3231
|
+
}
|
|
3232
|
+
return spinner;
|
|
3233
|
+
};
|
|
3234
|
+
|
|
3235
|
+
const createTaskLog = (label, {
|
|
3236
|
+
disabled = false,
|
|
3237
|
+
stopOnWriteFromOutside
|
|
3238
|
+
} = {}) => {
|
|
3239
|
+
if (disabled) {
|
|
3240
|
+
return {
|
|
3241
|
+
setRightText: () => {},
|
|
3242
|
+
done: () => {},
|
|
3243
|
+
happen: () => {},
|
|
3244
|
+
fail: () => {}
|
|
3245
|
+
};
|
|
3589
3246
|
}
|
|
3247
|
+
const startMs = Date.now();
|
|
3248
|
+
const log = createLog();
|
|
3249
|
+
let message = label;
|
|
3250
|
+
const taskSpinner = startSpinner({
|
|
3251
|
+
log,
|
|
3252
|
+
render: () => message,
|
|
3253
|
+
stopOnWriteFromOutside
|
|
3254
|
+
});
|
|
3255
|
+
return {
|
|
3256
|
+
setRightText: value => {
|
|
3257
|
+
message = `${label} ${value}`;
|
|
3258
|
+
},
|
|
3259
|
+
done: () => {
|
|
3260
|
+
const msEllapsed = Date.now() - startMs;
|
|
3261
|
+
taskSpinner.stop(`${UNICODE.OK} ${label} (done in ${msAsDuration(msEllapsed)})`);
|
|
3262
|
+
},
|
|
3263
|
+
happen: message => {
|
|
3264
|
+
taskSpinner.stop(`${UNICODE.INFO} ${message} (at ${new Date().toLocaleTimeString()})`);
|
|
3265
|
+
},
|
|
3266
|
+
fail: (message = `failed to ${label}`) => {
|
|
3267
|
+
taskSpinner.stop(`${UNICODE.FAILURE} ${message}`);
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3590
3270
|
};
|
|
3591
3271
|
|
|
3592
3272
|
const memoize = compute => {
|
|
@@ -5264,7 +4944,7 @@ const startServer = async ({
|
|
|
5264
4944
|
logLevel,
|
|
5265
4945
|
startLog = true,
|
|
5266
4946
|
serverName = "server",
|
|
5267
|
-
|
|
4947
|
+
https = false,
|
|
5268
4948
|
http2 = false,
|
|
5269
4949
|
http1Allowed = true,
|
|
5270
4950
|
redirectHttpToHttps,
|
|
@@ -5275,8 +4955,6 @@ const startServer = async ({
|
|
|
5275
4955
|
port = 0,
|
|
5276
4956
|
// assign a random available port
|
|
5277
4957
|
portHint,
|
|
5278
|
-
privateKey,
|
|
5279
|
-
certificate,
|
|
5280
4958
|
// when inside a worker, we should not try to stop server on SIGINT
|
|
5281
4959
|
// otherwise it can create an EPIPE error while primary process tries
|
|
5282
4960
|
// to kill the server
|
|
@@ -5307,39 +4985,52 @@ const startServer = async ({
|
|
|
5307
4985
|
// time allocated to server code to start reading the request body
|
|
5308
4986
|
// after this delay the underlying stream is destroyed, attempting to read it would throw
|
|
5309
4987
|
// if used the stream stays opened, it's only if the stream is not read at all that it gets destroyed
|
|
5310
|
-
requestBodyLifetime = 60_000 * 2
|
|
4988
|
+
requestBodyLifetime = 60_000 * 2,
|
|
4989
|
+
// 2s
|
|
4990
|
+
...rest
|
|
5311
4991
|
} = {}) => {
|
|
4992
|
+
// param validations
|
|
4993
|
+
{
|
|
4994
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
4995
|
+
if (unexpectedParamNames.length > 0) {
|
|
4996
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
4997
|
+
}
|
|
4998
|
+
if (https) {
|
|
4999
|
+
if (typeof https !== "object") {
|
|
5000
|
+
throw new TypeError(`https must be an object, got ${https}`);
|
|
5001
|
+
}
|
|
5002
|
+
const {
|
|
5003
|
+
certificate,
|
|
5004
|
+
privateKey
|
|
5005
|
+
} = https;
|
|
5006
|
+
if (!certificate || !privateKey) {
|
|
5007
|
+
throw new TypeError(`https must be an object with { certificate, privateKey }`);
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
if (http2 && !https) {
|
|
5011
|
+
throw new Error(`http2 needs https`);
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5312
5014
|
const logger = createLogger({
|
|
5313
5015
|
logLevel
|
|
5314
5016
|
});
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
if (!certificate) {
|
|
5320
|
-
throw new Error(`missing certificate for https server`);
|
|
5017
|
+
// param warnings and normalization
|
|
5018
|
+
{
|
|
5019
|
+
if (redirectHttpToHttps === undefined && https && !allowHttpRequestOnHttps) {
|
|
5020
|
+
redirectHttpToHttps = true;
|
|
5321
5021
|
}
|
|
5322
|
-
if (!
|
|
5323
|
-
|
|
5022
|
+
if (redirectHttpToHttps && !https) {
|
|
5023
|
+
logger.warn(`redirectHttpToHttps ignored because protocol is http`);
|
|
5024
|
+
redirectHttpToHttps = false;
|
|
5025
|
+
}
|
|
5026
|
+
if (allowHttpRequestOnHttps && redirectHttpToHttps) {
|
|
5027
|
+
logger.warn(`redirectHttpToHttps ignored because allowHttpRequestOnHttps is enabled`);
|
|
5028
|
+
redirectHttpToHttps = false;
|
|
5029
|
+
}
|
|
5030
|
+
if (allowHttpRequestOnHttps && !https) {
|
|
5031
|
+
logger.warn(`allowHttpRequestOnHttps ignored because protocol is http`);
|
|
5032
|
+
allowHttpRequestOnHttps = false;
|
|
5324
5033
|
}
|
|
5325
|
-
}
|
|
5326
|
-
if (http2 && protocol !== "https") {
|
|
5327
|
-
throw new Error(`http2 needs "https" but protocol is "${protocol}"`);
|
|
5328
|
-
}
|
|
5329
|
-
if (redirectHttpToHttps === undefined && protocol === "https" && !allowHttpRequestOnHttps) {
|
|
5330
|
-
redirectHttpToHttps = true;
|
|
5331
|
-
}
|
|
5332
|
-
if (redirectHttpToHttps && protocol === "http") {
|
|
5333
|
-
logger.warn(`redirectHttpToHttps ignored because protocol is http`);
|
|
5334
|
-
redirectHttpToHttps = false;
|
|
5335
|
-
}
|
|
5336
|
-
if (allowHttpRequestOnHttps && redirectHttpToHttps) {
|
|
5337
|
-
logger.warn(`redirectHttpToHttps ignored because allowHttpRequestOnHttps is enabled`);
|
|
5338
|
-
redirectHttpToHttps = false;
|
|
5339
|
-
}
|
|
5340
|
-
if (allowHttpRequestOnHttps && protocol === "http") {
|
|
5341
|
-
logger.warn(`allowHttpRequestOnHttps ignored because protocol is http`);
|
|
5342
|
-
allowHttpRequestOnHttps = false;
|
|
5343
5034
|
}
|
|
5344
5035
|
const server = {};
|
|
5345
5036
|
const serviceController = createServiceController(services);
|
|
@@ -5370,11 +5061,9 @@ const startServer = async ({
|
|
|
5370
5061
|
});
|
|
5371
5062
|
startServerOperation.throwIfAborted();
|
|
5372
5063
|
nodeServer = await createNodeServer({
|
|
5373
|
-
|
|
5064
|
+
https,
|
|
5374
5065
|
redirectHttpToHttps,
|
|
5375
5066
|
allowHttpRequestOnHttps,
|
|
5376
|
-
certificate,
|
|
5377
|
-
privateKey,
|
|
5378
5067
|
http2,
|
|
5379
5068
|
http1Allowed
|
|
5380
5069
|
});
|
|
@@ -5385,6 +5074,7 @@ const startServer = async ({
|
|
|
5385
5074
|
nodeServer.unref();
|
|
5386
5075
|
}
|
|
5387
5076
|
const createOrigin = hostname => {
|
|
5077
|
+
const protocol = https ? "https" : "http";
|
|
5388
5078
|
if (isIP(hostname) === 6) {
|
|
5389
5079
|
return `${protocol}://[${hostname}]`;
|
|
5390
5080
|
}
|
|
@@ -6099,7 +5789,7 @@ const startServer = async ({
|
|
|
6099
5789
|
let websocketServer = new WebSocketServer({
|
|
6100
5790
|
noServer: true
|
|
6101
5791
|
});
|
|
6102
|
-
const websocketOrigin =
|
|
5792
|
+
const websocketOrigin = https ? `wss://${hostname}:${port}` : `ws://${hostname}:${port}`;
|
|
6103
5793
|
server.websocketOrigin = websocketOrigin;
|
|
6104
5794
|
const upgradeCallback = (nodeRequest, socket, head) => {
|
|
6105
5795
|
websocketServer.handleUpgrade(nodeRequest, socket, head, async websocket => {
|
|
@@ -6158,32 +5848,37 @@ const startServer = async ({
|
|
|
6158
5848
|
return server;
|
|
6159
5849
|
};
|
|
6160
5850
|
const createNodeServer = async ({
|
|
6161
|
-
|
|
5851
|
+
https,
|
|
6162
5852
|
redirectHttpToHttps,
|
|
6163
5853
|
allowHttpRequestOnHttps,
|
|
6164
|
-
certificate,
|
|
6165
|
-
privateKey,
|
|
6166
5854
|
http2,
|
|
6167
5855
|
http1Allowed
|
|
6168
5856
|
}) => {
|
|
6169
|
-
if (
|
|
6170
|
-
|
|
6171
|
-
}
|
|
6172
|
-
if (redirectHttpToHttps || allowHttpRequestOnHttps) {
|
|
6173
|
-
return createPolyglotServer({
|
|
5857
|
+
if (https) {
|
|
5858
|
+
const {
|
|
6174
5859
|
certificate,
|
|
6175
|
-
privateKey
|
|
6176
|
-
|
|
6177
|
-
|
|
5860
|
+
privateKey
|
|
5861
|
+
} = https;
|
|
5862
|
+
if (redirectHttpToHttps || allowHttpRequestOnHttps) {
|
|
5863
|
+
return createPolyglotServer({
|
|
5864
|
+
certificate,
|
|
5865
|
+
privateKey,
|
|
5866
|
+
http2,
|
|
5867
|
+
http1Allowed
|
|
5868
|
+
});
|
|
5869
|
+
}
|
|
5870
|
+
const {
|
|
5871
|
+
createServer
|
|
5872
|
+
} = await import("node:https");
|
|
5873
|
+
return createServer({
|
|
5874
|
+
cert: certificate,
|
|
5875
|
+
key: privateKey
|
|
6178
5876
|
});
|
|
6179
5877
|
}
|
|
6180
5878
|
const {
|
|
6181
5879
|
createServer
|
|
6182
|
-
} = await import("node:
|
|
6183
|
-
return createServer(
|
|
6184
|
-
cert: certificate,
|
|
6185
|
-
key: privateKey
|
|
6186
|
-
});
|
|
5880
|
+
} = await import("node:http");
|
|
5881
|
+
return createServer();
|
|
6187
5882
|
};
|
|
6188
5883
|
const testCanPushStream = http2Stream => {
|
|
6189
5884
|
if (!http2Stream.pushAllowed) {
|
|
@@ -8578,7 +8273,7 @@ const createResolveUrlError = ({
|
|
|
8578
8273
|
reason,
|
|
8579
8274
|
...details
|
|
8580
8275
|
}) => {
|
|
8581
|
-
const resolveError = new Error(createDetailedMessage$
|
|
8276
|
+
const resolveError = new Error(createDetailedMessage$1(`Failed to resolve url reference`, {
|
|
8582
8277
|
reason,
|
|
8583
8278
|
...details,
|
|
8584
8279
|
"specifier": `"${reference.specifier}"`,
|
|
@@ -8612,7 +8307,7 @@ const createFetchUrlContentError = ({
|
|
|
8612
8307
|
reason,
|
|
8613
8308
|
...details
|
|
8614
8309
|
}) => {
|
|
8615
|
-
const fetchError = new Error(createDetailedMessage$
|
|
8310
|
+
const fetchError = new Error(createDetailedMessage$1(`Failed to fetch url content`, {
|
|
8616
8311
|
reason,
|
|
8617
8312
|
...details,
|
|
8618
8313
|
"url": urlInfo.url,
|
|
@@ -8679,7 +8374,7 @@ const createTransformUrlContentError = ({
|
|
|
8679
8374
|
reason,
|
|
8680
8375
|
...details
|
|
8681
8376
|
}) => {
|
|
8682
|
-
const transformError = new Error(createDetailedMessage$
|
|
8377
|
+
const transformError = new Error(createDetailedMessage$1(`"transformUrlContent" error on "${urlInfo.type}"`, {
|
|
8683
8378
|
reason,
|
|
8684
8379
|
...details,
|
|
8685
8380
|
"url": urlInfo.url,
|
|
@@ -8732,7 +8427,7 @@ const createFinalizeUrlContentError = ({
|
|
|
8732
8427
|
urlInfo,
|
|
8733
8428
|
error
|
|
8734
8429
|
}) => {
|
|
8735
|
-
const finalizeError = new Error(createDetailedMessage$
|
|
8430
|
+
const finalizeError = new Error(createDetailedMessage$1(`"finalizeUrlContent" error on "${urlInfo.type}"`, {
|
|
8736
8431
|
...detailsFromValueThrown(error),
|
|
8737
8432
|
"url": urlInfo.url,
|
|
8738
8433
|
"url reference trace": reference.trace.message,
|
|
@@ -8976,7 +8671,7 @@ const createKitchen = ({
|
|
|
8976
8671
|
writeGeneratedFiles,
|
|
8977
8672
|
outDirectoryUrl
|
|
8978
8673
|
}) => {
|
|
8979
|
-
const logger = createLogger
|
|
8674
|
+
const logger = createLogger({
|
|
8980
8675
|
logLevel
|
|
8981
8676
|
});
|
|
8982
8677
|
const kitchenContext = {
|
|
@@ -9238,7 +8933,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9238
8933
|
try {
|
|
9239
8934
|
const fetchUrlContentReturnValue = await pluginController.callAsyncHooksUntil("fetchUrlContent", urlInfo, contextDuringFetch);
|
|
9240
8935
|
if (!fetchUrlContentReturnValue) {
|
|
9241
|
-
logger.warn(createDetailedMessage$
|
|
8936
|
+
logger.warn(createDetailedMessage$1(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
|
|
9242
8937
|
"url": urlInfo.url,
|
|
9243
8938
|
"url reference trace": reference.trace.message
|
|
9244
8939
|
}));
|
|
@@ -15417,10 +15112,7 @@ const jsenvPluginAsJsClassicLibrary = ({
|
|
|
15417
15112
|
...context,
|
|
15418
15113
|
buildDirectoryUrl: context.outDirectoryUrl
|
|
15419
15114
|
},
|
|
15420
|
-
|
|
15421
|
-
babelHelpersChunk: false,
|
|
15422
|
-
preserveDynamicImport: true
|
|
15423
|
-
}
|
|
15115
|
+
preserveDynamicImport: true
|
|
15424
15116
|
});
|
|
15425
15117
|
const jsModuleBundledUrlInfo = bundleUrlInfos[jsModuleUrlInfo.url];
|
|
15426
15118
|
if (context.dev) {
|
|
@@ -21036,8 +20728,26 @@ const build = async ({
|
|
|
21036
20728
|
writeOnFileSystem = true,
|
|
21037
20729
|
writeGeneratedFiles = false,
|
|
21038
20730
|
assetManifest = versioningMethod === "filename",
|
|
21039
|
-
assetManifestFileRelativeUrl = "asset-manifest.json"
|
|
20731
|
+
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
20732
|
+
...rest
|
|
21040
20733
|
}) => {
|
|
20734
|
+
// param validation
|
|
20735
|
+
{
|
|
20736
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
20737
|
+
if (unexpectedParamNames.length > 0) {
|
|
20738
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
20739
|
+
}
|
|
20740
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
20741
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
20742
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
20743
|
+
}
|
|
20744
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
20745
|
+
const buildDirectoryUrlValidation = validateDirectoryUrl(buildDirectoryUrl);
|
|
20746
|
+
if (!buildDirectoryUrlValidation.valid) {
|
|
20747
|
+
throw new TypeError(`buildDirectoryUrl ${buildDirectoryUrlValidation.message}, got ${buildDirectoryUrlValidation}`);
|
|
20748
|
+
}
|
|
20749
|
+
buildDirectoryUrl = buildDirectoryUrlValidation.value;
|
|
20750
|
+
}
|
|
21041
20751
|
const operation = Abort.startOperation();
|
|
21042
20752
|
operation.addAbortSignal(signal);
|
|
21043
20753
|
if (handleSIGINT) {
|
|
@@ -21047,8 +20757,6 @@ const build = async ({
|
|
|
21047
20757
|
}, abort);
|
|
21048
20758
|
});
|
|
21049
20759
|
}
|
|
21050
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
21051
|
-
buildDirectoryUrl = assertAndNormalizeDirectoryUrl(buildDirectoryUrl);
|
|
21052
20760
|
assertEntryPoints({
|
|
21053
20761
|
entryPoints
|
|
21054
20762
|
});
|
|
@@ -21081,7 +20789,7 @@ const build = async ({
|
|
|
21081
20789
|
signal,
|
|
21082
20790
|
logLevel
|
|
21083
20791
|
}) => {
|
|
21084
|
-
const logger = createLogger
|
|
20792
|
+
const logger = createLogger({
|
|
21085
20793
|
logLevel
|
|
21086
20794
|
});
|
|
21087
20795
|
const buildOperation = Abort.startOperation();
|
|
@@ -21366,7 +21074,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21366
21074
|
const rawUrl = buildDirectoryRedirections.get(url) || url;
|
|
21367
21075
|
const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
|
|
21368
21076
|
if (!rawUrlInfo) {
|
|
21369
|
-
throw new Error(createDetailedMessage$
|
|
21077
|
+
throw new Error(createDetailedMessage$1(`Cannot find url`, {
|
|
21370
21078
|
url,
|
|
21371
21079
|
"raw urls": Array.from(buildDirectoryRedirections.values()),
|
|
21372
21080
|
"build urls": Array.from(buildDirectoryRedirections.keys())
|
|
@@ -22996,12 +22704,10 @@ const startDevServer = async ({
|
|
|
22996
22704
|
handleSIGINT = true,
|
|
22997
22705
|
logLevel = "info",
|
|
22998
22706
|
serverLogLevel = "warn",
|
|
22999
|
-
|
|
22707
|
+
https,
|
|
23000
22708
|
// it's better to use http1 by default because it allows to get statusText in devtools
|
|
23001
22709
|
// which gives valuable information when there is errors
|
|
23002
22710
|
http2 = false,
|
|
23003
|
-
certificate,
|
|
23004
|
-
privateKey,
|
|
23005
22711
|
hostname,
|
|
23006
22712
|
port = 3456,
|
|
23007
22713
|
acceptAnyIp,
|
|
@@ -23044,12 +22750,24 @@ const startDevServer = async ({
|
|
|
23044
22750
|
sourcemapsSourcesContent,
|
|
23045
22751
|
// no real need to write files during github workflow
|
|
23046
22752
|
// and mitigates https://github.com/actions/runner-images/issues/3885
|
|
23047
|
-
writeGeneratedFiles = !process.env.CI
|
|
22753
|
+
writeGeneratedFiles = !process.env.CI,
|
|
22754
|
+
...rest
|
|
23048
22755
|
}) => {
|
|
23049
|
-
|
|
22756
|
+
// params type checking
|
|
22757
|
+
{
|
|
22758
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
22759
|
+
if (unexpectedParamNames.length > 0) {
|
|
22760
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
22761
|
+
}
|
|
22762
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
22763
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
22764
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
22765
|
+
}
|
|
22766
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
22767
|
+
}
|
|
22768
|
+
const logger = createLogger({
|
|
23050
22769
|
logLevel
|
|
23051
22770
|
});
|
|
23052
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
23053
22771
|
const operation = Abort.startOperation();
|
|
23054
22772
|
operation.addAbortSignal(signal);
|
|
23055
22773
|
if (handleSIGINT) {
|
|
@@ -23139,10 +22857,8 @@ const startDevServer = async ({
|
|
|
23139
22857
|
keepProcessAlive,
|
|
23140
22858
|
logLevel: serverLogLevel,
|
|
23141
22859
|
startLog: false,
|
|
23142
|
-
|
|
22860
|
+
https,
|
|
23143
22861
|
http2,
|
|
23144
|
-
certificate,
|
|
23145
|
-
privateKey,
|
|
23146
22862
|
acceptAnyIp,
|
|
23147
22863
|
hostname,
|
|
23148
22864
|
port,
|
|
@@ -23225,14 +22941,14 @@ const startDevServer = async ({
|
|
|
23225
22941
|
// default error handling
|
|
23226
22942
|
jsenvServiceErrorHandler({
|
|
23227
22943
|
sendErrorDetails: true
|
|
23228
|
-
})]
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
22944
|
+
})]
|
|
22945
|
+
});
|
|
22946
|
+
server.stoppedPromise.then(reason => {
|
|
22947
|
+
onStop();
|
|
22948
|
+
serverStopCallbacks.forEach(serverStopCallback => {
|
|
22949
|
+
serverStopCallback(reason);
|
|
22950
|
+
});
|
|
22951
|
+
serverStopCallbacks.length = 0;
|
|
23236
22952
|
});
|
|
23237
22953
|
startDevServerTask.done();
|
|
23238
22954
|
if (hostname) {
|
|
@@ -23369,7 +23085,7 @@ const readNodeV8CoverageDirectory = async ({
|
|
|
23369
23085
|
timeSpentTrying += 200;
|
|
23370
23086
|
return tryReadJsonFile();
|
|
23371
23087
|
}
|
|
23372
|
-
console.warn(createDetailedMessage$
|
|
23088
|
+
console.warn(createDetailedMessage$1(`Error while reading coverage file`, {
|
|
23373
23089
|
"error stack": e.stack,
|
|
23374
23090
|
"file": dirEntryUrl
|
|
23375
23091
|
}));
|
|
@@ -23530,7 +23246,7 @@ const composeV8AndIstanbul = (v8FileByFileCoverage, istanbulFileByFileCoverage,
|
|
|
23530
23246
|
const v8Coverage = v8FileByFileCoverage[key];
|
|
23531
23247
|
if (v8Coverage) {
|
|
23532
23248
|
if (coverageV8ConflictWarning) {
|
|
23533
|
-
console.warn(createDetailedMessage$
|
|
23249
|
+
console.warn(createDetailedMessage$1(`Coverage conflict on "${key}", found two coverage that cannot be merged together: v8 and istanbul. The istanbul coverage will be ignored.`, {
|
|
23534
23250
|
details: `This happens when a file is executed on a runtime using v8 coverage (node or chromium) and on runtime using istanbul coverage (firefox or webkit)`,
|
|
23535
23251
|
suggestion: "You can disable this warning with coverageV8ConflictWarning: false"
|
|
23536
23252
|
}));
|
|
@@ -23924,7 +23640,7 @@ const run = async ({
|
|
|
23924
23640
|
cb(runResult);
|
|
23925
23641
|
} catch (e) {
|
|
23926
23642
|
cb({
|
|
23927
|
-
status: "
|
|
23643
|
+
status: "failed",
|
|
23928
23644
|
errors: [e]
|
|
23929
23645
|
});
|
|
23930
23646
|
}
|
|
@@ -23955,7 +23671,7 @@ const run = async ({
|
|
|
23955
23671
|
result.status = "aborted";
|
|
23956
23672
|
}
|
|
23957
23673
|
} else {
|
|
23958
|
-
result.status = "
|
|
23674
|
+
result.status = "failed";
|
|
23959
23675
|
result.errors.push(e);
|
|
23960
23676
|
}
|
|
23961
23677
|
} finally {
|
|
@@ -24043,7 +23759,7 @@ const generateFileExecutionSteps = ({
|
|
|
24043
23759
|
return;
|
|
24044
23760
|
}
|
|
24045
23761
|
if (typeof stepConfig !== "object") {
|
|
24046
|
-
throw new TypeError(createDetailedMessage$
|
|
23762
|
+
throw new TypeError(createDetailedMessage$1(`found unexpected value in plan, they must be object`, {
|
|
24047
23763
|
["file relative path"]: fileRelativeUrl,
|
|
24048
23764
|
["execution name"]: executionName,
|
|
24049
23765
|
["value"]: stepConfig
|
|
@@ -24062,7 +23778,7 @@ const EXECUTION_COLORS = {
|
|
|
24062
23778
|
executing: ANSI.BLUE,
|
|
24063
23779
|
aborted: ANSI.MAGENTA,
|
|
24064
23780
|
timedout: ANSI.MAGENTA,
|
|
24065
|
-
|
|
23781
|
+
failed: ANSI.RED,
|
|
24066
23782
|
completed: ANSI.GREEN,
|
|
24067
23783
|
cancelled: ANSI.GREY
|
|
24068
23784
|
};
|
|
@@ -24195,8 +23911,8 @@ const createStatusSummary = ({
|
|
|
24195
23911
|
if (counters.timedout === counters.total) {
|
|
24196
23912
|
return `all ${ANSI.color(`timed out`, EXECUTION_COLORS.timedout)}`;
|
|
24197
23913
|
}
|
|
24198
|
-
if (counters.
|
|
24199
|
-
return `all ${ANSI.color(`
|
|
23914
|
+
if (counters.failed === counters.total) {
|
|
23915
|
+
return `all ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`;
|
|
24200
23916
|
}
|
|
24201
23917
|
if (counters.completed === counters.total) {
|
|
24202
23918
|
return `all ${ANSI.color(`completed`, EXECUTION_COLORS.completed)}`;
|
|
@@ -24215,8 +23931,8 @@ const createMixedDetails = ({
|
|
|
24215
23931
|
if (counters.timedout) {
|
|
24216
23932
|
parts.push(`${counters.timedout} ${ANSI.color(`timed out`, EXECUTION_COLORS.timedout)}`);
|
|
24217
23933
|
}
|
|
24218
|
-
if (counters.
|
|
24219
|
-
parts.push(`${counters.
|
|
23934
|
+
if (counters.failed) {
|
|
23935
|
+
parts.push(`${counters.failed} ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`);
|
|
24220
23936
|
}
|
|
24221
23937
|
if (counters.completed) {
|
|
24222
23938
|
parts.push(`${counters.completed} ${ANSI.color(`completed`, EXECUTION_COLORS.completed)}`);
|
|
@@ -24249,11 +23965,11 @@ const descriptionFormatters = {
|
|
|
24249
23965
|
}) => {
|
|
24250
23966
|
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} timeout after ${executionParams.allocatedMs}ms`, EXECUTION_COLORS.timedout);
|
|
24251
23967
|
},
|
|
24252
|
-
|
|
23968
|
+
efailedrrored: ({
|
|
24253
23969
|
index,
|
|
24254
23970
|
total
|
|
24255
23971
|
}) => {
|
|
24256
|
-
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total}
|
|
23972
|
+
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} failed`, EXECUTION_COLORS.failed);
|
|
24257
23973
|
},
|
|
24258
23974
|
completed: ({
|
|
24259
23975
|
index,
|
|
@@ -24456,7 +24172,7 @@ const executePlan = async (plan, {
|
|
|
24456
24172
|
}
|
|
24457
24173
|
});
|
|
24458
24174
|
});
|
|
24459
|
-
logger.debug(createDetailedMessage$
|
|
24175
|
+
logger.debug(createDetailedMessage$1(`Prepare executing plan`, {
|
|
24460
24176
|
runtimes: JSON.stringify(runtimes, null, " ")
|
|
24461
24177
|
}));
|
|
24462
24178
|
const multipleExecutionsOperation = Abort.startOperation();
|
|
@@ -24483,7 +24199,7 @@ const executePlan = async (plan, {
|
|
|
24483
24199
|
await ensureEmptyDirectory(process.env.NODE_V8_COVERAGE);
|
|
24484
24200
|
} else {
|
|
24485
24201
|
coverageMethodForNodeJs = "Profiler";
|
|
24486
|
-
logger.warn(createDetailedMessage$
|
|
24202
|
+
logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
|
|
24487
24203
|
"suggestion": `set process.env.NODE_V8_COVERAGE`,
|
|
24488
24204
|
"suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
|
|
24489
24205
|
}));
|
|
@@ -24572,7 +24288,7 @@ const executePlan = async (plan, {
|
|
|
24572
24288
|
total: executionSteps.length,
|
|
24573
24289
|
aborted: 0,
|
|
24574
24290
|
timedout: 0,
|
|
24575
|
-
|
|
24291
|
+
failed: 0,
|
|
24576
24292
|
completed: 0,
|
|
24577
24293
|
done: 0
|
|
24578
24294
|
};
|
|
@@ -24655,7 +24371,7 @@ const executePlan = async (plan, {
|
|
|
24655
24371
|
});
|
|
24656
24372
|
} else {
|
|
24657
24373
|
executionResult = {
|
|
24658
|
-
status: "
|
|
24374
|
+
status: "failed",
|
|
24659
24375
|
errors: [new Error(`No file at ${fileRelativeUrl} for execution "${executionName}"`)]
|
|
24660
24376
|
};
|
|
24661
24377
|
}
|
|
@@ -24679,8 +24395,8 @@ const executePlan = async (plan, {
|
|
|
24679
24395
|
counters.aborted++;
|
|
24680
24396
|
} else if (executionResult.status === "timedout") {
|
|
24681
24397
|
counters.timedout++;
|
|
24682
|
-
} else if (executionResult.status === "
|
|
24683
|
-
counters.
|
|
24398
|
+
} else if (executionResult.status === "failed") {
|
|
24399
|
+
counters.failed++;
|
|
24684
24400
|
} else if (executionResult.status === "completed") {
|
|
24685
24401
|
counters.completed++;
|
|
24686
24402
|
}
|
|
@@ -24915,46 +24631,58 @@ const executeTestPlan = async ({
|
|
|
24915
24631
|
coverageReportSkipFull = false,
|
|
24916
24632
|
coverageReportTextLog = true,
|
|
24917
24633
|
coverageReportJsonFile = process.env.CI ? null : "./.coverage/coverage.json",
|
|
24918
|
-
coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null
|
|
24634
|
+
coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null,
|
|
24635
|
+
...rest
|
|
24919
24636
|
}) => {
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
|
|
24923
|
-
|
|
24924
|
-
|
|
24925
|
-
|
|
24926
|
-
|
|
24927
|
-
|
|
24928
|
-
|
|
24929
|
-
|
|
24930
|
-
|
|
24931
|
-
if (
|
|
24932
|
-
|
|
24933
|
-
}
|
|
24934
|
-
if (
|
|
24935
|
-
|
|
24936
|
-
|
|
24937
|
-
}
|
|
24938
|
-
|
|
24939
|
-
|
|
24940
|
-
|
|
24941
|
-
|
|
24942
|
-
const {
|
|
24943
|
-
cover
|
|
24944
|
-
}
|
|
24945
|
-
|
|
24946
|
-
|
|
24637
|
+
// param validation
|
|
24638
|
+
{
|
|
24639
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
24640
|
+
if (unexpectedParamNames.length > 0) {
|
|
24641
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
24642
|
+
}
|
|
24643
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
24644
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
24645
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
24646
|
+
}
|
|
24647
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
24648
|
+
if (typeof testPlan !== "object") {
|
|
24649
|
+
throw new Error(`testPlan must be an object, got ${testPlan}`);
|
|
24650
|
+
}
|
|
24651
|
+
if (coverageEnabled) {
|
|
24652
|
+
if (typeof coverageConfig !== "object") {
|
|
24653
|
+
throw new TypeError(`coverageConfig must be an object, got ${coverageConfig}`);
|
|
24654
|
+
}
|
|
24655
|
+
if (!coverageAndExecutionAllowed) {
|
|
24656
|
+
const associationsForExecute = URL_META.resolveAssociations({
|
|
24657
|
+
execute: testPlan
|
|
24658
|
+
}, "file:///");
|
|
24659
|
+
const associationsForCover = URL_META.resolveAssociations({
|
|
24660
|
+
cover: coverageConfig
|
|
24661
|
+
}, "file:///");
|
|
24662
|
+
const patternsMatchingCoverAndExecute = Object.keys(associationsForExecute.execute).filter(testPlanPattern => {
|
|
24663
|
+
const {
|
|
24664
|
+
cover
|
|
24665
|
+
} = URL_META.applyAssociations({
|
|
24666
|
+
url: testPlanPattern,
|
|
24667
|
+
associations: associationsForCover
|
|
24668
|
+
});
|
|
24669
|
+
return cover;
|
|
24947
24670
|
});
|
|
24948
|
-
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
}));
|
|
24671
|
+
if (patternsMatchingCoverAndExecute.length) {
|
|
24672
|
+
// It would be strange, for a given file to be both covered and executed
|
|
24673
|
+
throw new Error(createDetailedMessage$1(`some file will be both covered and executed`, {
|
|
24674
|
+
patterns: patternsMatchingCoverAndExecute
|
|
24675
|
+
}));
|
|
24676
|
+
}
|
|
24955
24677
|
}
|
|
24956
24678
|
}
|
|
24957
24679
|
}
|
|
24680
|
+
const logger = createLogger({
|
|
24681
|
+
logLevel
|
|
24682
|
+
});
|
|
24683
|
+
if (Object.keys(coverageConfig).length === 0) {
|
|
24684
|
+
logger.warn(`coverageConfig is an empty object. Nothing will be instrumented for coverage so your coverage will be empty`);
|
|
24685
|
+
}
|
|
24958
24686
|
const result = await executePlan(testPlan, {
|
|
24959
24687
|
signal,
|
|
24960
24688
|
handleSIGINT,
|
|
@@ -25334,12 +25062,12 @@ const createRuntimeFromPlaywright = ({
|
|
|
25334
25062
|
}
|
|
25335
25063
|
if (winner.name === "error") {
|
|
25336
25064
|
let error = winner.data;
|
|
25337
|
-
result.status = "
|
|
25065
|
+
result.status = "failed";
|
|
25338
25066
|
result.errors.push(error);
|
|
25339
25067
|
return;
|
|
25340
25068
|
}
|
|
25341
25069
|
if (winner.name === "closed") {
|
|
25342
|
-
result.status = "
|
|
25070
|
+
result.status = "failed";
|
|
25343
25071
|
result.errors.push(isBrowserDedicatedToExecution ? new Error(`browser disconnected during execution`) : new Error(`page closed during execution`));
|
|
25344
25072
|
return;
|
|
25345
25073
|
}
|
|
@@ -25351,8 +25079,8 @@ const createRuntimeFromPlaywright = ({
|
|
|
25351
25079
|
result.namespace = executionResults;
|
|
25352
25080
|
Object.keys(executionResults).forEach(key => {
|
|
25353
25081
|
const executionResult = executionResults[key];
|
|
25354
|
-
if (executionResult.status === "
|
|
25355
|
-
result.status = "
|
|
25082
|
+
if (executionResult.status === "failed") {
|
|
25083
|
+
result.status = "failed";
|
|
25356
25084
|
result.errors.push({
|
|
25357
25085
|
...executionResult.exception,
|
|
25358
25086
|
stack: executionResult.exception.text
|
|
@@ -25370,7 +25098,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
25370
25098
|
await callback();
|
|
25371
25099
|
}, Promise.resolve());
|
|
25372
25100
|
} catch (e) {
|
|
25373
|
-
result.status = "
|
|
25101
|
+
result.status = "failed";
|
|
25374
25102
|
result.errors = [e];
|
|
25375
25103
|
}
|
|
25376
25104
|
if (keepRunning) {
|
|
@@ -25452,7 +25180,7 @@ const importPlaywright = async ({
|
|
|
25452
25180
|
return namespace;
|
|
25453
25181
|
} catch (e) {
|
|
25454
25182
|
if (e.code === "ERR_MODULE_NOT_FOUND") {
|
|
25455
|
-
throw new Error(createDetailedMessage$
|
|
25183
|
+
throw new Error(createDetailedMessage$1(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
|
|
25456
25184
|
suggestion: `npm install --save-dev playwright`
|
|
25457
25185
|
}), {
|
|
25458
25186
|
cause: e
|
|
@@ -25610,7 +25338,7 @@ const createChildExecOptions = async ({
|
|
|
25610
25338
|
debugModeInheritBreak = true
|
|
25611
25339
|
} = {}) => {
|
|
25612
25340
|
if (typeof debugMode === "string" && AVAILABLE_DEBUG_MODE.indexOf(debugMode) === -1) {
|
|
25613
|
-
throw new TypeError(createDetailedMessage$
|
|
25341
|
+
throw new TypeError(createDetailedMessage$1(`unexpected debug mode.`, {
|
|
25614
25342
|
["debug mode"]: debugMode,
|
|
25615
25343
|
["allowed debug mode"]: AVAILABLE_DEBUG_MODE
|
|
25616
25344
|
}));
|
|
@@ -25876,7 +25604,7 @@ nodeChildProcess.run = async ({
|
|
|
25876
25604
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
25877
25605
|
env: envForChildProcess
|
|
25878
25606
|
});
|
|
25879
|
-
logger.debug(createDetailedMessage$
|
|
25607
|
+
logger.debug(createDetailedMessage$1(`child process forked (pid ${childProcess.pid})`, {
|
|
25880
25608
|
"execArgv": execArgv.join(`\n`),
|
|
25881
25609
|
"custom env": JSON.stringify(env, null, " ")
|
|
25882
25610
|
}));
|
|
@@ -25999,7 +25727,7 @@ nodeChildProcess.run = async ({
|
|
|
25999
25727
|
if (winner.name === "error") {
|
|
26000
25728
|
const error = winner.data;
|
|
26001
25729
|
removeOutputListener();
|
|
26002
|
-
result.status = "
|
|
25730
|
+
result.status = "failed";
|
|
26003
25731
|
result.errors.push(error);
|
|
26004
25732
|
return;
|
|
26005
25733
|
}
|
|
@@ -26009,18 +25737,18 @@ nodeChildProcess.run = async ({
|
|
|
26009
25737
|
} = winner.data;
|
|
26010
25738
|
await cleanup("process exit");
|
|
26011
25739
|
if (code === 12) {
|
|
26012
|
-
result.status = "
|
|
25740
|
+
result.status = "failed";
|
|
26013
25741
|
result.errors.push(new Error(`node process exited with 12 (the forked child process wanted to use a non-available port for debug)`));
|
|
26014
25742
|
return;
|
|
26015
25743
|
}
|
|
26016
25744
|
if (code === null || code === 0 || code === EXIT_CODES.SIGINT || code === EXIT_CODES.SIGTERM || code === EXIT_CODES.SIGABORT) {
|
|
26017
|
-
result.status = "
|
|
25745
|
+
result.status = "failed";
|
|
26018
25746
|
result.errors.push(new Error(`node process exited during execution`));
|
|
26019
25747
|
return;
|
|
26020
25748
|
}
|
|
26021
25749
|
// process.exit(1) in child process or process.exitCode = 1 + process.exit()
|
|
26022
25750
|
// means there was an error even if we don't know exactly what.
|
|
26023
|
-
result.status = "
|
|
25751
|
+
result.status = "failed";
|
|
26024
25752
|
result.errors.push(new Error(`node process exited with code ${code} during execution`));
|
|
26025
25753
|
return;
|
|
26026
25754
|
}
|
|
@@ -26029,7 +25757,7 @@ nodeChildProcess.run = async ({
|
|
|
26029
25757
|
value
|
|
26030
25758
|
} = winner.data;
|
|
26031
25759
|
if (status === "action-failed") {
|
|
26032
|
-
result.status = "
|
|
25760
|
+
result.status = "failed";
|
|
26033
25761
|
result.errors.push(value);
|
|
26034
25762
|
return;
|
|
26035
25763
|
}
|
|
@@ -26046,7 +25774,7 @@ nodeChildProcess.run = async ({
|
|
|
26046
25774
|
try {
|
|
26047
25775
|
await writeResult();
|
|
26048
25776
|
} catch (e) {
|
|
26049
|
-
result.status = "
|
|
25777
|
+
result.status = "failed";
|
|
26050
25778
|
result.errors.push(e);
|
|
26051
25779
|
}
|
|
26052
25780
|
if (keepRunning) {
|
|
@@ -26272,7 +26000,7 @@ nodeWorkerThread.run = async ({
|
|
|
26272
26000
|
if (winner.name === "error") {
|
|
26273
26001
|
const error = winner.data;
|
|
26274
26002
|
removeOutputListener();
|
|
26275
|
-
result.status = "
|
|
26003
|
+
result.status = "failed";
|
|
26276
26004
|
result.errors.push(error);
|
|
26277
26005
|
return;
|
|
26278
26006
|
}
|
|
@@ -26282,18 +26010,18 @@ nodeWorkerThread.run = async ({
|
|
|
26282
26010
|
} = winner.data;
|
|
26283
26011
|
await cleanup("process exit");
|
|
26284
26012
|
if (code === 12) {
|
|
26285
|
-
result.status = "
|
|
26013
|
+
result.status = "failed";
|
|
26286
26014
|
result.errors.push(new Error(`node process exited with 12 (the forked child process wanted to use a non-available port for debug)`));
|
|
26287
26015
|
return;
|
|
26288
26016
|
}
|
|
26289
26017
|
if (code === null || code === 0 || code === EXIT_CODES.SIGINT || code === EXIT_CODES.SIGTERM || code === EXIT_CODES.SIGABORT) {
|
|
26290
|
-
result.status = "
|
|
26018
|
+
result.status = "failed";
|
|
26291
26019
|
result.errors.push(new Error(`node worker thread exited during execution`));
|
|
26292
26020
|
return;
|
|
26293
26021
|
}
|
|
26294
26022
|
// process.exit(1) in child process or process.exitCode = 1 + process.exit()
|
|
26295
26023
|
// means there was an error even if we don't know exactly what.
|
|
26296
|
-
result.status = "
|
|
26024
|
+
result.status = "failed";
|
|
26297
26025
|
result.errors.push(new Error(`node worker thread exited with code ${code} during execution`));
|
|
26298
26026
|
}
|
|
26299
26027
|
const {
|
|
@@ -26301,7 +26029,7 @@ nodeWorkerThread.run = async ({
|
|
|
26301
26029
|
value
|
|
26302
26030
|
} = winner.data;
|
|
26303
26031
|
if (status === "action-failed") {
|
|
26304
|
-
result.status = "
|
|
26032
|
+
result.status = "failed";
|
|
26305
26033
|
result.errors.push(value);
|
|
26306
26034
|
return;
|
|
26307
26035
|
}
|
|
@@ -26318,7 +26046,7 @@ nodeWorkerThread.run = async ({
|
|
|
26318
26046
|
try {
|
|
26319
26047
|
await writeResult();
|
|
26320
26048
|
} catch (e) {
|
|
26321
|
-
result.status = "
|
|
26049
|
+
result.status = "failed";
|
|
26322
26050
|
result.errors.push(e);
|
|
26323
26051
|
}
|
|
26324
26052
|
if (keepRunning) {
|
|
@@ -26409,10 +26137,8 @@ const startBuildServer = async ({
|
|
|
26409
26137
|
handleSIGINT = true,
|
|
26410
26138
|
logLevel,
|
|
26411
26139
|
serverLogLevel = "warn",
|
|
26412
|
-
|
|
26140
|
+
https,
|
|
26413
26141
|
http2,
|
|
26414
|
-
certificate,
|
|
26415
|
-
privateKey,
|
|
26416
26142
|
acceptAnyIp,
|
|
26417
26143
|
hostname,
|
|
26418
26144
|
port = 9779,
|
|
@@ -26429,7 +26155,7 @@ const startBuildServer = async ({
|
|
|
26429
26155
|
buildServerMainFile = getCallerPosition().url,
|
|
26430
26156
|
cooldownBetweenFileEvents
|
|
26431
26157
|
}) => {
|
|
26432
|
-
const logger = createLogger
|
|
26158
|
+
const logger = createLogger({
|
|
26433
26159
|
logLevel
|
|
26434
26160
|
});
|
|
26435
26161
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -26539,10 +26265,8 @@ const startBuildServer = async ({
|
|
|
26539
26265
|
keepProcessAlive,
|
|
26540
26266
|
logLevel: serverLogLevel,
|
|
26541
26267
|
startLog: false,
|
|
26542
|
-
|
|
26268
|
+
https,
|
|
26543
26269
|
http2,
|
|
26544
|
-
certificate,
|
|
26545
|
-
privateKey,
|
|
26546
26270
|
acceptAnyIp,
|
|
26547
26271
|
hostname,
|
|
26548
26272
|
port,
|
|
@@ -26638,7 +26362,7 @@ const execute = async ({
|
|
|
26638
26362
|
runtimeParams,
|
|
26639
26363
|
ignoreError = false
|
|
26640
26364
|
}) => {
|
|
26641
|
-
const logger = createLogger
|
|
26365
|
+
const logger = createLogger({
|
|
26642
26366
|
logLevel
|
|
26643
26367
|
});
|
|
26644
26368
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -26682,7 +26406,7 @@ const execute = async ({
|
|
|
26682
26406
|
});
|
|
26683
26407
|
result = resultTransformer(result);
|
|
26684
26408
|
try {
|
|
26685
|
-
if (result.status === "
|
|
26409
|
+
if (result.status === "failed") {
|
|
26686
26410
|
if (ignoreError) {
|
|
26687
26411
|
return result;
|
|
26688
26412
|
}
|