@coze-arch/cli 0.0.10-alpha.b1a3b0 → 0.0.11

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 (26) hide show
  1. package/lib/__templates__/expo/AGENTS.md +3 -3
  2. package/lib/__templates__/expo/README.md +3 -3
  3. package/lib/__templates__/expo/client/eslint.config.mjs +2 -0
  4. package/lib/__templates__/expo/client/heroui/components/button/button.tsx +2 -2
  5. package/lib/__templates__/expo/client/heroui/components/chip/chip.tsx +2 -2
  6. package/lib/__templates__/expo/client/heroui/components/list-group/list-group.types.ts +3 -3
  7. package/lib/__templates__/expo/client/heroui/components/pressable-feedback/index.ts +0 -1
  8. package/lib/__templates__/expo/client/heroui/components/pressable-feedback/pressable-feedback.animation.ts +1 -0
  9. package/lib/__templates__/expo/client/heroui/components/pressable-feedback/pressable-feedback.styles.ts +0 -1
  10. package/lib/__templates__/expo/client/heroui/components/skeleton/skeleton.animation.ts +1 -0
  11. package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +4 -4
  12. package/lib/__templates__/expo/client/heroui/helpers/external/utils/color-kit/index.ts +5 -2
  13. package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
  14. package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-dev-info.ts +1 -1
  15. package/lib/__templates__/expo/client/heroui/primitives/slider/slider.tsx +1 -0
  16. package/lib/__templates__/expo/client/heroui/primitives/slot/slot.tsx +1 -0
  17. package/lib/__templates__/expo/package.json +1 -1
  18. package/lib/__templates__/nextjs/AGENTS.md +6 -4
  19. package/lib/__templates__/nextjs/eslint.config.mjs +9 -0
  20. package/lib/__templates__/taro/.coze +2 -0
  21. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +1 -2
  22. package/lib/__templates__/taro/config/index.ts +1 -1
  23. package/lib/__templates__/taro/package.json +1 -0
  24. package/lib/__templates__/taro/project.config.json +1 -1
  25. package/lib/cli.js +245 -252
  26. package/package.json +2 -2
@@ -54,13 +54,13 @@ Uniwind 官方文档:https://docs.uniwind.dev/llms.txt
54
54
 
55
55
  ```bash
56
56
  # 对 client 和 server 目录同时进行校验
57
- npm run lint
57
+ pnpm -w lint:all
58
58
 
59
59
  # 对 client 目录进行校验
60
- npm run lint:client
60
+ pnpm -w lint:client
61
61
 
62
62
  # 对 server 目录进行校验
63
- npm run lint:server
63
+ pnpm -w lint:server
64
64
  ```
65
65
 
66
66
  ## 如何修改主题模式(跟随系统、固定暗色、固定亮色)
@@ -54,13 +54,13 @@ Uniwind 官方文档:https://docs.uniwind.dev/llms.txt
54
54
 
55
55
  ```bash
56
56
  # 对 client 和 server 目录同时进行校验
57
- npm run lint
57
+ pnpm -w lint:all
58
58
 
59
59
  # 对 client 目录进行校验
60
- npm run lint:client
60
+ pnpm -w lint:client
61
61
 
62
62
  # 对 server 目录进行校验
63
- npm run lint:server
63
+ pnpm -w lint:server
64
64
  ```
65
65
 
66
66
  ## 如何修改主题模式(跟随系统、固定暗色、固定亮色)
@@ -84,6 +84,8 @@ export default [
84
84
  'no-prototype-builtins': 'off',
85
85
  'react/react-in-jsx-scope': 'off',
86
86
  'react/jsx-uses-react': 'off',
87
+ 'react/display-name': 'off',
88
+ 'react/prop-types': 'off',
87
89
  'fontawesome6/valid-name': 'error',
88
90
  'reanimated/ban-mix-use': 'error',
89
91
  'forbidEmoji/no-emoji': 'error',
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, useMemo } from 'react';
2
- import { View } from 'react-native';
2
+ import { Text as RNText } from 'react-native';
3
3
  import { useThemeColor } from '../../helpers/external/hooks';
4
4
  import { colorKit } from '../../helpers/external/utils';
5
5
  import { HeroText } from '../../helpers/internal/components';
@@ -236,7 +236,7 @@ const ButtonRoot = forwardRef<PressableRef, ButtonRootProps>((props, ref) => {
236
236
 
237
237
  // --------------------------------------------------
238
238
 
239
- const ButtonLabel = forwardRef<View, ButtonLabelProps>((props, ref) => {
239
+ const ButtonLabel = forwardRef<RNText, ButtonLabelProps>((props, ref) => {
240
240
  const { children, className, ...restProps } = props;
241
241
 
242
242
  const { size, variant } = useButton();
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, useMemo } from 'react';
2
- import { Pressable, View, type StyleProp, type ViewStyle } from 'react-native';
2
+ import { Pressable, Text as RNText, type StyleProp, type ViewStyle } from 'react-native';
3
3
  import { HeroText } from '../../helpers/internal/components';
4
4
  import { AnimationSettingsProvider } from '../../helpers/internal/contexts';
5
5
  import type { PressableRef } from '../../helpers/internal/types';
@@ -78,7 +78,7 @@ const Chip = forwardRef<PressableRef, ChipProps>((props, ref) => {
78
78
 
79
79
  // --------------------------------------------------
80
80
 
81
- const ChipLabel = forwardRef<View, ChipLabelProps>((props, ref) => {
81
+ const ChipLabel = forwardRef<RNText, ChipLabelProps>((props, ref) => {
82
82
  const { children, className, ...restProps } = props;
83
83
 
84
84
  const { size, variant, color } = useChip();
@@ -1,4 +1,4 @@
1
- import type { PressableProps, ViewProps } from 'react-native';
1
+ import type { PressableProps, TextProps, ViewProps } from 'react-native';
2
2
  import type { SurfaceVariant } from '../surface/surface.types';
3
3
 
4
4
  /**
@@ -85,7 +85,7 @@ export interface ListGroupItemContentProps extends ViewProps {
85
85
  * Props for the ListGroup.ItemTitle component.
86
86
  * Renders the primary text label for an item.
87
87
  */
88
- export interface ListGroupItemTitleProps extends ViewProps {
88
+ export interface ListGroupItemTitleProps extends TextProps {
89
89
  /**
90
90
  * Title text or custom content
91
91
  */
@@ -100,7 +100,7 @@ export interface ListGroupItemTitleProps extends ViewProps {
100
100
  * Props for the ListGroup.ItemDescription component.
101
101
  * Renders secondary descriptive text below the title.
102
102
  */
103
- export interface ListGroupItemDescriptionProps extends ViewProps {
103
+ export interface ListGroupItemDescriptionProps extends TextProps {
104
104
  /**
105
105
  * Description text or custom content
106
106
  */
@@ -1,4 +1,3 @@
1
- /* eslint-disable prettier/prettier */
2
1
  export { default as PressableFeedback } from './pressable-feedback';
3
2
  export { pressableFeedbackClassNames } from './pressable-feedback.styles';
4
3
  export type * from './pressable-feedback.types';
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-hooks/preserve-manual-memoization */
1
2
  import { useCallback } from 'react';
2
3
  import type { GestureResponderEvent } from 'react-native';
3
4
  import type { SharedValue } from 'react-native-reanimated';
@@ -1,4 +1,3 @@
1
- /* eslint-disable prettier/prettier */
2
1
  import { StyleSheet } from 'react-native';
3
2
  import { tv } from 'tailwind-variants';
4
3
  import { combineStyles } from '../../helpers/internal/utils';
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-hooks/immutability */
1
2
  import { useEffect, useMemo } from 'react';
2
3
  import type { SharedValue } from 'react-native-reanimated';
3
4
  import {
@@ -1,5 +1,5 @@
1
1
  import { forwardRef, useMemo } from 'react';
2
- import { View } from 'react-native';
2
+ import { View, Text as RNText } from 'react-native';
3
3
  import { GestureDetector } from 'react-native-gesture-handler';
4
4
  import Animated from 'react-native-reanimated';
5
5
  import { useThemeColor } from '../../helpers/external/hooks';
@@ -134,7 +134,7 @@ const ToastRoot = forwardRef<ViewRef, ToastRootProps>((props, ref) => {
134
134
  {...restProps}
135
135
  >
136
136
  {children}
137
- {/*
137
+ {/*
138
138
  When visible toasts have different heights, the toast adapts to the last visible toast height.
139
139
  In cases where a toast originally has one height and gets smaller when a new toast comes to stack,
140
140
  content might be visible behind the last toast without proper padding.
@@ -174,7 +174,7 @@ const ToastRoot = forwardRef<ViewRef, ToastRootProps>((props, ref) => {
174
174
 
175
175
  // --------------------------------------------------
176
176
 
177
- const ToastTitle = forwardRef<View, ToastTitleProps>((props, ref) => {
177
+ const ToastTitle = forwardRef<RNText, ToastTitleProps>((props, ref) => {
178
178
  const { children, className, ...restProps } = props;
179
179
 
180
180
  const { variant } = useToast();
@@ -193,7 +193,7 @@ const ToastTitle = forwardRef<View, ToastTitleProps>((props, ref) => {
193
193
 
194
194
  // --------------------------------------------------
195
195
 
196
- const ToastDescription = forwardRef<View, ToastDescriptionProps>(
196
+ const ToastDescription = forwardRef<RNText, ToastDescriptionProps>(
197
197
  (props, ref) => {
198
198
  const { children, className, ...restProps } = props;
199
199
 
@@ -1,3 +1,6 @@
1
+ /* eslint-disable regexp/use-ignore-case */
2
+ /* eslint-disable regexp/optimal-quantifier-concatenation */
3
+ /* eslint-disable regexp/no-useless-quantifier */
1
4
  /**
2
5
  * Color manipulation utilities adapted from reanimated-color-picker
3
6
  *
@@ -293,7 +296,7 @@ export const colorKitUI = () => {
293
296
  ): ColorFormats | null => {
294
297
  // color int
295
298
  if (typeof color === 'number') {
296
- // eslint-disable-next-line no-bitwise
299
+
297
300
  if (color >>> 0 === color && color >= 0 && color <= 0xffffffff)
298
301
  return 'hex8';
299
302
  return null;
@@ -1491,7 +1494,7 @@ export const colorKitUI = () => {
1491
1494
  ): ColorFormats | 'named' | null => {
1492
1495
  // color int
1493
1496
  if (typeof color === 'number') {
1494
- // eslint-disable-next-line no-bitwise
1497
+
1495
1498
  if (color >>> 0 === color && color >= 0 && color <= 0xffffffff)
1496
1499
  return 'hex8';
1497
1500
  return null;
@@ -39,7 +39,7 @@ type SetStateFn<T> = (prevState?: T) => T;
39
39
  function useControllableState<T>({
40
40
  prop,
41
41
  defaultProp,
42
- onChange = () => {},
42
+ onChange = () => {}, // eslint-disable-line @typescript-eslint/no-empty-function
43
43
  }: UseControllableStateParams<T>) {
44
44
  const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({
45
45
  defaultProp,
@@ -31,7 +31,7 @@ export function useDevInfo(devInfo?: DevInfoConfig): void {
31
31
  ` - Check component documentation - Each component page includes a link to the component's style source\n` +
32
32
  `• If styles are occupied by animation, modify them via the animation prop on components that support it.\n` +
33
33
  `• To deactivate animated style completely and apply your own styles, use isAnimatedStyleActive prop.\n` +
34
- `${LOG_COLOR.YELLOW}💡 To disable this message, set config.devInfo.stylingPrinciples to false${LOG_COLOR.RESET}`
34
+ `${LOG_COLOR.YELLOW} To disable this message, set config.devInfo.stylingPrinciples to false${LOG_COLOR.RESET}`
35
35
  );
36
36
  }
37
37
  }, [stylingPrinciples]);
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-hooks/refs */
1
2
  import {
2
3
  forwardRef,
3
4
  useCallback,
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-hooks/refs */
1
2
  import {
2
3
  cloneElement,
3
4
  forwardRef,
@@ -9,7 +9,7 @@
9
9
  "preinstall": "npx only-allow pnpm",
10
10
  "lint:client": "npm run lint --prefix ./client",
11
11
  "lint:server": "npm run lint --prefix ./server",
12
- "lint": "npm run lint --prefix ./client; npm run lint --prefix ./server"
12
+ "lint:all": "npm run lint --prefix ./client; npm run lint --prefix ./server"
13
13
  },
14
14
  "dependencies": {},
15
15
  "devDependencies": {},
@@ -42,13 +42,15 @@
42
42
 
43
43
  ## 开发规范
44
44
 
45
- - **项目理解加速**:初始可以依赖项目下`package.json`文件理解项目类型,如果没有或无法理解退化成阅读其他文件。
46
- - **Hydration 错误预防**:严禁在 JSX 渲染逻辑中直接使用 typeof window、Date.now()、Math.random() 等动态数据。必须使用 'use client' 并配合 useEffect + useState 确保动态内容仅在客户端挂载后渲染;同时严禁非法 HTML 嵌套(如 <p> 嵌套 <div>)。
45
+ ### Hydration 问题防范
47
46
 
47
+ 1. 严禁在 JSX 渲染逻辑中直接使用 typeof window、Date.now()、Math.random() 等动态数据。**必须使用 'use client' 并配合 useEffect + useState 确保动态内容仅在客户端挂载后渲染**;同时严禁非法 HTML 嵌套(如 <p> 嵌套 <div>)。
48
+ 2. **禁止使用 head 标签**,优先使用 metadata,详见文档:https://nextjs.org/docs/app/api-reference/functions/generate-metadata
49
+ 1. 三方 CSS、字体等资源可在 `globals.css` 中顶部通过 `@import` 引入或使用 next/font
50
+ 2. preload, preconnect, dns-prefetch 通过 ReactDOM 的 preload、preconnect、dns-prefetch 方法引入
51
+ 3. json-ld 可阅读 https://nextjs.org/docs/app/guides/json-ld
48
52
 
49
53
  ## UI 设计与组件规范 (UI & Styling Standards)
50
54
 
51
55
  - 模板默认预装核心组件库 `shadcn/ui`,位于`src/components/ui/`目录下
52
56
  - Next.js 项目**必须默认**采用 shadcn/ui 组件、风格和规范,**除非用户指定用其他的组件和规范。**
53
-
54
-
@@ -2,12 +2,21 @@ import nextTs from 'eslint-config-next/typescript';
2
2
  import nextVitals from 'eslint-config-next/core-web-vitals';
3
3
  import { defineConfig, globalIgnores } from 'eslint/config';
4
4
 
5
+ const syntaxRules = [
6
+ {
7
+ selector: 'JSXOpeningElement[name.name="head"]',
8
+ message:
9
+ '禁止使用 head 标签,优先使用 metadata。三方 CSS、字体等资源可以在 globals.css 中顶部通过 @import 引入或者使用 next/font;preload, preconnect, dns-prefetch 通过 ReactDOM 的 preload、preconnect、dns-prefetch 方法引入;json-ld 可阅读 https://nextjs.org/docs/app/guides/json-ld',
10
+ },
11
+ ];
12
+
5
13
  const eslintConfig = defineConfig([
6
14
  ...nextVitals,
7
15
  ...nextTs,
8
16
  {
9
17
  rules: {
10
18
  'react-hooks/set-state-in-effect': 'off',
19
+ 'no-restricted-syntax': ['error', ...syntaxRules],
11
20
  },
12
21
  },
13
22
  // Override default ignores of eslint-config-next.
@@ -1,4 +1,6 @@
1
1
  [project]
2
+ template = "taro"
3
+ version = "legacy.2"
2
4
  entrypoint = "server.js"
3
5
  requires = ["nodejs-24"]
4
6
 
@@ -1,5 +1,4 @@
1
1
  # build_weapp.sh - 通过 PID 文件精确杀掉自己上次的构建进程
2
- export OUTPUT_ROOT=dist
3
2
  PID_FILE="/tmp/coze-build_weapp.pid"
4
3
 
5
4
  # 杀掉上次的构建进程组
@@ -15,7 +14,7 @@ if [ -f "$PID_FILE" ]; then
15
14
  fi
16
15
 
17
16
  # 用 setsid 创建新的进程组,方便下次整组杀掉
18
- setsid pnpm build:weapp &
17
+ setsid pnpm pack &
19
18
  echo $! > "$PID_FILE"
20
19
 
21
20
  echo "构建已启动 (PID: $(cat $PID_FILE))"
@@ -37,7 +37,7 @@ const generateTTProjectConfig = (outputRoot: string) => {
37
37
  // https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
38
38
  export default defineConfig<'vite'>(async (merge, _env) => {
39
39
  const outputRootMap: Record<string, string> = {
40
- weapp: 'dist-weapp',
40
+ weapp: 'dist',
41
41
  tt: 'dist-tt',
42
42
  h5: 'dist-web',
43
43
  };
@@ -21,6 +21,7 @@
21
21
  "lint:build": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\" --max-warnings=0",
22
22
  "lint:fix": "eslint \"src/**/*.{js,jsx,ts,tsx,css}\" --fix",
23
23
  "new": "taro new",
24
+ "pack": "pnpm exec concurrently --kill-others-on-fail --kill-signal SIGKILL -n weapp,tt -c yellow,cyan \"pnpm build:weapp\" \"pnpm build:tt\"",
24
25
  "preview:tt": "taro build --type tt --preview",
25
26
  "preview:weapp": "taro build --type weapp --preview",
26
27
  "tsc": "npx tsc --noEmit --skipLibCheck",
@@ -12,5 +12,5 @@
12
12
  "minified": false
13
13
  },
14
14
  "compileType": "miniprogram",
15
- "packOptions": {"ignore": [{"type": "folder","value": "./assets"}]}
15
+ "packOptions": { "ignore": [{ "type": "folder", "value": "./assets" }] }
16
16
  }
package/lib/cli.js CHANGED
@@ -2106,7 +2106,7 @@ const EventBuilder = {
2106
2106
  };
2107
2107
 
2108
2108
  var name = "@coze-arch/cli";
2109
- var version = "0.0.10-alpha.b1a3b0";
2109
+ var version = "0.0.11";
2110
2110
  var description = "coze coding devtools cli";
2111
2111
  var license = "MIT";
2112
2112
  var author = "fanwenjie.fe@bytedance.com";
@@ -2179,7 +2179,7 @@ var devDependencies = {
2179
2179
  "json-schema-to-typescript": "^15.0.3",
2180
2180
  minimatch: "^10.0.1",
2181
2181
  playwright: "~1.55.0",
2182
- rollup: "^4.41.1",
2182
+ rollup: "^4.60.1",
2183
2183
  sucrase: "^3.35.0",
2184
2184
  "tree-kill": "^1.2.2",
2185
2185
  tsx: "^4.20.6",
@@ -3401,118 +3401,6 @@ function safeJsonParse(
3401
3401
  }
3402
3402
  }
3403
3403
 
3404
- 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; }
3405
-
3406
-
3407
- /**
3408
- * 检测并解析配置文件内容
3409
- *
3410
- * @param content - 文件内容
3411
- * @returns 解析后的配置对象
3412
- */
3413
- const parseConfigContent = (content) => {
3414
- // 1. 尝试 TOML 格式 (默认)
3415
- try {
3416
- const config = toml.parse(content);
3417
- return config ;
3418
- } catch (error) {
3419
- // TOML 解析失败,继续尝试其他格式
3420
-
3421
- console.debug('TOML parse failed:', error);
3422
- }
3423
-
3424
- // 2. 尝试 YAML 格式
3425
- try {
3426
- const config = jsYaml.load(content);
3427
- if (config && typeof config === 'object') {
3428
- return config ;
3429
- }
3430
- } catch (error) {
3431
- // YAML 解析失败,继续尝试其他格式
3432
-
3433
- console.debug('YAML parse failed:', error);
3434
- }
3435
-
3436
- // 3. 尝试 JSON 格式
3437
- const config = safeJsonParse(content);
3438
- if (config) {
3439
- return config;
3440
- }
3441
-
3442
- return null;
3443
- };
3444
-
3445
- /**
3446
- * 加载 .coze 配置文件
3447
- *
3448
- * @param projectPath - 项目目录路径
3449
- * @returns .coze 配置对象
3450
- */
3451
- const loadCozeConfig = async (
3452
- projectPath = process.cwd(),
3453
- ) => {
3454
- const cozeConfigPath = path.join(projectPath, '.coze');
3455
-
3456
- let content;
3457
- try {
3458
- content = await fs$1.readFile(cozeConfigPath, 'utf-8');
3459
- } catch (error) {
3460
- throw new Error(
3461
- `.coze config file not found in ${projectPath}\n` +
3462
- 'Please ensure you are in a project directory initialized with coze-coding.\n' +
3463
- `Error: ${error instanceof Error ? error.message : String(error)}`,
3464
- );
3465
- }
3466
-
3467
- const config = parseConfigContent(content);
3468
- if (!config) {
3469
- throw new Error(
3470
- 'Failed to parse .coze config file.\n' +
3471
- 'Please ensure the file is in valid TOML, YAML, or JSON format.',
3472
- );
3473
- }
3474
-
3475
- return config;
3476
- };
3477
-
3478
- /**
3479
- * 获取指定命令的配置
3480
- *
3481
- * @param config - .coze 配置对象
3482
- * @param commandName - 命令名称 (dev/build/start)
3483
- * @returns 命令配置数组
3484
- */
3485
- const getCommandConfig = (
3486
- config,
3487
- commandName,
3488
- ) => {
3489
- let commandConfig;
3490
-
3491
- // 根据命令名称映射到配置路径
3492
- switch (commandName) {
3493
- case 'dev':
3494
- commandConfig = _optionalChain$g([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
3495
- break;
3496
- case 'build':
3497
- commandConfig = _optionalChain$g([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
3498
- break;
3499
- case 'start':
3500
- commandConfig = _optionalChain$g([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
3501
- break;
3502
- default:
3503
- throw new Error(`Unknown command: ${commandName}`);
3504
- }
3505
-
3506
- if (!commandConfig || commandConfig.length === 0) {
3507
- throw new Error(
3508
- `Command '${commandName}' is not configured in .coze file.\n` +
3509
- 'Please add the corresponding configuration to your .coze file.',
3510
- );
3511
- }
3512
-
3513
- return commandConfig;
3514
- };
3515
-
3516
3404
  const ALIAS = Symbol.for('yaml.alias');
3517
3405
  const DOC = Symbol.for('yaml.document');
3518
3406
  const MAP = Symbol.for('yaml.map');
@@ -3548,7 +3436,7 @@ function isNode(node) {
3548
3436
  }
3549
3437
  const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
3550
3438
 
3551
- 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; }
3439
+ 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; }
3552
3440
  const BREAK = Symbol('break visit');
3553
3441
  const SKIP = Symbol('skip children');
3554
3442
  const REMOVE = Symbol('remove node');
@@ -3661,15 +3549,15 @@ function callVisitor(key, node, visitor, path) {
3661
3549
  if (typeof visitor === 'function')
3662
3550
  return visitor(key, node, path);
3663
3551
  if (isMap(node))
3664
- return _optionalChain$f([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3552
+ return _optionalChain$g([visitor, 'access', _ => _.Map, 'optionalCall', _2 => _2(key, node, path)]);
3665
3553
  if (isSeq(node))
3666
- return _optionalChain$f([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3554
+ return _optionalChain$g([visitor, 'access', _3 => _3.Seq, 'optionalCall', _4 => _4(key, node, path)]);
3667
3555
  if (isPair(node))
3668
- return _optionalChain$f([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3556
+ return _optionalChain$g([visitor, 'access', _5 => _5.Pair, 'optionalCall', _6 => _6(key, node, path)]);
3669
3557
  if (isScalar(node))
3670
- return _optionalChain$f([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3558
+ return _optionalChain$g([visitor, 'access', _7 => _7.Scalar, 'optionalCall', _8 => _8(key, node, path)]);
3671
3559
  if (isAlias(node))
3672
- return _optionalChain$f([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3560
+ return _optionalChain$g([visitor, 'access', _9 => _9.Alias, 'optionalCall', _10 => _10(key, node, path)]);
3673
3561
  return undefined;
3674
3562
  }
3675
3563
  function replaceNode(key, path, node) {
@@ -3760,7 +3648,7 @@ function applyReviver(reviver, obj, key, val) {
3760
3648
  return reviver.call(obj, key, val);
3761
3649
  }
3762
3650
 
3763
- 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; }
3651
+ 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; }
3764
3652
  /**
3765
3653
  * Recursively convert any node or its contents to native JavaScript
3766
3654
  *
@@ -3790,7 +3678,7 @@ function toJS(value, arg, ctx) {
3790
3678
  ctx.onCreate(res);
3791
3679
  return res;
3792
3680
  }
3793
- if (typeof value === 'bigint' && !_optionalChain$e([ctx, 'optionalAccess', _ => _.keep]))
3681
+ if (typeof value === 'bigint' && !_optionalChain$f([ctx, 'optionalAccess', _ => _.keep]))
3794
3682
  return Number(value);
3795
3683
  return value;
3796
3684
  }
@@ -3828,7 +3716,7 @@ class NodeBase {
3828
3716
  }
3829
3717
  }
3830
3718
 
3831
- 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; }
3719
+ 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; }
3832
3720
  class Alias extends NodeBase {
3833
3721
  constructor(source) {
3834
3722
  super(ALIAS);
@@ -3845,7 +3733,7 @@ class Alias extends NodeBase {
3845
3733
  */
3846
3734
  resolve(doc, ctx) {
3847
3735
  let nodes;
3848
- if (_optionalChain$d([ctx, 'optionalAccess', _ => _.aliasResolveCache])) {
3736
+ if (_optionalChain$e([ctx, 'optionalAccess', _ => _.aliasResolveCache])) {
3849
3737
  nodes = ctx.aliasResolveCache;
3850
3738
  }
3851
3739
  else {
@@ -3884,7 +3772,7 @@ class Alias extends NodeBase {
3884
3772
  data = anchors.get(source);
3885
3773
  }
3886
3774
  /* istanbul ignore if */
3887
- if (_optionalChain$d([data, 'optionalAccess', _2 => _2.res]) === undefined) {
3775
+ if (_optionalChain$e([data, 'optionalAccess', _2 => _2.res]) === undefined) {
3888
3776
  const msg = 'This should not happen: Alias anchor was not resolved?';
3889
3777
  throw new ReferenceError(msg);
3890
3778
  }
@@ -3936,7 +3824,7 @@ function getAliasCount(doc, node, anchors) {
3936
3824
  return 1;
3937
3825
  }
3938
3826
 
3939
- 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; }
3827
+ 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; }
3940
3828
  const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
3941
3829
  class Scalar extends NodeBase {
3942
3830
  constructor(value) {
@@ -3944,7 +3832,7 @@ class Scalar extends NodeBase {
3944
3832
  this.value = value;
3945
3833
  }
3946
3834
  toJSON(arg, ctx) {
3947
- return _optionalChain$c([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3835
+ return _optionalChain$d([ctx, 'optionalAccess', _ => _.keep]) ? this.value : toJS(this.value, arg, ctx);
3948
3836
  }
3949
3837
  toString() {
3950
3838
  return String(this.value);
@@ -3956,7 +3844,7 @@ Scalar.PLAIN = 'PLAIN';
3956
3844
  Scalar.QUOTE_DOUBLE = 'QUOTE_DOUBLE';
3957
3845
  Scalar.QUOTE_SINGLE = 'QUOTE_SINGLE';
3958
3846
 
3959
- function _nullishCoalesce$6(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$b(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3847
+ function _nullishCoalesce$6(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; }
3960
3848
  const defaultTagPrefix = 'tag:yaml.org,2002:';
3961
3849
  function findTagObject(value, tagName, tags) {
3962
3850
  if (tagName) {
@@ -3966,7 +3854,7 @@ function findTagObject(value, tagName, tags) {
3966
3854
  throw new Error(`Tag ${tagName} not found`);
3967
3855
  return tagObj;
3968
3856
  }
3969
- return tags.find(t => _optionalChain$b([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3857
+ return tags.find(t => _optionalChain$c([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(value)]) && !t.format);
3970
3858
  }
3971
3859
  function createNode(value, tagName, ctx) {
3972
3860
  if (isDocument(value))
@@ -3974,7 +3862,7 @@ function createNode(value, tagName, ctx) {
3974
3862
  if (isNode(value))
3975
3863
  return value;
3976
3864
  if (isPair(value)) {
3977
- const map = _optionalChain$b([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3865
+ const map = _optionalChain$c([ctx, 'access', _3 => _3.schema, 'access', _4 => _4[MAP], 'access', _5 => _5.createNode, 'optionalCall', _6 => _6(ctx.schema, null, ctx)]);
3978
3866
  map.items.push(value);
3979
3867
  return map;
3980
3868
  }
@@ -4001,7 +3889,7 @@ function createNode(value, tagName, ctx) {
4001
3889
  sourceObjects.set(value, ref);
4002
3890
  }
4003
3891
  }
4004
- if (_optionalChain$b([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
3892
+ if (_optionalChain$c([tagName, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8('!!')]))
4005
3893
  tagName = defaultTagPrefix + tagName.slice(2);
4006
3894
  let tagObj = findTagObject(value, tagName, schema.tags);
4007
3895
  if (!tagObj) {
@@ -4026,9 +3914,9 @@ function createNode(value, tagName, ctx) {
4026
3914
  onTagObj(tagObj);
4027
3915
  delete ctx.onTagObj;
4028
3916
  }
4029
- const node = _optionalChain$b([tagObj, 'optionalAccess', _9 => _9.createNode])
3917
+ const node = _optionalChain$c([tagObj, 'optionalAccess', _9 => _9.createNode])
4030
3918
  ? tagObj.createNode(ctx.schema, value, ctx)
4031
- : typeof _optionalChain$b([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
3919
+ : typeof _optionalChain$c([tagObj, 'optionalAccess', _10 => _10.nodeClass, 'optionalAccess', _11 => _11.from]) === 'function'
4032
3920
  ? tagObj.nodeClass.from(ctx.schema, value, ctx)
4033
3921
  : new Scalar(value);
4034
3922
  if (tagName)
@@ -4346,7 +4234,7 @@ function consumeMoreIndentedLines(text, i, indent) {
4346
4234
  return end;
4347
4235
  }
4348
4236
 
4349
- 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; }
4237
+ 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; }
4350
4238
  const getFoldOptions = (ctx, isBlock) => ({
4351
4239
  indentAtStart: isBlock ? ctx.indent.length : ctx.indentAtStart,
4352
4240
  lineWidth: ctx.options.lineWidth,
@@ -4631,9 +4519,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
4631
4519
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
4632
4520
  // and others in v1.1.
4633
4521
  if (actualString) {
4634
- const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$a([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4522
+ const test = (tag) => tag.default && tag.tag !== 'tag:yaml.org,2002:str' && _optionalChain$b([tag, 'access', _ => _.test, 'optionalAccess', _2 => _2.test, 'call', _3 => _3(str)]);
4635
4523
  const { compat, tags } = ctx.doc.schema;
4636
- if (tags.some(test) || _optionalChain$a([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4524
+ if (tags.some(test) || _optionalChain$b([compat, 'optionalAccess', _4 => _4.some, 'call', _5 => _5(test)]))
4637
4525
  return quotedString(value, ctx);
4638
4526
  }
4639
4527
  return implicitKey
@@ -4679,7 +4567,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
4679
4567
  return res;
4680
4568
  }
4681
4569
 
4682
- function _nullishCoalesce$5(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; }
4570
+ function _nullishCoalesce$5(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
4683
4571
  function createStringifyContext(doc, options) {
4684
4572
  const opt = Object.assign({
4685
4573
  blockQuote: true,
@@ -4697,6 +4585,7 @@ function createStringifyContext(doc, options) {
4697
4585
  nullStr: 'null',
4698
4586
  simpleKeys: false,
4699
4587
  singleQuote: null,
4588
+ trailingComma: false,
4700
4589
  trueStr: 'true',
4701
4590
  verifyAliasOrder: true
4702
4591
  }, doc.schema.toStringOptions, options);
@@ -4731,7 +4620,7 @@ function getTagObject(tags, item) {
4731
4620
  let obj;
4732
4621
  if (isScalar(item)) {
4733
4622
  obj = item.value;
4734
- let match = tags.filter(t => _optionalChain$9([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4623
+ let match = tags.filter(t => _optionalChain$a([t, 'access', _ => _.identify, 'optionalCall', _2 => _2(obj)]));
4735
4624
  if (match.length > 1) {
4736
4625
  const testMatch = match.filter(t => t.test);
4737
4626
  if (testMatch.length > 0)
@@ -4745,7 +4634,7 @@ function getTagObject(tags, item) {
4745
4634
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
4746
4635
  }
4747
4636
  if (!tagObj) {
4748
- const name = _nullishCoalesce$5(_optionalChain$9([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4637
+ const name = _nullishCoalesce$5(_optionalChain$a([obj, 'optionalAccess', _3 => _3.constructor, 'optionalAccess', _4 => _4.name]), () => ( (obj === null ? 'null' : typeof obj)));
4749
4638
  throw new Error(`Tag not resolved for ${name} value`);
4750
4639
  }
4751
4640
  return tagObj;
@@ -4771,7 +4660,7 @@ function stringify(item, ctx, onComment, onChompKeep) {
4771
4660
  if (isAlias(item)) {
4772
4661
  if (ctx.doc.directives)
4773
4662
  return item.toString(ctx);
4774
- if (_optionalChain$9([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4663
+ if (_optionalChain$a([ctx, 'access', _5 => _5.resolvedAliases, 'optionalAccess', _6 => _6.has, 'call', _7 => _7(item)])) {
4775
4664
  throw new TypeError(`Cannot stringify circular structure without alias nodes`);
4776
4665
  }
4777
4666
  else {
@@ -4953,7 +4842,7 @@ function warn(logLevel, warning) {
4953
4842
  }
4954
4843
  }
4955
4844
 
4956
- 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; }
4845
+ 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; }
4957
4846
  // If the value associated with a merge key is a single mapping node, each of
4958
4847
  // its key/value pairs is inserted into the current mapping, unless the key
4959
4848
  // already exists in it. If the value associated with the merge key is a
@@ -4977,7 +4866,7 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
4977
4866
  (isScalar(key) &&
4978
4867
  (!key.type || key.type === Scalar.PLAIN) &&
4979
4868
  merge.identify(key.value))) &&
4980
- _optionalChain$8([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)]);
4869
+ _optionalChain$9([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)]);
4981
4870
  function addMergeToJSMap(ctx, map, value) {
4982
4871
  value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
4983
4872
  if (isSeq(value))
@@ -5014,7 +4903,7 @@ function mergeValue(ctx, map, value) {
5014
4903
  return map;
5015
4904
  }
5016
4905
 
5017
- 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; }
4906
+ 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; }
5018
4907
  function addPairToJSMap(ctx, map, { key, value }) {
5019
4908
  if (isNode(key) && key.addToJSMap)
5020
4909
  key.addToJSMap(ctx, map, value);
@@ -5051,7 +4940,7 @@ function stringifyKey(key, jsKey, ctx) {
5051
4940
  // eslint-disable-next-line @typescript-eslint/no-base-to-string
5052
4941
  if (typeof jsKey !== 'object')
5053
4942
  return String(jsKey);
5054
- if (isNode(key) && _optionalChain$7([ctx, 'optionalAccess', _ => _.doc])) {
4943
+ if (isNode(key) && _optionalChain$8([ctx, 'optionalAccess', _ => _.doc])) {
5055
4944
  const strCtx = createStringifyContext(ctx.doc, {});
5056
4945
  strCtx.anchors = new Set();
5057
4946
  for (const node of ctx.anchors.keys())
@@ -5071,7 +4960,7 @@ function stringifyKey(key, jsKey, ctx) {
5071
4960
  return JSON.stringify(jsKey);
5072
4961
  }
5073
4962
 
5074
- 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; }
4963
+ 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; }
5075
4964
  function createPair(key, value, ctx) {
5076
4965
  const k = createNode(key, undefined, ctx);
5077
4966
  const v = createNode(value, undefined, ctx);
@@ -5092,17 +4981,17 @@ class Pair {
5092
4981
  return new Pair(key, value);
5093
4982
  }
5094
4983
  toJSON(_, ctx) {
5095
- const pair = _optionalChain$6([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
4984
+ const pair = _optionalChain$7([ctx, 'optionalAccess', _2 => _2.mapAsMap]) ? new Map() : {};
5096
4985
  return addPairToJSMap(ctx, pair, this);
5097
4986
  }
5098
4987
  toString(ctx, onComment, onChompKeep) {
5099
- return _optionalChain$6([ctx, 'optionalAccess', _3 => _3.doc])
4988
+ return _optionalChain$7([ctx, 'optionalAccess', _3 => _3.doc])
5100
4989
  ? stringifyPair(this, ctx, onComment, onChompKeep)
5101
4990
  : JSON.stringify(this);
5102
4991
  }
5103
4992
  }
5104
4993
 
5105
- function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
4994
+ function _nullishCoalesce$3(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
5106
4995
  function stringifyCollection(collection, ctx, options) {
5107
4996
  const flow = _nullishCoalesce$3(ctx.inFlow, () => ( collection.flow));
5108
4997
  const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
@@ -5196,19 +5085,29 @@ function stringifyFlowCollection({ items }, ctx, { flowChars, itemIndent }) {
5196
5085
  if (iv.commentBefore)
5197
5086
  reqNewline = true;
5198
5087
  }
5199
- else if (item.value == null && _optionalChain$5([ik, 'optionalAccess', _ => _.comment])) {
5088
+ else if (item.value == null && _optionalChain$6([ik, 'optionalAccess', _ => _.comment])) {
5200
5089
  comment = ik.comment;
5201
5090
  }
5202
5091
  }
5203
5092
  if (comment)
5204
5093
  reqNewline = true;
5205
5094
  let str = stringify(item, itemCtx, () => (comment = null));
5206
- if (i < items.length - 1)
5095
+ reqNewline || (reqNewline = lines.length > linesAtValue || str.includes('\n'));
5096
+ if (i < items.length - 1) {
5207
5097
  str += ',';
5098
+ }
5099
+ else if (ctx.options.trailingComma) {
5100
+ if (ctx.options.lineWidth > 0) {
5101
+ reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) +
5102
+ (str.length + 2) >
5103
+ ctx.options.lineWidth);
5104
+ }
5105
+ if (reqNewline) {
5106
+ str += ',';
5107
+ }
5108
+ }
5208
5109
  if (comment)
5209
5110
  str += lineComment(str, itemIndent, commentString(comment));
5210
- if (!reqNewline && (lines.length > linesAtValue || str.includes('\n')))
5211
- reqNewline = true;
5212
5111
  lines.push(str);
5213
5112
  linesAtValue = lines.length;
5214
5113
  }
@@ -5241,7 +5140,7 @@ function addCommentBefore({ indent, options: { commentString } }, lines, comment
5241
5140
  }
5242
5141
  }
5243
5142
 
5244
- function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain$4(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
5143
+ function _nullishCoalesce$2(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }
5245
5144
  function findPair(items, key) {
5246
5145
  const k = isScalar(key) ? key.value : key;
5247
5146
  for (const it of items) {
@@ -5302,12 +5201,12 @@ class YAMLMap extends Collection {
5302
5201
  _pair = pair;
5303
5202
  else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
5304
5203
  // In TypeScript, this never happens.
5305
- _pair = new Pair(pair, _optionalChain$4([pair, 'optionalAccess', _2 => _2.value]));
5204
+ _pair = new Pair(pair, _optionalChain$5([pair, 'optionalAccess', _2 => _2.value]));
5306
5205
  }
5307
5206
  else
5308
5207
  _pair = new Pair(pair.key, pair.value);
5309
5208
  const prev = findPair(this.items, _pair.key);
5310
- const sortEntries = _optionalChain$4([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5209
+ const sortEntries = _optionalChain$5([this, 'access', _3 => _3.schema, 'optionalAccess', _4 => _4.sortMapEntries]);
5311
5210
  if (prev) {
5312
5211
  if (!overwrite)
5313
5212
  throw new Error(`Key ${_pair.key} already set`);
@@ -5337,7 +5236,7 @@ class YAMLMap extends Collection {
5337
5236
  }
5338
5237
  get(key, keepScalar) {
5339
5238
  const it = findPair(this.items, key);
5340
- const node = _optionalChain$4([it, 'optionalAccess', _5 => _5.value]);
5239
+ const node = _optionalChain$5([it, 'optionalAccess', _5 => _5.value]);
5341
5240
  return _nullishCoalesce$2((!keepScalar && isScalar(node) ? node.value : node), () => ( undefined));
5342
5241
  }
5343
5242
  has(key) {
@@ -5352,8 +5251,8 @@ class YAMLMap extends Collection {
5352
5251
  * @returns Instance of Type, Map, or Object
5353
5252
  */
5354
5253
  toJSON(_, ctx, Type) {
5355
- const map = Type ? new Type() : _optionalChain$4([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5356
- if (_optionalChain$4([ctx, 'optionalAccess', _7 => _7.onCreate]))
5254
+ const map = Type ? new Type() : _optionalChain$5([ctx, 'optionalAccess', _6 => _6.mapAsMap]) ? new Map() : {};
5255
+ if (_optionalChain$5([ctx, 'optionalAccess', _7 => _7.onCreate]))
5357
5256
  ctx.onCreate(map);
5358
5257
  for (const item of this.items)
5359
5258
  addPairToJSMap(ctx, map, item);
@@ -5378,7 +5277,7 @@ class YAMLMap extends Collection {
5378
5277
  }
5379
5278
  }
5380
5279
 
5381
- 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; }
5280
+ 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; }
5382
5281
  class YAMLSeq extends Collection {
5383
5282
  static get tagName() {
5384
5283
  return 'tag:yaml.org,2002:seq';
@@ -5441,7 +5340,7 @@ class YAMLSeq extends Collection {
5441
5340
  }
5442
5341
  toJSON(_, ctx) {
5443
5342
  const seq = [];
5444
- if (_optionalChain$3([ctx, 'optionalAccess', _2 => _2.onCreate]))
5343
+ if (_optionalChain$4([ctx, 'optionalAccess', _2 => _2.onCreate]))
5445
5344
  ctx.onCreate(seq);
5446
5345
  let i = 0;
5447
5346
  for (const item of this.items)
@@ -5520,7 +5419,7 @@ function createPairs(schema, iterable, ctx) {
5520
5419
  return pairs;
5521
5420
  }
5522
5421
 
5523
- 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; }
5422
+ 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; }
5524
5423
  class YAMLOMap extends YAMLSeq {
5525
5424
  constructor() {
5526
5425
  super();
@@ -5539,7 +5438,7 @@ class YAMLOMap extends YAMLSeq {
5539
5438
  if (!ctx)
5540
5439
  return super.toJSON(_);
5541
5440
  const map = new Map();
5542
- if (_optionalChain$2([ctx, 'optionalAccess', _2 => _2.onCreate]))
5441
+ if (_optionalChain$3([ctx, 'optionalAccess', _2 => _2.onCreate]))
5543
5442
  ctx.onCreate(map);
5544
5443
  for (const pair of this.items) {
5545
5444
  let key, value;
@@ -5913,6 +5812,118 @@ const isProjectType = async (
5913
5812
  return result.detected && result.type === expectedType;
5914
5813
  };
5915
5814
 
5815
+ 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; }
5816
+
5817
+
5818
+ /**
5819
+ * 检测并解析配置文件内容
5820
+ *
5821
+ * @param content - 文件内容
5822
+ * @returns 解析后的配置对象
5823
+ */
5824
+ const parseConfigContent = (content) => {
5825
+ // 1. 尝试 TOML 格式 (默认)
5826
+ try {
5827
+ const config = toml.parse(content);
5828
+ return config ;
5829
+ } catch (error) {
5830
+ // TOML 解析失败,继续尝试其他格式
5831
+
5832
+ console.debug('TOML parse failed:', error);
5833
+ }
5834
+
5835
+ // 2. 尝试 YAML 格式
5836
+ try {
5837
+ const config = jsYaml.load(content);
5838
+ if (config && typeof config === 'object') {
5839
+ return config ;
5840
+ }
5841
+ } catch (error) {
5842
+ // YAML 解析失败,继续尝试其他格式
5843
+
5844
+ console.debug('YAML parse failed:', error);
5845
+ }
5846
+
5847
+ // 3. 尝试 JSON 格式
5848
+ const config = safeJsonParse(content);
5849
+ if (config) {
5850
+ return config;
5851
+ }
5852
+
5853
+ return null;
5854
+ };
5855
+
5856
+ /**
5857
+ * 加载 .coze 配置文件
5858
+ *
5859
+ * @param projectPath - 项目目录路径
5860
+ * @returns .coze 配置对象
5861
+ */
5862
+ const loadCozeConfig = async (
5863
+ projectPath = process.cwd(),
5864
+ ) => {
5865
+ const cozeConfigPath = path.join(projectPath, '.coze');
5866
+
5867
+ let content;
5868
+ try {
5869
+ content = await fs$1.readFile(cozeConfigPath, 'utf-8');
5870
+ } catch (error) {
5871
+ throw new Error(
5872
+ `.coze config file not found in ${projectPath}\n` +
5873
+ 'Please ensure you are in a project directory initialized with coze-coding.\n' +
5874
+ `Error: ${error instanceof Error ? error.message : String(error)}`,
5875
+ );
5876
+ }
5877
+
5878
+ const config = parseConfigContent(content);
5879
+ if (!config) {
5880
+ throw new Error(
5881
+ 'Failed to parse .coze config file.\n' +
5882
+ 'Please ensure the file is in valid TOML, YAML, or JSON format.',
5883
+ );
5884
+ }
5885
+
5886
+ return config;
5887
+ };
5888
+
5889
+ /**
5890
+ * 获取指定命令的配置
5891
+ *
5892
+ * @param config - .coze 配置对象
5893
+ * @param commandName - 命令名称 (dev/build/start)
5894
+ * @returns 命令配置数组
5895
+ */
5896
+ const getCommandConfig = (
5897
+ config,
5898
+ commandName,
5899
+ ) => {
5900
+ let commandConfig;
5901
+
5902
+ // 根据命令名称映射到配置路径
5903
+ switch (commandName) {
5904
+ case 'dev':
5905
+ commandConfig = _optionalChain$2([config, 'access', _ => _.dev, 'optionalAccess', _2 => _2.run]);
5906
+ break;
5907
+ case 'build':
5908
+ commandConfig = _optionalChain$2([config, 'access', _3 => _3.deploy, 'optionalAccess', _4 => _4.build]);
5909
+ break;
5910
+ case 'start':
5911
+ commandConfig = _optionalChain$2([config, 'access', _5 => _5.deploy, 'optionalAccess', _6 => _6.run]);
5912
+ break;
5913
+ default:
5914
+ throw new Error(`Unknown command: ${commandName}`);
5915
+ }
5916
+
5917
+ if (!commandConfig || commandConfig.length === 0) {
5918
+ throw new Error(
5919
+ `Command '${commandName}' is not configured in .coze file.\n` +
5920
+ 'Please add the corresponding configuration to your .coze file.',
5921
+ );
5922
+ }
5923
+
5924
+ return commandConfig;
5925
+ };
5926
+
5916
5927
  // ABOUTME: Fix rule to replace npx commands with pnpm in shell scripts (dev.sh, build.sh)
5917
5928
  // ABOUTME: This fixes module resolution issues when using npx in certain project types
5918
5929
  // ABOUTME: See: /Users/bytedance/Downloads/projects2/docs/npx-pnpm-module-resolution-issue.md
@@ -6426,18 +6437,50 @@ const createLogStream = (logFilePath) => {
6426
6437
  const logDir = path.dirname(logFilePath);
6427
6438
 
6428
6439
  // 确保日志目录存在
6440
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
6429
6441
  if (!fs.existsSync(logDir)) {
6442
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
6430
6443
  fs.mkdirSync(logDir, { recursive: true });
6431
6444
  }
6432
6445
 
6433
6446
  // 使用 'w' 标志覆盖之前的日志
6447
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- resolved from config, not raw user input
6434
6448
  return fs.createWriteStream(logFilePath, { flags: 'w' });
6435
6449
  };
6436
6450
 
6437
6451
  /**
6438
6452
  * 执行命令的内部实现
6439
6453
  */
6440
- // eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function
6454
+ const reportFailureAndExit = (
6455
+ error,
6456
+ exitCode,
6457
+ context
6458
+
6459
+
6460
+
6461
+
6462
+
6463
+ ,
6464
+ ) => {
6465
+ const { commandName, cmdStartTime, options, categories, errorContext } =
6466
+ context;
6467
+ reportError(error, { command: commandName, ...errorContext });
6468
+ reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
6469
+ args: JSON.stringify(options),
6470
+ errorCode: exitCode,
6471
+ errorMessage: error.message,
6472
+ categories,
6473
+ });
6474
+ flushSlardar()
6475
+ .then(() => {
6476
+ process.exit(exitCode);
6477
+ })
6478
+ .catch(() => {
6479
+ process.exit(exitCode);
6480
+ });
6481
+ };
6482
+
6483
+ // eslint-disable-next-line @coze-arch/max-line-per-function, max-lines-per-function -- orchestrates fix+build+reporting
6441
6484
  const executeRun = async (
6442
6485
  commandName,
6443
6486
  options = {},
@@ -6445,12 +6488,17 @@ const executeRun = async (
6445
6488
  const cmdStartTime = Date.now();
6446
6489
  let fixDuration = 0;
6447
6490
  let buildStartTime = 0;
6491
+ let projectType = 'unknown';
6448
6492
 
6449
6493
  try {
6450
6494
  logger.info(`Running ${commandName} command...`);
6451
6495
 
6496
+ // 检测项目类型,用于上报
6497
+ const projectDetection = await detectProjectType(process.cwd());
6498
+ projectType = projectDetection.type;
6499
+
6452
6500
  // 上报命令开始
6453
- reportCommandStart(commandName, JSON.stringify(options));
6501
+ reportCommandStart(commandName, JSON.stringify(options), { projectType });
6454
6502
 
6455
6503
  // 1. 对于 build 命令,先执行 fix 以确保项目配置正确
6456
6504
  if (['dev', 'build'].includes(commandName)) {
@@ -6458,9 +6506,9 @@ const executeRun = async (
6458
6506
  const fixStartTime = Date.now();
6459
6507
  try {
6460
6508
  await executeFix();
6461
- // eslint-disable-next-line @coze-arch/no-empty-catch
6462
- } catch (e) {
6463
- // just ignore
6509
+ // eslint-disable-next-line @coze-arch/no-empty-catch, @coze-arch/use-error-in-catch -- intentionally ignored
6510
+ } catch (_e) {
6511
+ // fix errors are intentionally ignored to allow the main command to proceed
6464
6512
  }
6465
6513
  fixDuration = Date.now() - fixStartTime;
6466
6514
  logger.info('');
@@ -6517,25 +6565,23 @@ const executeRun = async (
6517
6565
  logger.error(`Check log file for details: ${logFilePath}`);
6518
6566
 
6519
6567
  // 上报命令失败
6520
- reportError(new Error(errorMessage), {
6521
- command: commandName,
6522
- exitCode: String(_nullishCoalesce$1(code, () => ( 'unknown'))),
6523
- signal: _nullishCoalesce$1(signal, () => ( 'none')),
6524
- logFile: logFilePath,
6525
- });
6526
- reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
6527
- args: JSON.stringify(options),
6528
- errorCode: _nullishCoalesce$1(code, () => ( 1)),
6529
- errorMessage,
6568
+ reportFailureAndExit(new Error(errorMessage), code || 1, {
6569
+ commandName,
6570
+ cmdStartTime,
6571
+ options,
6572
+ categories: {
6573
+ fixDuration: String(fixDuration),
6574
+ buildDuration: String(buildDuration),
6575
+ exitCode: String(_nullishCoalesce$1(code, () => ( 'unknown'))),
6576
+ projectType,
6577
+ },
6578
+ errorContext: {
6579
+ exitCode: String(_nullishCoalesce$1(code, () => ( 'unknown'))),
6580
+ signal: _nullishCoalesce$1(signal, () => ( 'none')),
6581
+ logFile: logFilePath,
6582
+ projectType,
6583
+ },
6530
6584
  });
6531
- flushSlardar()
6532
- .then(() => {
6533
- process.exit(code || 1);
6534
- })
6535
- .catch(() => {
6536
- // Catch any errors in the promise chain to prevent unhandled rejections
6537
- process.exit(code || 1);
6538
- });
6539
6585
  } else {
6540
6586
  logger.success('Command completed successfully');
6541
6587
  logger.info(`Log file: ${logFilePath}`);
@@ -6547,6 +6593,7 @@ const executeRun = async (
6547
6593
  fixDuration: String(fixDuration),
6548
6594
  buildDuration: String(buildDuration),
6549
6595
  exitCode: '0',
6596
+ projectType,
6550
6597
  },
6551
6598
  });
6552
6599
  // flush 由 main 函数统一处理
@@ -6565,65 +6612,21 @@ const executeRun = async (
6565
6612
  const buildDuration = Date.now() - buildStartTime;
6566
6613
 
6567
6614
  // 上报错误
6568
- reportError(error, {
6569
- command: commandName,
6570
- type: 'child_process_error',
6571
- });
6572
- reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
6573
- args: JSON.stringify(options),
6574
- errorCode: 1,
6575
- errorMessage: error.message,
6615
+ reportFailureAndExit(error, 1, {
6616
+ commandName,
6617
+ cmdStartTime,
6618
+ options,
6576
6619
  categories: {
6577
6620
  fixDuration: String(fixDuration),
6578
6621
  buildDuration: String(buildDuration),
6579
6622
  exitCode: 'error',
6623
+ errorType: 'child_process_error',
6624
+ projectType,
6580
6625
  },
6626
+ errorContext: { type: 'child_process_error', projectType },
6581
6627
  });
6582
- flushSlardar()
6583
- .then(() => {
6584
- process.exit(1);
6585
- })
6586
- .catch(() => {
6587
- // Catch any errors in the promise chain to prevent unhandled rejections
6588
- process.exit(1);
6589
- });
6590
6628
  });
6591
6629
  });
6592
-
6593
- childProcess.on('error', (error) => {
6594
- logger.error('Failed to execute command:');
6595
- logger.error(`Error: ${error.message}`);
6596
- if (error.stack) {
6597
- logger.error(`Stack trace:\n${error.stack}`);
6598
- }
6599
- logStream.end();
6600
-
6601
- const buildDuration = Date.now() - buildStartTime;
6602
-
6603
- // 上报错误
6604
- reportError(error, {
6605
- command: commandName,
6606
- type: 'child_process_error',
6607
- });
6608
- reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
6609
- args: JSON.stringify(options),
6610
- errorCode: 1,
6611
- errorMessage: error.message,
6612
- categories: {
6613
- fixDuration: String(fixDuration),
6614
- buildDuration: String(buildDuration),
6615
- errorType: 'child_process_error',
6616
- },
6617
- });
6618
- flushSlardar()
6619
- .then(() => {
6620
- process.exit(1);
6621
- })
6622
- .catch(() => {
6623
- // Catch any errors in the promise chain to prevent unhandled rejections
6624
- process.exit(1);
6625
- });
6626
- });
6627
6630
  } catch (error) {
6628
6631
  const err = error instanceof Error ? error : new Error(String(error));
6629
6632
  logger.error(`Failed to run ${commandName} command:`);
@@ -6632,28 +6635,18 @@ const executeRun = async (
6632
6635
  const buildDuration = buildStartTime > 0 ? Date.now() - buildStartTime : 0;
6633
6636
 
6634
6637
  // 上报错误
6635
- reportError(err, {
6636
- command: commandName,
6637
- type: 'execution_error',
6638
- });
6639
- reportCommandComplete(commandName, false, Date.now() - cmdStartTime, {
6640
- args: JSON.stringify(options),
6641
- errorCode: 1,
6642
- errorMessage: err.message,
6638
+ reportFailureAndExit(err, 1, {
6639
+ commandName,
6640
+ cmdStartTime,
6641
+ options,
6643
6642
  categories: {
6644
6643
  fixDuration: String(fixDuration),
6645
6644
  buildDuration: String(buildDuration),
6646
6645
  errorType: 'execution_error',
6646
+ projectType,
6647
6647
  },
6648
+ errorContext: { type: 'execution_error', projectType },
6648
6649
  });
6649
- flushSlardar()
6650
- .then(() => {
6651
- process.exit(1);
6652
- })
6653
- .catch(() => {
6654
- // Catch any errors in the promise chain to prevent unhandled rejections
6655
- process.exit(1);
6656
- });
6657
6650
  }
6658
6651
  };
6659
6652
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.10-alpha.b1a3b0",
3
+ "version": "0.0.11",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -73,7 +73,7 @@
73
73
  "json-schema-to-typescript": "^15.0.3",
74
74
  "minimatch": "^10.0.1",
75
75
  "playwright": "~1.55.0",
76
- "rollup": "^4.41.1",
76
+ "rollup": "^4.60.1",
77
77
  "sucrase": "^3.35.0",
78
78
  "tree-kill": "^1.2.2",
79
79
  "tsx": "^4.20.6",