@coze-arch/cli 0.0.36-alpha.844e20 → 0.0.36-alpha.98d71c

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
@@ -28,6 +28,7 @@ var node_os = require('node:os');
28
28
  var promises = require('node:fs/promises');
29
29
  var node_child_process = require('node:child_process');
30
30
  var node_util = require('node:util');
31
+ var tar = require('tar');
31
32
  var node_stream = require('node:stream');
32
33
 
33
34
  /**
@@ -1634,7 +1635,7 @@ function createNodeTransport() {
1634
1635
  };
1635
1636
  }
1636
1637
 
1637
- function _nullishCoalesce$d(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; }/**
1638
+ function _nullishCoalesce$c(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; }/**
1638
1639
  * Slardar CLI Reporter 主类
1639
1640
  * 封装 @slardar/base 的初始化和上报逻辑
1640
1641
  */
@@ -1691,7 +1692,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1691
1692
  release: config.release,
1692
1693
  env: config.env,
1693
1694
  name: config.name,
1694
- useLocalConfig: _nullishCoalesce$d(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1695
+ useLocalConfig: _nullishCoalesce$c(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1695
1696
  domain: config.domain,
1696
1697
  // 设置本地采样率为 100%,确保事件不被过滤
1697
1698
  sample: {
@@ -1706,7 +1707,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1706
1707
  this.client.on('send', (ev) => {
1707
1708
  log$6(
1708
1709
  'send hook called for event: %s',
1709
- (_optionalChain$E([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1710
+ (_optionalChain$F([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1710
1711
  );
1711
1712
  });
1712
1713
 
@@ -1764,7 +1765,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1764
1765
  )
1765
1766
  : undefined;
1766
1767
 
1767
- _optionalChain$E([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1768
+ _optionalChain$F([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1768
1769
  name,
1769
1770
  metrics: cleanMetrics ,
1770
1771
  categories: cleanCategories ,
@@ -1835,7 +1836,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1835
1836
  log$6('Reporting JS error:', {
1836
1837
  name: error.name,
1837
1838
  message: error.message.slice(0, 100),
1838
- stack: _optionalChain$E([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1839
+ stack: _optionalChain$F([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1839
1840
  extra,
1840
1841
  source,
1841
1842
  });
@@ -1855,7 +1856,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1855
1856
  if (!this.ensureInitialized()) {
1856
1857
  return;
1857
1858
  }
1858
- _optionalChain$E([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1859
+ _optionalChain$F([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1859
1860
  }
1860
1861
 
1861
1862
  /**
@@ -1866,7 +1867,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1866
1867
  return;
1867
1868
  }
1868
1869
  log$6('Merging context:', context);
1869
- _optionalChain$E([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1870
+ _optionalChain$F([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1870
1871
  }
1871
1872
 
1872
1873
  /**
@@ -1876,7 +1877,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1876
1877
  if (!this.ensureInitialized()) {
1877
1878
  return;
1878
1879
  }
1879
- _optionalChain$E([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1880
+ _optionalChain$F([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1880
1881
  }
1881
1882
 
1882
1883
  /**
@@ -1886,7 +1887,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1886
1887
  if (!this.ensureInitialized()) {
1887
1888
  return;
1888
1889
  }
1889
- _optionalChain$E([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1890
+ _optionalChain$F([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1890
1891
  }
1891
1892
 
1892
1893
  /**
@@ -1923,7 +1924,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1923
1924
  return;
1924
1925
  }
1925
1926
  log$6('Flushing Slardar data...');
1926
- _optionalChain$E([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1927
+ _optionalChain$F([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1927
1928
  log$6('Waiting %dms for events to be sent...', waitMs);
1928
1929
  await new Promise(resolve => setTimeout(resolve, waitMs));
1929
1930
  log$6('Slardar data flushed');
@@ -1942,7 +1943,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1942
1943
  */
1943
1944
  const reporter = new SlardarCLIReporter();
1944
1945
 
1945
- 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; }
1946
+ 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; }
1946
1947
 
1947
1948
 
1948
1949
 
@@ -2002,11 +2003,11 @@ const EventBuilder = {
2002
2003
  name: CLI_EVENTS.CLI_COMMAND,
2003
2004
  categories: {
2004
2005
  command,
2005
- args: _optionalChain$D([options, 'optionalAccess', _ => _.args]),
2006
+ args: _optionalChain$E([options, 'optionalAccess', _ => _.args]),
2006
2007
  status: 'running' ,
2007
- ..._optionalChain$D([options, 'optionalAccess', _2 => _2.categories]),
2008
+ ..._optionalChain$E([options, 'optionalAccess', _2 => _2.categories]),
2008
2009
  },
2009
- metrics: _optionalChain$D([options, 'optionalAccess', _3 => _3.metrics]),
2010
+ metrics: _optionalChain$E([options, 'optionalAccess', _3 => _3.metrics]),
2010
2011
  };
2011
2012
  },
2012
2013
 
@@ -2027,13 +2028,13 @@ const EventBuilder = {
2027
2028
  name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
2028
2029
  categories: {
2029
2030
  command,
2030
- args: _optionalChain$D([options, 'optionalAccess', _4 => _4.args]),
2031
+ args: _optionalChain$E([options, 'optionalAccess', _4 => _4.args]),
2031
2032
  status: success ? ('success' ) : ('fail' ),
2032
- ..._optionalChain$D([options, 'optionalAccess', _5 => _5.categories]),
2033
+ ..._optionalChain$E([options, 'optionalAccess', _5 => _5.categories]),
2033
2034
  },
2034
2035
  metrics: {
2035
2036
  duration,
2036
- ...(_optionalChain$D([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2037
+ ...(_optionalChain$E([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2037
2038
  },
2038
2039
  };
2039
2040
  },
@@ -2054,12 +2055,12 @@ const EventBuilder = {
2054
2055
  name: CLI_EVENTS.NETWORK_REQUEST,
2055
2056
  categories: {
2056
2057
  url,
2057
- method: _optionalChain$D([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2058
- statusCode: _optionalChain$D([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2059
- status: _optionalChain$D([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2058
+ method: _optionalChain$E([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2059
+ statusCode: _optionalChain$E([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2060
+ status: _optionalChain$E([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2060
2061
  },
2061
2062
  metrics: {
2062
- duration: _optionalChain$D([options, 'optionalAccess', _12 => _12.duration]),
2063
+ duration: _optionalChain$E([options, 'optionalAccess', _12 => _12.duration]),
2063
2064
  },
2064
2065
  };
2065
2066
  },
@@ -2081,11 +2082,11 @@ const EventBuilder = {
2081
2082
  categories: {
2082
2083
  operation,
2083
2084
  filePath,
2084
- status: _optionalChain$D([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2085
+ status: _optionalChain$E([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2085
2086
  },
2086
2087
  metrics: {
2087
- duration: _optionalChain$D([options, 'optionalAccess', _14 => _14.duration]),
2088
- fileSize: _optionalChain$D([options, 'optionalAccess', _15 => _15.fileSize]),
2088
+ duration: _optionalChain$E([options, 'optionalAccess', _14 => _14.duration]),
2089
+ fileSize: _optionalChain$E([options, 'optionalAccess', _15 => _15.fileSize]),
2089
2090
  },
2090
2091
  };
2091
2092
  },
@@ -2113,7 +2114,7 @@ const EventBuilder = {
2113
2114
  };
2114
2115
 
2115
2116
  var name = "@coze-arch/cli";
2116
- var version = "0.0.36-alpha.844e20";
2117
+ var version = "0.0.36-alpha.98d71c";
2117
2118
  var description = "coze coding devtools cli";
2118
2119
  var license = "MIT";
2119
2120
  var author = "fanwenjie.fe@bytedance.com";
@@ -2223,7 +2224,7 @@ var packageJson = {
2223
2224
  cozePublishConfig: cozePublishConfig
2224
2225
  };
2225
2226
 
2226
- 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; }/**
2227
+ 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; }/**
2227
2228
  * Slardar 监控初始化和上报
2228
2229
  */
2229
2230
 
@@ -2326,11 +2327,11 @@ const reportCommandComplete = safeRun(
2326
2327
  ,
2327
2328
  ) => {
2328
2329
  const event = EventBuilder.cliCommandComplete(command, success, duration, {
2329
- args: _optionalChain$C([options, 'optionalAccess', _ => _.args]),
2330
- errorCode: _optionalChain$C([options, 'optionalAccess', _2 => _2.errorCode]),
2330
+ args: _optionalChain$D([options, 'optionalAccess', _ => _.args]),
2331
+ errorCode: _optionalChain$D([options, 'optionalAccess', _2 => _2.errorCode]),
2331
2332
  categories: {
2332
- ...(_optionalChain$C([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2333
- ..._optionalChain$C([options, 'optionalAccess', _4 => _4.categories]),
2333
+ ...(_optionalChain$D([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2334
+ ..._optionalChain$D([options, 'optionalAccess', _4 => _4.categories]),
2334
2335
  },
2335
2336
  });
2336
2337
  reporter.sendEvent(event.name, event.metrics, event.categories);
@@ -2389,7 +2390,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2389
2390
  await reporter.flush();
2390
2391
  });
2391
2392
 
2392
- function _nullishCoalesce$c(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }var LogLevel; (function (LogLevel) {
2393
+ function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }var LogLevel; (function (LogLevel) {
2393
2394
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2394
2395
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2395
2396
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2427,7 +2428,7 @@ class Logger {
2427
2428
 
2428
2429
  constructor(options = {}) {
2429
2430
  this.level = this.parseLogLevel(options.level);
2430
- this.useColor = _nullishCoalesce$c(options.useColor, () => ( this.isColorSupported()));
2431
+ this.useColor = _nullishCoalesce$b(options.useColor, () => ( this.isColorSupported()));
2431
2432
  this.prefix = options.prefix;
2432
2433
  }
2433
2434
 
@@ -2436,7 +2437,7 @@ class Logger {
2436
2437
  return level;
2437
2438
  }
2438
2439
 
2439
- const envLevel = _optionalChain$B([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2440
+ const envLevel = _optionalChain$C([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2440
2441
  if (envLevel && envLevel in LOG_LEVEL_MAP) {
2441
2442
  // envLevel 已通过 `in` 检查确认为 LOG_LEVEL_MAP 的键;
2442
2443
  // 显式判空以满足 noUncheckedIndexedAccess,运行时行为不变
@@ -2453,7 +2454,7 @@ class Logger {
2453
2454
  // 简单检测:Node.js 环境且支持 TTY
2454
2455
  return (
2455
2456
  typeof process !== 'undefined' &&
2456
- _optionalChain$B([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2457
+ _optionalChain$C([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2457
2458
  process.env.NO_COLOR === undefined
2458
2459
  );
2459
2460
  }
@@ -2478,7 +2479,7 @@ class Logger {
2478
2479
 
2479
2480
  const icon = this.colorize(options.icon, options.color);
2480
2481
  const prefix = this.prefix ? `${icon} ${this.prefix}` : icon;
2481
- console.log(prefix, options.message, ...(_nullishCoalesce$c(options.args, () => ( []))));
2482
+ console.log(prefix, options.message, ...(_nullishCoalesce$b(options.args, () => ( []))));
2482
2483
  }
2483
2484
 
2484
2485
  error(message, ...args) {
@@ -2846,9 +2847,9 @@ const COZE_HOME_DIR = '.coze';
2846
2847
 
2847
2848
  /**
2848
2849
  * Logs directory name
2849
- * Default: .coze-logs
2850
+ * Default: ~/.coze/logs
2850
2851
  */
2851
- const LOGS_DIR = '.coze-logs';
2852
+ const LOGS_DIR = 'logs';
2852
2853
 
2853
2854
  /**
2854
2855
  * Get the Coze home directory path
@@ -2863,10 +2864,10 @@ const getCozeHome = () =>
2863
2864
  * Get the logs directory path
2864
2865
  * Can be customized via COZE_LOG_DIR environment variable
2865
2866
  *
2866
- * @returns Absolute path to logs directory (default: ~/.coze-logs)
2867
+ * @returns Absolute path to logs directory (default: ~/.coze/logs)
2867
2868
  */
2868
2869
  const getCozeLogsDir = () =>
2869
- process.env.COZE_LOG_DIR || path.join(os.homedir(), LOGS_DIR);
2870
+ process.env.COZE_LOG_DIR || path.join(getCozeHome(), LOGS_DIR);
2870
2871
 
2871
2872
  /**
2872
2873
  * Get path for a specific file/directory within Coze home
@@ -2897,7 +2898,7 @@ const getCozeFilePath = (relativePath) =>
2897
2898
  * @example
2898
2899
  * ```ts
2899
2900
  * const devLog = getCozeLogPath('dev.log');
2900
- * // Returns: ~/.coze-logs/dev.log
2901
+ * // Returns: ~/.coze/logs/dev.log
2901
2902
  * ```
2902
2903
  */
2903
2904
  const getCozeLogPath = (filename) =>
@@ -3261,7 +3262,7 @@ const registerCommand$6 = program => {
3261
3262
  });
3262
3263
  };
3263
3264
 
3264
- 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; }// Safe JSON parsing utilities with type safety and error handling
3265
+ 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; }// Safe JSON parsing utilities with type safety and error handling
3265
3266
  // Provides fallback values, validation, and error monitoring capabilities
3266
3267
 
3267
3268
  /**
@@ -3361,12 +3362,12 @@ function safeJsonParse(
3361
3362
  const parsed = JSON.parse(String(input));
3362
3363
 
3363
3364
  // Optional validation
3364
- if (_optionalChain$A([options, 'optionalAccess', _ => _.validate])) {
3365
+ if (_optionalChain$B([options, 'optionalAccess', _ => _.validate])) {
3365
3366
  if (options.validate(parsed)) {
3366
3367
  return parsed;
3367
3368
  } else {
3368
3369
  const validationError = new Error('JSON validation failed');
3369
- _optionalChain$A([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3370
+ _optionalChain$B([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3370
3371
 
3371
3372
  if (options.throwOnValidationError) {
3372
3373
  throw validationError;
@@ -3378,10 +3379,10 @@ function safeJsonParse(
3378
3379
  return parsed;
3379
3380
  } catch (error) {
3380
3381
  // Re-throw validation errors when throwOnValidationError is true
3381
- if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$A([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3382
+ if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$B([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3382
3383
  throw error;
3383
3384
  }
3384
- _optionalChain$A([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3385
+ _optionalChain$B([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3385
3386
  return defaultValue;
3386
3387
  }
3387
3388
  }
@@ -3421,7 +3422,7 @@ function isNode(node) {
3421
3422
  }
3422
3423
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3423
3424
 
3424
- function _optionalChain$z(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; }
3425
+ 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; }
3425
3426
  const BREAK = Symbol('break visit');
3426
3427
  const SKIP = Symbol('skip children');
3427
3428
  const REMOVE = Symbol('remove node');
@@ -3534,15 +3535,15 @@ function callVisitor(key, node, visitor, path) {
3534
3535
  if (typeof visitor === 'function')
3535
3536
  return visitor(key, node, path);
3536
3537
  if (isMap(node))
3537
- return _optionalChain$z([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3538
+ return _optionalChain$A([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3538
3539
  if (isSeq(node))
3539
- return _optionalChain$z([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3540
+ return _optionalChain$A([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3540
3541
  if (isPair(node))
3541
- return _optionalChain$z([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3542
+ return _optionalChain$A([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3542
3543
  if (isScalar(node))
3543
- return _optionalChain$z([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3544
+ return _optionalChain$A([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3544
3545
  if (isAlias(node))
3545
- return _optionalChain$z([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3546
+ return _optionalChain$A([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3546
3547
  return undefined;
3547
3548
  }
3548
3549
  function replaceNode(key, path, node) {
@@ -3633,7 +3634,7 @@ function applyReviver(reviver, obj, key, val) {
3633
3634
  return reviver.call(obj, key, val);
3634
3635
  }
3635
3636
 
3636
- function _optionalChain$y(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; }
3637
+ function _optionalChain$z(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; }
3637
3638
  /**
3638
3639
  * Recursively convert any node or its contents to native JavaScript
3639
3640
  *
@@ -3663,7 +3664,7 @@ function toJS(value, arg, ctx) {
3663
3664
  ctx.onCreate(res);
3664
3665
  return res;
3665
3666
  }
3666
- if (typeof value === 'bigint' && !_optionalChain$y([ctx, 'optionalAccess', _ => _.keep]))
3667
+ if (typeof value === 'bigint' && !_optionalChain$z([ctx, 'optionalAccess', _ => _.keep]))
3667
3668
  return Number(value);
3668
3669
  return value;
3669
3670
  }
@@ -3701,7 +3702,7 @@ class NodeBase {
3701
3702
  }
3702
3703
  }
3703
3704
 
3704
- function _optionalChain$x(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; }
3705
+ function _optionalChain$y(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; }
3705
3706
  class Alias extends NodeBase {
3706
3707
  constructor(source) {
3707
3708
  super(ALIAS);
@@ -3717,10 +3718,10 @@ class Alias extends NodeBase {
3717
3718
  * instance of the `source` anchor before this node.
3718
3719
  */
3719
3720
  resolve(doc, ctx) {
3720
- if (_optionalChain$x([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3721
+ if (_optionalChain$y([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3721
3722
  throw new ReferenceError('Alias resolution is disabled');
3722
3723
  let nodes;
3723
- if (_optionalChain$x([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3724
+ if (_optionalChain$y([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3724
3725
  nodes = ctx.aliasResolveCache;
3725
3726
  }
3726
3727
  else {
@@ -3759,7 +3760,7 @@ class Alias extends NodeBase {
3759
3760
  data = anchors.get(source);
3760
3761
  }
3761
3762
  /* istanbul ignore if */
3762
- if (_optionalChain$x([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3763
+ if (_optionalChain$y([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3763
3764
  const msg = 'This should not happen: Alias anchor was not resolved?';
3764
3765
  throw new ReferenceError(msg);
3765
3766
  }
@@ -3811,7 +3812,7 @@ function getAliasCount(doc, node, anchors) {
3811
3812
  return 1;
3812
3813
  }
3813
3814
 
3814
- function _optionalChain$w(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; }
3815
+ function _optionalChain$x(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; }
3815
3816
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3816
3817
  class Scalar extends NodeBase {
3817
3818
  constructor(value) {
@@ -3819,7 +3820,7 @@ class Scalar extends NodeBase {
3819
3820
  this.value = value;
3820
3821
  }
3821
3822
  toJSON(arg, ctx) {
3822
- return _optionalChain$w([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3823
+ return _optionalChain$x([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3823
3824
  }
3824
3825
  toString() {
3825
3826
  return String(this.value);
@@ -3831,17 +3832,17 @@ Scalar.PLAIN = 'PLAIN';
3831
3832
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3832
3833
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3833
3834
 
3834
- function _nullishCoalesce$b(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$v(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; }
3835
+ function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$w(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; }
3835
3836
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3836
3837
  function findTagObject(value, tagName, tags) {
3837
3838
  if (tagName) {
3838
3839
  const match = tags.filter(t => t.tag === tagName);
3839
- const tagObj = _nullishCoalesce$b(match.find(t => !t.format), () => ( match[0]));
3840
+ const tagObj = _nullishCoalesce$a(match.find(t => !t.format), () => ( match[0]));
3840
3841
  if (!tagObj)
3841
3842
  throw new Error(`Tag ${tagName} not found`);
3842
3843
  return tagObj;
3843
3844
  }
3844
- return tags.find(t => _optionalChain$v([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3845
+ return tags.find(t => _optionalChain$w([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3845
3846
  }
3846
3847
  function createNode(value, tagName, ctx) {
3847
3848
  if (isDocument(value))
@@ -3849,7 +3850,7 @@ function createNode(value, tagName, ctx) {
3849
3850
  if (isNode(value))
3850
3851
  return value;
3851
3852
  if (isPair(value)) {
3852
- const map = _optionalChain$v([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3853
+ const map = _optionalChain$w([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3853
3854
  map.items.push(value);
3854
3855
  return map;
3855
3856
  }
@@ -3868,7 +3869,7 @@ function createNode(value, tagName, ctx) {
3868
3869
  if (aliasDuplicateObjects && value && typeof value === 'object') {
3869
3870
  ref = sourceObjects.get(value);
3870
3871
  if (ref) {
3871
- _nullishCoalesce$b(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3872
+ _nullishCoalesce$a(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3872
3873
  return new Alias(ref.anchor);
3873
3874
  }
3874
3875
  else {
@@ -3876,7 +3877,7 @@ function createNode(value, tagName, ctx) {
3876
3877
  sourceObjects.set(value, ref);
3877
3878
  }
3878
3879
  }
3879
- if (_optionalChain$v([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3880
+ if (_optionalChain$w([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3880
3881
  tagName = defaultTagPrefix + tagName.slice(2);
3881
3882
  let tagObj = findTagObject(value, tagName, schema.tags);
3882
3883
  if (!tagObj) {
@@ -3901,9 +3902,9 @@ function createNode(value, tagName, ctx) {
3901
3902
  onTagObj(tagObj);
3902
3903
  delete ctx.onTagObj;
3903
3904
  }
3904
- const node = _optionalChain$v([tagObj, 'optionalAccess', _9 => _9.createNode])
3905
+ const node = _optionalChain$w([tagObj, 'optionalAccess', _9 => _9.createNode])
3905
3906
  ? tagObj.createNode(ctx.schema, value, ctx)
3906
- : typeof _optionalChain$v([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3907
+ : typeof _optionalChain$w([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3907
3908
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
3908
3909
  : new Scalar(value);
3909
3910
  if (tagName)
@@ -4221,7 +4222,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4221
4222
  return end;
4222
4223
  }
4223
4224
 
4224
- 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; }
4225
+ function _optionalChain$v(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; }
4225
4226
  const getFoldOptions = (ctx, isBlock) => ({
4226
4227
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4227
4228
  lineWidth: ctx.options.lineWidth,
@@ -4506,9 +4507,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4506
4507
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4507
4508
  // and others in v1.1.
4508
4509
  if (actualString) {
4509
- const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$u([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4510
+ const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$v([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4510
4511
  const { compat, tags } = ctx.doc.schema;
4511
- if (tags.some(test) || _optionalChain$u([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4512
+ if (tags.some(test) || _optionalChain$v([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4512
4513
  return quotedString(value, ctx);
4513
4514
  }
4514
4515
  return implicitKey
@@ -4554,7 +4555,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4554
4555
  return res;
4555
4556
  }
4556
4557
 
4557
- 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; }
4558
+ function _nullishCoalesce$9(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; }
4558
4559
  function createStringifyContext(doc, options) {
4559
4560
  const opt = Object.assign({
4560
4561
  blockQuote: true,
@@ -4601,27 +4602,27 @@ function getTagObject(tags, item) {
4601
4602
  if (item.tag) {
4602
4603
  const match = tags.filter(t => t.tag === item.tag);
4603
4604
  if (match.length > 0)
4604
- return _nullishCoalesce$a(match.find(t => t.format === item.format), () => ( match[0]));
4605
+ return _nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match[0]));
4605
4606
  }
4606
4607
  let tagObj = undefined;
4607
4608
  let obj;
4608
4609
  if (isScalar(item)) {
4609
4610
  obj = item.value;
4610
- let match = tags.filter(t => _optionalChain$t([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4611
+ let match = tags.filter(t => _optionalChain$u([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4611
4612
  if (match.length > 1) {
4612
4613
  const testMatch = match.filter(t => t.test);
4613
4614
  if (testMatch.length > 0)
4614
4615
  match = testMatch;
4615
4616
  }
4616
4617
  tagObj =
4617
- _nullishCoalesce$a(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4618
+ _nullishCoalesce$9(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4618
4619
  }
4619
4620
  else {
4620
4621
  obj = item;
4621
4622
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4622
4623
  }
4623
4624
  if (!tagObj) {
4624
- const name = _nullishCoalesce$a(_optionalChain$t([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4625
+ const name = _nullishCoalesce$9(_optionalChain$u([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4625
4626
  throw new Error(`Tag not resolved for ${name} value`);
4626
4627
  }
4627
4628
  return tagObj;
@@ -4636,7 +4637,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
4636
4637
  anchors.add(anchor);
4637
4638
  props.push(`&${anchor}`);
4638
4639
  }
4639
- const tag = _nullishCoalesce$a(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4640
+ const tag = _nullishCoalesce$9(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4640
4641
  if (tag)
4641
4642
  props.push(doc.directives.tagString(tag));
4642
4643
  return props.join(' ');
@@ -4647,7 +4648,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4647
4648
  if (isAlias(item)) {
4648
4649
  if (ctx.doc.directives)
4649
4650
  return item.toString(ctx);
4650
- if (_optionalChain$t([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4651
+ if (_optionalChain$u([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4651
4652
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4652
4653
  }
4653
4654
  else {
@@ -4662,10 +4663,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
4662
4663
  const node = isNode(item)
4663
4664
  ? item
4664
4665
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
4665
- _nullishCoalesce$a(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4666
+ _nullishCoalesce$9(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4666
4667
  const props = stringifyProps(node, tagObj, ctx);
4667
4668
  if (props.length > 0)
4668
- ctx.indentAtStart = (_nullishCoalesce$a(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4669
+ ctx.indentAtStart = (_nullishCoalesce$9(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4669
4670
  const str = typeof tagObj.stringify === 'function'
4670
4671
  ? tagObj.stringify(node, ctx, onComment, onChompKeep)
4671
4672
  : isScalar(node)
@@ -4678,7 +4679,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4678
4679
  : `${props}\n${ctx.indent}${str}`;
4679
4680
  }
4680
4681
 
4681
- function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4682
+ function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4682
4683
  function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4683
4684
  const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
4684
4685
  let keyComment = (isNode(key) && key.comment) || null;
@@ -4788,7 +4789,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4788
4789
  const vs0 = valueStr[0];
4789
4790
  const nl0 = valueStr.indexOf('\n');
4790
4791
  const hasNewline = nl0 !== -1;
4791
- const flow = _nullishCoalesce$9(_nullishCoalesce$9(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4792
+ const flow = _nullishCoalesce$8(_nullishCoalesce$8(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4792
4793
  if (hasNewline || !flow) {
4793
4794
  let hasPropsLine = false;
4794
4795
  if (hasNewline && (vs0 === '&' || vs0 === '!')) {
@@ -4829,7 +4830,7 @@ function warn(logLevel, warning) {
4829
4830
  }
4830
4831
  }
4831
4832
 
4832
- 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; }
4833
+ 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; }
4833
4834
  // If the value associated with a merge key is a single mapping node, each of
4834
4835
  // its key/value pairs is inserted into the current mapping, unless the key
4835
4836
  // already exists in it. If the value associated with the merge key is a
@@ -4853,7 +4854,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4853
4854
  (isScalar(key) &&
4854
4855
  (!key.type || key.type === Scalar.PLAIN) &&
4855
4856
  merge.identify(key.value))) &&
4856
- _optionalChain$s([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)]);
4857
+ _optionalChain$t([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)]);
4857
4858
  function addMergeToJSMap(ctx, map, value) {
4858
4859
  const source = resolveAliasValue(ctx, value);
4859
4860
  if (isSeq(source))
@@ -4893,7 +4894,7 @@ function resolveAliasValue(ctx, value) {
4893
4894
  return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
4894
4895
  }
4895
4896
 
4896
- 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; }
4897
+ 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; }
4897
4898
  function addPairToJSMap(ctx, map, { key, value }) {
4898
4899
  if (isNode(key) && key.addToJSMap)
4899
4900
  key.addToJSMap(ctx, map, value);
@@ -4930,7 +4931,7 @@ function stringifyKey(key, jsKey, ctx) {
4930
4931
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
4931
4932
  if (typeof jsKey !== 'object')
4932
4933
  return String(jsKey);
4933
- if (isNode(key) && _optionalChain$r([ctx, 'optionalAccess', _ => _.doc])) {
4934
+ if (isNode(key) && _optionalChain$s([ctx, 'optionalAccess', _ => _.doc])) {
4934
4935
  const strCtx = createStringifyContext(ctx.doc, {});
4935
4936
  strCtx.anchors = new Set();
4936
4937
  for (const node of ctx.anchors.keys())
@@ -4950,7 +4951,7 @@ function stringifyKey(key, jsKey, ctx) {
4950
4951
  return JSON.stringify(jsKey);
4951
4952
  }
4952
4953
 
4953
- 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; }
4954
+ 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; }
4954
4955
  function createPair(key, value, ctx) {
4955
4956
  const k = createNode(key, undefined, ctx);
4956
4957
  const v = createNode(value, undefined, ctx);
@@ -4971,19 +4972,19 @@ class Pair {
4971
4972
  return new Pair(key, value);
4972
4973
  }
4973
4974
  toJSON(_, ctx) {
4974
- const pair = _optionalChain$q([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4975
+ const pair = _optionalChain$r([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4975
4976
  return addPairToJSMap(ctx, pair, this);
4976
4977
  }
4977
4978
  toString(ctx, onComment, onChompKeep) {
4978
- return _optionalChain$q([ctx, 'optionalAccess', _3 => _3.doc])
4979
+ return _optionalChain$r([ctx, 'optionalAccess', _3 => _3.doc])
4979
4980
  ? stringifyPair(this, ctx, onComment, onChompKeep)
4980
4981
  : JSON.stringify(this);
4981
4982
  }
4982
4983
  }
4983
4984
 
4984
- function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
4985
+ function _nullishCoalesce$7(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; }
4985
4986
  function stringifyCollection(collection, ctx, options) {
4986
- const flow = _nullishCoalesce$8(ctx.inFlow, () => ( collection.flow));
4987
+ const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
4987
4988
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
4988
4989
  return stringify(collection, ctx, options);
4989
4990
  }
@@ -5075,7 +5076,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5075
5076
  if (iv.commentBefore)
5076
5077
  reqNewline = true;
5077
5078
  }
5078
- else if (item.value == null && _optionalChain$p([ik, 'optionalAccess', _ => _.comment])) {
5079
+ else if (item.value == null && _optionalChain$q([ik, 'optionalAccess', _ => _.comment])) {
5079
5080
  comment = ik.comment;
5080
5081
  }
5081
5082
  }
@@ -5130,7 +5131,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5130
5131
  }
5131
5132
  }
5132
5133
 
5133
- function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
5134
+ function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
5134
5135
  function findPair(items, key) {
5135
5136
  const k = isScalar(key) ? key.value : key;
5136
5137
  for (const it of items) {
@@ -5191,12 +5192,12 @@ class YAMLMap extends Collection {
5191
5192
  _pair = pair;
5192
5193
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5193
5194
  // In TypeScript, this never happens.
5194
- _pair = new Pair(pair, _optionalChain$o([pair, 'optionalAccess', _2 => _2.value]));
5195
+ _pair = new Pair(pair, _optionalChain$p([pair, 'optionalAccess', _2 => _2.value]));
5195
5196
  }
5196
5197
  else
5197
5198
  _pair = new Pair(pair.key, pair.value);
5198
5199
  const prev = findPair(this.items, _pair.key);
5199
- const sortEntries = _optionalChain$o([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5200
+ const sortEntries = _optionalChain$p([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5200
5201
  if (prev) {
5201
5202
  if (!overwrite)
5202
5203
  throw new Error(`Key ${_pair.key} already set`);
@@ -5226,8 +5227,8 @@ class YAMLMap extends Collection {
5226
5227
  }
5227
5228
  get(key, keepScalar) {
5228
5229
  const it = findPair(this.items, key);
5229
- const node = _optionalChain$o([it, 'optionalAccess', _5 => _5.value]);
5230
- return _nullishCoalesce$7((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5230
+ const node = _optionalChain$p([it, 'optionalAccess', _5 => _5.value]);
5231
+ return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5231
5232
  }
5232
5233
  has(key) {
5233
5234
  return !!findPair(this.items, key);
@@ -5241,8 +5242,8 @@ class YAMLMap extends Collection {
5241
5242
  * @returns Instance of Type, Map, or Object
5242
5243
  */
5243
5244
  toJSON(_, ctx, Type) {
5244
- const map = Type ? new Type() : _optionalChain$o([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5245
- if (_optionalChain$o([ctx, 'optionalAccess', _7 => _7.onCreate]))
5245
+ const map = Type ? new Type() : _optionalChain$p([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5246
+ if (_optionalChain$p([ctx, 'optionalAccess', _7 => _7.onCreate]))
5246
5247
  ctx.onCreate(map);
5247
5248
  for (const item of this.items)
5248
5249
  addPairToJSMap(ctx, map, item);
@@ -5267,7 +5268,7 @@ class YAMLMap extends Collection {
5267
5268
  }
5268
5269
  }
5269
5270
 
5270
- 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; }
5271
+ 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; }
5271
5272
  class YAMLSeq extends Collection {
5272
5273
  static get tagName() {
5273
5274
  return 'tag:yaml.org,2002:seq';
@@ -5330,7 +5331,7 @@ class YAMLSeq extends Collection {
5330
5331
  }
5331
5332
  toJSON(_, ctx) {
5332
5333
  const seq = [];
5333
- if (_optionalChain$n([ctx, 'optionalAccess', _2 => _2.onCreate]))
5334
+ if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.onCreate]))
5334
5335
  ctx.onCreate(seq);
5335
5336
  let i = 0;
5336
5337
  for (const item of this.items)
@@ -5409,7 +5410,7 @@ function createPairs(schema, iterable, ctx) {
5409
5410
  return pairs;
5410
5411
  }
5411
5412
 
5412
- 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; }
5413
+ 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; }
5413
5414
  class YAMLOMap extends YAMLSeq {
5414
5415
  constructor() {
5415
5416
  super();
@@ -5428,7 +5429,7 @@ class YAMLOMap extends YAMLSeq {
5428
5429
  if (!ctx)
5429
5430
  return super.toJSON(_);
5430
5431
  const map = new Map();
5431
- if (_optionalChain$m([ctx, 'optionalAccess', _2 => _2.onCreate]))
5432
+ if (_optionalChain$n([ctx, 'optionalAccess', _2 => _2.onCreate]))
5432
5433
  ctx.onCreate(map);
5433
5434
  for (const pair of this.items) {
5434
5435
  let key, value;
@@ -5546,7 +5547,7 @@ const isDirExists = async (file) => {
5546
5547
  }
5547
5548
  };
5548
5549
 
5549
- 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; }// ABOUTME: Project type detection utility
5550
+ 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; }// ABOUTME: Project type detection utility
5550
5551
 
5551
5552
  /**
5552
5553
  * 支持的项目类型枚举
@@ -5648,7 +5649,7 @@ const collectProjectInfo = async (
5648
5649
  }
5649
5650
 
5650
5651
  const scripts = Object.entries(
5651
- (_optionalChain$l([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5652
+ (_optionalChain$m([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5652
5653
  ).reduce((acc, [name, script]) => {
5653
5654
  if (typeof script === 'string') {
5654
5655
  acc[name] = script;
@@ -5802,7 +5803,7 @@ const detectProjectType = async (
5802
5803
  };
5803
5804
  };
5804
5805
 
5805
- 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; }
5806
+ 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; }
5806
5807
 
5807
5808
 
5808
5809
  /**
@@ -5976,16 +5977,16 @@ const getCommandConfig = (
5976
5977
 
5977
5978
  switch (commandName) {
5978
5979
  case 'dev':
5979
- commandConfig = _optionalChain$k([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5980
+ commandConfig = _optionalChain$l([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5980
5981
  break;
5981
5982
  case 'build':
5982
- commandConfig = _optionalChain$k([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5983
+ commandConfig = _optionalChain$l([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5983
5984
  break;
5984
5985
  case 'start':
5985
- commandConfig = _optionalChain$k([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5986
+ commandConfig = _optionalChain$l([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5986
5987
  break;
5987
5988
  case 'validate':
5988
- commandConfig = _optionalChain$k([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5989
+ commandConfig = _optionalChain$l([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5989
5990
  break;
5990
5991
  default:
5991
5992
  throw new Error(`Unknown command: ${commandName}`);
@@ -6136,7 +6137,7 @@ const byFlag = (flag) => {
6136
6137
  return predicate;
6137
6138
  };
6138
6139
 
6139
- 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; }
6140
+ 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; }
6140
6141
 
6141
6142
 
6142
6143
 
@@ -6167,7 +6168,7 @@ echo "Validate passed!"
6167
6168
  * @returns
6168
6169
  */
6169
6170
  const isCozeValid$3 = (cozeConfig) => {
6170
- if (_optionalChain$j([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6171
+ if (_optionalChain$k([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6171
6172
  logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
6172
6173
  return false;
6173
6174
  }
@@ -6312,7 +6313,7 @@ const patchExpoValidate = {
6312
6313
  },
6313
6314
  };
6314
6315
 
6315
- 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; }
6316
+ 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; }
6316
6317
 
6317
6318
 
6318
6319
 
@@ -6345,7 +6346,7 @@ echo "Validate passed!"
6345
6346
  * @returns
6346
6347
  */
6347
6348
  const isCozeValid$2 = (cozeConfig) => {
6348
- if (_optionalChain$i([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6349
+ if (_optionalChain$j([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6349
6350
  logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
6350
6351
  return false;
6351
6352
  }
@@ -6493,7 +6494,7 @@ const patchNextjsValidate = {
6493
6494
  },
6494
6495
  };
6495
6496
 
6496
- 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; }
6497
+ 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; }
6497
6498
 
6498
6499
  const PATCH_ID$5 = 'nextjs/validate-concurrently@0.0.30';
6499
6500
  const PACKAGE_JSON_FILE$3 = 'package.json';
@@ -6526,7 +6527,7 @@ const readPackageJson = async (projectFolder) => {
6526
6527
  };
6527
6528
 
6528
6529
  const getTargetValidateScript = (packageJson) => {
6529
- const validateScript = _optionalChain$h([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
6530
+ const validateScript = _optionalChain$i([packageJson, 'access', _ => _.scripts, 'optionalAccess', _2 => _2.validate]);
6530
6531
  if (typeof validateScript !== 'string') {
6531
6532
  return null;
6532
6533
  }
@@ -6543,7 +6544,7 @@ const getTargetValidateScript = (packageJson) => {
6543
6544
 
6544
6545
  const canStackAfterNextjsValidatePatch = async (context, packageJson) => {
6545
6546
  const scripts = packageJson.scripts || {};
6546
- if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$h([context, 'access', _3 => _3.cozeConfig, 'access', _4 => _4.dev, 'optionalAccess', _5 => _5.validate])) {
6547
+ if (typeof scripts.validate !== 'undefined' || typeof scripts['ts-check'] !== 'string' || _optionalChain$i([context, 'access', _3 => _3.cozeConfig, 'access', _4 => _4.dev, 'optionalAccess', _5 => _5.validate])) {
6547
6548
  return false;
6548
6549
  }
6549
6550
 
@@ -6612,7 +6613,7 @@ const patchNextjsValidateConcurrently = {
6612
6613
  apply: patchPackageJson$2,
6613
6614
  };
6614
6615
 
6615
- 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; }
6616
+ 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; }
6616
6617
 
6617
6618
 
6618
6619
 
@@ -6645,7 +6646,7 @@ echo "Validate passed!"
6645
6646
  * @returns
6646
6647
  */
6647
6648
  const isCozeValid$1 = (cozeConfig) => {
6648
- if (_optionalChain$g([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6649
+ if (_optionalChain$h([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6649
6650
  logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
6650
6651
  return false;
6651
6652
  }
@@ -6790,7 +6791,7 @@ const patchViteValidate = {
6790
6791
  },
6791
6792
  };
6792
6793
 
6793
- 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; }
6794
+ 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; }
6794
6795
 
6795
6796
 
6796
6797
 
@@ -6827,7 +6828,7 @@ echo "Validate passed!"
6827
6828
  * @returns
6828
6829
  */
6829
6830
  const isCozeValid = (cozeConfig) => {
6830
- if (_optionalChain$f([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6831
+ if (_optionalChain$g([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6831
6832
  logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
6832
6833
  return false;
6833
6834
  }
@@ -6976,7 +6977,7 @@ const patchTaroValidate = {
6976
6977
  },
6977
6978
  };
6978
6979
 
6979
- 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; }
6980
+ 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; }
6980
6981
  const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
6981
6982
  const PACKAGE_JSON_FILE = 'package.json';
6982
6983
  const PACK_SCRIPT_FILE = '.cozeproj/scripts/pack.sh';
@@ -7055,12 +7056,12 @@ const readPackageScripts = async (
7055
7056
  const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
7056
7057
  const packageJson = safeJsonParse(packageJsonContent, null);
7057
7058
 
7058
- return _optionalChain$e([packageJson, 'optionalAccess', _ => _.scripts]) || null;
7059
+ return _optionalChain$f([packageJson, 'optionalAccess', _ => _.scripts]) || null;
7059
7060
  };
7060
7061
 
7061
7062
  const hasBuildTtScript = async (projectFolder) => {
7062
7063
  const scripts = await readPackageScripts(projectFolder);
7063
- return typeof _optionalChain$e([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
7064
+ return typeof _optionalChain$f([scripts, 'optionalAccess', _2 => _2['build:tt']]) === 'string';
7064
7065
  };
7065
7066
 
7066
7067
  const hasLegacyPackScript = async (projectFolder) => {
@@ -7414,7 +7415,7 @@ const getTemplatePatches = (
7414
7415
  ) =>
7415
7416
  patches.filter(patch => patch.template === template);
7416
7417
 
7417
- function _nullishCoalesce$6(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; }
7418
+ 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; }
7418
7419
  const DEFAULT_LEGACY_VERSION = 'legacy';
7419
7420
 
7420
7421
  const loadFlagsWithFallback = async () => {
@@ -7520,7 +7521,7 @@ const getNextPatchState = (
7520
7521
 
7521
7522
  ) => ({
7522
7523
  template,
7523
- version: _optionalChain$d([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
7524
+ version: _optionalChain$e([config, 'access', _ => _.project, 'optionalAccess', _2 => _2.version]) || DEFAULT_LEGACY_VERSION,
7524
7525
  appliedPatches: [...appliedPatches, patchId],
7525
7526
  });
7526
7527
 
@@ -7544,15 +7545,15 @@ const executePatch = async (
7544
7545
  }
7545
7546
 
7546
7547
  const template =
7547
- _optionalChain$d([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
7548
+ _optionalChain$e([config, 'access', _3 => _3.project, 'optionalAccess', _4 => _4.template]) || (await detectTemplateKey(projectFolder));
7548
7549
 
7549
7550
  if (!template) {
7550
7551
  logger.info('Patch skipped: template not detected');
7551
7552
  return;
7552
7553
  }
7553
7554
 
7554
- const appliedPatches = [...(_optionalChain$d([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
7555
- const projectVersion = _optionalChain$d([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
7555
+ const appliedPatches = [...(_optionalChain$e([config, 'access', _5 => _5.project, 'optionalAccess', _6 => _6.appliedPatches]) || [])];
7556
+ const projectVersion = _optionalChain$e([config, 'access', _7 => _7.project, 'optionalAccess', _8 => _8.version]);
7556
7557
  const flags = await loadFlagsWithFallback();
7557
7558
 
7558
7559
  const context = {
@@ -7597,7 +7598,7 @@ const executePatch = async (
7597
7598
 
7598
7599
  if (options.dryRun) {
7599
7600
  logger.info(`Detected template: ${template}`);
7600
- logger.info(`Current version: ${_nullishCoalesce$6(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7601
+ logger.info(`Current version: ${_nullishCoalesce$5(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7601
7602
  logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
7602
7603
  logger.info('Matched patches:');
7603
7604
  matchedPatches.forEach(patch => {
@@ -7655,14 +7656,14 @@ const registerCommand$5 = program => {
7655
7656
  ) => {
7656
7657
  await executePatch({
7657
7658
  directory,
7658
- dryRun: _optionalChain$d([command, 'optionalAccess', _9 => _9.dryRun]),
7659
- showFlags: _optionalChain$d([command, 'optionalAccess', _10 => _10.showFlags]),
7659
+ dryRun: _optionalChain$e([command, 'optionalAccess', _9 => _9.dryRun]),
7660
+ showFlags: _optionalChain$e([command, 'optionalAccess', _10 => _10.showFlags]),
7660
7661
  });
7661
7662
  },
7662
7663
  );
7663
7664
  };
7664
7665
 
7665
- function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
7666
+ 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; }
7666
7667
  const d$1 = debug('coze-init-cli:run');
7667
7668
 
7668
7669
  /**
@@ -7793,12 +7794,12 @@ const executeRun = async (commandName, options = {}) => {
7793
7794
  }
7794
7795
 
7795
7796
  // 将输出同时写入控制台和日志文件
7796
- _optionalChain$c([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
7797
+ _optionalChain$d([childProcess, 'access', _ => _.stdout, 'optionalAccess', _2 => _2.on, 'call', _3 => _3('data', (data) => {
7797
7798
  process.stdout.write(data);
7798
7799
  logStream.write(data);
7799
7800
  })]);
7800
7801
 
7801
- _optionalChain$c([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
7802
+ _optionalChain$d([childProcess, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.on, 'call', _6 => _6('data', (data) => {
7802
7803
  process.stderr.write(data);
7803
7804
  logStream.write(data);
7804
7805
  })]);
@@ -7811,7 +7812,7 @@ const executeRun = async (commandName, options = {}) => {
7811
7812
  const buildDuration = Date.now() - buildStartTime;
7812
7813
 
7813
7814
  if (code !== 0) {
7814
- const errorMessage = `Command exited with code ${_nullishCoalesce$5(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7815
+ const errorMessage = `Command exited with code ${_nullishCoalesce$4(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7815
7816
  logger.error(errorMessage);
7816
7817
  logger.error(`Check log file for details: ${logFilePath}`);
7817
7818
 
@@ -7823,12 +7824,12 @@ const executeRun = async (commandName, options = {}) => {
7823
7824
  categories: {
7824
7825
  fixDuration: String(fixDuration),
7825
7826
  buildDuration: String(buildDuration),
7826
- exitCode: String(_nullishCoalesce$5(code, () => ( 'unknown'))),
7827
+ exitCode: String(_nullishCoalesce$4(code, () => ( 'unknown'))),
7827
7828
  projectType,
7828
7829
  },
7829
7830
  errorContext: {
7830
- exitCode: String(_nullishCoalesce$5(code, () => ( 'unknown'))),
7831
- signal: _nullishCoalesce$5(signal, () => ( 'none')),
7831
+ exitCode: String(_nullishCoalesce$4(code, () => ( 'unknown'))),
7832
+ signal: _nullishCoalesce$4(signal, () => ( 'none')),
7832
7833
  logFile: logFilePath,
7833
7834
  projectType,
7834
7835
  },
@@ -8742,7 +8743,7 @@ const scanRoutesOnce = async (
8742
8743
  }
8743
8744
  };
8744
8745
 
8745
- 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; }// Route manifest generation command
8746
+ 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; }// Route manifest generation command
8746
8747
 
8747
8748
 
8748
8749
  const log = debug('coze:routes');
@@ -8843,11 +8844,11 @@ const registerCommand$3 = program => {
8843
8844
  'Output file path (defaults to ~/.coze/routes.json)',
8844
8845
  )
8845
8846
  .action(async (directory, options) => {
8846
- await executeRoutes({ directory, output: _optionalChain$b([options, 'optionalAccess', _ => _.output]) });
8847
+ await executeRoutes({ directory, output: _optionalChain$c([options, 'optionalAccess', _ => _.output]) });
8847
8848
  });
8848
8849
  };
8849
8850
 
8850
- function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
8851
+ function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
8851
8852
 
8852
8853
 
8853
8854
  const d = debug('coze-init-cli:check-bins');
@@ -8904,7 +8905,7 @@ const checkBins = async (cwd, fix) => {
8904
8905
 
8905
8906
  const bins =
8906
8907
  typeof depPkg.bin === 'string'
8907
- ? { [_nullishCoalesce$4(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
8908
+ ? { [_nullishCoalesce$3(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
8908
8909
  : depPkg.bin;
8909
8910
 
8910
8911
  d('%s declares bins: %o', depName, Object.keys(bins));
@@ -9848,7 +9849,7 @@ const execute = async (
9848
9849
  };
9849
9850
  };
9850
9851
 
9851
- function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
9852
+ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
9852
9853
  /**
9853
9854
  * 运行 pnpm install
9854
9855
  */
@@ -9969,8 +9970,8 @@ const runDev = (projectPath) => {
9969
9970
  // 获取当前 CLI 的可执行文件路径
9970
9971
  // process.argv[0] 是 node,process.argv[1] 是 CLI 入口文件
9971
9972
  // 二者在 CLI 运行时必然存在,兜底空串仅为满足类型收窄,运行时不会命中
9972
- const nodeBin = _nullishCoalesce$3(process.argv[0], () => ( ''));
9973
- const cliPath = _nullishCoalesce$3(process.argv[1], () => ( ''));
9973
+ const nodeBin = _nullishCoalesce$2(process.argv[0], () => ( ''));
9974
+ const cliPath = _nullishCoalesce$2(process.argv[1], () => ( ''));
9974
9975
 
9975
9976
  try {
9976
9977
  // 使用通用的后台执行函数启动开发服务器
@@ -10040,7 +10041,7 @@ const executeTemplateEngineStep = async ctx => {
10040
10041
  templateName: ctx.templateName,
10041
10042
  outputPath: ctx.outputPath,
10042
10043
  command: ctx.command,
10043
- force: _nullishCoalesce$3(ctx.options.force, () => ( false)),
10044
+ force: _nullishCoalesce$2(ctx.options.force, () => ( false)),
10044
10045
  });
10045
10046
 
10046
10047
  // 保存结果到上下文
@@ -10317,7 +10318,7 @@ const registerCommand$1 = program => {
10317
10318
  .allowUnknownOption() // 允许透传参数
10318
10319
  .action(async (directory, options, command) => {
10319
10320
  // 位置参数优先级高于 --output 选项
10320
- const outputPath = _nullishCoalesce$3(directory, () => ( options.output));
10321
+ const outputPath = _nullishCoalesce$2(directory, () => ( options.output));
10321
10322
  // Always use force mode - overwrite existing files without conflict check
10322
10323
  const force = true;
10323
10324
  await executeInit({ ...options, output: outputPath, force }, command);
@@ -10434,7 +10435,7 @@ const withRequestedApplicationType = (
10434
10435
  };
10435
10436
  };
10436
10437
 
10437
- 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; }
10438
+ 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; }
10438
10439
 
10439
10440
  const DEFAULT_CONFIG = {
10440
10441
  apiBaseUrl: 'https://code.coze.cn/',
@@ -10463,7 +10464,7 @@ const readJson = async (path) => {
10463
10464
  };
10464
10465
 
10465
10466
  const configuredPath = (options) =>
10466
- _optionalChain$a([options, 'optionalAccess', _ => _.config]) || process.env.COZE_CONFIG_FILE;
10467
+ _optionalChain$b([options, 'optionalAccess', _ => _.config]) || process.env.COZE_CONFIG_FILE;
10467
10468
 
10468
10469
  const loadConfig = async (options = {}) => {
10469
10470
  const customPath = configuredPath(options);
@@ -10814,7 +10815,8 @@ const loginWithOAuth = async (
10814
10815
  await saveOAuthToken(config, options, await pollToken(config, deviceCode));
10815
10816
  };
10816
10817
 
10817
- 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; }
10818
+ 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; }
10819
+
10818
10820
 
10819
10821
 
10820
10822
 
@@ -10879,10 +10881,10 @@ const unwrap = (
10879
10881
  responseMetadata,
10880
10882
  ) => {
10881
10883
  const root = isRecord(payload) ? payload : undefined;
10882
- const first = isRecord(_optionalChain$9([root, 'optionalAccess', _ => _.data])) ? root.data : undefined;
10883
- const second = isRecord(_optionalChain$9([first, 'optionalAccess', _2 => _2.data])) ? first.data : undefined;
10884
+ const first = isRecord(_optionalChain$a([root, 'optionalAccess', _ => _.data])) ? root.data : undefined;
10885
+ const second = isRecord(_optionalChain$a([first, 'optionalAccess', _2 => _2.data])) ? first.data : undefined;
10884
10886
  const envelope = [root, first].find(candidate => candidate && 'code' in candidate);
10885
- if (_optionalChain$9([envelope, 'optionalAccess', _3 => _3.code]) !== undefined && Number(envelope.code) !== 0) {
10887
+ if (_optionalChain$a([envelope, 'optionalAccess', _3 => _3.code]) !== undefined && Number(envelope.code) !== 0) {
10886
10888
  throw new CliError(
10887
10889
  typeof envelope.msg === 'string'
10888
10890
  ? envelope.msg.slice(0, MAX_MESSAGE_LENGTH)
@@ -10934,7 +10936,7 @@ class DeployApiClient {
10934
10936
  if (this.config.organizationId) {
10935
10937
  headers['x-coze-account'] = this.config.organizationId;
10936
10938
  }
10937
- const lane = _optionalChain$9([this, 'access', _4 => _4.globalOptions, 'access', _5 => _5.lane, 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]) || _optionalChain$9([this, 'access', _8 => _8.config, 'access', _9 => _9.xTTEnv, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]);
10939
+ const lane = _optionalChain$a([this, 'access', _4 => _4.globalOptions, 'access', _5 => _5.lane, 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]) || _optionalChain$a([this, 'access', _8 => _8.config, 'access', _9 => _9.xTTEnv, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]);
10938
10940
  if (lane) {
10939
10941
  headers['x-use-ppe'] = '1';
10940
10942
  headers['x-tt-env'] = lane;
@@ -10965,7 +10967,7 @@ class DeployApiClient {
10965
10967
  if (!response.ok) {
10966
10968
  const root = isRecord(payload) ? payload : undefined;
10967
10969
  throw new CliError(
10968
- typeof _optionalChain$9([root, 'optionalAccess', _12 => _12.msg]) === 'string'
10970
+ typeof _optionalChain$a([root, 'optionalAccess', _12 => _12.msg]) === 'string'
10969
10971
  ? root.msg.slice(0, MAX_MESSAGE_LENGTH)
10970
10972
  : `Deployment API failed: ${response.status} ${response.statusText}` +
10971
10973
  `${validJson ? '' : '; response was not JSON'}`,
@@ -11088,6 +11090,12 @@ class DeployApiClient {
11088
11090
  );
11089
11091
  }
11090
11092
 
11093
+ getOnlineEnvironment(appId) {
11094
+ return this.post(
11095
+ '/environment/get_online', { app_id: appId }, 'app_id',
11096
+ );
11097
+ }
11098
+
11091
11099
  checkRollbackDatabase(body) {
11092
11100
  return this.post(
11093
11101
  '/deploy_history/check_rollback_database', body, 'is_rollback_possible',
@@ -11164,6 +11172,35 @@ class DeployApiClient {
11164
11172
  );
11165
11173
  }
11166
11174
 
11175
+ authorizeMiniProgram(body
11176
+
11177
+
11178
+
11179
+
11180
+
11181
+
11182
+ ) {
11183
+ return this.post
11184
+
11185
+
11186
+
11187
+ ('/mini_program/auth', body);
11188
+ }
11189
+
11190
+ createMiniProgramPreview(body
11191
+
11192
+
11193
+
11194
+
11195
+ ) {
11196
+ return this.post
11197
+
11198
+
11199
+
11200
+
11201
+ ('/mini_program/preview', body);
11202
+ }
11203
+
11167
11204
  listDomains(appId, unitType) {
11168
11205
  return this.post(
11169
11206
  '/domain/list', {
@@ -11397,7 +11434,7 @@ const registerDoctor = (program) => {
11397
11434
  });
11398
11435
  };
11399
11436
 
11400
- 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; }
11437
+ 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; }
11401
11438
 
11402
11439
 
11403
11440
 
@@ -11428,7 +11465,7 @@ function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[
11428
11465
 
11429
11466
 
11430
11467
  const getDeployParentOptions = (command) =>
11431
- _optionalChain$8([command, 'access', _ => _.parent, 'optionalAccess', _2 => _2.opts, 'call', _3 => _3()]) || {};
11468
+ _optionalChain$9([command, 'access', _ => _.parent, 'optionalAccess', _2 => _2.opts, 'call', _3 => _3()]) || {};
11432
11469
 
11433
11470
  const getDeployAppIdOption = (
11434
11471
  options,
@@ -11478,10 +11515,10 @@ const TERMINAL_STATUSES = new Set([
11478
11515
  const getDeployStatusText = (status) =>
11479
11516
  status ? STATUS_NAMES[status] || 'Unknown' : 'Unknown';
11480
11517
 
11481
- 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; }
11518
+ 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; }
11482
11519
 
11483
11520
  const formatDeployDetails = (history) =>
11484
- (_optionalChain$7([history, 'optionalAccess', _ => _.deploy_detail]) || []).map(detail => ({
11521
+ (_optionalChain$8([history, 'optionalAccess', _ => _.deploy_detail]) || []).map(detail => ({
11485
11522
  target: detail.target,
11486
11523
  status: getDeployStatusText(detail.status),
11487
11524
  deploy_log_key: detail.deploy_log_key,
@@ -11491,7 +11528,7 @@ const formatDeployDetails = (history) =>
11491
11528
  const getDeployLogKeys = (history) =>
11492
11529
  [...new Set(
11493
11530
  (history.deploy_detail || [])
11494
- .map(detail => _optionalChain$7([detail, 'access', _2 => _2.deploy_log_key, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]))
11531
+ .map(detail => _optionalChain$8([detail, 'access', _2 => _2.deploy_log_key, 'optionalAccess', _3 => _3.trim, 'call', _4 => _4()]))
11495
11532
  .filter((key) => Boolean(key)),
11496
11533
  )];
11497
11534
 
@@ -11506,16 +11543,17 @@ const resolveDeployHistoryId = (
11506
11543
  ) =>
11507
11544
  normalizePositiveId(deployHistoryId) || normalizePositiveId(previousDeployHistoryId);
11508
11545
 
11509
- 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; }
11546
+ 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; }
11510
11547
 
11511
11548
  const SOURCE_SNAPSHOT_BYTES = 20;
11549
+ const PROJECT_METADATA_FILE_MODE = 0o644;
11512
11550
 
11513
11551
  const isId = (value) =>
11514
11552
  typeof value === 'string' && /^\d+$/u.test(value);
11515
11553
 
11516
11554
 
11517
11555
  const resolveAppId = async (cwd, appId) => {
11518
- const explicit = _optionalChain$6([appId, 'optionalAccess', _ => _.trim, 'call', _2 => _2()]);
11556
+ const explicit = _optionalChain$7([appId, 'optionalAccess', _ => _.trim, 'call', _2 => _2()]);
11519
11557
  if (explicit) {
11520
11558
  return explicit;
11521
11559
  }
@@ -11561,11 +11599,11 @@ const readProjectMetadata = async (
11561
11599
  }
11562
11600
  throw error;
11563
11601
  }
11564
- const projectSection = _optionalChain$6([cozeFileContent, 'access', _3 => _3.match, 'call', _4 => _4(
11602
+ const projectSection = _optionalChain$7([cozeFileContent, 'access', _3 => _3.match, 'call', _4 => _4(
11565
11603
  /^\s*\[project\]\s*(?:#.*)?$([\s\S]*?)(?=^\s*\[[^\]]+\]\s*(?:#.*)?$|(?![\s\S]))/mu,
11566
11604
  ), 'optionalAccess', _5 => _5[1]]);
11567
11605
  const readProjectString = (key) =>
11568
- _optionalChain$6([projectSection
11606
+ _optionalChain$7([projectSection
11569
11607
  , 'optionalAccess', _6 => _6.match, 'call', _7 => _7(new RegExp(`^\\s*${key}\\s*=\\s*["']([^"']+)["']`, 'mu')), 'optionalAccess', _8 => _8[1]
11570
11608
  , 'optionalAccess', _9 => _9.trim, 'call', _10 => _10()]);
11571
11609
  const name = readProjectString('name');
@@ -11573,7 +11611,7 @@ const readProjectMetadata = async (
11573
11611
  const projectId = readProjectString('project_id');
11574
11612
  const appId = readProjectString('app_id');
11575
11613
  const hasUnquotedId = (key) =>
11576
- Boolean(_optionalChain$6([projectSection, 'optionalAccess', _11 => _11.match, 'call', _12 => _12(new RegExp(`^\\s*${key}\\s*=\\s*(?!["'])\\S+`, 'mu'))]));
11614
+ Boolean(_optionalChain$7([projectSection, 'optionalAccess', _11 => _11.match, 'call', _12 => _12(new RegExp(`^\\s*${key}\\s*=\\s*(?!["'])\\S+`, 'mu'))]));
11577
11615
  if (hasUnquotedId('project_id') || hasUnquotedId('app_id')) {
11578
11616
  throw new CliError(
11579
11617
  '.coze [project].project_id and app_id must be quoted decimal strings.',
@@ -11598,7 +11636,7 @@ const updateProjectValue = (content, key, value) => {
11598
11636
  const sectionStart = sectionMatch.index + sectionMatch[0].length;
11599
11637
  const following = content.slice(sectionStart);
11600
11638
  const nextSection = /^\s*\[[^\]]+\]\s*(?:#.*)?$/mu.exec(following);
11601
- const sectionEnd = _optionalChain$6([nextSection, 'optionalAccess', _13 => _13.index]) === undefined
11639
+ const sectionEnd = _optionalChain$7([nextSection, 'optionalAccess', _13 => _13.index]) === undefined
11602
11640
  ? content.length
11603
11641
  : sectionStart + nextSection.index;
11604
11642
  const before = content.slice(0, sectionStart);
@@ -11629,7 +11667,11 @@ const writeProjectBinding = async (
11629
11667
  }
11630
11668
  const tempPath = node_path.join(node_path.dirname(path), `.coze-${node_crypto.randomUUID()}.tmp`);
11631
11669
  try {
11632
- await promises.writeFile(tempPath, content, { encoding: 'utf8', mode: 0o600 });
11670
+ await promises.writeFile(tempPath, content, {
11671
+ encoding: 'utf8',
11672
+ mode: PROJECT_METADATA_FILE_MODE,
11673
+ });
11674
+ await promises.chmod(tempPath, PROJECT_METADATA_FILE_MODE);
11633
11675
  await promises.rename(tempPath, path);
11634
11676
  } finally {
11635
11677
  await promises.rm(tempPath, { force: true });
@@ -11648,17 +11690,18 @@ const ensureProjectMetadata = async (
11648
11690
  throw error;
11649
11691
  }
11650
11692
  }
11651
- const name = _optionalChain$6([options, 'access', _14 => _14.name, 'optionalAccess', _15 => _15.trim, 'call', _16 => _16()]) || 'Pages application';
11652
- const projectType = _optionalChain$6([options, 'access', _17 => _17.projectType, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]) || 'web';
11693
+ const name = _optionalChain$7([options, 'access', _14 => _14.name, 'optionalAccess', _15 => _15.trim, 'call', _16 => _16()]) || 'Pages application';
11694
+ const projectType = _optionalChain$7([options, 'access', _17 => _17.projectType, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]) || 'web';
11653
11695
  await promises.writeFile(
11654
11696
  node_path.join(sourceRoot, '.coze'),
11655
11697
  `[project]\nname = ${JSON.stringify(name)}\nproject_type = ${JSON.stringify(projectType)}\n`,
11656
- { encoding: 'utf8', mode: 0o600 },
11698
+ { encoding: 'utf8', mode: PROJECT_METADATA_FILE_MODE },
11657
11699
  );
11700
+ await promises.chmod(node_path.join(sourceRoot, '.coze'), PROJECT_METADATA_FILE_MODE);
11658
11701
  return readProjectMetadata(sourceRoot);
11659
11702
  };
11660
11703
 
11661
- 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; }
11704
+ 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; }
11662
11705
  const isFile = async (path) => {
11663
11706
  try {
11664
11707
  return (await promises.stat(path)).isFile();
@@ -11688,14 +11731,14 @@ const validatePagesSource = async (
11688
11731
  );
11689
11732
  }
11690
11733
  const project = config.project ;
11691
- if (typeof _optionalChain$5([project, 'optionalAccess', _ => _.template]) !== 'string' || project.template.trim().toLowerCase() !== 'nextjs') {
11734
+ if (typeof _optionalChain$6([project, 'optionalAccess', _ => _.template]) !== 'string' || project.template.trim().toLowerCase() !== 'nextjs') {
11692
11735
  throw new CliError(
11693
11736
  'Pages source contains no index.html; .coze project.template must be "nextjs".',
11694
11737
  'PAGES_BUILD_CONFIG_REQUIRED',
11695
11738
  );
11696
11739
  }
11697
11740
  const deploy = config.deploy ;
11698
- const build = _optionalChain$5([deploy, 'optionalAccess', _2 => _2.build]);
11741
+ const build = _optionalChain$6([deploy, 'optionalAccess', _2 => _2.build]);
11699
11742
  if (!Array.isArray(build) || build.length === 0 || !build.every(part => typeof part === 'string' && part.length > 0)) {
11700
11743
  throw new CliError(
11701
11744
  'Pages source contains no index.html; .coze deploy.build must be a non-empty string array.',
@@ -11736,7 +11779,157 @@ const readDeployLocalContext = async (
11736
11779
  return { ...sourceSnapshot, metadata, isPagesDeployment };
11737
11780
  };
11738
11781
 
11782
+ // 服务端 deploy_app/list 的 page_size 上限,超了会被判参数错误。
11783
+ // 客户端先拦一道,是为了把错误说在本地(带上上限值),而不是回一句服务端的通用参数错误。
11784
+ const APP_LIST_MAX_PAGE_SIZE = 100;
11785
+
11786
+ // page_token 是**页码的十进制字符串**(服务端口径,与 deploy_history/list 一致),不是不透明游标。
11787
+ // 所以这里能、也应该在本地校验:`--page-token abc` 早报错,比发出去再被拒强。
11788
+ const parsePositiveInt = (
11789
+ raw,
11790
+ option,
11791
+ code,
11792
+ max,
11793
+ ) => {
11794
+ const value = Number(raw);
11795
+ if (!Number.isSafeInteger(value) || value <= 0) {
11796
+ throw new CliError(`${option} must be a positive integer.`, code, { [option]: raw });
11797
+ }
11798
+ if (max !== undefined && value > max) {
11799
+ throw new CliError(`${option} must not exceed ${String(max)}.`, code, { [option]: raw });
11800
+ }
11801
+ return value;
11802
+ };
11803
+
11804
+ // ⛔ 别再用 `Number(options.pageSize || 20)`:`--page-size abc` 会算出 NaN,
11805
+ // JSON.stringify 把它写成 null 发给服务端,最后表现为「参数没生效」而不是「参数写错了」。
11806
+ const parsePageSize = (
11807
+ raw,
11808
+ fallback,
11809
+ max,
11810
+ ) => {
11811
+ if (raw === undefined || raw === '') {
11812
+ return fallback;
11813
+ }
11814
+ return parsePositiveInt(raw, '--page-size', 'INVALID_PAGE_SIZE', max);
11815
+ };
11816
+
11817
+ const parsePageToken = (raw) => {
11818
+ if (raw === undefined || raw === '') {
11819
+ return undefined;
11820
+ }
11821
+ parsePositiveInt(raw, '--page-token', 'INVALID_PAGE_TOKEN');
11822
+ return raw;
11823
+ };
11824
+
11825
+
11826
+
11827
+
11828
+
11829
+
11830
+
11831
+ // collectAllPages 顺着 next_page_token 把所有页取回来。
11832
+ //
11833
+ // 服务端从「全量单页」改成真分页之后,`app list` 一次只回一页;想要「我的全部应用」就得翻页。
11834
+ // 与其让每个调用方各写一遍循环,不如给一个 --all。
11835
+ //
11836
+ // ⚠️ 不设页数上限截断:静默截断正是这次要修掉的毛病。只防死循环——服务端如果一直回同一个
11837
+ // token(或说 has_more 却不给 token),直接报错,而不是无限翻。
11838
+ const collectAllPages = async (
11839
+ fetchPage,
11840
+ ) => {
11841
+ const items = [];
11842
+ const seen = new Set();
11843
+ let pageToken;
11844
+ let pages = 0;
11845
+ for (;;) {
11846
+ const page = await fetchPage(pageToken);
11847
+ items.push(...(page.items || []));
11848
+ pages += 1;
11849
+ if (!page.has_more) {
11850
+ return { items, pages };
11851
+ }
11852
+ const next = page.next_page_token;
11853
+ if (!next || seen.has(next)) {
11854
+ throw new CliError(
11855
+ 'The server reported more pages but returned no usable next_page_token.',
11856
+ 'INVALID_PAGE_TOKEN',
11857
+ { next_page_token: next, pages },
11858
+ );
11859
+ }
11860
+ seen.add(next);
11861
+ pageToken = next;
11862
+ }
11863
+ };
11864
+
11865
+ async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
11866
+
11739
11867
  const registerDeployReadCommands = (deploy) => {
11868
+ deploy
11869
+ .command('status')
11870
+ .option('--app-id <appId>', 'Application ID')
11871
+ .option('--deploy-id <deployId>', 'Deployment history ID')
11872
+ .action(async (options, command) => {
11873
+ const runtime = await getRuntime(command);
11874
+ const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
11875
+ let deployHistoryId = options.deployId;
11876
+ if (!deployHistoryId) {
11877
+ deployHistoryId = await _asyncOptionalChain([(
11878
+ await runtime.client.listDeployHistory({ app_id: appId, page_size: 1 })
11879
+ ), 'access', async _ => _.deploy_history_list, 'optionalAccess', async _2 => _2[0], 'optionalAccess', async _3 => _3.deploy_history_id]);
11880
+ }
11881
+ if (!deployHistoryId) {
11882
+ throw new CliError('No deployment history found.', 'DEPLOYMENT_NOT_FOUND');
11883
+ }
11884
+ const history = await runtime.client.getDeployHistory({
11885
+ app_id: appId,
11886
+ deploy_history_id: deployHistoryId,
11887
+ });
11888
+ runtime.output.print({
11889
+ app_id: appId,
11890
+ deploy_history_id: deployHistoryId,
11891
+ status: getDeployStatusText(history.status),
11892
+ commit_hash: history.commit_hash,
11893
+ domains: history.domain_list || [],
11894
+ error_analysis: history.error_analysis,
11895
+ deploy_detail: formatDeployDetails(history),
11896
+ connector_data_list: history.connector_data_list || [],
11897
+ mobile_artifact_list: history.mobile_artifact_list || [],
11898
+ });
11899
+ });
11900
+
11901
+ deploy
11902
+ .command('list')
11903
+ .option('--app-id <appId>', 'Application ID')
11904
+ .option('--page-size <pageSize>', 'Page size', '10')
11905
+ .option('--page-token <pageToken>', 'Page token (page number)')
11906
+ .action(async (options, command) => {
11907
+ // 先在本地校验:`--page-size abc` 以前算出 NaN 发出去,表现成「参数没生效」。
11908
+ const pageSize = parsePageSize(options.pageSize, 10);
11909
+ const pageToken = parsePageToken(options.pageToken);
11910
+ const runtime = await getRuntime(command);
11911
+ const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
11912
+ const data = await runtime.client.listDeployHistory({
11913
+ app_id: appId,
11914
+ page_size: pageSize,
11915
+ page_token: pageToken,
11916
+ });
11917
+ runtime.output.print({
11918
+ items: (data.deploy_history_list || []).map(item => ({
11919
+ deploy_history_id: item.deploy_history_id,
11920
+ status: getDeployStatusText(item.status),
11921
+ commit_hash: item.commit_hash_short || item.commit_hash,
11922
+ created_at: item.created_at,
11923
+ can_rollback: item.can_rollback,
11924
+ deploy_detail: formatDeployDetails(item),
11925
+ connector_data_list: item.connector_data_list || [],
11926
+ mobile_artifact_list: item.mobile_artifact_list || [],
11927
+ })),
11928
+ next_page_token: data.next_page_token,
11929
+ has_more: data.has_more,
11930
+ });
11931
+ });
11932
+
11740
11933
  deploy
11741
11934
  .command('online')
11742
11935
  .description('Show the current online deployment')
@@ -11754,6 +11947,7 @@ const registerDeployReadCommands = (deploy) => {
11754
11947
  created_at: item.created_at,
11755
11948
  deploy_detail: formatDeployDetails(item),
11756
11949
  domains: item.domain_list || [],
11950
+ mobile_artifact_list: item.mobile_artifact_list || [],
11757
11951
  })),
11758
11952
  });
11759
11953
  });
@@ -11796,223 +11990,113 @@ const registerDeployReadCommands = (deploy) => {
11796
11990
  });
11797
11991
  };
11798
11992
 
11799
- function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
11993
+ const registerEnv = (code) => {
11994
+ const env = code
11995
+ .command('env')
11996
+ .description('Inspect the current online environment snapshot');
11997
+
11998
+ env
11999
+ .command('list')
12000
+ .description('List environment variables of the current online deployment')
12001
+ .option('--app-id <appId>', 'Application ID')
12002
+ .action(async (options, command) => {
12003
+ const runtime = await getRuntime(command);
12004
+ const appId = await requireAppId(
12005
+ runtime.cwd,
12006
+ getDeployAppIdOption(options, command),
12007
+ );
12008
+ runtime.output.print(await runtime.client.getOnlineEnvironment(appId));
12009
+ });
12010
+ };
12011
+
12012
+ 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; }/* eslint-disable security/detect-non-literal-fs-filename -- validated project-local build output paths */
11800
12013
 
11801
- const ENV_KEY_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
11802
- const RESERVED_ENV_PREFIX = 'COZE_';
12014
+ const BUILD_OUTPUT_DIRS = new Set(['dist', 'dist-tt']);
12015
+ const EXCLUDED_PARTS = new Set([
12016
+ '.git',
12017
+ '.env',
12018
+ 'node_modules',
12019
+ ]);
12020
+ const REPRODUCIBLE_ARCHIVE_MTIME = new Date(0);
11803
12021
 
11804
- const assertEnvKey = (key) => {
11805
- if (!ENV_KEY_PATTERN.test(key)) {
12022
+ const validateBuildOutput = async (
12023
+ sourceRoot,
12024
+ buildOutputDir,
12025
+ ) => {
12026
+ if (!BUILD_OUTPUT_DIRS.has(buildOutputDir)) {
11806
12027
  throw new CliError(
11807
- `Invalid environment variable name: ${key}`,
11808
- 'ENV_KEY_INVALID',
12028
+ `Unsupported Mini-program build output directory: ${buildOutputDir}.`,
12029
+ 'SOURCE_PACKAGE_FAILED',
11809
12030
  );
11810
12031
  }
11811
- if (key.startsWith(RESERVED_ENV_PREFIX)) {
12032
+ const buildOutputRoot = node_path.resolve(sourceRoot, buildOutputDir);
12033
+ try {
12034
+ const info = await promises.lstat(buildOutputRoot);
12035
+ if (info.isSymbolicLink() || !info.isDirectory()) {
12036
+ throw new Error('build output must be a regular directory');
12037
+ }
12038
+ const realSourceRoot = await promises.realpath(sourceRoot);
12039
+ const realBuildOutputRoot = await promises.realpath(buildOutputRoot);
12040
+ const relativeOutput = node_path.relative(realSourceRoot, realBuildOutputRoot);
12041
+ if (!relativeOutput || relativeOutput.startsWith('..')) {
12042
+ throw new Error('build output must be inside the source root');
12043
+ }
12044
+ } catch (error) {
11812
12045
  throw new CliError(
11813
- `${RESERVED_ENV_PREFIX} is reserved for platform environment variables.`,
11814
- 'ENV_KEY_RESERVED',
12046
+ `Invalid Mini-program build output ${buildOutputRoot}: ${error instanceof Error ? error.message : String(error)}`,
12047
+ 'SOURCE_PACKAGE_FAILED',
11815
12048
  );
11816
12049
  }
11817
12050
  };
11818
12051
 
11819
- const readEnvFile = async (sourceRoot) => {
11820
- try {
11821
- return await promises.readFile(node_path.join(sourceRoot, '.env'), 'utf8');
11822
- } catch (error) {
11823
- if ((error ).code === 'ENOENT') {
11824
- return undefined;
11825
- }
11826
- throw new CliError('Unable to read the local .env file.', 'ENV_FILE_READ_FAILED');
12052
+ const shouldInclude = (
12053
+ archivePath,
12054
+ entry,
12055
+ ) => {
12056
+ if (_optionalChain$5([entry, 'access', _ => _.isSymbolicLink, 'optionalCall', _2 => _2()])) {
12057
+ return false;
11827
12058
  }
12059
+ return !archivePath.split(/[\\/]/u).some(part =>
12060
+ EXCLUDED_PARTS.has(part) || part.startsWith('.git'),
12061
+ );
11828
12062
  };
11829
12063
 
11830
- const parseEnvFile = (content) => {
12064
+ const createMiniProgramPackage = async (
12065
+ sourceRoot,
12066
+ buildOutputDir,
12067
+ ) => {
12068
+ const resolvedSourceRoot = node_path.resolve(sourceRoot);
12069
+ await validateBuildOutput(resolvedSourceRoot, buildOutputDir);
12070
+ const tempDirectory = await promises.mkdtemp(node_path.join(node_os.tmpdir(), 'coze-mini-program-source-'));
12071
+ const outputPath = node_path.join(tempDirectory, 'source.tar.gz');
11831
12072
  try {
11832
- const values = node_util.parseEnv(content);
11833
- if (Object.keys(values).some(key => !ENV_KEY_PATTERN.test(key))) {
11834
- throw new Error('invalid environment variable name');
11835
- }
11836
- return values;
11837
- } catch (e) {
11838
- throw new CliError('The local .env file is invalid.', 'ENV_FILE_INVALID');
11839
- }
11840
- };
11841
-
11842
- const assignmentPattern = (key) =>
11843
- new RegExp(`^\\s*(?:export\\s+)?${key}\\s*=`, 'u');
11844
-
11845
- const formatEnvValue = (value) => {
11846
- if (value.includes('\n') || value.includes('\r')) {
11847
- throw new CliError(
11848
- 'Environment variable values must be single-line.',
11849
- 'ENV_VALUE_INVALID',
12073
+ await tar.create(
12074
+ {
12075
+ cwd: resolvedSourceRoot,
12076
+ file: outputPath,
12077
+ filter: shouldInclude,
12078
+ gzip: true,
12079
+ mtime: REPRODUCIBLE_ARCHIVE_MTIME,
12080
+ portable: true,
12081
+ },
12082
+ [buildOutputDir],
11850
12083
  );
11851
- }
11852
- if (!value.includes("'")) {
11853
- return `'${value}'`;
11854
- }
11855
- if (!value.includes('"')) {
11856
- return `"${value}"`;
11857
- }
11858
- if (value === value.trim() && !value.includes('#')) {
11859
- return value;
11860
- }
11861
- throw new CliError(
11862
- 'Environment variable values containing both quote types cannot also contain surrounding whitespace or #.',
11863
- 'ENV_VALUE_INVALID',
11864
- );
11865
- };
11866
-
11867
- const writeEnvFile = async (sourceRoot, content) => {
11868
- try {
11869
- await promises.writeFile(node_path.join(sourceRoot, '.env'), content, { encoding: 'utf8', mode: 0o600 });
11870
- } catch (e2) {
11871
- throw new CliError('Unable to write the local .env file.', 'ENV_FILE_WRITE_FAILED');
11872
- }
11873
- };
11874
-
11875
- const listProjectEnv = async (
11876
- sourceRoot,
11877
- ) => {
11878
- const content = await readEnvFile(sourceRoot);
11879
- if (content === undefined) {
11880
- return {};
11881
- }
11882
- return Object.fromEntries(
11883
- Object.entries(parseEnvFile(content))
11884
- .filter(([key]) => !key.startsWith(RESERVED_ENV_PREFIX))
11885
- .map(([key, value]) => [key, _nullishCoalesce$2(value, () => ( ''))]),
11886
- );
11887
- };
11888
-
11889
- const setProjectEnv = async (
11890
- sourceRoot,
11891
- key,
11892
- value,
11893
- ) => {
11894
- assertEnvKey(key);
11895
- const content = (await readEnvFile(sourceRoot)) || '';
11896
- if (content) {
11897
- parseEnvFile(content);
11898
- }
11899
- const lines = content.split(/\r?\n/u);
11900
- const pattern = assignmentPattern(key);
11901
- const replacement = `${key}=${formatEnvValue(value)}`;
11902
- const updatedLines = [];
11903
- let replaced = false;
11904
- for (const line of lines) {
11905
- if (pattern.test(line)) {
11906
- if (!replaced) {
11907
- updatedLines.push(replacement);
11908
- replaced = true;
11909
- }
11910
- } else {
11911
- updatedLines.push(line);
11912
- }
11913
- }
11914
- if (!replaced) {
11915
- while (updatedLines[updatedLines.length - 1] === '') {
11916
- updatedLines.pop();
12084
+ const info = await promises.stat(outputPath);
12085
+ if (info.size === 0) {
12086
+ throw new Error('source archive is empty');
11917
12087
  }
11918
- updatedLines.push(replacement);
11919
- }
11920
- while (updatedLines[updatedLines.length - 1] === '') {
11921
- updatedLines.pop();
11922
- }
11923
- await writeEnvFile(sourceRoot, `${updatedLines.join('\n')}\n`);
11924
- };
11925
-
11926
- const deleteProjectEnv = async (
11927
- sourceRoot,
11928
- key,
11929
- ) => {
11930
- assertEnvKey(key);
11931
- const content = await readEnvFile(sourceRoot);
11932
- if (content === undefined) {
11933
- return false;
11934
- }
11935
- parseEnvFile(content);
11936
- const pattern = assignmentPattern(key);
11937
- const lines = content.split(/\r?\n/u);
11938
- const filtered = lines.filter(line => !pattern.test(line));
11939
- if (filtered.length === lines.length) {
11940
- return false;
11941
- }
11942
- await writeEnvFile(sourceRoot, filtered.join('\n'));
11943
- return true;
11944
- };
11945
-
11946
- const readProjectEnv = async (
11947
- sourceRoot,
11948
- ) => {
11949
- const content = await readEnvFile(sourceRoot);
11950
- if (content === undefined) {
11951
- return [];
12088
+ return {
12089
+ path: outputPath,
12090
+ sizeBytes: info.size,
12091
+ cleanup: () => promises.rm(tempDirectory, { recursive: true, force: true }),
12092
+ };
12093
+ } catch (error) {
12094
+ await promises.rm(tempDirectory, { recursive: true, force: true });
12095
+ throw new CliError(
12096
+ `Unable to package Mini-program build output: ${error instanceof Error ? error.message : String(error)}`,
12097
+ 'SOURCE_PACKAGE_FAILED',
12098
+ );
11952
12099
  }
11953
- const values = parseEnvFile(content);
11954
-
11955
- return Object.entries(values)
11956
- .filter(([key]) => !key.startsWith(RESERVED_ENV_PREFIX))
11957
- .map(([key, value]) => ({
11958
- secret_id: '',
11959
- secret_key: key,
11960
- secret_val: _nullishCoalesce$2(value, () => ( '')),
11961
- secret_type: 'user_custom',
11962
- }));
11963
- };
11964
-
11965
- const resolveSourceRoot = (cwd, options) =>
11966
- node_path.resolve(cwd, options.sourceRoot || '.');
11967
-
11968
- const addSourceRootOption = (command) =>
11969
- command.option('--source-root <sourceRoot>', 'Local project root', '.');
11970
-
11971
- const registerEnv = (code) => {
11972
- const env = code
11973
- .command('env')
11974
- .description('Manage the local project .env file');
11975
-
11976
- addSourceRootOption(env.command('list').description('List local environment variables')).action(
11977
- async (options, command) => {
11978
- const runtime = await getRuntime(command);
11979
- const sourceRoot = resolveSourceRoot(runtime.cwd, options);
11980
- runtime.output.print({
11981
- source_root: sourceRoot,
11982
- variables: await listProjectEnv(sourceRoot),
11983
- });
11984
- },
11985
- );
11986
-
11987
- addSourceRootOption(
11988
- env
11989
- .command('set <key> <value>')
11990
- .description('Set a local environment variable'),
11991
- ).action(
11992
- async (
11993
- key,
11994
- value,
11995
- options,
11996
- command,
11997
- ) => {
11998
- const runtime = await getRuntime(command);
11999
- const sourceRoot = resolveSourceRoot(runtime.cwd, options);
12000
- await setProjectEnv(sourceRoot, key, value);
12001
- runtime.output.print({ source_root: sourceRoot, key, updated: true });
12002
- },
12003
- );
12004
-
12005
- addSourceRootOption(
12006
- env.command('delete <key>').description('Delete a local environment variable'),
12007
- ).action(async (key, options, command) => {
12008
- const runtime = await getRuntime(command);
12009
- const sourceRoot = resolveSourceRoot(runtime.cwd, options);
12010
- runtime.output.print({
12011
- source_root: sourceRoot,
12012
- key,
12013
- deleted: await deleteProjectEnv(sourceRoot, key),
12014
- });
12015
- });
12016
12100
  };
12017
12101
 
12018
12102
  function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
@@ -12021,6 +12105,11 @@ const CONNECTOR_IDS = {
12021
12105
  douyin: '10000126',
12022
12106
  } ;
12023
12107
 
12108
+ const MINI_PROGRAM_BUILD_OUTPUT_DIRS = {
12109
+ wechat: 'dist',
12110
+ douyin: 'dist-tt',
12111
+ } ;
12112
+
12024
12113
 
12025
12114
 
12026
12115
 
@@ -12045,6 +12134,18 @@ const resolveConnectorId = (platform) => {
12045
12134
  return connectorId;
12046
12135
  };
12047
12136
 
12137
+ const resolveBuildOutputDir = (platform) => {
12138
+ const outputDir =
12139
+ MINI_PROGRAM_BUILD_OUTPUT_DIRS[platform ];
12140
+ if (!outputDir) {
12141
+ throw new CliError(
12142
+ `Unsupported Mini-program platform ${String(platform)}; expected wechat or douyin.`,
12143
+ 'INVALID_MINIPROGRAM_PLATFORM',
12144
+ );
12145
+ }
12146
+ return outputDir;
12147
+ };
12148
+
12048
12149
  const resolveProjectId = async (
12049
12150
  command,
12050
12151
  options,
@@ -12064,6 +12165,137 @@ const resolveProjectId = async (
12064
12165
  return metadata.projectId;
12065
12166
  };
12066
12167
 
12168
+ const MINI_PROGRAM_AUTH_STATUS = {
12169
+ authorized: 1,
12170
+ needAuthorize: 2,
12171
+ boundToOtherUser: 3,
12172
+ } ;
12173
+
12174
+ const getBoundToOtherUserMessage = (platform) => {
12175
+ const platformName = platform === 'wechat' ? 'WeChat' : 'Douyin';
12176
+ const platformConsole =
12177
+ platform === 'wechat' ? 'WeChat Public Platform' : 'Douyin Open Platform';
12178
+ return [
12179
+ `This ${platformName} Mini-program AppID is authorized by another Coze user.`,
12180
+ `If this is an AppID you manage, revoke Coze's previous third-party platform authorization in the ${platformConsole}, then rerun this auth command. The CLI will recheck the AppID and authorize it for your current Coze account.`,
12181
+ 'If this is not your AppID, change --mini-app-id to an AppID for which you have administrator permission, then rerun this auth command.',
12182
+ ].join(' ');
12183
+ };
12184
+
12185
+ const getAuthRequiredMessage = () =>
12186
+ 'This Mini-program AppID is not authorized for the current Coze user. Run `coze-dev deploy code mini-program auth` first.';
12187
+
12188
+ const getPreviewFailureMessage = (data
12189
+
12190
+
12191
+ ) =>
12192
+ _optionalChain$4([data, 'access', _4 => _4.stderr, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]) || _optionalChain$4([data, 'access', _7 => _7.stdout, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]) || 'Mini-program preview failed.';
12193
+
12194
+ const registerAuthorizationCommand = (miniProgram) => {
12195
+ miniProgram
12196
+ .command('auth')
12197
+ .description('Authorize a Mini-program AppID for the current Coze user')
12198
+ .requiredOption('--platform <platform>', 'wechat or douyin')
12199
+ .requiredOption('--mini-app-id <miniAppId>', 'Mini-program AppID')
12200
+ .option('--project-id <projectId>', 'Deployment Project ID')
12201
+ .option('--source-root <sourceRoot>', 'Directory containing .coze', '.')
12202
+ .action(async (options, command) => {
12203
+ const runtime = await getRuntime(command);
12204
+ const projectId = await resolveProjectId(command, options);
12205
+ const authorization = await runtime.client.authorizeMiniProgram({
12206
+ project_id: projectId,
12207
+ app_id: options.miniAppId || '',
12208
+ connector_id: resolveConnectorId(options.platform),
12209
+ redirect_url: 'https://code.coze.cn/coding/auth/callback/miniprogram',
12210
+ });
12211
+ if (authorization.status === MINI_PROGRAM_AUTH_STATUS.needAuthorize) {
12212
+ runtime.output.print({
12213
+ project_id: projectId,
12214
+ mini_app_id: options.miniAppId,
12215
+ platform: options.platform,
12216
+ authorization_required: true,
12217
+ auth_url: authorization.auth_url,
12218
+ });
12219
+ return;
12220
+ }
12221
+ if (authorization.status === MINI_PROGRAM_AUTH_STATUS.boundToOtherUser) {
12222
+ throw new CliError(
12223
+ getBoundToOtherUserMessage(options.platform),
12224
+ 'MINIPROGRAM_AUTHORIZED_BY_OTHER_USER',
12225
+ );
12226
+ }
12227
+ if (authorization.status !== MINI_PROGRAM_AUTH_STATUS.authorized) {
12228
+ throw new CliError(
12229
+ `Unexpected Mini-program authorization status: ${String(authorization.status)}.`,
12230
+ 'INVALID_RESPONSE',
12231
+ );
12232
+ }
12233
+ runtime.output.print({
12234
+ project_id: projectId,
12235
+ mini_app_id: options.miniAppId,
12236
+ platform: options.platform,
12237
+ authorized: true,
12238
+ });
12239
+ });
12240
+ };
12241
+
12242
+ const registerPreviewCommand = (miniProgram) => {
12243
+ miniProgram
12244
+ .command('preview')
12245
+ .description('Create a Mini-program preview QR code from the local build artifact')
12246
+ .requiredOption('--platform <platform>', 'wechat or douyin')
12247
+ .requiredOption('--mini-app-id <miniAppId>', 'Mini-program AppID')
12248
+ .option('--project-id <projectId>', 'Deployment Project ID')
12249
+ .option('--source-root <sourceRoot>', 'Directory containing dist or dist-tt', '.')
12250
+ .action(async (options, command) => {
12251
+ const runtime = await getRuntime(command);
12252
+ const projectId = await resolveProjectId(command, options);
12253
+ const authorization = await runtime.client.getMiniProgramAuthStatus({
12254
+ project_id: projectId,
12255
+ connector_id: resolveConnectorId(options.platform),
12256
+ });
12257
+ if (
12258
+ !authorization.is_authorized ||
12259
+ authorization.bound_related_id !== options.miniAppId
12260
+ ) {
12261
+ throw new CliError(
12262
+ getAuthRequiredMessage(),
12263
+ 'MINIPROGRAM_AUTH_REQUIRED',
12264
+ );
12265
+ }
12266
+ const sourceRoot = node_path.resolve(runtime.cwd, options.sourceRoot || '.');
12267
+ const buildOutputDir = resolveBuildOutputDir(options.platform);
12268
+ const sourcePackage = await createMiniProgramPackage(
12269
+ sourceRoot,
12270
+ buildOutputDir,
12271
+ );
12272
+ try {
12273
+ const content = await promises.readFile(sourcePackage.path);
12274
+ const data = await runtime.client.createMiniProgramPreview({
12275
+ project_id: projectId,
12276
+ app_id: options.miniAppId || '',
12277
+ connector_id: resolveConnectorId(options.platform),
12278
+ source_package_base64: content.toString('base64'),
12279
+ });
12280
+ if (data.failed) {
12281
+ throw new CliError(
12282
+ getPreviewFailureMessage(data),
12283
+ 'MINIPROGRAM_PREVIEW_FAILED',
12284
+ );
12285
+ }
12286
+ runtime.output.print({
12287
+ project_id: projectId,
12288
+ mini_app_id: options.miniAppId,
12289
+ platform: options.platform,
12290
+ source_package_size_bytes: sourcePackage.sizeBytes,
12291
+ ...data,
12292
+ });
12293
+ } finally {
12294
+ await sourcePackage.cleanup();
12295
+ }
12296
+ });
12297
+ };
12298
+
12067
12299
  const registerMiniProgram = (code) => {
12068
12300
  const miniProgram = code
12069
12301
  .command('mini-program')
@@ -12148,89 +12380,9 @@ const registerMiniProgram = (code) => {
12148
12380
  });
12149
12381
  runtime.output.print({ project_id: projectId, platform: options.platform, unbound: true });
12150
12382
  });
12151
- };
12152
-
12153
- // 服务端 deploy_app/list 的 page_size 上限,超了会被判参数错误。
12154
- // 客户端先拦一道,是为了把错误说在本地(带上上限值),而不是回一句服务端的通用参数错误。
12155
- const APP_LIST_MAX_PAGE_SIZE = 100;
12156
-
12157
- // page_token 是**页码的十进制字符串**(服务端口径,与 deploy_history/list 一致),不是不透明游标。
12158
- // 所以这里能、也应该在本地校验:`--page-token abc` 早报错,比发出去再被拒强。
12159
- const parsePositiveInt = (
12160
- raw,
12161
- option,
12162
- code,
12163
- max,
12164
- ) => {
12165
- const value = Number(raw);
12166
- if (!Number.isSafeInteger(value) || value <= 0) {
12167
- throw new CliError(`${option} must be a positive integer.`, code, { [option]: raw });
12168
- }
12169
- if (max !== undefined && value > max) {
12170
- throw new CliError(`${option} must not exceed ${String(max)}.`, code, { [option]: raw });
12171
- }
12172
- return value;
12173
- };
12174
-
12175
- // ⛔ 别再用 `Number(options.pageSize || 20)`:`--page-size abc` 会算出 NaN,
12176
- // JSON.stringify 把它写成 null 发给服务端,最后表现为「参数没生效」而不是「参数写错了」。
12177
- const parsePageSize = (
12178
- raw,
12179
- fallback,
12180
- max,
12181
- ) => {
12182
- if (raw === undefined || raw === '') {
12183
- return fallback;
12184
- }
12185
- return parsePositiveInt(raw, '--page-size', 'INVALID_PAGE_SIZE', max);
12186
- };
12187
-
12188
- const parsePageToken = (raw) => {
12189
- if (raw === undefined || raw === '') {
12190
- return undefined;
12191
- }
12192
- parsePositiveInt(raw, '--page-token', 'INVALID_PAGE_TOKEN');
12193
- return raw;
12194
- };
12195
-
12196
-
12197
-
12198
-
12199
-
12200
-
12201
12383
 
12202
- // collectAllPages 顺着 next_page_token 把所有页取回来。
12203
- //
12204
- // 服务端从「全量单页」改成真分页之后,`app list` 一次只回一页;想要「我的全部应用」就得翻页。
12205
- // 与其让每个调用方各写一遍循环,不如给一个 --all。
12206
- //
12207
- // ⚠️ 不设页数上限截断:静默截断正是这次要修掉的毛病。只防死循环——服务端如果一直回同一个
12208
- // token(或说 has_more 却不给 token),直接报错,而不是无限翻。
12209
- const collectAllPages = async (
12210
- fetchPage,
12211
- ) => {
12212
- const items = [];
12213
- const seen = new Set();
12214
- let pageToken;
12215
- let pages = 0;
12216
- for (;;) {
12217
- const page = await fetchPage(pageToken);
12218
- items.push(...(page.items || []));
12219
- pages += 1;
12220
- if (!page.has_more) {
12221
- return { items, pages };
12222
- }
12223
- const next = page.next_page_token;
12224
- if (!next || seen.has(next)) {
12225
- throw new CliError(
12226
- 'The server reported more pages but returned no usable next_page_token.',
12227
- 'INVALID_PAGE_TOKEN',
12228
- { next_page_token: next, pages },
12229
- );
12230
- }
12231
- seen.add(next);
12232
- pageToken = next;
12233
- }
12384
+ registerAuthorizationCommand(miniProgram);
12385
+ registerPreviewCommand(miniProgram);
12234
12386
  };
12235
12387
 
12236
12388
  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; }
@@ -12946,7 +13098,7 @@ const createDeploymentWithSourcePackage = async (
12946
13098
  return { uploadMode: 'direct' , result };
12947
13099
  };
12948
13100
 
12949
- function _nullishCoalesce(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; } async function _asyncOptionalChain(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 = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
13101
+ function _nullishCoalesce(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; }
12950
13102
  const SUPPORTED_MINIPROGRAM_CONNECTOR_IDS = new Set(['10000127', '10000126']);
12951
13103
  const collectConnectorId = (value, previous) => [
12952
13104
  ...previous,
@@ -13093,8 +13245,25 @@ const registerDeploy = (code) => {
13093
13245
  }
13094
13246
  let encryptEnvVariable;
13095
13247
  if (applicationType !== 'pages') {
13096
- runtime.output.debug('[deploy] Reading and encrypting local environment variables...');
13097
- const envSecrets = await readProjectEnv(sourceRoot);
13248
+ runtime.output.debug('[deploy] Loading and encrypting online environment variables...');
13249
+ const onlineEnvironment = appId
13250
+ ? await runtime.client.getOnlineEnvironment(appId)
13251
+ : undefined;
13252
+ if (onlineEnvironment && onlineEnvironment.snapshot_status >= 3) {
13253
+ throw new CliError(
13254
+ onlineEnvironment.status_message ||
13255
+ 'The current online environment snapshot is unavailable.',
13256
+ 'ONLINE_ENVIRONMENT_UNAVAILABLE',
13257
+ );
13258
+ }
13259
+ const envSecrets = (_optionalChain([onlineEnvironment, 'optionalAccess', _ => _.variables]) || [])
13260
+ .filter(variable => variable.source === 'user')
13261
+ .map(variable => ({
13262
+ secret_id: '',
13263
+ secret_key: variable.key,
13264
+ secret_val: variable.value,
13265
+ secret_type: 'user_custom' ,
13266
+ }));
13098
13267
  const encrypted = await runtime.client.encryptProjectSecret(projectId, envSecrets);
13099
13268
  encryptEnvVariable = encrypted.sealed_secrets;
13100
13269
  if (!encryptEnvVariable) {
@@ -13168,73 +13337,11 @@ const registerDeploy = (code) => {
13168
13337
  deploy_history_id: deployHistoryId,
13169
13338
  version: result.version,
13170
13339
  commit_hash: commitHash,
13171
- status: getDeployStatusText(_nullishCoalesce(_optionalChain([history, 'optionalAccess', _ => _.status]), () => ( result.status))),
13340
+ status: getDeployStatusText(_nullishCoalesce(_optionalChain([history, 'optionalAccess', _2 => _2.status]), () => ( result.status))),
13172
13341
  source_package_size_bytes: sourcePackage.sizeBytes,
13173
13342
  upload_mode: deployment.uploadMode,
13174
13343
  local_link: appId && !projectCreated ? 'unchanged' : 'written',
13175
- });
13176
- });
13177
-
13178
- deploy
13179
- .command('status')
13180
- .option('--app-id <appId>', 'Application ID')
13181
- .option('--deploy-id <deployId>', 'Deployment history ID')
13182
- .action(async (options, command) => {
13183
- const runtime = await getRuntime(command);
13184
- const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
13185
- let deployHistoryId = options.deployId;
13186
- if (!deployHistoryId) {
13187
- deployHistoryId = await _asyncOptionalChain([(
13188
- await runtime.client.listDeployHistory({ app_id: appId, page_size: 1 })
13189
- ), 'access', async _2 => _2.deploy_history_list, 'optionalAccess', async _3 => _3[0], 'optionalAccess', async _4 => _4.deploy_history_id]);
13190
- }
13191
- if (!deployHistoryId) {
13192
- throw new CliError('No deployment history found.', 'DEPLOYMENT_NOT_FOUND');
13193
- }
13194
- const history = await runtime.client.getDeployHistory({
13195
- app_id: appId,
13196
- deploy_history_id: deployHistoryId,
13197
- });
13198
- runtime.output.print({
13199
- app_id: appId,
13200
- deploy_history_id: deployHistoryId,
13201
- status: getDeployStatusText(history.status),
13202
- commit_hash: history.commit_hash,
13203
- domains: history.domain_list || [],
13204
- error_analysis: history.error_analysis,
13205
- deploy_detail: formatDeployDetails(history),
13206
- connector_data_list: history.connector_data_list || [],
13207
- });
13208
- });
13209
-
13210
- deploy
13211
- .command('list')
13212
- .option('--app-id <appId>', 'Application ID')
13213
- .option('--page-size <pageSize>', 'Page size', '10')
13214
- .option('--page-token <pageToken>', 'Page token (page number)')
13215
- .action(async (options, command) => {
13216
- // 先在本地校验:`--page-size abc` 以前算出 NaN 发出去,表现成「参数没生效」。
13217
- const pageSize = parsePageSize(options.pageSize, 10);
13218
- const pageToken = parsePageToken(options.pageToken);
13219
- const runtime = await getRuntime(command);
13220
- const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
13221
- const data = await runtime.client.listDeployHistory({
13222
- app_id: appId,
13223
- page_size: pageSize,
13224
- page_token: pageToken,
13225
- });
13226
- runtime.output.print({
13227
- items: (data.deploy_history_list || []).map(item => ({
13228
- deploy_history_id: item.deploy_history_id,
13229
- status: getDeployStatusText(item.status),
13230
- commit_hash: item.commit_hash_short || item.commit_hash,
13231
- created_at: item.created_at,
13232
- can_rollback: item.can_rollback,
13233
- deploy_detail: formatDeployDetails(item),
13234
- connector_data_list: item.connector_data_list || [],
13235
- })),
13236
- next_page_token: data.next_page_token,
13237
- has_more: data.has_more,
13344
+ mobile_artifact_list: _optionalChain([history, 'optionalAccess', _3 => _3.mobile_artifact_list]) || [],
13238
13345
  });
13239
13346
  });
13240
13347
 
@@ -13337,7 +13444,7 @@ const registerDeploy = (code) => {
13337
13444
  .action(async (options, command) => {
13338
13445
  const runtime = await getRuntime(command);
13339
13446
  const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
13340
- let key = _optionalChain([options, 'access', _5 => _5.key, 'optionalAccess', _6 => _6.trim, 'call', _7 => _7()]);
13447
+ let key = _optionalChain([options, 'access', _4 => _4.key, 'optionalAccess', _5 => _5.trim, 'call', _6 => _6()]);
13341
13448
  if (!key) {
13342
13449
  const history = await runtime.client.getDeployHistory({
13343
13450
  app_id: appId,
@@ -13379,7 +13486,7 @@ const registerDeploy = (code) => {
13379
13486
  const runtime = await getRuntime(command);
13380
13487
  const appId = await requireAppId(runtime.cwd, getDeployAppIdOption(options, command));
13381
13488
  const application = await runtime.client.getApplication(appId);
13382
- const commitHash = options.commitId || _optionalChain([application, 'access', _8 => _8.latest_deployment, 'optionalAccess', _9 => _9.commit_hash]);
13489
+ const commitHash = options.commitId || _optionalChain([application, 'access', _7 => _7.latest_deployment, 'optionalAccess', _8 => _8.commit_hash]);
13383
13490
  if (!commitHash) {
13384
13491
  throw new CliError('No deployment commit is available.', 'DEPLOYMENT_NOT_FOUND');
13385
13492
  }