create-nuxt-base 2.6.3 → 2.6.5

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.
@@ -1,37 +1,67 @@
1
1
  #!/usr/bin/env bash
2
+ # Verify the built Nuxt server boots and stays up, then exit cleanly.
3
+ #
4
+ # Previously this script also streamed logs via a parallel `tail -f` and waited
5
+ # on both PIDs on EXIT. On macOS / bash that pattern hangs intermittently:
6
+ # `tail -f` does not always honor SIGTERM while blocked on the kqueue file
7
+ # watch, so `wait $TAIL_PID` blocks indefinitely and the surrounding
8
+ # `pnpm run check` never returns. We now skip the live stream and print the
9
+ # relevant log excerpt at the end instead.
10
+
2
11
  set -e
3
12
 
4
- # Temp file for server output
5
- LOG_FILE=$(mktemp)
13
+ LOG_FILE=$(mktemp -t nuxt-check-server.XXXXXX)
6
14
 
7
- # Start the built Nuxt server in background, redirect output to log file
8
- # The build step already ran before this script is called
9
- node .output/server/index.mjs > "$LOG_FILE" 2>&1 &
10
- SERVER_PID=$!
15
+ cleanup() {
16
+ if [[ -n "${SERVER_PID:-}" ]]; then
17
+ # SIGTERM first, then SIGKILL if still alive after ~2s. We do NOT `wait`
18
+ # on the child — it was the original hang. Nitro can take a moment to
19
+ # unwind its listeners; the escalation gives it that moment.
20
+ kill "$SERVER_PID" 2>/dev/null || true
21
+ for _ in 1 2 3 4; do
22
+ kill -0 "$SERVER_PID" 2>/dev/null || break
23
+ sleep 0.5
24
+ done
25
+ kill -9 "$SERVER_PID" 2>/dev/null || true
26
+ fi
27
+ rm -f "$LOG_FILE"
28
+ }
29
+ trap cleanup EXIT
11
30
 
12
- # Show log output in real-time
13
- tail -f "$LOG_FILE" &
14
- TAIL_PID=$!
31
+ # Pick a free port so the check passes regardless of what is running on
32
+ # 3000/3001 (sister API dev server, another nuxt instance, …). Strip
33
+ # ANSI color escape sequences from the command output — when this
34
+ # script runs under a workspace runner like lerna/nx, stdout may be
35
+ # wrapped and color codes ("\x1b[33m...\x1b[39m") injected. Those would
36
+ # land inside FREE_PORT and crash Nitro with
37
+ # `ERR_SOCKET_BAD_PORT options.port ... Received type string ('<codes>50604<codes>')`.
38
+ # A naïve `tr -cd '0-9'` makes it worse because the color codes contain
39
+ # digits (33, 39) themselves; sed only on the escape pattern keeps the
40
+ # port digits intact.
41
+ # Use NITRO_PORT rather than PORT — Nitro 2.13.3 reads PORT as a string
42
+ # without parseInt and feeds it straight into net.Server#listen.
43
+ FREE_PORT=$(node -e "const s=require('net').createServer();s.listen(0,'127.0.0.1',()=>{const p=s.address().port;s.close(()=>console.log(p));});" | sed $'s/\x1b\\[[0-9;]*m//g' | tr -d '[:space:]')
44
+ echo "Using free port: $FREE_PORT"
15
45
 
16
- # Ensure cleanup on exit: kill server, tail, and remove temp file
17
- trap 'kill $SERVER_PID $TAIL_PID 2>/dev/null; wait $SERVER_PID $TAIL_PID 2>/dev/null || true; rm -f "$LOG_FILE"' EXIT
46
+ NITRO_PORT=$FREE_PORT node .output/server/index.mjs >"$LOG_FILE" 2>&1 &
47
+ SERVER_PID=$!
48
+ # Remove from job table so bash does not print "Terminated: 15" on SIGTERM
49
+ disown "$SERVER_PID" 2>/dev/null || true
18
50
 
19
- # Wait for the Nitro server ready message (max 60 seconds)
20
- for i in $(seq 1 60); do
51
+ for _ in $(seq 1 60); do
21
52
  if grep -q "Listening on\|Nitro ready\|Local:" "$LOG_FILE" 2>/dev/null; then
22
- echo ""
53
+ tail -n 5 "$LOG_FILE"
23
54
  echo "Server started successfully - check complete"
24
55
  exit 0
25
56
  fi
26
- # Check if server process died unexpectedly
27
- if ! kill -0 $SERVER_PID 2>/dev/null; then
28
- echo ""
29
- echo "Server process exited unexpectedly"
57
+ if ! kill -0 "$SERVER_PID" 2>/dev/null; then
58
+ echo "Server process exited unexpectedly. Full log:"
59
+ cat "$LOG_FILE"
30
60
  exit 1
31
61
  fi
32
62
  sleep 1
33
63
  done
34
64
 
35
- echo ""
36
- echo "Server failed to start within 60 seconds"
65
+ echo "Server failed to start within 60 seconds. Last 30 log lines:"
66
+ tail -n 30 "$LOG_FILE"
37
67
  exit 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nuxt-base",
3
- "version": "2.6.3",
3
+ "version": "2.6.5",
4
4
  "description": "Starter to generate a configured environment with VueJS, Nuxt, Tailwind, Linting, Unit Tests, Playwright etc.",
5
5
  "license": "MIT",
6
6
  "author": "lenne.Tech GmbH",