@coze-arch/cli 0.0.1-alpha.e8683e → 0.0.1-alpha.e89608
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/.cozeproj/scripts/dev_run.sh +25 -16
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/README.md +2 -2
- package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
- package/lib/__templates__/expo/client/app.config.ts +2 -2
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +21 -1
- package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +36 -34
- package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
- 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/react-native/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
- package/lib/__templates__/expo/package.json +3 -0
- package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +1318 -2636
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -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 +5 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +2096 -956
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +1 -2
- package/lib/__templates__/nextjs/scripts/start.sh +1 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/nuxt-vue/_npmrc +23 -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__/nuxt-vue/assets/css/main.css +24 -0
- 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__/nuxt-vue/postcss.config.mjs +8 -0
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +31 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +15 -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/.coze +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +751 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +223 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +80 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +107 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23100 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +52 -0
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/index.html +39 -0
- package/lib/__templates__/taro/src/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +201 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +75 -0
- package/lib/__templates__/vite/README.md +189 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +20 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +944 -1551
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +2 -2
- package/lib/__templates__/vite/scripts/start.sh +3 -3
- package/lib/__templates__/vite/server/index.ts +57 -0
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/vite.ts +79 -0
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +1 -0
- package/lib/cli.js +651 -173
- package/package.json +7 -3
|
@@ -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/index.ts --format cjs --platform node --target node20 --outDir dist-server --no-splitting --no-minify --external vite
|
|
16
|
+
|
|
14
17
|
echo "Build completed successfully!"
|
|
@@ -27,6 +27,6 @@ kill_port_if_listening() {
|
|
|
27
27
|
|
|
28
28
|
echo "Clearing port ${PORT} before start."
|
|
29
29
|
kill_port_if_listening
|
|
30
|
-
echo "Starting
|
|
30
|
+
echo "Starting Koa + Vite dev server on port ${PORT}..."
|
|
31
31
|
|
|
32
|
-
npx
|
|
32
|
+
PORT=$PORT npx tsx watch server/index.ts
|
|
@@ -7,9 +7,9 @@ DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-$PORT}"
|
|
|
7
7
|
|
|
8
8
|
start_service() {
|
|
9
9
|
cd "${COZE_WORKSPACE_PATH}"
|
|
10
|
-
echo "Starting
|
|
11
|
-
|
|
10
|
+
echo "Starting Koa production server on port ${DEPLOY_RUN_PORT}..."
|
|
11
|
+
PORT=$DEPLOY_RUN_PORT node dist-server/index.js
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
echo "Starting
|
|
14
|
+
echo "Starting Koa production server on port ${DEPLOY_RUN_PORT}..."
|
|
15
15
|
start_service
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Koa from 'koa';
|
|
2
|
+
import bodyParser from 'koa-bodyparser';
|
|
3
|
+
import router from './routes/index';
|
|
4
|
+
import { setupVite } from './vite';
|
|
5
|
+
|
|
6
|
+
const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
|
|
7
|
+
|
|
8
|
+
async function createServer() {
|
|
9
|
+
const app = new Koa();
|
|
10
|
+
|
|
11
|
+
// 全局错误处理
|
|
12
|
+
app.use(async (ctx, next) => {
|
|
13
|
+
try {
|
|
14
|
+
await next();
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error('Server error:', err);
|
|
17
|
+
const status =
|
|
18
|
+
err instanceof Error && 'status' in err
|
|
19
|
+
? (err as { status?: number }).status || 500
|
|
20
|
+
: 500;
|
|
21
|
+
ctx.status = status;
|
|
22
|
+
ctx.body = {
|
|
23
|
+
error: err instanceof Error ? err.message : 'Internal server error',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// 请求日志(仅开发环境)
|
|
29
|
+
if (isDev) {
|
|
30
|
+
app.use(async (ctx, next) => {
|
|
31
|
+
const start = Date.now();
|
|
32
|
+
await next();
|
|
33
|
+
const ms = Date.now() - start;
|
|
34
|
+
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 添加请求体解析
|
|
39
|
+
app.use(bodyParser());
|
|
40
|
+
|
|
41
|
+
// 注册 API 路由
|
|
42
|
+
app.use(router.routes()).use(router.allowedMethods());
|
|
43
|
+
|
|
44
|
+
// 集成 Vite(开发模式)或静态文件服务(生产模式)
|
|
45
|
+
await setupVite(app);
|
|
46
|
+
|
|
47
|
+
const port = process.env.PORT || <%= port %>;
|
|
48
|
+
app.listen(port, () => {
|
|
49
|
+
console.log(`\n✨ Server running at http://localhost:${port}`);
|
|
50
|
+
console.log(`📝 Environment: ${isDev ? 'development' : 'production'}\n`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
createServer().catch((err) => {
|
|
55
|
+
console.error('Failed to start server:', err);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Router from '@koa/router';
|
|
2
|
+
|
|
3
|
+
const router = new Router();
|
|
4
|
+
|
|
5
|
+
// API 路由示例
|
|
6
|
+
router.get('/api/hello', async ctx => {
|
|
7
|
+
ctx.body = {
|
|
8
|
+
message: 'Hello from Koa + Vite!',
|
|
9
|
+
timestamp: new Date().toISOString(),
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
router.post('/api/data', async ctx => {
|
|
14
|
+
const requestData = ctx.request.body;
|
|
15
|
+
ctx.body = {
|
|
16
|
+
success: true,
|
|
17
|
+
data: requestData,
|
|
18
|
+
receivedAt: new Date().toISOString(),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// 健康检查接口
|
|
23
|
+
router.get('/api/health', async ctx => {
|
|
24
|
+
ctx.body = {
|
|
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,79 @@
|
|
|
1
|
+
import type Koa from 'koa';
|
|
2
|
+
import serve from 'koa-static';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
|
|
6
|
+
const isDev = process.env.COZE_PROJECT_ENV !== 'PROD';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 集成 Vite 开发服务器(中间件模式)
|
|
10
|
+
* 使用动态 import 避免在生产构建时打包 vite
|
|
11
|
+
*/
|
|
12
|
+
export async function setupViteMiddleware(app: Koa) {
|
|
13
|
+
// 动态导入 vite,只在开发环境运行时加载
|
|
14
|
+
const { createServer: createViteServer } = await import('vite');
|
|
15
|
+
|
|
16
|
+
const vite = await createViteServer({
|
|
17
|
+
server: {
|
|
18
|
+
middlewareMode: true,
|
|
19
|
+
hmr: {
|
|
20
|
+
port: process.env.HMR_PORT ? parseInt(process.env.HMR_PORT) : undefined,
|
|
21
|
+
overlay: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
appType: 'spa',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// 将 Vite middleware 转换为 Koa middleware
|
|
28
|
+
app.use(async ctx => {
|
|
29
|
+
await new Promise<void>((resolve, reject) => {
|
|
30
|
+
vite.middlewares(ctx.req, ctx.res, (err?: Error) => {
|
|
31
|
+
if (err) {
|
|
32
|
+
reject(err);
|
|
33
|
+
} else {
|
|
34
|
+
resolve();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log('🚀 Vite dev server initialized');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 设置生产环境静态文件服务
|
|
45
|
+
*/
|
|
46
|
+
export function setupStaticServer(app: Koa) {
|
|
47
|
+
// 在 CommonJS 编译后,__dirname 会自动可用
|
|
48
|
+
// 在 TypeScript 中,我们使用相对于当前文件的路径
|
|
49
|
+
const distPath = path.resolve(process.cwd(), 'dist');
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(distPath)) {
|
|
52
|
+
console.error('❌ dist folder not found. Please run "pnpm build" first.');
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 服务静态文件
|
|
57
|
+
app.use(serve(distPath));
|
|
58
|
+
|
|
59
|
+
// SPA fallback - 所有非 API 请求返回 index.html
|
|
60
|
+
app.use(async ctx => {
|
|
61
|
+
if (!ctx.path.startsWith('/api')) {
|
|
62
|
+
ctx.type = 'html';
|
|
63
|
+
ctx.body = fs.createReadStream(path.join(distPath, 'index.html'));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
console.log('📦 Serving static files from dist/');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 根据环境设置 Vite
|
|
72
|
+
*/
|
|
73
|
+
export async function setupVite(app: Koa) {
|
|
74
|
+
if (isDev) {
|
|
75
|
+
await setupViteMiddleware(app);
|
|
76
|
+
} else {
|
|
77
|
+
setupStaticServer(app);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -7,56 +7,26 @@ export function initApp(): void {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
app.innerHTML = `
|
|
10
|
-
<div class="flex
|
|
11
|
-
|
|
12
|
-
|
|
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 min-h-screen">
|
|
11
|
+
<main class="flex w-full h-full max-w-3xl flex-col items-center justify-center px-16 py-32 sm:items-center">
|
|
12
|
+
<div class="flex flex-col items-center justify-between gap-4">
|
|
15
13
|
<img
|
|
16
|
-
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/
|
|
14
|
+
src="https://lf-coze-web-cdn.coze.cn/obj/eden-cn/lm-lgvj/ljhwZthlaukjlkulzlp/coze-coding/icon/coze-coding.gif"
|
|
17
15
|
alt="扣子编程 Logo"
|
|
18
|
-
width=
|
|
19
|
-
height=
|
|
20
|
-
style="width:
|
|
16
|
+
width={156}
|
|
17
|
+
height={130}
|
|
18
|
+
style="width: 156px; height: 130px; object-fit: contain;"
|
|
21
19
|
/>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</
|
|
32
|
-
<p class="max-w-2xl text-lg leading-8 text-zinc-600 dark:text-zinc-400">
|
|
33
|
-
当前是空白入口文件,项目正在开发中,请稍候...
|
|
34
|
-
<br />
|
|
35
|
-
开发完成后界面将自动更新。如未自动更新成功,可以手动点击右上角刷新或重启按钮查看效果。
|
|
36
|
-
</p>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<!-- 底部按钮区 -->
|
|
40
|
-
<div class="flex w-full flex-col gap-4 text-base font-medium sm:w-auto sm:flex-row">
|
|
41
|
-
<!-- 按钮 1:前往首页 -->
|
|
42
|
-
<a
|
|
43
|
-
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"
|
|
44
|
-
href="https://code.coze.cn/"
|
|
45
|
-
target="_blank"
|
|
46
|
-
rel="noopener noreferrer"
|
|
47
|
-
>
|
|
48
|
-
前往首页
|
|
49
|
-
</a>
|
|
50
|
-
|
|
51
|
-
<!-- 按钮 2:查看文档 -->
|
|
52
|
-
<a
|
|
53
|
-
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"
|
|
54
|
-
href="https://docs.coze.cn/"
|
|
55
|
-
target="_blank"
|
|
56
|
-
rel="noopener noreferrer"
|
|
57
|
-
>
|
|
58
|
-
查看文档
|
|
59
|
-
</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>
|
|
60
30
|
</div>
|
|
61
31
|
</main>
|
|
62
32
|
</div>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
|
-
import { resolve } from 'path';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { resolve, join, basename } from 'path';
|
|
4
|
+
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -59,32 +60,66 @@ const config = {
|
|
|
59
60
|
return context;
|
|
60
61
|
},
|
|
61
62
|
|
|
62
|
-
onAfterRender: async (
|
|
63
|
+
onAfterRender: async (_context, outputPath) => {
|
|
63
64
|
console.log(`\nProject created at: ${outputPath}`);
|
|
64
65
|
console.log('\nConfiguration:');
|
|
65
66
|
console.log(' - Framework: vite');
|
|
66
67
|
console.log(' - TypeScript: enabled');
|
|
67
68
|
console.log(' - App Router: enabled');
|
|
68
|
-
console.log(` - Port: ${
|
|
69
|
+
console.log(` - Port: ${_context.port}`);
|
|
70
|
+
},
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
onComplete: async (_context, outputPath) => {
|
|
73
|
+
// Skip pnpm update in test environment to avoid monorepo workspace issues
|
|
71
74
|
if (process.env.NODE_ENV === 'test') {
|
|
72
75
|
console.log('⊘ Skipping dependency update in test environment');
|
|
73
76
|
return;
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
const cmd =
|
|
77
|
-
|
|
79
|
+
const cmd = 'pnpm';
|
|
80
|
+
const args = ['update', 'coze-coding-dev-sdk@^0.7.0'];
|
|
81
|
+
console.log(
|
|
82
|
+
`\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
|
|
83
|
+
);
|
|
84
|
+
|
|
78
85
|
try {
|
|
79
86
|
const projectRoot = resolve(outputPath);
|
|
80
|
-
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
|
|
88
|
+
// Determine log directory
|
|
89
|
+
const logDir = process.env.COZE_LOG_DIR || resolve(__dirname, '../.log');
|
|
90
|
+
mkdirSync(logDir, { recursive: true });
|
|
91
|
+
|
|
92
|
+
// Use project name in log file to avoid conflicts
|
|
93
|
+
const projectName = basename(projectRoot);
|
|
94
|
+
const logFile = join(logDir, `${projectName}-init.log`);
|
|
95
|
+
|
|
96
|
+
// Write log header
|
|
97
|
+
const timestamp = new Date().toISOString();
|
|
98
|
+
appendFileSync(
|
|
99
|
+
logFile,
|
|
100
|
+
`\n=== [${timestamp}] ${cmd} ${args.join(' ')} ===\n`,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
// Open log file for appending
|
|
104
|
+
const logFd = openSync(logFile, 'a');
|
|
105
|
+
|
|
106
|
+
// Spawn in detached mode
|
|
107
|
+
const child = spawn(cmd, args, {
|
|
108
|
+
cwd: projectRoot,
|
|
109
|
+
detached: true,
|
|
110
|
+
stdio: ['ignore', logFd, logFd],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
child.unref();
|
|
114
|
+
closeSync(logFd);
|
|
115
|
+
|
|
116
|
+
console.log(
|
|
117
|
+
'✓ coze-coding-dev-sdk update triggered (running in background)',
|
|
118
|
+
);
|
|
119
|
+
console.log(` Log file: ${logFile}`);
|
|
85
120
|
} catch (error) {
|
|
86
|
-
console.error('✗ Failed to
|
|
87
|
-
|
|
121
|
+
console.error('✗ Failed to trigger coze-coding-dev-sdk update:', error);
|
|
122
|
+
console.log(' You can manually run: pnpm update coze-coding-dev-sdk');
|
|
88
123
|
}
|
|
89
124
|
},
|
|
90
125
|
};
|
|
@@ -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
|
}
|