@coze-arch/cli 0.0.1-beta.5

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 (126) hide show
  1. package/README.md +142 -0
  2. package/bin/main +2 -0
  3. package/lib/__templates__/expo/.coze +7 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/deploy_build.sh +109 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +257 -0
  6. package/lib/__templates__/expo/README.md +13 -0
  7. package/lib/__templates__/expo/_gitignore +11 -0
  8. package/lib/__templates__/expo/app.json +63 -0
  9. package/lib/__templates__/expo/babel.config.js +9 -0
  10. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +43 -0
  11. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +1 -0
  12. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +7 -0
  13. package/lib/__templates__/expo/client/app/+not-found.tsx +79 -0
  14. package/lib/__templates__/expo/client/app/_layout.tsx +33 -0
  15. package/lib/__templates__/expo/client/assets/fonts/SpaceMono-Regular.ttf +0 -0
  16. package/lib/__templates__/expo/client/assets/images/adaptive-icon.png +0 -0
  17. package/lib/__templates__/expo/client/assets/images/default-avatar.png +0 -0
  18. package/lib/__templates__/expo/client/assets/images/favicon.png +0 -0
  19. package/lib/__templates__/expo/client/assets/images/icon.png +0 -0
  20. package/lib/__templates__/expo/client/assets/images/partial-react-logo.png +0 -0
  21. package/lib/__templates__/expo/client/assets/images/react-logo.png +0 -0
  22. package/lib/__templates__/expo/client/assets/images/react-logo@2x.png +0 -0
  23. package/lib/__templates__/expo/client/assets/images/react-logo@3x.png +0 -0
  24. package/lib/__templates__/expo/client/assets/images/splash-icon.png +0 -0
  25. package/lib/__templates__/expo/client/components/Screen.tsx +330 -0
  26. package/lib/__templates__/expo/client/components/SmartDateInput.tsx +238 -0
  27. package/lib/__templates__/expo/client/constants/theme.ts +118 -0
  28. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +142 -0
  29. package/lib/__templates__/expo/client/hooks/useColorScheme.ts +1 -0
  30. package/lib/__templates__/expo/client/hooks/useTheme.ts +13 -0
  31. package/lib/__templates__/expo/client/index.js +11 -0
  32. package/lib/__templates__/expo/client/screens/home/index.tsx +54 -0
  33. package/lib/__templates__/expo/client/screens/home/styles.ts +332 -0
  34. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +80 -0
  35. package/lib/__templates__/expo/client/utils/index.ts +55 -0
  36. package/lib/__templates__/expo/eslint-formatter-simple.mjs +49 -0
  37. package/lib/__templates__/expo/eslint.config.mjs +98 -0
  38. package/lib/__templates__/expo/metro.config.js +53 -0
  39. package/lib/__templates__/expo/package.json +100 -0
  40. package/lib/__templates__/expo/pnpm-lock.yaml +13978 -0
  41. package/lib/__templates__/expo/src/index.ts +12 -0
  42. package/lib/__templates__/expo/template.config.js +49 -0
  43. package/lib/__templates__/expo/tsconfig.json +24 -0
  44. package/lib/__templates__/nextjs/.coze +11 -0
  45. package/lib/__templates__/nextjs/.vscode/settings.json +121 -0
  46. package/lib/__templates__/nextjs/README.md +36 -0
  47. package/lib/__templates__/nextjs/_gitignore +99 -0
  48. package/lib/__templates__/nextjs/_npmrc +22 -0
  49. package/lib/__templates__/nextjs/eslint.config.mjs +18 -0
  50. package/lib/__templates__/nextjs/next-env.d.ts +6 -0
  51. package/lib/__templates__/nextjs/next.config.ts +7 -0
  52. package/lib/__templates__/nextjs/package.json +32 -0
  53. package/lib/__templates__/nextjs/pnpm-lock.yaml +4061 -0
  54. package/lib/__templates__/nextjs/postcss.config.mjs +7 -0
  55. package/lib/__templates__/nextjs/public/file.svg +1 -0
  56. package/lib/__templates__/nextjs/public/globe.svg +1 -0
  57. package/lib/__templates__/nextjs/public/next.svg +1 -0
  58. package/lib/__templates__/nextjs/public/vercel.svg +1 -0
  59. package/lib/__templates__/nextjs/public/window.svg +1 -0
  60. package/lib/__templates__/nextjs/scripts/build.sh +14 -0
  61. package/lib/__templates__/nextjs/scripts/dev.sh +51 -0
  62. package/lib/__templates__/nextjs/scripts/start.sh +15 -0
  63. package/lib/__templates__/nextjs/src/app/favicon.ico +0 -0
  64. package/lib/__templates__/nextjs/src/app/globals.css +26 -0
  65. package/lib/__templates__/nextjs/src/app/layout.tsx +34 -0
  66. package/lib/__templates__/nextjs/src/app/page.tsx +66 -0
  67. package/lib/__templates__/nextjs/template.config.js +55 -0
  68. package/lib/__templates__/nextjs/tsconfig.json +34 -0
  69. package/lib/__templates__/react-rsbuild/.coze +11 -0
  70. package/lib/__templates__/react-rsbuild/.vscode/settings.json +121 -0
  71. package/lib/__templates__/react-rsbuild/README.md +61 -0
  72. package/lib/__templates__/react-rsbuild/_gitignore +97 -0
  73. package/lib/__templates__/react-rsbuild/_npmrc +22 -0
  74. package/lib/__templates__/react-rsbuild/package.json +31 -0
  75. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +997 -0
  76. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +13 -0
  77. package/lib/__templates__/react-rsbuild/scripts/build.sh +14 -0
  78. package/lib/__templates__/react-rsbuild/scripts/dev.sh +51 -0
  79. package/lib/__templates__/react-rsbuild/scripts/start.sh +15 -0
  80. package/lib/__templates__/react-rsbuild/src/App.tsx +60 -0
  81. package/lib/__templates__/react-rsbuild/src/index.css +21 -0
  82. package/lib/__templates__/react-rsbuild/src/index.html +12 -0
  83. package/lib/__templates__/react-rsbuild/src/index.tsx +16 -0
  84. package/lib/__templates__/react-rsbuild/tailwind.config.js +9 -0
  85. package/lib/__templates__/react-rsbuild/template.config.js +54 -0
  86. package/lib/__templates__/react-rsbuild/tsconfig.json +17 -0
  87. package/lib/__templates__/rsbuild/.coze +11 -0
  88. package/lib/__templates__/rsbuild/.vscode/settings.json +7 -0
  89. package/lib/__templates__/rsbuild/README.md +61 -0
  90. package/lib/__templates__/rsbuild/_gitignore +97 -0
  91. package/lib/__templates__/rsbuild/_npmrc +22 -0
  92. package/lib/__templates__/rsbuild/package.json +24 -0
  93. package/lib/__templates__/rsbuild/pnpm-lock.yaml +888 -0
  94. package/lib/__templates__/rsbuild/rsbuild.config.ts +12 -0
  95. package/lib/__templates__/rsbuild/scripts/build.sh +14 -0
  96. package/lib/__templates__/rsbuild/scripts/dev.sh +51 -0
  97. package/lib/__templates__/rsbuild/scripts/start.sh +15 -0
  98. package/lib/__templates__/rsbuild/src/index.css +21 -0
  99. package/lib/__templates__/rsbuild/src/index.html +12 -0
  100. package/lib/__templates__/rsbuild/src/index.ts +5 -0
  101. package/lib/__templates__/rsbuild/src/main.ts +65 -0
  102. package/lib/__templates__/rsbuild/tailwind.config.js +9 -0
  103. package/lib/__templates__/rsbuild/template.config.js +54 -0
  104. package/lib/__templates__/rsbuild/tsconfig.json +16 -0
  105. package/lib/__templates__/templates.json +100 -0
  106. package/lib/__templates__/vite/.coze +11 -0
  107. package/lib/__templates__/vite/.vscode/settings.json +7 -0
  108. package/lib/__templates__/vite/README.md +61 -0
  109. package/lib/__templates__/vite/_gitignore +66 -0
  110. package/lib/__templates__/vite/_npmrc +22 -0
  111. package/lib/__templates__/vite/index.html +13 -0
  112. package/lib/__templates__/vite/package.json +24 -0
  113. package/lib/__templates__/vite/pnpm-lock.yaml +1249 -0
  114. package/lib/__templates__/vite/postcss.config.js +6 -0
  115. package/lib/__templates__/vite/scripts/build.sh +14 -0
  116. package/lib/__templates__/vite/scripts/dev.sh +51 -0
  117. package/lib/__templates__/vite/scripts/start.sh +15 -0
  118. package/lib/__templates__/vite/src/index.css +21 -0
  119. package/lib/__templates__/vite/src/index.ts +5 -0
  120. package/lib/__templates__/vite/src/main.ts +65 -0
  121. package/lib/__templates__/vite/tailwind.config.js +9 -0
  122. package/lib/__templates__/vite/template.config.js +55 -0
  123. package/lib/__templates__/vite/tsconfig.json +16 -0
  124. package/lib/__templates__/vite/vite.config.ts +15 -0
  125. package/lib/cli.js +1575 -0
  126. package/package.json +70 -0
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ };
@@ -0,0 +1,14 @@
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
10
+
11
+ echo "Building the project..."
12
+ npx vite build
13
+
14
+ echo "Build completed successfully!"
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ PORT=<%= port %>
5
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
6
+
7
+ cd "${COZE_WORKSPACE_PATH}"
8
+
9
+ kill_port_if_listening() {
10
+ 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
+
24
+ if [[ -z "${pids}" ]]; then
25
+ echo "Port ${PORT} is free."
26
+ return
27
+ fi
28
+
29
+ echo "Port ${PORT} in use by PIDs: ${pids} (SIGKILL)"
30
+ echo "${pids}" | xargs -I {} kill -9 {}
31
+ 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
+
40
+ if [[ -n "${pids}" ]]; then
41
+ echo "Warning: port ${PORT} still busy after SIGKILL, PIDs: ${pids}"
42
+ else
43
+ echo "Port ${PORT} cleared."
44
+ fi
45
+ }
46
+
47
+ echo "Clearing port ${PORT} before start."
48
+ kill_port_if_listening
49
+ echo "Starting HTTP service on port ${PORT} for dev..."
50
+
51
+ npx vite --port $PORT
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ set -Eeuo pipefail
3
+
4
+ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
5
+ PORT=<%= port %>
6
+ DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-$PORT}"
7
+
8
+ start_service() {
9
+ cd "${COZE_WORKSPACE_PATH}"
10
+ echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for deploy..."
11
+ npx vite preview --port $DEPLOY_RUN_PORT
12
+ }
13
+
14
+ echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for deploy..."
15
+ start_service
@@ -0,0 +1,21 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ :root {
6
+ --background: #ffffff;
7
+ --foreground: #171717;
8
+ }
9
+
10
+ @media (prefers-color-scheme: dark) {
11
+ :root {
12
+ --background: #0a0a0a;
13
+ --foreground: #ededed;
14
+ }
15
+ }
16
+
17
+ body {
18
+ background: var(--background);
19
+ color: var(--foreground);
20
+ font-family: Arial, Helvetica, sans-serif;
21
+ }
@@ -0,0 +1,5 @@
1
+ import './index.css';
2
+ import { initApp } from './main';
3
+
4
+ // Initialize the application
5
+ initApp();
@@ -0,0 +1,65 @@
1
+ export function initApp(): void {
2
+ const app = document.getElementById('app');
3
+
4
+ if (!app) {
5
+ console.error('App element not found');
6
+ return;
7
+ }
8
+
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">
15
+ <img
16
+ class="dark:invert"
17
+ src="https://lf3-static.bytednsdoc.com/obj/eden-cn/hkpzboz/coze_logo.png"
18
+ alt="扣子编程 Logo"
19
+ width="40"
20
+ height="40"
21
+ style="width: 40px; height: 40px; object-fit: contain;"
22
+ />
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>
61
+ </div>
62
+ </main>
63
+ </div>
64
+ `;
65
+ }
@@ -0,0 +1,9 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ export default {
3
+ content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
4
+ darkMode: 'media',
5
+ theme: {
6
+ extend: {},
7
+ },
8
+ plugins: [],
9
+ };
@@ -0,0 +1,55 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ export const paramsSchema = {
11
+ type: 'object',
12
+ properties: {
13
+ appName: {
14
+ type: 'string',
15
+ minLength: 1,
16
+ pattern: '^[a-z0-9-]+$',
17
+ description:
18
+ 'Application name (lowercase, alphanumeric and hyphens only)',
19
+ },
20
+ port: {
21
+ type: 'number',
22
+ default: 3000,
23
+ minimum: 1024,
24
+ maximum: 65535,
25
+ description: 'Development server port',
26
+ },
27
+ },
28
+ required: [],
29
+ additionalProperties: false,
30
+ };
31
+
32
+ const config = {
33
+ paramsSchema,
34
+
35
+ defaultParams: {
36
+ port: 3000,
37
+ appName: 'app',
38
+ },
39
+
40
+ onBeforeRender: async context => {
41
+ console.log(`Creating Vanilla TypeScript + Vite project: ${context.appName}`);
42
+ return context;
43
+ },
44
+
45
+ onAfterRender: async (context, outputPath) => {
46
+ console.log(`\nProject created at: ${outputPath}`);
47
+ console.log(`\nConfiguration:`);
48
+ console.log(` - TypeScript: enabled`);
49
+ console.log(` - Framework: None (Vanilla JS/TS)`);
50
+ console.log(` - Build Tool: Vite`);
51
+ console.log(` - Port: ${context.port}`);
52
+ },
53
+ };
54
+
55
+ export default config;
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "resolveJsonModule": true,
12
+ "isolatedModules": true,
13
+ "noEmit": true
14
+ },
15
+ "include": ["src"]
16
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'vite';
2
+
3
+ export default defineConfig({
4
+ port: '<%= port %>',
5
+ host: '0.0.0.0',
6
+ server: {
7
+ hmr: {
8
+ overlay: true,
9
+ path: '/hot/vite-hmr',
10
+ port: '<%= port %>',
11
+ clientPort: 443,
12
+ timeout: 30000,
13
+ },
14
+ },
15
+ });