@coze-arch/cli 0.0.1-alpha.fc5c04 → 0.0.1-alpha.ff3d06
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.
- package/README.md +1 -0
- package/lib/__templates__/expo/_npmrc +1 -0
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +7 -0
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
- package/lib/__templates__/nextjs/AGENTS.md +54 -0
- package/lib/__templates__/nextjs/README.md +5 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -2
- package/lib/__templates__/nextjs/package.json +2 -5
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1028 -5
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +8 -2
- package/lib/__templates__/nextjs/scripts/start.sh +7 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +1 -2
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/AGENTS.md +42 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/{vite-vue/src/index.css → nuxt-vue/assets/css/main.css} +6 -11
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
- package/lib/__templates__/nuxt-vue/package.json +35 -0
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
- package/lib/__templates__/{vite-vue → nuxt-vue}/postcss.config.mjs +3 -1
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/{vite-vue → nuxt-vue}/scripts/build.sh +2 -2
- package/lib/__templates__/{vite-vue → nuxt-vue}/scripts/dev.sh +9 -2
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
- package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
- package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
- package/lib/__templates__/nuxt-vue/template.config.js +87 -0
- package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
- package/lib/__templates__/taro/README.md +57 -45
- package/lib/__templates__/taro/config/index.ts +45 -30
- package/lib/__templates__/taro/eslint.config.mjs +61 -6
- package/lib/__templates__/taro/package.json +8 -3
- package/lib/__templates__/taro/pnpm-lock.yaml +515 -203
- package/lib/__templates__/taro/src/app.css +140 -36
- package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
- package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
- package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
- package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
- package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
- package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
- package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
- package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
- package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
- package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
- package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
- package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
- package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
- package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
- package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
- package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
- package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
- package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
- package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
- package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
- package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
- package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
- package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
- package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
- package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
- package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
- package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
- package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
- package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
- package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
- package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
- package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
- package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
- package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
- package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
- package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
- package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
- package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
- package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
- package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
- package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
- package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
- package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
- package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
- package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
- package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
- package/lib/__templates__/taro/src/lib/measure.ts +115 -0
- package/lib/__templates__/taro/src/lib/platform.ts +12 -0
- package/lib/__templates__/taro/src/lib/utils.ts +6 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +49 -12
- package/lib/__templates__/taro/src/presets/h5-styles.ts +78 -0
- package/lib/__templates__/templates.json +17 -17
- package/lib/__templates__/vite/AGENTS.md +41 -0
- package/lib/__templates__/vite/README.md +190 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +10 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +755 -15
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +9 -2
- package/lib/__templates__/vite/scripts/start.sh +9 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +65 -0
- package/lib/__templates__/vite/server/vite.ts +67 -0
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +4 -0
- package/lib/cli.js +3251 -768
- package/package.json +9 -3
- package/lib/__templates__/vite-vue/README.md +0 -451
- package/lib/__templates__/vite-vue/_gitignore +0 -66
- package/lib/__templates__/vite-vue/eslint.config.mjs +0 -9
- package/lib/__templates__/vite-vue/index.html +0 -13
- package/lib/__templates__/vite-vue/package.json +0 -38
- package/lib/__templates__/vite-vue/pnpm-lock.yaml +0 -3132
- package/lib/__templates__/vite-vue/scripts/prepare.sh +0 -9
- package/lib/__templates__/vite-vue/scripts/start.sh +0 -15
- package/lib/__templates__/vite-vue/src/App.vue +0 -6
- package/lib/__templates__/vite-vue/src/main.ts +0 -8
- package/lib/__templates__/vite-vue/src/router/index.ts +0 -17
- package/lib/__templates__/vite-vue/src/views/Home.vue +0 -38
- package/lib/__templates__/vite-vue/src/vite-env.d.ts +0 -8
- package/lib/__templates__/vite-vue/tailwind.config.js +0 -9
- package/lib/__templates__/vite-vue/template.config.js +0 -127
- package/lib/__templates__/vite-vue/tsconfig.json +0 -17
- package/lib/__templates__/vite-vue/vite.config.ts +0 -28
- /package/lib/__templates__/{vite-vue → nuxt-vue}/.coze +0 -0
- /package/lib/__templates__/{vite-vue → nuxt-vue}/_npmrc +0 -0
|
@@ -8,7 +8,10 @@ cd "${COZE_WORKSPACE_PATH}"
|
|
|
8
8
|
echo "Installing dependencies..."
|
|
9
9
|
pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
10
10
|
|
|
11
|
-
echo "Building
|
|
11
|
+
echo "Building frontend with Vite..."
|
|
12
12
|
npx vite build
|
|
13
13
|
|
|
14
|
+
echo "Bundling server with tsup..."
|
|
15
|
+
npx tsup server/server.ts --format cjs --platform node --target node20 --outDir dist-server --no-splitting --no-minify --external vite
|
|
16
|
+
|
|
14
17
|
echo "Build completed successfully!"
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
set -Eeuo pipefail
|
|
3
3
|
|
|
4
|
+
<% if (process.env.NODE_ENV === 'test') { %>
|
|
5
|
+
# 测试环境:支持环境变量覆盖端口
|
|
6
|
+
PORT="${PORT:-<%= port %>}"
|
|
7
|
+
COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
8
|
+
DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
|
|
9
|
+
<% } else { %>
|
|
4
10
|
PORT=<%= port %>
|
|
5
11
|
COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
6
12
|
DEPLOY_RUN_PORT=<%= port %>
|
|
13
|
+
<% } %>
|
|
7
14
|
|
|
8
15
|
cd "${COZE_WORKSPACE_PATH}"
|
|
9
16
|
|
|
@@ -27,6 +34,6 @@ kill_port_if_listening() {
|
|
|
27
34
|
|
|
28
35
|
echo "Clearing port ${PORT} before start."
|
|
29
36
|
kill_port_if_listening
|
|
30
|
-
echo "Starting
|
|
37
|
+
echo "Starting express + Vite dev server on port ${PORT}..."
|
|
31
38
|
|
|
32
|
-
npx
|
|
39
|
+
PORT=$PORT npx tsx watch server/server.ts
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
set -Eeuo pipefail
|
|
3
3
|
|
|
4
4
|
COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
5
|
+
<% if (process.env.NODE_ENV === 'test') { %>
|
|
6
|
+
# 测试环境:支持环境变量覆盖端口
|
|
7
|
+
PORT="${PORT:-<%= port %>}"
|
|
8
|
+
DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
|
|
9
|
+
<% } else { %>
|
|
5
10
|
PORT=<%= port %>
|
|
6
11
|
DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-$PORT}"
|
|
12
|
+
<% } %>
|
|
7
13
|
|
|
8
14
|
start_service() {
|
|
9
15
|
cd "${COZE_WORKSPACE_PATH}"
|
|
10
|
-
echo "Starting
|
|
11
|
-
|
|
16
|
+
echo "Starting express production server on port ${DEPLOY_RUN_PORT}..."
|
|
17
|
+
PORT=$DEPLOY_RUN_PORT node dist-server/server.js
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
echo "Starting
|
|
20
|
+
echo "Starting express production server on port ${DEPLOY_RUN_PORT}..."
|
|
15
21
|
start_service
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Router } from 'express';
|
|
2
|
+
|
|
3
|
+
const router = Router();
|
|
4
|
+
|
|
5
|
+
// API 路由示例
|
|
6
|
+
router.get('/api/hello', (req, res) => {
|
|
7
|
+
res.json({
|
|
8
|
+
message: 'Hello from Express + Vite!',
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
router.post('/api/data', (req, res) => {
|
|
14
|
+
const requestData = req.body;
|
|
15
|
+
res.json({
|
|
16
|
+
success: true,
|
|
17
|
+
data: requestData,
|
|
18
|
+
receivedAt: new Date().toISOString(),
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// 健康检查接口
|
|
23
|
+
router.get('/api/health', (req, res) => {
|
|
24
|
+
res.json({
|
|
25
|
+
status: 'ok',
|
|
26
|
+
env: process.env.COZE_PROJECT_ENV,
|
|
27
|
+
timestamp: new Date().toISOString(),
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default router;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// ABOUTME: Express server with Vite integration
|
|
2
|
+
// ABOUTME: Handles API routes and serves frontend in dev/prod modes
|
|
3
|
+
|
|
4
|
+
import { createServer, type Server } from 'http';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import router from './routes/index';
|
|
7
|
+
import { setupVite } from './vite';
|
|
8
|
+
|
|
9
|
+
const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
|
|
10
|
+
const port = parseInt(process.env.PORT || '<%= port %>', 10);
|
|
11
|
+
const hostname = process.env.HOSTNAME || 'localhost';
|
|
12
|
+
const app = express();
|
|
13
|
+
// 使用 http.createServer 包装 Express app,以便支持 WebSocket 等协议升级
|
|
14
|
+
const server = createServer(app);
|
|
15
|
+
|
|
16
|
+
async function startServer(): Promise<Server> {
|
|
17
|
+
// 请求日志(仅开发环境)
|
|
18
|
+
if (isDev) {
|
|
19
|
+
app.use((req, res, next) => {
|
|
20
|
+
const start = Date.now();
|
|
21
|
+
res.on('finish', () => {
|
|
22
|
+
const ms = Date.now() - start;
|
|
23
|
+
console.log(`${req.method} ${req.url} - ${ms}ms`);
|
|
24
|
+
});
|
|
25
|
+
next();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 添加请求体解析
|
|
30
|
+
app.use(express.json());
|
|
31
|
+
app.use(express.urlencoded({ extended: true }));
|
|
32
|
+
|
|
33
|
+
// 注册 API 路由
|
|
34
|
+
app.use(router);
|
|
35
|
+
|
|
36
|
+
// 集成 Vite(开发模式)或静态文件服务(生产模式)
|
|
37
|
+
await setupVite(app);
|
|
38
|
+
|
|
39
|
+
// 全局错误处理
|
|
40
|
+
app.use((err: Error, req: express.Request, res: express.Response) => {
|
|
41
|
+
console.error('Server error:', err);
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
const status = 'status' in err ? (err as any).status || 500 : 500;
|
|
44
|
+
res.status(status).json({
|
|
45
|
+
error: err.message || 'Internal server error',
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
server.once('error', err => {
|
|
50
|
+
console.error('Server error:', err);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
server.listen(port, () => {
|
|
55
|
+
console.log(`\n✨ Server running at http://${hostname}:${port}`);
|
|
56
|
+
console.log(`📝 Environment: ${isDev ? 'development' : 'production'}\n`);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return server;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
startServer().catch(err => {
|
|
63
|
+
console.error('Failed to start server:', err);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// ABOUTME: Vite integration for Express server
|
|
2
|
+
// ABOUTME: Handles dev middleware and production static file serving
|
|
3
|
+
|
|
4
|
+
import type { Application, Request, Response } from 'express';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import { createServer as createViteServer } from 'vite';
|
|
9
|
+
import viteConfig from '../vite.config';
|
|
10
|
+
|
|
11
|
+
const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 集成 Vite 开发服务器(中间件模式)
|
|
15
|
+
*/
|
|
16
|
+
export async function setupViteMiddleware(app: Application) {
|
|
17
|
+
const vite = await createViteServer({
|
|
18
|
+
...viteConfig,
|
|
19
|
+
server: {
|
|
20
|
+
...viteConfig.server,
|
|
21
|
+
middlewareMode: true,
|
|
22
|
+
},
|
|
23
|
+
appType: 'spa',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// 使用 Vite middleware
|
|
27
|
+
app.use(vite.middlewares);
|
|
28
|
+
|
|
29
|
+
console.log('🚀 Vite dev server initialized');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 设置生产环境静态文件服务
|
|
34
|
+
*/
|
|
35
|
+
export function setupStaticServer(app: Application) {
|
|
36
|
+
const distPath = path.resolve(process.cwd(), 'dist');
|
|
37
|
+
|
|
38
|
+
if (!fs.existsSync(distPath)) {
|
|
39
|
+
console.error('❌ dist folder not found. Please run "pnpm build" first.');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 1. 服务静态文件(如果存在对应文件则直接返回)
|
|
44
|
+
app.use(express.static(distPath));
|
|
45
|
+
|
|
46
|
+
// 2. SPA fallback - 所有未处理的请求返回 index.html
|
|
47
|
+
// 到达这里的请求说明:
|
|
48
|
+
// - 不是 API 请求(已被前面注册的路由处理)
|
|
49
|
+
// - 不是静态文件(express.static 未找到对应文件)
|
|
50
|
+
// - 需要返回 index.html 让前端路由处理
|
|
51
|
+
app.use((_req: Request, res: Response) => {
|
|
52
|
+
res.sendFile(path.join(distPath, 'index.html'));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
console.log('📦 Serving static files from dist/');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 根据环境设置 Vite
|
|
60
|
+
*/
|
|
61
|
+
export async function setupVite(app: Application) {
|
|
62
|
+
if (isDev) {
|
|
63
|
+
await setupViteMiddleware(app);
|
|
64
|
+
} else {
|
|
65
|
+
setupStaticServer(app);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
"target": "ES2020",
|
|
4
4
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
5
5
|
"module": "ESNext",
|
|
6
|
-
"moduleResolution": "
|
|
6
|
+
"moduleResolution": "node",
|
|
7
7
|
"strict": true,
|
|
8
8
|
"esModuleInterop": true,
|
|
9
9
|
"skipLibCheck": true,
|
|
10
10
|
"forceConsistentCasingInFileNames": true,
|
|
11
11
|
"resolveJsonModule": true,
|
|
12
12
|
"isolatedModules": true,
|
|
13
|
-
"noEmit": true
|
|
13
|
+
"noEmit": true,
|
|
14
|
+
"types": ["node"]
|
|
14
15
|
},
|
|
15
|
-
"include": ["src"]
|
|
16
|
+
"include": ["src", "server"]
|
|
16
17
|
}
|