@coze-arch/cli 0.1.4-alpha.170425 → 0.1.4-alpha.2217bc

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.
@@ -48,77 +48,62 @@ 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 stays real in WORK_DIR;
52
- # workspace directories stay real too, so pnpm never writes them to Drive.
53
- mirror_root() {
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|pnpm-lock.yaml) continue ;;
59
- client|server)
60
- [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
- ;;
75
+ node_modules|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
- while IFS= read -r -d '' entry; do
67
- name="$(basename "$entry")"
68
- case "$name" in
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
- mirror_workspace() {
79
- local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
- local entry name
81
- if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
- rm -rf "$work_dir"
83
- fi
84
- mkdir -p "$work_dir"
85
-
86
- while IFS= read -r -d '' entry; do
87
- [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
- done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
-
90
- while IFS= read -r -d '' entry; do
91
- name="$(basename "$entry")"
92
- [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
- done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
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
- '.next/**',
42
- 'out/**',
43
- 'build/**',
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",
@@ -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,11 @@ 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
58
59
  echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
59
60
 
60
61
  # 测试环境保持服务为前台进程,便于 e2e 收集输出并停止进程。
61
- exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx watch src/server.ts
62
+ exec env PORT="${DEPLOY_RUN_PORT}" pnpm tsx src/server.ts
62
63
  <% } else { %>
63
64
  LOG_DIR="${COZE_LOG_DIR:-${COZE_WORKSPACE_PATH}/logs}"
64
65
  LOG_FILE="${LOG_DIR}/app.log"
@@ -226,6 +227,7 @@ fi
226
227
 
227
228
  echo "Clearing port ${DEPLOY_RUN_PORT} before start."
228
229
  kill_port_if_listening
230
+ bash "${COZE_WORKSPACE_PATH}/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
229
231
  echo "Starting HTTP service on port ${DEPLOY_RUN_PORT} for dev..."
230
232
 
231
233
  mkdir -p "${LOG_DIR}"
@@ -233,7 +235,7 @@ mkdir -p "${LOG_DIR}"
233
235
 
234
236
  export PORT="${DEPLOY_RUN_PORT}"
235
237
  server_pid="$(spawn_detached "${COZE_WORKSPACE_PATH}" "${LOG_FILE}" \
236
- "$(command -v pnpm)" tsx watch src/server.ts)"
238
+ "$(command -v pnpm)" tsx src/server.ts)"
237
239
  if [[ -z "${server_pid}" ]]; then
238
240
  echo "Dev server failed to start: 未获取到后台进程 PID。" >&2
239
241
  dump_log
@@ -48,77 +48,62 @@ 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 stays real in WORK_DIR;
52
- # workspace directories stay real too, so pnpm never writes them to Drive.
53
- mirror_root() {
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|pnpm-lock.yaml) continue ;;
59
- client|server)
60
- [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
- ;;
75
+ node_modules|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
- while IFS= read -r -d '' entry; do
67
- name="$(basename "$entry")"
68
- case "$name" in
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
- mirror_workspace() {
79
- local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
- local entry name
81
- if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
- rm -rf "$work_dir"
83
- fi
84
- mkdir -p "$work_dir"
85
-
86
- while IFS= read -r -d '' entry; do
87
- [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
- done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
-
90
- while IFS= read -r -d '' entry; do
91
- name="$(basename "$entry")"
92
- [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
- done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
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
- # Mirror the project with symlinks. node_modules stays real in WORK_DIR;
52
- # workspace directories stay real too, so pnpm never writes them to Drive.
53
- mirror_root() {
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|pnpm-lock.yaml) continue ;;
59
- client|server)
60
- [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
- ;;
75
+ node_modules|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
- while IFS= read -r -d '' entry; do
67
- name="$(basename "$entry")"
68
- case "$name" in
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
- mirror_workspace() {
79
- local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
- local entry name
81
- if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
- rm -rf "$work_dir"
83
- fi
84
- mkdir -p "$work_dir"
85
-
86
- while IFS= read -r -d '' entry; do
87
- [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
- done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
-
90
- while IFS= read -r -d '' entry; do
91
- name="$(basename "$entry")"
92
- [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
- done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
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
- # Mirror the project with symlinks. node_modules stays real in WORK_DIR;
52
- # workspace directories stay real too, so pnpm never writes them to Drive.
53
- mirror_root() {
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|pnpm-lock.yaml) continue ;;
59
- client|server)
60
- [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
- ;;
75
+ node_modules|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
- while IFS= read -r -d '' entry; do
67
- name="$(basename "$entry")"
68
- case "$name" in
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
- mirror_workspace() {
79
- local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
- local entry name
81
- if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
- rm -rf "$work_dir"
83
- fi
84
- mkdir -p "$work_dir"
85
-
86
- while IFS= read -r -d '' entry; do
87
- [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
- done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
-
90
- while IFS= read -r -d '' entry; do
91
- name="$(basename "$entry")"
92
- [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
- done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
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
- # Mirror the project with symlinks. node_modules stays real in WORK_DIR;
52
- # workspace directories stay real too, so pnpm never writes them to Drive.
53
- mirror_root() {
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|pnpm-lock.yaml) continue ;;
59
- client|server)
60
- [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
- ;;
75
+ node_modules|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
- while IFS= read -r -d '' entry; do
67
- name="$(basename "$entry")"
68
- case "$name" in
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
- mirror_workspace() {
79
- local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
- local entry name
81
- if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
- rm -rf "$work_dir"
83
- fi
84
- mkdir -p "$work_dir"
85
-
86
- while IFS= read -r -d '' entry; do
87
- [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
- done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
-
90
- while IFS= read -r -d '' entry; do
91
- name="$(basename "$entry")"
92
- [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
- done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
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.170425";
2117
+ var version = "0.1.4-alpha.2217bc";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.1.4-alpha.170425",
3
+ "version": "0.1.4-alpha.2217bc",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",