@coze-arch/cli 0.0.23 → 0.0.24

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.
@@ -10,3 +10,5 @@ expo-env.d.ts
10
10
  logs/
11
11
  *.tsbuildinfo
12
12
  node-compile-cache/
13
+ .cozeproj/reduction
14
+ .preview
@@ -42,11 +42,8 @@ const config = {
42
42
  console.log(`Creating Expo project: ${context.appName}`);
43
43
  return context;
44
44
  },
45
- onAfterRender: async (context, outputPath) => {
46
- console.log(`\nProject created at: ${outputPath}`);
47
- console.log(`\nConfiguration:`);
48
- console.log(` - Framework: Expo`);
49
- console.log(` - Port: ${context.port}`);
45
+ onAfterRender: async (_context, _outputPath) => {
46
+ // 输出由 init 命令统一处理
50
47
  },
51
48
  onComplete: async (_context, outputPath) => {
52
49
  // Skip pnpm update in test environment to avoid monorepo workspace issues
@@ -0,0 +1,2 @@
1
+ .cozeproj/reduction
2
+ .preview
@@ -98,3 +98,5 @@ Desktop.ini
98
98
  .turbo
99
99
 
100
100
  .coze-logs
101
+ .cozeproj/reduction
102
+ .preview
@@ -53,13 +53,8 @@ const config = {
53
53
  return context;
54
54
  },
55
55
 
56
- onAfterRender: async (_context, outputPath) => {
57
- console.log(`\nProject created at: ${outputPath}`);
58
- console.log('\nConfiguration:');
59
- console.log(' - Framework: Next.js');
60
- console.log(' - TypeScript: enabled');
61
- console.log(' - App Router: enabled');
62
- console.log(` - Port: ${_context.port}`);
56
+ onAfterRender: async (_context, _outputPath) => {
57
+ // 输出由 init 命令统一处理
63
58
  },
64
59
 
65
60
  onComplete: async (_context, outputPath) => {
@@ -1,4 +1,5 @@
1
1
  # Nuxt dev/build outputs
2
+
2
3
  .output
3
4
  .data
4
5
  .nuxt
@@ -8,18 +9,24 @@ dist
8
9
  node-compile-cache
9
10
 
10
11
  # Node dependencies
12
+
11
13
  node_modules
12
14
 
13
15
  # Logs
16
+
14
17
  logs
15
- *.log
18
+ \*.log
16
19
 
17
20
  # Misc
21
+
18
22
  .DS_Store
19
23
  .fleet
20
24
  .idea
21
25
 
22
26
  # Local env files
27
+
23
28
  .env
24
- .env.*
29
+ .env.\*
25
30
  !.env.example
31
+ .cozeproj/reduction
32
+ .preview
@@ -62,14 +62,8 @@ const config = {
62
62
  return context;
63
63
  },
64
64
 
65
- onAfterRender: async (_context, outputPath) => {
66
- console.log(`\nProject created at: ${outputPath}`);
67
- console.log('\nConfiguration:');
68
- console.log(' - Framework: Nuxt.js');
69
- console.log(' - TypeScript: enabled');
70
- console.log(' - Vue: 3.x');
71
- console.log(' - Build Tool: Vite');
72
- console.log(` - Port: ${_context.port}`);
65
+ onAfterRender: async (_context, _outputPath) => {
66
+ // 输出由 init 命令统一处理
73
67
  },
74
68
 
75
69
  onComplete: async (_context, _outputPath) => {
@@ -1,3 +1,5 @@
1
1
  node_modules
2
2
  dist
3
- .env
3
+ .env
4
+ .cozeproj/reduction
5
+ .preview
@@ -39,3 +39,5 @@ pnpm-debug.log*
39
39
 
40
40
  # Key
41
41
  # key/
42
+ .cozeproj/reduction
43
+ .preview
@@ -54,14 +54,8 @@ const config = {
54
54
  console.log(`Creating Taro project: ${context.appName}`);
55
55
  return context;
56
56
  },
57
- onAfterRender: async (context, outputPath) => {
58
- console.log(`\nProject created at: ${outputPath}`);
59
- console.log('\nConfiguration:');
60
- console.log(' - Framework: Taro 4 + NestJS');
61
- console.log(' - TypeScript: enabled');
62
- console.log(' - Platforms: H5, WeChat Mini Program');
63
- console.log(` - H5 Port: ${context.port}`);
64
- console.log(` - Server Port: ${context.serverPort}`);
57
+ onAfterRender: async (_context, _outputPath) => {
58
+ // 输出由 init 命令统一处理
65
59
  },
66
60
  };
67
61
 
@@ -66,3 +66,5 @@ Thumbs.db
66
66
  .vite/
67
67
 
68
68
  .coze-logs
69
+ .cozeproj/reduction
70
+ .preview
@@ -60,13 +60,8 @@ const config = {
60
60
  return context;
61
61
  },
62
62
 
63
- onAfterRender: async (_context, outputPath) => {
64
- console.log(`\nProject created at: ${outputPath}`);
65
- console.log('\nConfiguration:');
66
- console.log(' - Framework: vite');
67
- console.log(' - TypeScript: enabled');
68
- console.log(' - App Router: enabled');
69
- console.log(` - Port: ${_context.port}`);
63
+ onAfterRender: async (_context, _outputPath) => {
64
+ // 输出由 init 命令统一处理
70
65
  },
71
66
 
72
67
  onComplete: async (_context, outputPath) => {
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$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; }/**
1631
+ function _nullishCoalesce$a(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
  */
@@ -1685,7 +1685,7 @@ class SlardarCLIReporter {constructor() { SlardarCLIReporter.prototype.__init.ca
1685
1685
  release: config.release,
1686
1686
  env: config.env,
1687
1687
  name: config.name,
1688
- useLocalConfig: _nullishCoalesce$9(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1688
+ useLocalConfig: _nullishCoalesce$a(config.useLocalConfig, () => ( false)), // 默认使用服务端配置
1689
1689
  domain: config.domain,
1690
1690
  // 设置本地采样率为 100%,确保事件不被过滤
1691
1691
  sample: {
@@ -2107,7 +2107,7 @@ const EventBuilder = {
2107
2107
  };
2108
2108
 
2109
2109
  var name = "@coze-arch/cli";
2110
- var version = "0.0.22";
2110
+ var version = "0.0.24";
2111
2111
  var description = "coze coding devtools cli";
2112
2112
  var license = "MIT";
2113
2113
  var author = "fanwenjie.fe@bytedance.com";
@@ -2180,15 +2180,15 @@ var devDependencies = {
2180
2180
  "@types/minimist": "^1.2.5",
2181
2181
  "@types/node": "^24",
2182
2182
  "@types/shelljs": "^0.10.0",
2183
- "@vitest/coverage-v8": "~4.1.6",
2183
+ "@vitest/coverage-v8": "~4.1.7",
2184
2184
  knip: "^5.30.1",
2185
2185
  minimatch: "^10.0.1",
2186
- playwright: "~1.55.0",
2186
+ playwright: "~1.60.0",
2187
2187
  rollup: "^4.60.1",
2188
- sucrase: "^3.35.0",
2188
+ sucrase: "^3.35.1",
2189
2189
  "tree-kill": "^1.2.2",
2190
2190
  tsx: "^4.21.0",
2191
- vitest: "~4.1.6"
2191
+ vitest: "~4.1.7"
2192
2192
  };
2193
2193
  var publishConfig = {
2194
2194
  access: "public",
@@ -2382,7 +2382,7 @@ const flushSlardar = safeRun('flushSlardar', async () => {
2382
2382
  await reporter.flush();
2383
2383
  });
2384
2384
 
2385
- 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) {
2385
+ function _nullishCoalesce$9(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) {
2386
2386
  const ERROR = 0; LogLevel[LogLevel["ERROR"] = ERROR] = "ERROR";
2387
2387
  const WARN = 1; LogLevel[LogLevel["WARN"] = WARN] = "WARN";
2388
2388
  const SUCCESS = 2; LogLevel[LogLevel["SUCCESS"] = SUCCESS] = "SUCCESS";
@@ -2420,7 +2420,7 @@ class Logger {
2420
2420
 
2421
2421
  constructor(options = {}) {
2422
2422
  this.level = this.parseLogLevel(options.level);
2423
- this.useColor = _nullishCoalesce$8(options.useColor, () => ( this.isColorSupported()));
2423
+ this.useColor = _nullishCoalesce$9(options.useColor, () => ( this.isColorSupported()));
2424
2424
  this.prefix = options.prefix;
2425
2425
  }
2426
2426
 
@@ -2466,7 +2466,7 @@ class Logger {
2466
2466
 
2467
2467
  const icon = this.colorize(options.icon, options.color);
2468
2468
  const prefix = this.prefix ? `${icon} ${this.prefix}` : icon;
2469
- console.log(prefix, options.message, ...(_nullishCoalesce$8(options.args, () => ( []))));
2469
+ console.log(prefix, options.message, ...(_nullishCoalesce$9(options.args, () => ( []))));
2470
2470
  }
2471
2471
 
2472
2472
  error(message, ...args) {
@@ -2720,10 +2720,11 @@ const getTemplatePath = async (
2720
2720
  try {
2721
2721
  await fs$1.access(templatePath);
2722
2722
  logger.verbose(' - Template directory exists: ✓');
2723
- // eslint-disable-next-line @coze-arch/use-error-in-catch -- Error handling done in throw statement
2724
- } catch (e) {
2723
+ } catch (error) {
2725
2724
  logger.error(' - Template directory does not exist: ✗');
2726
- throw new Error(`Template directory not found: ${templatePath}`);
2725
+ throw new Error(
2726
+ `Template directory not found: ${templatePath} (cause: ${error instanceof Error ? error.message : String(error)})`,
2727
+ );
2727
2728
  }
2728
2729
 
2729
2730
  return templatePath;
@@ -3850,12 +3851,12 @@ Scalar.PLAIN = 'PLAIN';
3850
3851
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3851
3852
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3852
3853
 
3853
- 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; }
3854
+ function _nullishCoalesce$8(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$j(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3854
3855
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3855
3856
  function findTagObject(value, tagName, tags) {
3856
3857
  if (tagName) {
3857
3858
  const match = tags.filter(t => t.tag === tagName);
3858
- const tagObj = _nullishCoalesce$7(match.find(t => !t.format), () => ( match[0]));
3859
+ const tagObj = _nullishCoalesce$8(match.find(t => !t.format), () => ( match[0]));
3859
3860
  if (!tagObj)
3860
3861
  throw new Error(`Tag ${tagName} not found`);
3861
3862
  return tagObj;
@@ -3887,7 +3888,7 @@ function createNode(value, tagName, ctx) {
3887
3888
  if (aliasDuplicateObjects && value && typeof value === 'object') {
3888
3889
  ref = sourceObjects.get(value);
3889
3890
  if (ref) {
3890
- _nullishCoalesce$7(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3891
+ _nullishCoalesce$8(ref.anchor, () => ( (ref.anchor = onAnchor(value))));
3891
3892
  return new Alias(ref.anchor);
3892
3893
  }
3893
3894
  else {
@@ -4573,7 +4574,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4573
4574
  return res;
4574
4575
  }
4575
4576
 
4576
- 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; }
4577
+ function _nullishCoalesce$7(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; }
4577
4578
  function createStringifyContext(doc, options) {
4578
4579
  const opt = Object.assign({
4579
4580
  blockQuote: true,
@@ -4620,7 +4621,7 @@ function getTagObject(tags, item) {
4620
4621
  if (item.tag) {
4621
4622
  const match = tags.filter(t => t.tag === item.tag);
4622
4623
  if (match.length > 0)
4623
- return _nullishCoalesce$6(match.find(t => t.format === item.format), () => ( match[0]));
4624
+ return _nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match[0]));
4624
4625
  }
4625
4626
  let tagObj = undefined;
4626
4627
  let obj;
@@ -4633,14 +4634,14 @@ function getTagObject(tags, item) {
4633
4634
  match = testMatch;
4634
4635
  }
4635
4636
  tagObj =
4636
- _nullishCoalesce$6(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4637
+ _nullishCoalesce$7(match.find(t => t.format === item.format), () => ( match.find(t => !t.format)));
4637
4638
  }
4638
4639
  else {
4639
4640
  obj = item;
4640
4641
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4641
4642
  }
4642
4643
  if (!tagObj) {
4643
- const name = _nullishCoalesce$6(_optionalChain$h([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4644
+ const name = _nullishCoalesce$7(_optionalChain$h([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4644
4645
  throw new Error(`Tag not resolved for ${name} value`);
4645
4646
  }
4646
4647
  return tagObj;
@@ -4655,7 +4656,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
4655
4656
  anchors.add(anchor);
4656
4657
  props.push(`&${anchor}`);
4657
4658
  }
4658
- const tag = _nullishCoalesce$6(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4659
+ const tag = _nullishCoalesce$7(node.tag, () => ( (tagObj.default ? null : tagObj.tag)));
4659
4660
  if (tag)
4660
4661
  props.push(doc.directives.tagString(tag));
4661
4662
  return props.join(' ');
@@ -4681,10 +4682,10 @@ function stringify(item, ctx, onComment, onChompKeep) {
4681
4682
  const node = isNode(item)
4682
4683
  ? item
4683
4684
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
4684
- _nullishCoalesce$6(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4685
+ _nullishCoalesce$7(tagObj, () => ( (tagObj = getTagObject(ctx.doc.schema.tags, node))));
4685
4686
  const props = stringifyProps(node, tagObj, ctx);
4686
4687
  if (props.length > 0)
4687
- ctx.indentAtStart = (_nullishCoalesce$6(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4688
+ ctx.indentAtStart = (_nullishCoalesce$7(ctx.indentAtStart, () => ( 0))) + props.length + 1;
4688
4689
  const str = typeof tagObj.stringify === 'function'
4689
4690
  ? tagObj.stringify(node, ctx, onComment, onChompKeep)
4690
4691
  : isScalar(node)
@@ -4697,7 +4698,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4697
4698
  : `${props}\n${ctx.indent}${str}`;
4698
4699
  }
4699
4700
 
4700
- function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4701
+ function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
4701
4702
  function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4702
4703
  const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
4703
4704
  let keyComment = (isNode(key) && key.comment) || null;
@@ -4807,7 +4808,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
4807
4808
  const vs0 = valueStr[0];
4808
4809
  const nl0 = valueStr.indexOf('\n');
4809
4810
  const hasNewline = nl0 !== -1;
4810
- const flow = _nullishCoalesce$5(_nullishCoalesce$5(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4811
+ const flow = _nullishCoalesce$6(_nullishCoalesce$6(ctx.inFlow, () => ( value.flow)), () => ( value.items.length === 0));
4811
4812
  if (hasNewline || !flow) {
4812
4813
  let hasPropsLine = false;
4813
4814
  if (hasNewline && (vs0 === '&' || vs0 === '!')) {
@@ -5000,9 +5001,9 @@ class Pair {
5000
5001
  }
5001
5002
  }
5002
5003
 
5003
- 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; }
5004
+ function _nullishCoalesce$5(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; }
5004
5005
  function stringifyCollection(collection, ctx, options) {
5005
- const flow = _nullishCoalesce$4(ctx.inFlow, () => ( collection.flow));
5006
+ const flow = _nullishCoalesce$5(ctx.inFlow, () => ( collection.flow));
5006
5007
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
5007
5008
  return stringify(collection, ctx, options);
5008
5009
  }
@@ -5149,7 +5150,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5149
5150
  }
5150
5151
  }
5151
5152
 
5152
- 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; }
5153
+ function _nullishCoalesce$4(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; }
5153
5154
  function findPair(items, key) {
5154
5155
  const k = isScalar(key) ? key.value : key;
5155
5156
  for (const it of items) {
@@ -5246,7 +5247,7 @@ class YAMLMap extends Collection {
5246
5247
  get(key, keepScalar) {
5247
5248
  const it = findPair(this.items, key);
5248
5249
  const node = _optionalChain$c([it, 'optionalAccess', _5 => _5.value]);
5249
- return _nullishCoalesce$3((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5250
+ return _nullishCoalesce$4((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5250
5251
  }
5251
5252
  has(key) {
5252
5253
  return !!findPair(this.items, key);
@@ -7313,7 +7314,7 @@ const getTemplatePatches = (
7313
7314
  ) =>
7314
7315
  patches.filter(patch => patch.template === template);
7315
7316
 
7316
- function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7317
+ function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$2(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7317
7318
  const DEFAULT_LEGACY_VERSION = 'legacy';
7318
7319
 
7319
7320
  const loadFlagsWithFallback = async () => {
@@ -7496,7 +7497,7 @@ const executePatch = async (
7496
7497
 
7497
7498
  if (options.dryRun) {
7498
7499
  logger.info(`Detected template: ${template}`);
7499
- logger.info(`Current version: ${_nullishCoalesce$2(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7500
+ logger.info(`Current version: ${_nullishCoalesce$3(projectVersion, () => ( DEFAULT_LEGACY_VERSION))}`);
7500
7501
  logger.info(`Applied patches: ${appliedPatches.join(', ') || '(none)'}`);
7501
7502
  logger.info('Matched patches:');
7502
7503
  matchedPatches.forEach(patch => {
@@ -7561,7 +7562,9 @@ const registerCommand$4 = program => {
7561
7562
  );
7562
7563
  };
7563
7564
 
7564
- function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7565
+ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
7566
+ const d$1 = debug('coze-init-cli:run');
7567
+
7565
7568
  /**
7566
7569
  * 日志文件名常量
7567
7570
  */
@@ -7661,9 +7664,12 @@ const executeRun = async (
7661
7664
  const fixStartTime = Date.now();
7662
7665
  try {
7663
7666
  await executePatch();
7664
- // eslint-disable-next-line @coze-arch/no-empty-catch, @coze-arch/use-error-in-catch -- intentionally ignored
7665
- } catch (_e) {
7666
- // fix errors are intentionally ignored to allow the main command to proceed
7667
+ } catch (patchError) {
7668
+ // patch errors are intentionally non-fatal: trace and proceed with the main command
7669
+ d$1(
7670
+ 'patch step failed (continuing): %s',
7671
+ patchError instanceof Error ? patchError.message : String(patchError),
7672
+ );
7667
7673
  }
7668
7674
  fixDuration = Date.now() - fixStartTime;
7669
7675
  logger.info('');
@@ -7715,7 +7721,7 @@ const executeRun = async (
7715
7721
  const buildDuration = Date.now() - buildStartTime;
7716
7722
 
7717
7723
  if (code !== 0) {
7718
- const errorMessage = `Command exited with code ${_nullishCoalesce$1(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7724
+ const errorMessage = `Command exited with code ${_nullishCoalesce$2(code, () => ( 'unknown'))}${signal ? ` and signal ${signal}` : ''}`;
7719
7725
  logger.error(errorMessage);
7720
7726
  logger.error(`Check log file for details: ${logFilePath}`);
7721
7727
 
@@ -7727,12 +7733,12 @@ const executeRun = async (
7727
7733
  categories: {
7728
7734
  fixDuration: String(fixDuration),
7729
7735
  buildDuration: String(buildDuration),
7730
- exitCode: String(_nullishCoalesce$1(code, () => ( 'unknown'))),
7736
+ exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
7731
7737
  projectType,
7732
7738
  },
7733
7739
  errorContext: {
7734
- exitCode: String(_nullishCoalesce$1(code, () => ( 'unknown'))),
7735
- signal: _nullishCoalesce$1(signal, () => ( 'none')),
7740
+ exitCode: String(_nullishCoalesce$2(code, () => ( 'unknown'))),
7741
+ signal: _nullishCoalesce$2(signal, () => ( 'none')),
7736
7742
  logFile: logFilePath,
7737
7743
  projectType,
7738
7744
  },
@@ -8741,6 +8747,9 @@ const registerCommand$2 = program => {
8741
8747
  });
8742
8748
  };
8743
8749
 
8750
+ function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
8751
+
8752
+
8744
8753
  const d = debug('coze-init-cli:check-bins');
8745
8754
 
8746
8755
 
@@ -8752,7 +8761,6 @@ const d = debug('coze-init-cli:check-bins');
8752
8761
  const checkBins = async (cwd, fix) => {
8753
8762
  d('starting check, cwd=%s fix=%s', cwd, fix);
8754
8763
 
8755
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- fallback {} ensures non-null
8756
8764
  const pkgJson = safeJsonParse
8757
8765
 
8758
8766
 
@@ -8796,8 +8804,7 @@ const checkBins = async (cwd, fix) => {
8796
8804
 
8797
8805
  const bins =
8798
8806
  typeof depPkg.bin === 'string'
8799
- ? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- split always has ≥1 element
8800
- { [depName.split('/').pop()]: depPkg.bin }
8807
+ ? { [_nullishCoalesce$1(depName.split('/').pop(), () => ( depName))]: depPkg.bin }
8801
8808
  : depPkg.bin;
8802
8809
 
8803
8810
  d('%s declares bins: %o', depName, Object.keys(bins));
@@ -8953,6 +8960,8 @@ const validateParams = (
8953
8960
  return params ;
8954
8961
  };
8955
8962
 
8963
+ const ARGV_USER_ARGS_OFFSET = 2;
8964
+
8956
8965
  /**
8957
8966
  * 从 Commander 解析透传参数
8958
8967
  * 将 kebab-case 的 CLI 参数转换为 camelCase
@@ -8967,9 +8976,7 @@ const parsePassThroughParams = (
8967
8976
  command,
8968
8977
  knownOptions = new Set(),
8969
8978
  ) => {
8970
- // 使用 minimist 解析所有参数
8971
- // eslint-disable-next-line @typescript-eslint/no-magic-numbers -- slice(2) to skip node and script path
8972
- const parsed = minimist(process.argv.slice(2));
8979
+ const parsed = minimist(process.argv.slice(ARGV_USER_ARGS_OFFSET));
8973
8980
 
8974
8981
  // 过滤掉已知选项和位置参数(_)
8975
8982
  const filtered = Object.entries(parsed).reduce(
@@ -9276,6 +9283,49 @@ const prepareFileInfo = async (options
9276
9283
  return processedFileInfo;
9277
9284
  };
9278
9285
 
9286
+ /**
9287
+ * 合并 .gitignore 文件内容
9288
+ * 将新内容中的条目合并到已有内容中,避免重复
9289
+ *
9290
+ * @param existingContent - 已有的 .gitignore 内容
9291
+ * @param newContent - 新的 .gitignore 内容
9292
+ * @returns 合并后的内容
9293
+ */
9294
+ const mergeGitignoreContent = (
9295
+ existingContent,
9296
+ newContent,
9297
+ ) => {
9298
+ const existingLines = new Set(
9299
+ existingContent
9300
+ .split('\n')
9301
+ .map(line => line.trim())
9302
+ .filter(line => line.length > 0),
9303
+ );
9304
+
9305
+ const newLines = newContent.split('\n');
9306
+ const linesToAppend = [];
9307
+
9308
+ for (const line of newLines) {
9309
+ const trimmed = line.trim();
9310
+ // 跳过空行和已存在的条目
9311
+ if (trimmed.length === 0 || existingLines.has(trimmed)) {
9312
+ continue;
9313
+ }
9314
+ linesToAppend.push(line);
9315
+ }
9316
+
9317
+ if (linesToAppend.length === 0) {
9318
+ return existingContent;
9319
+ }
9320
+
9321
+ // 确保已有内容以换行结尾
9322
+ const base = existingContent.endsWith('\n')
9323
+ ? existingContent
9324
+ : existingContent + '\n';
9325
+
9326
+ return base + linesToAppend.join('\n') + '\n';
9327
+ };
9328
+
9279
9329
  /**
9280
9330
  * 写入渲染后的文件到目标路径
9281
9331
  *
@@ -9308,9 +9358,21 @@ const writeRenderedFile = async (options
9308
9358
  logger.verbose(' ✓ Written (binary, modified by hook)');
9309
9359
  }
9310
9360
  } else {
9311
- // 文本文件
9312
- await fs$1.writeFile(destPath, fileInfo.content, 'utf-8');
9313
- logger.verbose(' Rendered and written');
9361
+ // .gitignore 文件:合并而非覆盖
9362
+ const fileName = path.basename(destPath);
9363
+ if (fileName === '.gitignore' && fs.existsSync(destPath)) {
9364
+ const existingContent = await fs$1.readFile(destPath, 'utf-8');
9365
+ const mergedContent = mergeGitignoreContent(
9366
+ existingContent,
9367
+ fileInfo.content,
9368
+ );
9369
+ await fs$1.writeFile(destPath, mergedContent, 'utf-8');
9370
+ logger.verbose(' ✓ Merged with existing .gitignore');
9371
+ } else {
9372
+ // 其他文本文件
9373
+ await fs$1.writeFile(destPath, fileInfo.content, 'utf-8');
9374
+ logger.verbose(' ✓ Rendered and written');
9375
+ }
9314
9376
  }
9315
9377
  };
9316
9378
  // end_aigc
@@ -9704,26 +9766,24 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else {
9704
9766
  */
9705
9767
  const runPnpmInstall = (projectPath) => {
9706
9768
  logger.info('\nInstalling dependencies with pnpm...');
9707
- logger.info(`Executing: pnpm install in ${projectPath}`);
9708
9769
 
9709
9770
  const result = shelljs.exec('pnpm install', {
9710
9771
  cwd: projectPath,
9711
- silent: true, // 使用 silent 来捕获输出
9772
+ silent: true,
9712
9773
  });
9713
9774
 
9714
- // 输出 stdout
9775
+ // verbose 模式下输出 pnpm install 的详细日志
9715
9776
  if (result.stdout) {
9716
- process.stdout.write(result.stdout);
9777
+ logger.verbose(result.stdout);
9717
9778
  }
9718
-
9719
- // 输出 stderr
9720
9779
  if (result.stderr) {
9721
- process.stderr.write(result.stderr);
9780
+ logger.verbose(result.stderr);
9722
9781
  }
9723
9782
 
9724
9783
  if (result.code === 0) {
9725
9784
  logger.success('Dependencies installed successfully!');
9726
9785
  } else {
9786
+ // 仅在失败时输出详细信息以便排查
9727
9787
  const errorMessage = [
9728
9788
  `pnpm install failed with exit code ${result.code}`,
9729
9789
  result.stderr ? `\nStderr:\n${result.stderr}` : '',
@@ -9740,22 +9800,11 @@ const runPnpmInstall = (projectPath) => {
9740
9800
  * 运行 git 命令的辅助函数
9741
9801
  */
9742
9802
  const runGitCommand = (command, projectPath) => {
9743
- logger.info(`Executing: ${command}`);
9744
-
9745
9803
  const result = shelljs.exec(command, {
9746
9804
  cwd: projectPath,
9747
9805
  silent: true,
9748
9806
  });
9749
9807
 
9750
- // 输出命令的结果
9751
- if (result.stdout) {
9752
- process.stdout.write(result.stdout);
9753
- }
9754
-
9755
- if (result.stderr) {
9756
- process.stderr.write(result.stderr);
9757
- }
9758
-
9759
9808
  if (result.code !== 0) {
9760
9809
  const errorMessage = [
9761
9810
  `${command} failed with exit code ${result.code}`,
@@ -9810,7 +9859,6 @@ const commitChanges = (projectPath) => {
9810
9859
  }
9811
9860
 
9812
9861
  try {
9813
- logger.info('\nCommitting initialized files...');
9814
9862
  runGitCommand('git add --all', projectPath);
9815
9863
  runGitCommand('git commit -m "chore: init env"', projectPath);
9816
9864
  logger.success('Changes committed successfully!');
@@ -9830,14 +9878,10 @@ const commitChanges = (projectPath) => {
9830
9878
  * 使用 CLI 自己的 dev 命令(定义在 run.ts)而不是直接运行 npm run dev
9831
9879
  */
9832
9880
  const runDev = (projectPath) => {
9833
- logger.info('\nStarting development server in background...');
9834
-
9835
9881
  // 获取当前 CLI 的可执行文件路径
9836
9882
  // process.argv[0] 是 node,process.argv[1] 是 CLI 入口文件
9837
9883
  const cliPath = process.argv[1];
9838
9884
 
9839
- logger.info(`Executing: ${cliPath} dev in ${projectPath}`);
9840
-
9841
9885
  try {
9842
9886
  // 使用通用的后台执行函数启动开发服务器
9843
9887
  // 调用 CLI 自己的 dev 命令
@@ -9848,7 +9892,6 @@ const runDev = (projectPath) => {
9848
9892
 
9849
9893
  if (pid) {
9850
9894
  logger.success('Development server started in background!');
9851
- logger.info(`Process ID: ${pid}`);
9852
9895
  logger.info(
9853
9896
  '\nThe dev server is running independently. You can close this terminal.',
9854
9897
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -73,15 +73,15 @@
73
73
  "@types/minimist": "^1.2.5",
74
74
  "@types/node": "^24",
75
75
  "@types/shelljs": "^0.10.0",
76
- "@vitest/coverage-v8": "~4.1.6",
76
+ "@vitest/coverage-v8": "~4.1.7",
77
77
  "knip": "^5.30.1",
78
78
  "minimatch": "^10.0.1",
79
- "playwright": "~1.55.0",
79
+ "playwright": "~1.60.0",
80
80
  "rollup": "^4.60.1",
81
- "sucrase": "^3.35.0",
81
+ "sucrase": "^3.35.1",
82
82
  "tree-kill": "^1.2.2",
83
83
  "tsx": "^4.21.0",
84
- "vitest": "~4.1.6"
84
+ "vitest": "~4.1.7"
85
85
  },
86
86
  "publishConfig": {
87
87
  "access": "public",