pgserve 1.0.2 → 1.0.4

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/knip.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "$schema": "https://unpkg.com/knip@5/schema.json",
3
3
  "entry": ["src/index.js", "bin/pglite-server.js"],
4
4
  "project": ["src/**/*.js", "bin/**/*.js"],
5
- "ignore": ["tests/**", "helpers/**"],
5
+ "ignore": ["tests/**", "helpers/**", "scripts/**"],
6
6
  "ignoreDependencies": ["pino-pretty"],
7
+ "ignoreBinaries": ["scripts/test-npx.sh"],
7
8
  "ignoreExportsUsedInFile": true
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgserve",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Embedded PostgreSQL server with true concurrent connections - zero config, auto-provision databases",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -13,6 +13,8 @@
13
13
  "lint": "eslint src/ bin/",
14
14
  "lint:fix": "eslint src/ bin/ --fix",
15
15
  "deadcode": "knip",
16
+ "test:npx": "scripts/test-npx.sh",
17
+ "prepublishOnly": "npm run lint && npm run deadcode && npm run test:npx",
16
18
  "prepare": "husky"
17
19
  },
18
20
  "keywords": [
@@ -0,0 +1,51 @@
1
+ #!/bin/bash
2
+ # Test that the package works with npx (simulates fresh install)
3
+ # This catches path resolution issues that static analysis can't detect
4
+
5
+ set -e
6
+
7
+ echo "=== Testing npx compatibility ==="
8
+
9
+ # Create temp directory
10
+ TEST_DIR=$(mktemp -d)
11
+ trap "rm -rf $TEST_DIR" EXIT
12
+
13
+ # Pack the current package
14
+ echo "Packing package..."
15
+ PACK_FILE=$(npm pack --pack-destination "$TEST_DIR" 2>/dev/null | tail -1)
16
+
17
+ # Extract and install in isolated environment
18
+ echo "Installing in isolated environment..."
19
+ cd "$TEST_DIR"
20
+ npm init -y > /dev/null 2>&1
21
+ npm install "$PACK_FILE" > /dev/null 2>&1
22
+
23
+ # Test that it starts (with timeout)
24
+ echo "Testing server startup..."
25
+ timeout 8 npx pgserve --no-cluster --port 15432 > output.log 2>&1 &
26
+ PID=$!
27
+
28
+ # Wait for ready signal
29
+ for i in {1..20}; do
30
+ if grep -q "READY" output.log 2>/dev/null; then
31
+ echo "✓ Server started successfully"
32
+ kill $PID 2>/dev/null || true
33
+ wait $PID 2>/dev/null || true
34
+ echo "=== npx test PASSED ==="
35
+ exit 0
36
+ fi
37
+ if ! kill -0 $PID 2>/dev/null; then
38
+ echo "✗ Server exited unexpectedly"
39
+ cat output.log
40
+ echo "=== npx test FAILED ==="
41
+ exit 1
42
+ fi
43
+ sleep 0.5
44
+ done
45
+
46
+ # Timeout
47
+ kill $PID 2>/dev/null || true
48
+ echo "✗ Server did not start within timeout"
49
+ cat output.log
50
+ echo "=== npx test FAILED ==="
51
+ exit 1
package/src/postgres.js CHANGED
@@ -37,10 +37,12 @@ function getBinaryPaths() {
37
37
  throw new Error(`Unsupported platform: ${platform}-${arch}`);
38
38
  }
39
39
 
40
- // Find the package in node_modules
40
+ // Find the package in node_modules (check multiple locations for npx/pnpm/npm compatibility)
41
41
  const possiblePaths = [
42
42
  path.join(process.cwd(), 'node_modules', pkgName, 'native', 'bin'),
43
43
  path.join(import.meta.dirname, '..', 'node_modules', pkgName, 'native', 'bin'),
44
+ path.join(import.meta.dirname, '..', '..', pkgName, 'native', 'bin'), // Hoisted (npx flat structure)
45
+ path.join(import.meta.dirname, '..', '..', '..', pkgName, 'native', 'bin'), // Extra level for some package managers
44
46
  ];
45
47
 
46
48
  for (const binDir of possiblePaths) {