@coze-arch/cli 0.0.38-alpha.da33e3 → 0.0.39-alpha.bdff32
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 +69 -104
- package/docs/deploy.md +181 -0
- package/lib/__templates__/expo/.coze +5 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.ps1 +10 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +4 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.ps1 +74 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +108 -19
- package/lib/__templates__/expo/.cozeproj/scripts/prod_build.ps1 +15 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.ps1 +10 -0
- package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/validate.ps1 +7 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -1
- package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
- package/lib/__templates__/expo/server/package.json +2 -2
- package/lib/__templates__/expo/server/src/index.ts +1 -1
- package/lib/__templates__/expo/template.config.js +11 -2
- package/lib/__templates__/native-static/.coze +4 -2
- package/lib/__templates__/native-static/scripts/serve.ps1 +7 -0
- package/lib/__templates__/nextjs/.coze +5 -0
- package/lib/__templates__/nextjs/package.json +2 -2
- package/lib/__templates__/nextjs/pnpm-lock.yaml +54 -54
- package/lib/__templates__/nextjs/scripts/build.ps1 +16 -0
- package/lib/__templates__/nextjs/scripts/dev.ps1 +63 -0
- package/lib/__templates__/nextjs/scripts/dev.sh +234 -7
- package/lib/__templates__/nextjs/scripts/prepare.ps1 +18 -0
- package/lib/__templates__/nextjs/scripts/start.ps1 +11 -0
- package/lib/__templates__/nextjs/scripts/validate.ps1 +8 -0
- package/lib/__templates__/nextjs/template.config.js +4 -2
- package/lib/__templates__/nuxt-vue/.coze +5 -0
- package/lib/__templates__/nuxt-vue/package.json +1 -1
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +5 -5
- package/lib/__templates__/nuxt-vue/scripts/build.ps1 +12 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.ps1 +63 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +232 -3
- package/lib/__templates__/nuxt-vue/scripts/prepare.ps1 +12 -0
- package/lib/__templates__/nuxt-vue/scripts/start.ps1 +11 -0
- package/lib/__templates__/nuxt-vue/scripts/validate.ps1 +8 -0
- package/lib/__templates__/phaser/.coze +18 -0
- package/lib/__templates__/phaser/README.md +45 -0
- package/lib/__templates__/phaser/_gitignore +23 -0
- package/lib/__templates__/phaser/_npmrc +14 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
- package/lib/__templates__/phaser/assets/image_sequence/coze-game-loading/manifest.json +11 -0
- package/lib/__templates__/phaser/debug-runtime/flow-graph.json +20 -0
- package/lib/__templates__/phaser/index.html +12 -0
- package/lib/__templates__/phaser/package.json +31 -0
- package/lib/__templates__/phaser/pnpm-lock.yaml +661 -0
- package/lib/__templates__/phaser/scripts/build.ps1 +12 -0
- package/lib/__templates__/phaser/scripts/build.sh +8 -0
- package/lib/__templates__/phaser/scripts/dev.ps1 +49 -0
- package/lib/__templates__/phaser/scripts/dev.sh +82 -0
- package/lib/__templates__/phaser/scripts/prepare.ps1 +8 -0
- package/lib/__templates__/phaser/scripts/prepare.sh +7 -0
- package/lib/__templates__/phaser/scripts/spawn-detached.cjs +29 -0
- package/lib/__templates__/phaser/scripts/start.ps1 +49 -0
- package/lib/__templates__/phaser/scripts/start.sh +82 -0
- package/lib/__templates__/phaser/scripts/validate.ps1 +7 -0
- package/lib/__templates__/phaser/scripts/validate.sh +7 -0
- package/lib/__templates__/phaser/src/assets.ts +15 -0
- package/lib/__templates__/phaser/src/global.d.ts +39 -0
- package/lib/__templates__/phaser/src/main.ts +28 -0
- package/lib/__templates__/phaser/src/scene/BootScene.ts +213 -0
- package/lib/__templates__/phaser/src/scene/DevLoadingScene.ts +69 -0
- package/lib/__templates__/phaser/src/style.css +28 -0
- package/lib/__templates__/phaser/src/types.ts +32 -0
- package/lib/__templates__/phaser/src/utils/asset-loader.ts +319 -0
- package/lib/__templates__/phaser/src/utils/index.ts +2 -0
- package/lib/__templates__/phaser/src/utils/mark-editable.ts +13 -0
- package/lib/__templates__/phaser/template.config.js +43 -0
- package/lib/__templates__/phaser/tsconfig.json +23 -0
- package/lib/__templates__/phaser/vite.config.ts +96 -0
- package/lib/__templates__/phaser-static/.coze +15 -0
- package/lib/__templates__/phaser-static/README.md +40 -0
- package/lib/__templates__/phaser-static/_gitignore +6 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0001.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0002.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0003.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0004.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0005.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0006.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0007.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0008.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0009.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0010.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0011.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0012.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0013.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0014.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0015.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0016.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0017.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0018.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0019.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0020.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0021.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0022.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0023.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/frame_0024.png +0 -0
- package/lib/__templates__/phaser-static/assets/image_sequence/coze-game-loading/manifest.json +11 -0
- package/lib/__templates__/phaser-static/debug-runtime/flow-graph.json +20 -0
- package/lib/__templates__/phaser-static/index.html +17 -0
- package/lib/__templates__/phaser-static/scripts/serve.ps1 +7 -0
- package/lib/__templates__/phaser-static/src/assets.js +15 -0
- package/lib/__templates__/phaser-static/src/main.js +26 -0
- package/lib/__templates__/phaser-static/src/phaser.js +7 -0
- package/lib/__templates__/phaser-static/src/scene/BootScene.js +205 -0
- package/lib/__templates__/phaser-static/src/scene/DevLoadingScene.js +67 -0
- package/lib/__templates__/phaser-static/src/style.css +28 -0
- package/lib/__templates__/phaser-static/src/utils/asset-loader.js +267 -0
- package/lib/__templates__/phaser-static/src/utils/index.js +2 -0
- package/lib/__templates__/phaser-static/src/utils/mark-editable.js +3 -0
- package/lib/__templates__/phaser-static/template.config.js +35 -0
- package/lib/__templates__/pi-agent/package.json +1 -1
- package/lib/__templates__/pi-agent/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/.coze +6 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.ps1 +10 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.ps1 +8 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +1 -1
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.ps1 +3 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.ps1 +62 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +178 -68
- package/lib/__templates__/taro/.cozeproj/scripts/pack.ps1 +7 -0
- package/lib/__templates__/taro/.cozeproj/scripts/validate.ps1 +7 -0
- package/lib/__templates__/taro/AGENTS.md +11 -7
- package/lib/__templates__/taro/README.md +4 -4
- package/lib/__templates__/taro/config/index.ts +10 -2
- package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
- package/lib/__templates__/taro/server/package.json +1 -1
- package/lib/__templates__/taro/server/src/main.ts +8 -2
- package/lib/__templates__/templates.json +51 -1
- package/lib/__templates__/vite/.coze +5 -0
- package/lib/__templates__/vite/package.json +1 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +5 -5
- package/lib/__templates__/vite/scripts/build.ps1 +16 -0
- package/lib/__templates__/vite/scripts/dev.ps1 +63 -0
- package/lib/__templates__/vite/scripts/dev.sh +110 -1
- package/lib/__templates__/vite/scripts/prepare.ps1 +18 -0
- package/lib/__templates__/vite/scripts/start.ps1 +11 -0
- package/lib/__templates__/vite/scripts/validate.ps1 +8 -0
- package/lib/__templates__/vite/template.config.js +4 -2
- package/lib/cli.js +3719 -211
- package/lib/deploy/package-project.js +244 -0
- package/lib/deploy/package-project.py +183 -0
- package/package.json +5 -2
|
@@ -111,8 +111,8 @@ importers:
|
|
|
111
111
|
specifier: ^1.1.1
|
|
112
112
|
version: 1.1.1(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
|
113
113
|
coze-coding-dev-sdk:
|
|
114
|
-
specifier: ^0.7.
|
|
115
|
-
version: 0.7.
|
|
114
|
+
specifier: ^0.7.25
|
|
115
|
+
version: 0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
|
|
116
116
|
date-fns:
|
|
117
117
|
specifier: ^4.1.0
|
|
118
118
|
version: 4.1.0
|
|
@@ -138,8 +138,8 @@ importers:
|
|
|
138
138
|
specifier: ^0.468.0
|
|
139
139
|
version: 0.468.0(react@19.2.3)
|
|
140
140
|
next:
|
|
141
|
-
specifier: 16.
|
|
142
|
-
version: 16.
|
|
141
|
+
specifier: 16.3.3
|
|
142
|
+
version: 16.3.3(@babel/core@7.28.6)(@types/node@20.19.30)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
|
143
143
|
next-themes:
|
|
144
144
|
specifier: ^0.4.6
|
|
145
145
|
version: 0.4.6(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
|
|
@@ -1434,60 +1434,60 @@ packages:
|
|
|
1434
1434
|
'@napi-rs/wasm-runtime@0.2.12':
|
|
1435
1435
|
resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==}
|
|
1436
1436
|
|
|
1437
|
-
'@next/env@16.
|
|
1438
|
-
resolution: {integrity: sha512-
|
|
1437
|
+
'@next/env@16.3.3':
|
|
1438
|
+
resolution: {integrity: sha512-U2eYQRwXj+dsqxV79zFqExDdatnNY/ZWc2nsJU1p/OgT7fd3dXwlF6OjYaFQCfMoeTA19PWq+wVmYgimVA+V+g==}
|
|
1439
1439
|
|
|
1440
1440
|
'@next/eslint-plugin-next@16.3.3':
|
|
1441
1441
|
resolution: {integrity: sha512-pbEh30vvjKpDoTAmo1v3q2uM4JUi8QaEBpbmjWvGfoec2jLghy/WNtvzAT0bk+Ik9oz6etjt4YjXEk4BQnicCw==}
|
|
1442
1442
|
|
|
1443
|
-
'@next/swc-darwin-arm64@16.
|
|
1444
|
-
resolution: {integrity: sha512-
|
|
1443
|
+
'@next/swc-darwin-arm64@16.3.3':
|
|
1444
|
+
resolution: {integrity: sha512-8Hiv32QJPwdV6KYJ8meR9SBA061tQqnIKTJDocvOXlEQqib0xMFpzArosuffFUUc0sslbh7QQ8a3Yey1QV8EIw==}
|
|
1445
1445
|
engines: {node: '>= 10'}
|
|
1446
1446
|
cpu: [arm64]
|
|
1447
1447
|
os: [darwin]
|
|
1448
1448
|
|
|
1449
|
-
'@next/swc-darwin-x64@16.
|
|
1450
|
-
resolution: {integrity: sha512-
|
|
1449
|
+
'@next/swc-darwin-x64@16.3.3':
|
|
1450
|
+
resolution: {integrity: sha512-A1lgKgwVchRYmSe467zdwhxT9040dd8lH+o65sL5Jet8fjB4kegw/rDyPIpYVRb6jAqwXFOJpjIXJLxQKLiE3A==}
|
|
1451
1451
|
engines: {node: '>= 10'}
|
|
1452
1452
|
cpu: [x64]
|
|
1453
1453
|
os: [darwin]
|
|
1454
1454
|
|
|
1455
|
-
'@next/swc-linux-arm64-gnu@16.
|
|
1456
|
-
resolution: {integrity: sha512
|
|
1455
|
+
'@next/swc-linux-arm64-gnu@16.3.3':
|
|
1456
|
+
resolution: {integrity: sha512-bf0FIssMFueU2dm7vQEWWxk0c8UjKTdW0yzuh0sQsD8pf1+KCLDdaqhYZNMYGmXwEOiHAUzgBKudovIlcvvBjg==}
|
|
1457
1457
|
engines: {node: '>= 10'}
|
|
1458
1458
|
cpu: [arm64]
|
|
1459
1459
|
os: [linux]
|
|
1460
1460
|
libc: [glibc]
|
|
1461
1461
|
|
|
1462
|
-
'@next/swc-linux-arm64-musl@16.
|
|
1463
|
-
resolution: {integrity: sha512-
|
|
1462
|
+
'@next/swc-linux-arm64-musl@16.3.3':
|
|
1463
|
+
resolution: {integrity: sha512-W7viwCk9JY/cAkdz/A273rd5bb3RgT/IHwR7Upv90tunjBWNtAAhGhoecHh+teRNRSinuAFmE+l7fwZ4YKkrXg==}
|
|
1464
1464
|
engines: {node: '>= 10'}
|
|
1465
1465
|
cpu: [arm64]
|
|
1466
1466
|
os: [linux]
|
|
1467
1467
|
libc: [musl]
|
|
1468
1468
|
|
|
1469
|
-
'@next/swc-linux-x64-gnu@16.
|
|
1470
|
-
resolution: {integrity: sha512-
|
|
1469
|
+
'@next/swc-linux-x64-gnu@16.3.3':
|
|
1470
|
+
resolution: {integrity: sha512-0W46zw1N3ODpI6n0GeivHvvob1pooozgZVqy65k0mh4/7vr+FbY9+WpHzNVXjHipJf/A3FDheBG19H1s5A25rA==}
|
|
1471
1471
|
engines: {node: '>= 10'}
|
|
1472
1472
|
cpu: [x64]
|
|
1473
1473
|
os: [linux]
|
|
1474
1474
|
libc: [glibc]
|
|
1475
1475
|
|
|
1476
|
-
'@next/swc-linux-x64-musl@16.
|
|
1477
|
-
resolution: {integrity: sha512-
|
|
1476
|
+
'@next/swc-linux-x64-musl@16.3.3':
|
|
1477
|
+
resolution: {integrity: sha512-H4mBso8ZTMBPtdT0PN0pBx2ayTvQuTuvS6qT13d77yVFJXAPCxkyIhLTmdMaGTJs0krQYI/qpzdHijCeihXhbg==}
|
|
1478
1478
|
engines: {node: '>= 10'}
|
|
1479
1479
|
cpu: [x64]
|
|
1480
1480
|
os: [linux]
|
|
1481
1481
|
libc: [musl]
|
|
1482
1482
|
|
|
1483
|
-
'@next/swc-win32-arm64-msvc@16.
|
|
1484
|
-
resolution: {integrity: sha512-
|
|
1483
|
+
'@next/swc-win32-arm64-msvc@16.3.3':
|
|
1484
|
+
resolution: {integrity: sha512-cTMUJpcEGmeywofCUfhR+rSsoE33+rVPnPEYNTNdLNlsOeEg/vktOsKUSTb28vUGqD2jkm4Zaskcwn7OCI6FQg==}
|
|
1485
1485
|
engines: {node: '>= 10'}
|
|
1486
1486
|
cpu: [arm64]
|
|
1487
1487
|
os: [win32]
|
|
1488
1488
|
|
|
1489
|
-
'@next/swc-win32-x64-msvc@16.
|
|
1490
|
-
resolution: {integrity: sha512-
|
|
1489
|
+
'@next/swc-win32-x64-msvc@16.3.3':
|
|
1490
|
+
resolution: {integrity: sha512-2VR4cTBzHXaBjnGsuH6GyJjENzQOmHeAh11uY1iUhjm3j5dEUrVJuUj+VL78jaGi/Dik8xS76zEj18BsFhlVZQ==}
|
|
1491
1491
|
engines: {node: '>= 10'}
|
|
1492
1492
|
cpu: [x64]
|
|
1493
1493
|
os: [win32]
|
|
@@ -2583,8 +2583,8 @@ packages:
|
|
|
2583
2583
|
resolution: {integrity: sha512-Fukw1cUTQ6xdLiHDJhKKPu6svEPaCEDvThqCne3OaQyZvuq2qjhJAd91kJu3PXLG18aooCgYBaB6qQz35hhABg==}
|
|
2584
2584
|
engines: {node: '>=20.0.0'}
|
|
2585
2585
|
|
|
2586
|
-
'@swc/helpers@0.5.
|
|
2587
|
-
resolution: {integrity: sha512-
|
|
2586
|
+
'@swc/helpers@0.5.23':
|
|
2587
|
+
resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==}
|
|
2588
2588
|
|
|
2589
2589
|
'@tailwindcss/node@4.1.18':
|
|
2590
2590
|
resolution: {integrity: sha512-DoR7U1P7iYhw16qJ49fgXUlry1t4CpXeErJHnQ44JgTSKMaZUdf17cfn5mHchfJ4KRBZRFA/Coo+MUF5+gOaCQ==}
|
|
@@ -3383,8 +3383,8 @@ packages:
|
|
|
3383
3383
|
typescript:
|
|
3384
3384
|
optional: true
|
|
3385
3385
|
|
|
3386
|
-
coze-coding-dev-sdk@0.7.
|
|
3387
|
-
resolution: {integrity: sha512-
|
|
3386
|
+
coze-coding-dev-sdk@0.7.25:
|
|
3387
|
+
resolution: {integrity: sha512-5683ngikMdsRW0slGTE2OAZ1Fyj0lhkC4fGNOwsqKc35e68/gtg9KmmtK9CK9SZ+5/oIn/4wLoHXFB0gHJtO2A==}
|
|
3388
3388
|
engines: {node: '>=18.0.0'}
|
|
3389
3389
|
hasBin: true
|
|
3390
3390
|
|
|
@@ -4962,8 +4962,8 @@ packages:
|
|
|
4962
4962
|
react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
|
|
4963
4963
|
react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc
|
|
4964
4964
|
|
|
4965
|
-
next@16.
|
|
4966
|
-
resolution: {integrity: sha512-
|
|
4965
|
+
next@16.3.3:
|
|
4966
|
+
resolution: {integrity: sha512-tuRTx1nQ/yVw83cwJBo9F+njGUgMn3UHQycreWHB8XsStvvAh1AthbI8/4IpKnFaF58F+iSiHejYOlMQ/eq83g==}
|
|
4967
4967
|
engines: {node: '>=20.9.0'}
|
|
4968
4968
|
hasBin: true
|
|
4969
4969
|
peerDependencies:
|
|
@@ -5288,8 +5288,8 @@ packages:
|
|
|
5288
5288
|
postcss-value-parser@4.2.0:
|
|
5289
5289
|
resolution: {integrity: sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==}
|
|
5290
5290
|
|
|
5291
|
-
postcss@8.
|
|
5292
|
-
resolution: {integrity: sha512-
|
|
5291
|
+
postcss@8.5.23:
|
|
5292
|
+
resolution: {integrity: sha512-g50586zr4bZmwFiTlflMu8E0bDTb5I5gertgwAKmsdUlTQIhZtunzUlD1WSzwcVWPoAVpsrA6vlfCD7oXvRwgg==}
|
|
5293
5293
|
engines: {node: ^10 || ^12 || >=14}
|
|
5294
5294
|
|
|
5295
5295
|
postcss@8.5.6:
|
|
@@ -7633,7 +7633,7 @@ snapshots:
|
|
|
7633
7633
|
'@tybys/wasm-util': 0.10.1
|
|
7634
7634
|
optional: true
|
|
7635
7635
|
|
|
7636
|
-
'@next/env@16.
|
|
7636
|
+
'@next/env@16.3.3': {}
|
|
7637
7637
|
|
|
7638
7638
|
'@next/eslint-plugin-next@16.3.3(eslint@9.39.2(jiti@2.6.1))':
|
|
7639
7639
|
dependencies:
|
|
@@ -7642,28 +7642,28 @@ snapshots:
|
|
|
7642
7642
|
transitivePeerDependencies:
|
|
7643
7643
|
- eslint
|
|
7644
7644
|
|
|
7645
|
-
'@next/swc-darwin-arm64@16.
|
|
7645
|
+
'@next/swc-darwin-arm64@16.3.3':
|
|
7646
7646
|
optional: true
|
|
7647
7647
|
|
|
7648
|
-
'@next/swc-darwin-x64@16.
|
|
7648
|
+
'@next/swc-darwin-x64@16.3.3':
|
|
7649
7649
|
optional: true
|
|
7650
7650
|
|
|
7651
|
-
'@next/swc-linux-arm64-gnu@16.
|
|
7651
|
+
'@next/swc-linux-arm64-gnu@16.3.3':
|
|
7652
7652
|
optional: true
|
|
7653
7653
|
|
|
7654
|
-
'@next/swc-linux-arm64-musl@16.
|
|
7654
|
+
'@next/swc-linux-arm64-musl@16.3.3':
|
|
7655
7655
|
optional: true
|
|
7656
7656
|
|
|
7657
|
-
'@next/swc-linux-x64-gnu@16.
|
|
7657
|
+
'@next/swc-linux-x64-gnu@16.3.3':
|
|
7658
7658
|
optional: true
|
|
7659
7659
|
|
|
7660
|
-
'@next/swc-linux-x64-musl@16.
|
|
7660
|
+
'@next/swc-linux-x64-musl@16.3.3':
|
|
7661
7661
|
optional: true
|
|
7662
7662
|
|
|
7663
|
-
'@next/swc-win32-arm64-msvc@16.
|
|
7663
|
+
'@next/swc-win32-arm64-msvc@16.3.3':
|
|
7664
7664
|
optional: true
|
|
7665
7665
|
|
|
7666
|
-
'@next/swc-win32-x64-msvc@16.
|
|
7666
|
+
'@next/swc-win32-x64-msvc@16.3.3':
|
|
7667
7667
|
optional: true
|
|
7668
7668
|
|
|
7669
7669
|
'@noble/ciphers@1.3.0': {}
|
|
@@ -8883,7 +8883,7 @@ snapshots:
|
|
|
8883
8883
|
- bufferutil
|
|
8884
8884
|
- utf-8-validate
|
|
8885
8885
|
|
|
8886
|
-
'@swc/helpers@0.5.
|
|
8886
|
+
'@swc/helpers@0.5.23':
|
|
8887
8887
|
dependencies:
|
|
8888
8888
|
tslib: 2.8.1
|
|
8889
8889
|
|
|
@@ -9676,7 +9676,7 @@ snapshots:
|
|
|
9676
9676
|
optionalDependencies:
|
|
9677
9677
|
typescript: 5.9.3
|
|
9678
9678
|
|
|
9679
|
-
coze-coding-dev-sdk@0.7.
|
|
9679
|
+
coze-coding-dev-sdk@0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
|
|
9680
9680
|
dependencies:
|
|
9681
9681
|
'@langchain/core': 1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6))
|
|
9682
9682
|
'@langchain/openai': 1.2.3(@langchain/core@1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6)))(ws@8.19.0)
|
|
@@ -11288,25 +11288,25 @@ snapshots:
|
|
|
11288
11288
|
react: 19.2.3
|
|
11289
11289
|
react-dom: 19.2.3(react@19.2.3)
|
|
11290
11290
|
|
|
11291
|
-
next@16.
|
|
11291
|
+
next@16.3.3(@babel/core@7.28.6)(@types/node@20.19.30)(react-dom@19.2.3(react@19.2.3))(react@19.2.3):
|
|
11292
11292
|
dependencies:
|
|
11293
|
-
'@next/env': 16.
|
|
11294
|
-
'@swc/helpers': 0.5.
|
|
11293
|
+
'@next/env': 16.3.3
|
|
11294
|
+
'@swc/helpers': 0.5.23
|
|
11295
11295
|
baseline-browser-mapping: 2.11.19
|
|
11296
11296
|
caniuse-lite: 1.0.30001766
|
|
11297
|
-
postcss: 8.
|
|
11297
|
+
postcss: 8.5.23
|
|
11298
11298
|
react: 19.2.3
|
|
11299
11299
|
react-dom: 19.2.3(react@19.2.3)
|
|
11300
11300
|
styled-jsx: 5.1.6(@babel/core@7.28.6)(react@19.2.3)
|
|
11301
11301
|
optionalDependencies:
|
|
11302
|
-
'@next/swc-darwin-arm64': 16.
|
|
11303
|
-
'@next/swc-darwin-x64': 16.
|
|
11304
|
-
'@next/swc-linux-arm64-gnu': 16.
|
|
11305
|
-
'@next/swc-linux-arm64-musl': 16.
|
|
11306
|
-
'@next/swc-linux-x64-gnu': 16.
|
|
11307
|
-
'@next/swc-linux-x64-musl': 16.
|
|
11308
|
-
'@next/swc-win32-arm64-msvc': 16.
|
|
11309
|
-
'@next/swc-win32-x64-msvc': 16.
|
|
11302
|
+
'@next/swc-darwin-arm64': 16.3.3
|
|
11303
|
+
'@next/swc-darwin-x64': 16.3.3
|
|
11304
|
+
'@next/swc-linux-arm64-gnu': 16.3.3
|
|
11305
|
+
'@next/swc-linux-arm64-musl': 16.3.3
|
|
11306
|
+
'@next/swc-linux-x64-gnu': 16.3.3
|
|
11307
|
+
'@next/swc-linux-x64-musl': 16.3.3
|
|
11308
|
+
'@next/swc-win32-arm64-msvc': 16.3.3
|
|
11309
|
+
'@next/swc-win32-x64-msvc': 16.3.3
|
|
11310
11310
|
sharp: 0.35.3(@types/node@20.19.30)
|
|
11311
11311
|
transitivePeerDependencies:
|
|
11312
11312
|
- '@babel/core'
|
|
@@ -11596,7 +11596,7 @@ snapshots:
|
|
|
11596
11596
|
|
|
11597
11597
|
postcss-value-parser@4.2.0: {}
|
|
11598
11598
|
|
|
11599
|
-
postcss@8.
|
|
11599
|
+
postcss@8.5.23:
|
|
11600
11600
|
dependencies:
|
|
11601
11601
|
nanoid: 3.3.18
|
|
11602
11602
|
picocolors: 1.1.1
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
|
|
3
|
+
$workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
|
|
4
|
+
Set-Location $workspace
|
|
5
|
+
|
|
6
|
+
Write-Host "Installing dependencies..."
|
|
7
|
+
& pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
8
|
+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
9
|
+
|
|
10
|
+
Write-Host "Building the Next.js project..."
|
|
11
|
+
& pnpm next build
|
|
12
|
+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
13
|
+
|
|
14
|
+
Write-Host "Bundling server with tsup..."
|
|
15
|
+
& pnpm tsup src/server.ts --format cjs --platform node --target node20 --outDir dist --no-splitting --no-minify
|
|
16
|
+
exit $LASTEXITCODE
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
|
|
3
|
+
function Get-WorkspacePath {
|
|
4
|
+
if ($env:COZE_WORKSPACE_PATH) {
|
|
5
|
+
return $env:COZE_WORKSPACE_PATH
|
|
6
|
+
}
|
|
7
|
+
return (Get-Location).Path
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function Stop-ProcessTree([int] $processId) {
|
|
11
|
+
if ($processId -gt 0 -and (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
|
|
12
|
+
& taskkill.exe /PID $processId /T /F *> $null
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function Stop-ListeningProcess([int] $port) {
|
|
17
|
+
$connections = Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue
|
|
18
|
+
$connections | Select-Object -ExpandProperty OwningProcess -Unique | ForEach-Object {
|
|
19
|
+
Stop-ProcessTree $_
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$workspace = Get-WorkspacePath
|
|
24
|
+
$defaultPort = <%= port %>
|
|
25
|
+
$port = if ($env:DEPLOY_RUN_PORT) { [int] $env:DEPLOY_RUN_PORT } elseif ($env:PORT) { [int] $env:PORT } else { $defaultPort }
|
|
26
|
+
Set-Location $workspace
|
|
27
|
+
Stop-ListeningProcess $port
|
|
28
|
+
|
|
29
|
+
<% if (process.env.NODE_ENV === 'test') { %>
|
|
30
|
+
$env:PORT = "$port"
|
|
31
|
+
& pnpm tsx watch src/server.ts
|
|
32
|
+
exit $LASTEXITCODE
|
|
33
|
+
<% } else { %>
|
|
34
|
+
$logDirectory = if ($env:COZE_LOG_DIR) { $env:COZE_LOG_DIR } else { Join-Path $workspace "logs" }
|
|
35
|
+
$logFile = Join-Path $logDirectory "server.log"
|
|
36
|
+
$errorLogFile = Join-Path $logDirectory "server-error.log"
|
|
37
|
+
$pidFile = Join-Path $logDirectory "server.pid"
|
|
38
|
+
New-Item -ItemType Directory -Force -Path $logDirectory | Out-Null
|
|
39
|
+
|
|
40
|
+
if (Test-Path $pidFile) {
|
|
41
|
+
Stop-ProcessTree ([int] (Get-Content $pidFile -Raw))
|
|
42
|
+
Remove-Item $pidFile -Force
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$previousPort = $env:PORT
|
|
46
|
+
$env:PORT = "$port"
|
|
47
|
+
try {
|
|
48
|
+
$process = Start-Process -FilePath $env:ComSpec -ArgumentList @("/d", "/s", "/c", "pnpm tsx watch src/server.ts") -WorkingDirectory $workspace -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
|
|
49
|
+
} finally {
|
|
50
|
+
if ($null -eq $previousPort) { Remove-Item Env:PORT -ErrorAction SilentlyContinue } else { $env:PORT = $previousPort }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
$process.Id | Set-Content $pidFile
|
|
54
|
+
Start-Sleep -Seconds 1
|
|
55
|
+
if ($process.HasExited) {
|
|
56
|
+
Get-Content $errorLogFile -Tail 20 -ErrorAction SilentlyContinue
|
|
57
|
+
Remove-Item $pidFile -Force -ErrorAction SilentlyContinue
|
|
58
|
+
exit 1
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Write-Host "Dev server started (PID: $($process.Id))."
|
|
62
|
+
Write-Host "Log file: $logFile"
|
|
63
|
+
<% } %>
|
|
@@ -7,33 +7,260 @@ PORT="${PORT:-<%= port %>}"
|
|
|
7
7
|
COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
8
8
|
DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
|
|
9
9
|
<% } else { %>
|
|
10
|
-
PORT
|
|
10
|
+
PORT="${DEPLOY_RUN_PORT:-${PORT:-<%= port %>}}"
|
|
11
11
|
COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
|
|
12
12
|
DEPLOY_RUN_PORT="${DEPLOY_RUN_PORT:-${PORT}}"
|
|
13
13
|
<% } %>
|
|
14
14
|
|
|
15
15
|
cd "${COZE_WORKSPACE_PATH}"
|
|
16
16
|
|
|
17
|
+
list_port_pids() {
|
|
18
|
+
local port=$1
|
|
19
|
+
local pids=""
|
|
20
|
+
local has_tool=0
|
|
21
|
+
|
|
22
|
+
if command -v ss >/dev/null 2>&1; then
|
|
23
|
+
has_tool=1
|
|
24
|
+
pids=$(ss -H -lntp 2>/dev/null | awk -v port="${port}" '$4 ~ ":"port"$"' | grep -o 'pid=[0-9]*' | cut -d= -f2 | sort -u | paste -sd' ' - || true)
|
|
25
|
+
fi
|
|
26
|
+
if [[ -z "${pids}" ]] && command -v lsof >/dev/null 2>&1; then
|
|
27
|
+
has_tool=1
|
|
28
|
+
pids=$(lsof -t -iTCP:"${port}" -sTCP:LISTEN 2>/dev/null | sort -u | paste -sd' ' - || true)
|
|
29
|
+
fi
|
|
30
|
+
if [[ "${has_tool}" -eq 0 ]]; then
|
|
31
|
+
echo "Warning: neither ss nor lsof available, cannot inspect port ${port}." >&2
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
echo "${pids}"
|
|
35
|
+
}
|
|
36
|
+
|
|
17
37
|
kill_port_if_listening() {
|
|
18
38
|
local pids
|
|
19
|
-
pids=$(
|
|
39
|
+
pids=$(list_port_pids "${DEPLOY_RUN_PORT}")
|
|
20
40
|
if [[ -z "${pids}" ]]; then
|
|
21
41
|
echo "Port ${DEPLOY_RUN_PORT} is free."
|
|
22
42
|
return
|
|
23
43
|
fi
|
|
24
44
|
echo "Port ${DEPLOY_RUN_PORT} in use by PIDs: ${pids} (SIGKILL)"
|
|
25
|
-
echo "${pids}" | xargs -I {} kill -9 {}
|
|
45
|
+
echo "${pids}" | xargs -I {} kill -9 {} || true
|
|
26
46
|
sleep 1
|
|
27
|
-
pids=$(
|
|
47
|
+
pids=$(list_port_pids "${DEPLOY_RUN_PORT}")
|
|
28
48
|
if [[ -n "${pids}" ]]; then
|
|
29
|
-
echo "
|
|
49
|
+
echo "端口 ${DEPLOY_RUN_PORT} 被 PID ${pids} 占用且无法清理(SIGKILL 后仍在监听),dev server 无法启动。" >&2
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
echo "Port ${DEPLOY_RUN_PORT} cleared."
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
<% if (process.env.NODE_ENV === 'test') { %>
|
|
56
|
+
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
57
|
+
kill_port_if_listening
|
|
58
|
+
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
59
|
+
|
|
60
|
+
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
61
|
+
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch src/server.ts
|
|
62
|
+
<% } else { %>
|
|
63
|
+
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
64
|
+
LOG_FILE="${LOG_DIR}/app.log"
|
|
65
|
+
PID_FILE="${LOG_DIR}/server.pid"
|
|
66
|
+
|
|
67
|
+
# detached 出去的进程没人负责回收,超过这个时长就自己退出,避免端口与内存长期泄露。
|
|
68
|
+
MAX_RUNTIME_SECONDS=1200
|
|
69
|
+
|
|
70
|
+
# 真正被 detach 的是这层 bash wrapper:它是进程组 leader,组内 watchdog 到点回收整组
|
|
71
|
+
# (wrapper -> pnpm -> tsx -> node);被包的进程自己先退出时也顺手清空进程组,不留残余。
|
|
72
|
+
RUN_WITH_TIMEOUT='
|
|
73
|
+
timeout_seconds=$1
|
|
74
|
+
shift
|
|
75
|
+
|
|
76
|
+
"$@" &
|
|
77
|
+
child_pid=$!
|
|
78
|
+
|
|
79
|
+
# 先忽略 TERM,才能在向整组发 TERM(自己也在组里)之后存活下来补一发 KILL。
|
|
80
|
+
( trap "" TERM
|
|
81
|
+
sleep "${timeout_seconds}"
|
|
82
|
+
echo "[dev] 后台进程运行超过 ${timeout_seconds}s,回收进程组 $$。"
|
|
83
|
+
kill -TERM -- "-$$" 2>/dev/null || true
|
|
84
|
+
sleep 5
|
|
85
|
+
kill -KILL -- "-$$" 2>/dev/null || true
|
|
86
|
+
) &
|
|
87
|
+
|
|
88
|
+
wait "${child_pid}"
|
|
89
|
+
kill -KILL -- "-$$" 2>/dev/null || true
|
|
90
|
+
'
|
|
91
|
+
|
|
92
|
+
# 返回的 PID 是 wrapper 的,同时也是整个进程组的 PGID,后续按组回收。
|
|
93
|
+
spawn_detached() {
|
|
94
|
+
local cwd="$1"
|
|
95
|
+
local log_file="$2"
|
|
96
|
+
shift 2
|
|
97
|
+
|
|
98
|
+
node - "$cwd" "$log_file" \
|
|
99
|
+
/bin/bash -c "${RUN_WITH_TIMEOUT}" detached-runner "${MAX_RUNTIME_SECONDS}" "$@" <<'NODE'
|
|
100
|
+
const fs = require('node:fs');
|
|
101
|
+
const { spawn } = require('node:child_process');
|
|
102
|
+
|
|
103
|
+
const [cwd, logFile, command, ...args] = process.argv.slice(2);
|
|
104
|
+
if (!cwd || !logFile || !command) {
|
|
105
|
+
throw new Error('spawn_detached 缺少 cwd、log_file 或 command');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const logFd = fs.openSync(logFile, 'a');
|
|
109
|
+
try {
|
|
110
|
+
const child = spawn(command, args, {
|
|
111
|
+
cwd,
|
|
112
|
+
detached: true,
|
|
113
|
+
env: process.env,
|
|
114
|
+
stdio: ['ignore', logFd, logFd],
|
|
115
|
+
});
|
|
116
|
+
child.unref();
|
|
117
|
+
process.stdout.write(String(child.pid));
|
|
118
|
+
} finally {
|
|
119
|
+
fs.closeSync(logFd);
|
|
120
|
+
}
|
|
121
|
+
NODE
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
stop_detached() {
|
|
125
|
+
local pid="${1:-}"
|
|
126
|
+
if [[ -z "${pid}" ]]; then
|
|
127
|
+
return
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
kill -TERM -- "-${pid}" 2>/dev/null || kill -TERM "${pid}" 2>/dev/null || true
|
|
131
|
+
sleep 1
|
|
132
|
+
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
READY_RETRIES=10
|
|
136
|
+
READY_PROBE_HOSTS=("127.0.0.1" "::1")
|
|
137
|
+
LOG_TAIL_LINES=40
|
|
138
|
+
|
|
139
|
+
dump_log() {
|
|
140
|
+
echo "---- tail -n ${LOG_TAIL_LINES} ${LOG_FILE} ----" >&2
|
|
141
|
+
tail -n "${LOG_TAIL_LINES}" "${LOG_FILE}" >&2 || true
|
|
142
|
+
echo "---- end of ${LOG_FILE} ----" >&2
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# 仅用于无 ss/lsof 时的兜底探测。服务可能只 bind IPv4 loopback、只 bind IPv6 loopback
|
|
146
|
+
# (server.listen(port, 'localhost') 会变成 ::1 独占),或 bind 双栈通配地址,
|
|
147
|
+
port_connectable() {
|
|
148
|
+
local port=$1
|
|
149
|
+
local host
|
|
150
|
+
for host in "${READY_PROBE_HOSTS[@]}"; do
|
|
151
|
+
if command -v nc >/dev/null 2>&1; then
|
|
152
|
+
if nc -z -w 1 "${host}" "${port}" >/dev/null 2>&1; then
|
|
153
|
+
return 0
|
|
154
|
+
fi
|
|
155
|
+
elif (exec 3<>"/dev/tcp/${host}/${port}") >/dev/null 2>&1; then
|
|
156
|
+
return 0
|
|
157
|
+
fi
|
|
158
|
+
done
|
|
159
|
+
return 1
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
port_probe_available() {
|
|
163
|
+
command -v ss >/dev/null 2>&1 || command -v lsof >/dev/null 2>&1
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
# 端口监听者是否属于本进程组:spawn detached 后 PID == PGID,子孙进程继承该 PGID。
|
|
167
|
+
# 0 = 是;1 = 不是(无人监听,或监听者不属于本进程组);2 = 无探测工具,无法判断
|
|
168
|
+
port_listened_by_pgid() {
|
|
169
|
+
local port=$1 pgid=$2
|
|
170
|
+
local listener owner
|
|
171
|
+
|
|
172
|
+
if ! port_probe_available; then
|
|
173
|
+
return 2
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
for listener in $(list_port_pids "${port}" 2>/dev/null); do
|
|
177
|
+
owner=$(ps -o pgid= -p "${listener}" 2>/dev/null | tr -d ' ')
|
|
178
|
+
if [[ "${owner}" == "${pgid}" ]]; then
|
|
179
|
+
return 0
|
|
180
|
+
fi
|
|
181
|
+
done
|
|
182
|
+
return 1
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
wait_for_ready() {
|
|
186
|
+
local pid=$1 port=$2
|
|
187
|
+
local attempt=0 owned
|
|
188
|
+
|
|
189
|
+
if ! port_probe_available; then
|
|
190
|
+
echo "Warning: 缺少 ss 与 lsof,无法确认端口监听者归属,仅按 loopback 可连接性判断就绪。" >&2
|
|
191
|
+
fi
|
|
192
|
+
|
|
193
|
+
while [[ "${attempt}" -lt "${READY_RETRIES}" ]]; do
|
|
194
|
+
if ! kill -0 "${pid}" 2>/dev/null; then
|
|
195
|
+
echo "Dev server 进程在启动过程中退出。" >&2
|
|
196
|
+
return 1
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
if port_listened_by_pgid "${port}" "${pid}"; then
|
|
200
|
+
owned=0
|
|
30
201
|
else
|
|
31
|
-
|
|
202
|
+
owned=$?
|
|
32
203
|
fi
|
|
204
|
+
if [[ "${owned}" -eq 0 ]]; then
|
|
205
|
+
return 0
|
|
206
|
+
fi
|
|
207
|
+
if [[ "${owned}" -eq 2 ]] && port_connectable "${port}"; then
|
|
208
|
+
return 0
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
sleep 1
|
|
212
|
+
attempt=$((attempt + 1))
|
|
213
|
+
done
|
|
214
|
+
|
|
215
|
+
return 2
|
|
33
216
|
}
|
|
34
217
|
|
|
218
|
+
# 监听端口的是孙进程(pnpm -> tsx -> node),只清端口会漏掉上层 pnpm/tsx,
|
|
219
|
+
# 所以先按上次记录的 PID 把整个进程组回收掉。
|
|
220
|
+
if [[ -f "${PID_FILE}" ]]; then
|
|
221
|
+
stop_detached "$(cat "${PID_FILE}" 2>/dev/null || true)"
|
|
222
|
+
rm -f "${PID_FILE}"
|
|
223
|
+
fi
|
|
224
|
+
|
|
35
225
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
36
226
|
kill_port_if_listening
|
|
37
227
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
38
228
|
|
|
39
|
-
|
|
229
|
+
mkdir -p "${LOG_DIR}"
|
|
230
|
+
: > "${LOG_FILE}"
|
|
231
|
+
|
|
232
|
+
export PORT="${DEPLOY_RUN_PORT}"
|
|
233
|
+
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
234
|
+
"$(command -v pnpm)" tsx watch src/server.ts)"
|
|
235
|
+
if [[ -z "${server_pid}" ]]; then
|
|
236
|
+
echo "Dev server failed to start: 未获取到后台进程 PID。" >&2
|
|
237
|
+
dump_log
|
|
238
|
+
exit 1
|
|
239
|
+
fi
|
|
240
|
+
echo "${server_pid}" > "${PID_FILE}"
|
|
241
|
+
|
|
242
|
+
if wait_for_ready "${server_pid}" "${DEPLOY_RUN_PORT}"; then
|
|
243
|
+
ready_status=0
|
|
244
|
+
else
|
|
245
|
+
ready_status=$?
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
if [[ "${ready_status}" -ne 0 ]]; then
|
|
249
|
+
if [[ "${ready_status}" -eq 2 ]]; then
|
|
250
|
+
# 进程还活着但迟迟没监听端口:多半是编译/运行时报错后 tsx watch 驻留,日志里有真正原因。
|
|
251
|
+
echo "Dev server 在 ${READY_RETRIES} 次探测(每次 1s)内未就绪于端口 ${DEPLOY_RUN_PORT}(进程 ${server_pid} 仍在运行,已回收)。" >&2
|
|
252
|
+
else
|
|
253
|
+
echo "Dev server failed to start. See ${LOG_FILE}." >&2
|
|
254
|
+
fi
|
|
255
|
+
# 先 dump 再回收,避免 kill 的输出混进日志尾部;exit 1 意味着不留下任何后台进程。
|
|
256
|
+
dump_log
|
|
257
|
+
stop_detached "${server_pid}"
|
|
258
|
+
rm -f "${PID_FILE}"
|
|
259
|
+
exit 1
|
|
260
|
+
fi
|
|
261
|
+
|
|
262
|
+
echo "Dev server started (PID: ${server_pid}), listening on port ${DEPLOY_RUN_PORT}."
|
|
263
|
+
echo "Auto stop after ${MAX_RUNTIME_SECONDS}s."
|
|
264
|
+
echo "Log file: ${LOG_FILE}"
|
|
265
|
+
echo "PID file: ${PID_FILE}"
|
|
266
|
+
<% } %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
|
|
3
|
+
$workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
|
|
4
|
+
Set-Location $workspace
|
|
5
|
+
|
|
6
|
+
Write-Host "Installing dependencies..."
|
|
7
|
+
& pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
8
|
+
if ($LASTEXITCODE -ne 0) {
|
|
9
|
+
exit $LASTEXITCODE
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (Get-Command coze-dev -ErrorAction SilentlyContinue) {
|
|
13
|
+
& coze-dev check-bins --help *> $null
|
|
14
|
+
if ($LASTEXITCODE -eq 0) {
|
|
15
|
+
& coze-dev check-bins --fix
|
|
16
|
+
exit $LASTEXITCODE
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
|
|
3
|
+
$workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
|
|
4
|
+
$defaultPort = <%= port %>
|
|
5
|
+
$port = if ($env:DEPLOY_RUN_PORT) { $env:DEPLOY_RUN_PORT } elseif ($env:PORT) { $env:PORT } else { $defaultPort }
|
|
6
|
+
Set-Location $workspace
|
|
7
|
+
|
|
8
|
+
Write-Host "Starting HTTP service on port $port for deploy..."
|
|
9
|
+
$env:PORT = "$port"
|
|
10
|
+
& node dist/server.js
|
|
11
|
+
exit $LASTEXITCODE
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { spawn } from 'child_process';
|
|
4
4
|
import { resolve, join, basename } from 'path';
|
|
5
5
|
import { appendFileSync, openSync, closeSync, mkdirSync } from 'fs';
|
|
6
|
+
import { homedir } from 'os';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -65,7 +66,7 @@ const config = {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
const cmd = 'pnpm';
|
|
68
|
-
const args = ['update', 'coze-coding-dev-sdk@^0.7.
|
|
69
|
+
const args = ['update', 'coze-coding-dev-sdk@^0.7.25'];
|
|
69
70
|
console.log(
|
|
70
71
|
`\nTriggering: ${cmd} ${args.join(' ')} (running in background)`,
|
|
71
72
|
);
|
|
@@ -74,7 +75,8 @@ const config = {
|
|
|
74
75
|
const projectRoot = resolve(outputPath);
|
|
75
76
|
|
|
76
77
|
// Determine log directory
|
|
77
|
-
const
|
|
78
|
+
const cozeHome = process.env.COZE_HOME || join(homedir(), '.coze');
|
|
79
|
+
const logDir = process.env.COZE_LOG_DIR || join(cozeHome, 'logs');
|
|
78
80
|
mkdirSync(logDir, { recursive: true });
|
|
79
81
|
|
|
80
82
|
// Use project name in log file to avoid conflicts
|