@coze-arch/cli 0.0.31-alpha.08f83e → 0.0.31-alpha.e8a17f

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/lib/cli.js CHANGED
@@ -1628,7 +1628,7 @@ function createNodeTransport() {
1628
1628
  };
1629
1629
  }
1630
1630
 
1631
- function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$u(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
1631
+ function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$t(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
1632
1632
  * Slardar CLI Reporter 主类
1633
1633
  * 封装 @slardar/base 的初始化和上报逻辑
1634
1634
  */
@@ -1685,7 +1685,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1685
1685
  release: config.release,
1686
1686
  env: config.env,
1687
1687
  name: config.name,
1688
- useLocalConfig: _nullishCoalesce$b(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1688
+ useLocalConfig: _nullishCoalesce$a(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1689
1689
  domain: config.domain,
1690
1690
  // 设置本地采样率为 100%,确保事件不被过滤
1691
1691
  sample: {
@@ -1700,7 +1700,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1700
1700
  this.client.on('send', (ev) => {
1701
1701
  log$6(
1702
1702
  'send hook called for event: %s',
1703
- (_optionalChain$u([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1703
+ (_optionalChain$t([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1704
1704
  );
1705
1705
  });
1706
1706
 
@@ -1758,7 +1758,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1758
1758
  )
1759
1759
  : undefined;
1760
1760
 
1761
- _optionalChain$u([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1761
+ _optionalChain$t([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1762
1762
  name,
1763
1763
  metrics: cleanMetrics ,
1764
1764
  categories: cleanCategories ,
@@ -1829,7 +1829,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1829
1829
  log$6('Reporting JS error:', {
1830
1830
  name: error.name,
1831
1831
  message: error.message.slice(0, 100),
1832
- stack: _optionalChain$u([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1832
+ stack: _optionalChain$t([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1833
1833
  extra,
1834
1834
  source,
1835
1835
  });
@@ -1849,7 +1849,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1849
1849
  if (!this.ensureInitialized()) {
1850
1850
  return;
1851
1851
  }
1852
- _optionalChain$u([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1852
+ _optionalChain$t([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1853
1853
  }
1854
1854
 
1855
1855
  /**
@@ -1860,7 +1860,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1860
1860
  return;
1861
1861
  }
1862
1862
  log$6('Merging context:', context);
1863
- _optionalChain$u([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1863
+ _optionalChain$t([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1864
1864
  }
1865
1865
 
1866
1866
  /**
@@ -1870,7 +1870,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1870
1870
  if (!this.ensureInitialized()) {
1871
1871
  return;
1872
1872
  }
1873
- _optionalChain$u([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1873
+ _optionalChain$t([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1874
1874
  }
1875
1875
 
1876
1876
  /**
@@ -1880,7 +1880,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1880
1880
  if (!this.ensureInitialized()) {
1881
1881
  return;
1882
1882
  }
1883
- _optionalChain$u([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1883
+ _optionalChain$t([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1884
1884
  }
1885
1885
 
1886
1886
  /**
@@ -1917,7 +1917,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1917
1917
  return;
1918
1918
  }
1919
1919
  log$6('Flushing Slardar data...');
1920
- _optionalChain$u([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1920
+ _optionalChain$t([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1921
1921
  log$6('Waiting %dms for events to be sent...', waitMs);
1922
1922
  await new Promise(resolve => setTimeout(resolve, waitMs));
1923
1923
  log$6('Slardar data flushed');
@@ -1936,7 +1936,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1936
1936
  */
1937
1937
  const reporter = new SlardarCLIReporter();
1938
1938
 
1939
- function _optionalChain$t(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1939
+ function _optionalChain$s(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
1940
1940
 
1941
1941
 
1942
1942
 
@@ -1996,11 +1996,11 @@ const EventBuilder = {
1996
1996
  name: CLI_EVENTS.CLI_COMMAND,
1997
1997
  categories: {
1998
1998
  command,
1999
- args: _optionalChain$t([options, 'optionalAccess', _ => _.args]),
1999
+ args: _optionalChain$s([options, 'optionalAccess', _ => _.args]),
2000
2000
  status: 'running' ,
2001
- ..._optionalChain$t([options, 'optionalAccess', _2 => _2.categories]),
2001
+ ..._optionalChain$s([options, 'optionalAccess', _2 => _2.categories]),
2002
2002
  },
2003
- metrics: _optionalChain$t([options, 'optionalAccess', _3 => _3.metrics]),
2003
+ metrics: _optionalChain$s([options, 'optionalAccess', _3 => _3.metrics]),
2004
2004
  };
2005
2005
  },
2006
2006
 
@@ -2021,13 +2021,13 @@ const EventBuilder = {
2021
2021
  name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
2022
2022
  categories: {
2023
2023
  command,
2024
- args: _optionalChain$t([options, 'optionalAccess', _4 => _4.args]),
2024
+ args: _optionalChain$s([options, 'optionalAccess', _4 => _4.args]),
2025
2025
  status: success ? ('success' ) : ('fail' ),
2026
- ..._optionalChain$t([options, 'optionalAccess', _5 => _5.categories]),
2026
+ ..._optionalChain$s([options, 'optionalAccess', _5 => _5.categories]),
2027
2027
  },
2028
2028
  metrics: {
2029
2029
  duration,
2030
- ...(_optionalChain$t([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2030
+ ...(_optionalChain$s([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2031
2031
  },
2032
2032
  };
2033
2033
  },
@@ -2048,12 +2048,12 @@ const EventBuilder = {
2048
2048
  name: CLI_EVENTS.NETWORK_REQUEST,
2049
2049
  categories: {
2050
2050
  url,
2051
- method: _optionalChain$t([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2052
- statusCode: _optionalChain$t([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2053
- status: _optionalChain$t([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2051
+ method: _optionalChain$s([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2052
+ statusCode: _optionalChain$s([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2053
+ status: _optionalChain$s([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2054
2054
  },
2055
2055
  metrics: {
2056
- duration: _optionalChain$t([options, 'optionalAccess', _12 => _12.duration]),
2056
+ duration: _optionalChain$s([options, 'optionalAccess', _12 => _12.duration]),
2057
2057
  },
2058
2058
  };
2059
2059
  },
@@ -2075,11 +2075,11 @@ const EventBuilder = {
2075
2075
  categories: {
2076
2076
  operation,
2077
2077
  filePath,
2078
- status: _optionalChain$t([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2078
+ status: _optionalChain$s([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2079
2079
  },
2080
2080
  metrics: {
2081
- duration: _optionalChain$t([options, 'optionalAccess', _14 => _14.duration]),
2082
- fileSize: _optionalChain$t([options, 'optionalAccess', _15 => _15.fileSize]),
2081
+ duration: _optionalChain$s([options, 'optionalAccess', _14 => _14.duration]),
2082
+ fileSize: _optionalChain$s([options, 'optionalAccess', _15 => _15.fileSize]),
2083
2083
  },
2084
2084
  };
2085
2085
  },
@@ -2107,15 +2107,14 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@coze-arch/cli";
2110
- var version = "0.0.31-alpha.08f83e";
2110
+ var version = "0.0.31-alpha.e8a17f";
2111
2111
  var description = "coze coding devtools cli";
2112
2112
  var license = "MIT";
2113
2113
  var author = "fanwenjie.fe@bytedance.com";
2114
2114
  var maintainers = [
2115
2115
  ];
2116
2116
  var bin = {
2117
- coze: "bin/main",
2118
- "coze-dev": "bin/main"
2117
+ coze: "bin/main"
2119
2118
  };
2120
2119
  var files = [
2121
2120
  "lib",
@@ -2197,8 +2196,7 @@ var publishConfig = {
2197
2196
  };
2198
2197
  var cozePublishConfig = {
2199
2198
  bin: {
2200
- coze: "bin/main",
2201
- "coze-dev": "bin/main"
2199
+ coze: "bin/main"
2202
2200
  }
2203
2201
  };
2204
2202
  var packageJson = {
@@ -2218,7 +2216,7 @@ var packageJson = {
2218
2216
  cozePublishConfig: cozePublishConfig
2219
2217
  };
2220
2218
 
2221
- function _optionalChain$s(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2219
+ function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
2222
2220
  * Slardar 监控初始化和上报
2223
2221
  */
2224
2222
 
@@ -2321,11 +2319,11 @@ const reportCommandComplete = safeRun(
2321
2319
  ,
2322
2320
  ) => {
2323
2321
  const event = EventBuilder.cliCommandComplete(command, success, duration, {
2324
- args: _optionalChain$s([options, 'optionalAccess', _ => _.args]),
2325
- errorCode: _optionalChain$s([options, 'optionalAccess', _2 => _2.errorCode]),
2322
+ args: _optionalChain$r([options, 'optionalAccess', _ => _.args]),
2323
+ errorCode: _optionalChain$r([options, 'optionalAccess', _2 => _2.errorCode]),
2326
2324
  categories: {
2327
- ...(_optionalChain$s([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2328
- ..._optionalChain$s([options, 'optionalAccess', _4 => _4.categories]),
2325
+ ...(_optionalChain$r([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2326
+ ..._optionalChain$r([options, 'optionalAccess', _4 => _4.categories]),
2329
2327
  },
2330
2328
  });
2331
2329
  reporter.sendEvent(event.name, event.metrics, event.categories);
@@ -2384,7 +2382,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2384
2382
  await reporter.flush();
2385
2383
  });
2386
2384
 
2387
- function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
2385
+ function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$q(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
2388
2386
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2389
2387
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2390
2388
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2422,7 +2420,7 @@ class Logger {
2422
2420
 
2423
2421
  constructor(options = {}) {
2424
2422
  this.level = this.parseLogLevel(options.level);
2425
- this.useColor = _nullishCoalesce$a(options.useColor, () => ( this.isColorSupported()));
2423
+ this.useColor = _nullishCoalesce$9(options.useColor, () => ( this.isColorSupported()));
2426
2424
  this.prefix = options.prefix;
2427
2425
  }
2428
2426
 
@@ -2431,7 +2429,7 @@ class Logger {
2431
2429
  return level;
2432
2430
  }
2433
2431
 
2434
- const envLevel = _optionalChain$r([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2432
+ const envLevel = _optionalChain$q([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2435
2433
  if (envLevel && envLevel in LOG_LEVEL_MAP) {
2436
2434
  return LOG_LEVEL_MAP[envLevel];
2437
2435
  }
@@ -2443,7 +2441,7 @@ class Logger {
2443
2441
  // 简单检测:Node.js 环境且支持 TTY
2444
2442
  return (
2445
2443
  typeof process !== 'undefined' &&
2446
- _optionalChain$r([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2444
+ _optionalChain$q([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2447
2445
  process.env.NO_COLOR === undefined
2448
2446
  );
2449
2447
  }
@@ -2468,7 +2466,7 @@ class Logger {
2468
2466
 
2469
2467
  const icon = this.colorize(options.icon, options.color);
2470
2468
  const prefix = this.prefix ? `${icon} ${this.prefix}` : icon;
2471
- console.log(prefix, options.message, ...(_nullishCoalesce$a(options.args, () => ( []))));
2469
+ console.log(prefix, options.message, ...(_nullishCoalesce$9(options.args, () => ( []))));
2472
2470
  }
2473
2471
 
2474
2472
  error(message, ...args) {
@@ -2813,7 +2811,7 @@ const executeWarmup = async (options) => {
2813
2811
  /**
2814
2812
  * 注册 warmup 命令到 program
2815
2813
  */
2816
- const registerCommand$7 = program => {
2814
+ const registerCommand$6 = program => {
2817
2815
  program
2818
2816
  .command('warmup')
2819
2817
  .description('Pre-install dependencies for templates to speed up init')
@@ -3225,7 +3223,7 @@ const executeUpdate = (
3225
3223
  /**
3226
3224
  * 注册 update 命令到 program
3227
3225
  */
3228
- const registerCommand$6 = program => {
3226
+ const registerCommand$5 = program => {
3229
3227
  program
3230
3228
  .command('update <package>')
3231
3229
  .description('Update a package dependency')
@@ -3251,7 +3249,7 @@ const registerCommand$6 = program => {
3251
3249
  });
3252
3250
  };
3253
3251
 
3254
- function _optionalChain$q(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable @typescript-eslint/no-explicit-any */
3252
+ function _optionalChain$p(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable @typescript-eslint/no-explicit-any */
3255
3253
  // Safe JSON parsing utilities with type safety and error handling
3256
3254
  // Provides fallback values, validation, and error monitoring capabilities
3257
3255
 
@@ -3351,12 +3349,12 @@ function safeJsonParse(
3351
3349
  const parsed = JSON.parse(String(input));
3352
3350
 
3353
3351
  // Optional validation
3354
- if (_optionalChain$q([options, 'optionalAccess', _ => _.validate])) {
3352
+ if (_optionalChain$p([options, 'optionalAccess', _ => _.validate])) {
3355
3353
  if (options.validate(parsed)) {
3356
3354
  return parsed;
3357
3355
  } else {
3358
3356
  const validationError = new Error('JSON validation failed');
3359
- _optionalChain$q([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3357
+ _optionalChain$p([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3360
3358
 
3361
3359
  if (options.throwOnValidationError) {
3362
3360
  throw validationError;
@@ -3368,10 +3366,10 @@ function safeJsonParse(
3368
3366
  return parsed;
3369
3367
  } catch (error) {
3370
3368
  // Re-throw validation errors when throwOnValidationError is true
3371
- if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$q([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3369
+ if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$p([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3372
3370
  throw error;
3373
3371
  }
3374
- _optionalChain$q([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3372
+ _optionalChain$p([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3375
3373
  return defaultValue;
3376
3374
  }
3377
3375
  }
@@ -3411,7 +3409,7 @@ function isNode(node) {
3411
3409
  }
3412
3410
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3413
3411
 
3414
- function _optionalChain$p(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3412
+ function _optionalChain$o(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3415
3413
  const BREAK = Symbol('break visit');
3416
3414
  const SKIP = Symbol('skip children');
3417
3415
  const REMOVE = Symbol('remove node');
@@ -3524,15 +3522,15 @@ function callVisitor(key, node, visitor, path) {
3524
3522
  if (typeof visitor === 'function')
3525
3523
  return visitor(key, node, path);
3526
3524
  if (isMap(node))
3527
- return _optionalChain$p([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3525
+ return _optionalChain$o([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3528
3526
  if (isSeq(node))
3529
- return _optionalChain$p([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3527
+ return _optionalChain$o([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3530
3528
  if (isPair(node))
3531
- return _optionalChain$p([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3529
+ return _optionalChain$o([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3532
3530
  if (isScalar(node))
3533
- return _optionalChain$p([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3531
+ return _optionalChain$o([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3534
3532
  if (isAlias(node))
3535
- return _optionalChain$p([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3533
+ return _optionalChain$o([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3536
3534
  return undefined;
3537
3535
  }
3538
3536
  function replaceNode(key, path, node) {
@@ -3623,7 +3621,7 @@ function applyReviver(reviver, obj, key, val) {
3623
3621
  return reviver.call(obj, key, val);
3624
3622
  }
3625
3623
 
3626
- function _optionalChain$o(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3624
+ function _optionalChain$n(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3627
3625
  /**
3628
3626
  * Recursively convert any node or its contents to native JavaScript
3629
3627
  *
@@ -3653,7 +3651,7 @@ function toJS(value, arg, ctx) {
3653
3651
  ctx.onCreate(res);
3654
3652
  return res;
3655
3653
  }
3656
- if (typeof value === 'bigint' && !_optionalChain$o([ctx, 'optionalAccess', _ => _.keep]))
3654
+ if (typeof value === 'bigint' && !_optionalChain$n([ctx, 'optionalAccess', _ => _.keep]))
3657
3655
  return Number(value);
3658
3656
  return value;
3659
3657
  }
@@ -3691,7 +3689,7 @@ class NodeBase {
3691
3689
  }
3692
3690
  }
3693
3691
 
3694
- function _optionalChain$n(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3692
+ function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3695
3693
  class Alias extends NodeBase {
3696
3694
  constructor(source) {
3697
3695
  super(ALIAS);
@@ -3707,10 +3705,10 @@ class Alias extends NodeBase {
3707
3705
  * instance of the `source` anchor before this node.
3708
3706
  */
3709
3707
  resolve(doc, ctx) {
3710
- if (_optionalChain$n([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3708
+ if (_optionalChain$m([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3711
3709
  throw new ReferenceError('Alias resolution is disabled');
3712
3710
  let nodes;
3713
- if (_optionalChain$n([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3711
+ if (_optionalChain$m([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3714
3712
  nodes = ctx.aliasResolveCache;
3715
3713
  }
3716
3714
  else {
@@ -3749,7 +3747,7 @@ class Alias extends NodeBase {
3749
3747
  data = anchors.get(source);
3750
3748
  }
3751
3749
  /* istanbul ignore if */
3752
- if (_optionalChain$n([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3750
+ if (_optionalChain$m([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3753
3751
  const msg = 'This should not happen: Alias anchor was not resolved?';
3754
3752
  throw new ReferenceError(msg);
3755
3753
  }
@@ -3801,7 +3799,7 @@ function getAliasCount(doc, node, anchors) {
3801
3799
  return 1;
3802
3800
  }
3803
3801
 
3804
- function _optionalChain$m(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3802
+ function _optionalChain$l(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3805
3803
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3806
3804
  class Scalar extends NodeBase {
3807
3805
  constructor(value) {
@@ -3809,7 +3807,7 @@ class Scalar extends NodeBase {
3809
3807
  this.value = value;
3810
3808
  }
3811
3809
  toJSON(arg, ctx) {
3812
- return _optionalChain$m([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3810
+ return _optionalChain$l([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3813
3811
  }
3814
3812
  toString() {
3815
3813
  return String(this.value);
@@ -3821,17 +3819,17 @@ Scalar.PLAIN = 'PLAIN';
3821
3819
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3822
3820
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3823
3821
 
3824
- function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$l(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3822
+ function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3825
3823
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3826
3824
  function findTagObject(value, tagName, tags) {
3827
3825
  if (tagName) {
3828
3826
  const match = tags.filter(t => t.tag === tagName);
3829
- const tagObj = _nullishCoalesce$9(match.find(t => !t.format), () => ( match[0]));
3827
+ const tagObj = _nullishCoalesce$8(match.find(t => !t.format), () => ( match[0]));
3830
3828
  if (!tagObj)
3831
3829
  throw new Error(`Tag ${tagName} not found`);
3832
3830
  return tagObj;
3833
3831
  }
3834
- return tags.find(t => _optionalChain$l([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3832
+ return tags.find(t => _optionalChain$k([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3835
3833
  }
3836
3834
  function createNode(value, tagName, ctx) {
3837
3835
  if (isDocument(value))
@@ -3839,7 +3837,7 @@ function createNode(value, tagName, ctx) {
3839
3837
  if (isNode(value))
3840
3838
  return value;
3841
3839
  if (isPair(value)) {
3842
- const map = _optionalChain$l([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3840
+ const map = _optionalChain$k([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3843
3841
  map.items.push(value);
3844
3842
  return map;
3845
3843
  }
@@ -3858,7 +3856,7 @@ function createNode(value, tagName, ctx) {
3858
3856
  if (aliasDuplicateObjects && value && typeof value === 'object') {
3859
3857
  ref = sourceObjects.get(value);
3860
3858
  if (ref) {
3861
- _nullishCoalesce$9(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3859
+ _nullishCoalesce$8(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3862
3860
  return new Alias(ref.anchor);
3863
3861
  }
3864
3862
  else {
@@ -3866,7 +3864,7 @@ function createNode(value, tagName, ctx) {
3866
3864
  sourceObjects.set(value, ref);
3867
3865
  }
3868
3866
  }
3869
- if (_optionalChain$l([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3867
+ if (_optionalChain$k([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3870
3868
  tagName = defaultTagPrefix + tagName.slice(2);
3871
3869
  let tagObj = findTagObject(value, tagName, schema.tags);
3872
3870
  if (!tagObj) {
@@ -3891,9 +3889,9 @@ function createNode(value, tagName, ctx) {
3891
3889
  onTagObj(tagObj);
3892
3890
  delete ctx.onTagObj;
3893
3891
  }
3894
- const node = _optionalChain$l([tagObj, 'optionalAccess', _9 => _9.createNode])
3892
+ const node = _optionalChain$k([tagObj, 'optionalAccess', _9 => _9.createNode])
3895
3893
  ? tagObj.createNode(ctx.schema, value, ctx)
3896
- : typeof _optionalChain$l([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3894
+ : typeof _optionalChain$k([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3897
3895
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
3898
3896
  : new Scalar(value);
3899
3897
  if (tagName)
@@ -4211,7 +4209,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4211
4209
  return end;
4212
4210
  }
4213
4211
 
4214
- function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4212
+ function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4215
4213
  const getFoldOptions = (ctx, isBlock) => ({
4216
4214
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4217
4215
  lineWidth: ctx.options.lineWidth,
@@ -4496,9 +4494,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4496
4494
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4497
4495
  // and others in v1.1.
4498
4496
  if (actualString) {
4499
- const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$k([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4497
+ const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$j([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4500
4498
  const { compat, tags } = ctx.doc.schema;
4501
- if (tags.some(test) || _optionalChain$k([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4499
+ if (tags.some(test) || _optionalChain$j([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4502
4500
  return quotedString(value, ctx);
4503
4501
  }
4504
4502
  return implicitKey
@@ -4544,7 +4542,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4544
4542
  return res;
4545
4543
  }
4546
4544
 
4547
- function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4545
+ function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4548
4546
  function createStringifyContext(doc, options) {
4549
4547
  const opt = Object.assign({
4550
4548
  blockQuote: true,
@@ -4591,27 +4589,27 @@ function getTagObject(tags, item) {
4591
4589
  if (item.tag) {
4592
4590
  const match = tags.filter(t => t.tag === item.tag);
4593
4591
  if (match.length > 0)
4594
- return _nullishCoalesce$8(match.find(t => t.format === item.format), () => ( match[0]));
4592
+ return _nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match[0]));
4595
4593
  }
4596
4594
  let tagObj = undefined;
4597
4595
  let obj;
4598
4596
  if (isScalar(item)) {
4599
4597
  obj = item.value;
4600
- let match = tags.filter(t => _optionalChain$j([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4598
+ let match = tags.filter(t => _optionalChain$i([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4601
4599
  if (match.length > 1) {
4602
4600
  const testMatch = match.filter(t => t.test);
4603
4601
  if (testMatch.length > 0)
4604
4602
  match = testMatch;
4605
4603
  }
4606
4604
  tagObj =
4607
- _nullishCoalesce$8(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4605
+ _nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4608
4606
  }
4609
4607
  else {
4610
4608
  obj = item;
4611
4609
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4612
4610
  }
4613
4611
  if (!tagObj) {
4614
- const name = _nullishCoalesce$8(_optionalChain$j([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4612
+ const name = _nullishCoalesce$7(_optionalChain$i([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4615
4613
  throw new Error(`Tag not resolved for ${name} value`);
4616
4614
  }
4617
4615
  return tagObj;
@@ -4626,7 +4624,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
4626
4624
  anchors.add(anchor);
4627
4625
  props.push(`&${anchor}`);
4628
4626
  }
4629
- const tag = _nullishCoalesce$8(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4627
+ const tag = _nullishCoalesce$7(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4630
4628
  if (tag)
4631
4629
  props.push(doc.directives.tagString(tag));
4632
4630
  return props.join(' ');
@@ -4637,7 +4635,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4637
4635
  if (isAlias(item)) {
4638
4636
  if (ctx.doc.directives)
4639
4637
  return item.toString(ctx);
4640
- if (_optionalChain$j([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4638
+ if (_optionalChain$i([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4641
4639
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4642
4640
  }
4643
4641
  else {
@@ -4652,10 +4650,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
4652
4650
  const node = isNode(item)
4653
4651
  ? item
4654
4652
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
4655
- _nullishCoalesce$8(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4653
+ _nullishCoalesce$7(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4656
4654
  const props = stringifyProps(node, tagObj, ctx);
4657
4655
  if (props.length > 0)
4658
- ctx.indentAtStart = (_nullishCoalesce$8(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4656
+ ctx.indentAtStart = (_nullishCoalesce$7(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4659
4657
  const str = typeof tagObj.stringify === 'function'
4660
4658
  ? tagObj.stringify(node, ctx, onComment, onChompKeep)
4661
4659
  : isScalar(node)
@@ -4668,7 +4666,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4668
4666
  : `${props}\n${ctx.indent}${str}`;
4669
4667
  }
4670
4668
 
4671
- function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4669
+ function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4672
4670
  function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4673
4671
  const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
4674
4672
  let keyComment = (isNode(key) && key.comment) || null;
@@ -4778,7 +4776,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4778
4776
  const vs0 = valueStr[0];
4779
4777
  const nl0 = valueStr.indexOf('\n');
4780
4778
  const hasNewline = nl0 !== -1;
4781
- const flow = _nullishCoalesce$7(_nullishCoalesce$7(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4779
+ const flow = _nullishCoalesce$6(_nullishCoalesce$6(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4782
4780
  if (hasNewline || !flow) {
4783
4781
  let hasPropsLine = false;
4784
4782
  if (hasNewline && (vs0 === '&' || vs0 === '!')) {
@@ -4819,7 +4817,7 @@ function warn(logLevel, warning) {
4819
4817
  }
4820
4818
  }
4821
4819
 
4822
- function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4820
+ function _optionalChain$h(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4823
4821
  // If the value associated with a merge key is a single mapping node, each of
4824
4822
  // its key/value pairs is inserted into the current mapping, unless the key
4825
4823
  // already exists in it. If the value associated with the merge key is a
@@ -4843,7 +4841,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4843
4841
  (isScalar(key) &&
4844
4842
  (!key.type || key.type === Scalar.PLAIN) &&
4845
4843
  merge.identify(key.value))) &&
4846
- _optionalChain$i([ctx, 'optionalAccess', _ => _.doc, 'access', _2 => _2.schema, 'access', _3 => _3.tags, 'access', _4 => _4.some, 'call', _5 => _5(tag => tag.tag === merge.tag && tag.default)]);
4844
+ _optionalChain$h([ctx, 'optionalAccess', _ => _.doc, 'access', _2 => _2.schema, 'access', _3 => _3.tags, 'access', _4 => _4.some, 'call', _5 => _5(tag => tag.tag === merge.tag && tag.default)]);
4847
4845
  function addMergeToJSMap(ctx, map, value) {
4848
4846
  const source = resolveAliasValue(ctx, value);
4849
4847
  if (isSeq(source))
@@ -4883,7 +4881,7 @@ function resolveAliasValue(ctx, value) {
4883
4881
  return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
4884
4882
  }
4885
4883
 
4886
- function _optionalChain$h(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4884
+ function _optionalChain$g(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4887
4885
  function addPairToJSMap(ctx, map, { key, value }) {
4888
4886
  if (isNode(key) && key.addToJSMap)
4889
4887
  key.addToJSMap(ctx, map, value);
@@ -4920,7 +4918,7 @@ function stringifyKey(key, jsKey, ctx) {
4920
4918
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
4921
4919
  if (typeof jsKey !== 'object')
4922
4920
  return String(jsKey);
4923
- if (isNode(key) && _optionalChain$h([ctx, 'optionalAccess', _ => _.doc])) {
4921
+ if (isNode(key) && _optionalChain$g([ctx, 'optionalAccess', _ => _.doc])) {
4924
4922
  const strCtx = createStringifyContext(ctx.doc, {});
4925
4923
  strCtx.anchors = new Set();
4926
4924
  for (const node of ctx.anchors.keys())
@@ -4940,7 +4938,7 @@ function stringifyKey(key, jsKey, ctx) {
4940
4938
  return JSON.stringify(jsKey);
4941
4939
  }
4942
4940
 
4943
- function _optionalChain$g(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4941
+ function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4944
4942
  function createPair(key, value, ctx) {
4945
4943
  const k = createNode(key, undefined, ctx);
4946
4944
  const v = createNode(value, undefined, ctx);
@@ -4961,19 +4959,19 @@ class Pair {
4961
4959
  return new Pair(key, value);
4962
4960
  }
4963
4961
  toJSON(_, ctx) {
4964
- const pair = _optionalChain$g([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4962
+ const pair = _optionalChain$f([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4965
4963
  return addPairToJSMap(ctx, pair, this);
4966
4964
  }
4967
4965
  toString(ctx, onComment, onChompKeep) {
4968
- return _optionalChain$g([ctx, 'optionalAccess', _3 => _3.doc])
4966
+ return _optionalChain$f([ctx, 'optionalAccess', _3 => _3.doc])
4969
4967
  ? stringifyPair(this, ctx, onComment, onChompKeep)
4970
4968
  : JSON.stringify(this);
4971
4969
  }
4972
4970
  }
4973
4971
 
4974
- function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4972
+ function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$e(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4975
4973
  function stringifyCollection(collection, ctx, options) {
4976
- const flow = _nullishCoalesce$6(ctx.inFlow, () => ( collection.flow));
4974
+ const flow = _nullishCoalesce$5(ctx.inFlow, () => ( collection.flow));
4977
4975
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
4978
4976
  return stringify(collection, ctx, options);
4979
4977
  }
@@ -5065,7 +5063,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5065
5063
  if (iv.commentBefore)
5066
5064
  reqNewline = true;
5067
5065
  }
5068
- else if (item.value == null && _optionalChain$f([ik, 'optionalAccess', _ => _.comment])) {
5066
+ else if (item.value == null && _optionalChain$e([ik, 'optionalAccess', _ => _.comment])) {
5069
5067
  comment = ik.comment;
5070
5068
  }
5071
5069
  }
@@ -5120,7 +5118,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5120
5118
  }
5121
5119
  }
5122
5120
 
5123
- function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$e(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5121
+ function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5124
5122
  function findPair(items, key) {
5125
5123
  const k = isScalar(key) ? key.value : key;
5126
5124
  for (const it of items) {
@@ -5181,12 +5179,12 @@ class YAMLMap extends Collection {
5181
5179
  _pair = pair;
5182
5180
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5183
5181
  // In TypeScript, this never happens.
5184
- _pair = new Pair(pair, _optionalChain$e([pair, 'optionalAccess', _2 => _2.value]));
5182
+ _pair = new Pair(pair, _optionalChain$d([pair, 'optionalAccess', _2 => _2.value]));
5185
5183
  }
5186
5184
  else
5187
5185
  _pair = new Pair(pair.key, pair.value);
5188
5186
  const prev = findPair(this.items, _pair.key);
5189
- const sortEntries = _optionalChain$e([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5187
+ const sortEntries = _optionalChain$d([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5190
5188
  if (prev) {
5191
5189
  if (!overwrite)
5192
5190
  throw new Error(`Key ${_pair.key} already set`);
@@ -5216,8 +5214,8 @@ class YAMLMap extends Collection {
5216
5214
  }
5217
5215
  get(key, keepScalar) {
5218
5216
  const it = findPair(this.items, key);
5219
- const node = _optionalChain$e([it, 'optionalAccess', _5 => _5.value]);
5220
- return _nullishCoalesce$5((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5217
+ const node = _optionalChain$d([it, 'optionalAccess', _5 => _5.value]);
5218
+ return _nullishCoalesce$4((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5221
5219
  }
5222
5220
  has(key) {
5223
5221
  return !!findPair(this.items, key);
@@ -5231,8 +5229,8 @@ class YAMLMap extends Collection {
5231
5229
  * @returns Instance of Type, Map, or Object
5232
5230
  */
5233
5231
  toJSON(_, ctx, Type) {
5234
- const map = Type ? new Type() : _optionalChain$e([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5235
- if (_optionalChain$e([ctx, 'optionalAccess', _7 => _7.onCreate]))
5232
+ const map = Type ? new Type() : _optionalChain$d([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5233
+ if (_optionalChain$d([ctx, 'optionalAccess', _7 => _7.onCreate]))
5236
5234
  ctx.onCreate(map);
5237
5235
  for (const item of this.items)
5238
5236
  addPairToJSMap(ctx, map, item);
@@ -5257,7 +5255,7 @@ class YAMLMap extends Collection {
5257
5255
  }
5258
5256
  }
5259
5257
 
5260
- function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5258
+ function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5261
5259
  class YAMLSeq extends Collection {
5262
5260
  static get tagName() {
5263
5261
  return 'tag:yaml.org,2002:seq';
@@ -5320,7 +5318,7 @@ class YAMLSeq extends Collection {
5320
5318
  }
5321
5319
  toJSON(_, ctx) {
5322
5320
  const seq = [];
5323
- if (_optionalChain$d([ctx, 'optionalAccess', _2 => _2.onCreate]))
5321
+ if (_optionalChain$c([ctx, 'optionalAccess', _2 => _2.onCreate]))
5324
5322
  ctx.onCreate(seq);
5325
5323
  let i = 0;
5326
5324
  for (const item of this.items)
@@ -5399,7 +5397,7 @@ function createPairs(schema, iterable, ctx) {
5399
5397
  return pairs;
5400
5398
  }
5401
5399
 
5402
- function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5400
+ function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5403
5401
  class YAMLOMap extends YAMLSeq {
5404
5402
  constructor() {
5405
5403
  super();
@@ -5418,7 +5416,7 @@ class YAMLOMap extends YAMLSeq {
5418
5416
  if (!ctx)
5419
5417
  return super.toJSON(_);
5420
5418
  const map = new Map();
5421
- if (_optionalChain$c([ctx, 'optionalAccess', _2 => _2.onCreate]))
5419
+ if (_optionalChain$b([ctx, 'optionalAccess', _2 => _2.onCreate]))
5422
5420
  ctx.onCreate(map);
5423
5421
  for (const pair of this.items) {
5424
5422
  let key, value;
@@ -5536,7 +5534,7 @@ const isDirExists = async (file) => {
5536
5534
  }
5537
5535
  };
5538
5536
 
5539
- function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ABOUTME: Project type detection utility
5537
+ function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ABOUTME: Project type detection utility
5540
5538
 
5541
5539
  /**
5542
5540
  * 支持的项目类型枚举
@@ -5597,7 +5595,7 @@ var ProjectType; (function (ProjectType) {
5597
5595
  /**
5598
5596
  * 读取并解析 package.json
5599
5597
  */
5600
- const readPackageJson = async (
5598
+ const readPackageJson$1 = async (
5601
5599
  projectPath,
5602
5600
  ) => {
5603
5601
  const packageJsonPath = path.join(projectPath, 'package.json');
@@ -5619,7 +5617,7 @@ const collectProjectInfo = async (
5619
5617
  projectPath,
5620
5618
  ) => {
5621
5619
  // 1. 读取 package.json
5622
- const packageJson = await readPackageJson(projectPath);
5620
+ const packageJson = await readPackageJson$1(projectPath);
5623
5621
 
5624
5622
  // 2. 提取所有依赖
5625
5623
  const dependencies = new Set();
@@ -5638,7 +5636,7 @@ const collectProjectInfo = async (
5638
5636
  }
5639
5637
 
5640
5638
  const scripts = Object.entries(
5641
- (_optionalChain$b([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5639
+ (_optionalChain$a([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5642
5640
  ).reduce((acc, [name, script]) => {
5643
5641
  if (typeof script === 'string') {
5644
5642
  acc[name] = script;
@@ -5792,7 +5790,7 @@ const detectProjectType = async (
5792
5790
  };
5793
5791
  };
5794
5792
 
5795
- function _optionalChain$a(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5793
+ function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5796
5794
 
5797
5795
 
5798
5796
  /**
@@ -5966,16 +5964,16 @@ const getCommandConfig = (
5966
5964
 
5967
5965
  switch (commandName) {
5968
5966
  case 'dev':
5969
- commandConfig = _optionalChain$a([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5967
+ commandConfig = _optionalChain$9([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5970
5968
  break;
5971
5969
  case 'build':
5972
- commandConfig = _optionalChain$a([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5970
+ commandConfig = _optionalChain$9([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5973
5971
  break;
5974
5972
  case 'start':
5975
- commandConfig = _optionalChain$a([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5973
+ commandConfig = _optionalChain$9([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5976
5974
  break;
5977
5975
  case 'validate':
5978
- commandConfig = _optionalChain$a([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5976
+ commandConfig = _optionalChain$9([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5979
5977
  break;
5980
5978
  default:
5981
5979
  throw new Error(`Unknown command: ${commandName}`);
@@ -6126,7 +6124,7 @@ const byFlag = (flag) => {
6126
6124
  return predicate;
6127
6125
  };
6128
6126
 
6129
- function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6127
+ function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6130
6128
 
6131
6129
 
6132
6130
 
@@ -6157,7 +6155,7 @@ echo "Validate passed!"
6157
6155
  * @returns
6158
6156
  */
6159
6157
  const isCozeValid$3 = (cozeConfig) => {
6160
- if (_optionalChain$9([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6158
+ if (_optionalChain$8([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6161
6159
  logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
6162
6160
  return false;
6163
6161
  }
@@ -6222,7 +6220,7 @@ const isScriptValid$3 = async (projectFolder) => {
6222
6220
  * @param projectFolder
6223
6221
  * @returns
6224
6222
  */
6225
- const patchPackageJson$3 = async (projectFolder) => {
6223
+ const patchPackageJson$4 = async (projectFolder) => {
6226
6224
  const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$5);
6227
6225
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6228
6226
  const packageJson = safeJsonParse(packageJsonContent, null);
@@ -6290,7 +6288,7 @@ const patchExpoValidate = {
6290
6288
  (await isScriptValid$3(context.projectFolder)),
6291
6289
 
6292
6290
  apply: async (context) => {
6293
- await patchPackageJson$3(context.projectFolder);
6291
+ await patchPackageJson$4(context.projectFolder);
6294
6292
  await patchValidateScript$3(context.projectFolder);
6295
6293
  patchCoze$3(context.cozeConfig);
6296
6294
 
@@ -6302,7 +6300,7 @@ const patchExpoValidate = {
6302
6300
  },
6303
6301
  };
6304
6302
 
6305
- function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6303
+ function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6306
6304
 
6307
6305
 
6308
6306
 
@@ -6335,7 +6333,7 @@ echo "Validate passed!"
6335
6333
  * @returns
6336
6334
  */
6337
6335
  const isCozeValid$2 = (cozeConfig) => {
6338
- if (_optionalChain$8([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6336
+ if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6339
6337
  logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
6340
6338
  return false;
6341
6339
  }
@@ -6398,7 +6396,7 @@ const isScriptValid$2 = async (projectFolder) => {
6398
6396
  * @param projectFolder
6399
6397
  * @returns
6400
6398
  */
6401
- const patchPackageJson$2 = async (projectFolder) => {
6399
+ const patchPackageJson$3 = async (projectFolder) => {
6402
6400
  const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
6403
6401
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6404
6402
  const packageJson = safeJsonParse(packageJsonContent, null);
@@ -6471,7 +6469,7 @@ const patchNextjsValidate = {
6471
6469
  (await isScriptValid$2(context.projectFolder)),
6472
6470
 
6473
6471
  apply: async (context) => {
6474
- await patchPackageJson$2(context.projectFolder);
6472
+ await patchPackageJson$3(context.projectFolder);
6475
6473
  await patchValidateScript$2(context.projectFolder);
6476
6474
  patchCoze$2(context.cozeConfig);
6477
6475
 
@@ -6483,16 +6481,135 @@ const patchNextjsValidate = {
6483
6481
  },
6484
6482
  };
6485
6483
 
6486
- function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6484
+ function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6487
6485
 
6486
+ const PATCH_ID$5 = 'nextjs/validate-concurrently@0.0.30';
6487
+ const PACKAGE_JSON_FILE$3 = 'package.json';
6488
+ const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
6489
+ const NEXTJS_VALIDATE_CONCURRENTLY_FLAG = 'coding.arch.patch_nextjs_validate_concurrently';
6490
+ const LEGACY_VALIDATE_WITH_STYLE = "pnpm run --parallel '/^(ts-check|lint:build|lint:style)$/'";
6491
+ const LEGACY_VALIDATE_WITHOUT_STYLE = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
6492
+ const TARGET_VALIDATE_WITH_STYLE =
6493
+ 'pnpm dlx concurrently --group --names lint-tsc,lint-build,lint-style "pnpm ts-check" "pnpm lint:build" "pnpm lint:style"';
6494
+ const TARGET_VALIDATE_WITHOUT_STYLE = 'pnpm dlx concurrently --group --names lint-tsc,lint-build "pnpm ts-check" "pnpm lint:build"';
6488
6495
 
6489
6496
 
6490
6497
 
6491
6498
 
6492
6499
 
6493
- const PATCH_ID$5 = 'vite/validate@0.0.20';
6494
- const PACKAGE_JSON_FILE$3 = 'package.json';
6495
- const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
6500
+ const readPackageJson = async (projectFolder) => {
6501
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
6502
+ if (!(await isFileExists(packageJsonPath))) {
6503
+ logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: package.json not found');
6504
+ return null;
6505
+ }
6506
+
6507
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6508
+ const packageJson = safeJsonParse(packageJsonContent, null);
6509
+ if (!packageJson) {
6510
+ logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: package.json is invalid');
6511
+ return null;
6512
+ }
6513
+ return packageJson;
6514
+ };
6515
+
6516
+ const getTargetValidateScript = (packageJson) => {
6517
+ const validateScript = _optionalChain$6([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
6518
+ if (typeof validateScript !== 'string') {
6519
+ return null;
6520
+ }
6521
+
6522
+ const normalizedScript = validateScript.trim();
6523
+ if (normalizedScript === LEGACY_VALIDATE_WITH_STYLE) {
6524
+ return TARGET_VALIDATE_WITH_STYLE;
6525
+ }
6526
+ if (normalizedScript === LEGACY_VALIDATE_WITHOUT_STYLE) {
6527
+ return TARGET_VALIDATE_WITHOUT_STYLE;
6528
+ }
6529
+ return null;
6530
+ };
6531
+
6532
+ const canStackAfterNextjsValidatePatch = async (context, packageJson) => {
6533
+ const scripts = packageJson.scripts || {};
6534
+ if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$6([context, 'access', _3 => _3.cozeConfig, 'access', _4 => _4.dev, 'optionalAccess', _5 => _5.validate])) {
6535
+ return false;
6536
+ }
6537
+
6538
+ return !(await isFileExists(path.join(context.projectFolder, VALIDATE_SCRIPT_FILE$2)));
6539
+ };
6540
+
6541
+ const hasPatchTarget = async (context) => {
6542
+ const packageJson = await readPackageJson(context.projectFolder);
6543
+ if (!packageJson) {
6544
+ return false;
6545
+ }
6546
+
6547
+ if (getTargetValidateScript(packageJson)) {
6548
+ return true;
6549
+ }
6550
+
6551
+ if (await canStackAfterNextjsValidatePatch(context, packageJson)) {
6552
+ return true;
6553
+ }
6554
+
6555
+ logger.info('[patch-nextjs-validate-concurrently] NOT APPLY: validate script is not legacy pnpm run --parallel command');
6556
+ return false;
6557
+ };
6558
+
6559
+ const patchPackageJson$2 = async (context) => {
6560
+ const packageJsonPath = path.join(context.projectFolder, PACKAGE_JSON_FILE$3);
6561
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6562
+ const packageJson = safeJsonParse(packageJsonContent, null);
6563
+ const scripts = packageJson.scripts || {};
6564
+
6565
+ const targetValidateScript = getTargetValidateScript(packageJson);
6566
+ if (!targetValidateScript) {
6567
+ return {
6568
+ applied: false,
6569
+ patchId: PATCH_ID$5,
6570
+ message: 'legacy validate command not found',
6571
+ };
6572
+ }
6573
+
6574
+ scripts.validate = targetValidateScript;
6575
+ packageJson.scripts = scripts;
6576
+ await fs$1.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8');
6577
+ logger.info('[patch-nextjs-validate-concurrently] package.json patched');
6578
+
6579
+ return {
6580
+ applied: true,
6581
+ patchId: PATCH_ID$5,
6582
+ message: 'nextjs validate command patched',
6583
+ };
6584
+ };
6585
+
6586
+ const patchNextjsValidateConcurrently = {
6587
+ id: PATCH_ID$5,
6588
+ template: 'nextjs',
6589
+ disabled: byFlag(NEXTJS_VALIDATE_CONCURRENTLY_FLAG),
6590
+ operations: [
6591
+ {
6592
+ kind: 'file-patch',
6593
+ file: PACKAGE_JSON_FILE$3,
6594
+ description: 'Replace legacy validate command with concurrently',
6595
+ },
6596
+ ],
6597
+
6598
+ shouldApply: hasPatchTarget,
6599
+
6600
+ apply: patchPackageJson$2,
6601
+ };
6602
+
6603
+ function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6604
+
6605
+
6606
+
6607
+
6608
+
6609
+
6610
+ const PATCH_ID$4 = 'vite/validate@0.0.20';
6611
+ const PACKAGE_JSON_FILE$2 = 'package.json';
6612
+ const VALIDATE_SCRIPT_FILE$1 = 'scripts/validate.sh';
6496
6613
  const VITE_VALIDATE_FLAG = 'coding.arch.patch_vite_validate';
6497
6614
  const TARGET_LINT_BUILD$1 = 'eslint . --quiet';
6498
6615
  const TARGET_VALIDATE$1 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
@@ -6516,7 +6633,7 @@ echo "Validate passed!"
6516
6633
  * @returns
6517
6634
  */
6518
6635
  const isCozeValid$1 = (cozeConfig) => {
6519
- if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6636
+ if (_optionalChain$5([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6520
6637
  logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
6521
6638
  return false;
6522
6639
  }
@@ -6532,7 +6649,7 @@ const isCozeValid$1 = (cozeConfig) => {
6532
6649
  * @returns
6533
6650
  */
6534
6651
  const isPackageJsonValid$1 = async (projectFolder) => {
6535
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
6652
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6536
6653
  if (!(await isFileExists(packageJsonPath))) {
6537
6654
  logger.info('[patch-vite-validate] NOT APPLY: package.json not found');
6538
6655
  return false;
@@ -6564,7 +6681,7 @@ const isPackageJsonValid$1 = async (projectFolder) => {
6564
6681
  * @returns
6565
6682
  */
6566
6683
  const isScriptValid$1 = async (projectFolder) => {
6567
- const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
6684
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6568
6685
  if (await isFileExists(validateScriptPath)) {
6569
6686
  logger.info('[patch-vite-validate] NOT APPLY: validate.sh already exists');
6570
6687
  return false;
@@ -6578,7 +6695,7 @@ const isScriptValid$1 = async (projectFolder) => {
6578
6695
  * @returns
6579
6696
  */
6580
6697
  const patchPackageJson$1 = async (projectFolder) => {
6581
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
6698
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6582
6699
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6583
6700
  const packageJson = safeJsonParse(packageJsonContent, null);
6584
6701
  const scripts = packageJson.scripts || {};
@@ -6602,7 +6719,7 @@ const patchPackageJson$1 = async (projectFolder) => {
6602
6719
  * @returns
6603
6720
  */
6604
6721
  const patchValidateScript$1 = async (projectFolder) => {
6605
- const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
6722
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6606
6723
  await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
6607
6724
  await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$1, 'utf-8');
6608
6725
  logger.info('[patch-vite-validate] validate.sh patched');
@@ -6622,18 +6739,18 @@ const patchCoze$1 = (cozeConfig) => {
6622
6739
  };
6623
6740
 
6624
6741
  const patchViteValidate = {
6625
- id: PATCH_ID$5,
6742
+ id: PATCH_ID$4,
6626
6743
  template: 'vite',
6627
6744
  disabled: byFlag(VITE_VALIDATE_FLAG),
6628
6745
  operations: [
6629
6746
  {
6630
6747
  kind: 'file-patch',
6631
- file: PACKAGE_JSON_FILE$3,
6748
+ file: PACKAGE_JSON_FILE$2,
6632
6749
  description: 'Add lint:build and validate scripts for vite projects',
6633
6750
  },
6634
6751
  {
6635
6752
  kind: 'create-file',
6636
- file: VALIDATE_SCRIPT_FILE$2,
6753
+ file: VALIDATE_SCRIPT_FILE$1,
6637
6754
  description: 'Add validate shell script for vite projects',
6638
6755
  },
6639
6756
  {
@@ -6655,22 +6772,22 @@ const patchViteValidate = {
6655
6772
 
6656
6773
  return {
6657
6774
  applied: true,
6658
- patchId: PATCH_ID$5,
6775
+ patchId: PATCH_ID$4,
6659
6776
  message: 'vite validate patched',
6660
6777
  };
6661
6778
  },
6662
6779
  };
6663
6780
 
6664
- function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6781
+ function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6665
6782
 
6666
6783
 
6667
6784
 
6668
6785
 
6669
6786
 
6670
6787
 
6671
- const PATCH_ID$4 = 'taro/validate@0.0.20';
6672
- const PACKAGE_JSON_FILE$2 = 'package.json';
6673
- const VALIDATE_SCRIPT_FILE$1 = '.cozeproj/scripts/validate.sh';
6788
+ const PATCH_ID$3 = 'taro/validate@0.0.20';
6789
+ const PACKAGE_JSON_FILE$1 = 'package.json';
6790
+ const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
6674
6791
  const TARO_VALIDATE_FLAG = 'coding.arch.patch_taro_validate';
6675
6792
 
6676
6793
  const LEGACY_LINT_BUILD =
@@ -6698,7 +6815,7 @@ echo "Validate passed!"
6698
6815
  * @returns
6699
6816
  */
6700
6817
  const isCozeValid = (cozeConfig) => {
6701
- if (_optionalChain$6([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6818
+ if (_optionalChain$4([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6702
6819
  logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
6703
6820
  return false;
6704
6821
  }
@@ -6714,7 +6831,7 @@ const isCozeValid = (cozeConfig) => {
6714
6831
  * @returns
6715
6832
  */
6716
6833
  const isPackageJsonValid = async (projectFolder) => {
6717
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6834
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
6718
6835
  if (!(await isFileExists(packageJsonPath))) {
6719
6836
  logger.info('[patch-taro-validate] NOT APPLY: package.json not found');
6720
6837
  return false;
@@ -6748,7 +6865,7 @@ const isPackageJsonValid = async (projectFolder) => {
6748
6865
  * @returns
6749
6866
  */
6750
6867
  const isScriptValid = async (projectFolder) => {
6751
- const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6868
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
6752
6869
  if (await isFileExists(validateScriptPath)) {
6753
6870
  logger.info('[patch-taro-validate] NOT APPLY: validate.sh already exists');
6754
6871
  return false;
@@ -6762,7 +6879,7 @@ const isScriptValid = async (projectFolder) => {
6762
6879
  * @returns
6763
6880
  */
6764
6881
  const patchPackageJson = async (projectFolder) => {
6765
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6882
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
6766
6883
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6767
6884
  const packageJson = safeJsonParse(packageJsonContent, null);
6768
6885
  const scripts = packageJson.scripts || {};
@@ -6789,7 +6906,7 @@ const patchPackageJson = async (projectFolder) => {
6789
6906
  * @returns
6790
6907
  */
6791
6908
  const patchValidateScript = async (projectFolder) => {
6792
- const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6909
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
6793
6910
  await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
6794
6911
  await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT, 'utf-8');
6795
6912
  logger.info('[patch-taro-validate] validate.sh patched');
@@ -6809,19 +6926,19 @@ const patchCoze = (cozeConfig) => {
6809
6926
  };
6810
6927
 
6811
6928
  const patchTaroValidate = {
6812
- id: PATCH_ID$4,
6929
+ id: PATCH_ID$3,
6813
6930
  template: 'taro',
6814
6931
  disabled: byFlag(TARO_VALIDATE_FLAG),
6815
6932
  operations: [
6816
6933
  {
6817
6934
  kind: 'file-patch',
6818
- file: PACKAGE_JSON_FILE$2,
6935
+ file: PACKAGE_JSON_FILE$1,
6819
6936
  description:
6820
6937
  'Update lint:build and add validate script for taro projects',
6821
6938
  },
6822
6939
  {
6823
6940
  kind: 'create-file',
6824
- file: VALIDATE_SCRIPT_FILE$1,
6941
+ file: VALIDATE_SCRIPT_FILE,
6825
6942
  description: 'Add validate shell script for taro projects',
6826
6943
  },
6827
6944
  {
@@ -6841,15 +6958,15 @@ const patchTaroValidate = {
6841
6958
 
6842
6959
  return {
6843
6960
  applied: true,
6844
- patchId: PATCH_ID$4,
6961
+ patchId: PATCH_ID$3,
6845
6962
  message: 'taro validate patched',
6846
6963
  };
6847
6964
  },
6848
6965
  };
6849
6966
 
6850
- function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6851
- const PATCH_ID$3 = 'taro/update-pack-script-for-tt-build@0.0.13';
6852
- const PACKAGE_JSON_FILE$1 = 'package.json';
6967
+ function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6968
+ const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
6969
+ const PACKAGE_JSON_FILE = 'package.json';
6853
6970
  const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
6854
6971
  const LEGACY_PACK_SCRIPT_HASHES = new Set([
6855
6972
  '987575c08e1c32ce7bc553e1668b3ad8faad5623343fd0d21fea34d39f25a56d',
@@ -6918,7 +7035,7 @@ const hashContent = (content) =>
6918
7035
  const readPackageScripts = async (
6919
7036
  projectFolder,
6920
7037
  ) => {
6921
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
7038
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
6922
7039
  if (!(await isFileExists(packageJsonPath))) {
6923
7040
  return null;
6924
7041
  }
@@ -6926,12 +7043,12 @@ const readPackageScripts = async (
6926
7043
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6927
7044
  const packageJson = safeJsonParse(packageJsonContent, null);
6928
7045
 
6929
- return _optionalChain$5([packageJson, 'optionalAccess', _ => _.scripts]) || null;
7046
+ return _optionalChain$3([packageJson, 'optionalAccess', _ => _.scripts]) || null;
6930
7047
  };
6931
7048
 
6932
7049
  const hasBuildTtScript = async (projectFolder) => {
6933
7050
  const scripts = await readPackageScripts(projectFolder);
6934
- return typeof _optionalChain$5([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
7051
+ return typeof _optionalChain$3([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
6935
7052
  };
6936
7053
 
6937
7054
  const hasLegacyPackScript = async (projectFolder) => {
@@ -6945,7 +7062,7 @@ const hasLegacyPackScript = async (projectFolder) => {
6945
7062
  };
6946
7063
 
6947
7064
  const patchTaroPackScript = {
6948
- id: PATCH_ID$3,
7065
+ id: PATCH_ID$2,
6949
7066
  template: 'taro',
6950
7067
  disabled: byFlag('coding.arch.patch_taro_update_pack_script_for_tt_build'),
6951
7068
  operations: [
@@ -6964,7 +7081,7 @@ const patchTaroPackScript = {
6964
7081
  if (context.template !== 'taro') {
6965
7082
  return {
6966
7083
  applied: false,
6967
- patchId: PATCH_ID$3,
7084
+ patchId: PATCH_ID$2,
6968
7085
  message: 'Only applies to taro projects, skipping',
6969
7086
  };
6970
7087
  }
@@ -6972,7 +7089,7 @@ const patchTaroPackScript = {
6972
7089
  if (!(await hasBuildTtScript(context.projectFolder))) {
6973
7090
  return {
6974
7091
  applied: false,
6975
- patchId: PATCH_ID$3,
7092
+ patchId: PATCH_ID$2,
6976
7093
  message: 'package.json does not contain build:tt, skipping',
6977
7094
  };
6978
7095
  }
@@ -6980,7 +7097,7 @@ const patchTaroPackScript = {
6980
7097
  if (!(await hasLegacyPackScript(context.projectFolder))) {
6981
7098
  return {
6982
7099
  applied: false,
6983
- patchId: PATCH_ID$3,
7100
+ patchId: PATCH_ID$2,
6984
7101
  message: 'pack.sh does not match legacy template hash, skipping',
6985
7102
  };
6986
7103
  }
@@ -6994,13 +7111,13 @@ const patchTaroPackScript = {
6994
7111
 
6995
7112
  return {
6996
7113
  applied: true,
6997
- patchId: PATCH_ID$3,
7114
+ patchId: PATCH_ID$2,
6998
7115
  message: 'Updated legacy pack.sh to build weapp and tt targets',
6999
7116
  };
7000
7117
  },
7001
7118
  };
7002
7119
 
7003
- const PATCH_ID$2 = 'taro/add-agents-md@0.0.13';
7120
+ const PATCH_ID$1 = 'taro/add-agents-md@0.0.13';
7004
7121
  const AGENTS_FILE = 'AGENTS.md';
7005
7122
  const getTemplateAgentsPath = () =>
7006
7123
  path.join(getTemplatesDir(), 'taro', AGENTS_FILE);
@@ -7012,7 +7129,7 @@ const readTemplateAgentsContent = async () =>
7012
7129
  fs$1.readFile(getTemplateAgentsPath(), 'utf-8');
7013
7130
 
7014
7131
  const patchTaroAgentsMd = {
7015
- id: PATCH_ID$2,
7132
+ id: PATCH_ID$1,
7016
7133
  template: 'taro',
7017
7134
  disabled: byFlag('coding.arch.patch_taro_add_agents_md'),
7018
7135
  operations: [
@@ -7030,7 +7147,7 @@ const patchTaroAgentsMd = {
7030
7147
  if (context.template !== 'taro') {
7031
7148
  return {
7032
7149
  applied: false,
7033
- patchId: PATCH_ID$2,
7150
+ patchId: PATCH_ID$1,
7034
7151
  message: 'Only applies to taro projects, skipping',
7035
7152
  };
7036
7153
  }
@@ -7039,7 +7156,7 @@ const patchTaroAgentsMd = {
7039
7156
  if (await isFileExists(targetPath)) {
7040
7157
  return {
7041
7158
  applied: false,
7042
- patchId: PATCH_ID$2,
7159
+ patchId: PATCH_ID$1,
7043
7160
  message: 'AGENTS.md already exists, skipping',
7044
7161
  };
7045
7162
  }
@@ -7049,146 +7166,12 @@ const patchTaroAgentsMd = {
7049
7166
 
7050
7167
  return {
7051
7168
  applied: true,
7052
- patchId: PATCH_ID$2,
7169
+ patchId: PATCH_ID$1,
7053
7170
  message: 'Created AGENTS.md from taro template',
7054
7171
  };
7055
7172
  },
7056
7173
  };
7057
7174
 
7058
- function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7059
-
7060
-
7061
-
7062
-
7063
-
7064
- const OLD_WEB_TEMPLATE_VALIDATE_SCRIPT = `#!/bin/bash
7065
- set -Eeuo pipefail
7066
-
7067
- COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
7068
-
7069
- cd "\${COZE_WORKSPACE_PATH}"
7070
-
7071
- echo "\u{1F50D} Running validate..."
7072
- pnpm validate
7073
- echo "\u{2705} Validate passed!"
7074
- `;
7075
-
7076
- const OLD_WEB_PATCH_VALIDATE_SCRIPT = `#!/bin/bash
7077
- set -Eeuo pipefail
7078
- COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
7079
- cd "\${COZE_WORKSPACE_PATH}"
7080
- echo "Running validate..."
7081
- pnpm validate
7082
- echo "Validate passed!"
7083
- `;
7084
-
7085
- const createValidateScript = (parallelArgs) => `#!/bin/bash
7086
- set -Eeuo pipefail
7087
-
7088
- COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
7089
-
7090
- cd "\${COZE_WORKSPACE_PATH}"
7091
-
7092
- echo "Running validate..."
7093
- coze-dev parallel ${parallelArgs}
7094
- echo "Validate passed!"
7095
- `;
7096
-
7097
- const PACKAGE_JSON_FILE = 'package.json';
7098
- const VALIDATE_SCRIPT_FILE = 'scripts/validate.sh';
7099
- const PARALLEL_SCRIPT_NAMES = ['ts-check', 'lint:build', 'lint:style'] ;
7100
- const REQUIRED_SCRIPT_NAMES = ['ts-check', 'lint:build'] ;
7101
-
7102
- const isKnownOldValidateScript = (content) => [OLD_WEB_TEMPLATE_VALIDATE_SCRIPT, OLD_WEB_PATCH_VALIDATE_SCRIPT].includes(content);
7103
-
7104
- const loadPackageJson = async (projectFolder) => {
7105
- const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE);
7106
- if (!(await isFileExists(packageJsonPath))) {
7107
- return null;
7108
- }
7109
-
7110
- const content = await fs$1.readFile(packageJsonPath, 'utf-8');
7111
- return safeJsonParse(content, null);
7112
- };
7113
-
7114
- const hasScript = (scripts, scriptName) => {
7115
- if (!scripts) {
7116
- return false;
7117
- }
7118
- return typeof _optionalChain$4([Object, 'access', _ => _.getOwnPropertyDescriptor, 'call', _2 => _2(scripts, scriptName), 'optionalAccess', _3 => _3.value]) === 'string';
7119
- };
7120
-
7121
- const getParallelArgs = async (projectFolder) => {
7122
- const packageJson = await loadPackageJson(projectFolder);
7123
- const scripts = _optionalChain$4([packageJson, 'optionalAccess', _4 => _4.scripts]);
7124
- if (!REQUIRED_SCRIPT_NAMES.every(scriptName => hasScript(scripts, scriptName))) {
7125
- return null;
7126
- }
7127
-
7128
- return PARALLEL_SCRIPT_NAMES.filter(scriptName => hasScript(scripts, scriptName)).join(' ');
7129
- };
7130
-
7131
- const applyValidateRunnerPatch = async (context, patchId) => {
7132
- const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
7133
- const content = await fs$1.readFile(validateScriptPath, 'utf-8');
7134
-
7135
- if (!isKnownOldValidateScript(content)) {
7136
- return {
7137
- applied: false,
7138
- patchId,
7139
- message: 'validate.sh content is not a known old version, skipping',
7140
- };
7141
- }
7142
-
7143
- const parallelArgs = await getParallelArgs(context.projectFolder);
7144
- if (!parallelArgs) {
7145
- return {
7146
- applied: false,
7147
- patchId,
7148
- message: 'package.json scripts do not contain known validate scripts, skipping',
7149
- };
7150
- }
7151
-
7152
- await fs$1.writeFile(validateScriptPath, createValidateScript(parallelArgs), 'utf-8');
7153
-
7154
- logger.info(`Patched ${VALIDATE_SCRIPT_FILE}: use coze-dev parallel`);
7155
-
7156
- return {
7157
- applied: true,
7158
- patchId,
7159
- message: 'Updated validate.sh',
7160
- };
7161
- };
7162
-
7163
- const PATCH_ID$1 = 'nextjs/validate-runner@0.0.31';
7164
-
7165
- const patchNextjsValidateRunner = {
7166
- id: PATCH_ID$1,
7167
- template: 'nextjs',
7168
- disabled: byFlag('coding.arch.patch_nextjs_validate_runner'),
7169
- operations: [
7170
- {
7171
- kind: 'file-patch',
7172
- file: VALIDATE_SCRIPT_FILE,
7173
- description: 'Update validate shell script to use coze-dev parallel',
7174
- },
7175
- ],
7176
- shouldApply: async context => {
7177
- const validateScriptPath = path.join(context.projectFolder, VALIDATE_SCRIPT_FILE);
7178
- if (!(await isFileExists(validateScriptPath))) {
7179
- return false;
7180
- }
7181
-
7182
- const content = await fs$1.readFile(validateScriptPath, 'utf-8');
7183
- if (!isKnownOldValidateScript(content)) {
7184
- return false;
7185
- }
7186
-
7187
- return Boolean(await getParallelArgs(context.projectFolder));
7188
- },
7189
- apply: context => applyValidateRunnerPatch(context, PATCH_ID$1),
7190
- };
7191
-
7192
7175
  const SCRIPT_FILES = ['dev.sh', 'build.sh'] ;
7193
7176
  const SUPPORTED_TEMPLATES = new Set(['nextjs', 'vite', 'nuxt-vue']);
7194
7177
 
@@ -7404,7 +7387,7 @@ const patches = [
7404
7387
  patchExpoValidate,
7405
7388
  replaceNpxWithPnpmPatchNextjs,
7406
7389
  patchNextjsValidate,
7407
- patchNextjsValidateRunner,
7390
+ patchNextjsValidateConcurrently,
7408
7391
  replaceNpxWithPnpmPatchVite,
7409
7392
  patchViteValidate,
7410
7393
  replaceNpxWithPnpmPatchNuxtVue,
@@ -7414,9 +7397,12 @@ const patches = [
7414
7397
  patchTaroPackScript,
7415
7398
  ] ;
7416
7399
 
7417
- const getTemplatePatches = (template) => patches.filter(patch => patch.template === template);
7418
-
7419
- function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7400
+ const getTemplatePatches = (
7401
+ template,
7402
+ ) =>
7403
+ patches.filter(patch => patch.template === template);
7404
+
7405
+ function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7420
7406
  const DEFAULT_LEGACY_VERSION = 'legacy';
7421
7407
 
7422
7408
  const loadFlagsWithFallback = async () => {
@@ -7522,7 +7508,7 @@ const getNextPatchState = (
7522
7508
 
7523
7509
  ) => ({
7524
7510
  template,
7525
- version: _optionalChain$3([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
7511
+ version: _optionalChain$2([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
7526
7512
  appliedPatches: [...appliedPatches, patchId],
7527
7513
  });
7528
7514
 
@@ -7546,15 +7532,15 @@ const executePatch = async (
7546
7532
  }
7547
7533
 
7548
7534
  const template =
7549
- _optionalChain$3([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
7535
+ _optionalChain$2([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
7550
7536
 
7551
7537
  if (!template) {
7552
7538
  logger.info('Patch skipped: template not detected');
7553
7539
  return;
7554
7540
  }
7555
7541
 
7556
- const appliedPatches = [...(_optionalChain$3([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
7557
- const projectVersion = _optionalChain$3([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
7542
+ const appliedPatches = [...(_optionalChain$2([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
7543
+ const projectVersion = _optionalChain$2([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
7558
7544
  const flags = await loadFlagsWithFallback();
7559
7545
 
7560
7546
  const context = {
@@ -7599,7 +7585,7 @@ const executePatch = async (
7599
7585
 
7600
7586
  if (options.dryRun) {
7601
7587
  logger.info(`Detected template: ${template}`);
7602
- logger.info(`Current version: ${_nullishCoalesce$4(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7588
+ logger.info(`Current version: ${_nullishCoalesce$3(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7603
7589
  logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
7604
7590
  logger.info('Matched patches:');
7605
7591
  matchedPatches.forEach(patch => {
@@ -7640,7 +7626,7 @@ const executePatch = async (
7640
7626
  }
7641
7627
  };
7642
7628
 
7643
- const registerCommand$5 = program => {
7629
+ const registerCommand$4 = program => {
7644
7630
  program
7645
7631
  .command('patch')
7646
7632
  .description('Apply template patches for existing projects')
@@ -7657,14 +7643,14 @@ const registerCommand$5 = program => {
7657
7643
  ) => {
7658
7644
  await executePatch({
7659
7645
  directory,
7660
- dryRun: _optionalChain$3([command, 'optionalAccess', _9 => _9.dryRun]),
7661
- showFlags: _optionalChain$3([command, 'optionalAccess', _10 => _10.showFlags]),
7646
+ dryRun: _optionalChain$2([command, 'optionalAccess', _9 => _9.dryRun]),
7647
+ showFlags: _optionalChain$2([command, 'optionalAccess', _10 => _10.showFlags]),
7662
7648
  });
7663
7649
  },
7664
7650
  );
7665
7651
  };
7666
7652
 
7667
- function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7653
+ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7668
7654
  const d$1 = debug('coze-init-cli:run');
7669
7655
 
7670
7656
  /**
@@ -7795,12 +7781,12 @@ const executeRun = async (commandName, options = {}) => {
7795
7781
  }
7796
7782
 
7797
7783
  // 将输出同时写入控制台和日志文件
7798
- _optionalChain$2([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
7784
+ _optionalChain$1([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
7799
7785
  process.stdout.write(data);
7800
7786
  logStream.write(data);
7801
7787
  })]);
7802
7788
 
7803
- _optionalChain$2([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
7789
+ _optionalChain$1([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
7804
7790
  process.stderr.write(data);
7805
7791
  logStream.write(data);
7806
7792
  })]);
@@ -7813,7 +7799,7 @@ const executeRun = async (commandName, options = {}) => {
7813
7799
  const buildDuration = Date.now() - buildStartTime;
7814
7800
 
7815
7801
  if (code !== 0) {
7816
- const errorMessage = `Command exited with code ${_nullishCoalesce$3(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7802
+ const errorMessage = `Command exited with code ${_nullishCoalesce$2(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7817
7803
  logger.error(errorMessage);
7818
7804
  logger.error(`Check log file for details: ${logFilePath}`);
7819
7805
 
@@ -7825,12 +7811,12 @@ const executeRun = async (commandName, options = {}) => {
7825
7811
  categories: {
7826
7812
  fixDuration: String(fixDuration),
7827
7813
  buildDuration: String(buildDuration),
7828
- exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
7814
+ exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
7829
7815
  projectType,
7830
7816
  },
7831
7817
  errorContext: {
7832
- exitCode: String(_nullishCoalesce$3(code, () => ( 'unknown'))),
7833
- signal: _nullishCoalesce$3(signal, () => ( 'none')),
7818
+ exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
7819
+ signal: _nullishCoalesce$2(signal, () => ( 'none')),
7834
7820
  logFile: logFilePath,
7835
7821
  projectType,
7836
7822
  },
@@ -7906,7 +7892,7 @@ const executeRun = async (commandName, options = {}) => {
7906
7892
  /**
7907
7893
  * 注册 dev/build/start 命令到 program
7908
7894
  */
7909
- const registerCommand$4 = program => {
7895
+ const registerCommand$3 = program => {
7910
7896
  // dev 命令
7911
7897
  program
7912
7898
  .command('dev')
@@ -8734,7 +8720,7 @@ const scanRoutesOnce = async (
8734
8720
  }
8735
8721
  };
8736
8722
 
8737
- function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// Route manifest generation command
8723
+ function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// Route manifest generation command
8738
8724
 
8739
8725
 
8740
8726
  const log = debug('coze:routes');
@@ -8822,7 +8808,7 @@ const executeRoutes = async (
8822
8808
  /**
8823
8809
  * Register routes command to program
8824
8810
  */
8825
- const registerCommand$3 = program => {
8811
+ const registerCommand$2 = program => {
8826
8812
  program
8827
8813
  .command('routes')
8828
8814
  .description('Generate routes manifest for the current project')
@@ -8835,17 +8821,14 @@ const registerCommand$3 = program => {
8835
8821
  'Output file path (defaults to ~/.coze/routes.json)',
8836
8822
  )
8837
8823
  .action(async (directory, options) => {
8838
- await executeRoutes({ directory, output: _optionalChain$1([options, 'optionalAccess', _ => _.output]) });
8824
+ await executeRoutes({ directory, output: _optionalChain([options, 'optionalAccess', _ => _.output]) });
8839
8825
  });
8840
8826
  };
8841
8827
 
8842
- function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
8843
-
8844
-
8845
-
8846
-
8828
+ function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
8847
8829
 
8848
8830
 
8831
+ const d = debug('coze-init-cli:check-bins');
8849
8832
 
8850
8833
 
8851
8834
 
@@ -8853,123 +8836,117 @@ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else
8853
8836
 
8854
8837
 
8855
8838
 
8839
+ const checkBins = async (cwd, fix) => {
8840
+ d('starting check, cwd=%s fix=%s', cwd, fix);
8856
8841
 
8842
+ const pkgJson = safeJsonParse
8857
8843
 
8858
8844
 
8845
+ (await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
8859
8846
 
8847
+ const allDeps = Object.keys({
8848
+ ...pkgJson.dependencies,
8849
+ ...pkgJson.devDependencies,
8850
+ });
8860
8851
 
8852
+ d('found %d total dependencies to scan', allDeps.length);
8861
8853
 
8854
+ const binDir = path.join(cwd, 'node_modules', '.bin');
8855
+ d('bin directory: %s', binDir);
8856
+ const missing = [];
8862
8857
 
8863
- const collectOption = (value, previous = []) => [...previous, value];
8858
+ await Promise.all(
8859
+ allDeps.map(async depName => {
8860
+ let rawContent;
8861
+ try {
8862
+ rawContent = await fs$1.readFile(
8863
+ path.join(cwd, 'node_modules', depName, 'package.json'),
8864
+ 'utf8',
8865
+ );
8866
+ } catch (err) {
8867
+ d('dep %s not found in node_modules: %s', depName, err);
8868
+ missing.push({ dep: depName, bin: '', reason: 'missing-package' });
8869
+ return;
8870
+ }
8871
+ const depPkg = safeJsonParse(
8872
+ rawContent,
8873
+ );
8874
+ if (!depPkg) {
8875
+ d('skipping %s: failed to parse package.json', depName);
8876
+ return;
8877
+ }
8864
8878
 
8865
- const createScriptTask = (script, packageManager) => ({
8866
- label: script,
8867
- command: packageManager,
8868
- args: ['run', script],
8869
- });
8879
+ if (!depPkg.bin) {
8880
+ return;
8881
+ }
8870
8882
 
8871
- const createCommandTask = (command) => ({
8872
- label: command,
8873
- command,
8874
- args: [],
8875
- shell: true,
8876
- });
8883
+ const bins =
8884
+ typeof depPkg.bin === 'string'
8885
+ ? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
8886
+ : depPkg.bin;
8877
8887
 
8878
- const runTask = (task, cwd) =>
8879
- new Promise(resolve => {
8880
- const output = [];
8881
- const child = child_process.spawn(task.command, task.args, {
8882
- cwd,
8883
- env: process.env,
8884
- shell: task.shell,
8885
- stdio: ['ignore', 'pipe', 'pipe'],
8886
- });
8888
+ d('%s declares bins: %o', depName, Object.keys(bins));
8887
8889
 
8888
- _optionalChain([child, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', data => {
8889
- output.push(String(data));
8890
- })]);
8891
- _optionalChain([child, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', data => {
8892
- output.push(String(data));
8893
- })]);
8894
- child.on('error', error => {
8895
- output.push(`${error.stack || error.message}\n`);
8896
- resolve({
8897
- label: task.label,
8898
- code: 1,
8899
- output: output.join(''),
8900
- });
8901
- });
8902
- child.on('close', code => {
8903
- resolve({
8904
- label: task.label,
8905
- code: _nullishCoalesce$2(code, () => ( 1)),
8906
- output: output.join(''),
8907
- });
8908
- });
8909
- });
8890
+ await Promise.all(
8891
+ Object.keys(bins).map(async binName => {
8892
+ try {
8893
+ await fs$1.access(path.join(binDir, binName));
8894
+ d('bin present: %s', binName);
8895
+ } catch (err) {
8896
+ d('bin missing: %s (from %s): %s', binName, depName, err);
8897
+ missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
8898
+ }
8899
+ }),
8900
+ );
8901
+ }),
8902
+ );
8910
8903
 
8911
- const runParallelScripts = async (scripts, options = {}) => {
8912
- const resolvedOptions = {
8913
- cwd: options.cwd || process.cwd(),
8914
- packageManager: options.packageManager || 'pnpm',
8915
- commands: options.cmd || [],
8916
- };
8917
- const tasks = [
8918
- ...scripts.map(script => createScriptTask(script, resolvedOptions.packageManager)),
8919
- ...resolvedOptions.commands.map(command => createCommandTask(command)),
8920
- ];
8904
+ d('scan complete, missing=%d', missing.length);
8921
8905
 
8922
- if (tasks.length === 0) {
8923
- process.stderr.write('No scripts or commands specified.\n');
8924
- return 1;
8906
+ if (missing.length === 0) {
8907
+ logger.success(
8908
+ 'check-bins: all bin entries present, skipping force install.',
8909
+ );
8910
+ return;
8925
8911
  }
8926
8912
 
8927
- process.stdout.write(`Running ${tasks.length} task(s) in parallel...\n`);
8928
- tasks.forEach(task => {
8929
- process.stdout.write(`[${task.label}] started\n`);
8930
- });
8931
-
8932
- const results = await Promise.all(tasks.map(task => runTask(task, resolvedOptions.cwd)));
8933
- const failedResults = results.filter(result => result.code !== 0);
8934
-
8935
- results.forEach(result => {
8936
- if (result.code === 0) {
8937
- process.stdout.write(`[${result.label}] passed\n`);
8913
+ logger.warn('check-bins: missing or broken dependencies detected:');
8914
+ for (const { dep, bin, reason } of missing) {
8915
+ if (reason === 'missing-package') {
8916
+ logger.warn(` ${dep} -> (package not found in node_modules)`);
8938
8917
  } else {
8939
- process.stdout.write(`[${result.label}] failed (exit ${result.code})\n`);
8918
+ logger.warn(` ${dep} -> .bin/${bin}`);
8940
8919
  }
8941
- });
8942
-
8943
- if (failedResults.length === 0) {
8944
- process.stdout.write('Parallel tasks passed.\n');
8945
- return 0;
8946
8920
  }
8947
8921
 
8948
- process.stdout.write('\nParallel tasks failed. Failed task logs:\n');
8949
- failedResults.forEach(result => {
8950
- process.stdout.write(`\n===== ${result.label} (exit ${result.code}) =====\n`);
8951
- process.stdout.write(result.output || '(no output)\n');
8952
- if (!result.output.endsWith('\n')) {
8953
- process.stdout.write('\n');
8954
- }
8955
- process.stdout.write(`===== end ${result.label} =====\n`);
8956
- });
8922
+ if (!fix) {
8923
+ logger.error(
8924
+ 'check-bins: missing bin entries found, run with --fix to repair.',
8925
+ );
8926
+ process.exit(1);
8927
+ }
8957
8928
 
8958
- return 1;
8929
+ logger.info('check-bins: running pnpm i --force to fix...');
8930
+ d('executing: pnpm i --force');
8931
+ child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
8932
+ d('pnpm i --force completed');
8959
8933
  };
8960
8934
 
8961
- const registerCommand$2 = program => {
8935
+ const registerCommand$1 = program => {
8962
8936
  program
8963
- .command('parallel')
8964
- .description('Run package scripts or shell commands in parallel and print full logs for failed tasks')
8965
- .argument('[scripts...]', 'Package scripts to run with pnpm run')
8966
- .option('-c, --cmd <command>', 'Shell command to run in parallel', collectOption, [])
8967
- .option('--cwd <path>', 'Working directory', process.cwd())
8968
- .option('--package-manager <command>', 'Package manager command', 'pnpm')
8969
- .action(async (scripts, options) => {
8970
- const exitCode = await runParallelScripts(scripts, options);
8971
- if (exitCode !== 0) {
8972
- process.exit(exitCode);
8937
+ .command('check-bins')
8938
+ .description(
8939
+ 'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
8940
+ )
8941
+ .option('-c, --cwd <path>', 'Working directory to check', process.cwd())
8942
+ .option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
8943
+ .action(async (options) => {
8944
+ try {
8945
+ await checkBins(options.cwd, options.fix);
8946
+ } catch (err) {
8947
+ logger.warn(
8948
+ `check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
8949
+ );
8973
8950
  }
8974
8951
  });
8975
8952
  };
@@ -9849,7 +9826,7 @@ const execute = async (
9849
9826
  };
9850
9827
  };
9851
9828
 
9852
- function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
9829
+ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
9853
9830
  /**
9854
9831
  * 运行 pnpm install
9855
9832
  */
@@ -10039,7 +10016,7 @@ const executeTemplateEngineStep = async ctx => {
10039
10016
  templateName: ctx.templateName,
10040
10017
  outputPath: ctx.outputPath,
10041
10018
  command: ctx.command,
10042
- force: _nullishCoalesce$1(ctx.options.force, () => ( false)),
10019
+ force: _nullishCoalesce(ctx.options.force, () => ( false)),
10043
10020
  });
10044
10021
 
10045
10022
  // 保存结果到上下文
@@ -10298,7 +10275,7 @@ const executeInit = async (
10298
10275
  /**
10299
10276
  * 注册 init 命令到 program
10300
10277
  */
10301
- const registerCommand$1 = program => {
10278
+ const registerCommand = program => {
10302
10279
  program
10303
10280
  .command('init')
10304
10281
  .description('Initialize a new project from a template')
@@ -10316,148 +10293,21 @@ const registerCommand$1 = program => {
10316
10293
  .allowUnknownOption() // 允许透传参数
10317
10294
  .action(async (directory, options, command) => {
10318
10295
  // 位置参数优先级高于 --output 选项
10319
- const outputPath = _nullishCoalesce$1(directory, () => ( options.output));
10296
+ const outputPath = _nullishCoalesce(directory, () => ( options.output));
10320
10297
  // Always use force mode - overwrite existing files without conflict check
10321
10298
  const force = true;
10322
10299
  await executeInit({ ...options, output: outputPath, force }, command);
10323
10300
  });
10324
10301
  };
10325
10302
 
10326
- function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
10327
-
10328
-
10329
- const d = debug('coze-init-cli:check-bins');
10330
-
10331
-
10332
-
10333
-
10334
-
10335
-
10336
-
10337
- const checkBins = async (cwd, fix) => {
10338
- d('starting check, cwd=%s fix=%s', cwd, fix);
10339
-
10340
- const pkgJson = safeJsonParse
10341
-
10342
-
10343
- (await fs$1.readFile(path.join(cwd, 'package.json'), 'utf8'), {});
10344
-
10345
- const allDeps = Object.keys({
10346
- ...pkgJson.dependencies,
10347
- ...pkgJson.devDependencies,
10348
- });
10349
-
10350
- d('found %d total dependencies to scan', allDeps.length);
10351
-
10352
- const binDir = path.join(cwd, 'node_modules', '.bin');
10353
- d('bin directory: %s', binDir);
10354
- const missing = [];
10355
-
10356
- await Promise.all(
10357
- allDeps.map(async depName => {
10358
- let rawContent;
10359
- try {
10360
- rawContent = await fs$1.readFile(
10361
- path.join(cwd, 'node_modules', depName, 'package.json'),
10362
- 'utf8',
10363
- );
10364
- } catch (err) {
10365
- d('dep %s not found in node_modules: %s', depName, err);
10366
- missing.push({ dep: depName, bin: '', reason: 'missing-package' });
10367
- return;
10368
- }
10369
- const depPkg = safeJsonParse(
10370
- rawContent,
10371
- );
10372
- if (!depPkg) {
10373
- d('skipping %s: failed to parse package.json', depName);
10374
- return;
10375
- }
10376
-
10377
- if (!depPkg.bin) {
10378
- return;
10379
- }
10380
-
10381
- const bins =
10382
- typeof depPkg.bin === 'string'
10383
- ? { [_nullishCoalesce(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
10384
- : depPkg.bin;
10385
-
10386
- d('%s declares bins: %o', depName, Object.keys(bins));
10387
-
10388
- await Promise.all(
10389
- Object.keys(bins).map(async binName => {
10390
- try {
10391
- await fs$1.access(path.join(binDir, binName));
10392
- d('bin present: %s', binName);
10393
- } catch (err) {
10394
- d('bin missing: %s (from %s): %s', binName, depName, err);
10395
- missing.push({ dep: depName, bin: binName, reason: 'missing-bin' });
10396
- }
10397
- }),
10398
- );
10399
- }),
10400
- );
10401
-
10402
- d('scan complete, missing=%d', missing.length);
10403
-
10404
- if (missing.length === 0) {
10405
- logger.success(
10406
- 'check-bins: all bin entries present, skipping force install.',
10407
- );
10408
- return;
10409
- }
10410
-
10411
- logger.warn('check-bins: missing or broken dependencies detected:');
10412
- for (const { dep, bin, reason } of missing) {
10413
- if (reason === 'missing-package') {
10414
- logger.warn(` ${dep} -> (package not found in node_modules)`);
10415
- } else {
10416
- logger.warn(` ${dep} -> .bin/${bin}`);
10417
- }
10418
- }
10419
-
10420
- if (!fix) {
10421
- logger.error(
10422
- 'check-bins: missing bin entries found, run with --fix to repair.',
10423
- );
10424
- process.exit(1);
10425
- }
10426
-
10427
- logger.info('check-bins: running pnpm i --force to fix...');
10428
- d('executing: pnpm i --force');
10429
- child_process.execSync('pnpm i --force', { stdio: 'inherit', cwd });
10430
- d('pnpm i --force completed');
10431
- };
10432
-
10433
- const registerCommand = program => {
10434
- program
10435
- .command('check-bins')
10436
- .description(
10437
- 'Verify all bin entries from dependencies exist in node_modules/.bin, run pnpm i --force if any are missing',
10438
- )
10439
- .option('-c, --cwd <path>', 'Working directory to check', process.cwd())
10440
- .option('--fix', 'Run pnpm i --force to repair missing bin entries', false)
10441
- .action(async (options) => {
10442
- try {
10443
- await checkBins(options.cwd, options.fix);
10444
- } catch (err) {
10445
- logger.warn(
10446
- `check-bins: skipped due to error: ${err instanceof Error ? err.message : String(err)}`,
10447
- );
10448
- }
10449
- });
10450
- };
10451
-
10452
10303
  const commands = [
10453
- registerCommand$1,
10304
+ registerCommand,
10305
+ registerCommand$3,
10306
+ registerCommand$6,
10454
10307
  registerCommand$4,
10455
- registerCommand$7,
10456
10308
  registerCommand$5,
10457
- registerCommand$6,
10458
- registerCommand$3,
10459
- registerCommand,
10460
10309
  registerCommand$2,
10310
+ registerCommand$1,
10461
10311
  ];
10462
10312
 
10463
10313
  const main = async () => {
@@ -10487,7 +10337,12 @@ const main = async () => {
10487
10337
 
10488
10338
  const program = new commander.Command();
10489
10339
 
10490
- program.name('coze-dev').description('Coze Coding CLI - Project template engine for frontend stacks').version(packageJson.version);
10340
+ program
10341
+ .name('coze')
10342
+ .description(
10343
+ 'Coze Coding CLI - Project template engine for frontend stacks',
10344
+ )
10345
+ .version(packageJson.version);
10491
10346
 
10492
10347
  commands.forEach(initCmd => initCmd(program));
10493
10348