@jsenv/core 30.4.2 → 31.0.1
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 +582 -832
- package/package.json +5 -5
- package/src/build/build.js +26 -3
- package/src/build/start_build_server.js +43 -24
- package/src/dev/file_service.js +2 -1
- package/src/dev/start_dev_server.js +31 -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/kitchen/kitchen.js +11 -1
- 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;
|
|
3541
|
-
};
|
|
3542
|
-
ansiEscapes.eraseEndLine = ESC + 'K';
|
|
3543
|
-
ansiEscapes.eraseStartLine = ESC + '1K';
|
|
3544
|
-
ansiEscapes.eraseLine = ESC + '2K';
|
|
3545
|
-
ansiEscapes.eraseDown = ESC + 'J';
|
|
3546
|
-
ansiEscapes.eraseUp = ESC + '1J';
|
|
3547
|
-
ansiEscapes.eraseScreen = ESC + '2J';
|
|
3548
|
-
ansiEscapes.scrollUp = ESC + 'S';
|
|
3549
|
-
ansiEscapes.scrollDown = ESC + 'T';
|
|
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}`;
|
|
3137
|
+
streamOutputSpy = null;
|
|
3138
|
+
lastOutput = "";
|
|
3139
|
+
}
|
|
3140
|
+
};
|
|
3141
|
+
Object.assign(log, {
|
|
3142
|
+
write,
|
|
3143
|
+
dynamicWrite,
|
|
3144
|
+
destroy
|
|
3145
|
+
});
|
|
3146
|
+
return log;
|
|
3147
|
+
};
|
|
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
|
}));
|
|
@@ -9530,7 +9225,13 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9530
9225
|
} = urlInfo;
|
|
9531
9226
|
if (generatedUrl && generatedUrl.startsWith("file:")) {
|
|
9532
9227
|
if (urlInfo.type === "directory") ; else if (urlInfo.content === null) ; else {
|
|
9533
|
-
|
|
9228
|
+
let contentIsInlined = urlInfo.isInline;
|
|
9229
|
+
if (contentIsInlined && context.supervisor && urlGraph.getUrlInfo(urlInfo.inlineUrlSite.url).type === "html") {
|
|
9230
|
+
contentIsInlined = false;
|
|
9231
|
+
}
|
|
9232
|
+
if (!contentIsInlined) {
|
|
9233
|
+
writeFileSync(new URL(generatedUrl), urlInfo.content);
|
|
9234
|
+
}
|
|
9534
9235
|
const {
|
|
9535
9236
|
sourcemapGeneratedUrl,
|
|
9536
9237
|
sourcemap
|
|
@@ -15417,10 +15118,7 @@ const jsenvPluginAsJsClassicLibrary = ({
|
|
|
15417
15118
|
...context,
|
|
15418
15119
|
buildDirectoryUrl: context.outDirectoryUrl
|
|
15419
15120
|
},
|
|
15420
|
-
|
|
15421
|
-
babelHelpersChunk: false,
|
|
15422
|
-
preserveDynamicImport: true
|
|
15423
|
-
}
|
|
15121
|
+
preserveDynamicImport: true
|
|
15424
15122
|
});
|
|
15425
15123
|
const jsModuleBundledUrlInfo = bundleUrlInfos[jsModuleUrlInfo.url];
|
|
15426
15124
|
if (context.dev) {
|
|
@@ -21036,8 +20734,26 @@ const build = async ({
|
|
|
21036
20734
|
writeOnFileSystem = true,
|
|
21037
20735
|
writeGeneratedFiles = false,
|
|
21038
20736
|
assetManifest = versioningMethod === "filename",
|
|
21039
|
-
assetManifestFileRelativeUrl = "asset-manifest.json"
|
|
20737
|
+
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
20738
|
+
...rest
|
|
21040
20739
|
}) => {
|
|
20740
|
+
// param validation
|
|
20741
|
+
{
|
|
20742
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
20743
|
+
if (unexpectedParamNames.length > 0) {
|
|
20744
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
20745
|
+
}
|
|
20746
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
20747
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
20748
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
20749
|
+
}
|
|
20750
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
20751
|
+
const buildDirectoryUrlValidation = validateDirectoryUrl(buildDirectoryUrl);
|
|
20752
|
+
if (!buildDirectoryUrlValidation.valid) {
|
|
20753
|
+
throw new TypeError(`buildDirectoryUrl ${buildDirectoryUrlValidation.message}, got ${buildDirectoryUrlValidation}`);
|
|
20754
|
+
}
|
|
20755
|
+
buildDirectoryUrl = buildDirectoryUrlValidation.value;
|
|
20756
|
+
}
|
|
21041
20757
|
const operation = Abort.startOperation();
|
|
21042
20758
|
operation.addAbortSignal(signal);
|
|
21043
20759
|
if (handleSIGINT) {
|
|
@@ -21047,8 +20763,6 @@ const build = async ({
|
|
|
21047
20763
|
}, abort);
|
|
21048
20764
|
});
|
|
21049
20765
|
}
|
|
21050
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
21051
|
-
buildDirectoryUrl = assertAndNormalizeDirectoryUrl(buildDirectoryUrl);
|
|
21052
20766
|
assertEntryPoints({
|
|
21053
20767
|
entryPoints
|
|
21054
20768
|
});
|
|
@@ -21081,7 +20795,7 @@ const build = async ({
|
|
|
21081
20795
|
signal,
|
|
21082
20796
|
logLevel
|
|
21083
20797
|
}) => {
|
|
21084
|
-
const logger = createLogger
|
|
20798
|
+
const logger = createLogger({
|
|
21085
20799
|
logLevel
|
|
21086
20800
|
});
|
|
21087
20801
|
const buildOperation = Abort.startOperation();
|
|
@@ -21366,7 +21080,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21366
21080
|
const rawUrl = buildDirectoryRedirections.get(url) || url;
|
|
21367
21081
|
const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
|
|
21368
21082
|
if (!rawUrlInfo) {
|
|
21369
|
-
throw new Error(createDetailedMessage$
|
|
21083
|
+
throw new Error(createDetailedMessage$1(`Cannot find url`, {
|
|
21370
21084
|
url,
|
|
21371
21085
|
"raw urls": Array.from(buildDirectoryRedirections.values()),
|
|
21372
21086
|
"build urls": Array.from(buildDirectoryRedirections.keys())
|
|
@@ -22548,6 +22262,7 @@ const createFileService = ({
|
|
|
22548
22262
|
logLevel,
|
|
22549
22263
|
serverStopCallbacks,
|
|
22550
22264
|
serverEventsDispatcher,
|
|
22265
|
+
contextCache,
|
|
22551
22266
|
rootDirectoryUrl,
|
|
22552
22267
|
runtimeCompat,
|
|
22553
22268
|
plugins,
|
|
@@ -22611,7 +22326,6 @@ const createFileService = ({
|
|
|
22611
22326
|
}
|
|
22612
22327
|
});
|
|
22613
22328
|
serverStopCallbacks.push(stopWatchingClientFiles);
|
|
22614
|
-
const contextCache = new Map();
|
|
22615
22329
|
const getOrCreateContext = request => {
|
|
22616
22330
|
const {
|
|
22617
22331
|
runtimeName,
|
|
@@ -22672,6 +22386,7 @@ const createFileService = ({
|
|
|
22672
22386
|
cacheControl,
|
|
22673
22387
|
ribbon
|
|
22674
22388
|
})],
|
|
22389
|
+
supervisor,
|
|
22675
22390
|
minification: false,
|
|
22676
22391
|
sourcemaps,
|
|
22677
22392
|
sourcemapsSourcesProtocol,
|
|
@@ -22996,12 +22711,10 @@ const startDevServer = async ({
|
|
|
22996
22711
|
handleSIGINT = true,
|
|
22997
22712
|
logLevel = "info",
|
|
22998
22713
|
serverLogLevel = "warn",
|
|
22999
|
-
|
|
22714
|
+
https,
|
|
23000
22715
|
// it's better to use http1 by default because it allows to get statusText in devtools
|
|
23001
22716
|
// which gives valuable information when there is errors
|
|
23002
22717
|
http2 = false,
|
|
23003
|
-
certificate,
|
|
23004
|
-
privateKey,
|
|
23005
22718
|
hostname,
|
|
23006
22719
|
port = 3456,
|
|
23007
22720
|
acceptAnyIp,
|
|
@@ -23044,12 +22757,24 @@ const startDevServer = async ({
|
|
|
23044
22757
|
sourcemapsSourcesContent,
|
|
23045
22758
|
// no real need to write files during github workflow
|
|
23046
22759
|
// and mitigates https://github.com/actions/runner-images/issues/3885
|
|
23047
|
-
writeGeneratedFiles = !process.env.CI
|
|
22760
|
+
writeGeneratedFiles = !process.env.CI,
|
|
22761
|
+
...rest
|
|
23048
22762
|
}) => {
|
|
23049
|
-
|
|
22763
|
+
// params type checking
|
|
22764
|
+
{
|
|
22765
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
22766
|
+
if (unexpectedParamNames.length > 0) {
|
|
22767
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
22768
|
+
}
|
|
22769
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
22770
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
22771
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
22772
|
+
}
|
|
22773
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
22774
|
+
}
|
|
22775
|
+
const logger = createLogger({
|
|
23050
22776
|
logLevel
|
|
23051
22777
|
});
|
|
23052
|
-
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
23053
22778
|
const operation = Abort.startOperation();
|
|
23054
22779
|
operation.addAbortSignal(signal);
|
|
23055
22780
|
if (handleSIGINT) {
|
|
@@ -23131,6 +22856,7 @@ const startDevServer = async ({
|
|
|
23131
22856
|
serverStopCallbacks.push(() => {
|
|
23132
22857
|
serverEventsDispatcher.destroy();
|
|
23133
22858
|
});
|
|
22859
|
+
const contextCache = new Map();
|
|
23134
22860
|
const server = await startServer({
|
|
23135
22861
|
signal,
|
|
23136
22862
|
stopOnExit: false,
|
|
@@ -23139,10 +22865,8 @@ const startDevServer = async ({
|
|
|
23139
22865
|
keepProcessAlive,
|
|
23140
22866
|
logLevel: serverLogLevel,
|
|
23141
22867
|
startLog: false,
|
|
23142
|
-
|
|
22868
|
+
https,
|
|
23143
22869
|
http2,
|
|
23144
|
-
certificate,
|
|
23145
|
-
privateKey,
|
|
23146
22870
|
acceptAnyIp,
|
|
23147
22871
|
hostname,
|
|
23148
22872
|
port,
|
|
@@ -23161,6 +22885,7 @@ const startDevServer = async ({
|
|
|
23161
22885
|
logLevel,
|
|
23162
22886
|
serverStopCallbacks,
|
|
23163
22887
|
serverEventsDispatcher,
|
|
22888
|
+
contextCache,
|
|
23164
22889
|
rootDirectoryUrl,
|
|
23165
22890
|
runtimeCompat,
|
|
23166
22891
|
plugins,
|
|
@@ -23225,14 +22950,14 @@ const startDevServer = async ({
|
|
|
23225
22950
|
// default error handling
|
|
23226
22951
|
jsenvServiceErrorHandler({
|
|
23227
22952
|
sendErrorDetails: true
|
|
23228
|
-
})]
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
|
|
23234
|
-
|
|
23235
|
-
|
|
22953
|
+
})]
|
|
22954
|
+
});
|
|
22955
|
+
server.stoppedPromise.then(reason => {
|
|
22956
|
+
onStop();
|
|
22957
|
+
serverStopCallbacks.forEach(serverStopCallback => {
|
|
22958
|
+
serverStopCallback(reason);
|
|
22959
|
+
});
|
|
22960
|
+
serverStopCallbacks.length = 0;
|
|
23236
22961
|
});
|
|
23237
22962
|
startDevServerTask.done();
|
|
23238
22963
|
if (hostname) {
|
|
@@ -23251,7 +22976,8 @@ const startDevServer = async ({
|
|
|
23251
22976
|
origin: server.origin,
|
|
23252
22977
|
stop: () => {
|
|
23253
22978
|
server.stop();
|
|
23254
|
-
}
|
|
22979
|
+
},
|
|
22980
|
+
contextCache
|
|
23255
22981
|
};
|
|
23256
22982
|
};
|
|
23257
22983
|
|
|
@@ -23369,7 +23095,7 @@ const readNodeV8CoverageDirectory = async ({
|
|
|
23369
23095
|
timeSpentTrying += 200;
|
|
23370
23096
|
return tryReadJsonFile();
|
|
23371
23097
|
}
|
|
23372
|
-
console.warn(createDetailedMessage$
|
|
23098
|
+
console.warn(createDetailedMessage$1(`Error while reading coverage file`, {
|
|
23373
23099
|
"error stack": e.stack,
|
|
23374
23100
|
"file": dirEntryUrl
|
|
23375
23101
|
}));
|
|
@@ -23530,7 +23256,7 @@ const composeV8AndIstanbul = (v8FileByFileCoverage, istanbulFileByFileCoverage,
|
|
|
23530
23256
|
const v8Coverage = v8FileByFileCoverage[key];
|
|
23531
23257
|
if (v8Coverage) {
|
|
23532
23258
|
if (coverageV8ConflictWarning) {
|
|
23533
|
-
console.warn(createDetailedMessage$
|
|
23259
|
+
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
23260
|
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
23261
|
suggestion: "You can disable this warning with coverageV8ConflictWarning: false"
|
|
23536
23262
|
}));
|
|
@@ -23924,7 +23650,7 @@ const run = async ({
|
|
|
23924
23650
|
cb(runResult);
|
|
23925
23651
|
} catch (e) {
|
|
23926
23652
|
cb({
|
|
23927
|
-
status: "
|
|
23653
|
+
status: "failed",
|
|
23928
23654
|
errors: [e]
|
|
23929
23655
|
});
|
|
23930
23656
|
}
|
|
@@ -23955,7 +23681,7 @@ const run = async ({
|
|
|
23955
23681
|
result.status = "aborted";
|
|
23956
23682
|
}
|
|
23957
23683
|
} else {
|
|
23958
|
-
result.status = "
|
|
23684
|
+
result.status = "failed";
|
|
23959
23685
|
result.errors.push(e);
|
|
23960
23686
|
}
|
|
23961
23687
|
} finally {
|
|
@@ -24043,7 +23769,7 @@ const generateFileExecutionSteps = ({
|
|
|
24043
23769
|
return;
|
|
24044
23770
|
}
|
|
24045
23771
|
if (typeof stepConfig !== "object") {
|
|
24046
|
-
throw new TypeError(createDetailedMessage$
|
|
23772
|
+
throw new TypeError(createDetailedMessage$1(`found unexpected value in plan, they must be object`, {
|
|
24047
23773
|
["file relative path"]: fileRelativeUrl,
|
|
24048
23774
|
["execution name"]: executionName,
|
|
24049
23775
|
["value"]: stepConfig
|
|
@@ -24062,7 +23788,7 @@ const EXECUTION_COLORS = {
|
|
|
24062
23788
|
executing: ANSI.BLUE,
|
|
24063
23789
|
aborted: ANSI.MAGENTA,
|
|
24064
23790
|
timedout: ANSI.MAGENTA,
|
|
24065
|
-
|
|
23791
|
+
failed: ANSI.RED,
|
|
24066
23792
|
completed: ANSI.GREEN,
|
|
24067
23793
|
cancelled: ANSI.GREY
|
|
24068
23794
|
};
|
|
@@ -24195,8 +23921,8 @@ const createStatusSummary = ({
|
|
|
24195
23921
|
if (counters.timedout === counters.total) {
|
|
24196
23922
|
return `all ${ANSI.color(`timed out`, EXECUTION_COLORS.timedout)}`;
|
|
24197
23923
|
}
|
|
24198
|
-
if (counters.
|
|
24199
|
-
return `all ${ANSI.color(`
|
|
23924
|
+
if (counters.failed === counters.total) {
|
|
23925
|
+
return `all ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`;
|
|
24200
23926
|
}
|
|
24201
23927
|
if (counters.completed === counters.total) {
|
|
24202
23928
|
return `all ${ANSI.color(`completed`, EXECUTION_COLORS.completed)}`;
|
|
@@ -24215,8 +23941,8 @@ const createMixedDetails = ({
|
|
|
24215
23941
|
if (counters.timedout) {
|
|
24216
23942
|
parts.push(`${counters.timedout} ${ANSI.color(`timed out`, EXECUTION_COLORS.timedout)}`);
|
|
24217
23943
|
}
|
|
24218
|
-
if (counters.
|
|
24219
|
-
parts.push(`${counters.
|
|
23944
|
+
if (counters.failed) {
|
|
23945
|
+
parts.push(`${counters.failed} ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`);
|
|
24220
23946
|
}
|
|
24221
23947
|
if (counters.completed) {
|
|
24222
23948
|
parts.push(`${counters.completed} ${ANSI.color(`completed`, EXECUTION_COLORS.completed)}`);
|
|
@@ -24249,11 +23975,11 @@ const descriptionFormatters = {
|
|
|
24249
23975
|
}) => {
|
|
24250
23976
|
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} timeout after ${executionParams.allocatedMs}ms`, EXECUTION_COLORS.timedout);
|
|
24251
23977
|
},
|
|
24252
|
-
|
|
23978
|
+
efailedrrored: ({
|
|
24253
23979
|
index,
|
|
24254
23980
|
total
|
|
24255
23981
|
}) => {
|
|
24256
|
-
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total}
|
|
23982
|
+
return ANSI.color(`${UNICODE.FAILURE_RAW} execution ${index + 1} of ${total} failed`, EXECUTION_COLORS.failed);
|
|
24257
23983
|
},
|
|
24258
23984
|
completed: ({
|
|
24259
23985
|
index,
|
|
@@ -24456,7 +24182,7 @@ const executePlan = async (plan, {
|
|
|
24456
24182
|
}
|
|
24457
24183
|
});
|
|
24458
24184
|
});
|
|
24459
|
-
logger.debug(createDetailedMessage$
|
|
24185
|
+
logger.debug(createDetailedMessage$1(`Prepare executing plan`, {
|
|
24460
24186
|
runtimes: JSON.stringify(runtimes, null, " ")
|
|
24461
24187
|
}));
|
|
24462
24188
|
const multipleExecutionsOperation = Abort.startOperation();
|
|
@@ -24483,7 +24209,7 @@ const executePlan = async (plan, {
|
|
|
24483
24209
|
await ensureEmptyDirectory(process.env.NODE_V8_COVERAGE);
|
|
24484
24210
|
} else {
|
|
24485
24211
|
coverageMethodForNodeJs = "Profiler";
|
|
24486
|
-
logger.warn(createDetailedMessage$
|
|
24212
|
+
logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
|
|
24487
24213
|
"suggestion": `set process.env.NODE_V8_COVERAGE`,
|
|
24488
24214
|
"suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
|
|
24489
24215
|
}));
|
|
@@ -24572,7 +24298,7 @@ const executePlan = async (plan, {
|
|
|
24572
24298
|
total: executionSteps.length,
|
|
24573
24299
|
aborted: 0,
|
|
24574
24300
|
timedout: 0,
|
|
24575
|
-
|
|
24301
|
+
failed: 0,
|
|
24576
24302
|
completed: 0,
|
|
24577
24303
|
done: 0
|
|
24578
24304
|
};
|
|
@@ -24655,7 +24381,7 @@ const executePlan = async (plan, {
|
|
|
24655
24381
|
});
|
|
24656
24382
|
} else {
|
|
24657
24383
|
executionResult = {
|
|
24658
|
-
status: "
|
|
24384
|
+
status: "failed",
|
|
24659
24385
|
errors: [new Error(`No file at ${fileRelativeUrl} for execution "${executionName}"`)]
|
|
24660
24386
|
};
|
|
24661
24387
|
}
|
|
@@ -24679,8 +24405,8 @@ const executePlan = async (plan, {
|
|
|
24679
24405
|
counters.aborted++;
|
|
24680
24406
|
} else if (executionResult.status === "timedout") {
|
|
24681
24407
|
counters.timedout++;
|
|
24682
|
-
} else if (executionResult.status === "
|
|
24683
|
-
counters.
|
|
24408
|
+
} else if (executionResult.status === "failed") {
|
|
24409
|
+
counters.failed++;
|
|
24684
24410
|
} else if (executionResult.status === "completed") {
|
|
24685
24411
|
counters.completed++;
|
|
24686
24412
|
}
|
|
@@ -24915,46 +24641,58 @@ const executeTestPlan = async ({
|
|
|
24915
24641
|
coverageReportSkipFull = false,
|
|
24916
24642
|
coverageReportTextLog = true,
|
|
24917
24643
|
coverageReportJsonFile = process.env.CI ? null : "./.coverage/coverage.json",
|
|
24918
|
-
coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null
|
|
24644
|
+
coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null,
|
|
24645
|
+
...rest
|
|
24919
24646
|
}) => {
|
|
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
|
-
|
|
24647
|
+
// param validation
|
|
24648
|
+
{
|
|
24649
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
24650
|
+
if (unexpectedParamNames.length > 0) {
|
|
24651
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
24652
|
+
}
|
|
24653
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
24654
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
24655
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
24656
|
+
}
|
|
24657
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
24658
|
+
if (typeof testPlan !== "object") {
|
|
24659
|
+
throw new Error(`testPlan must be an object, got ${testPlan}`);
|
|
24660
|
+
}
|
|
24661
|
+
if (coverageEnabled) {
|
|
24662
|
+
if (typeof coverageConfig !== "object") {
|
|
24663
|
+
throw new TypeError(`coverageConfig must be an object, got ${coverageConfig}`);
|
|
24664
|
+
}
|
|
24665
|
+
if (!coverageAndExecutionAllowed) {
|
|
24666
|
+
const associationsForExecute = URL_META.resolveAssociations({
|
|
24667
|
+
execute: testPlan
|
|
24668
|
+
}, "file:///");
|
|
24669
|
+
const associationsForCover = URL_META.resolveAssociations({
|
|
24670
|
+
cover: coverageConfig
|
|
24671
|
+
}, "file:///");
|
|
24672
|
+
const patternsMatchingCoverAndExecute = Object.keys(associationsForExecute.execute).filter(testPlanPattern => {
|
|
24673
|
+
const {
|
|
24674
|
+
cover
|
|
24675
|
+
} = URL_META.applyAssociations({
|
|
24676
|
+
url: testPlanPattern,
|
|
24677
|
+
associations: associationsForCover
|
|
24678
|
+
});
|
|
24679
|
+
return cover;
|
|
24947
24680
|
});
|
|
24948
|
-
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
}));
|
|
24681
|
+
if (patternsMatchingCoverAndExecute.length) {
|
|
24682
|
+
// It would be strange, for a given file to be both covered and executed
|
|
24683
|
+
throw new Error(createDetailedMessage$1(`some file will be both covered and executed`, {
|
|
24684
|
+
patterns: patternsMatchingCoverAndExecute
|
|
24685
|
+
}));
|
|
24686
|
+
}
|
|
24955
24687
|
}
|
|
24956
24688
|
}
|
|
24957
24689
|
}
|
|
24690
|
+
const logger = createLogger({
|
|
24691
|
+
logLevel
|
|
24692
|
+
});
|
|
24693
|
+
if (Object.keys(coverageConfig).length === 0) {
|
|
24694
|
+
logger.warn(`coverageConfig is an empty object. Nothing will be instrumented for coverage so your coverage will be empty`);
|
|
24695
|
+
}
|
|
24958
24696
|
const result = await executePlan(testPlan, {
|
|
24959
24697
|
signal,
|
|
24960
24698
|
handleSIGINT,
|
|
@@ -25334,12 +25072,12 @@ const createRuntimeFromPlaywright = ({
|
|
|
25334
25072
|
}
|
|
25335
25073
|
if (winner.name === "error") {
|
|
25336
25074
|
let error = winner.data;
|
|
25337
|
-
result.status = "
|
|
25075
|
+
result.status = "failed";
|
|
25338
25076
|
result.errors.push(error);
|
|
25339
25077
|
return;
|
|
25340
25078
|
}
|
|
25341
25079
|
if (winner.name === "closed") {
|
|
25342
|
-
result.status = "
|
|
25080
|
+
result.status = "failed";
|
|
25343
25081
|
result.errors.push(isBrowserDedicatedToExecution ? new Error(`browser disconnected during execution`) : new Error(`page closed during execution`));
|
|
25344
25082
|
return;
|
|
25345
25083
|
}
|
|
@@ -25351,8 +25089,8 @@ const createRuntimeFromPlaywright = ({
|
|
|
25351
25089
|
result.namespace = executionResults;
|
|
25352
25090
|
Object.keys(executionResults).forEach(key => {
|
|
25353
25091
|
const executionResult = executionResults[key];
|
|
25354
|
-
if (executionResult.status === "
|
|
25355
|
-
result.status = "
|
|
25092
|
+
if (executionResult.status === "failed") {
|
|
25093
|
+
result.status = "failed";
|
|
25356
25094
|
result.errors.push({
|
|
25357
25095
|
...executionResult.exception,
|
|
25358
25096
|
stack: executionResult.exception.text
|
|
@@ -25370,7 +25108,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
25370
25108
|
await callback();
|
|
25371
25109
|
}, Promise.resolve());
|
|
25372
25110
|
} catch (e) {
|
|
25373
|
-
result.status = "
|
|
25111
|
+
result.status = "failed";
|
|
25374
25112
|
result.errors = [e];
|
|
25375
25113
|
}
|
|
25376
25114
|
if (keepRunning) {
|
|
@@ -25452,7 +25190,7 @@ const importPlaywright = async ({
|
|
|
25452
25190
|
return namespace;
|
|
25453
25191
|
} catch (e) {
|
|
25454
25192
|
if (e.code === "ERR_MODULE_NOT_FOUND") {
|
|
25455
|
-
throw new Error(createDetailedMessage$
|
|
25193
|
+
throw new Error(createDetailedMessage$1(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
|
|
25456
25194
|
suggestion: `npm install --save-dev playwright`
|
|
25457
25195
|
}), {
|
|
25458
25196
|
cause: e
|
|
@@ -25610,7 +25348,7 @@ const createChildExecOptions = async ({
|
|
|
25610
25348
|
debugModeInheritBreak = true
|
|
25611
25349
|
} = {}) => {
|
|
25612
25350
|
if (typeof debugMode === "string" && AVAILABLE_DEBUG_MODE.indexOf(debugMode) === -1) {
|
|
25613
|
-
throw new TypeError(createDetailedMessage$
|
|
25351
|
+
throw new TypeError(createDetailedMessage$1(`unexpected debug mode.`, {
|
|
25614
25352
|
["debug mode"]: debugMode,
|
|
25615
25353
|
["allowed debug mode"]: AVAILABLE_DEBUG_MODE
|
|
25616
25354
|
}));
|
|
@@ -25876,7 +25614,7 @@ nodeChildProcess.run = async ({
|
|
|
25876
25614
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
25877
25615
|
env: envForChildProcess
|
|
25878
25616
|
});
|
|
25879
|
-
logger.debug(createDetailedMessage$
|
|
25617
|
+
logger.debug(createDetailedMessage$1(`child process forked (pid ${childProcess.pid})`, {
|
|
25880
25618
|
"execArgv": execArgv.join(`\n`),
|
|
25881
25619
|
"custom env": JSON.stringify(env, null, " ")
|
|
25882
25620
|
}));
|
|
@@ -25999,7 +25737,7 @@ nodeChildProcess.run = async ({
|
|
|
25999
25737
|
if (winner.name === "error") {
|
|
26000
25738
|
const error = winner.data;
|
|
26001
25739
|
removeOutputListener();
|
|
26002
|
-
result.status = "
|
|
25740
|
+
result.status = "failed";
|
|
26003
25741
|
result.errors.push(error);
|
|
26004
25742
|
return;
|
|
26005
25743
|
}
|
|
@@ -26009,18 +25747,18 @@ nodeChildProcess.run = async ({
|
|
|
26009
25747
|
} = winner.data;
|
|
26010
25748
|
await cleanup("process exit");
|
|
26011
25749
|
if (code === 12) {
|
|
26012
|
-
result.status = "
|
|
25750
|
+
result.status = "failed";
|
|
26013
25751
|
result.errors.push(new Error(`node process exited with 12 (the forked child process wanted to use a non-available port for debug)`));
|
|
26014
25752
|
return;
|
|
26015
25753
|
}
|
|
26016
25754
|
if (code === null || code === 0 || code === EXIT_CODES.SIGINT || code === EXIT_CODES.SIGTERM || code === EXIT_CODES.SIGABORT) {
|
|
26017
|
-
result.status = "
|
|
25755
|
+
result.status = "failed";
|
|
26018
25756
|
result.errors.push(new Error(`node process exited during execution`));
|
|
26019
25757
|
return;
|
|
26020
25758
|
}
|
|
26021
25759
|
// process.exit(1) in child process or process.exitCode = 1 + process.exit()
|
|
26022
25760
|
// means there was an error even if we don't know exactly what.
|
|
26023
|
-
result.status = "
|
|
25761
|
+
result.status = "failed";
|
|
26024
25762
|
result.errors.push(new Error(`node process exited with code ${code} during execution`));
|
|
26025
25763
|
return;
|
|
26026
25764
|
}
|
|
@@ -26029,7 +25767,7 @@ nodeChildProcess.run = async ({
|
|
|
26029
25767
|
value
|
|
26030
25768
|
} = winner.data;
|
|
26031
25769
|
if (status === "action-failed") {
|
|
26032
|
-
result.status = "
|
|
25770
|
+
result.status = "failed";
|
|
26033
25771
|
result.errors.push(value);
|
|
26034
25772
|
return;
|
|
26035
25773
|
}
|
|
@@ -26046,7 +25784,7 @@ nodeChildProcess.run = async ({
|
|
|
26046
25784
|
try {
|
|
26047
25785
|
await writeResult();
|
|
26048
25786
|
} catch (e) {
|
|
26049
|
-
result.status = "
|
|
25787
|
+
result.status = "failed";
|
|
26050
25788
|
result.errors.push(e);
|
|
26051
25789
|
}
|
|
26052
25790
|
if (keepRunning) {
|
|
@@ -26272,7 +26010,7 @@ nodeWorkerThread.run = async ({
|
|
|
26272
26010
|
if (winner.name === "error") {
|
|
26273
26011
|
const error = winner.data;
|
|
26274
26012
|
removeOutputListener();
|
|
26275
|
-
result.status = "
|
|
26013
|
+
result.status = "failed";
|
|
26276
26014
|
result.errors.push(error);
|
|
26277
26015
|
return;
|
|
26278
26016
|
}
|
|
@@ -26282,18 +26020,18 @@ nodeWorkerThread.run = async ({
|
|
|
26282
26020
|
} = winner.data;
|
|
26283
26021
|
await cleanup("process exit");
|
|
26284
26022
|
if (code === 12) {
|
|
26285
|
-
result.status = "
|
|
26023
|
+
result.status = "failed";
|
|
26286
26024
|
result.errors.push(new Error(`node process exited with 12 (the forked child process wanted to use a non-available port for debug)`));
|
|
26287
26025
|
return;
|
|
26288
26026
|
}
|
|
26289
26027
|
if (code === null || code === 0 || code === EXIT_CODES.SIGINT || code === EXIT_CODES.SIGTERM || code === EXIT_CODES.SIGABORT) {
|
|
26290
|
-
result.status = "
|
|
26028
|
+
result.status = "failed";
|
|
26291
26029
|
result.errors.push(new Error(`node worker thread exited during execution`));
|
|
26292
26030
|
return;
|
|
26293
26031
|
}
|
|
26294
26032
|
// process.exit(1) in child process or process.exitCode = 1 + process.exit()
|
|
26295
26033
|
// means there was an error even if we don't know exactly what.
|
|
26296
|
-
result.status = "
|
|
26034
|
+
result.status = "failed";
|
|
26297
26035
|
result.errors.push(new Error(`node worker thread exited with code ${code} during execution`));
|
|
26298
26036
|
}
|
|
26299
26037
|
const {
|
|
@@ -26301,7 +26039,7 @@ nodeWorkerThread.run = async ({
|
|
|
26301
26039
|
value
|
|
26302
26040
|
} = winner.data;
|
|
26303
26041
|
if (status === "action-failed") {
|
|
26304
|
-
result.status = "
|
|
26042
|
+
result.status = "failed";
|
|
26305
26043
|
result.errors.push(value);
|
|
26306
26044
|
return;
|
|
26307
26045
|
}
|
|
@@ -26318,7 +26056,7 @@ nodeWorkerThread.run = async ({
|
|
|
26318
26056
|
try {
|
|
26319
26057
|
await writeResult();
|
|
26320
26058
|
} catch (e) {
|
|
26321
|
-
result.status = "
|
|
26059
|
+
result.status = "failed";
|
|
26322
26060
|
result.errors.push(e);
|
|
26323
26061
|
}
|
|
26324
26062
|
if (keepRunning) {
|
|
@@ -26409,10 +26147,8 @@ const startBuildServer = async ({
|
|
|
26409
26147
|
handleSIGINT = true,
|
|
26410
26148
|
logLevel,
|
|
26411
26149
|
serverLogLevel = "warn",
|
|
26412
|
-
|
|
26150
|
+
https,
|
|
26413
26151
|
http2,
|
|
26414
|
-
certificate,
|
|
26415
|
-
privateKey,
|
|
26416
26152
|
acceptAnyIp,
|
|
26417
26153
|
hostname,
|
|
26418
26154
|
port = 9779,
|
|
@@ -26427,30 +26163,46 @@ const startBuildServer = async ({
|
|
|
26427
26163
|
},
|
|
26428
26164
|
buildServerAutoreload = false,
|
|
26429
26165
|
buildServerMainFile = getCallerPosition().url,
|
|
26430
|
-
cooldownBetweenFileEvents
|
|
26166
|
+
cooldownBetweenFileEvents,
|
|
26167
|
+
...rest
|
|
26431
26168
|
}) => {
|
|
26432
|
-
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26436
|
-
|
|
26437
|
-
|
|
26438
|
-
|
|
26439
|
-
|
|
26440
|
-
|
|
26441
|
-
|
|
26442
|
-
|
|
26443
|
-
|
|
26444
|
-
|
|
26445
|
-
|
|
26446
|
-
|
|
26169
|
+
// params validation
|
|
26170
|
+
{
|
|
26171
|
+
const unexpectedParamNames = Object.keys(rest);
|
|
26172
|
+
if (unexpectedParamNames.length > 0) {
|
|
26173
|
+
throw new TypeError(`${unexpectedParamNames.join(",")}: there is no such param`);
|
|
26174
|
+
}
|
|
26175
|
+
const rootDirectoryUrlValidation = validateDirectoryUrl(rootDirectoryUrl);
|
|
26176
|
+
if (!rootDirectoryUrlValidation.valid) {
|
|
26177
|
+
throw new TypeError(`rootDirectoryUrl ${rootDirectoryUrlValidation.message}, got ${rootDirectoryUrl}`);
|
|
26178
|
+
}
|
|
26179
|
+
rootDirectoryUrl = rootDirectoryUrlValidation.value;
|
|
26180
|
+
const buildDirectoryUrlValidation = validateDirectoryUrl(buildDirectoryUrl);
|
|
26181
|
+
if (!buildDirectoryUrlValidation.valid) {
|
|
26182
|
+
throw new TypeError(`buildDirectoryUrl ${buildDirectoryUrlValidation.message}, got ${buildDirectoryUrlValidation}`);
|
|
26183
|
+
}
|
|
26184
|
+
buildDirectoryUrl = buildDirectoryUrlValidation.value;
|
|
26185
|
+
if (buildIndexPath) {
|
|
26186
|
+
if (typeof buildIndexPath !== "string") {
|
|
26187
|
+
throw new TypeError(`buildIndexPath must be a string, got ${buildIndexPath}`);
|
|
26188
|
+
}
|
|
26189
|
+
if (buildIndexPath[0] === "/") {
|
|
26190
|
+
buildIndexPath = buildIndexPath.slice(1);
|
|
26191
|
+
} else {
|
|
26192
|
+
const buildIndexUrl = new URL(buildIndexPath, buildDirectoryUrl).href;
|
|
26193
|
+
if (!buildIndexUrl.startsWith(buildDirectoryUrl)) {
|
|
26194
|
+
throw new Error(`buildIndexPath must be relative, got ${buildIndexPath}`);
|
|
26195
|
+
}
|
|
26196
|
+
buildIndexPath = buildIndexUrl.slice(buildDirectoryUrl.length);
|
|
26197
|
+
}
|
|
26198
|
+
if (!existsSync(new URL(buildIndexPath, buildDirectoryUrl))) {
|
|
26199
|
+
buildIndexPath = null;
|
|
26447
26200
|
}
|
|
26448
|
-
buildIndexPath = buildIndexUrl.slice(buildDirectoryUrl.length);
|
|
26449
|
-
}
|
|
26450
|
-
if (!existsSync(new URL(buildIndexPath, buildDirectoryUrl))) {
|
|
26451
|
-
buildIndexPath = null;
|
|
26452
26201
|
}
|
|
26453
26202
|
}
|
|
26203
|
+
const logger = createLogger({
|
|
26204
|
+
logLevel
|
|
26205
|
+
});
|
|
26454
26206
|
const operation = Abort.startOperation();
|
|
26455
26207
|
operation.addAbortSignal(signal);
|
|
26456
26208
|
if (handleSIGINT) {
|
|
@@ -26539,10 +26291,8 @@ const startBuildServer = async ({
|
|
|
26539
26291
|
keepProcessAlive,
|
|
26540
26292
|
logLevel: serverLogLevel,
|
|
26541
26293
|
startLog: false,
|
|
26542
|
-
|
|
26294
|
+
https,
|
|
26543
26295
|
http2,
|
|
26544
|
-
certificate,
|
|
26545
|
-
privateKey,
|
|
26546
26296
|
acceptAnyIp,
|
|
26547
26297
|
hostname,
|
|
26548
26298
|
port,
|
|
@@ -26638,7 +26388,7 @@ const execute = async ({
|
|
|
26638
26388
|
runtimeParams,
|
|
26639
26389
|
ignoreError = false
|
|
26640
26390
|
}) => {
|
|
26641
|
-
const logger = createLogger
|
|
26391
|
+
const logger = createLogger({
|
|
26642
26392
|
logLevel
|
|
26643
26393
|
});
|
|
26644
26394
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -26682,7 +26432,7 @@ const execute = async ({
|
|
|
26682
26432
|
});
|
|
26683
26433
|
result = resultTransformer(result);
|
|
26684
26434
|
try {
|
|
26685
|
-
if (result.status === "
|
|
26435
|
+
if (result.status === "failed") {
|
|
26686
26436
|
if (ignoreError) {
|
|
26687
26437
|
return result;
|
|
26688
26438
|
}
|