postgresdk 0.7.2 → 0.7.3

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.
Files changed (3) hide show
  1. package/dist/cli.js +49 -13
  2. package/dist/index.js +49 -13
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3379,27 +3379,57 @@ else
3379
3379
  fi
3380
3380
 
3381
3381
  echo ""
3382
- echo "\uD83D\uDE80 Starting API server..."
3383
- echo "⚠️ TODO: Uncomment and customize the API server startup command below:"
3382
+ echo "\uD83D\uDE80 API Server Setup"
3383
+ echo "════════════════════════════════════════════════════════════════"
3384
3384
  echo ""
3385
- echo " # Example for Node.js/Bun using PROJECT_ROOT:"
3386
- echo " # cd \\$PROJECT_ROOT && npm run dev &"
3387
- echo " # SERVER_PID=\\$!"
3385
+ echo "⚠️ IMPORTANT: This script expects your API server to be running."
3388
3386
  echo ""
3389
- echo " # Example for custom server file:"
3390
- echo " # DATABASE_URL=\\$TEST_DATABASE_URL node \\$PROJECT_ROOT/src/server.js &"
3391
- echo " # SERVER_PID=\\$!"
3387
+ echo " Option 1: Start manually (recommended for development)"
3388
+ echo " - Start your API server in another terminal"
3389
+ echo " - Make sure it uses TEST_DATABASE_URL: $TEST_DATABASE_URL"
3390
+ echo " - Make sure it's accessible at: $TEST_API_URL"
3392
3391
  echo ""
3393
- echo " # Example for Bun:"
3394
- echo " # DATABASE_URL=\\$TEST_DATABASE_URL bun \\$PROJECT_ROOT/src/index.ts &"
3395
- echo " # SERVER_PID=\\$!"
3392
+ echo " Option 2: Auto-start (edit this script)"
3393
+ echo " - Uncomment and customize one of these commands:"
3394
+ echo " # cd $PROJECT_ROOT && DATABASE_URL=$TEST_DATABASE_URL npm run dev &"
3395
+ echo " # DATABASE_URL=$TEST_DATABASE_URL bun $PROJECT_ROOT/src/server.ts &"
3396
+ echo " # SERVER_PID=$! # (uncomment this line too)"
3397
+ echo " # sleep 3 # (wait for server to start)"
3396
3398
  echo ""
3397
- echo " Please edit this script to start your API server."
3399
+ echo "════════════════════════════════════════════════════════════════"
3398
3400
  echo ""
3399
- # cd $PROJECT_ROOT && npm run dev &
3401
+
3402
+ # Uncomment these lines to auto-start your API server:
3403
+ # cd $PROJECT_ROOT && DATABASE_URL=$TEST_DATABASE_URL npm run dev &
3400
3404
  # SERVER_PID=$!
3401
3405
  # sleep 3
3402
3406
 
3407
+ # Check if API server is running before starting tests
3408
+ echo "\uD83D\uDD0D Checking if API server is running..."
3409
+ API_URL="\${TEST_API_URL:-http://localhost:3000}"
3410
+
3411
+ # Simple health check - just try to connect to the port
3412
+ if ! curl -f -s --connect-timeout 3 "\${API_URL}/health" > /dev/null 2>&1; then
3413
+ # Try a generic endpoint or just check if port is open
3414
+ if ! nc -z localhost 3000 2>/dev/null; then
3415
+ echo "❌ ERROR: API server is not running on \${API_URL}"
3416
+ echo ""
3417
+ echo " The API server must be running before tests can execute."
3418
+ echo " Please:"
3419
+ echo " 1. Start your API server manually, OR"
3420
+ echo " 2. Edit this script to start the server automatically (see comments above)"
3421
+ echo ""
3422
+ echo " Uncomment and customize one of these server startup commands:"
3423
+ echo " # cd $PROJECT_ROOT && npm run dev &"
3424
+ echo " # DATABASE_URL=$TEST_DATABASE_URL bun $PROJECT_ROOT/src/server.ts &"
3425
+ echo ""
3426
+ exit 1
3427
+ fi
3428
+ fi
3429
+
3430
+ echo "✅ API server is responding"
3431
+ echo ""
3432
+
3403
3433
  echo "\uD83E\uDDEA Running tests..."
3404
3434
  TIMESTAMP=$(date +%Y%m%d_%H%M%S)
3405
3435
  TEST_RESULTS_DIR="$SCRIPT_DIR/test-results"
@@ -3422,8 +3452,14 @@ echo " $TEST_RESULTS_DIR/"
3422
3452
  echo ""
3423
3453
  echo "\uD83D\uDCA1 Tips:"
3424
3454
  echo " - Database will be stopped automatically on script exit"
3455
+ echo " - API server (if started by this script) will also be stopped automatically"
3425
3456
  echo " - To manually stop the database: docker-compose -f $SCRIPT_DIR/docker-compose.yml down"
3426
3457
  echo " - To reset the database: docker-compose -f $SCRIPT_DIR/docker-compose.yml down -v"
3458
+ echo ""
3459
+ echo "\uD83D\uDD27 If tests failed due to server issues:"
3460
+ echo " - Check that your API server is configured to use TEST_DATABASE_URL"
3461
+ echo " - Verify your API server is accessible at $API_URL"
3462
+ echo " - Make sure all required environment variables are set"
3427
3463
 
3428
3464
  exit $TEST_EXIT_CODE
3429
3465
  `;
package/dist/index.js CHANGED
@@ -3116,27 +3116,57 @@ else
3116
3116
  fi
3117
3117
 
3118
3118
  echo ""
3119
- echo "\uD83D\uDE80 Starting API server..."
3120
- echo "⚠️ TODO: Uncomment and customize the API server startup command below:"
3119
+ echo "\uD83D\uDE80 API Server Setup"
3120
+ echo "════════════════════════════════════════════════════════════════"
3121
3121
  echo ""
3122
- echo " # Example for Node.js/Bun using PROJECT_ROOT:"
3123
- echo " # cd \\$PROJECT_ROOT && npm run dev &"
3124
- echo " # SERVER_PID=\\$!"
3122
+ echo "⚠️ IMPORTANT: This script expects your API server to be running."
3125
3123
  echo ""
3126
- echo " # Example for custom server file:"
3127
- echo " # DATABASE_URL=\\$TEST_DATABASE_URL node \\$PROJECT_ROOT/src/server.js &"
3128
- echo " # SERVER_PID=\\$!"
3124
+ echo " Option 1: Start manually (recommended for development)"
3125
+ echo " - Start your API server in another terminal"
3126
+ echo " - Make sure it uses TEST_DATABASE_URL: $TEST_DATABASE_URL"
3127
+ echo " - Make sure it's accessible at: $TEST_API_URL"
3129
3128
  echo ""
3130
- echo " # Example for Bun:"
3131
- echo " # DATABASE_URL=\\$TEST_DATABASE_URL bun \\$PROJECT_ROOT/src/index.ts &"
3132
- echo " # SERVER_PID=\\$!"
3129
+ echo " Option 2: Auto-start (edit this script)"
3130
+ echo " - Uncomment and customize one of these commands:"
3131
+ echo " # cd $PROJECT_ROOT && DATABASE_URL=$TEST_DATABASE_URL npm run dev &"
3132
+ echo " # DATABASE_URL=$TEST_DATABASE_URL bun $PROJECT_ROOT/src/server.ts &"
3133
+ echo " # SERVER_PID=$! # (uncomment this line too)"
3134
+ echo " # sleep 3 # (wait for server to start)"
3133
3135
  echo ""
3134
- echo " Please edit this script to start your API server."
3136
+ echo "════════════════════════════════════════════════════════════════"
3135
3137
  echo ""
3136
- # cd $PROJECT_ROOT && npm run dev &
3138
+
3139
+ # Uncomment these lines to auto-start your API server:
3140
+ # cd $PROJECT_ROOT && DATABASE_URL=$TEST_DATABASE_URL npm run dev &
3137
3141
  # SERVER_PID=$!
3138
3142
  # sleep 3
3139
3143
 
3144
+ # Check if API server is running before starting tests
3145
+ echo "\uD83D\uDD0D Checking if API server is running..."
3146
+ API_URL="\${TEST_API_URL:-http://localhost:3000}"
3147
+
3148
+ # Simple health check - just try to connect to the port
3149
+ if ! curl -f -s --connect-timeout 3 "\${API_URL}/health" > /dev/null 2>&1; then
3150
+ # Try a generic endpoint or just check if port is open
3151
+ if ! nc -z localhost 3000 2>/dev/null; then
3152
+ echo "❌ ERROR: API server is not running on \${API_URL}"
3153
+ echo ""
3154
+ echo " The API server must be running before tests can execute."
3155
+ echo " Please:"
3156
+ echo " 1. Start your API server manually, OR"
3157
+ echo " 2. Edit this script to start the server automatically (see comments above)"
3158
+ echo ""
3159
+ echo " Uncomment and customize one of these server startup commands:"
3160
+ echo " # cd $PROJECT_ROOT && npm run dev &"
3161
+ echo " # DATABASE_URL=$TEST_DATABASE_URL bun $PROJECT_ROOT/src/server.ts &"
3162
+ echo ""
3163
+ exit 1
3164
+ fi
3165
+ fi
3166
+
3167
+ echo "✅ API server is responding"
3168
+ echo ""
3169
+
3140
3170
  echo "\uD83E\uDDEA Running tests..."
3141
3171
  TIMESTAMP=$(date +%Y%m%d_%H%M%S)
3142
3172
  TEST_RESULTS_DIR="$SCRIPT_DIR/test-results"
@@ -3159,8 +3189,14 @@ echo " $TEST_RESULTS_DIR/"
3159
3189
  echo ""
3160
3190
  echo "\uD83D\uDCA1 Tips:"
3161
3191
  echo " - Database will be stopped automatically on script exit"
3192
+ echo " - API server (if started by this script) will also be stopped automatically"
3162
3193
  echo " - To manually stop the database: docker-compose -f $SCRIPT_DIR/docker-compose.yml down"
3163
3194
  echo " - To reset the database: docker-compose -f $SCRIPT_DIR/docker-compose.yml down -v"
3195
+ echo ""
3196
+ echo "\uD83D\uDD27 If tests failed due to server issues:"
3197
+ echo " - Check that your API server is configured to use TEST_DATABASE_URL"
3198
+ echo " - Verify your API server is accessible at $API_URL"
3199
+ echo " - Make sure all required environment variables are set"
3164
3200
 
3165
3201
  exit $TEST_EXIT_CODE
3166
3202
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {