@coze-arch/cli 0.0.1-alpha.912cd5 → 0.0.1-alpha.934b8f

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 (134) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +46 -0
  3. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +229 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  6. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +46 -0
  7. package/lib/__templates__/expo/README.md +68 -7
  8. package/lib/__templates__/expo/_gitignore +1 -1
  9. package/lib/__templates__/expo/_npmrc +3 -5
  10. package/lib/__templates__/expo/client/app/+not-found.tsx +15 -64
  11. package/lib/__templates__/expo/client/app/_layout.tsx +15 -12
  12. package/lib/__templates__/expo/client/app/index.tsx +1 -0
  13. package/lib/__templates__/expo/client/app.config.ts +76 -0
  14. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  15. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  16. package/lib/__templates__/expo/client/components/ThemedView.tsx +37 -0
  17. package/lib/__templates__/expo/client/constants/theme.ts +117 -58
  18. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  19. package/lib/__templates__/expo/client/declarations.d.ts +5 -0
  20. package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +33 -10
  21. package/lib/__templates__/expo/client/hooks/useColorScheme.tsx +48 -0
  22. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  23. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  24. package/lib/__templates__/expo/client/metro.config.js +121 -0
  25. package/lib/__templates__/expo/client/package.json +95 -0
  26. package/lib/__templates__/expo/client/screens/demo/index.tsx +25 -0
  27. package/lib/__templates__/expo/client/screens/demo/styles.ts +28 -0
  28. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +1 -0
  29. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  30. package/lib/__templates__/expo/client/utils/index.ts +23 -2
  31. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  32. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  33. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  34. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  35. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  36. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  37. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  38. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  39. package/lib/__templates__/expo/package.json +16 -101
  40. package/lib/__templates__/expo/patches/expo@54.0.32.patch +45 -0
  41. package/lib/__templates__/expo/pnpm-lock.yaml +1534 -3359
  42. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  43. package/lib/__templates__/expo/server/build.js +21 -0
  44. package/lib/__templates__/expo/server/package.json +32 -0
  45. package/lib/__templates__/expo/server/src/index.ts +19 -0
  46. package/lib/__templates__/expo/server/tsconfig.json +24 -0
  47. package/lib/__templates__/expo/template.config.js +2 -1
  48. package/lib/__templates__/expo/tsconfig.json +1 -24
  49. package/lib/__templates__/nextjs/.coze +4 -3
  50. package/lib/__templates__/nextjs/_npmrc +2 -1
  51. package/lib/__templates__/nextjs/next.config.ts +12 -0
  52. package/lib/__templates__/nextjs/package.json +16 -1
  53. package/lib/__templates__/nextjs/pnpm-lock.yaml +3294 -1030
  54. package/lib/__templates__/nextjs/scripts/dev.sh +8 -27
  55. package/lib/__templates__/nextjs/scripts/prepare.sh +9 -0
  56. package/lib/__templates__/nextjs/src/app/globals.css +109 -89
  57. package/lib/__templates__/nextjs/src/app/layout.tsx +19 -32
  58. package/lib/__templates__/nextjs/src/app/page.tsx +16 -48
  59. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +29 -22
  60. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +228 -230
  61. package/lib/__templates__/nextjs/template.config.js +31 -1
  62. package/lib/__templates__/taro/.coze +14 -0
  63. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  64. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +13 -0
  65. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +16 -0
  66. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +74 -0
  67. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  68. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +1 -0
  69. package/lib/__templates__/taro/README.md +687 -0
  70. package/lib/__templates__/taro/_gitignore +40 -0
  71. package/lib/__templates__/taro/_npmrc +18 -0
  72. package/lib/__templates__/taro/babel.config.js +12 -0
  73. package/lib/__templates__/taro/config/dev.ts +9 -0
  74. package/lib/__templates__/taro/config/index.ts +173 -0
  75. package/lib/__templates__/taro/config/prod.ts +35 -0
  76. package/lib/__templates__/taro/eslint.config.mjs +57 -0
  77. package/lib/__templates__/taro/key/private.appid.key +0 -0
  78. package/lib/__templates__/taro/package.json +95 -0
  79. package/lib/__templates__/taro/pnpm-lock.yaml +22430 -0
  80. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  81. package/lib/__templates__/taro/project.config.json +15 -0
  82. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  83. package/lib/__templates__/taro/server/package.json +38 -0
  84. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  85. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  86. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  87. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  88. package/lib/__templates__/taro/server/src/main.ts +37 -0
  89. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  90. package/lib/__templates__/taro/src/app.config.ts +11 -0
  91. package/lib/__templates__/taro/src/app.css +52 -0
  92. package/lib/__templates__/taro/src/app.ts +14 -0
  93. package/lib/__templates__/taro/src/index.html +50 -0
  94. package/lib/__templates__/taro/src/network.ts +39 -0
  95. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  96. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  97. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  98. package/lib/__templates__/taro/src/utils/h5-styles.ts +22 -0
  99. package/lib/__templates__/taro/src/utils/wx-debug.ts +23 -0
  100. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  101. package/lib/__templates__/taro/template.config.js +68 -0
  102. package/lib/__templates__/taro/tsconfig.json +29 -0
  103. package/lib/__templates__/taro/types/global.d.ts +32 -0
  104. package/lib/__templates__/templates.json +93 -36
  105. package/lib/__templates__/vite/.coze +4 -3
  106. package/lib/__templates__/vite/README.md +204 -26
  107. package/lib/__templates__/vite/_npmrc +2 -1
  108. package/lib/__templates__/vite/eslint.config.mjs +9 -0
  109. package/lib/__templates__/vite/package.json +11 -2
  110. package/lib/__templates__/vite/pnpm-lock.yaml +3232 -243
  111. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  112. package/lib/__templates__/vite/scripts/prepare.sh +9 -0
  113. package/lib/__templates__/vite/src/main.ts +17 -48
  114. package/lib/__templates__/vite/template.config.js +40 -5
  115. package/lib/__templates__/vite/vite.config.ts +3 -3
  116. package/lib/cli.js +1479 -461
  117. package/package.json +10 -4
  118. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +0 -109
  119. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +0 -257
  120. package/lib/__templates__/expo/app.json +0 -63
  121. package/lib/__templates__/expo/babel.config.js +0 -9
  122. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  123. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  124. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  125. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +0 -1
  126. package/lib/__templates__/expo/client/index.js +0 -12
  127. package/lib/__templates__/expo/client/screens/home/index.tsx +0 -54
  128. package/lib/__templates__/expo/client/screens/home/styles.ts +0 -332
  129. package/lib/__templates__/expo/metro.config.js +0 -53
  130. package/lib/__templates__/expo/src/index.ts +0 -12
  131. package/lib/__templates__/nextjs/.vscode/settings.json +0 -121
  132. package/lib/__templates__/nextjs/server.mjs +0 -50
  133. package/lib/__templates__/vite/.vscode/settings.json +0 -7
  134. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
@@ -3,44 +3,25 @@ set -Eeuo pipefail
3
3
 
4
4
  PORT=<%= port %>
5
5
  COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
6
+ DEPLOY_RUN_PORT=<%= port %>
6
7
 
7
8
  cd "${COZE_WORKSPACE_PATH}"
8
9
 
9
10
  kill_port_if_listening() {
10
11
  local pids
11
-
12
- # Check if lsof is available (macOS/BSD) or ss (Linux)
13
- if command -v lsof >/dev/null 2>&1; then
14
- # macOS/BSD using lsof
15
- pids=$(lsof -ti:${PORT} 2>/dev/null || true)
16
- elif command -v ss >/dev/null 2>&1; then
17
- # Linux using ss
18
- pids=$(ss -H -lntp 2>/dev/null | awk -v port="${PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
19
- else
20
- echo "Warning: neither lsof nor ss found, cannot check port ${PORT}"
21
- return
22
- fi
23
-
12
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
24
13
  if [[ -z "${pids}" ]]; then
25
- echo "Port ${PORT} is free."
14
+ echo "Port ${DEPLOY_RUN_PORT} is free."
26
15
  return
27
16
  fi
28
-
29
- echo "Port ${PORT} in use by PIDs: ${pids} (SIGKILL)"
17
+ echo "Port ${DEPLOY_RUN_PORT} in use by PIDs: ${pids} (SIGKILL)"
30
18
  echo "${pids}" | xargs -I {} kill -9 {}
31
19
  sleep 1
32
-
33
- # Verify port is cleared
34
- if command -v lsof >/dev/null 2>&1; then
35
- pids=$(lsof -ti:${PORT} 2>/dev/null || true)
36
- elif command -v ss >/dev/null 2>&1; then
37
- pids=$(ss -H -lntp 2>/dev/null | awk -v port="${PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
38
- fi
39
-
20
+ pids=$(ss -H -lntp 2>/dev/null | awk -v port="${DEPLOY_RUN_PORT}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | paste -sd' ' - || true)
40
21
  if [[ -n "${pids}" ]]; then
41
- echo "Warning: port ${PORT} still busy after SIGKILL, PIDs: ${pids}"
22
+ echo "Warning: port ${DEPLOY_RUN_PORT} still busy after SIGKILL, PIDs: ${pids}"
42
23
  else
43
- echo "Port ${PORT} cleared."
24
+ echo "Port ${DEPLOY_RUN_PORT} cleared."
44
25
  fi
45
26
  }
46
27
 
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+
6
+ cd "${COZE_WORKSPACE_PATH}"
7
+
8
+ echo "Installing dependencies..."
9
+ pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
@@ -7,57 +7,26 @@ export function initApp(): void {
7
7
  }
8
8
 
9
9
  app.innerHTML = `
10
- <div class="flex min-h-screen items-center justify-center bg-white text-black transition-colors duration-300 dark:bg-black dark:text-white">
11
- <!-- 主容器 -->
12
- <main class="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between px-16 py-32 sm:items-start">
13
- <!-- 头部:Logo 产品名称 -->
14
- <div class="flex items-center gap-3">
10
+ <div class="flex h-full items-center justify-center bg-background text-foreground transition-colors duration-300 dark:bg-background dark:text-foreground overflow-hidden">
11
+ {/* 主容器 */}
12
+ <main class="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
13
+ <div class="flex flex-col items-center justify-between gap-4">
15
14
  <img
16
- class="dark:invert"
17
- src="https://lf3-static.bytednsdoc.com/obj/eden-cn/hkpzboz/coze_logo.png"
15
+ src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
18
16
  alt="扣子编程 Logo"
19
- width="40"
20
- height="40"
21
- style="width: 40px; height: 40px; object-fit: contain;"
17
+ width={156}
18
+ height={130}
22
19
  />
23
- <span class="text-xl font-bold tracking-tight text-black dark:text-zinc-50">
24
- 扣子编程
25
- </span>
26
- </div>
27
-
28
- <!-- 中间内容区:主标题和副标题 -->
29
- <div class="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
30
- <h1 class="max-w-xl text-4xl font-semibold leading-tight tracking-tight text-black dark:text-zinc-50">
31
- 扣子编程,你的 AI 开发伙伴已就位
32
- </h1>
33
- <p class="max-w-2xl text-lg leading-8 text-zinc-600 dark:text-zinc-400">
34
- 当前是空白入口文件,项目正在开发中,请稍候...
35
- <br />
36
- 开发完成后界面将自动更新。如未自动更新成功,可以手动点击右上角刷新或重启按钮查看效果。
37
- </p>
38
- </div>
39
-
40
- <!-- 底部按钮区 -->
41
- <div class="flex w-full flex-col gap-4 text-base font-medium sm:w-auto sm:flex-row">
42
- <!-- 按钮 1:前往首页 -->
43
- <a
44
- class="flex h-12 w-full min-w-[160px] items-center justify-center gap-2 rounded-full bg-black px-8 text-white transition-colors hover:bg-zinc-800 dark:bg-white dark:text-black dark:hover:bg-zinc-200 md:w-auto"
45
- href="https://code.coze.cn/"
46
- target="_blank"
47
- rel="noopener noreferrer"
48
- >
49
- 前往首页
50
- </a>
51
-
52
- <!-- 按钮 2:查看文档 -->
53
- <a
54
- class="flex h-12 w-full min-w-[160px] items-center justify-center rounded-full border border-solid border-black/[.08] px-8 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-auto"
55
- href="https://docs.coze.cn/"
56
- target="_blank"
57
- rel="noopener noreferrer"
58
- >
59
- 查看文档
60
- </a>
20
+ <div>
21
+ <div class="flex flex-col items-center gap-2 text-center sm:items-center sm:text-center">
22
+ <h1 class="max-w-xl text-base font-semibold leading-tight tracking-tight text-foreground dark:text-foreground">
23
+ 应用开发中
24
+ </h1>
25
+ <p class="max-w-2xl text-sm-14 leading-8 text-muted-foreground dark:text-muted-foreground">
26
+ 请稍后,页面即将呈现
27
+ </p>
28
+ </div>
29
+ </div>
61
30
  </div>
62
31
  </main>
63
32
  </div>
@@ -1,5 +1,8 @@
1
1
 
2
2
 
3
+ import { resolve } from 'path';
4
+
5
+
3
6
 
4
7
 
5
8
 
@@ -24,17 +27,29 @@ export const paramsSchema = {
24
27
  maximum: 65535,
25
28
  description: 'Development server port',
26
29
  },
30
+ hmrPort: {
31
+ type: 'number',
32
+ default: 6000,
33
+ minimum: 1024,
34
+ maximum: 65535,
35
+ description: 'Development HMR server port',
36
+ },
27
37
  },
28
38
  required: [],
29
39
  additionalProperties: false,
30
40
  };
31
41
 
42
+ const description = `Vite(简单项目):\`coze init \${COZE_WORKSPACE_PATH} --template vite\`
43
+ - 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。`;
44
+
32
45
  const config = {
46
+ description: description,
33
47
  paramsSchema,
34
48
 
35
49
  defaultParams: {
36
50
  port: 5000,
37
- appName: 'app',
51
+ hmrPort: 6000,
52
+ appName: 'projects',
38
53
  },
39
54
 
40
55
  onBeforeRender: async context => {
@@ -46,11 +61,31 @@ const config = {
46
61
 
47
62
  onAfterRender: async (context, outputPath) => {
48
63
  console.log(`\nProject created at: ${outputPath}`);
49
- console.log(`\nConfiguration:`);
50
- console.log(` - TypeScript: enabled`);
51
- console.log(` - Framework: None (Vanilla JS/TS)`);
52
- console.log(` - Build Tool: Vite`);
64
+ console.log('\nConfiguration:');
65
+ console.log(' - Framework: vite');
66
+ console.log(' - TypeScript: enabled');
67
+ console.log(' - App Router: enabled');
53
68
  console.log(` - Port: ${context.port}`);
69
+
70
+ // Skip pnpm add in test environment to avoid monorepo workspace issues
71
+ if (process.env.NODE_ENV === 'test') {
72
+ console.log('⊘ Skipping dependency update in test environment');
73
+ return;
74
+ }
75
+
76
+ const cmd = `pnpm add coze-coding-dev-sdk@"^0.7.0"`;
77
+ console.log(`${cmd}`);
78
+ try {
79
+ const projectRoot = resolve(outputPath);
80
+ // execSync(cmd, {
81
+ // cwd: projectRoot,
82
+ // stdio: 'inherit',
83
+ // });
84
+ console.log('✓ coze-coding-dev-sdk updated successfully');
85
+ } catch (error) {
86
+ console.error('✗ Failed to update coze-coding-dev-sdk:', error);
87
+ throw error;
88
+ }
54
89
  },
55
90
  };
56
91
 
@@ -1,13 +1,13 @@
1
1
  import { defineConfig } from 'vite';
2
2
 
3
3
  export default defineConfig({
4
- port: '<%= port %>',
5
- host: '0.0.0.0',
6
4
  server: {
5
+ port: <%= port %>,
6
+ host: '0.0.0.0',
7
7
  hmr: {
8
8
  overlay: true,
9
9
  path: '/hot/vite-hmr',
10
- port: '<%= port %>',
10
+ port: <%= hmrPort %>,
11
11
  clientPort: 443,
12
12
  timeout: 30000,
13
13
  },