postgresdk 0.6.15 → 0.6.17

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/dist/cli.js CHANGED
@@ -3214,8 +3214,9 @@ volumes:
3214
3214
  postgres_data:
3215
3215
  `;
3216
3216
  }
3217
- function emitTestScript(framework = "vitest") {
3217
+ function emitTestScript(framework = "vitest", testDirPath) {
3218
3218
  const runCommand = framework === "bun" ? "bun test" : framework;
3219
+ const pathToRoot = testDirPath ? testDirPath.split("/").filter((p) => p && p !== ".").map(() => "..").join("/") : "../..";
3219
3220
  return `#!/bin/bash
3220
3221
  # Test Runner Script
3221
3222
  #
@@ -3234,10 +3235,10 @@ set -e
3234
3235
 
3235
3236
  SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
3236
3237
 
3237
- # PROJECT_ROOT is the root of your project (3 levels up from tests directory)
3238
+ # PROJECT_ROOT is the root of your project
3238
3239
  # Use this to reference files from your project root
3239
3240
  # Example: $PROJECT_ROOT/src/server.ts
3240
- PROJECT_ROOT="$( cd "$SCRIPT_DIR/../../.." && pwd )"
3241
+ PROJECT_ROOT="$( cd "$SCRIPT_DIR/${pathToRoot}" && pwd )"
3241
3242
 
3242
3243
  echo "\uD83D\uDCCD Project root: $PROJECT_ROOT"
3243
3244
  echo "\uD83D\uDCCD Test directory: $SCRIPT_DIR"
@@ -3286,42 +3287,6 @@ export TEST_API_URL="http://localhost:3000"
3286
3287
  echo "⏳ Waiting for database..."
3287
3288
  sleep 3
3288
3289
 
3289
- # REQUIRED: Run migrations on the test database
3290
- echo ""
3291
- echo "\uD83D\uDCCA Database Migration Step"
3292
- echo "========================================="
3293
- echo ""
3294
- echo "⚠️ IMPORTANT: You must run migrations before tests can work!"
3295
- echo ""
3296
- echo "Choose one of the following options:"
3297
- echo ""
3298
- echo "Option 1: Add your migration command (recommended):"
3299
- echo " Uncomment and modify one of these examples:"
3300
- echo ""
3301
- echo " # For Prisma:"
3302
- echo " # npx prisma migrate deploy"
3303
- echo ""
3304
- echo " # For Drizzle:"
3305
- echo " # npx drizzle-kit push --config=./drizzle.config.ts"
3306
- echo ""
3307
- echo " # For node-pg-migrate:"
3308
- echo " # npm run migrate up"
3309
- echo ""
3310
- echo " # For Knex:"
3311
- echo " # npx knex migrate:latest"
3312
- echo ""
3313
- echo " # For TypeORM:"
3314
- echo " # npm run typeorm migration:run"
3315
- echo ""
3316
- echo " # For custom migration scripts:"
3317
- echo " # node ./scripts/migrate.js"
3318
- echo ""
3319
- echo "Option 2: Skip migrations (only if your database is already set up):"
3320
- echo " Uncomment the line: # SKIP_MIGRATIONS=true"
3321
- echo ""
3322
- echo "========================================="
3323
- echo ""
3324
-
3325
3290
  # MIGRATION_COMMAND:
3326
3291
  # Add your migration command here. Examples using PROJECT_ROOT:
3327
3292
  # MIGRATION_COMMAND="cd $PROJECT_ROOT && npx prisma migrate deploy"
@@ -3339,7 +3304,7 @@ if [ -z "\${MIGRATION_COMMAND}" ] && [ -z "\${SKIP_MIGRATIONS}" ]; then
3339
3304
  echo " 1. Set MIGRATION_COMMAND with your migration command"
3340
3305
  echo " 2. Set SKIP_MIGRATIONS=true if migrations aren't needed"
3341
3306
  echo ""
3342
- echo " Tests cannot run without a properly migrated database schema."
3307
+ echo " See the comments above for examples."
3343
3308
  echo ""
3344
3309
  exit 1
3345
3310
  fi
@@ -4193,7 +4158,7 @@ async function generate(configPath) {
4193
4158
  });
4194
4159
  files.push({
4195
4160
  path: join(testDir, "run-tests.sh"),
4196
- content: emitTestScript(testFramework)
4161
+ content: emitTestScript(testFramework, testDir)
4197
4162
  });
4198
4163
  files.push({
4199
4164
  path: join(testDir, ".gitignore"),
@@ -22,4 +22,4 @@ export declare function emitDockerCompose(): string;
22
22
  /**
23
23
  * Generate test runner script
24
24
  */
25
- export declare function emitTestScript(framework?: "vitest" | "jest" | "bun"): string;
25
+ export declare function emitTestScript(framework?: "vitest" | "jest" | "bun", testDirPath?: string): string;
package/dist/index.js CHANGED
@@ -2951,8 +2951,9 @@ volumes:
2951
2951
  postgres_data:
2952
2952
  `;
2953
2953
  }
2954
- function emitTestScript(framework = "vitest") {
2954
+ function emitTestScript(framework = "vitest", testDirPath) {
2955
2955
  const runCommand = framework === "bun" ? "bun test" : framework;
2956
+ const pathToRoot = testDirPath ? testDirPath.split("/").filter((p) => p && p !== ".").map(() => "..").join("/") : "../..";
2956
2957
  return `#!/bin/bash
2957
2958
  # Test Runner Script
2958
2959
  #
@@ -2971,10 +2972,10 @@ set -e
2971
2972
 
2972
2973
  SCRIPT_DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
2973
2974
 
2974
- # PROJECT_ROOT is the root of your project (3 levels up from tests directory)
2975
+ # PROJECT_ROOT is the root of your project
2975
2976
  # Use this to reference files from your project root
2976
2977
  # Example: $PROJECT_ROOT/src/server.ts
2977
- PROJECT_ROOT="$( cd "$SCRIPT_DIR/../../.." && pwd )"
2978
+ PROJECT_ROOT="$( cd "$SCRIPT_DIR/${pathToRoot}" && pwd )"
2978
2979
 
2979
2980
  echo "\uD83D\uDCCD Project root: $PROJECT_ROOT"
2980
2981
  echo "\uD83D\uDCCD Test directory: $SCRIPT_DIR"
@@ -3023,42 +3024,6 @@ export TEST_API_URL="http://localhost:3000"
3023
3024
  echo "⏳ Waiting for database..."
3024
3025
  sleep 3
3025
3026
 
3026
- # REQUIRED: Run migrations on the test database
3027
- echo ""
3028
- echo "\uD83D\uDCCA Database Migration Step"
3029
- echo "========================================="
3030
- echo ""
3031
- echo "⚠️ IMPORTANT: You must run migrations before tests can work!"
3032
- echo ""
3033
- echo "Choose one of the following options:"
3034
- echo ""
3035
- echo "Option 1: Add your migration command (recommended):"
3036
- echo " Uncomment and modify one of these examples:"
3037
- echo ""
3038
- echo " # For Prisma:"
3039
- echo " # npx prisma migrate deploy"
3040
- echo ""
3041
- echo " # For Drizzle:"
3042
- echo " # npx drizzle-kit push --config=./drizzle.config.ts"
3043
- echo ""
3044
- echo " # For node-pg-migrate:"
3045
- echo " # npm run migrate up"
3046
- echo ""
3047
- echo " # For Knex:"
3048
- echo " # npx knex migrate:latest"
3049
- echo ""
3050
- echo " # For TypeORM:"
3051
- echo " # npm run typeorm migration:run"
3052
- echo ""
3053
- echo " # For custom migration scripts:"
3054
- echo " # node ./scripts/migrate.js"
3055
- echo ""
3056
- echo "Option 2: Skip migrations (only if your database is already set up):"
3057
- echo " Uncomment the line: # SKIP_MIGRATIONS=true"
3058
- echo ""
3059
- echo "========================================="
3060
- echo ""
3061
-
3062
3027
  # MIGRATION_COMMAND:
3063
3028
  # Add your migration command here. Examples using PROJECT_ROOT:
3064
3029
  # MIGRATION_COMMAND="cd $PROJECT_ROOT && npx prisma migrate deploy"
@@ -3076,7 +3041,7 @@ if [ -z "\${MIGRATION_COMMAND}" ] && [ -z "\${SKIP_MIGRATIONS}" ]; then
3076
3041
  echo " 1. Set MIGRATION_COMMAND with your migration command"
3077
3042
  echo " 2. Set SKIP_MIGRATIONS=true if migrations aren't needed"
3078
3043
  echo ""
3079
- echo " Tests cannot run without a properly migrated database schema."
3044
+ echo " See the comments above for examples."
3080
3045
  echo ""
3081
3046
  exit 1
3082
3047
  fi
@@ -3930,7 +3895,7 @@ async function generate(configPath) {
3930
3895
  });
3931
3896
  files.push({
3932
3897
  path: join(testDir, "run-tests.sh"),
3933
- content: emitTestScript(testFramework)
3898
+ content: emitTestScript(testFramework, testDir)
3934
3899
  });
3935
3900
  files.push({
3936
3901
  path: join(testDir, ".gitignore"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.6.15",
3
+ "version": "0.6.17",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {