ework-aio 0.1.9 → 0.1.10

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/bin/ework-aio CHANGED
@@ -253,10 +253,11 @@ function startOne(svc: SvcName, foreground: boolean): boolean {
253
253
  }
254
254
  const envPath = svcEnvPath(svc);
255
255
  if (!existsSync(envPath)) {
256
- console.error(
257
- `${SVC_CONFIG[svc].label}: missing .env at ${envPath}.`
258
- );
259
- console.error(" Run `ework-aio install --no-start` first to scaffold config + data dir.");
256
+ console.error(`${SVC_CONFIG[svc].label}: missing .env at ${envPath}.`);
257
+ console.error(" Run `ework-aio install` first to scaffold config + data dir.");
258
+ console.error(" If install fails with npm ENOTEMPTY, a stale temp dir is blocking it.");
259
+ console.error(" Manual fix: sudo rm -rf \"$(npm root -g)/.ework-*\" \"$(npm root -g)\"/*.Trash*");
260
+ console.error(" Then re-run: ework-aio install");
260
261
  return false;
261
262
  }
262
263
 
package/bin/install.sh CHANGED
@@ -162,12 +162,59 @@ ensure_pkg() {
162
162
  }
163
163
  case "$MODE" in
164
164
  install)
165
+ # Pre-clean stale npm rename temp-dirs from any previous failed install.
166
+ # npm's atomic-install pattern renames the existing package dir to a
167
+ # `.<pkg>-<rand>` sibling before extracting the new tarball; if a prior
168
+ # install crashed mid-flight, that temp dir stays behind and the NEXT
169
+ # install fails with ENOTEMPTY on the rename. Symptoms:
170
+ # npm error code ENOTEMPTY
171
+ # npm error syscall rename
172
+ # npm error path .../node_modules/ework-web
173
+ # npm error dest .../node_modules/.ework-web-Cx2Tkt83
174
+ clean_npm_stale_dirs() {
175
+ local npm_root
176
+ npm_root="$(npm root -g 2>/dev/null)" || return 0
177
+ [[ -d "$npm_root" ]] || return 0
178
+ # Stale temp patterns: .ework-web-XXXX, .ework-daemon-XXXX, .opencode-ework-XXXX,
179
+ # .ework-aio-XXXX, plus the .Trash suffix some npm versions use.
180
+ local found=()
181
+ while IFS= read -r p; do
182
+ [[ -n "$p" ]] && found+=("$p")
183
+ done < <(find "$npm_root" -maxdepth 1 \( \
184
+ -name '.ework-web-*' -o \
185
+ -name '.ework-daemon-*' -o \
186
+ -name '.ework-aio-*' -o \
187
+ -name '.opencode-ework-*' -o \
188
+ -name 'ework-*.Trash*' -o \
189
+ -name 'opencode-ework.Trash*' \) 2>/dev/null || true)
190
+ if [[ ${#found[@]} -gt 0 ]]; then
191
+ log "Found ${#found[@]} stale npm temp dir(s) under $npm_root from a previous failed install:"
192
+ printf ' %s\n' "${found[@]}"
193
+ log "Removing..."
194
+ local d
195
+ for d in "${found[@]}"; do
196
+ rm -rf "$d" 2>/dev/null || warn "could not remove $d (try: sudo rm -rf $d)"
197
+ done
198
+ fi
199
+ }
200
+
201
+ npm_install_global() {
202
+ # One retry after a cleanup pass — covers the ENOTEMPTY case where npm
203
+ # itself produced a fresh temp dir during this same failed run.
204
+ if ! npm install -g "$1@latest"; then
205
+ warn "npm install -g $1@latest failed; cleaning stale temp dirs and retrying once..."
206
+ clean_npm_stale_dirs
207
+ npm install -g "$1@latest"
208
+ fi
209
+ }
210
+
211
+ clean_npm_stale_dirs
165
212
  log "Installing/updating npm packages globally..."
166
213
  # Install each as a top-level global so bins are linked to PATH.
167
214
  # (npm v9 doesn't hoist nested deps' bins from `npm i -g ework-aio`.)
168
215
  # Always run `npm install -g` (not gated on presence) so re-runs pick up new versions.
169
216
  for pkg in ework-web ework-daemon opencode-ework ework-aio; do
170
- npm install -g "$pkg@latest" || die "npm install -g $pkg@latest failed"
217
+ npm_install_global "$pkg" || die "npm install -g $pkg@latest failed (even after cleanup retry; manual fix: sudo rm -rf $(npm root -g)/.$pkg-* $(npm root -g)/$pkg.Trash*)"
171
218
  done
172
219
  ok "npm packages ready"
173
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-aio",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "All-in-one installer for ework (issue tracker) + ework-daemon (AI bridge) + opencode-ework (plugin). One command: npm i -g ework-aio && ework-aio install.",
5
5
  "type": "module",
6
6
  "license": "MIT",