@coze-arch/cli 0.1.4-alpha.170425 → 0.1.4-alpha.3f9b02
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 +59 -59
- 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 -1
- 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 +6 -2
- package/lib/__templates__/nextjs/scripts/prepare-next-output.sh +72 -0
- package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +59 -59
- package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +59 -59
- package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +59 -59
- package/lib/__templates__/vite/scripts/prepare-node-modules.sh +59 -59
- package/lib/cli.js +1 -1
- package/package.json +1 -1
|
@@ -48,77 +48,62 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
51
|
+
# Previous versions mirrored the whole project into WORK_DIR. That gives pnpm
|
|
52
|
+
# and framework dev servers two paths for the same source tree, which breaks
|
|
53
|
+
# file watching and on-demand compilation. Keep only managed local outputs.
|
|
54
|
+
cleanup_legacy_workspace() {
|
|
55
|
+
local workspace_dir="$1" entry name
|
|
56
|
+
if [ -L "$workspace_dir" ] || { [ -e "$workspace_dir" ] && [ ! -d "$workspace_dir" ]; }; then
|
|
57
|
+
rm -rf "$workspace_dir"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -d "$workspace_dir" ]; then
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
while IFS= read -r -d '' entry; do
|
|
65
|
+
name="$(basename "$entry")"
|
|
66
|
+
[ "$name" = "node_modules" ] || rm -rf "$entry"
|
|
67
|
+
done < <(find "$workspace_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cleanup_legacy_shadow_project() {
|
|
54
71
|
local entry name
|
|
55
72
|
while IFS= read -r -d '' entry; do
|
|
56
73
|
name="$(basename "$entry")"
|
|
57
74
|
case "$name" in
|
|
58
|
-
node_modules|
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
75
|
+
node_modules|.next|client|server) continue ;;
|
|
62
76
|
esac
|
|
63
77
|
rm -rf "$entry"
|
|
64
78
|
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
80
|
+
for workspace in client server; do
|
|
81
|
+
cleanup_legacy_workspace "$WORK_DIR/$workspace"
|
|
82
|
+
done
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
copy_install_metadata() {
|
|
86
|
+
local filename source_file target_file workspace
|
|
87
|
+
for filename in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
88
|
+
source_file="$PROJECT_ROOT/$filename"
|
|
89
|
+
target_file="$WORK_DIR/$filename"
|
|
90
|
+
rm -f "$target_file"
|
|
91
|
+
if [ -f "$source_file" ]; then
|
|
92
|
+
cp "$source_file" "$target_file"
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
for workspace in client server; do
|
|
97
|
+
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
98
|
+
mkdir -p "$WORK_DIR/$workspace"
|
|
99
|
+
rm -f "$WORK_DIR/$workspace/package.json"
|
|
100
|
+
cp "$PROJECT_ROOT/$workspace/package.json" "$WORK_DIR/$workspace/package.json"
|
|
101
|
+
else
|
|
102
|
+
rm -rf "$WORK_DIR/$workspace"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
107
|
link_node_modules() {
|
|
123
108
|
local source_dir="$1" target_dir="$2"
|
|
124
109
|
local current=""
|
|
@@ -139,6 +124,21 @@ link_node_modules() {
|
|
|
139
124
|
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
125
|
}
|
|
141
126
|
|
|
127
|
+
cleanup_legacy_shadow_project
|
|
128
|
+
copy_install_metadata
|
|
129
|
+
|
|
130
|
+
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
131
|
+
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
136
|
+
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
137
|
+
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
138
|
+
chmod 0644 "$temporary_lockfile"
|
|
139
|
+
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
142
|
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
143
|
for workspace in client server; do
|
|
144
144
|
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
@@ -23,6 +23,11 @@ const eslintConfig = defineConfig([
|
|
|
23
23
|
...nextVitals,
|
|
24
24
|
...nextTs,
|
|
25
25
|
{
|
|
26
|
+
settings: {
|
|
27
|
+
// node_modules 里的 barrel 包(lucide-react 等)不参与 ExportMap 构建,
|
|
28
|
+
// import/no-cycle 只需要项目源码的依赖图。
|
|
29
|
+
'import/ignore': ['/node_modules/'],
|
|
30
|
+
},
|
|
26
31
|
rules: {
|
|
27
32
|
'import/no-cycle': ['error', { ignoreExternal: true }],
|
|
28
33
|
'react-hooks/set-state-in-effect': 'off',
|
|
@@ -37,14 +42,15 @@ const eslintConfig = defineConfig([
|
|
|
37
42
|
},
|
|
38
43
|
// Override default ignores of eslint-config-next.
|
|
39
44
|
globalIgnores([
|
|
40
|
-
// Default ignores of eslint-config-next
|
|
41
|
-
|
|
42
|
-
'
|
|
43
|
-
'
|
|
45
|
+
// Default ignores of eslint-config-next (trailing slash prunes the whole
|
|
46
|
+
// directory instead of walking into it):
|
|
47
|
+
'.next/',
|
|
48
|
+
'out/',
|
|
49
|
+
'build/',
|
|
44
50
|
'next-env.d.ts',
|
|
45
51
|
// Build artifacts:
|
|
46
52
|
'server.js',
|
|
47
|
-
'dist
|
|
53
|
+
'dist/',
|
|
48
54
|
// Script files (CommonJS):
|
|
49
55
|
'scripts/**/*.js',
|
|
50
56
|
]),
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
+
import path from 'path';
|
|
2
3
|
|
|
3
4
|
const nextConfig: NextConfig = {
|
|
4
5
|
// outputFileTracingRoot: path.resolve(__dirname, '../../'), // Uncomment and add 'import path from "path"' if needed
|
|
5
6
|
/* config options here */
|
|
6
7
|
serverExternalPackages: ['coze-coding-dev-sdk'],
|
|
8
|
+
webpack: (config, { dev }) => {
|
|
9
|
+
if (dev && config.cache && config.cache.type === 'filesystem') {
|
|
10
|
+
config.cache.cacheDirectory = path.resolve(
|
|
11
|
+
'node_modules/.cache/next-webpack',
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
return config;
|
|
15
|
+
},
|
|
7
16
|
allowedDevOrigins: ['*.dev.coze.site'],
|
|
8
17
|
images: {
|
|
9
18
|
remotePatterns: [
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"build": "bash ./scripts/build.sh",
|
|
7
7
|
"dev": "bash ./scripts/dev.sh",
|
|
8
8
|
"preinstall": "npx only-allow pnpm",
|
|
9
|
-
"lint": "eslint",
|
|
9
|
+
"lint": "eslint --cache --cache-location node_modules/.cache/eslint/",
|
|
10
10
|
"lint:build": "eslint . --quiet",
|
|
11
11
|
"lint:style": "stylelint \"src/**/*.css\"",
|
|
12
12
|
"start": "bash ./scripts/start.sh",
|
|
@@ -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
|
}
|
|
@@ -55,10 +55,12 @@ kill_port_if_listening() {
|
|
|
55
55
|
<% if (process.env.NODE_ENV === 'test') { %>
|
|
56
56
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
57
57
|
kill_port_if_listening
|
|
58
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
59
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-next-output.sh"
|
|
58
60
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
59
61
|
|
|
60
62
|
# 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
|
|
61
|
-
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx
|
|
63
|
+
exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx src/server.ts
|
|
62
64
|
<% } else { %>
|
|
63
65
|
LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
|
|
64
66
|
LOG_FILE="${LOG_DIR}/app.log"
|
|
@@ -226,6 +228,8 @@ fi
|
|
|
226
228
|
|
|
227
229
|
echo "Clearing port ${DEPLOY_RUN_PORT} before start."
|
|
228
230
|
kill_port_if_listening
|
|
231
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
|
|
232
|
+
bash "${COZE_WORKSPACE_PATH}/scripts/prepare-next-output.sh"
|
|
229
233
|
echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
|
|
230
234
|
|
|
231
235
|
mkdir -p "${LOG_DIR}"
|
|
@@ -233,7 +237,7 @@ mkdir -p "${LOG_DIR}"
|
|
|
233
237
|
|
|
234
238
|
export PORT="${DEPLOY_RUN_PORT}"
|
|
235
239
|
server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
|
|
236
|
-
"$(command -v pnpm)" tsx
|
|
240
|
+
"$(command -v pnpm)" tsx src/server.ts)"
|
|
237
241
|
if [[ -z "${server_pid}" ]]; then
|
|
238
242
|
echo "Dev server failed to start: 未获取到后台进程 PID。" >&2
|
|
239
243
|
dump_log
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
NEXT_LAYOUT_FILE="$NEXT_DIR/.coze-layout"
|
|
23
|
+
NEXT_LAYOUT_VERSION="real-source-v1"
|
|
24
|
+
LEGACY_NEXT_DIR="$NM_ROOT/next/$PROJECT_ID"
|
|
25
|
+
|
|
26
|
+
if [ -L "$NEXT_DIR" ]; then
|
|
27
|
+
current="$(readlink "$NEXT_DIR")"
|
|
28
|
+
if [ "$current" = "$PROJECT_ROOT/.next" ]; then
|
|
29
|
+
rm "$NEXT_DIR"
|
|
30
|
+
else
|
|
31
|
+
echo "[next] refusing to replace unmanaged local output symlink: $NEXT_DIR" >&2
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
elif [ -e "$NEXT_DIR" ] && [ ! -d "$NEXT_DIR" ]; then
|
|
35
|
+
echo "[next] local output path is not a directory: $NEXT_DIR" >&2
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
mkdir -p "$NEXT_DIR"
|
|
39
|
+
|
|
40
|
+
# The previous shadow-project layout compiled routes from a different source
|
|
41
|
+
# root. Drop that local output once, then retain the real-source cache.
|
|
42
|
+
if ! grep -qxF "$NEXT_LAYOUT_VERSION" "$NEXT_LAYOUT_FILE" 2>/dev/null; then
|
|
43
|
+
rm -rf "$NEXT_DIR"
|
|
44
|
+
mkdir -p "$NEXT_DIR"
|
|
45
|
+
printf '%s\n' "$NEXT_LAYOUT_VERSION" > "$NEXT_LAYOUT_FILE"
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ -L "$PROJECT_ROOT/.next" ]; then
|
|
49
|
+
current="$(readlink "$PROJECT_ROOT/.next")"
|
|
50
|
+
if [ "$current" = "$NEXT_DIR" ]; then
|
|
51
|
+
exit 0
|
|
52
|
+
fi
|
|
53
|
+
if [ "$current" = "$LEGACY_NEXT_DIR" ]; then
|
|
54
|
+
rm "$PROJECT_ROOT/.next"
|
|
55
|
+
else
|
|
56
|
+
echo "[next] refusing to replace unmanaged symlink: $PROJECT_ROOT/.next" >&2
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
fi
|
|
60
|
+
|
|
61
|
+
if [ -e "$PROJECT_ROOT/.next" ]; then
|
|
62
|
+
rm -rf "$PROJECT_ROOT/.next"
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
if ! ln -s "$NEXT_DIR" "$PROJECT_ROOT/.next"; then
|
|
66
|
+
if [ ! -L "$PROJECT_ROOT/.next" ] || [ "$(readlink "$PROJECT_ROOT/.next")" != "$NEXT_DIR" ]; then
|
|
67
|
+
echo "[next] failed to link $PROJECT_ROOT/.next to $NEXT_DIR" >&2
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
echo "[next] Compiler output ready at $NEXT_DIR"
|
|
@@ -48,77 +48,62 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
51
|
+
# Previous versions mirrored the whole project into WORK_DIR. That gives pnpm
|
|
52
|
+
# and framework dev servers two paths for the same source tree, which breaks
|
|
53
|
+
# file watching and on-demand compilation. Keep only managed local outputs.
|
|
54
|
+
cleanup_legacy_workspace() {
|
|
55
|
+
local workspace_dir="$1" entry name
|
|
56
|
+
if [ -L "$workspace_dir" ] || { [ -e "$workspace_dir" ] && [ ! -d "$workspace_dir" ]; }; then
|
|
57
|
+
rm -rf "$workspace_dir"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -d "$workspace_dir" ]; then
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
while IFS= read -r -d '' entry; do
|
|
65
|
+
name="$(basename "$entry")"
|
|
66
|
+
[ "$name" = "node_modules" ] || rm -rf "$entry"
|
|
67
|
+
done < <(find "$workspace_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cleanup_legacy_shadow_project() {
|
|
54
71
|
local entry name
|
|
55
72
|
while IFS= read -r -d '' entry; do
|
|
56
73
|
name="$(basename "$entry")"
|
|
57
74
|
case "$name" in
|
|
58
|
-
node_modules|
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
75
|
+
node_modules|.next|client|server) continue ;;
|
|
62
76
|
esac
|
|
63
77
|
rm -rf "$entry"
|
|
64
78
|
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
80
|
+
for workspace in client server; do
|
|
81
|
+
cleanup_legacy_workspace "$WORK_DIR/$workspace"
|
|
82
|
+
done
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
copy_install_metadata() {
|
|
86
|
+
local filename source_file target_file workspace
|
|
87
|
+
for filename in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
88
|
+
source_file="$PROJECT_ROOT/$filename"
|
|
89
|
+
target_file="$WORK_DIR/$filename"
|
|
90
|
+
rm -f "$target_file"
|
|
91
|
+
if [ -f "$source_file" ]; then
|
|
92
|
+
cp "$source_file" "$target_file"
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
for workspace in client server; do
|
|
97
|
+
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
98
|
+
mkdir -p "$WORK_DIR/$workspace"
|
|
99
|
+
rm -f "$WORK_DIR/$workspace/package.json"
|
|
100
|
+
cp "$PROJECT_ROOT/$workspace/package.json" "$WORK_DIR/$workspace/package.json"
|
|
101
|
+
else
|
|
102
|
+
rm -rf "$WORK_DIR/$workspace"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
107
|
link_node_modules() {
|
|
123
108
|
local source_dir="$1" target_dir="$2"
|
|
124
109
|
local current=""
|
|
@@ -139,6 +124,21 @@ link_node_modules() {
|
|
|
139
124
|
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
125
|
}
|
|
141
126
|
|
|
127
|
+
cleanup_legacy_shadow_project
|
|
128
|
+
copy_install_metadata
|
|
129
|
+
|
|
130
|
+
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
131
|
+
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
136
|
+
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
137
|
+
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
138
|
+
chmod 0644 "$temporary_lockfile"
|
|
139
|
+
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
142
|
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
143
|
for workspace in client server; do
|
|
144
144
|
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
@@ -48,77 +48,62 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
51
|
+
# Previous versions mirrored the whole project into WORK_DIR. That gives pnpm
|
|
52
|
+
# and framework dev servers two paths for the same source tree, which breaks
|
|
53
|
+
# file watching and on-demand compilation. Keep only managed local outputs.
|
|
54
|
+
cleanup_legacy_workspace() {
|
|
55
|
+
local workspace_dir="$1" entry name
|
|
56
|
+
if [ -L "$workspace_dir" ] || { [ -e "$workspace_dir" ] && [ ! -d "$workspace_dir" ]; }; then
|
|
57
|
+
rm -rf "$workspace_dir"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -d "$workspace_dir" ]; then
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
while IFS= read -r -d '' entry; do
|
|
65
|
+
name="$(basename "$entry")"
|
|
66
|
+
[ "$name" = "node_modules" ] || rm -rf "$entry"
|
|
67
|
+
done < <(find "$workspace_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cleanup_legacy_shadow_project() {
|
|
54
71
|
local entry name
|
|
55
72
|
while IFS= read -r -d '' entry; do
|
|
56
73
|
name="$(basename "$entry")"
|
|
57
74
|
case "$name" in
|
|
58
|
-
node_modules|
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
75
|
+
node_modules|.next|client|server) continue ;;
|
|
62
76
|
esac
|
|
63
77
|
rm -rf "$entry"
|
|
64
78
|
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
80
|
+
for workspace in client server; do
|
|
81
|
+
cleanup_legacy_workspace "$WORK_DIR/$workspace"
|
|
82
|
+
done
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
copy_install_metadata() {
|
|
86
|
+
local filename source_file target_file workspace
|
|
87
|
+
for filename in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
88
|
+
source_file="$PROJECT_ROOT/$filename"
|
|
89
|
+
target_file="$WORK_DIR/$filename"
|
|
90
|
+
rm -f "$target_file"
|
|
91
|
+
if [ -f "$source_file" ]; then
|
|
92
|
+
cp "$source_file" "$target_file"
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
for workspace in client server; do
|
|
97
|
+
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
98
|
+
mkdir -p "$WORK_DIR/$workspace"
|
|
99
|
+
rm -f "$WORK_DIR/$workspace/package.json"
|
|
100
|
+
cp "$PROJECT_ROOT/$workspace/package.json" "$WORK_DIR/$workspace/package.json"
|
|
101
|
+
else
|
|
102
|
+
rm -rf "$WORK_DIR/$workspace"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
107
|
link_node_modules() {
|
|
123
108
|
local source_dir="$1" target_dir="$2"
|
|
124
109
|
local current=""
|
|
@@ -139,6 +124,21 @@ link_node_modules() {
|
|
|
139
124
|
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
125
|
}
|
|
141
126
|
|
|
127
|
+
cleanup_legacy_shadow_project
|
|
128
|
+
copy_install_metadata
|
|
129
|
+
|
|
130
|
+
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
131
|
+
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
136
|
+
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
137
|
+
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
138
|
+
chmod 0644 "$temporary_lockfile"
|
|
139
|
+
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
142
|
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
143
|
for workspace in client server; do
|
|
144
144
|
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
@@ -48,77 +48,62 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
51
|
+
# Previous versions mirrored the whole project into WORK_DIR. That gives pnpm
|
|
52
|
+
# and framework dev servers two paths for the same source tree, which breaks
|
|
53
|
+
# file watching and on-demand compilation. Keep only managed local outputs.
|
|
54
|
+
cleanup_legacy_workspace() {
|
|
55
|
+
local workspace_dir="$1" entry name
|
|
56
|
+
if [ -L "$workspace_dir" ] || { [ -e "$workspace_dir" ] && [ ! -d "$workspace_dir" ]; }; then
|
|
57
|
+
rm -rf "$workspace_dir"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -d "$workspace_dir" ]; then
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
while IFS= read -r -d '' entry; do
|
|
65
|
+
name="$(basename "$entry")"
|
|
66
|
+
[ "$name" = "node_modules" ] || rm -rf "$entry"
|
|
67
|
+
done < <(find "$workspace_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cleanup_legacy_shadow_project() {
|
|
54
71
|
local entry name
|
|
55
72
|
while IFS= read -r -d '' entry; do
|
|
56
73
|
name="$(basename "$entry")"
|
|
57
74
|
case "$name" in
|
|
58
|
-
node_modules|
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
75
|
+
node_modules|.next|client|server) continue ;;
|
|
62
76
|
esac
|
|
63
77
|
rm -rf "$entry"
|
|
64
78
|
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
80
|
+
for workspace in client server; do
|
|
81
|
+
cleanup_legacy_workspace "$WORK_DIR/$workspace"
|
|
82
|
+
done
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
copy_install_metadata() {
|
|
86
|
+
local filename source_file target_file workspace
|
|
87
|
+
for filename in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
88
|
+
source_file="$PROJECT_ROOT/$filename"
|
|
89
|
+
target_file="$WORK_DIR/$filename"
|
|
90
|
+
rm -f "$target_file"
|
|
91
|
+
if [ -f "$source_file" ]; then
|
|
92
|
+
cp "$source_file" "$target_file"
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
for workspace in client server; do
|
|
97
|
+
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
98
|
+
mkdir -p "$WORK_DIR/$workspace"
|
|
99
|
+
rm -f "$WORK_DIR/$workspace/package.json"
|
|
100
|
+
cp "$PROJECT_ROOT/$workspace/package.json" "$WORK_DIR/$workspace/package.json"
|
|
101
|
+
else
|
|
102
|
+
rm -rf "$WORK_DIR/$workspace"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
107
|
link_node_modules() {
|
|
123
108
|
local source_dir="$1" target_dir="$2"
|
|
124
109
|
local current=""
|
|
@@ -139,6 +124,21 @@ link_node_modules() {
|
|
|
139
124
|
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
125
|
}
|
|
141
126
|
|
|
127
|
+
cleanup_legacy_shadow_project
|
|
128
|
+
copy_install_metadata
|
|
129
|
+
|
|
130
|
+
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
131
|
+
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
136
|
+
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
137
|
+
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
138
|
+
chmod 0644 "$temporary_lockfile"
|
|
139
|
+
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
142
|
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
143
|
for workspace in client server; do
|
|
144
144
|
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
@@ -48,77 +48,62 @@ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
48
48
|
|
|
49
49
|
mkdir -p "$WORK_DIR"
|
|
50
50
|
|
|
51
|
-
#
|
|
52
|
-
#
|
|
53
|
-
|
|
51
|
+
# Previous versions mirrored the whole project into WORK_DIR. That gives pnpm
|
|
52
|
+
# and framework dev servers two paths for the same source tree, which breaks
|
|
53
|
+
# file watching and on-demand compilation. Keep only managed local outputs.
|
|
54
|
+
cleanup_legacy_workspace() {
|
|
55
|
+
local workspace_dir="$1" entry name
|
|
56
|
+
if [ -L "$workspace_dir" ] || { [ -e "$workspace_dir" ] && [ ! -d "$workspace_dir" ]; }; then
|
|
57
|
+
rm -rf "$workspace_dir"
|
|
58
|
+
return
|
|
59
|
+
fi
|
|
60
|
+
if [ ! -d "$workspace_dir" ]; then
|
|
61
|
+
return 0
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
while IFS= read -r -d '' entry; do
|
|
65
|
+
name="$(basename "$entry")"
|
|
66
|
+
[ "$name" = "node_modules" ] || rm -rf "$entry"
|
|
67
|
+
done < <(find "$workspace_dir" -mindepth 1 -maxdepth 1 -print0)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
cleanup_legacy_shadow_project() {
|
|
54
71
|
local entry name
|
|
55
72
|
while IFS= read -r -d '' entry; do
|
|
56
73
|
name="$(basename "$entry")"
|
|
57
74
|
case "$name" in
|
|
58
|
-
node_modules|
|
|
59
|
-
client|server)
|
|
60
|
-
[ -f "$PROJECT_ROOT/$name/package.json" ] && continue
|
|
61
|
-
;;
|
|
75
|
+
node_modules|.next|client|server) continue ;;
|
|
62
76
|
esac
|
|
63
77
|
rm -rf "$entry"
|
|
64
78
|
done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
node_modules|pnpm-lock.yaml) continue ;;
|
|
70
|
-
client|server)
|
|
71
|
-
[ -f "$entry/package.json" ] && continue
|
|
72
|
-
;;
|
|
73
|
-
esac
|
|
74
|
-
ln -s "$entry" "$WORK_DIR/$name"
|
|
75
|
-
done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
|
|
80
|
+
for workspace in client server; do
|
|
81
|
+
cleanup_legacy_workspace "$WORK_DIR/$workspace"
|
|
82
|
+
done
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
copy_install_metadata() {
|
|
86
|
+
local filename source_file target_file workspace
|
|
87
|
+
for filename in package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc; do
|
|
88
|
+
source_file="$PROJECT_ROOT/$filename"
|
|
89
|
+
target_file="$WORK_DIR/$filename"
|
|
90
|
+
rm -f "$target_file"
|
|
91
|
+
if [ -f "$source_file" ]; then
|
|
92
|
+
cp "$source_file" "$target_file"
|
|
93
|
+
fi
|
|
94
|
+
done
|
|
95
|
+
|
|
96
|
+
for workspace in client server; do
|
|
97
|
+
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
98
|
+
mkdir -p "$WORK_DIR/$workspace"
|
|
99
|
+
rm -f "$WORK_DIR/$workspace/package.json"
|
|
100
|
+
cp "$PROJECT_ROOT/$workspace/package.json" "$WORK_DIR/$workspace/package.json"
|
|
101
|
+
else
|
|
102
|
+
rm -rf "$WORK_DIR/$workspace"
|
|
103
|
+
fi
|
|
104
|
+
done
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
mirror_root
|
|
97
|
-
for workspace in client server; do
|
|
98
|
-
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
|
99
|
-
mirror_workspace "$workspace"
|
|
100
|
-
fi
|
|
101
|
-
done
|
|
102
|
-
|
|
103
|
-
# pnpm refuses to update a symlinked lockfile, so install against a local copy.
|
|
104
|
-
rm -rf "$WORK_DIR/pnpm-lock.yaml"
|
|
105
|
-
if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
|
|
106
|
-
cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
|
|
107
|
-
fi
|
|
108
|
-
|
|
109
|
-
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
110
|
-
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
111
|
-
rm -f "$WORK_DIR/pnpm-lock.yaml"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
|
|
115
|
-
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
116
|
-
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
117
|
-
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
118
|
-
chmod 0644 "$temporary_lockfile"
|
|
119
|
-
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
120
|
-
fi
|
|
121
|
-
|
|
122
107
|
link_node_modules() {
|
|
123
108
|
local source_dir="$1" target_dir="$2"
|
|
124
109
|
local current=""
|
|
@@ -139,6 +124,21 @@ link_node_modules() {
|
|
|
139
124
|
ln -s "$target_dir" "$source_dir/node_modules"
|
|
140
125
|
}
|
|
141
126
|
|
|
127
|
+
cleanup_legacy_shadow_project
|
|
128
|
+
copy_install_metadata
|
|
129
|
+
|
|
130
|
+
echo "[node_modules] Installing dependencies in $WORK_DIR"
|
|
131
|
+
if ! (cd "$WORK_DIR" && pnpm install "$@"); then
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
|
|
136
|
+
temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
|
|
137
|
+
cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
|
|
138
|
+
chmod 0644 "$temporary_lockfile"
|
|
139
|
+
mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
142
|
link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
|
|
143
143
|
for workspace in client server; do
|
|
144
144
|
if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
|
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.3f9b02";
|
|
2118
2118
|
var description = "coze coding devtools cli";
|
|
2119
2119
|
var license = "MIT";
|
|
2120
2120
|
var author = "fanwenjie.fe@bytedance.com";
|