@coze-arch/cli 0.1.4-alpha.5377b5 → 0.1.4-alpha.703f82
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/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/expo/client/components/Screen.tsx +65 -25
- package/lib/__templates__/expo/client/heroui/components/toast/toast.tsx +6 -2
- package/lib/__templates__/expo/client/heroui/helpers/internal/hooks/use-controllable-state.ts +1 -1
- package/lib/__templates__/nextjs/eslint.config.mjs +11 -5
- package/lib/__templates__/nextjs/next.config.ts +9 -0
- package/lib/__templates__/nextjs/package.json +1 -4
- package/lib/__templates__/nextjs/pnpm-lock.yaml +0 -931
- package/lib/__templates__/nextjs/scripts/build.sh +1 -0
- package/lib/__templates__/nextjs/scripts/dev.ps1 +2 -2
- package/lib/__templates__/nextjs/scripts/dev.sh +19 -5
- package/lib/__templates__/nextjs/scripts/prepare-next-output.sh +62 -0
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/nextjs/src/app/layout.tsx +0 -4
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +4 -4
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +4 -4
- package/lib/cli.js +1 -1
- package/package.json +1 -1
- package/lib/__templates__/nextjs/.babelrc +0 -15
|
@@ -7,6 +7,7 @@ cd "${COZE_WORKSPACE_PATH}"
|
|
|
7
7
|
|
|
8
8
|
echo "Installing dependencies..."
|
|
9
9
|
bash "$COZE_WORKSPACE_PATH/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
10
|
+
bash "$COZE_WORKSPACE_PATH/scripts/prepare-next-output.sh"
|
|
10
11
|
|
|
11
12
|
echo "Building the Next.js project..."
|
|
12
13
|
pnpm next build --webpack
|
|
@@ -28,7 +28,7 @@ Stop-ListeningProcess $port
|
|
|
28
28
|
|
|
29
29
|
<% if (process.env.NODE_ENV === 'test') { %>
|
|
30
30
|
$env:PORT = "$port"
|
|
31
|
-
& pnpm tsx watch src/server.ts
|
|
31
|
+
& pnpm tsx watch --ignore .next src/server.ts
|
|
32
32
|
exit $LASTEXITCODE
|
|
33
33
|
<% } else { %>
|
|
34
34
|
$logDirectory = if ($env:COZE_LOG_DIR) { $env:COZE_LOG_DIR } else { Join-Path $workspace "logs" }
|
|
@@ -45,7 +45,7 @@ if (Test-Path $pidFile) {
|
|
|
45
45
|
$previousPort = $env:PORT
|
|
46
46
|
$env:PORT = "$port"
|
|
47
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
|
|
48
|
+
$process = Start-Process -FilePath $env:ComSpec -ArgumentList @("/d", "/s", "/c", "pnpm tsx watch --ignore .next src/server.ts") -WorkingDirectory $workspace -RedirectStandardOutput $logFile -RedirectStandardError $errorLogFile -PassThru
|
|
49
49
|
} finally {
|
|
50
50
|
if ($null -eq $previousPort) { Remove-Item Env:PORT -ErrorAction SilentlyContinue } else { $env:PORT = $previousPort }
|
|
51
51
|
}
|
|
@@ -52,13 +52,25 @@ kill_port_if_listening() {
|
|
|
52
52
|
echo "Port ${DEPLOY_RUN_PORT} cleared."
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
resolve_next_output_dir() {
|
|
56
|
+
local output_dir="${COZE_WORKSPACE_PATH}/.next"
|
|
57
|
+
if [[ -d "${output_dir}" ]]; then
|
|
58
|
+
(cd "${output_dir}" && pwd -P)
|
|
59
|
+
else
|
|
60
|
+
printf '%s\n' "${output_dir}"
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
<% if (process.env.NODE_ENV === 'test') { %>
|
|
56
65
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
57
66
|
kill_port_if_listening
|
|
67
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-next-output.sh"
|
|
68
|
+
NEXT_OUTPUT_DIR="$(resolve_next_output_dir)"
|
|
58
69
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
59
70
|
|
|
60
71
|
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
61
|
-
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch
|
|
72
|
+
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch \
|
|
73
|
+
--ignore .next --ignore "${NEXT_OUTPUT_DIR}" src/server.ts
|
|
62
74
|
<% } else { %>
|
|
63
75
|
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
64
76
|
LOG_FILE="${LOG_DIR}/app.log"
|
|
@@ -134,7 +146,7 @@ stop_detached() {
|
|
|
134
146
|
kill -KILL -- "-${pid}" 2>/dev/null || true
|
|
135
147
|
}
|
|
136
148
|
|
|
137
|
-
READY_RETRIES=
|
|
149
|
+
READY_RETRIES=30
|
|
138
150
|
READY_PROBE_HOSTS=("127.0.0.1" "::1")
|
|
139
151
|
LOG_TAIL_LINES=40
|
|
140
152
|
|
|
@@ -226,6 +238,8 @@ fi
|
|
|
226
238
|
|
|
227
239
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
228
240
|
kill_port_if_listening
|
|
241
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-next-output.sh"
|
|
242
|
+
NEXT_OUTPUT_DIR="$(resolve_next_output_dir)"
|
|
229
243
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
230
244
|
|
|
231
245
|
mkdir -p "${LOG_DIR}"
|
|
@@ -233,7 +247,8 @@ mkdir -p "${LOG_DIR}"
|
|
|
233
247
|
|
|
234
248
|
export PORT="${DEPLOY_RUN_PORT}"
|
|
235
249
|
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
236
|
-
"$(command -v pnpm)" tsx watch
|
|
250
|
+
"$(command -v pnpm)" tsx watch \
|
|
251
|
+
--ignore .next --ignore "${NEXT_OUTPUT_DIR}" src/server.ts)"
|
|
237
252
|
if [[ -z "${server_pid}" ]]; then
|
|
238
253
|
echo "Dev server failed to start: 未获取到后台进程 PID。" >&2
|
|
239
254
|
dump_log
|
|
@@ -249,8 +264,7 @@ fi
|
|
|
249
264
|
|
|
250
265
|
if [[ "${ready_status}" -ne 0 ]]; then
|
|
251
266
|
if [[ "${ready_status}" -eq 2 ]]; then
|
|
252
|
-
|
|
253
|
-
echo "Dev server 在 ${READY_RETRIES} 次探测(每次 1s)内未就绪于端口 ${DEPLOY_RUN_PORT}(进程 ${server_pid} 仍在运行,已回收)。" >&2
|
|
267
|
+
echo "Dev server did not listen on port ${DEPLOY_RUN_PORT} after ${READY_RETRIES} attempts; stopping PID ${server_pid}." >&2
|
|
254
268
|
else
|
|
255
269
|
echo "Dev server failed to start. See ${LOG_FILE}." >&2
|
|
256
270
|
fi
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Keep Next.js compiler output off Coze Drive while leaving source files in place.
|
|
3
|
+
set -euo pipefail
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
6
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
|
|
7
|
+
|
|
8
|
+
DRIVE_ROOT="${COZE_DRIVE_ROOT:-/Coze/Drive}"
|
|
9
|
+
if [ -d "$DRIVE_ROOT" ]; then
|
|
10
|
+
DRIVE_ROOT="$(cd "$DRIVE_ROOT" && pwd -P)"
|
|
11
|
+
else
|
|
12
|
+
DRIVE_ROOT="${DRIVE_ROOT%/}"
|
|
13
|
+
fi
|
|
14
|
+
case "$PROJECT_ROOT" in
|
|
15
|
+
"$DRIVE_ROOT"|"$DRIVE_ROOT"/*) ;;
|
|
16
|
+
*) exit 0 ;;
|
|
17
|
+
esac
|
|
18
|
+
|
|
19
|
+
NM_ROOT="/tmp/nm"
|
|
20
|
+
PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
|
|
21
|
+
NEXT_DIR="$NM_ROOT/$PROJECT_ID/.next"
|
|
22
|
+
LEGACY_NEXT_DIR="$NM_ROOT/next/$PROJECT_ID"
|
|
23
|
+
|
|
24
|
+
if [ -L "$NEXT_DIR" ]; then
|
|
25
|
+
current="$(readlink "$NEXT_DIR")"
|
|
26
|
+
if [ "$current" = "$PROJECT_ROOT/.next" ]; then
|
|
27
|
+
rm "$NEXT_DIR"
|
|
28
|
+
else
|
|
29
|
+
echo "[next] refusing to replace unmanaged local output symlink: $NEXT_DIR" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
elif [ -e "$NEXT_DIR" ] && [ ! -d "$NEXT_DIR" ]; then
|
|
33
|
+
echo "[next] local output path is not a directory: $NEXT_DIR" >&2
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
mkdir -p "$NEXT_DIR"
|
|
37
|
+
|
|
38
|
+
if [ -L "$PROJECT_ROOT/.next" ]; then
|
|
39
|
+
current="$(readlink "$PROJECT_ROOT/.next")"
|
|
40
|
+
if [ "$current" = "$NEXT_DIR" ]; then
|
|
41
|
+
exit 0
|
|
42
|
+
fi
|
|
43
|
+
if [ "$current" = "$LEGACY_NEXT_DIR" ]; then
|
|
44
|
+
rm "$PROJECT_ROOT/.next"
|
|
45
|
+
else
|
|
46
|
+
echo "[next] refusing to replace unmanaged symlink: $PROJECT_ROOT/.next" >&2
|
|
47
|
+
exit 1
|
|
48
|
+
fi
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
if [ -e "$PROJECT_ROOT/.next" ]; then
|
|
52
|
+
rm -rf "$PROJECT_ROOT/.next"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
if ! ln -s "$NEXT_DIR" "$PROJECT_ROOT/.next"; then
|
|
56
|
+
if [ ! -L "$PROJECT_ROOT/.next" ] || [ "$(readlink "$PROJECT_ROOT/.next")" != "$NEXT_DIR" ]; then
|
|
57
|
+
echo "[next] failed to link $PROJECT_ROOT/.next to $NEXT_DIR" >&2
|
|
58
|
+
exit 1
|
|
59
|
+
fi
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
echo "[next] Compiler output ready at $NEXT_DIR"
|
|
@@ -48,14 +48,14 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
# Mirror the project with symlinks. node_modules
|
|
52
|
-
#
|
|
51
|
+
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
+
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
53
|
mirror_root() {
|
|
54
54
|
local entry name
|
|
55
55
|
while IFS= read -r -d '' entry; do
|
|
56
56
|
name="$(basename "$entry")"
|
|
57
57
|
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
58
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
59
|
client|server)
|
|
60
60
|
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
61
|
;;
|
|
@@ -66,7 +66,7 @@ mirror_root() {
|
|
|
66
66
|
while IFS= read -r -d '' entry; do
|
|
67
67
|
name="$(basename "$entry")"
|
|
68
68
|
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
69
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
70
|
client|server)
|
|
71
71
|
[ -f "$entry/package.json" ] && continue
|
|
72
72
|
;;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Metadata } from 'next';
|
|
2
|
-
import { Inspector } from 'react-dev-inspector';
|
|
3
2
|
import './globals.css';
|
|
4
3
|
|
|
5
4
|
export const metadata: Metadata = {
|
|
@@ -61,12 +60,9 @@ export default function RootLayout({
|
|
|
61
60
|
}: Readonly<{
|
|
62
61
|
children: React.ReactNode;
|
|
63
62
|
}>) {
|
|
64
|
-
const isDev = process.env.COZE_PROJECT_ENV === 'DEV';
|
|
65
|
-
|
|
66
63
|
return (
|
|
67
64
|
<html lang="en">
|
|
68
65
|
<body className={`antialiased`}>
|
|
69
|
-
{isDev && <Inspector />}
|
|
70
66
|
{children}
|
|
71
67
|
</body>
|
|
72
68
|
</html>
|
|
@@ -48,14 +48,14 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
# Mirror the project with symlinks. node_modules
|
|
52
|
-
#
|
|
51
|
+
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
+
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
53
|
mirror_root() {
|
|
54
54
|
local entry name
|
|
55
55
|
while IFS= read -r -d '' entry; do
|
|
56
56
|
name="$(basename "$entry")"
|
|
57
57
|
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
58
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
59
|
client|server)
|
|
60
60
|
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
61
|
;;
|
|
@@ -66,7 +66,7 @@ mirror_root() {
|
|
|
66
66
|
while IFS= read -r -d '' entry; do
|
|
67
67
|
name="$(basename "$entry")"
|
|
68
68
|
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
69
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
70
|
client|server)
|
|
71
71
|
[ -f "$entry/package.json" ] && continue
|
|
72
72
|
;;
|
|
@@ -48,14 +48,14 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
# Mirror the project with symlinks. node_modules
|
|
52
|
-
#
|
|
51
|
+
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
+
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
53
|
mirror_root() {
|
|
54
54
|
local entry name
|
|
55
55
|
while IFS= read -r -d '' entry; do
|
|
56
56
|
name="$(basename "$entry")"
|
|
57
57
|
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
58
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
59
|
client|server)
|
|
60
60
|
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
61
|
;;
|
|
@@ -66,7 +66,7 @@ mirror_root() {
|
|
|
66
66
|
while IFS= read -r -d '' entry; do
|
|
67
67
|
name="$(basename "$entry")"
|
|
68
68
|
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
69
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
70
|
client|server)
|
|
71
71
|
[ -f "$entry/package.json" ] && continue
|
|
72
72
|
;;
|
|
@@ -48,14 +48,14 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
# Mirror the project with symlinks. node_modules
|
|
52
|
-
#
|
|
51
|
+
# Mirror the project with symlinks. node_modules and managed compiler output
|
|
52
|
+
# stay real in WORK_DIR; workspace directories stay real there too.
|
|
53
53
|
mirror_root() {
|
|
54
54
|
local entry name
|
|
55
55
|
while IFS= read -r -d '' entry; do
|
|
56
56
|
name="$(basename "$entry")"
|
|
57
57
|
case "$name" in
|
|
58
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
58
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
59
59
|
client|server)
|
|
60
60
|
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
61
|
;;
|
|
@@ -66,7 +66,7 @@ mirror_root() {
|
|
|
66
66
|
while IFS= read -r -d '' entry; do
|
|
67
67
|
name="$(basename "$entry")"
|
|
68
68
|
case "$name" in
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
69
|
+
node_modules|pnpm-lock.yaml|.next) continue ;;
|
|
70
70
|
client|server)
|
|
71
71
|
[ -f "$entry/package.json" ] && continue
|
|
72
72
|
;;
|
package/lib/cli.js
CHANGED
|
@@ -2114,7 +2114,7 @@ const EventBuilder = {
|
|
|
2114
2114
|
};
|
|
2115
2115
|
|
|
2116
2116
|
var name = "@coze-arch/cli";
|
|
2117
|
-
var version = "0.1.4-alpha.
|
|
2117
|
+
var version = "0.1.4-alpha.703f82";
|
|
2118
2118
|
var description = "coze coding devtools cli";
|
|
2119
2119
|
var license = "MIT";
|
|
2120
2120
|
var author = "fanwenjie.fe@bytedance.com";
|
package/package.json
CHANGED