@jsenv/core 30.4.1 → 30.4.2

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/main.js CHANGED
@@ -753,7 +753,7 @@ const getPermissionOrComputeDefault = (action, subject, permissions) => {
753
753
  * - stats object documentation on Node.js
754
754
  * https://nodejs.org/docs/latest-v13.x/api/fs.html#fs_class_fs_stats
755
755
  */
756
- const isWindows$2 = process.platform === "win32";
756
+ const isWindows$3 = process.platform === "win32";
757
757
  const readEntryStat = async (source, {
758
758
  nullIfNotFound = false,
759
759
  followLink = true
@@ -767,7 +767,7 @@ const readEntryStat = async (source, {
767
767
  return readStat(sourcePath, {
768
768
  followLink,
769
769
  ...handleNotFoundOption,
770
- ...(isWindows$2 ? {
770
+ ...(isWindows$3 ? {
771
771
  // Windows can EPERM on stat
772
772
  handlePermissionDeniedError: async error => {
773
773
  console.error(`trying to fix windows EPERM after stats on ${sourcePath}`);
@@ -1715,7 +1715,7 @@ const ensureParentDirectories = async destination => {
1715
1715
  });
1716
1716
  };
1717
1717
 
1718
- const isWindows$1 = process.platform === "win32";
1718
+ const isWindows$2 = process.platform === "win32";
1719
1719
  const baseUrlFallback = fileSystemPathToUrl$1(process.cwd());
1720
1720
 
1721
1721
  /**
@@ -1737,7 +1737,7 @@ const ensureWindowsDriveLetter = (url, baseUrl) => {
1737
1737
  } catch (e) {
1738
1738
  throw new Error(`absolute url expected but got ${url}`);
1739
1739
  }
1740
- if (!isWindows$1) {
1740
+ if (!isWindows$2) {
1741
1741
  return url;
1742
1742
  }
1743
1743
  try {
@@ -1834,10 +1834,10 @@ const guardTooFastSecondCallPerFile = (callback, cooldownBetweenFileEvents = 40)
1834
1834
  };
1835
1835
  };
1836
1836
 
1837
- const isWindows = process.platform === "win32";
1837
+ const isWindows$1 = process.platform === "win32";
1838
1838
  const createWatcher = (sourcePath, options) => {
1839
1839
  const watcher = watch(sourcePath, options);
1840
- if (isWindows) {
1840
+ if (isWindows$1) {
1841
1841
  watcher.on("error", async error => {
1842
1842
  // https://github.com/joyent/node/issues/4337
1843
1843
  if (error.code === "EPERM") {
@@ -2264,16 +2264,16 @@ const writeFileSync = (destination, content = "") => {
2264
2264
  }
2265
2265
  };
2266
2266
 
2267
- const LOG_LEVEL_OFF = "off";
2268
- const LOG_LEVEL_DEBUG = "debug";
2269
- const LOG_LEVEL_INFO = "info";
2270
- const LOG_LEVEL_WARN = "warn";
2271
- const LOG_LEVEL_ERROR = "error";
2267
+ const LOG_LEVEL_OFF$1 = "off";
2268
+ const LOG_LEVEL_DEBUG$1 = "debug";
2269
+ const LOG_LEVEL_INFO$1 = "info";
2270
+ const LOG_LEVEL_WARN$1 = "warn";
2271
+ const LOG_LEVEL_ERROR$1 = "error";
2272
2272
 
2273
- const createLogger = ({
2274
- logLevel = LOG_LEVEL_INFO
2273
+ const createLogger$1 = ({
2274
+ logLevel = LOG_LEVEL_INFO$1
2275
2275
  } = {}) => {
2276
- if (logLevel === LOG_LEVEL_DEBUG) {
2276
+ if (logLevel === LOG_LEVEL_DEBUG$1) {
2277
2277
  return {
2278
2278
  level: "debug",
2279
2279
  levels: {
@@ -2282,13 +2282,13 @@ const createLogger = ({
2282
2282
  warn: true,
2283
2283
  error: true
2284
2284
  },
2285
- debug,
2286
- info,
2287
- warn,
2288
- error
2285
+ debug: debug$1,
2286
+ info: info$1,
2287
+ warn: warn$1,
2288
+ error: error$1
2289
2289
  };
2290
2290
  }
2291
- if (logLevel === LOG_LEVEL_INFO) {
2291
+ if (logLevel === LOG_LEVEL_INFO$1) {
2292
2292
  return {
2293
2293
  level: "info",
2294
2294
  levels: {
@@ -2297,13 +2297,13 @@ const createLogger = ({
2297
2297
  warn: true,
2298
2298
  error: true
2299
2299
  },
2300
- debug: debugDisabled,
2301
- info,
2302
- warn,
2303
- error
2300
+ debug: debugDisabled$1,
2301
+ info: info$1,
2302
+ warn: warn$1,
2303
+ error: error$1
2304
2304
  };
2305
2305
  }
2306
- if (logLevel === LOG_LEVEL_WARN) {
2306
+ if (logLevel === LOG_LEVEL_WARN$1) {
2307
2307
  return {
2308
2308
  level: "warn",
2309
2309
  levels: {
@@ -2312,13 +2312,13 @@ const createLogger = ({
2312
2312
  warn: true,
2313
2313
  error: true
2314
2314
  },
2315
- debug: debugDisabled,
2316
- info: infoDisabled,
2317
- warn,
2318
- error
2315
+ debug: debugDisabled$1,
2316
+ info: infoDisabled$1,
2317
+ warn: warn$1,
2318
+ error: error$1
2319
2319
  };
2320
2320
  }
2321
- if (logLevel === LOG_LEVEL_ERROR) {
2321
+ if (logLevel === LOG_LEVEL_ERROR$1) {
2322
2322
  return {
2323
2323
  level: "error",
2324
2324
  levels: {
@@ -2327,13 +2327,13 @@ const createLogger = ({
2327
2327
  warn: false,
2328
2328
  error: true
2329
2329
  },
2330
- debug: debugDisabled,
2331
- info: infoDisabled,
2332
- warn: warnDisabled,
2333
- error
2330
+ debug: debugDisabled$1,
2331
+ info: infoDisabled$1,
2332
+ warn: warnDisabled$1,
2333
+ error: error$1
2334
2334
  };
2335
2335
  }
2336
- if (logLevel === LOG_LEVEL_OFF) {
2336
+ if (logLevel === LOG_LEVEL_OFF$1) {
2337
2337
  return {
2338
2338
  level: "off",
2339
2339
  levels: {
@@ -2342,60 +2342,60 @@ const createLogger = ({
2342
2342
  warn: false,
2343
2343
  error: false
2344
2344
  },
2345
- debug: debugDisabled,
2346
- info: infoDisabled,
2347
- warn: warnDisabled,
2348
- error: errorDisabled
2345
+ debug: debugDisabled$1,
2346
+ info: infoDisabled$1,
2347
+ warn: warnDisabled$1,
2348
+ error: errorDisabled$1
2349
2349
  };
2350
2350
  }
2351
2351
  throw new Error(`unexpected logLevel.
2352
2352
  --- logLevel ---
2353
2353
  ${logLevel}
2354
2354
  --- 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 = (...args) => console.debug(...args);
2362
- const debugDisabled = () => {};
2363
- const info = (...args) => console.info(...args);
2364
- const infoDisabled = () => {};
2365
- const warn = (...args) => console.warn(...args);
2366
- const warnDisabled = () => {};
2367
- const error = (...args) => console.error(...args);
2368
- const errorDisabled = () => {};
2355
+ ${LOG_LEVEL_OFF$1}
2356
+ ${LOG_LEVEL_ERROR$1}
2357
+ ${LOG_LEVEL_WARN$1}
2358
+ ${LOG_LEVEL_INFO$1}
2359
+ ${LOG_LEVEL_DEBUG$1}`);
2360
+ };
2361
+ const debug$1 = (...args) => console.debug(...args);
2362
+ const debugDisabled$1 = () => {};
2363
+ const info$1 = (...args) => console.info(...args);
2364
+ const infoDisabled$1 = () => {};
2365
+ const warn$1 = (...args) => console.warn(...args);
2366
+ const warnDisabled$1 = () => {};
2367
+ const error$1 = (...args) => console.error(...args);
2368
+ const errorDisabled$1 = () => {};
2369
2369
 
2370
2370
  // From: https://github.com/sindresorhus/has-flag/blob/main/index.js
2371
2371
  /// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
2372
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
2372
+ function hasFlag$1(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
2373
2373
  const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
2374
2374
  const position = argv.indexOf(prefix + flag);
2375
2375
  const terminatorPosition = argv.indexOf('--');
2376
2376
  return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
2377
2377
  }
2378
2378
  const {
2379
- env
2379
+ env: env$1
2380
2380
  } = process$1;
2381
- let flagForceColor;
2382
- if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
2383
- flagForceColor = 0;
2384
- } else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
2385
- flagForceColor = 1;
2381
+ let flagForceColor$1;
2382
+ if (hasFlag$1('no-color') || hasFlag$1('no-colors') || hasFlag$1('color=false') || hasFlag$1('color=never')) {
2383
+ flagForceColor$1 = 0;
2384
+ } else if (hasFlag$1('color') || hasFlag$1('colors') || hasFlag$1('color=true') || hasFlag$1('color=always')) {
2385
+ flagForceColor$1 = 1;
2386
2386
  }
2387
- function envForceColor() {
2388
- if ('FORCE_COLOR' in env) {
2389
- if (env.FORCE_COLOR === 'true') {
2387
+ function envForceColor$1() {
2388
+ if ('FORCE_COLOR' in env$1) {
2389
+ if (env$1.FORCE_COLOR === 'true') {
2390
2390
  return 1;
2391
2391
  }
2392
- if (env.FORCE_COLOR === 'false') {
2392
+ if (env$1.FORCE_COLOR === 'false') {
2393
2393
  return 0;
2394
2394
  }
2395
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
2395
+ return env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env$1.FORCE_COLOR, 10), 3);
2396
2396
  }
2397
2397
  }
2398
- function translateLevel(level) {
2398
+ function translateLevel$1(level) {
2399
2399
  if (level === 0) {
2400
2400
  return false;
2401
2401
  }
@@ -2406,37 +2406,37 @@ function translateLevel(level) {
2406
2406
  has16m: level >= 3
2407
2407
  };
2408
2408
  }
2409
- function _supportsColor(haveStream, {
2409
+ function _supportsColor$1(haveStream, {
2410
2410
  streamIsTTY,
2411
2411
  sniffFlags = true
2412
2412
  } = {}) {
2413
- const noFlagForceColor = envForceColor();
2413
+ const noFlagForceColor = envForceColor$1();
2414
2414
  if (noFlagForceColor !== undefined) {
2415
- flagForceColor = noFlagForceColor;
2415
+ flagForceColor$1 = noFlagForceColor;
2416
2416
  }
2417
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
2417
+ const forceColor = sniffFlags ? flagForceColor$1 : noFlagForceColor;
2418
2418
  if (forceColor === 0) {
2419
2419
  return 0;
2420
2420
  }
2421
2421
  if (sniffFlags) {
2422
- if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
2422
+ if (hasFlag$1('color=16m') || hasFlag$1('color=full') || hasFlag$1('color=truecolor')) {
2423
2423
  return 3;
2424
2424
  }
2425
- if (hasFlag('color=256')) {
2425
+ if (hasFlag$1('color=256')) {
2426
2426
  return 2;
2427
2427
  }
2428
2428
  }
2429
2429
 
2430
2430
  // Check for Azure DevOps pipelines.
2431
2431
  // Has to be above the `!streamIsTTY` check.
2432
- if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
2432
+ if ('TF_BUILD' in env$1 && 'AGENT_NAME' in env$1) {
2433
2433
  return 1;
2434
2434
  }
2435
2435
  if (haveStream && !streamIsTTY && forceColor === undefined) {
2436
2436
  return 0;
2437
2437
  }
2438
2438
  const min = forceColor || 0;
2439
- if (env.TERM === 'dumb') {
2439
+ if (env$1.TERM === 'dumb') {
2440
2440
  return min;
2441
2441
  }
2442
2442
  if (process$1.platform === 'win32') {
@@ -2448,27 +2448,27 @@ function _supportsColor(haveStream, {
2448
2448
  }
2449
2449
  return 1;
2450
2450
  }
2451
- if ('CI' in env) {
2452
- if ('GITHUB_ACTIONS' in env) {
2451
+ if ('CI' in env$1) {
2452
+ if ('GITHUB_ACTIONS' in env$1) {
2453
2453
  return 3;
2454
2454
  }
2455
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
2455
+ if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env$1) || env$1.CI_NAME === 'codeship') {
2456
2456
  return 1;
2457
2457
  }
2458
2458
  return min;
2459
2459
  }
2460
- if ('TEAMCITY_VERSION' in env) {
2461
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2460
+ if ('TEAMCITY_VERSION' in env$1) {
2461
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
2462
2462
  }
2463
- if (env.COLORTERM === 'truecolor') {
2463
+ if (env$1.COLORTERM === 'truecolor') {
2464
2464
  return 3;
2465
2465
  }
2466
- if (env.TERM === 'xterm-kitty') {
2466
+ if (env$1.TERM === 'xterm-kitty') {
2467
2467
  return 3;
2468
2468
  }
2469
- if ('TERM_PROGRAM' in env) {
2470
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2471
- switch (env.TERM_PROGRAM) {
2469
+ if ('TERM_PROGRAM' in env$1) {
2470
+ const version = Number.parseInt((env$1.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2471
+ switch (env$1.TERM_PROGRAM) {
2472
2472
  case 'iTerm.app':
2473
2473
  {
2474
2474
  return version >= 3 ? 3 : 2;
@@ -2481,34 +2481,34 @@ function _supportsColor(haveStream, {
2481
2481
  }
2482
2482
  }
2483
2483
 
2484
- if (/-256(color)?$/i.test(env.TERM)) {
2484
+ if (/-256(color)?$/i.test(env$1.TERM)) {
2485
2485
  return 2;
2486
2486
  }
2487
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
2487
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) {
2488
2488
  return 1;
2489
2489
  }
2490
- if ('COLORTERM' in env) {
2490
+ if ('COLORTERM' in env$1) {
2491
2491
  return 1;
2492
2492
  }
2493
2493
  return min;
2494
2494
  }
2495
- function createSupportsColor(stream, options = {}) {
2496
- const level = _supportsColor(stream, {
2495
+ function createSupportsColor$1(stream, options = {}) {
2496
+ const level = _supportsColor$1(stream, {
2497
2497
  streamIsTTY: stream && stream.isTTY,
2498
2498
  ...options
2499
2499
  });
2500
- return translateLevel(level);
2500
+ return translateLevel$1(level);
2501
2501
  }
2502
2502
  ({
2503
- stdout: createSupportsColor({
2503
+ stdout: createSupportsColor$1({
2504
2504
  isTTY: tty.isatty(1)
2505
2505
  }),
2506
- stderr: createSupportsColor({
2506
+ stderr: createSupportsColor$1({
2507
2507
  isTTY: tty.isatty(2)
2508
2508
  })
2509
2509
  });
2510
2510
 
2511
- const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
2511
+ const processSupportsBasicColor = createSupportsColor$1(process.stdout).hasBasic;
2512
2512
  let canUseColors = processSupportsBasicColor;
2513
2513
 
2514
2514
  // GitHub workflow does support ANSI but "supports-color" returns false
@@ -2588,7 +2588,7 @@ const UNICODE = {
2588
2588
  supported: canUseUnicode
2589
2589
  };
2590
2590
 
2591
- const createDetailedMessage$1 = (message, details = {}) => {
2591
+ const createDetailedMessage$2 = (message, details = {}) => {
2592
2592
  let string = `${message}`;
2593
2593
  Object.keys(details).forEach(key => {
2594
2594
  const value = details[key];
@@ -2852,79 +2852,86 @@ const distributePercentages = (namedNumbers, {
2852
2852
  return percentages;
2853
2853
  };
2854
2854
 
2855
- const ESC = '\u001B[';
2856
- const OSC = '\u001B]';
2857
- const BEL = '\u0007';
2858
- const SEP = ';';
2859
- const isTerminalApp = process$1.env.TERM_PROGRAM === 'Apple_Terminal';
2860
- const ansiEscapes = {};
2861
- ansiEscapes.cursorTo = (x, y) => {
2855
+ const ESC$1 = '\u001B[';
2856
+ const OSC$1 = '\u001B]';
2857
+ const BEL$1 = '\u0007';
2858
+ const SEP$1 = ';';
2859
+
2860
+ /* global window */
2861
+ const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
2862
+ const isTerminalApp$1 = !isBrowser && process$1.env.TERM_PROGRAM === 'Apple_Terminal';
2863
+ const isWindows = !isBrowser && process$1.platform === 'win32';
2864
+ const cwdFunction = isBrowser ? () => {
2865
+ throw new Error('`process.cwd()` only works in Node.js, not the browser.');
2866
+ } : process$1.cwd;
2867
+ const ansiEscapes$1 = {};
2868
+ ansiEscapes$1.cursorTo = (x, y) => {
2862
2869
  if (typeof x !== 'number') {
2863
2870
  throw new TypeError('The `x` argument is required');
2864
2871
  }
2865
2872
  if (typeof y !== 'number') {
2866
- return ESC + (x + 1) + 'G';
2873
+ return ESC$1 + (x + 1) + 'G';
2867
2874
  }
2868
- return ESC + (y + 1) + SEP + (x + 1) + 'H';
2875
+ return ESC$1 + (y + 1) + SEP$1 + (x + 1) + 'H';
2869
2876
  };
2870
- ansiEscapes.cursorMove = (x, y) => {
2877
+ ansiEscapes$1.cursorMove = (x, y) => {
2871
2878
  if (typeof x !== 'number') {
2872
2879
  throw new TypeError('The `x` argument is required');
2873
2880
  }
2874
2881
  let returnValue = '';
2875
2882
  if (x < 0) {
2876
- returnValue += ESC + -x + 'D';
2883
+ returnValue += ESC$1 + -x + 'D';
2877
2884
  } else if (x > 0) {
2878
- returnValue += ESC + x + 'C';
2885
+ returnValue += ESC$1 + x + 'C';
2879
2886
  }
2880
2887
  if (y < 0) {
2881
- returnValue += ESC + -y + 'A';
2888
+ returnValue += ESC$1 + -y + 'A';
2882
2889
  } else if (y > 0) {
2883
- returnValue += ESC + y + 'B';
2890
+ returnValue += ESC$1 + y + 'B';
2884
2891
  }
2885
2892
  return returnValue;
2886
2893
  };
2887
- ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A';
2888
- ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B';
2889
- ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C';
2890
- ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D';
2891
- ansiEscapes.cursorLeft = ESC + 'G';
2892
- ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's';
2893
- ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u';
2894
- ansiEscapes.cursorGetPosition = ESC + '6n';
2895
- ansiEscapes.cursorNextLine = ESC + 'E';
2896
- ansiEscapes.cursorPrevLine = ESC + 'F';
2897
- ansiEscapes.cursorHide = ESC + '?25l';
2898
- ansiEscapes.cursorShow = ESC + '?25h';
2899
- ansiEscapes.eraseLines = count => {
2894
+ ansiEscapes$1.cursorUp = (count = 1) => ESC$1 + count + 'A';
2895
+ ansiEscapes$1.cursorDown = (count = 1) => ESC$1 + count + 'B';
2896
+ ansiEscapes$1.cursorForward = (count = 1) => ESC$1 + count + 'C';
2897
+ ansiEscapes$1.cursorBackward = (count = 1) => ESC$1 + count + 'D';
2898
+ ansiEscapes$1.cursorLeft = ESC$1 + 'G';
2899
+ ansiEscapes$1.cursorSavePosition = isTerminalApp$1 ? '\u001B7' : ESC$1 + 's';
2900
+ ansiEscapes$1.cursorRestorePosition = isTerminalApp$1 ? '\u001B8' : ESC$1 + 'u';
2901
+ ansiEscapes$1.cursorGetPosition = ESC$1 + '6n';
2902
+ ansiEscapes$1.cursorNextLine = ESC$1 + 'E';
2903
+ ansiEscapes$1.cursorPrevLine = ESC$1 + 'F';
2904
+ ansiEscapes$1.cursorHide = ESC$1 + '?25l';
2905
+ ansiEscapes$1.cursorShow = ESC$1 + '?25h';
2906
+ ansiEscapes$1.eraseLines = count => {
2900
2907
  let clear = '';
2901
2908
  for (let i = 0; i < count; i++) {
2902
- clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
2909
+ clear += ansiEscapes$1.eraseLine + (i < count - 1 ? ansiEscapes$1.cursorUp() : '');
2903
2910
  }
2904
2911
  if (count) {
2905
- clear += ansiEscapes.cursorLeft;
2912
+ clear += ansiEscapes$1.cursorLeft;
2906
2913
  }
2907
2914
  return clear;
2908
2915
  };
2909
- ansiEscapes.eraseEndLine = ESC + 'K';
2910
- ansiEscapes.eraseStartLine = ESC + '1K';
2911
- ansiEscapes.eraseLine = ESC + '2K';
2912
- ansiEscapes.eraseDown = ESC + 'J';
2913
- ansiEscapes.eraseUp = ESC + '1J';
2914
- ansiEscapes.eraseScreen = ESC + '2J';
2915
- ansiEscapes.scrollUp = ESC + 'S';
2916
- ansiEscapes.scrollDown = ESC + 'T';
2917
- ansiEscapes.clearScreen = '\u001Bc';
2918
- ansiEscapes.clearTerminal = process$1.platform === 'win32' ? `${ansiEscapes.eraseScreen}${ESC}0f`
2916
+ ansiEscapes$1.eraseEndLine = ESC$1 + 'K';
2917
+ ansiEscapes$1.eraseStartLine = ESC$1 + '1K';
2918
+ ansiEscapes$1.eraseLine = ESC$1 + '2K';
2919
+ ansiEscapes$1.eraseDown = ESC$1 + 'J';
2920
+ ansiEscapes$1.eraseUp = ESC$1 + '1J';
2921
+ ansiEscapes$1.eraseScreen = ESC$1 + '2J';
2922
+ ansiEscapes$1.scrollUp = ESC$1 + 'S';
2923
+ ansiEscapes$1.scrollDown = ESC$1 + 'T';
2924
+ ansiEscapes$1.clearScreen = '\u001Bc';
2925
+ ansiEscapes$1.clearTerminal = isWindows ? `${ansiEscapes$1.eraseScreen}${ESC$1}0f`
2919
2926
  // 1. Erases the screen (Only done in case `2` is not supported)
2920
2927
  // 2. Erases the whole screen including scrollback buffer
2921
2928
  // 3. Moves cursor to the top-left position
2922
2929
  // More info: https://www.real-world-systems.com/docs/ANSIcode.html
2923
- : `${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`;
2924
- ansiEscapes.beep = BEL;
2925
- ansiEscapes.link = (text, url) => [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
2926
- ansiEscapes.image = (buffer, options = {}) => {
2927
- let returnValue = `${OSC}1337;File=inline=1`;
2930
+ : `${ansiEscapes$1.eraseScreen}${ESC$1}3J${ESC$1}H`;
2931
+ ansiEscapes$1.beep = BEL$1;
2932
+ ansiEscapes$1.link = (text, url) => [OSC$1, '8', SEP$1, SEP$1, url, BEL$1, text, OSC$1, '8', SEP$1, SEP$1, BEL$1].join('');
2933
+ ansiEscapes$1.image = (buffer, options = {}) => {
2934
+ let returnValue = `${OSC$1}1337;File=inline=1`;
2928
2935
  if (options.width) {
2929
2936
  returnValue += `;width=${options.width}`;
2930
2937
  }
@@ -2934,12 +2941,12 @@ ansiEscapes.image = (buffer, options = {}) => {
2934
2941
  if (options.preserveAspectRatio === false) {
2935
2942
  returnValue += ';preserveAspectRatio=0';
2936
2943
  }
2937
- return returnValue + ':' + buffer.toString('base64') + BEL;
2944
+ return returnValue + ':' + buffer.toString('base64') + BEL$1;
2938
2945
  };
2939
- ansiEscapes.iTerm = {
2940
- setCwd: (cwd = process$1.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
2946
+ ansiEscapes$1.iTerm = {
2947
+ setCwd: (cwd = cwdFunction()) => `${OSC$1}50;CurrentDir=${cwd}${BEL$1}`,
2941
2948
  annotation(message, options = {}) {
2942
- let returnValue = `${OSC}1337;`;
2949
+ let returnValue = `${OSC$1}1337;`;
2943
2950
  const hasX = typeof options.x !== 'undefined';
2944
2951
  const hasY = typeof options.y !== 'undefined';
2945
2952
  if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
@@ -2952,7 +2959,7 @@ ansiEscapes.iTerm = {
2952
2959
  } else {
2953
2960
  returnValue += message;
2954
2961
  }
2955
- return returnValue + BEL;
2962
+ return returnValue + BEL$1;
2956
2963
  }
2957
2964
  };
2958
2965
 
@@ -3027,7 +3034,7 @@ const createLog = ({
3027
3034
  return "";
3028
3035
  }
3029
3036
  clearAttemptResult = true;
3030
- return ansiEscapes.eraseLines(visualLineCount);
3037
+ return ansiEscapes$1.eraseLines(visualLineCount);
3031
3038
  };
3032
3039
  const spyStream = () => {
3033
3040
  if (stream === process.stdout) {
@@ -3088,126 +3095,498 @@ const createLog = ({
3088
3095
  };
3089
3096
  const noopStreamSpy = () => "";
3090
3097
 
3091
- // could be inlined but vscode do not correctly
3092
- // expand/collapse template strings, so I put it at the bottom
3093
- const addNewLines = (string, newLine) => {
3094
- if (newLine === "before") {
3095
- return `
3096
- ${string}`;
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;
3097
3439
  }
3098
- if (newLine === "after") {
3099
- return `${string}
3100
- `;
3440
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
3441
+ return 1;
3101
3442
  }
3102
- if (newLine === "around") {
3103
- return `
3104
- ${string}
3105
- `;
3443
+ if ('COLORTERM' in env) {
3444
+ return 1;
3106
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
+ });
3107
3485
  return string;
3108
3486
  };
3109
3487
 
3110
- const startSpinner = ({
3111
- log,
3112
- frames = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"],
3113
- fps = 20,
3114
- keepProcessAlive = false,
3115
- stopOnWriteFromOutside = true,
3116
- stopOnVerticalOverflow = true,
3117
- render = () => "",
3118
- effect = () => {}
3119
- }) => {
3120
- let frameIndex = 0;
3121
- let interval;
3122
- let running = true;
3123
- const spinner = {
3124
- message: undefined
3125
- };
3126
- const update = message => {
3127
- spinner.message = running ? `${frames[frameIndex]} ${message}` : message;
3128
- return spinner.message;
3129
- };
3130
- spinner.update = update;
3131
- let cleanup;
3132
- if (ANSI.supported) {
3133
- running = true;
3134
- cleanup = effect();
3135
- log.write(update(render()));
3136
- interval = setInterval(() => {
3137
- frameIndex = frameIndex === frames.length - 1 ? 0 : frameIndex + 1;
3138
- log.dynamicWrite(({
3139
- outputFromOutside
3140
- }) => {
3141
- if (outputFromOutside && stopOnWriteFromOutside) {
3142
- stop();
3143
- return "";
3144
- }
3145
- return update(render());
3146
- });
3147
- }, 1000 / fps);
3148
- if (!keepProcessAlive) {
3149
- interval.unref();
3150
- }
3151
- } else {
3152
- log.write(update(render()));
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');
3153
3497
  }
3154
- const stop = message => {
3155
- running = false;
3156
- if (interval) {
3157
- clearInterval(interval);
3158
- interval = null;
3159
- }
3160
- if (cleanup) {
3161
- cleanup();
3162
- cleanup = null;
3163
- }
3164
- if (log && message) {
3165
- log.write(update(message));
3166
- log = null;
3167
- }
3168
- };
3169
- spinner.stop = stop;
3170
- if (stopOnVerticalOverflow) {
3171
- log.onVerticalOverflow = stop;
3498
+ if (typeof y !== 'number') {
3499
+ return ESC + (x + 1) + 'G';
3172
3500
  }
3173
- return spinner;
3501
+ return ESC + (y + 1) + SEP + (x + 1) + 'H';
3174
3502
  };
3175
-
3176
- const createTaskLog = (label, {
3177
- disabled = false,
3178
- stopOnWriteFromOutside
3179
- } = {}) => {
3180
- if (disabled) {
3181
- return {
3182
- setRightText: () => {},
3183
- done: () => {},
3184
- happen: () => {},
3185
- fail: () => {}
3186
- };
3503
+ ansiEscapes.cursorMove = (x, y) => {
3504
+ if (typeof x !== 'number') {
3505
+ throw new TypeError('The `x` argument is required');
3187
3506
  }
3188
- const startMs = Date.now();
3189
- const log = createLog();
3190
- let message = label;
3191
- const taskSpinner = startSpinner({
3192
- log,
3193
- render: () => message,
3194
- stopOnWriteFromOutside
3195
- });
3196
- return {
3197
- setRightText: value => {
3198
- message = `${label} ${value}`;
3199
- },
3200
- done: () => {
3201
- const msEllapsed = Date.now() - startMs;
3202
- taskSpinner.stop(`${UNICODE.OK} ${label} (done in ${msAsDuration(msEllapsed)})`);
3203
- },
3204
- happen: message => {
3205
- taskSpinner.stop(`${UNICODE.INFO} ${message} (at ${new Date().toLocaleTimeString()})`);
3206
- },
3207
- fail: (message = `failed to ${label}`) => {
3208
- taskSpinner.stop(`${UNICODE.FAILURE} ${message}`);
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}`;
3563
+ }
3564
+ if (options.height) {
3565
+ returnValue += `;height=${options.height}`;
3566
+ }
3567
+ if (options.preserveAspectRatio === false) {
3568
+ returnValue += ';preserveAspectRatio=0';
3569
+ }
3570
+ return returnValue + ':' + buffer.toString('base64') + BEL;
3571
+ };
3572
+ ansiEscapes.iTerm = {
3573
+ setCwd: (cwd = process$1.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
3574
+ annotation(message, options = {}) {
3575
+ let returnValue = `${OSC}1337;`;
3576
+ const hasX = typeof options.x !== 'undefined';
3577
+ const hasY = typeof options.y !== 'undefined';
3578
+ if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
3579
+ throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
3209
3580
  }
3210
- };
3581
+ message = message.replace(/\|/g, '');
3582
+ returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
3583
+ if (options.length > 0) {
3584
+ returnValue += (hasX ? [message, options.length, options.x, options.y] : [options.length, message]).join('|');
3585
+ } else {
3586
+ returnValue += message;
3587
+ }
3588
+ return returnValue + BEL;
3589
+ }
3211
3590
  };
3212
3591
 
3213
3592
  const memoize = compute => {
@@ -8199,7 +8578,7 @@ const createResolveUrlError = ({
8199
8578
  reason,
8200
8579
  ...details
8201
8580
  }) => {
8202
- const resolveError = new Error(createDetailedMessage$1(`Failed to resolve url reference`, {
8581
+ const resolveError = new Error(createDetailedMessage$2(`Failed to resolve url reference`, {
8203
8582
  reason,
8204
8583
  ...details,
8205
8584
  "specifier": `"${reference.specifier}"`,
@@ -8233,7 +8612,7 @@ const createFetchUrlContentError = ({
8233
8612
  reason,
8234
8613
  ...details
8235
8614
  }) => {
8236
- const fetchError = new Error(createDetailedMessage$1(`Failed to fetch url content`, {
8615
+ const fetchError = new Error(createDetailedMessage$2(`Failed to fetch url content`, {
8237
8616
  reason,
8238
8617
  ...details,
8239
8618
  "url": urlInfo.url,
@@ -8300,7 +8679,7 @@ const createTransformUrlContentError = ({
8300
8679
  reason,
8301
8680
  ...details
8302
8681
  }) => {
8303
- const transformError = new Error(createDetailedMessage$1(`"transformUrlContent" error on "${urlInfo.type}"`, {
8682
+ const transformError = new Error(createDetailedMessage$2(`"transformUrlContent" error on "${urlInfo.type}"`, {
8304
8683
  reason,
8305
8684
  ...details,
8306
8685
  "url": urlInfo.url,
@@ -8353,7 +8732,7 @@ const createFinalizeUrlContentError = ({
8353
8732
  urlInfo,
8354
8733
  error
8355
8734
  }) => {
8356
- const finalizeError = new Error(createDetailedMessage$1(`"finalizeUrlContent" error on "${urlInfo.type}"`, {
8735
+ const finalizeError = new Error(createDetailedMessage$2(`"finalizeUrlContent" error on "${urlInfo.type}"`, {
8357
8736
  ...detailsFromValueThrown(error),
8358
8737
  "url": urlInfo.url,
8359
8738
  "url reference trace": reference.trace.message,
@@ -8597,7 +8976,7 @@ const createKitchen = ({
8597
8976
  writeGeneratedFiles,
8598
8977
  outDirectoryUrl
8599
8978
  }) => {
8600
- const logger = createLogger({
8979
+ const logger = createLogger$1({
8601
8980
  logLevel
8602
8981
  });
8603
8982
  const kitchenContext = {
@@ -8859,7 +9238,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
8859
9238
  try {
8860
9239
  const fetchUrlContentReturnValue = await pluginController.callAsyncHooksUntil("fetchUrlContent", urlInfo, contextDuringFetch);
8861
9240
  if (!fetchUrlContentReturnValue) {
8862
- logger.warn(createDetailedMessage$1(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
9241
+ logger.warn(createDetailedMessage$2(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
8863
9242
  "url": urlInfo.url,
8864
9243
  "url reference trace": reference.trace.message
8865
9244
  }));
@@ -20702,7 +21081,7 @@ const build = async ({
20702
21081
  signal,
20703
21082
  logLevel
20704
21083
  }) => {
20705
- const logger = createLogger({
21084
+ const logger = createLogger$1({
20706
21085
  logLevel
20707
21086
  });
20708
21087
  const buildOperation = Abort.startOperation();
@@ -20987,7 +21366,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
20987
21366
  const rawUrl = buildDirectoryRedirections.get(url) || url;
20988
21367
  const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
20989
21368
  if (!rawUrlInfo) {
20990
- throw new Error(createDetailedMessage$1(`Cannot find url`, {
21369
+ throw new Error(createDetailedMessage$2(`Cannot find url`, {
20991
21370
  url,
20992
21371
  "raw urls": Array.from(buildDirectoryRedirections.values()),
20993
21372
  "build urls": Array.from(buildDirectoryRedirections.keys())
@@ -22667,7 +23046,7 @@ const startDevServer = async ({
22667
23046
  // and mitigates https://github.com/actions/runner-images/issues/3885
22668
23047
  writeGeneratedFiles = !process.env.CI
22669
23048
  }) => {
22670
- const logger = createLogger({
23049
+ const logger = createLogger$1({
22671
23050
  logLevel
22672
23051
  });
22673
23052
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -22990,7 +23369,7 @@ const readNodeV8CoverageDirectory = async ({
22990
23369
  timeSpentTrying += 200;
22991
23370
  return tryReadJsonFile();
22992
23371
  }
22993
- console.warn(createDetailedMessage$1(`Error while reading coverage file`, {
23372
+ console.warn(createDetailedMessage$2(`Error while reading coverage file`, {
22994
23373
  "error stack": e.stack,
22995
23374
  "file": dirEntryUrl
22996
23375
  }));
@@ -23151,7 +23530,7 @@ const composeV8AndIstanbul = (v8FileByFileCoverage, istanbulFileByFileCoverage,
23151
23530
  const v8Coverage = v8FileByFileCoverage[key];
23152
23531
  if (v8Coverage) {
23153
23532
  if (coverageV8ConflictWarning) {
23154
- 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.`, {
23533
+ console.warn(createDetailedMessage$2(`Coverage conflict on "${key}", found two coverage that cannot be merged together: v8 and istanbul. The istanbul coverage will be ignored.`, {
23155
23534
  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)`,
23156
23535
  suggestion: "You can disable this warning with coverageV8ConflictWarning: false"
23157
23536
  }));
@@ -23664,7 +24043,7 @@ const generateFileExecutionSteps = ({
23664
24043
  return;
23665
24044
  }
23666
24045
  if (typeof stepConfig !== "object") {
23667
- throw new TypeError(createDetailedMessage$1(`found unexpected value in plan, they must be object`, {
24046
+ throw new TypeError(createDetailedMessage$2(`found unexpected value in plan, they must be object`, {
23668
24047
  ["file relative path"]: fileRelativeUrl,
23669
24048
  ["execution name"]: executionName,
23670
24049
  ["value"]: stepConfig
@@ -24077,7 +24456,7 @@ const executePlan = async (plan, {
24077
24456
  }
24078
24457
  });
24079
24458
  });
24080
- logger.debug(createDetailedMessage$1(`Prepare executing plan`, {
24459
+ logger.debug(createDetailedMessage$2(`Prepare executing plan`, {
24081
24460
  runtimes: JSON.stringify(runtimes, null, " ")
24082
24461
  }));
24083
24462
  const multipleExecutionsOperation = Abort.startOperation();
@@ -24104,7 +24483,7 @@ const executePlan = async (plan, {
24104
24483
  await ensureEmptyDirectory(process.env.NODE_V8_COVERAGE);
24105
24484
  } else {
24106
24485
  coverageMethodForNodeJs = "Profiler";
24107
- logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
24486
+ logger.warn(createDetailedMessage$2(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
24108
24487
  "suggestion": `set process.env.NODE_V8_COVERAGE`,
24109
24488
  "suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
24110
24489
  }));
@@ -24538,7 +24917,7 @@ const executeTestPlan = async ({
24538
24917
  coverageReportJsonFile = process.env.CI ? null : "./.coverage/coverage.json",
24539
24918
  coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null
24540
24919
  }) => {
24541
- const logger = createLogger({
24920
+ const logger = createLogger$1({
24542
24921
  logLevel
24543
24922
  });
24544
24923
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -24570,7 +24949,7 @@ const executeTestPlan = async ({
24570
24949
  });
24571
24950
  if (patternsMatchingCoverAndExecute.length) {
24572
24951
  // It would be strange, for a given file to be both covered and executed
24573
- throw new Error(createDetailedMessage$1(`some file will be both covered and executed`, {
24952
+ throw new Error(createDetailedMessage$2(`some file will be both covered and executed`, {
24574
24953
  patterns: patternsMatchingCoverAndExecute
24575
24954
  }));
24576
24955
  }
@@ -25073,7 +25452,7 @@ const importPlaywright = async ({
25073
25452
  return namespace;
25074
25453
  } catch (e) {
25075
25454
  if (e.code === "ERR_MODULE_NOT_FOUND") {
25076
- throw new Error(createDetailedMessage$1(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
25455
+ throw new Error(createDetailedMessage$2(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
25077
25456
  suggestion: `npm install --save-dev playwright`
25078
25457
  }), {
25079
25458
  cause: e
@@ -25231,7 +25610,7 @@ const createChildExecOptions = async ({
25231
25610
  debugModeInheritBreak = true
25232
25611
  } = {}) => {
25233
25612
  if (typeof debugMode === "string" && AVAILABLE_DEBUG_MODE.indexOf(debugMode) === -1) {
25234
- throw new TypeError(createDetailedMessage$1(`unexpected debug mode.`, {
25613
+ throw new TypeError(createDetailedMessage$2(`unexpected debug mode.`, {
25235
25614
  ["debug mode"]: debugMode,
25236
25615
  ["allowed debug mode"]: AVAILABLE_DEBUG_MODE
25237
25616
  }));
@@ -25497,7 +25876,7 @@ nodeChildProcess.run = async ({
25497
25876
  stdio: ["pipe", "pipe", "pipe", "ipc"],
25498
25877
  env: envForChildProcess
25499
25878
  });
25500
- logger.debug(createDetailedMessage$1(`child process forked (pid ${childProcess.pid})`, {
25879
+ logger.debug(createDetailedMessage$2(`child process forked (pid ${childProcess.pid})`, {
25501
25880
  "execArgv": execArgv.join(`\n`),
25502
25881
  "custom env": JSON.stringify(env, null, " ")
25503
25882
  }));
@@ -26050,7 +26429,7 @@ const startBuildServer = async ({
26050
26429
  buildServerMainFile = getCallerPosition().url,
26051
26430
  cooldownBetweenFileEvents
26052
26431
  }) => {
26053
- const logger = createLogger({
26432
+ const logger = createLogger$1({
26054
26433
  logLevel
26055
26434
  });
26056
26435
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
@@ -26259,7 +26638,7 @@ const execute = async ({
26259
26638
  runtimeParams,
26260
26639
  ignoreError = false
26261
26640
  }) => {
26262
- const logger = createLogger({
26641
+ const logger = createLogger$1({
26263
26642
  logLevel
26264
26643
  });
26265
26644
  rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);