@coze-arch/cli 0.1.7 → 0.1.8-alpha.2ee669

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 (42) hide show
  1. package/README.md +18 -0
  2. package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +178 -10
  3. package/lib/__templates__/native-static/.coze +2 -2
  4. package/lib/__templates__/nextjs/.coze +1 -1
  5. package/lib/__templates__/nextjs/README.md +18 -0
  6. package/lib/__templates__/nextjs/scripts/build.sh +1 -1
  7. package/lib/__templates__/nextjs/scripts/dev.sh +16 -34
  8. package/lib/__templates__/nextjs/scripts/local-workspace.cjs +302 -0
  9. package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +178 -10
  10. package/lib/__templates__/nextjs/scripts/prepare.sh +10 -2
  11. package/lib/__templates__/nextjs/scripts/validate.sh +11 -1
  12. package/lib/__templates__/nextjs/template.config.js +20 -6
  13. package/lib/__templates__/nextjs/tsconfig.json +0 -1
  14. package/lib/__templates__/nuxt-vue/.coze +1 -1
  15. package/lib/__templates__/nuxt-vue/README.md +20 -2
  16. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  17. package/lib/__templates__/nuxt-vue/scripts/dev.sh +10 -4
  18. package/lib/__templates__/nuxt-vue/scripts/local-workspace.cjs +302 -0
  19. package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +178 -10
  20. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +10 -2
  21. package/lib/__templates__/nuxt-vue/scripts/validate.sh +11 -1
  22. package/lib/__templates__/taro/.coze +2 -2
  23. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +6 -1
  24. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +10 -1
  25. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +56 -4
  26. package/lib/__templates__/taro/.cozeproj/scripts/local-workspace.cjs +351 -0
  27. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +16 -6
  28. package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +178 -10
  29. package/lib/__templates__/taro/.cozeproj/scripts/taro-build.cjs +66 -0
  30. package/lib/__templates__/taro/.cozeproj/scripts/validate.sh +3 -0
  31. package/lib/__templates__/taro/package.json +5 -5
  32. package/lib/__templates__/vite/.coze +1 -1
  33. package/lib/__templates__/vite/README.md +20 -0
  34. package/lib/__templates__/vite/scripts/build.sh +1 -1
  35. package/lib/__templates__/vite/scripts/dev.sh +10 -4
  36. package/lib/__templates__/vite/scripts/local-workspace.cjs +302 -0
  37. package/lib/__templates__/vite/scripts/prepare-node-modules.sh +178 -10
  38. package/lib/__templates__/vite/scripts/prepare.sh +10 -2
  39. package/lib/__templates__/vite/scripts/validate.sh +7 -1
  40. package/lib/__templates__/vite/template.config.js +20 -6
  41. package/lib/cli.js +365 -184
  42. package/package.json +2 -1
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');
19
20
  var fastGlob = require('fast-glob');
20
21
  var child_process = require('child_process');
21
22
  var addFormats = require('ajv-formats');
22
23
  var Ajv = require('ajv');
23
24
  var minimist = require('minimist');
24
25
  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$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; }/**
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; }/**
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$G([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1710
+ (_optionalChain$H([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$G([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1768
+ _optionalChain$H([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$G([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1839
+ stack: _optionalChain$H([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$G([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1859
+ _optionalChain$H([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$G([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1870
+ _optionalChain$H([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$G([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1880
+ _optionalChain$H([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$G([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1890
+ _optionalChain$H([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$G([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1927
+ _optionalChain$H([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$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; }
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; }
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$F([options, 'optionalAccess', _ => _.args]),
2006
+ args: _optionalChain$G([options, 'optionalAccess', _ => _.args]),
2007
2007
  status: 'running' ,
2008
- ..._optionalChain$F([options, 'optionalAccess', _2 => _2.categories]),
2008
+ ..._optionalChain$G([options, 'optionalAccess', _2 => _2.categories]),
2009
2009
  },
2010
- metrics: _optionalChain$F([options, 'optionalAccess', _3 => _3.metrics]),
2010
+ metrics: _optionalChain$G([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$F([options, 'optionalAccess', _4 => _4.args]),
2031
+ args: _optionalChain$G([options, 'optionalAccess', _4 => _4.args]),
2032
2032
  status: success ? ('success' ) : ('fail' ),
2033
- ..._optionalChain$F([options, 'optionalAccess', _5 => _5.categories]),
2033
+ ..._optionalChain$G([options, 'optionalAccess', _5 => _5.categories]),
2034
2034
  },
2035
2035
  metrics: {
2036
2036
  duration,
2037
- ...(_optionalChain$F([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2037
+ ...(_optionalChain$G([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$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' ),
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' ),
2061
2061
  },
2062
2062
  metrics: {
2063
- duration: _optionalChain$F([options, 'optionalAccess', _12 => _12.duration]),
2063
+ duration: _optionalChain$G([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$F([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2085
+ status: _optionalChain$G([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2086
2086
  },
2087
2087
  metrics: {
2088
- duration: _optionalChain$F([options, 'optionalAccess', _14 => _14.duration]),
2089
- fileSize: _optionalChain$F([options, 'optionalAccess', _15 => _15.fileSize]),
2088
+ duration: _optionalChain$G([options, 'optionalAccess', _14 => _14.duration]),
2089
+ fileSize: _optionalChain$G([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.7";
2117
+ var version = "0.1.8-alpha.2ee669";
2118
2118
  var description = "coze coding devtools cli";
2119
2119
  var license = "MIT";
2120
2120
  var author = "fanwenjie.fe@bytedance.com";
@@ -2148,6 +2148,7 @@ 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",
2151
2152
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
2152
2153
  "test:perf:compare": "bash scripts/compare-perf.sh",
2153
2154
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -2225,7 +2226,7 @@ var packageJson = {
2225
2226
  cozePublishConfig: cozePublishConfig
2226
2227
  };
2227
2228
 
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; }/**
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; }/**
2229
2230
  * Slardar 监控初始化和上报
2230
2231
  */
2231
2232
 
@@ -2328,11 +2329,11 @@ const reportCommandComplete = safeRun(
2328
2329
  ,
2329
2330
  ) => {
2330
2331
  const event = EventBuilder.cliCommandComplete(command, success, duration, {
2331
- args: _optionalChain$E([options, 'optionalAccess', _ => _.args]),
2332
- errorCode: _optionalChain$E([options, 'optionalAccess', _2 => _2.errorCode]),
2332
+ args: _optionalChain$F([options, 'optionalAccess', _ => _.args]),
2333
+ errorCode: _optionalChain$F([options, 'optionalAccess', _2 => _2.errorCode]),
2333
2334
  categories: {
2334
- ...(_optionalChain$E([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2335
- ..._optionalChain$E([options, 'optionalAccess', _4 => _4.categories]),
2335
+ ...(_optionalChain$F([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2336
+ ..._optionalChain$F([options, 'optionalAccess', _4 => _4.categories]),
2336
2337
  },
2337
2338
  });
2338
2339
  reporter.sendEvent(event.name, event.metrics, event.categories);
@@ -2391,7 +2392,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2391
2392
  await reporter.flush();
2392
2393
  });
2393
2394
 
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) {
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) {
2395
2396
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2396
2397
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2397
2398
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2438,7 +2439,7 @@ class Logger {
2438
2439
  return level;
2439
2440
  }
2440
2441
 
2441
- const envLevel = _optionalChain$D([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2442
+ const envLevel = _optionalChain$E([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2442
2443
  if (envLevel && envLevel in LOG_LEVEL_MAP) {
2443
2444
  // envLevel 已通过 `in` 检查确认为 LOG_LEVEL_MAP 的键;
2444
2445
  // 显式判空以满足 noUncheckedIndexedAccess,运行时行为不变
@@ -2455,7 +2456,7 @@ class Logger {
2455
2456
  // 简单检测:Node.js 环境且支持 TTY
2456
2457
  return (
2457
2458
  typeof process !== 'undefined' &&
2458
- _optionalChain$D([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2459
+ _optionalChain$E([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2459
2460
  process.env.NO_COLOR === undefined
2460
2461
  );
2461
2462
  }
@@ -3263,7 +3264,7 @@ const registerCommand$6 = program => {
3263
3264
  });
3264
3265
  };
3265
3266
 
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
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
3267
3268
  // Provides fallback values, validation, and error monitoring capabilities
3268
3269
 
3269
3270
  /**
@@ -3363,12 +3364,12 @@ function safeJsonParse(
3363
3364
  const parsed = JSON.parse(String(input));
3364
3365
 
3365
3366
  // Optional validation
3366
- if (_optionalChain$C([options, 'optionalAccess', _ => _.validate])) {
3367
+ if (_optionalChain$D([options, 'optionalAccess', _ => _.validate])) {
3367
3368
  if (options.validate(parsed)) {
3368
3369
  return parsed;
3369
3370
  } else {
3370
3371
  const validationError = new Error('JSON validation failed');
3371
- _optionalChain$C([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3372
+ _optionalChain$D([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3372
3373
 
3373
3374
  if (options.throwOnValidationError) {
3374
3375
  throw validationError;
@@ -3380,10 +3381,10 @@ function safeJsonParse(
3380
3381
  return parsed;
3381
3382
  } catch (error) {
3382
3383
  // Re-throw validation errors when throwOnValidationError is true
3383
- if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$C([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3384
+ if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$D([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3384
3385
  throw error;
3385
3386
  }
3386
- _optionalChain$C([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3387
+ _optionalChain$D([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3387
3388
  return defaultValue;
3388
3389
  }
3389
3390
  }
@@ -3423,7 +3424,7 @@ function isNode(node) {
3423
3424
  }
3424
3425
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3425
3426
 
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; }
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; }
3427
3428
  const BREAK = Symbol('break visit');
3428
3429
  const SKIP = Symbol('skip children');
3429
3430
  const REMOVE = Symbol('remove node');
@@ -3536,15 +3537,15 @@ function callVisitor(key, node, visitor, path) {
3536
3537
  if (typeof visitor === 'function')
3537
3538
  return visitor(key, node, path);
3538
3539
  if (isMap(node))
3539
- return _optionalChain$B([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3540
+ return _optionalChain$C([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3540
3541
  if (isSeq(node))
3541
- return _optionalChain$B([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3542
+ return _optionalChain$C([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3542
3543
  if (isPair(node))
3543
- return _optionalChain$B([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3544
+ return _optionalChain$C([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3544
3545
  if (isScalar(node))
3545
- return _optionalChain$B([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3546
+ return _optionalChain$C([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3546
3547
  if (isAlias(node))
3547
- return _optionalChain$B([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3548
+ return _optionalChain$C([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3548
3549
  return undefined;
3549
3550
  }
3550
3551
  function replaceNode(key, path, node) {
@@ -3635,7 +3636,7 @@ function applyReviver(reviver, obj, key, val) {
3635
3636
  return reviver.call(obj, key, val);
3636
3637
  }
3637
3638
 
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; }
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; }
3639
3640
  /**
3640
3641
  * Recursively convert any node or its contents to native JavaScript
3641
3642
  *
@@ -3665,7 +3666,7 @@ function toJS(value, arg, ctx) {
3665
3666
  ctx.onCreate(res);
3666
3667
  return res;
3667
3668
  }
3668
- if (typeof value === 'bigint' && !_optionalChain$A([ctx, 'optionalAccess', _ => _.keep]))
3669
+ if (typeof value === 'bigint' && !_optionalChain$B([ctx, 'optionalAccess', _ => _.keep]))
3669
3670
  return Number(value);
3670
3671
  return value;
3671
3672
  }
@@ -3703,7 +3704,7 @@ class NodeBase {
3703
3704
  }
3704
3705
  }
3705
3706
 
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; }
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; }
3707
3708
  class Alias extends NodeBase {
3708
3709
  constructor(source) {
3709
3710
  super(ALIAS);
@@ -3719,10 +3720,10 @@ class Alias extends NodeBase {
3719
3720
  * instance of the `source` anchor before this node.
3720
3721
  */
3721
3722
  resolve(doc, ctx) {
3722
- if (_optionalChain$z([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3723
+ if (_optionalChain$A([ctx, 'optionalAccess', _ => _.maxAliasCount]) === 0)
3723
3724
  throw new ReferenceError('Alias resolution is disabled');
3724
3725
  let nodes;
3725
- if (_optionalChain$z([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3726
+ if (_optionalChain$A([ctx, 'optionalAccess', _2 => _2.aliasResolveCache])) {
3726
3727
  nodes = ctx.aliasResolveCache;
3727
3728
  }
3728
3729
  else {
@@ -3761,7 +3762,7 @@ class Alias extends NodeBase {
3761
3762
  data = anchors.get(source);
3762
3763
  }
3763
3764
  /* istanbul ignore if */
3764
- if (_optionalChain$z([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3765
+ if (_optionalChain$A([data, 'optionalAccess', _3 => _3.res]) === undefined) {
3765
3766
  const msg = 'This should not happen: Alias anchor was not resolved?';
3766
3767
  throw new ReferenceError(msg);
3767
3768
  }
@@ -3813,7 +3814,7 @@ function getAliasCount(doc, node, anchors) {
3813
3814
  return 1;
3814
3815
  }
3815
3816
 
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; }
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; }
3817
3818
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3818
3819
  class Scalar extends NodeBase {
3819
3820
  constructor(value) {
@@ -3821,7 +3822,7 @@ class Scalar extends NodeBase {
3821
3822
  this.value = value;
3822
3823
  }
3823
3824
  toJSON(arg, ctx) {
3824
- return _optionalChain$y([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3825
+ return _optionalChain$z([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3825
3826
  }
3826
3827
  toString() {
3827
3828
  return String(this.value);
@@ -3833,7 +3834,7 @@ Scalar.PLAIN = 'PLAIN';
3833
3834
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3834
3835
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3835
3836
 
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; }
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; }
3837
3838
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3838
3839
  function findTagObject(value, tagName, tags) {
3839
3840
  if (tagName) {
@@ -3843,7 +3844,7 @@ function findTagObject(value, tagName, tags) {
3843
3844
  throw new Error(`Tag ${tagName} not found`);
3844
3845
  return tagObj;
3845
3846
  }
3846
- return tags.find(t => _optionalChain$x([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3847
+ return tags.find(t => _optionalChain$y([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3847
3848
  }
3848
3849
  function createNode(value, tagName, ctx) {
3849
3850
  if (isDocument(value))
@@ -3851,7 +3852,7 @@ function createNode(value, tagName, ctx) {
3851
3852
  if (isNode(value))
3852
3853
  return value;
3853
3854
  if (isPair(value)) {
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)]);
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)]);
3855
3856
  map.items.push(value);
3856
3857
  return map;
3857
3858
  }
@@ -3878,7 +3879,7 @@ function createNode(value, tagName, ctx) {
3878
3879
  sourceObjects.set(value, ref);
3879
3880
  }
3880
3881
  }
3881
- if (_optionalChain$x([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3882
+ if (_optionalChain$y([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3882
3883
  tagName = defaultTagPrefix + tagName.slice(2);
3883
3884
  let tagObj = findTagObject(value, tagName, schema.tags);
3884
3885
  if (!tagObj) {
@@ -3903,9 +3904,9 @@ function createNode(value, tagName, ctx) {
3903
3904
  onTagObj(tagObj);
3904
3905
  delete ctx.onTagObj;
3905
3906
  }
3906
- const node = _optionalChain$x([tagObj, 'optionalAccess', _9 => _9.createNode])
3907
+ const node = _optionalChain$y([tagObj, 'optionalAccess', _9 => _9.createNode])
3907
3908
  ? tagObj.createNode(ctx.schema, value, ctx)
3908
- : typeof _optionalChain$x([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3909
+ : typeof _optionalChain$y([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3909
3910
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
3910
3911
  : new Scalar(value);
3911
3912
  if (tagName)
@@ -4223,7 +4224,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4223
4224
  return end;
4224
4225
  }
4225
4226
 
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; }
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; }
4227
4228
  const getFoldOptions = (ctx, isBlock) => ({
4228
4229
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4229
4230
  lineWidth: ctx.options.lineWidth,
@@ -4508,9 +4509,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4508
4509
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4509
4510
  // and others in v1.1.
4510
4511
  if (actualString) {
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)]);
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)]);
4512
4513
  const { compat, tags } = ctx.doc.schema;
4513
- if (tags.some(test) || _optionalChain$w([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4514
+ if (tags.some(test) || _optionalChain$x([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4514
4515
  return quotedString(value, ctx);
4515
4516
  }
4516
4517
  return implicitKey
@@ -4556,7 +4557,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4556
4557
  return res;
4557
4558
  }
4558
4559
 
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; }
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; }
4560
4561
  function createStringifyContext(doc, options) {
4561
4562
  const opt = Object.assign({
4562
4563
  blockQuote: true,
@@ -4609,7 +4610,7 @@ function getTagObject(tags, item) {
4609
4610
  let obj;
4610
4611
  if (isScalar(item)) {
4611
4612
  obj = item.value;
4612
- let match = tags.filter(t => _optionalChain$v([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4613
+ let match = tags.filter(t => _optionalChain$w([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4613
4614
  if (match.length > 1) {
4614
4615
  const testMatch = match.filter(t => t.test);
4615
4616
  if (testMatch.length > 0)
@@ -4623,7 +4624,7 @@ function getTagObject(tags, item) {
4623
4624
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4624
4625
  }
4625
4626
  if (!tagObj) {
4626
- const name = _nullishCoalesce$9(_optionalChain$v([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4627
+ const name = _nullishCoalesce$9(_optionalChain$w([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4627
4628
  throw new Error(`Tag not resolved for ${name} value`);
4628
4629
  }
4629
4630
  return tagObj;
@@ -4649,7 +4650,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4649
4650
  if (isAlias(item)) {
4650
4651
  if (ctx.doc.directives)
4651
4652
  return item.toString(ctx);
4652
- if (_optionalChain$v([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4653
+ if (_optionalChain$w([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4653
4654
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4654
4655
  }
4655
4656
  else {
@@ -4831,7 +4832,7 @@ function warn(logLevel, warning) {
4831
4832
  }
4832
4833
  }
4833
4834
 
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; }
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; }
4835
4836
  // If the value associated with a merge key is a single mapping node, each of
4836
4837
  // its key/value pairs is inserted into the current mapping, unless the key
4837
4838
  // already exists in it. If the value associated with the merge key is a
@@ -4855,7 +4856,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4855
4856
  (isScalar(key) &&
4856
4857
  (!key.type || key.type === Scalar.PLAIN) &&
4857
4858
  merge.identify(key.value))) &&
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)]);
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)]);
4859
4860
  function addMergeToJSMap(ctx, map, value) {
4860
4861
  const source = resolveAliasValue(ctx, value);
4861
4862
  if (isSeq(source))
@@ -4895,7 +4896,7 @@ function resolveAliasValue(ctx, value) {
4895
4896
  return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
4896
4897
  }
4897
4898
 
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; }
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; }
4899
4900
  function addPairToJSMap(ctx, map, { key, value }) {
4900
4901
  if (isNode(key) && key.addToJSMap)
4901
4902
  key.addToJSMap(ctx, map, value);
@@ -4932,7 +4933,7 @@ function stringifyKey(key, jsKey, ctx) {
4932
4933
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
4933
4934
  if (typeof jsKey !== 'object')
4934
4935
  return String(jsKey);
4935
- if (isNode(key) && _optionalChain$t([ctx, 'optionalAccess', _ => _.doc])) {
4936
+ if (isNode(key) && _optionalChain$u([ctx, 'optionalAccess', _ => _.doc])) {
4936
4937
  const strCtx = createStringifyContext(ctx.doc, {});
4937
4938
  strCtx.anchors = new Set();
4938
4939
  for (const node of ctx.anchors.keys())
@@ -4952,7 +4953,7 @@ function stringifyKey(key, jsKey, ctx) {
4952
4953
  return JSON.stringify(jsKey);
4953
4954
  }
4954
4955
 
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; }
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; }
4956
4957
  function createPair(key, value, ctx) {
4957
4958
  const k = createNode(key, undefined, ctx);
4958
4959
  const v = createNode(value, undefined, ctx);
@@ -4973,17 +4974,17 @@ class Pair {
4973
4974
  return new Pair(key, value);
4974
4975
  }
4975
4976
  toJSON(_, ctx) {
4976
- const pair = _optionalChain$s([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4977
+ const pair = _optionalChain$t([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4977
4978
  return addPairToJSMap(ctx, pair, this);
4978
4979
  }
4979
4980
  toString(ctx, onComment, onChompKeep) {
4980
- return _optionalChain$s([ctx, 'optionalAccess', _3 => _3.doc])
4981
+ return _optionalChain$t([ctx, 'optionalAccess', _3 => _3.doc])
4981
4982
  ? stringifyPair(this, ctx, onComment, onChompKeep)
4982
4983
  : JSON.stringify(this);
4983
4984
  }
4984
4985
  }
4985
4986
 
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; }
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; }
4987
4988
  function stringifyCollection(collection, ctx, options) {
4988
4989
  const flow = _nullishCoalesce$7(ctx.inFlow, () => ( collection.flow));
4989
4990
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
@@ -5077,7 +5078,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5077
5078
  if (iv.commentBefore)
5078
5079
  reqNewline = true;
5079
5080
  }
5080
- else if (item.value == null && _optionalChain$r([ik, 'optionalAccess', _ => _.comment])) {
5081
+ else if (item.value == null && _optionalChain$s([ik, 'optionalAccess', _ => _.comment])) {
5081
5082
  comment = ik.comment;
5082
5083
  }
5083
5084
  }
@@ -5132,7 +5133,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5132
5133
  }
5133
5134
  }
5134
5135
 
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; }
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; }
5136
5137
  function findPair(items, key) {
5137
5138
  const k = isScalar(key) ? key.value : key;
5138
5139
  for (const it of items) {
@@ -5193,12 +5194,12 @@ class YAMLMap extends Collection {
5193
5194
  _pair = pair;
5194
5195
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5195
5196
  // In TypeScript, this never happens.
5196
- _pair = new Pair(pair, _optionalChain$q([pair, 'optionalAccess', _2 => _2.value]));
5197
+ _pair = new Pair(pair, _optionalChain$r([pair, 'optionalAccess', _2 => _2.value]));
5197
5198
  }
5198
5199
  else
5199
5200
  _pair = new Pair(pair.key, pair.value);
5200
5201
  const prev = findPair(this.items, _pair.key);
5201
- const sortEntries = _optionalChain$q([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5202
+ const sortEntries = _optionalChain$r([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5202
5203
  if (prev) {
5203
5204
  if (!overwrite)
5204
5205
  throw new Error(`Key ${_pair.key} already set`);
@@ -5228,7 +5229,7 @@ class YAMLMap extends Collection {
5228
5229
  }
5229
5230
  get(key, keepScalar) {
5230
5231
  const it = findPair(this.items, key);
5231
- const node = _optionalChain$q([it, 'optionalAccess', _5 => _5.value]);
5232
+ const node = _optionalChain$r([it, 'optionalAccess', _5 => _5.value]);
5232
5233
  return _nullishCoalesce$6((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5233
5234
  }
5234
5235
  has(key) {
@@ -5243,8 +5244,8 @@ class YAMLMap extends Collection {
5243
5244
  * @returns Instance of Type, Map, or Object
5244
5245
  */
5245
5246
  toJSON(_, ctx, Type) {
5246
- const map = Type ? new Type() : _optionalChain$q([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5247
- if (_optionalChain$q([ctx, 'optionalAccess', _7 => _7.onCreate]))
5247
+ const map = Type ? new Type() : _optionalChain$r([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5248
+ if (_optionalChain$r([ctx, 'optionalAccess', _7 => _7.onCreate]))
5248
5249
  ctx.onCreate(map);
5249
5250
  for (const item of this.items)
5250
5251
  addPairToJSMap(ctx, map, item);
@@ -5269,7 +5270,7 @@ class YAMLMap extends Collection {
5269
5270
  }
5270
5271
  }
5271
5272
 
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; }
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; }
5273
5274
  class YAMLSeq extends Collection {
5274
5275
  static get tagName() {
5275
5276
  return 'tag:yaml.org,2002:seq';
@@ -5332,7 +5333,7 @@ class YAMLSeq extends Collection {
5332
5333
  }
5333
5334
  toJSON(_, ctx) {
5334
5335
  const seq = [];
5335
- if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
5336
+ if (_optionalChain$q([ctx, 'optionalAccess', _2 => _2.onCreate]))
5336
5337
  ctx.onCreate(seq);
5337
5338
  let i = 0;
5338
5339
  for (const item of this.items)
@@ -5411,7 +5412,7 @@ function createPairs(schema, iterable, ctx) {
5411
5412
  return pairs;
5412
5413
  }
5413
5414
 
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; }
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; }
5415
5416
  class YAMLOMap extends YAMLSeq {
5416
5417
  constructor() {
5417
5418
  super();
@@ -5430,7 +5431,7 @@ class YAMLOMap extends YAMLSeq {
5430
5431
  if (!ctx)
5431
5432
  return super.toJSON(_);
5432
5433
  const map = new Map();
5433
- if (_optionalChain$o([ctx, 'optionalAccess', _2 => _2.onCreate]))
5434
+ if (_optionalChain$p([ctx, 'optionalAccess', _2 => _2.onCreate]))
5434
5435
  ctx.onCreate(map);
5435
5436
  for (const pair of this.items) {
5436
5437
  let key, value;
@@ -5548,7 +5549,7 @@ const isDirExists = async (file) => {
5548
5549
  }
5549
5550
  };
5550
5551
 
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
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
5552
5553
 
5553
5554
  /**
5554
5555
  * 支持的项目类型枚举
@@ -5650,7 +5651,7 @@ const collectProjectInfo = async (
5650
5651
  }
5651
5652
 
5652
5653
  const scripts = Object.entries(
5653
- (_optionalChain$n([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5654
+ (_optionalChain$o([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5654
5655
  ).reduce((acc, [name, script]) => {
5655
5656
  if (typeof script === 'string') {
5656
5657
  acc[name] = script;
@@ -5804,7 +5805,7 @@ const detectProjectType = async (
5804
5805
  };
5805
5806
  };
5806
5807
 
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; }
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; }
5808
5809
 
5809
5810
 
5810
5811
  /**
@@ -5971,13 +5972,13 @@ const getDefaultCommandConfig = (
5971
5972
  ) => {
5972
5973
  switch (commandName) {
5973
5974
  case 'dev':
5974
- return _optionalChain$m([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5975
+ return _optionalChain$n([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5975
5976
  case 'build':
5976
- return _optionalChain$m([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5977
+ return _optionalChain$n([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5977
5978
  case 'start':
5978
- return _optionalChain$m([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5979
+ return _optionalChain$n([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5979
5980
  case 'validate':
5980
- return _optionalChain$m([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5981
+ return _optionalChain$n([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
5981
5982
  default:
5982
5983
  throw new Error(`Unknown command: ${commandName}`);
5983
5984
  }
@@ -5989,13 +5990,13 @@ const getWindowsCommandConfig = (
5989
5990
  ) => {
5990
5991
  switch (commandName) {
5991
5992
  case 'dev':
5992
- return _optionalChain$m([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
5993
+ return _optionalChain$n([config, 'access', _9 => _9.dev, 'optionalAccess', _10 => _10.run_win]);
5993
5994
  case 'build':
5994
- return _optionalChain$m([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
5995
+ return _optionalChain$n([config, 'access', _11 => _11.deploy, 'optionalAccess', _12 => _12.build_win]);
5995
5996
  case 'start':
5996
- return _optionalChain$m([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
5997
+ return _optionalChain$n([config, 'access', _13 => _13.deploy, 'optionalAccess', _14 => _14.run_win]);
5997
5998
  case 'validate':
5998
- return _optionalChain$m([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
5999
+ return _optionalChain$n([config, 'access', _15 => _15.dev, 'optionalAccess', _16 => _16.validate_win]);
5999
6000
  default:
6000
6001
  throw new Error(`Unknown command: ${commandName}`);
6001
6002
  }
@@ -6020,7 +6021,7 @@ const getCommandConfig = (
6020
6021
  platform === 'win32'
6021
6022
  ? getWindowsCommandConfig(config, commandName)
6022
6023
  : undefined;
6023
- const commandConfig = _optionalChain$m([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
6024
+ const commandConfig = _optionalChain$n([windowsCommandConfig, 'optionalAccess', _17 => _17.length])
6024
6025
  ? windowsCommandConfig
6025
6026
  : defaultCommandConfig;
6026
6027
 
@@ -6169,6 +6170,273 @@ const byFlag = (flag) => {
6169
6170
  return predicate;
6170
6171
  };
6171
6172
 
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
+
6172
6440
  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; }
6173
6441
 
6174
6442
 
@@ -7440,6 +7708,7 @@ const patches = [
7440
7708
  patchTaroAgentsMd,
7441
7709
  patchTaroValidate,
7442
7710
  patchTaroPackScript,
7711
+ ...webLocalWorkspacePatches,
7443
7712
  ] ;
7444
7713
 
7445
7714
  const getTemplatePatches = (
@@ -9129,94 +9398,6 @@ const parsePassThroughParams = (command, knownOptions = new Set()) => {
9129
9398
  return filtered;
9130
9399
  };
9131
9400
 
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
-
9220
9401
  // ABOUTME: File system utilities for template file processing
9221
9402
  // ABOUTME: Provides directory scanning, file path conversion, and node_modules copying
9222
9403