@coze-arch/cli 0.0.20 → 0.0.21

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 (2) hide show
  1. package/lib/cli.js +818 -89
  2. package/package.json +5 -1
package/lib/cli.js CHANGED
@@ -1628,7 +1628,7 @@ function createNodeTransport() {
1628
1628
  };
1629
1629
  }
1630
1630
 
1631
- function _nullishCoalesce$9(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$o(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
1631
+ function _nullishCoalesce$9(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; }/**
1632
1632
  * Slardar CLI Reporter 主类
1633
1633
  * 封装 @slardar/base 的初始化和上报逻辑
1634
1634
  */
@@ -1700,7 +1700,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1700
1700
  this.client.on('send', (ev) => {
1701
1701
  log$6(
1702
1702
  'send hook called for event: %s',
1703
- (_optionalChain$o([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1703
+ (_optionalChain$s([ev, 'optionalAccess', _ => _.ev_type]) ) || 'unknown',
1704
1704
  );
1705
1705
  });
1706
1706
 
@@ -1758,7 +1758,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1758
1758
  )
1759
1759
  : undefined;
1760
1760
 
1761
- _optionalChain$o([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1761
+ _optionalChain$s([this, 'access', _2 => _2.client, 'access', _3 => _3.sendEvent, 'optionalCall', _4 => _4({
1762
1762
  name,
1763
1763
  metrics: cleanMetrics ,
1764
1764
  categories: cleanCategories ,
@@ -1829,7 +1829,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1829
1829
  log$6('Reporting JS error:', {
1830
1830
  name: error.name,
1831
1831
  message: error.message.slice(0, 100),
1832
- stack: _optionalChain$o([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1832
+ stack: _optionalChain$s([error, 'access', _5 => _5.stack, 'optionalAccess', _6 => _6.slice, 'call', _7 => _7(0, 200)]),
1833
1833
  extra,
1834
1834
  source,
1835
1835
  });
@@ -1849,7 +1849,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1849
1849
  if (!this.ensureInitialized()) {
1850
1850
  return;
1851
1851
  }
1852
- _optionalChain$o([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1852
+ _optionalChain$s([this, 'access', _8 => _8.client, 'access', _9 => _9.context, 'optionalAccess', _10 => _10.set, 'call', _11 => _11(key, value)]);
1853
1853
  }
1854
1854
 
1855
1855
  /**
@@ -1860,7 +1860,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1860
1860
  return;
1861
1861
  }
1862
1862
  log$6('Merging context:', context);
1863
- _optionalChain$o([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1863
+ _optionalChain$s([this, 'access', _12 => _12.client, 'access', _13 => _13.context, 'optionalAccess', _14 => _14.merge, 'call', _15 => _15(context)]);
1864
1864
  }
1865
1865
 
1866
1866
  /**
@@ -1870,7 +1870,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1870
1870
  if (!this.ensureInitialized()) {
1871
1871
  return;
1872
1872
  }
1873
- _optionalChain$o([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1873
+ _optionalChain$s([this, 'access', _16 => _16.client, 'access', _17 => _17.context, 'optionalAccess', _18 => _18.delete, 'call', _19 => _19(key)]);
1874
1874
  }
1875
1875
 
1876
1876
  /**
@@ -1880,7 +1880,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1880
1880
  if (!this.ensureInitialized()) {
1881
1881
  return;
1882
1882
  }
1883
- _optionalChain$o([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1883
+ _optionalChain$s([this, 'access', _20 => _20.client, 'access', _21 => _21.context, 'optionalAccess', _22 => _22.clear, 'call', _23 => _23()]);
1884
1884
  }
1885
1885
 
1886
1886
  /**
@@ -1917,7 +1917,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1917
1917
  return;
1918
1918
  }
1919
1919
  log$6('Flushing Slardar data...');
1920
- _optionalChain$o([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1920
+ _optionalChain$s([this, 'access', _24 => _24.client, 'access', _25 => _25.getSender, 'optionalCall', _26 => _26(), 'optionalAccess', _27 => _27.flush, 'call', _28 => _28()]);
1921
1921
  log$6('Waiting %dms for events to be sent...', waitMs);
1922
1922
  await new Promise(resolve => setTimeout(resolve, waitMs));
1923
1923
  log$6('Slardar data flushed');
@@ -1936,7 +1936,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1936
1936
  */
1937
1937
  const reporter = new SlardarCLIReporter();
1938
1938
 
1939
- function _optionalChain$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; }
1939
+ 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; }
1940
1940
 
1941
1941
 
1942
1942
 
@@ -1996,11 +1996,11 @@ const EventBuilder = {
1996
1996
  name: CLI_EVENTS.CLI_COMMAND,
1997
1997
  categories: {
1998
1998
  command,
1999
- args: _optionalChain$n([options, 'optionalAccess', _ => _.args]),
1999
+ args: _optionalChain$r([options, 'optionalAccess', _ => _.args]),
2000
2000
  status: 'running' ,
2001
- ..._optionalChain$n([options, 'optionalAccess', _2 => _2.categories]),
2001
+ ..._optionalChain$r([options, 'optionalAccess', _2 => _2.categories]),
2002
2002
  },
2003
- metrics: _optionalChain$n([options, 'optionalAccess', _3 => _3.metrics]),
2003
+ metrics: _optionalChain$r([options, 'optionalAccess', _3 => _3.metrics]),
2004
2004
  };
2005
2005
  },
2006
2006
 
@@ -2021,13 +2021,13 @@ const EventBuilder = {
2021
2021
  name: CLI_EVENTS.CLI_COMMAND_COMPLETE,
2022
2022
  categories: {
2023
2023
  command,
2024
- args: _optionalChain$n([options, 'optionalAccess', _4 => _4.args]),
2024
+ args: _optionalChain$r([options, 'optionalAccess', _4 => _4.args]),
2025
2025
  status: success ? ('success' ) : ('fail' ),
2026
- ..._optionalChain$n([options, 'optionalAccess', _5 => _5.categories]),
2026
+ ..._optionalChain$r([options, 'optionalAccess', _5 => _5.categories]),
2027
2027
  },
2028
2028
  metrics: {
2029
2029
  duration,
2030
- ...(_optionalChain$n([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2030
+ ...(_optionalChain$r([options, 'optionalAccess', _6 => _6.errorCode]) && { errorCode: options.errorCode }),
2031
2031
  },
2032
2032
  };
2033
2033
  },
@@ -2048,12 +2048,12 @@ const EventBuilder = {
2048
2048
  name: CLI_EVENTS.NETWORK_REQUEST,
2049
2049
  categories: {
2050
2050
  url,
2051
- method: _optionalChain$n([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2052
- statusCode: _optionalChain$n([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2053
- status: _optionalChain$n([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2051
+ method: _optionalChain$r([options, 'optionalAccess', _7 => _7.method]) || 'GET',
2052
+ statusCode: _optionalChain$r([options, 'optionalAccess', _8 => _8.statusCode, 'optionalAccess', _9 => _9.toString, 'call', _10 => _10()]),
2053
+ status: _optionalChain$r([options, 'optionalAccess', _11 => _11.success]) ? ('success' ) : ('fail' ),
2054
2054
  },
2055
2055
  metrics: {
2056
- duration: _optionalChain$n([options, 'optionalAccess', _12 => _12.duration]),
2056
+ duration: _optionalChain$r([options, 'optionalAccess', _12 => _12.duration]),
2057
2057
  },
2058
2058
  };
2059
2059
  },
@@ -2075,11 +2075,11 @@ const EventBuilder = {
2075
2075
  categories: {
2076
2076
  operation,
2077
2077
  filePath,
2078
- status: _optionalChain$n([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2078
+ status: _optionalChain$r([options, 'optionalAccess', _13 => _13.success]) ? ('success' ) : ('fail' ),
2079
2079
  },
2080
2080
  metrics: {
2081
- duration: _optionalChain$n([options, 'optionalAccess', _14 => _14.duration]),
2082
- fileSize: _optionalChain$n([options, 'optionalAccess', _15 => _15.fileSize]),
2081
+ duration: _optionalChain$r([options, 'optionalAccess', _14 => _14.duration]),
2082
+ fileSize: _optionalChain$r([options, 'optionalAccess', _15 => _15.fileSize]),
2083
2083
  },
2084
2084
  };
2085
2085
  },
@@ -2107,7 +2107,7 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@coze-arch/cli";
2110
- var version = "0.0.20";
2110
+ var version = "0.0.21";
2111
2111
  var description = "coze coding devtools cli";
2112
2112
  var license = "MIT";
2113
2113
  var author = "fanwenjie.fe@bytedance.com";
@@ -2130,6 +2130,8 @@ var scripts = {
2130
2130
  prebuild: "tsx scripts/prebuild.ts",
2131
2131
  build: "tsx scripts/build.ts",
2132
2132
  create: "tsx scripts/create-template.ts",
2133
+ knip: "knip --include files",
2134
+ "knip:all": "knip",
2133
2135
  lint: "eslint ./ --cache",
2134
2136
  "pre-release": "tsx scripts/pre-release.ts",
2135
2137
  postpublish: "bash scripts/sync-npmmirror.sh",
@@ -2165,6 +2167,7 @@ var devDependencies = {
2165
2167
  "@coze-arch/ts-config": "workspace:*",
2166
2168
  "@coze-arch/vitest-config": "workspace:*",
2167
2169
  "@coze-coding/lambda": "workspace:*",
2170
+ "@emnapi/runtime": "^1.7.1",
2168
2171
  "@inquirer/prompts": "^3.2.0",
2169
2172
  "@playwright/test": "~1.55.0",
2170
2173
  "@slardar/rd-cli": "^0.10.3",
@@ -2178,6 +2181,7 @@ var devDependencies = {
2178
2181
  "@types/shelljs": "^0.10.0",
2179
2182
  "@vitest/coverage-v8": "~4.0.18",
2180
2183
  "json-schema-to-typescript": "^15.0.3",
2184
+ knip: "^5.30.1",
2181
2185
  minimatch: "^10.0.1",
2182
2186
  playwright: "~1.55.0",
2183
2187
  rollup: "^4.60.1",
@@ -2213,7 +2217,7 @@ var packageJson = {
2213
2217
  cozePublishConfig: cozePublishConfig
2214
2218
  };
2215
2219
 
2216
- 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; }/**
2220
+ 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; }/**
2217
2221
  * Slardar 监控初始化和上报
2218
2222
  */
2219
2223
 
@@ -2316,11 +2320,11 @@ const reportCommandComplete = safeRun(
2316
2320
  ,
2317
2321
  ) => {
2318
2322
  const event = EventBuilder.cliCommandComplete(command, success, duration, {
2319
- args: _optionalChain$m([options, 'optionalAccess', _ => _.args]),
2320
- errorCode: _optionalChain$m([options, 'optionalAccess', _2 => _2.errorCode]),
2323
+ args: _optionalChain$q([options, 'optionalAccess', _ => _.args]),
2324
+ errorCode: _optionalChain$q([options, 'optionalAccess', _2 => _2.errorCode]),
2321
2325
  categories: {
2322
- ...(_optionalChain$m([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2323
- ..._optionalChain$m([options, 'optionalAccess', _4 => _4.categories]),
2326
+ ...(_optionalChain$q([options, 'optionalAccess', _3 => _3.errorMessage]) && { errorMessage: options.errorMessage }),
2327
+ ..._optionalChain$q([options, 'optionalAccess', _4 => _4.categories]),
2324
2328
  },
2325
2329
  });
2326
2330
  reporter.sendEvent(event.name, event.metrics, event.categories);
@@ -2379,7 +2383,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2379
2383
  await reporter.flush();
2380
2384
  });
2381
2385
 
2382
- function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$l(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
2386
+ function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$p(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var LogLevel; (function (LogLevel) {
2383
2387
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2384
2388
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2385
2389
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2426,7 +2430,7 @@ class Logger {
2426
2430
  return level;
2427
2431
  }
2428
2432
 
2429
- const envLevel = _optionalChain$l([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2433
+ const envLevel = _optionalChain$p([process, 'access', _ => _.env, 'access', _2 => _2.LOG_LEVEL, 'optionalAccess', _3 => _3.toLowerCase, 'call', _4 => _4()]);
2430
2434
  if (envLevel && envLevel in LOG_LEVEL_MAP) {
2431
2435
  return LOG_LEVEL_MAP[envLevel];
2432
2436
  }
@@ -2438,7 +2442,7 @@ class Logger {
2438
2442
  // 简单检测:Node.js 环境且支持 TTY
2439
2443
  return (
2440
2444
  typeof process !== 'undefined' &&
2441
- _optionalChain$l([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2445
+ _optionalChain$p([process, 'access', _5 => _5.stdout, 'optionalAccess', _6 => _6.isTTY]) === true &&
2442
2446
  process.env.NO_COLOR === undefined
2443
2447
  );
2444
2448
  }
@@ -3277,7 +3281,7 @@ const registerCommand$5 = program => {
3277
3281
  });
3278
3282
  };
3279
3283
 
3280
- function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/* eslint-disable @typescript-eslint/no-explicit-any */
3284
+ 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; }/* eslint-disable @typescript-eslint/no-explicit-any */
3281
3285
  // Safe JSON parsing utilities with type safety and error handling
3282
3286
  // Provides fallback values, validation, and error monitoring capabilities
3283
3287
 
@@ -3377,12 +3381,12 @@ function safeJsonParse(
3377
3381
  const parsed = JSON.parse(String(input));
3378
3382
 
3379
3383
  // Optional validation
3380
- if (_optionalChain$k([options, 'optionalAccess', _ => _.validate])) {
3384
+ if (_optionalChain$o([options, 'optionalAccess', _ => _.validate])) {
3381
3385
  if (options.validate(parsed)) {
3382
3386
  return parsed;
3383
3387
  } else {
3384
3388
  const validationError = new Error('JSON validation failed');
3385
- _optionalChain$k([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3389
+ _optionalChain$o([options, 'access', _2 => _2.onError, 'optionalCall', _3 => _3(validationError, input)]);
3386
3390
 
3387
3391
  if (options.throwOnValidationError) {
3388
3392
  throw validationError;
@@ -3394,10 +3398,10 @@ function safeJsonParse(
3394
3398
  return parsed;
3395
3399
  } catch (error) {
3396
3400
  // Re-throw validation errors when throwOnValidationError is true
3397
- if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$k([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3401
+ if (error instanceof Error && error.message === 'JSON validation failed' && _optionalChain$o([options, 'optionalAccess', _4 => _4.throwOnValidationError])) {
3398
3402
  throw error;
3399
3403
  }
3400
- _optionalChain$k([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3404
+ _optionalChain$o([options, 'optionalAccess', _5 => _5.onError, 'optionalCall', _6 => _6(error , input)]);
3401
3405
  return defaultValue;
3402
3406
  }
3403
3407
  }
@@ -3437,7 +3441,7 @@ function isNode(node) {
3437
3441
  }
3438
3442
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3439
3443
 
3440
- function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3444
+ 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; }
3441
3445
  const BREAK = Symbol('break visit');
3442
3446
  const SKIP = Symbol('skip children');
3443
3447
  const REMOVE = Symbol('remove node');
@@ -3550,15 +3554,15 @@ function callVisitor(key, node, visitor, path) {
3550
3554
  if (typeof visitor === 'function')
3551
3555
  return visitor(key, node, path);
3552
3556
  if (isMap(node))
3553
- return _optionalChain$j([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3557
+ return _optionalChain$n([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3554
3558
  if (isSeq(node))
3555
- return _optionalChain$j([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3559
+ return _optionalChain$n([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3556
3560
  if (isPair(node))
3557
- return _optionalChain$j([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3561
+ return _optionalChain$n([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3558
3562
  if (isScalar(node))
3559
- return _optionalChain$j([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3563
+ return _optionalChain$n([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3560
3564
  if (isAlias(node))
3561
- return _optionalChain$j([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3565
+ return _optionalChain$n([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3562
3566
  return undefined;
3563
3567
  }
3564
3568
  function replaceNode(key, path, node) {
@@ -3649,7 +3653,7 @@ function applyReviver(reviver, obj, key, val) {
3649
3653
  return reviver.call(obj, key, val);
3650
3654
  }
3651
3655
 
3652
- function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3656
+ 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; }
3653
3657
  /**
3654
3658
  * Recursively convert any node or its contents to native JavaScript
3655
3659
  *
@@ -3679,7 +3683,7 @@ function toJS(value, arg, ctx) {
3679
3683
  ctx.onCreate(res);
3680
3684
  return res;
3681
3685
  }
3682
- if (typeof value === 'bigint' && !_optionalChain$i([ctx, 'optionalAccess', _ => _.keep]))
3686
+ if (typeof value === 'bigint' && !_optionalChain$m([ctx, 'optionalAccess', _ => _.keep]))
3683
3687
  return Number(value);
3684
3688
  return value;
3685
3689
  }
@@ -3717,7 +3721,7 @@ class NodeBase {
3717
3721
  }
3718
3722
  }
3719
3723
 
3720
- 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; }
3724
+ 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; }
3721
3725
  class Alias extends NodeBase {
3722
3726
  constructor(source) {
3723
3727
  super(ALIAS);
@@ -3734,7 +3738,7 @@ class Alias extends NodeBase {
3734
3738
  */
3735
3739
  resolve(doc, ctx) {
3736
3740
  let nodes;
3737
- if (_optionalChain$h([ctx, 'optionalAccess', _ => _.aliasResolveCache])) {
3741
+ if (_optionalChain$l([ctx, 'optionalAccess', _ => _.aliasResolveCache])) {
3738
3742
  nodes = ctx.aliasResolveCache;
3739
3743
  }
3740
3744
  else {
@@ -3773,7 +3777,7 @@ class Alias extends NodeBase {
3773
3777
  data = anchors.get(source);
3774
3778
  }
3775
3779
  /* istanbul ignore if */
3776
- if (_optionalChain$h([data, 'optionalAccess', _2 => _2.res]) === undefined) {
3780
+ if (_optionalChain$l([data, 'optionalAccess', _2 => _2.res]) === undefined) {
3777
3781
  const msg = 'This should not happen: Alias anchor was not resolved?';
3778
3782
  throw new ReferenceError(msg);
3779
3783
  }
@@ -3825,7 +3829,7 @@ function getAliasCount(doc, node, anchors) {
3825
3829
  return 1;
3826
3830
  }
3827
3831
 
3828
- 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; }
3832
+ function _optionalChain$k(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3829
3833
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3830
3834
  class Scalar extends NodeBase {
3831
3835
  constructor(value) {
@@ -3833,7 +3837,7 @@ class Scalar extends NodeBase {
3833
3837
  this.value = value;
3834
3838
  }
3835
3839
  toJSON(arg, ctx) {
3836
- return _optionalChain$g([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3840
+ return _optionalChain$k([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3837
3841
  }
3838
3842
  toString() {
3839
3843
  return String(this.value);
@@ -3845,7 +3849,7 @@ Scalar.PLAIN = 'PLAIN';
3845
3849
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3846
3850
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3847
3851
 
3848
- function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$f(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3852
+ function _nullishCoalesce$7(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3849
3853
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3850
3854
  function findTagObject(value, tagName, tags) {
3851
3855
  if (tagName) {
@@ -3855,7 +3859,7 @@ function findTagObject(value, tagName, tags) {
3855
3859
  throw new Error(`Tag ${tagName} not found`);
3856
3860
  return tagObj;
3857
3861
  }
3858
- return tags.find(t => _optionalChain$f([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3862
+ return tags.find(t => _optionalChain$j([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3859
3863
  }
3860
3864
  function createNode(value, tagName, ctx) {
3861
3865
  if (isDocument(value))
@@ -3863,7 +3867,7 @@ function createNode(value, tagName, ctx) {
3863
3867
  if (isNode(value))
3864
3868
  return value;
3865
3869
  if (isPair(value)) {
3866
- const map = _optionalChain$f([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3870
+ const map = _optionalChain$j([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3867
3871
  map.items.push(value);
3868
3872
  return map;
3869
3873
  }
@@ -3890,7 +3894,7 @@ function createNode(value, tagName, ctx) {
3890
3894
  sourceObjects.set(value, ref);
3891
3895
  }
3892
3896
  }
3893
- if (_optionalChain$f([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3897
+ if (_optionalChain$j([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3894
3898
  tagName = defaultTagPrefix + tagName.slice(2);
3895
3899
  let tagObj = findTagObject(value, tagName, schema.tags);
3896
3900
  if (!tagObj) {
@@ -3915,9 +3919,9 @@ function createNode(value, tagName, ctx) {
3915
3919
  onTagObj(tagObj);
3916
3920
  delete ctx.onTagObj;
3917
3921
  }
3918
- const node = _optionalChain$f([tagObj, 'optionalAccess', _9 => _9.createNode])
3922
+ const node = _optionalChain$j([tagObj, 'optionalAccess', _9 => _9.createNode])
3919
3923
  ? tagObj.createNode(ctx.schema, value, ctx)
3920
- : typeof _optionalChain$f([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3924
+ : typeof _optionalChain$j([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3921
3925
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
3922
3926
  : new Scalar(value);
3923
3927
  if (tagName)
@@ -4235,7 +4239,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4235
4239
  return end;
4236
4240
  }
4237
4241
 
4238
- 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; }
4242
+ function _optionalChain$i(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4239
4243
  const getFoldOptions = (ctx, isBlock) => ({
4240
4244
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4241
4245
  lineWidth: ctx.options.lineWidth,
@@ -4520,9 +4524,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4520
4524
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4521
4525
  // and others in v1.1.
4522
4526
  if (actualString) {
4523
- const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$e([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4527
+ const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$i([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4524
4528
  const { compat, tags } = ctx.doc.schema;
4525
- if (tags.some(test) || _optionalChain$e([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4529
+ if (tags.some(test) || _optionalChain$i([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4526
4530
  return quotedString(value, ctx);
4527
4531
  }
4528
4532
  return implicitKey
@@ -4568,7 +4572,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4568
4572
  return res;
4569
4573
  }
4570
4574
 
4571
- function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4575
+ function _nullishCoalesce$6(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; }
4572
4576
  function createStringifyContext(doc, options) {
4573
4577
  const opt = Object.assign({
4574
4578
  blockQuote: true,
@@ -4621,7 +4625,7 @@ function getTagObject(tags, item) {
4621
4625
  let obj;
4622
4626
  if (isScalar(item)) {
4623
4627
  obj = item.value;
4624
- let match = tags.filter(t => _optionalChain$d([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4628
+ let match = tags.filter(t => _optionalChain$h([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4625
4629
  if (match.length > 1) {
4626
4630
  const testMatch = match.filter(t => t.test);
4627
4631
  if (testMatch.length > 0)
@@ -4635,7 +4639,7 @@ function getTagObject(tags, item) {
4635
4639
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4636
4640
  }
4637
4641
  if (!tagObj) {
4638
- const name = _nullishCoalesce$6(_optionalChain$d([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4642
+ const name = _nullishCoalesce$6(_optionalChain$h([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4639
4643
  throw new Error(`Tag not resolved for ${name} value`);
4640
4644
  }
4641
4645
  return tagObj;
@@ -4661,7 +4665,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4661
4665
  if (isAlias(item)) {
4662
4666
  if (ctx.doc.directives)
4663
4667
  return item.toString(ctx);
4664
- if (_optionalChain$d([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4668
+ if (_optionalChain$h([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4665
4669
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4666
4670
  }
4667
4671
  else {
@@ -4843,7 +4847,7 @@ function warn(logLevel, warning) {
4843
4847
  }
4844
4848
  }
4845
4849
 
4846
- 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; }
4850
+ 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; }
4847
4851
  // If the value associated with a merge key is a single mapping node, each of
4848
4852
  // its key/value pairs is inserted into the current mapping, unless the key
4849
4853
  // already exists in it. If the value associated with the merge key is a
@@ -4867,7 +4871,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4867
4871
  (isScalar(key) &&
4868
4872
  (!key.type || key.type === Scalar.PLAIN) &&
4869
4873
  merge.identify(key.value))) &&
4870
- _optionalChain$c([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)]);
4874
+ _optionalChain$g([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)]);
4871
4875
  function addMergeToJSMap(ctx, map, value) {
4872
4876
  value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
4873
4877
  if (isSeq(value))
@@ -4904,7 +4908,7 @@ function mergeValue(ctx, map, value) {
4904
4908
  return map;
4905
4909
  }
4906
4910
 
4907
- 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; }
4911
+ 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; }
4908
4912
  function addPairToJSMap(ctx, map, { key, value }) {
4909
4913
  if (isNode(key) && key.addToJSMap)
4910
4914
  key.addToJSMap(ctx, map, value);
@@ -4941,7 +4945,7 @@ function stringifyKey(key, jsKey, ctx) {
4941
4945
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
4942
4946
  if (typeof jsKey !== 'object')
4943
4947
  return String(jsKey);
4944
- if (isNode(key) && _optionalChain$b([ctx, 'optionalAccess', _ => _.doc])) {
4948
+ if (isNode(key) && _optionalChain$f([ctx, 'optionalAccess', _ => _.doc])) {
4945
4949
  const strCtx = createStringifyContext(ctx.doc, {});
4946
4950
  strCtx.anchors = new Set();
4947
4951
  for (const node of ctx.anchors.keys())
@@ -4961,7 +4965,7 @@ function stringifyKey(key, jsKey, ctx) {
4961
4965
  return JSON.stringify(jsKey);
4962
4966
  }
4963
4967
 
4964
- 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; }
4968
+ 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; }
4965
4969
  function createPair(key, value, ctx) {
4966
4970
  const k = createNode(key, undefined, ctx);
4967
4971
  const v = createNode(value, undefined, ctx);
@@ -4982,17 +4986,17 @@ class Pair {
4982
4986
  return new Pair(key, value);
4983
4987
  }
4984
4988
  toJSON(_, ctx) {
4985
- const pair = _optionalChain$a([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4989
+ const pair = _optionalChain$e([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4986
4990
  return addPairToJSMap(ctx, pair, this);
4987
4991
  }
4988
4992
  toString(ctx, onComment, onChompKeep) {
4989
- return _optionalChain$a([ctx, 'optionalAccess', _3 => _3.doc])
4993
+ return _optionalChain$e([ctx, 'optionalAccess', _3 => _3.doc])
4990
4994
  ? stringifyPair(this, ctx, onComment, onChompKeep)
4991
4995
  : JSON.stringify(this);
4992
4996
  }
4993
4997
  }
4994
4998
 
4995
- function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4999
+ function _nullishCoalesce$4(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$d(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
4996
5000
  function stringifyCollection(collection, ctx, options) {
4997
5001
  const flow = _nullishCoalesce$4(ctx.inFlow, () => ( collection.flow));
4998
5002
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
@@ -5086,7 +5090,7 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5086
5090
  if (iv.commentBefore)
5087
5091
  reqNewline = true;
5088
5092
  }
5089
- else if (item.value == null && _optionalChain$9([ik, 'optionalAccess', _ => _.comment])) {
5093
+ else if (item.value == null && _optionalChain$d([ik, 'optionalAccess', _ => _.comment])) {
5090
5094
  comment = ik.comment;
5091
5095
  }
5092
5096
  }
@@ -5141,7 +5145,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5141
5145
  }
5142
5146
  }
5143
5147
 
5144
- function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5148
+ function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$c(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5145
5149
  function findPair(items, key) {
5146
5150
  const k = isScalar(key) ? key.value : key;
5147
5151
  for (const it of items) {
@@ -5202,12 +5206,12 @@ class YAMLMap extends Collection {
5202
5206
  _pair = pair;
5203
5207
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5204
5208
  // In TypeScript, this never happens.
5205
- _pair = new Pair(pair, _optionalChain$8([pair, 'optionalAccess', _2 => _2.value]));
5209
+ _pair = new Pair(pair, _optionalChain$c([pair, 'optionalAccess', _2 => _2.value]));
5206
5210
  }
5207
5211
  else
5208
5212
  _pair = new Pair(pair.key, pair.value);
5209
5213
  const prev = findPair(this.items, _pair.key);
5210
- const sortEntries = _optionalChain$8([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5214
+ const sortEntries = _optionalChain$c([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5211
5215
  if (prev) {
5212
5216
  if (!overwrite)
5213
5217
  throw new Error(`Key ${_pair.key} already set`);
@@ -5237,7 +5241,7 @@ class YAMLMap extends Collection {
5237
5241
  }
5238
5242
  get(key, keepScalar) {
5239
5243
  const it = findPair(this.items, key);
5240
- const node = _optionalChain$8([it, 'optionalAccess', _5 => _5.value]);
5244
+ const node = _optionalChain$c([it, 'optionalAccess', _5 => _5.value]);
5241
5245
  return _nullishCoalesce$3((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5242
5246
  }
5243
5247
  has(key) {
@@ -5252,8 +5256,8 @@ class YAMLMap extends Collection {
5252
5256
  * @returns Instance of Type, Map, or Object
5253
5257
  */
5254
5258
  toJSON(_, ctx, Type) {
5255
- const map = Type ? new Type() : _optionalChain$8([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5256
- if (_optionalChain$8([ctx, 'optionalAccess', _7 => _7.onCreate]))
5259
+ const map = Type ? new Type() : _optionalChain$c([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5260
+ if (_optionalChain$c([ctx, 'optionalAccess', _7 => _7.onCreate]))
5257
5261
  ctx.onCreate(map);
5258
5262
  for (const item of this.items)
5259
5263
  addPairToJSMap(ctx, map, item);
@@ -5278,7 +5282,7 @@ class YAMLMap extends Collection {
5278
5282
  }
5279
5283
  }
5280
5284
 
5281
- function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5285
+ 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; }
5282
5286
  class YAMLSeq extends Collection {
5283
5287
  static get tagName() {
5284
5288
  return 'tag:yaml.org,2002:seq';
@@ -5341,7 +5345,7 @@ class YAMLSeq extends Collection {
5341
5345
  }
5342
5346
  toJSON(_, ctx) {
5343
5347
  const seq = [];
5344
- if (_optionalChain$7([ctx, 'optionalAccess', _2 => _2.onCreate]))
5348
+ if (_optionalChain$b([ctx, 'optionalAccess', _2 => _2.onCreate]))
5345
5349
  ctx.onCreate(seq);
5346
5350
  let i = 0;
5347
5351
  for (const item of this.items)
@@ -5420,7 +5424,7 @@ function createPairs(schema, iterable, ctx) {
5420
5424
  return pairs;
5421
5425
  }
5422
5426
 
5423
- function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5427
+ 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; }
5424
5428
  class YAMLOMap extends YAMLSeq {
5425
5429
  constructor() {
5426
5430
  super();
@@ -5439,7 +5443,7 @@ class YAMLOMap extends YAMLSeq {
5439
5443
  if (!ctx)
5440
5444
  return super.toJSON(_);
5441
5445
  const map = new Map();
5442
- if (_optionalChain$6([ctx, 'optionalAccess', _2 => _2.onCreate]))
5446
+ if (_optionalChain$a([ctx, 'optionalAccess', _2 => _2.onCreate]))
5443
5447
  ctx.onCreate(map);
5444
5448
  for (const pair of this.items) {
5445
5449
  let key, value;
@@ -5557,7 +5561,7 @@ const isDirExists = async (file) => {
5557
5561
  }
5558
5562
  };
5559
5563
 
5560
- function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ABOUTME: Project type detection utility
5564
+ function _optionalChain$9(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// ABOUTME: Project type detection utility
5561
5565
 
5562
5566
  /**
5563
5567
  * 支持的项目类型枚举
@@ -5659,7 +5663,7 @@ const collectProjectInfo = async (
5659
5663
  }
5660
5664
 
5661
5665
  const scripts = Object.entries(
5662
- (_optionalChain$5([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5666
+ (_optionalChain$9([packageJson, 'optionalAccess', _ => _.scripts]) ) || {},
5663
5667
  ).reduce((acc, [name, script]) => {
5664
5668
  if (typeof script === 'string') {
5665
5669
  acc[name] = script;
@@ -5813,7 +5817,7 @@ const detectProjectType = async (
5813
5817
  };
5814
5818
  };
5815
5819
 
5816
- function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5820
+ function _optionalChain$8(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5817
5821
 
5818
5822
 
5819
5823
  /**
@@ -5987,16 +5991,16 @@ const getCommandConfig = (
5987
5991
 
5988
5992
  switch (commandName) {
5989
5993
  case 'dev':
5990
- commandConfig = _optionalChain$4([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5994
+ commandConfig = _optionalChain$8([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5991
5995
  break;
5992
5996
  case 'build':
5993
- commandConfig = _optionalChain$4([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5997
+ commandConfig = _optionalChain$8([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5994
5998
  break;
5995
5999
  case 'start':
5996
- commandConfig = _optionalChain$4([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
6000
+ commandConfig = _optionalChain$8([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5997
6001
  break;
5998
6002
  case 'validate':
5999
- commandConfig = _optionalChain$4([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
6003
+ commandConfig = _optionalChain$8([config, 'access', _7 => _7.dev, 'optionalAccess', _8 => _8.validate]);
6000
6004
  break;
6001
6005
  default:
6002
6006
  throw new Error(`Unknown command: ${commandName}`);
@@ -6147,6 +6151,727 @@ const byFlag = (flag) => {
6147
6151
  return predicate;
6148
6152
  };
6149
6153
 
6154
+ function _optionalChain$7(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6155
+
6156
+
6157
+
6158
+
6159
+
6160
+
6161
+ const PATCH_ID$6 = 'expo/validate@0.0.20';
6162
+ const PACKAGE_JSON_FILE$4 = 'package.json';
6163
+ const VALIDATE_SCRIPT_FILE$3 = '.cozeproj/scripts/validate.sh';
6164
+ const EXPO_VALIDATE_FLAG = 'coding.arch.patch_expo_validate';
6165
+ const TARGET_VALIDATE$3 = "pnpm run --parallel '/^(lint:client|lint:server)$/'";
6166
+ const TARGET_VALIDATE_SCRIPT$3 = `#!/bin/bash
6167
+ set -Eeuo pipefail
6168
+ cd "\${COZE_WORKSPACE_PATH:-$(pwd)}"
6169
+ echo "Running validate..."
6170
+ pnpm validate
6171
+ echo "Validate passed!"
6172
+ `;
6173
+
6174
+
6175
+
6176
+
6177
+
6178
+ /**
6179
+ * 检查 .coze 文件是否合法
6180
+ * dev.validate 不存在即合法
6181
+ * @param cozeConfig
6182
+ * @returns
6183
+ */
6184
+ const isCozeValid$3 = (cozeConfig) => {
6185
+ if (_optionalChain$7([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6186
+ logger.info('[patch-expo-validate] NOT APPLY: dev.validate exists');
6187
+ return false;
6188
+ }
6189
+ return true;
6190
+ };
6191
+
6192
+ /**
6193
+ * 检查 package.json 文件是否合法
6194
+ * 1.文件存在且格式正确
6195
+ * 2.依赖项lint:client与lint:server存在
6196
+ * 3.不存在validate
6197
+ * @param projectFolder
6198
+ * @returns
6199
+ */
6200
+ const isPackageJsonValid$3 = async (projectFolder) => {
6201
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
6202
+ if (!(await isFileExists(packageJsonPath))) {
6203
+ logger.info('[patch-expo-validate] NOT APPLY: package.json not found');
6204
+ return false;
6205
+ }
6206
+
6207
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6208
+ const packageJson = safeJsonParse(packageJsonContent, null);
6209
+ if (!packageJson) {
6210
+ logger.info('[patch-expo-validate] NOT APPLY: package.json is invalid');
6211
+ return false;
6212
+ }
6213
+
6214
+ const scripts = packageJson.scripts || {};
6215
+ if (typeof scripts['lint:client'] !== 'string') {
6216
+ logger.info('[patch-expo-validate] NOT APPLY: lint:client not found');
6217
+ return false;
6218
+ }
6219
+ if (typeof scripts['lint:server'] !== 'string') {
6220
+ logger.info('[patch-expo-validate] NOT APPLY: lint:server not found');
6221
+ return false;
6222
+ }
6223
+ if (typeof scripts.validate !== 'undefined') {
6224
+ logger.info('[patch-expo-validate] NOT APPLY: pnpm validate exists');
6225
+ return false;
6226
+ }
6227
+ return true;
6228
+ };
6229
+
6230
+ /**
6231
+ * 检查 validate.sh 文件是否合法
6232
+ * 目标文件不存在即为合法
6233
+ * @param projectFolder
6234
+ * @returns
6235
+ */
6236
+ const isScriptValid$3 = async (projectFolder) => {
6237
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
6238
+ if (await isFileExists(validateScriptPath)) {
6239
+ logger.info('NOT APPLY: validate.sh already exists');
6240
+ return false;
6241
+ }
6242
+ return true;
6243
+ };
6244
+
6245
+ /**
6246
+ * 补全 package.json 文件中的 validate 脚本
6247
+ * @param projectFolder
6248
+ * @returns
6249
+ */
6250
+ const patchPackageJson$3 = async (projectFolder) => {
6251
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$4);
6252
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6253
+ const packageJson = safeJsonParse(packageJsonContent, null);
6254
+ const scripts = packageJson.scripts || {};
6255
+ scripts.validate = TARGET_VALIDATE$3;
6256
+ packageJson.scripts = scripts;
6257
+ await fs$1.writeFile(
6258
+ packageJsonPath,
6259
+ `${JSON.stringify(packageJson, null, 2)}\n`,
6260
+ 'utf-8',
6261
+ );
6262
+ logger.info('[patch-expo-validate] package.json patched');
6263
+ };
6264
+
6265
+ /**
6266
+ * 补全 validate.sh 文件
6267
+ * @param projectFolder
6268
+ * @returns
6269
+ */
6270
+ const patchValidateScript$3 = async (projectFolder) => {
6271
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$3);
6272
+ await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
6273
+ await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$3, 'utf-8');
6274
+ logger.info('[patch-expo-validate] validate.sh patched');
6275
+ };
6276
+
6277
+ /**
6278
+ * 补全 .coze 文件中的 dev.validate 命令
6279
+ * @param cozeConfig
6280
+ * @returns
6281
+ */
6282
+ const patchCoze$3 = (cozeConfig) => {
6283
+ cozeConfig.dev = {
6284
+ ...(cozeConfig.dev || {}),
6285
+ validate: ['bash', '.cozeproj/scripts/validate.sh'],
6286
+ };
6287
+ logger.info('[patch-expo-validate] .coze patched');
6288
+ };
6289
+
6290
+ const patchExpoValidate = {
6291
+ id: PATCH_ID$6,
6292
+ template: 'expo',
6293
+ disabled: byFlag(EXPO_VALIDATE_FLAG),
6294
+ operations: [
6295
+ {
6296
+ kind: 'file-patch',
6297
+ file: PACKAGE_JSON_FILE$4,
6298
+ description: 'Add validate script for expo projects',
6299
+ },
6300
+ {
6301
+ kind: 'create-file',
6302
+ file: VALIDATE_SCRIPT_FILE$3,
6303
+ description: 'Add validate shell script for expo projects',
6304
+ },
6305
+ {
6306
+ kind: 'file-patch',
6307
+ file: '.coze',
6308
+ description: 'Add dev.validate command for expo projects',
6309
+ },
6310
+ ],
6311
+
6312
+ shouldApply: async context =>
6313
+ isCozeValid$3(context.cozeConfig) &&
6314
+ (await isPackageJsonValid$3(context.projectFolder)) &&
6315
+ (await isScriptValid$3(context.projectFolder)),
6316
+
6317
+ apply: async (context) => {
6318
+ await patchPackageJson$3(context.projectFolder);
6319
+ await patchValidateScript$3(context.projectFolder);
6320
+ patchCoze$3(context.cozeConfig);
6321
+
6322
+ return {
6323
+ applied: true,
6324
+ patchId: PATCH_ID$6,
6325
+ message: 'expo validate patched',
6326
+ };
6327
+ },
6328
+ };
6329
+
6330
+ function _optionalChain$6(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6331
+
6332
+
6333
+
6334
+
6335
+
6336
+
6337
+ const PATCH_ID$5 = 'nextjs/validate@0.0.20';
6338
+ const PACKAGE_JSON_FILE$3 = 'package.json';
6339
+ const VALIDATE_SCRIPT_FILE$2 = 'scripts/validate.sh';
6340
+ const NEXTJS_VALIDATE_FLAG = 'coding.arch.patch_nextjs_validate';
6341
+ const TARGET_LINT_BUILD$2 = 'eslint . --quiet';
6342
+ const TARGET_VALIDATE$2 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
6343
+ const TARGET_VALIDATE_SCRIPT$2 = `#!/bin/bash
6344
+ set -Eeuo pipefail
6345
+ COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
6346
+ cd "\${COZE_WORKSPACE_PATH}"
6347
+ echo "Running validate..."
6348
+ pnpm validate
6349
+ echo "Validate passed!"
6350
+ `;
6351
+
6352
+
6353
+
6354
+
6355
+
6356
+ /**
6357
+ * 检查 .coze 文件是否合法
6358
+ * dev.validate 不存在即合法
6359
+ * @param cozeConfig
6360
+ * @returns
6361
+ */
6362
+ const isCozeValid$2 = (cozeConfig) => {
6363
+ if (_optionalChain$6([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6364
+ logger.info('[patch-nextjs-validate] NOT APPLY: dev.validate exists');
6365
+ return false;
6366
+ }
6367
+ return true;
6368
+ };
6369
+
6370
+ /**
6371
+ * 检查 package.json 文件是否合法
6372
+ * 1.文件存在且格式正确
6373
+ * 2.依赖项 ts-check 存在
6374
+ * 3.validate 不存在
6375
+ * @param projectFolder
6376
+ * @returns
6377
+ */
6378
+ const isPackageJsonValid$2 = async (projectFolder) => {
6379
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
6380
+ if (!(await isFileExists(packageJsonPath))) {
6381
+ logger.info('[patch-nextjs-validate] NOT APPLY: package.json not found');
6382
+ return false;
6383
+ }
6384
+
6385
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6386
+ const packageJson = safeJsonParse(packageJsonContent, null);
6387
+ if (!packageJson) {
6388
+ logger.info('[patch-nextjs-validate] NOT APPLY: package.json is invalid');
6389
+ return false;
6390
+ }
6391
+
6392
+ const scripts = packageJson.scripts || {};
6393
+ if (typeof scripts['ts-check'] !== 'string') {
6394
+ logger.info('[patch-nextjs-validate] NOT APPLY: ts-check not found');
6395
+ return false;
6396
+ }
6397
+ if (typeof scripts.validate !== 'undefined') {
6398
+ logger.info('[patch-nextjs-validate] NOT APPLY: pnpm validate exists');
6399
+ return false;
6400
+ }
6401
+ return true;
6402
+ };
6403
+
6404
+ /**
6405
+ * 检查 validate.sh 文件是否合法
6406
+ * 目标文件不存在即为合法
6407
+ * @param projectFolder
6408
+ * @returns
6409
+ */
6410
+ const isScriptValid$2 = async (projectFolder) => {
6411
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
6412
+ if (await isFileExists(validateScriptPath)) {
6413
+ logger.info(
6414
+ '[patch-nextjs-validate] NOT APPLY: validate.sh already exists',
6415
+ );
6416
+ return false;
6417
+ }
6418
+ return true;
6419
+ };
6420
+
6421
+ /**
6422
+ * 补全 package.json 文件中的 lint:build 和 validate 脚本
6423
+ * @param projectFolder
6424
+ * @returns
6425
+ */
6426
+ const patchPackageJson$2 = async (projectFolder) => {
6427
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$3);
6428
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6429
+ const packageJson = safeJsonParse(packageJsonContent, null);
6430
+ const scripts = packageJson.scripts || {};
6431
+
6432
+ // lint:build 不存在时才覆盖
6433
+ if (typeof scripts['lint:build'] === 'undefined') {
6434
+ scripts['lint:build'] = TARGET_LINT_BUILD$2;
6435
+ }
6436
+ scripts.validate = TARGET_VALIDATE$2;
6437
+ packageJson.scripts = scripts;
6438
+ await fs$1.writeFile(
6439
+ packageJsonPath,
6440
+ `${JSON.stringify(packageJson, null, 2)}\n`,
6441
+ 'utf-8',
6442
+ );
6443
+ logger.info('[patch-nextjs-validate] package.json patched');
6444
+ };
6445
+
6446
+ /**
6447
+ * 补全 validate.sh 文件
6448
+ * @param projectFolder
6449
+ * @returns
6450
+ */
6451
+ const patchValidateScript$2 = async (projectFolder) => {
6452
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$2);
6453
+ await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
6454
+ await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$2, 'utf-8');
6455
+ logger.info('[patch-nextjs-validate] validate.sh patched');
6456
+ };
6457
+
6458
+ /**
6459
+ * 补全 .coze 文件中的 dev.validate 命令
6460
+ * @param cozeConfig
6461
+ * @returns
6462
+ */
6463
+ const patchCoze$2 = (cozeConfig) => {
6464
+ cozeConfig.dev = {
6465
+ ...(cozeConfig.dev || {}),
6466
+ validate: ['bash', './scripts/validate.sh'],
6467
+ };
6468
+ logger.info('[patch-nextjs-validate] .coze patched');
6469
+ };
6470
+
6471
+ const patchNextjsValidate = {
6472
+ id: PATCH_ID$5,
6473
+ template: 'nextjs',
6474
+ disabled: byFlag(NEXTJS_VALIDATE_FLAG),
6475
+ operations: [
6476
+ {
6477
+ kind: 'file-patch',
6478
+ file: PACKAGE_JSON_FILE$3,
6479
+ description: 'Add lint:build and validate scripts for nextjs projects',
6480
+ },
6481
+ {
6482
+ kind: 'create-file',
6483
+ file: VALIDATE_SCRIPT_FILE$2,
6484
+ description: 'Add validate shell script for nextjs projects',
6485
+ },
6486
+ {
6487
+ kind: 'file-patch',
6488
+ file: '.coze',
6489
+ description: 'Add dev.validate command for nextjs projects',
6490
+ },
6491
+ ],
6492
+
6493
+ shouldApply: async context =>
6494
+ isCozeValid$2(context.cozeConfig) &&
6495
+ (await isPackageJsonValid$2(context.projectFolder)) &&
6496
+ (await isScriptValid$2(context.projectFolder)),
6497
+
6498
+ apply: async (context) => {
6499
+ await patchPackageJson$2(context.projectFolder);
6500
+ await patchValidateScript$2(context.projectFolder);
6501
+ patchCoze$2(context.cozeConfig);
6502
+
6503
+ return {
6504
+ applied: true,
6505
+ patchId: PATCH_ID$5,
6506
+ message: 'nextjs validate patched',
6507
+ };
6508
+ },
6509
+ };
6510
+
6511
+ function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6512
+
6513
+
6514
+
6515
+
6516
+
6517
+
6518
+ const PATCH_ID$4 = 'vite/validate@0.0.20';
6519
+ const PACKAGE_JSON_FILE$2 = 'package.json';
6520
+ const VALIDATE_SCRIPT_FILE$1 = 'scripts/validate.sh';
6521
+ const VITE_VALIDATE_FLAG = 'coding.arch.patch_vite_validate';
6522
+ const TARGET_LINT_BUILD$1 = 'eslint . --quiet';
6523
+ const TARGET_VALIDATE$1 = "pnpm run --parallel '/^(ts-check|lint:build)$/'";
6524
+ const TARGET_VALIDATE_SCRIPT$1 = `#!/bin/bash
6525
+ set -Eeuo pipefail
6526
+ COZE_WORKSPACE_PATH="\${COZE_WORKSPACE_PATH:-$(pwd)}"
6527
+ cd "\${COZE_WORKSPACE_PATH}"
6528
+ echo "Running validate..."
6529
+ pnpm validate
6530
+ echo "Validate passed!"
6531
+ `;
6532
+
6533
+
6534
+
6535
+
6536
+
6537
+ /**
6538
+ * 检查 .coze 文件是否合法
6539
+ * dev.validate 不存在即合法
6540
+ * @param cozeConfig
6541
+ * @returns
6542
+ */
6543
+ const isCozeValid$1 = (cozeConfig) => {
6544
+ if (_optionalChain$5([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6545
+ logger.info('[patch-vite-validate] NOT APPLY: dev.validate exists');
6546
+ return false;
6547
+ }
6548
+ return true;
6549
+ };
6550
+
6551
+ /**
6552
+ * 检查 package.json 文件是否合法
6553
+ * 1.文件存在且格式正确
6554
+ * 2.依赖项 ts-check 存在
6555
+ * 3.validate 不存在
6556
+ * @param projectFolder
6557
+ * @returns
6558
+ */
6559
+ const isPackageJsonValid$1 = async (projectFolder) => {
6560
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6561
+ if (!(await isFileExists(packageJsonPath))) {
6562
+ logger.info('[patch-vite-validate] NOT APPLY: package.json not found');
6563
+ return false;
6564
+ }
6565
+
6566
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6567
+ const packageJson = safeJsonParse(packageJsonContent, null);
6568
+ if (!packageJson) {
6569
+ logger.info('[patch-vite-validate] NOT APPLY: package.json is invalid');
6570
+ return false;
6571
+ }
6572
+
6573
+ const scripts = packageJson.scripts || {};
6574
+ if (typeof scripts['ts-check'] !== 'string') {
6575
+ logger.info('[patch-vite-validate] NOT APPLY: ts-check not found');
6576
+ return false;
6577
+ }
6578
+ if (typeof scripts.validate !== 'undefined') {
6579
+ logger.info('[patch-vite-validate] NOT APPLY: pnpm validate exists');
6580
+ return false;
6581
+ }
6582
+ return true;
6583
+ };
6584
+
6585
+ /**
6586
+ * 检查 validate.sh 文件是否合法
6587
+ * 目标文件不存在即为合法
6588
+ * @param projectFolder
6589
+ * @returns
6590
+ */
6591
+ const isScriptValid$1 = async (projectFolder) => {
6592
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6593
+ if (await isFileExists(validateScriptPath)) {
6594
+ logger.info('[patch-vite-validate] NOT APPLY: validate.sh already exists');
6595
+ return false;
6596
+ }
6597
+ return true;
6598
+ };
6599
+
6600
+ /**
6601
+ * 补全 package.json 文件中的 lint:build 和 validate 脚本
6602
+ * @param projectFolder
6603
+ * @returns
6604
+ */
6605
+ const patchPackageJson$1 = async (projectFolder) => {
6606
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$2);
6607
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6608
+ const packageJson = safeJsonParse(packageJsonContent, null);
6609
+ const scripts = packageJson.scripts || {};
6610
+ if (typeof scripts['lint:build'] === 'undefined') {
6611
+ // lint:build 不存在时才覆盖
6612
+ scripts['lint:build'] = TARGET_LINT_BUILD$1;
6613
+ }
6614
+ scripts.validate = TARGET_VALIDATE$1;
6615
+ packageJson.scripts = scripts;
6616
+ await fs$1.writeFile(
6617
+ packageJsonPath,
6618
+ `${JSON.stringify(packageJson, null, 2)}\n`,
6619
+ 'utf-8',
6620
+ );
6621
+ logger.info('[patch-vite-validate] package.json patched');
6622
+ };
6623
+
6624
+ /**
6625
+ * 补全 validate.sh 文件
6626
+ * @param projectFolder
6627
+ * @returns
6628
+ */
6629
+ const patchValidateScript$1 = async (projectFolder) => {
6630
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE$1);
6631
+ await fs$1.mkdir(path.join(projectFolder, 'scripts'), { recursive: true });
6632
+ await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT$1, 'utf-8');
6633
+ logger.info('[patch-vite-validate] validate.sh patched');
6634
+ };
6635
+
6636
+ /**
6637
+ * 补全 .coze 文件中的 dev.validate 命令
6638
+ * @param cozeConfig
6639
+ * @returns
6640
+ */
6641
+ const patchCoze$1 = (cozeConfig) => {
6642
+ cozeConfig.dev = {
6643
+ ...(cozeConfig.dev || {}),
6644
+ validate: ['bash', './scripts/validate.sh'],
6645
+ };
6646
+ logger.info('[patch-vite-validate] .coze patched');
6647
+ };
6648
+
6649
+ const patchViteValidate = {
6650
+ id: PATCH_ID$4,
6651
+ template: 'vite',
6652
+ disabled: byFlag(VITE_VALIDATE_FLAG),
6653
+ operations: [
6654
+ {
6655
+ kind: 'file-patch',
6656
+ file: PACKAGE_JSON_FILE$2,
6657
+ description: 'Add lint:build and validate scripts for vite projects',
6658
+ },
6659
+ {
6660
+ kind: 'create-file',
6661
+ file: VALIDATE_SCRIPT_FILE$1,
6662
+ description: 'Add validate shell script for vite projects',
6663
+ },
6664
+ {
6665
+ kind: 'file-patch',
6666
+ file: '.coze',
6667
+ description: 'Add dev.validate command for vite projects',
6668
+ },
6669
+ ],
6670
+
6671
+ shouldApply: async context =>
6672
+ isCozeValid$1(context.cozeConfig) &&
6673
+ (await isPackageJsonValid$1(context.projectFolder)) &&
6674
+ (await isScriptValid$1(context.projectFolder)),
6675
+
6676
+ apply: async (context) => {
6677
+ await patchPackageJson$1(context.projectFolder);
6678
+ await patchValidateScript$1(context.projectFolder);
6679
+ patchCoze$1(context.cozeConfig);
6680
+
6681
+ return {
6682
+ applied: true,
6683
+ patchId: PATCH_ID$4,
6684
+ message: 'vite validate patched',
6685
+ };
6686
+ },
6687
+ };
6688
+
6689
+ function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6690
+
6691
+
6692
+
6693
+
6694
+
6695
+
6696
+ const PATCH_ID$3 = 'taro/validate@0.0.20';
6697
+ const PACKAGE_JSON_FILE$1 = 'package.json';
6698
+ const VALIDATE_SCRIPT_FILE = '.cozeproj/scripts/validate.sh';
6699
+ const TARO_VALIDATE_FLAG = 'coding.arch.patch_taro_validate';
6700
+
6701
+ const LEGACY_LINT_BUILD =
6702
+ 'eslint "src/**/*.{js,jsx,ts,tsx,css}" --max-warnings=0';
6703
+ const TARGET_LINT_BUILD =
6704
+ 'eslint "src/**/*.{js,jsx,ts,tsx,css}" --max-warnings=0 --quiet';
6705
+ const TARGET_VALIDATE =
6706
+ 'pnpm exec concurrently --kill-others-on-fail --kill-signal SIGKILL -n lint,tsc -c red,blue "pnpm lint:build" "pnpm tsc"';
6707
+ const TARGET_VALIDATE_SCRIPT = `#!/bin/bash
6708
+ set -Eeuo pipefail
6709
+ cd "\${COZE_WORKSPACE_PATH}"
6710
+ echo "Running validate..."
6711
+ pnpm validate
6712
+ echo "Validate passed!"
6713
+ `;
6714
+
6715
+
6716
+
6717
+
6718
+
6719
+ /**
6720
+ * 检查 .coze 文件是否合法
6721
+ * dev.validate 不存在即合法
6722
+ * @param cozeConfig
6723
+ * @returns
6724
+ */
6725
+ const isCozeValid = (cozeConfig) => {
6726
+ if (_optionalChain$4([cozeConfig, 'access', _ => _.dev, 'optionalAccess', _2 => _2.validate])) {
6727
+ logger.info('[patch-taro-validate] NOT APPLY: dev.validate exists');
6728
+ return false;
6729
+ }
6730
+ return true;
6731
+ };
6732
+
6733
+ /**
6734
+ * 检查 package.json 文件是否合法
6735
+ * 1.文件存在且格式正确
6736
+ * 2.依赖项 tsc 与 lint:build 存在
6737
+ * 3.validate 不存在
6738
+ * @param projectFolder
6739
+ * @returns
6740
+ */
6741
+ const isPackageJsonValid = async (projectFolder) => {
6742
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
6743
+ if (!(await isFileExists(packageJsonPath))) {
6744
+ logger.info('[patch-taro-validate] NOT APPLY: package.json not found');
6745
+ return false;
6746
+ }
6747
+
6748
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6749
+ const packageJson = safeJsonParse(packageJsonContent, null);
6750
+ if (!packageJson) {
6751
+ logger.info('[patch-taro-validate] NOT APPLY: package.json is invalid');
6752
+ return false;
6753
+ }
6754
+
6755
+ const scripts = packageJson.scripts || {};
6756
+ if (typeof scripts.tsc !== 'string') {
6757
+ logger.info('[patch-taro-validate] NOT APPLY: tsc script not found');
6758
+ return false;
6759
+ }
6760
+
6761
+ if (typeof scripts.validate !== 'undefined') {
6762
+ logger.info('[patch-taro-validate] NOT APPLY: pnpm validate exists');
6763
+ return false;
6764
+ }
6765
+
6766
+ return true;
6767
+ };
6768
+
6769
+ /**
6770
+ * 检查 validate.sh 文件是否合法
6771
+ * 目标文件不存在即为合法
6772
+ * @param projectFolder
6773
+ * @returns
6774
+ */
6775
+ const isScriptValid = async (projectFolder) => {
6776
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
6777
+ if (await isFileExists(validateScriptPath)) {
6778
+ logger.info('[patch-taro-validate] NOT APPLY: validate.sh already exists');
6779
+ return false;
6780
+ }
6781
+ return true;
6782
+ };
6783
+
6784
+ /**
6785
+ * 补全 package.json 文件中的 lint:build 和 validate 脚本
6786
+ * @param projectFolder
6787
+ * @returns
6788
+ */
6789
+ const patchPackageJson = async (projectFolder) => {
6790
+ const packageJsonPath = path.join(projectFolder, PACKAGE_JSON_FILE$1);
6791
+ const packageJsonContent = await fs$1.readFile(packageJsonPath, 'utf-8');
6792
+ const packageJson = safeJsonParse(packageJsonContent, null);
6793
+ const scripts = packageJson.scripts || {};
6794
+
6795
+ // lint:build 为旧模板值时才修正为带 --quiet 的版本
6796
+ const lintBuild = scripts['lint:build'];
6797
+ if (lintBuild === LEGACY_LINT_BUILD) {
6798
+ scripts['lint:build'] = TARGET_LINT_BUILD;
6799
+ }
6800
+
6801
+ scripts.validate = TARGET_VALIDATE;
6802
+ packageJson.scripts = scripts;
6803
+ await fs$1.writeFile(
6804
+ packageJsonPath,
6805
+ `${JSON.stringify(packageJson, null, 2)}\n`,
6806
+ 'utf-8',
6807
+ );
6808
+ logger.info('[patch-taro-validate] package.json patched');
6809
+ };
6810
+
6811
+ /**
6812
+ * 补全 validate.sh 文件
6813
+ * @param projectFolder
6814
+ * @returns
6815
+ */
6816
+ const patchValidateScript = async (projectFolder) => {
6817
+ const validateScriptPath = path.join(projectFolder, VALIDATE_SCRIPT_FILE);
6818
+ await fs$1.mkdir(path.join(projectFolder, '.cozeproj', 'scripts'), { recursive: true });
6819
+ await fs$1.writeFile(validateScriptPath, TARGET_VALIDATE_SCRIPT, 'utf-8');
6820
+ logger.info('[patch-taro-validate] validate.sh patched');
6821
+ };
6822
+
6823
+ /**
6824
+ * 补全 .coze 文件中的 dev.validate 命令
6825
+ * @param cozeConfig
6826
+ * @returns
6827
+ */
6828
+ const patchCoze = (cozeConfig) => {
6829
+ cozeConfig.dev = {
6830
+ ...(cozeConfig.dev || {}),
6831
+ validate: ['bash', '.cozeproj/scripts/validate.sh'],
6832
+ };
6833
+ logger.info('[patch-taro-validate] .coze patched');
6834
+ };
6835
+
6836
+ const patchTaroValidate = {
6837
+ id: PATCH_ID$3,
6838
+ template: 'taro',
6839
+ disabled: byFlag(TARO_VALIDATE_FLAG),
6840
+ operations: [
6841
+ {
6842
+ kind: 'file-patch',
6843
+ file: PACKAGE_JSON_FILE$1,
6844
+ description:
6845
+ 'Update lint:build and add validate script for taro projects',
6846
+ },
6847
+ {
6848
+ kind: 'create-file',
6849
+ file: VALIDATE_SCRIPT_FILE,
6850
+ description: 'Add validate shell script for taro projects',
6851
+ },
6852
+ {
6853
+ kind: 'file-patch',
6854
+ file: '.coze',
6855
+ description: 'Add dev.validate command for taro projects',
6856
+ },
6857
+ ],
6858
+ shouldApply: async context =>
6859
+ isCozeValid(context.cozeConfig) &&
6860
+ (await isPackageJsonValid(context.projectFolder)) &&
6861
+ (await isScriptValid(context.projectFolder)),
6862
+ apply: async (context) => {
6863
+ await patchPackageJson(context.projectFolder);
6864
+ await patchValidateScript(context.projectFolder);
6865
+ patchCoze(context.cozeConfig);
6866
+
6867
+ return {
6868
+ applied: true,
6869
+ patchId: PATCH_ID$3,
6870
+ message: 'taro validate patched',
6871
+ };
6872
+ },
6873
+ };
6874
+
6150
6875
  function _optionalChain$3(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
6151
6876
  const PATCH_ID$2 = 'taro/update-pack-script-for-tt-build@0.0.13';
6152
6877
  const PACKAGE_JSON_FILE = 'package.json';
@@ -6567,11 +7292,15 @@ const patchNextOutputTracingRoot = {
6567
7292
  };
6568
7293
 
6569
7294
  const patches = [
7295
+ patchExpoValidate,
6570
7296
  replaceNpxWithPnpmPatchNextjs,
7297
+ patchNextjsValidate,
6571
7298
  replaceNpxWithPnpmPatchVite,
7299
+ patchViteValidate,
6572
7300
  replaceNpxWithPnpmPatchNuxtVue,
6573
7301
  patchNextOutputTracingRoot,
6574
7302
  patchTaroAgentsMd,
7303
+ patchTaroValidate,
6575
7304
  patchTaroPackScript,
6576
7305
  ] ;
6577
7306