@coze-arch/cli 0.1.8-alpha.e237ba → 0.1.8

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.
Files changed (32) hide show
  1. package/README.md +0 -18
  2. package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +10 -178
  3. package/lib/__templates__/nextjs/.coze +1 -1
  4. package/lib/__templates__/nextjs/README.md +0 -18
  5. package/lib/__templates__/nextjs/scripts/build.sh +1 -1
  6. package/lib/__templates__/nextjs/scripts/dev.sh +34 -16
  7. package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +10 -178
  8. package/lib/__templates__/nextjs/scripts/prepare.sh +2 -10
  9. package/lib/__templates__/nextjs/scripts/validate.sh +1 -11
  10. package/lib/__templates__/nextjs/template.config.js +6 -20
  11. package/lib/__templates__/nextjs/tsconfig.json +1 -0
  12. package/lib/__templates__/nuxt-vue/.coze +1 -1
  13. package/lib/__templates__/nuxt-vue/README.md +2 -20
  14. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  15. package/lib/__templates__/nuxt-vue/scripts/dev.sh +4 -10
  16. package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +10 -178
  17. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +2 -10
  18. package/lib/__templates__/nuxt-vue/scripts/validate.sh +1 -11
  19. package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +10 -178
  20. package/lib/__templates__/vite/.coze +1 -1
  21. package/lib/__templates__/vite/README.md +0 -20
  22. package/lib/__templates__/vite/scripts/build.sh +1 -1
  23. package/lib/__templates__/vite/scripts/dev.sh +4 -10
  24. package/lib/__templates__/vite/scripts/prepare-node-modules.sh +10 -178
  25. package/lib/__templates__/vite/scripts/prepare.sh +2 -10
  26. package/lib/__templates__/vite/scripts/validate.sh +1 -7
  27. package/lib/__templates__/vite/template.config.js +6 -20
  28. package/lib/cli.js +184 -365
  29. package/package.json +1 -2
  30. package/lib/__templates__/nextjs/scripts/local-workspace.cjs +0 -302
  31. package/lib/__templates__/nuxt-vue/scripts/local-workspace.cjs +0 -302
  32. package/lib/__templates__/vite/scripts/local-workspace.cjs +0 -302
package/lib/cli.js CHANGED
@@ -16,13 +16,13 @@ var os = require('os');
16
16
  var jsYaml = require('js-yaml');
17
17
  var TOML = require('@iarna/toml');
18
18
  var crypto = require('crypto');
19
- var ejs = require('ejs');
20
19
  var fastGlob = require('fast-glob');
21
20
  var child_process = require('child_process');
22
21
  var addFormats = require('ajv-formats');
23
22
  var Ajv = require('ajv');
24
23
  var minimist = require('minimist');
25
24
  var changeCase = require('change-case');
25
+ var ejs = require('ejs');
26
26
  var node_os = require('node:os');
27
27
  var promises = require('node:fs/promises');
28
28
  var node_crypto = require('node:crypto');
@@ -1635,7 +1635,7 @@ function createNodeTransport() {
1635
1635
  };
1636
1636
  }
1637
1637
 
1638
- function _nullishCoalesce$c(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
1638
+ function _nullishCoalesce$c(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
1639
1639
  * Slardar CLI Reporter 主类
1640
1640
  * 封装 @slardar/base 的初始化和上报逻辑
1641
1641
  */
@@ -1707,7 +1707,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1707
1707
  this.client.on('send', (ev) => {
1708
1708
  log$6(
1709
1709
  'send hook called for event: %s',
1710
- (_optionalChain$H([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1710
+ (_optionalChain$G([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1711
1711
  );
1712
1712
  });
1713
1713
 
@@ -1765,7 +1765,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1765
1765
  )
1766
1766
  : undefined;
1767
1767
 
1768
- _optionalChain$H([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1768
+ _optionalChain$G([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1769
1769
  name,
1770
1770
  metrics: cleanMetrics ,
1771
1771
  categories: cleanCategories ,
@@ -1836,7 +1836,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1836
1836
  log$6('Reporting JS error:', {
1837
1837
  name: error.name,
1838
1838
  message: error.message.slice(0, 100),
1839
- stack: _optionalChain$H([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1839
+ stack: _optionalChain$G([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1840
1840
  extra,
1841
1841
  source,
1842
1842
  });
@@ -1856,7 +1856,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1856
1856
  if (!this.ensureInitialized()) {
1857
1857
  return;
1858
1858
  }
1859
- _optionalChain$H([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1859
+ _optionalChain$G([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1860
1860
  }
1861
1861
 
1862
1862
  /**
@@ -1867,7 +1867,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1867
1867
  return;
1868
1868
  }
1869
1869
  log$6('Merging context:', context);
1870
- _optionalChain$H([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1870
+ _optionalChain$G([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1871
1871
  }
1872
1872
 
1873
1873
  /**
@@ -1877,7 +1877,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1877
1877
  if (!this.ensureInitialized()) {
1878
1878
  return;
1879
1879
  }
1880
- _optionalChain$H([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1880
+ _optionalChain$G([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1881
1881
  }
1882
1882
 
1883
1883
  /**
@@ -1887,7 +1887,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1887
1887
  if (!this.ensureInitialized()) {
1888
1888
  return;
1889
1889
  }
1890
- _optionalChain$H([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1890
+ _optionalChain$G([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1891
1891
  }
1892
1892
 
1893
1893
  /**
@@ -1924,7 +1924,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1924
1924
  return;
1925
1925
  }
1926
1926
  log$6('Flushing Slardar data...');
1927
- _optionalChain$H([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1927
+ _optionalChain$G([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1928
1928
  log$6('Waiting %dms for events to be sent...', waitMs);
1929
1929
  await new Promise(resolve => setTimeout(resolve, waitMs));
1930
1930
  log$6('Slardar data flushed');
@@ -1943,7 +1943,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1943
1943
  */
1944
1944
  const reporter = new SlardarCLIReporter();
1945
1945
 
1946
- 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; }
1946
+ 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; }
1947
1947
 
1948
1948
 
1949
1949
 
@@ -2003,11 +2003,11 @@ const EventBuilder = {
2003
2003
  name: CLI_EVENTS.CLI_COMMAND,
2004
2004
  categories: {
2005
2005
  command,
2006
- args: _optionalChain$G([options, 'optionalAccess', _ => _.args]),
2006
+ args: _optionalChain$F([options, 'optionalAccess', _ => _.args]),
2007
2007
  status: 'running' ,
2008
- ..._optionalChain$G([options, 'optionalAccess', _2 => _2.categories]),
2008
+ ..._optionalChain$F([options, 'optionalAccess', _2 => _2.categories]),
2009
2009
  },
2010
- metrics: _optionalChain$G([options, 'optionalAccess', _3 => _3.metrics]),
2010
+ metrics: _optionalChain$F([options, 'optionalAccess', _3 => _3.metrics]),
2011
2011
  };
2012
2012
  },
2013
2013
 
@@ -2028,13 +2028,13 @@ const EventBuilder = {
2028
2028
  name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
2029
2029
  categories: {
2030
2030
  command,
2031
- args: _optionalChain$G([options, 'optionalAccess', _4 => _4.args]),
2031
+ args: _optionalChain$F([options, 'optionalAccess', _4 => _4.args]),
2032
2032
  status: success ? ('success' ) : ('fail' ),
2033
- ..._optionalChain$G([options, 'optionalAccess', _5 => _5.categories]),
2033
+ ..._optionalChain$F([options, 'optionalAccess', _5 => _5.categories]),
2034
2034
  },
2035
2035
  metrics: {
2036
2036
  duration,
2037
- ...(_optionalChain$G([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2037
+ ...(_optionalChain$F([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2038
2038
  },
2039
2039
  };
2040
2040
  },
@@ -2055,12 +2055,12 @@ const EventBuilder = {
2055
2055
  name: CLI_EVENTS.NETWORK_REQUEST,
2056
2056
  categories: {
2057
2057
  url,
2058
- method: _optionalChain$G([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2059
- statusCode: _optionalChain$G([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2060
- status: _optionalChain$G([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2058
+ method: _optionalChain$F([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2059
+ statusCode: _optionalChain$F([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2060
+ status: _optionalChain$F([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2061
2061
  },
2062
2062
  metrics: {
2063
- duration: _optionalChain$G([options, 'optionalAccess', _12 => _12.duration]),
2063
+ duration: _optionalChain$F([options, 'optionalAccess', _12 => _12.duration]),
2064
2064
  },
2065
2065
  };
2066
2066
  },
@@ -2082,11 +2082,11 @@ const EventBuilder = {
2082
2082
  categories: {
2083
2083
  operation,
2084
2084
  filePath,
2085
- status: _optionalChain$G([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2085
+ status: _optionalChain$F([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2086
2086
  },
2087
2087
  metrics: {
2088
- duration: _optionalChain$G([options, 'optionalAccess', _14 => _14.duration]),
2089
- fileSize: _optionalChain$G([options, 'optionalAccess', _15 => _15.fileSize]),
2088
+ duration: _optionalChain$F([options, 'optionalAccess', _14 => _14.duration]),
2089
+ fileSize: _optionalChain$F([options, 'optionalAccess', _15 => _15.fileSize]),
2090
2090
  },
2091
2091
  };
2092
2092
  },
@@ -2114,7 +2114,7 @@ const EventBuilder = {
2114
2114
  };
2115
2115
 
2116
2116
  var name = "@coze-arch/cli";
2117
- var version = "0.1.8-alpha.e237ba";
2117
+ var version = "0.1.8";
2118
2118
  var description = "coze coding devtools cli";
2119
2119
  var license = "MIT";
2120
2120
  var author = "fanwenjie.fe@bytedance.com";
@@ -2148,7 +2148,6 @@ var scripts = {
2148
2148
  "test:all": "bash scripts/test-coverage.sh",
2149
2149
  "test:cov": "vitest --run --passWithNoTests --coverage",
2150
2150
  "test:e2e": "NODE_ENV=test bash scripts/e2e.sh",
2151
- "test:integration:web": "node --test __tests__/integration/local-workspace.test.cjs",
2152
2151
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
2153
2152
  "test:perf:compare": "bash scripts/compare-perf.sh",
2154
2153
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -2226,7 +2225,7 @@ var packageJson = {
2226
2225
  cozePublishConfig: cozePublishConfig
2227
2226
  };
2228
2227
 
2229
- 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; }/**
2228
+ 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; }/**
2230
2229
  * Slardar 监控初始化和上报
2231
2230
  */
2232
2231
 
@@ -2329,11 +2328,11 @@ const reportCommandComplete = safeRun(
2329
2328
  ,
2330
2329
  ) => {
2331
2330
  const event = EventBuilder.cliCommandComplete(command, success, duration, {
2332
- args: _optionalChain$F([options, 'optionalAccess', _ => _.args]),
2333
- errorCode: _optionalChain$F([options, 'optionalAccess', _2 => _2.errorCode]),
2331
+ args: _optionalChain$E([options, 'optionalAccess', _ => _.args]),
2332
+ errorCode: _optionalChain$E([options, 'optionalAccess', _2 => _2.errorCode]),
2334
2333
  categories: {
2335
- ...(_optionalChain$F([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2336
- ..._optionalChain$F([options, 'optionalAccess', _4 => _4.categories]),
2334
+ ...(_optionalChain$E([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2335
+ ..._optionalChain$E([options, 'optionalAccess', _4 => _4.categories]),
2337
2336
  },
2338
2337
  });
2339
2338
  reporter.sendEvent(event.name, event.metrics, event.categories);
@@ -2392,7 +2391,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2392
2391
  await reporter.flush();
2393
2392
  });
2394
2393
 
2395
- function _nullishCoalesce$b(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; }var LogLevel; (function (LogLevel) {
2394
+ function _nullishCoalesce$b(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; }var LogLevel; (function (LogLevel) {
2396
2395
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2397
2396
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2398
2397
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2439,7 +2438,7 @@ class Logger {
2439
2438
  return level;
2440
2439
  }
2441
2440
 
2442
- const envLevel = _optionalChain$E([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2441
+ const envLevel = _optionalChain$D([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2443
2442
  if (envLevel && envLevel in LOG_LEVEL_MAP) {
2444
2443
  // envLevel 已通过 `in` 检查确认为 LOG_LEVEL_MAP 的键;
2445
2444
  // 显式判空以满足 noUncheckedIndexedAccess,运行时行为不变
@@ -2456,7 +2455,7 @@ class Logger {
2456
2455
  // 简单检测:Node.js 环境且支持 TTY
2457
2456
  return (
2458
2457
  typeof process !== 'undefined' &&
2459
- _optionalChain$E([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2458
+ _optionalChain$D([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2460
2459
  process.env.NO_COLOR === undefined
2461
2460
  );
2462
2461
  }
@@ -3264,7 +3263,7 @@ const registerCommand$6 = program => {
3264
3263
  });
3265
3264
  };
3266
3265
 
3267
- 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; }// Safe JSON parsing utilities with type safety and error handling
3266
+ 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; }// Safe JSON parsing utilities with type safety and error handling
3268
3267
  // Provides fallback values, validation, and error monitoring capabilities
3269
3268
 
3270
3269
  /**
@@ -3364,12 +3363,12 @@ function safeJsonParse(
3364
3363
  const parsed = JSON.parse(String(input));
3365
3364
 
3366
3365
  // Optional validation
3367
- if (_optionalChain$D([options, 'optionalAccess', _ => _.validate])) {
3366
+ if (_optionalChain$C([options, 'optionalAccess', _ => _.validate])) {
3368
3367
  if (options.validate(parsed)) {
3369
3368
  return parsed;
3370
3369
  } else {
3371
3370
  const validationError = new Error('JSON validation failed');
3372
- _optionalChain$D([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3371
+ _optionalChain$C([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3373
3372
 
3374
3373
  if (options.throwOnValidationError) {
3375
3374
  throw validationError;
@@ -3381,10 +3380,10 @@ function safeJsonParse(
3381
3380
  return parsed;
3382
3381
  } catch (error) {
3383
3382
  // Re-throw validation errors when throwOnValidationError is true
3384
- if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$D([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3383
+ if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$C([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3385
3384
  throw error;
3386
3385
  }
3387
- _optionalChain$D([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3386
+ _optionalChain$C([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3388
3387
  return defaultValue;
3389
3388
  }
3390
3389
  }
@@ -3424,7 +3423,7 @@ function isNode(node) {
3424
3423
  }
3425
3424
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3426
3425
 
3427
- 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; }
3426
+ 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; }
3428
3427
  const BREAK = Symbol('break visit');
3429
3428
  const SKIP = Symbol('skip children');
3430
3429
  const REMOVE = Symbol('remove node');
@@ -3537,15 +3536,15 @@ function callVisitor(key, node, visitor, path) {
3537
3536
  if (typeof visitor === 'function')
3538
3537
  return visitor(key, node, path);
3539
3538
  if (isMap(node))
3540
- return _optionalChain$C([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3539
+ return _optionalChain$B([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3541
3540
  if (isSeq(node))
3542
- return _optionalChain$C([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3541
+ return _optionalChain$B([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3543
3542
  if (isPair(node))
3544
- return _optionalChain$C([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3543
+ return _optionalChain$B([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3545
3544
  if (isScalar(node))
3546
- return _optionalChain$C([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3545
+ return _optionalChain$B([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3547
3546
  if (isAlias(node))
3548
- return _optionalChain$C([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3547
+ return _optionalChain$B([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3549
3548
  return undefined;
3550
3549
  }
3551
3550
  function replaceNode(key, path, node) {
@@ -3636,7 +3635,7 @@ function applyReviver(reviver, obj, key, val) {
3636
3635
  return reviver.call(obj, key, val);
3637
3636
  }
3638
3637
 
3639
- 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; }
3638
+ 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; }
3640
3639
  /**
3641
3640
  * Recursively convert any node or its contents to native JavaScript
3642
3641
  *
@@ -3666,7 +3665,7 @@ function toJS(value, arg, ctx) {
3666
3665
  ctx.onCreate(res);
3667
3666
  return res;
3668
3667
  }
3669
- if (typeof value === 'bigint' && !_optionalChain$B([ctx, 'optionalAccess', _ => _.keep]))
3668
+ if (typeof value === 'bigint' && !_optionalChain$A([ctx, 'optionalAccess', _ => _.keep]))
3670
3669
  return Number(value);
3671
3670
  return value;
3672
3671
  }
@@ -3704,7 +3703,7 @@ class NodeBase {
3704
3703
  }
3705
3704
  }
3706
3705
 
3707
- 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; }
3706
+ 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; }
3708
3707
  class Alias extends NodeBase {
3709
3708
  constructor(source) {
3710
3709
  super(ALIAS);
@@ -3720,10 +3719,10 @@ class Alias extends NodeBase {
3720
3719
  * instance of the `source` anchor before this node.
3721
3720
  */
3722
3721
  resolve(doc, ctx) {
3723
- if (_optionalChain$A([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3722
+ if (_optionalChain$z([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3724
3723
  throw new ReferenceError('Alias resolution is disabled');
3725
3724
  let nodes;
3726
- if (_optionalChain$A([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3725
+ if (_optionalChain$z([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3727
3726
  nodes = ctx.aliasResolveCache;
3728
3727
  }
3729
3728
  else {
@@ -3762,7 +3761,7 @@ class Alias extends NodeBase {
3762
3761
  data = anchors.get(source);
3763
3762
  }
3764
3763
  /* istanbul ignore if */
3765
- if (_optionalChain$A([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3764
+ if (_optionalChain$z([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3766
3765
  const msg = 'This should not happen: Alias anchor was not resolved?';
3767
3766
  throw new ReferenceError(msg);
3768
3767
  }
@@ -3814,7 +3813,7 @@ function getAliasCount(doc, node, anchors) {
3814
3813
  return 1;
3815
3814
  }
3816
3815
 
3817
- 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; }
3816
+ 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; }
3818
3817
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3819
3818
  class Scalar extends NodeBase {
3820
3819
  constructor(value) {
@@ -3822,7 +3821,7 @@ class Scalar extends NodeBase {
3822
3821
  this.value = value;
3823
3822
  }
3824
3823
  toJSON(arg, ctx) {
3825
- return _optionalChain$z([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3824
+ return _optionalChain$y([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3826
3825
  }
3827
3826
  toString() {
3828
3827
  return String(this.value);
@@ -3834,7 +3833,7 @@ Scalar.PLAIN = 'PLAIN';
3834
3833
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3835
3834
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3836
3835
 
3837
- function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
3836
+ function _nullishCoalesce$a(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
3838
3837
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3839
3838
  function findTagObject(value, tagName, tags) {
3840
3839
  if (tagName) {
@@ -3844,7 +3843,7 @@ function findTagObject(value, tagName, tags) {
3844
3843
  throw new Error(`Tag ${tagName} not found`);
3845
3844
  return tagObj;
3846
3845
  }
3847
- return tags.find(t => _optionalChain$y([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3846
+ return tags.find(t => _optionalChain$x([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3848
3847
  }
3849
3848
  function createNode(value, tagName, ctx) {
3850
3849
  if (isDocument(value))
@@ -3852,7 +3851,7 @@ function createNode(value, tagName, ctx) {
3852
3851
  if (isNode(value))
3853
3852
  return value;
3854
3853
  if (isPair(value)) {
3855
- const map = _optionalChain$y([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3854
+ const map = _optionalChain$x([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3856
3855
  map.items.push(value);
3857
3856
  return map;
3858
3857
  }
@@ -3879,7 +3878,7 @@ function createNode(value, tagName, ctx) {
3879
3878
  sourceObjects.set(value, ref);
3880
3879
  }
3881
3880
  }
3882
- if (_optionalChain$y([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3881
+ if (_optionalChain$x([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3883
3882
  tagName = defaultTagPrefix + tagName.slice(2);
3884
3883
  let tagObj = findTagObject(value, tagName, schema.tags);
3885
3884
  if (!tagObj) {
@@ -3904,9 +3903,9 @@ function createNode(value, tagName, ctx) {
3904
3903
  onTagObj(tagObj);
3905
3904
  delete ctx.onTagObj;
3906
3905
  }
3907
- const node = _optionalChain$y([tagObj, 'optionalAccess', _9 => _9.createNode])
3906
+ const node = _optionalChain$x([tagObj, 'optionalAccess', _9 => _9.createNode])
3908
3907
  ? tagObj.createNode(ctx.schema, value, ctx)
3909
- : typeof _optionalChain$y([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3908
+ : typeof _optionalChain$x([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3910
3909
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
3911
3910
  : new Scalar(value);
3912
3911
  if (tagName)
@@ -4224,7 +4223,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4224
4223
  return end;
4225
4224
  }
4226
4225
 
4227
- 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; }
4226
+ 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; }
4228
4227
  const getFoldOptions = (ctx, isBlock) => ({
4229
4228
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4230
4229
  lineWidth: ctx.options.lineWidth,
@@ -4509,9 +4508,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4509
4508
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4510
4509
  // and others in v1.1.
4511
4510
  if (actualString) {
4512
- const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$x([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4511
+ const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$w([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4513
4512
  const { compat, tags } = ctx.doc.schema;
4514
- if (tags.some(test) || _optionalChain$x([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4513
+ if (tags.some(test) || _optionalChain$w([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4515
4514
  return quotedString(value, ctx);
4516
4515
  }
4517
4516
  return implicitKey
@@ -4557,7 +4556,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4557
4556
  return res;
4558
4557
  }
4559
4558
 
4560
- function _nullishCoalesce$9(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; }
4559
+ function _nullishCoalesce$9(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; }
4561
4560
  function createStringifyContext(doc, options) {
4562
4561
  const opt = Object.assign({
4563
4562
  blockQuote: true,
@@ -4610,7 +4609,7 @@ function getTagObject(tags, item) {
4610
4609
  let obj;
4611
4610
  if (isScalar(item)) {
4612
4611
  obj = item.value;
4613
- let match = tags.filter(t => _optionalChain$w([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4612
+ let match = tags.filter(t => _optionalChain$v([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4614
4613
  if (match.length > 1) {
4615
4614
  const testMatch = match.filter(t => t.test);
4616
4615
  if (testMatch.length > 0)
@@ -4624,7 +4623,7 @@ function getTagObject(tags, item) {
4624
4623
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4625
4624
  }
4626
4625
  if (!tagObj) {
4627
- const name = _nullishCoalesce$9(_optionalChain$w([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4626
+ const name = _nullishCoalesce$9(_optionalChain$v([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4628
4627
  throw new Error(`Tag not resolved for ${name} value`);
4629
4628
  }
4630
4629
  return tagObj;
@@ -4650,7 +4649,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4650
4649
  if (isAlias(item)) {
4651
4650
  if (ctx.doc.directives)
4652
4651
  return item.toString(ctx);
4653
- if (_optionalChain$w([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4652
+ if (_optionalChain$v([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4654
4653
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4655
4654
  }
4656
4655
  else {
@@ -4832,7 +4831,7 @@ function warn(logLevel, warning) {
4832
4831
  }
4833
4832
  }
4834
4833
 
4835
- 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; }
4834
+ 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; }
4836
4835
  // If the value associated with a merge key is a single mapping node, each of
4837
4836
  // its key/value pairs is inserted into the current mapping, unless the key
4838
4837
  // already exists in it. If the value associated with the merge key is a
@@ -4856,7 +4855,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4856
4855
  (isScalar(key) &&
4857
4856
  (!key.type || key.type === Scalar.PLAIN) &&
4858
4857
  merge.identify(key.value))) &&
4859
- _optionalChain$v([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)]);
4858
+ _optionalChain$u([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)]);
4860
4859
  function addMergeToJSMap(ctx, map, value) {
4861
4860
  const source = resolveAliasValue(ctx, value);
4862
4861
  if (isSeq(source))
@@ -4896,7 +4895,7 @@ function resolveAliasValue(ctx, value) {
4896
4895
  return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
4897
4896
  }
4898
4897
 
4899
- 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; }
4898
+ 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; }
4900
4899
  function addPairToJSMap(ctx, map, { key, value }) {
4901
4900
  if (isNode(key) && key.addToJSMap)
4902
4901
  key.addToJSMap(ctx, map, value);
@@ -4933,7 +4932,7 @@ function stringifyKey(key, jsKey, ctx) {
4933
4932
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
4934
4933
  if (typeof jsKey !== 'object')
4935
4934
  return String(jsKey);
4936
- if (isNode(key) && _optionalChain$u([ctx, 'optionalAccess', _ => _.doc])) {
4935
+ if (isNode(key) && _optionalChain$t([ctx, 'optionalAccess', _ => _.doc])) {
4937
4936
  const strCtx = createStringifyContext(ctx.doc, {});
4938
4937
  strCtx.anchors = new Set();
4939
4938
  for (const node of ctx.anchors.keys())
@@ -4953,7 +4952,7 @@ function stringifyKey(key, jsKey, ctx) {
4953
4952
  return JSON.stringify(jsKey);
4954
4953
  }
4955
4954
 
4956
- 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; }
4955
+ 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; }
4957
4956
  function createPair(key, value, ctx) {
4958
4957
  const k = createNode(key, undefined, ctx);
4959
4958
  const v = createNode(value, undefined, ctx);
@@ -4974,17 +4973,17 @@ class Pair {
4974
4973
  return new Pair(key, value);
4975
4974
  }
4976
4975
  toJSON(_, ctx) {
4977
- const pair = _optionalChain$t([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4976
+ const pair = _optionalChain$s([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4978
4977
  return addPairToJSMap(ctx, pair, this);
4979
4978
  }
4980
4979
  toString(ctx, onComment, onChompKeep) {
4981
- return _optionalChain$t([ctx, 'optionalAccess', _3 => _3.doc])
4980
+ return _optionalChain$s([ctx, 'optionalAccess', _3 => _3.doc])
4982
4981
  ? stringifyPair(this, ctx, onComment, onChompKeep)
4983
4982
  : JSON.stringify(this);
4984
4983
  }
4985
4984
  }
4986
4985
 
4987
- function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
4986
+ function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4988
4987
  function stringifyCollection(collection, ctx, options) {
4989
4988
  const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
4990
4989
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
@@ -5078,7 +5077,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5078
5077
  if (iv.commentBefore)
5079
5078
  reqNewline = true;
5080
5079
  }
5081
- else if (item.value == null && _optionalChain$s([ik, 'optionalAccess', _ => _.comment])) {
5080
+ else if (item.value == null && _optionalChain$r([ik, 'optionalAccess', _ => _.comment])) {
5082
5081
  comment = ik.comment;
5083
5082
  }
5084
5083
  }
@@ -5133,7 +5132,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5133
5132
  }
5134
5133
  }
5135
5134
 
5136
- function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$r(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5135
+ function _nullishCoalesce$6(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; }
5137
5136
  function findPair(items, key) {
5138
5137
  const k = isScalar(key) ? key.value : key;
5139
5138
  for (const it of items) {
@@ -5194,12 +5193,12 @@ class YAMLMap extends Collection {
5194
5193
  _pair = pair;
5195
5194
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5196
5195
  // In TypeScript, this never happens.
5197
- _pair = new Pair(pair, _optionalChain$r([pair, 'optionalAccess', _2 => _2.value]));
5196
+ _pair = new Pair(pair, _optionalChain$q([pair, 'optionalAccess', _2 => _2.value]));
5198
5197
  }
5199
5198
  else
5200
5199
  _pair = new Pair(pair.key, pair.value);
5201
5200
  const prev = findPair(this.items, _pair.key);
5202
- const sortEntries = _optionalChain$r([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5201
+ const sortEntries = _optionalChain$q([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5203
5202
  if (prev) {
5204
5203
  if (!overwrite)
5205
5204
  throw new Error(`Key ${_pair.key} already set`);
@@ -5229,7 +5228,7 @@ class YAMLMap extends Collection {
5229
5228
  }
5230
5229
  get(key, keepScalar) {
5231
5230
  const it = findPair(this.items, key);
5232
- const node = _optionalChain$r([it, 'optionalAccess', _5 => _5.value]);
5231
+ const node = _optionalChain$q([it, 'optionalAccess', _5 => _5.value]);
5233
5232
  return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5234
5233
  }
5235
5234
  has(key) {
@@ -5244,8 +5243,8 @@ class YAMLMap extends Collection {
5244
5243
  * @returns Instance of Type, Map, or Object
5245
5244
  */
5246
5245
  toJSON(_, ctx, Type) {
5247
- const map = Type ? new Type() : _optionalChain$r([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5248
- if (_optionalChain$r([ctx, 'optionalAccess', _7 => _7.onCreate]))
5246
+ const map = Type ? new Type() : _optionalChain$q([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5247
+ if (_optionalChain$q([ctx, 'optionalAccess', _7 => _7.onCreate]))
5249
5248
  ctx.onCreate(map);
5250
5249
  for (const item of this.items)
5251
5250
  addPairToJSMap(ctx, map, item);
@@ -5270,7 +5269,7 @@ class YAMLMap extends Collection {
5270
5269
  }
5271
5270
  }
5272
5271
 
5273
- 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; }
5272
+ 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; }
5274
5273
  class YAMLSeq extends Collection {
5275
5274
  static get tagName() {
5276
5275
  return 'tag:yaml.org,2002:seq';
@@ -5333,7 +5332,7 @@ class YAMLSeq extends Collection {
5333
5332
  }
5334
5333
  toJSON(_, ctx) {
5335
5334
  const seq = [];
5336
- if (_optionalChain$q([ctx, 'optionalAccess', _2 => _2.onCreate]))
5335
+ if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
5337
5336
  ctx.onCreate(seq);
5338
5337
  let i = 0;
5339
5338
  for (const item of this.items)
@@ -5412,7 +5411,7 @@ function createPairs(schema, iterable, ctx) {
5412
5411
  return pairs;
5413
5412
  }
5414
5413
 
5415
- 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; }
5414
+ 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; }
5416
5415
  class YAMLOMap extends YAMLSeq {
5417
5416
  constructor() {
5418
5417
  super();
@@ -5431,7 +5430,7 @@ class YAMLOMap extends YAMLSeq {
5431
5430
  if (!ctx)
5432
5431
  return super.toJSON(_);
5433
5432
  const map = new Map();
5434
- if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
5433
+ if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.onCreate]))
5435
5434
  ctx.onCreate(map);
5436
5435
  for (const pair of this.items) {
5437
5436
  let key, value;
@@ -5549,7 +5548,7 @@ const isDirExists = async (file) => {
5549
5548
  }
5550
5549
  };
5551
5550
 
5552
- 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; }// ABOUTME: Project type detection utility
5551
+ 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; }// ABOUTME: Project type detection utility
5553
5552
 
5554
5553
  /**
5555
5554
  * 支持的项目类型枚举
@@ -5651,7 +5650,7 @@ const collectProjectInfo = async (
5651
5650
  }
5652
5651
 
5653
5652
  const scripts = Object.entries(
5654
- (_optionalChain$o([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5653
+ (_optionalChain$n([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5655
5654
  ).reduce((acc, [name, script]) => {
5656
5655
  if (typeof script === 'string') {
5657
5656
  acc[name] = script;
@@ -5805,7 +5804,7 @@ const detectProjectType = async (
5805
5804
  };
5806
5805
  };
5807
5806
 
5808
- 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; }
5807
+ 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; }
5809
5808
 
5810
5809
 
5811
5810
  /**
@@ -5972,13 +5971,13 @@ const getDefaultCommandConfig = (
5972
5971
  ) => {
5973
5972
  switch (commandName) {
5974
5973
  case 'dev':
5975
- return _optionalChain$n([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5974
+ return _optionalChain$m([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5976
5975
  case 'build':
5977
- return _optionalChain$n([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5976
+ return _optionalChain$m([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5978
5977
  case 'start':
5979
- return _optionalChain$n([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5978
+ return _optionalChain$m([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5980
5979
  case 'validate':
5981
- return _optionalChain$n([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5980
+ return _optionalChain$m([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5982
5981
  default:
5983
5982
  throw new Error(`Unknown command: ${commandName}`);
5984
5983
  }
@@ -5990,13 +5989,13 @@ const getWindowsCommandConfig = (
5990
5989
  ) => {
5991
5990
  switch (commandName) {
5992
5991
  case 'dev':
5993
- return _optionalChain$n([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
5992
+ return _optionalChain$m([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
5994
5993
  case 'build':
5995
- return _optionalChain$n([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
5994
+ return _optionalChain$m([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
5996
5995
  case 'start':
5997
- return _optionalChain$n([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
5996
+ return _optionalChain$m([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
5998
5997
  case 'validate':
5999
- return _optionalChain$n([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
5998
+ return _optionalChain$m([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
6000
5999
  default:
6001
6000
  throw new Error(`Unknown command: ${commandName}`);
6002
6001
  }
@@ -6021,7 +6020,7 @@ const getCommandConfig = (
6021
6020
  platform === 'win32'
6022
6021
  ? getWindowsCommandConfig(config, commandName)
6023
6022
  : undefined;
6024
- const commandConfig = _optionalChain$n([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
6023
+ const commandConfig = _optionalChain$m([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
6025
6024
  ? windowsCommandConfig
6026
6025
  : defaultCommandConfig;
6027
6026
 
@@ -6170,273 +6169,6 @@ const byFlag = (flag) => {
6170
6169
  return predicate;
6171
6170
  };
6172
6171
 
6173
- /**
6174
- * 渲染 EJS 模板文件
6175
- *
6176
- * @param filePath - 模板文件路径
6177
- * @param context - 模板上下文
6178
- * @returns 渲染后的内容
6179
- */
6180
- const renderTemplate = async (filePath, context) => {
6181
- const content = await fs$1.readFile(filePath, 'utf-8');
6182
-
6183
- try {
6184
- return ejs.render(content, context, {
6185
- filename: filePath,
6186
- });
6187
- } catch (error) {
6188
- throw new Error(`Failed to render template ${filePath}:\n${error instanceof Error ? error.message : String(error)}`);
6189
- }
6190
- };
6191
-
6192
- /**
6193
- * 判断文件是否需要渲染(是否为文本文件)
6194
- *
6195
- * @param filePath - 文件路径
6196
- * @returns 是否需要渲染
6197
- */
6198
- const shouldRenderFile = (filePath) => {
6199
- const textExtensions = new Set([
6200
- '.js',
6201
- '.ts',
6202
- '.jsx',
6203
- '.tsx',
6204
- '.json',
6205
- '.css',
6206
- '.scss',
6207
- '.sass',
6208
- '.less',
6209
- '.html',
6210
- '.md',
6211
- '.txt',
6212
- '.yaml',
6213
- '.yml',
6214
- '.xml',
6215
- '.svg',
6216
- '.env',
6217
- '.gitignore',
6218
- '.npmrc',
6219
- '.eslintrc',
6220
- '.prettierrc',
6221
- '.babelrc',
6222
- '.sh',
6223
- '.ps1',
6224
- ]);
6225
-
6226
- const ext = path.extname(filePath).toLowerCase();
6227
-
6228
- // 没有扩展名的文件(如 .coze)也尝试渲染
6229
- if (ext === '') {
6230
- return true;
6231
- }
6232
-
6233
- return textExtensions.has(ext);
6234
- };
6235
-
6236
- /**
6237
- * 判断文件是否应该被忽略(不复制到目标目录)
6238
- *
6239
- * @param filePath - 文件路径
6240
- * @returns 是否应该忽略
6241
- */
6242
- const shouldIgnoreFile = (filePath) => {
6243
- const fileName = path.basename(filePath);
6244
- const pathParts = filePath.split(/[\\/]+/);
6245
-
6246
- // 精确匹配的文件名
6247
- const exactMatch = ['template.config.ts', 'template.config.js', '.DS_Store'];
6248
-
6249
- // 目录名(需要检查路径中是否包含)
6250
- const directoryPatterns = ['node_modules', 'node-compile-cache'];
6251
-
6252
- // 检查精确匹配
6253
- if (exactMatch.includes(fileName)) {
6254
- return true;
6255
- }
6256
-
6257
- // 检查路径中是否包含需要忽略的目录
6258
- return directoryPatterns.some(dir => pathParts.includes(dir));
6259
- };
6260
-
6261
- 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; }
6262
-
6263
- const ACTIONS = ['prepare', 'dev', 'validate'] ;
6264
-
6265
-
6266
- const HELPER = 'local-workspace.cjs';
6267
- // Fingerprints of the previous template wrappers, rendered with port=5000.
6268
- // Match the entire file, not a substring: custom development steps must survive.
6269
- const LEGACY = {
6270
- vite: {
6271
- prepare: [
6272
- '743e5346701008f25d33389fa52b701037176bb88b1d246962268a27e615c046',
6273
- ],
6274
- dev: [
6275
- 'f5fa043f6b639b0eb782bf525b0dc7891d90f63c869c541e3dea54d3511a4164',
6276
- '9dbe702d1139fad8bf5870ef213833af42f54c81372da0faf5accb1c55cfce1b',
6277
- ],
6278
- validate: [
6279
- 'e27c7e3457b503514da88ec708149cb58a4488ee72f300bb5925cc396e120628',
6280
- ],
6281
- },
6282
- nextjs: {
6283
- prepare: [
6284
- '743e5346701008f25d33389fa52b701037176bb88b1d246962268a27e615c046',
6285
- ],
6286
- dev: [
6287
- '9ad0ff1c512d89085d357bffabb112b8629697821e44e2302b4831eb1f39dadc',
6288
- '5d0f939b9b9ede64ddeb1ed3527471f0e2581a29c892acadc0b800240f7a7803',
6289
- ],
6290
- validate: [
6291
- 'e27c7e3457b503514da88ec708149cb58a4488ee72f300bb5925cc396e120628',
6292
- ],
6293
- },
6294
- 'nuxt-vue': {
6295
- prepare: [
6296
- '992feb1f1bfc879c55dbc409ec057d31f905e3c6e4aee855cb361fe3ca7e0980',
6297
- ],
6298
- dev: [
6299
- '2fca7965cb46c07173f7b30be5ec9aa1bbbb303e5c4fc4424f676ea32942f58c',
6300
- '2a77aeb2201960659892e515c550754504a5d97187ae70c5edf84b464806e70b',
6301
- ],
6302
- validate: [
6303
- 'e27c7e3457b503514da88ec708149cb58a4488ee72f300bb5925cc396e120628',
6304
- ],
6305
- },
6306
- };
6307
-
6308
-
6309
-
6310
-
6311
-
6312
-
6313
- const planUpgrade = async (
6314
- context,
6315
- template,
6316
- ) => {
6317
- const config = context.cozeConfig;
6318
- const commands = [
6319
- [_optionalChain$m([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.build]), 'prepare'],
6320
- [_optionalChain$m([config, 'access', _3 => _3.dev, 'optionalAccess', _4 => _4.run]), 'dev'],
6321
- [_optionalChain$m([config, 'access', _5 => _5.dev, 'optionalAccess', _6 => _6.validate]), 'validate'],
6322
- ] ;
6323
- if (
6324
- commands.some(
6325
- ([argv, action]) =>
6326
- !Array.isArray(argv) || argv.length !== 2 || argv[0] !== 'bash' ||
6327
- argv[1] !== `./scripts/${action}.sh`,
6328
- )
6329
- ) {
6330
- return null;
6331
- }
6332
-
6333
- const scripts = new Map();
6334
- let port;
6335
- for (const action of ACTIONS) {
6336
- const file = path.join(context.projectFolder, 'scripts', `${action}.sh`);
6337
- try {
6338
- if (!(await fs$1.lstat(file)).isFile()) return null;
6339
- const text = await fs$1.readFile(file, 'utf8');
6340
- const match = text.match(/^PORT=[^\n]*?(\d{2,5})/m);
6341
- if (match) {
6342
- const value = Number(match[1]);
6343
- if (value < 1024 || value > 65535 || (port !== undefined && value !== port)) {
6344
- return null;
6345
- }
6346
- port = value;
6347
- }
6348
- const normalized = text.replace(/^PORT=[^\n]+/gm, line =>
6349
- line.replace(/\d+/g, '5000'),
6350
- );
6351
- const hash = crypto.createHash('sha256').update(normalized).digest('hex');
6352
- if (!LEGACY[template][action].includes(hash)) return null;
6353
- scripts.set(action, text);
6354
- } catch (error) {
6355
- if ((error ).code === 'ENOENT') return null;
6356
- throw error;
6357
- }
6358
- }
6359
- // Never overwrite a user-owned helper at the same path.
6360
- try {
6361
- await fs$1.lstat(path.join(context.projectFolder, 'scripts', HELPER));
6362
- return null;
6363
- } catch (error) {
6364
- if ((error ).code !== 'ENOENT') throw error;
6365
- }
6366
- return port === undefined ? null : { port, scripts };
6367
- };
6368
-
6369
- const createPatch = (template) => ({
6370
- id: `${template}/local-workspace@1`,
6371
- template,
6372
- operations: [
6373
- {
6374
- kind: 'create-file',
6375
- file: `scripts/${HELPER}`,
6376
- description: 'Add local rsync execution for cloud Web development',
6377
- },
6378
- ...ACTIONS.map(action => ({
6379
- kind: 'file-patch' ,
6380
- file: `scripts/${action}.sh`,
6381
- description: 'Upgrade only unchanged template wrappers; preserve configured port',
6382
- })),
6383
- {
6384
- kind: 'file-patch',
6385
- file: '.coze',
6386
- description: 'Declare rsync for Web development',
6387
- },
6388
- ],
6389
- shouldApply: async context => (await planUpgrade(context, template)) !== null,
6390
- apply: async context => {
6391
- const patchId = `${template}/local-workspace@1`;
6392
- const plan = await planUpgrade(context, template);
6393
- if (!plan) {
6394
- return {
6395
- applied: false, patchId,
6396
- message: 'Custom or unsupported Web wrappers; no files replaced',
6397
- };
6398
- }
6399
- const target = path.join(context.projectFolder, 'scripts');
6400
- const origin = path.join(getTemplatesDir(), template, 'scripts');
6401
- // Render everything before the first write. No business source or user config changes.
6402
- const replacements = new Map();
6403
- replacements.set(HELPER, await fs$1.readFile(path.join(origin, HELPER), 'utf8'));
6404
- for (const action of ACTIONS) {
6405
- replacements.set(
6406
- `${action}.sh`,
6407
- await renderTemplate(path.join(origin, `${action}.sh`), { port: plan.port }),
6408
- );
6409
- }
6410
- try {
6411
- for (const [name, content] of replacements) {
6412
- const temp = path.join(target, `.${name}.${process.pid}.tmp`);
6413
- try {
6414
- await fs$1.writeFile(temp, content, { encoding: 'utf8', mode: 0o755 });
6415
- await fs$1.rename(temp, path.join(target, name));
6416
- } finally {
6417
- await fs$1.rm(temp, { force: true });
6418
- }
6419
- }
6420
- } catch (error) {
6421
- for (const [action, content] of plan.scripts) {
6422
- await fs$1.writeFile(path.join(target, `${action}.sh`), content, 'utf8');
6423
- }
6424
- await fs$1.rm(path.join(target, HELPER), { force: true });
6425
- throw error;
6426
- }
6427
- const dev = context.cozeConfig.dev;
6428
- if (dev) dev.deps = [...new Set([...(dev.deps || []), 'rsync'])];
6429
- return {
6430
- applied: true, patchId,
6431
- message: 'Web development wrappers now sync Drive source and execute on local disk',
6432
- };
6433
- },
6434
- });
6435
-
6436
- const webLocalWorkspacePatches = (
6437
- ['vite', 'nextjs', 'nuxt-vue']
6438
- ).map(createPatch);
6439
-
6440
6172
  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; }
6441
6173
 
6442
6174
 
@@ -7708,7 +7440,6 @@ const patches = [
7708
7440
  patchTaroAgentsMd,
7709
7441
  patchTaroValidate,
7710
7442
  patchTaroPackScript,
7711
- ...webLocalWorkspacePatches,
7712
7443
  ] ;
7713
7444
 
7714
7445
  const getTemplatePatches = (
@@ -9398,6 +9129,94 @@ const parsePassThroughParams = (command, knownOptions = new Set()) => {
9398
9129
  return filtered;
9399
9130
  };
9400
9131
 
9132
+ /**
9133
+ * 渲染 EJS 模板文件
9134
+ *
9135
+ * @param filePath - 模板文件路径
9136
+ * @param context - 模板上下文
9137
+ * @returns 渲染后的内容
9138
+ */
9139
+ const renderTemplate = async (filePath, context) => {
9140
+ const content = await fs$1.readFile(filePath, 'utf-8');
9141
+
9142
+ try {
9143
+ return ejs.render(content, context, {
9144
+ filename: filePath,
9145
+ });
9146
+ } catch (error) {
9147
+ throw new Error(`Failed to render template ${filePath}:\n${error instanceof Error ? error.message : String(error)}`);
9148
+ }
9149
+ };
9150
+
9151
+ /**
9152
+ * 判断文件是否需要渲染(是否为文本文件)
9153
+ *
9154
+ * @param filePath - 文件路径
9155
+ * @returns 是否需要渲染
9156
+ */
9157
+ const shouldRenderFile = (filePath) => {
9158
+ const textExtensions = new Set([
9159
+ '.js',
9160
+ '.ts',
9161
+ '.jsx',
9162
+ '.tsx',
9163
+ '.json',
9164
+ '.css',
9165
+ '.scss',
9166
+ '.sass',
9167
+ '.less',
9168
+ '.html',
9169
+ '.md',
9170
+ '.txt',
9171
+ '.yaml',
9172
+ '.yml',
9173
+ '.xml',
9174
+ '.svg',
9175
+ '.env',
9176
+ '.gitignore',
9177
+ '.npmrc',
9178
+ '.eslintrc',
9179
+ '.prettierrc',
9180
+ '.babelrc',
9181
+ '.sh',
9182
+ '.ps1',
9183
+ ]);
9184
+
9185
+ const ext = path.extname(filePath).toLowerCase();
9186
+
9187
+ // 没有扩展名的文件(如 .coze)也尝试渲染
9188
+ if (ext === '') {
9189
+ return true;
9190
+ }
9191
+
9192
+ return textExtensions.has(ext);
9193
+ };
9194
+
9195
+ /**
9196
+ * 判断文件是否应该被忽略(不复制到目标目录)
9197
+ *
9198
+ * @param filePath - 文件路径
9199
+ * @returns 是否应该忽略
9200
+ */
9201
+ const shouldIgnoreFile = (filePath) => {
9202
+ const fileName = path.basename(filePath);
9203
+ const pathParts = filePath.split(/[\\/]+/);
9204
+
9205
+ // 精确匹配的文件名
9206
+ const exactMatch = ['template.config.ts', 'template.config.js', '.DS_Store'];
9207
+
9208
+ // 目录名(需要检查路径中是否包含)
9209
+ const directoryPatterns = ['node_modules', 'node-compile-cache'];
9210
+
9211
+ // 检查精确匹配
9212
+ if (exactMatch.includes(fileName)) {
9213
+ return true;
9214
+ }
9215
+
9216
+ // 检查路径中是否包含需要忽略的目录
9217
+ return directoryPatterns.some(dir => pathParts.includes(dir));
9218
+ };
9219
+
9401
9220
  // ABOUTME: File system utilities for template file processing
9402
9221
  // ABOUTME: Provides directory scanning, file path conversion, and node_modules copying
9403
9222