@elench/testkit 0.1.8 → 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/infra/fly-up.sh CHANGED
@@ -31,8 +31,8 @@ DATABASE_URL=$(cat "$STATE_DIR/database_url")
31
31
  DB_URL_ENV_NAME="${DB_URL_ENV_NAME:-DATABASE_URL}"
32
32
  FLY_PORT="${FLY_PORT:-443:3000/tcp:tls:http}"
33
33
 
34
- # Load target-specific env flags (sets FLY_ENV_FLAGS)
35
- FLY_ENV_FLAGS=""
34
+ # Load target-specific env args (sets FLY_ENV_ARGS array)
35
+ FLY_ENV_ARGS=()
36
36
  if [ -n "$FLY_ENV_FILE" ] && [ -f "$FLY_ENV_FILE" ]; then
37
37
  # shellcheck disable=SC1090
38
38
  source "$FLY_ENV_FILE"
@@ -65,17 +65,16 @@ fi
65
65
  if [ -n "$MACHINE_ID" ]; then
66
66
  echo "Reusing machine $MACHINE_ID — updating config"
67
67
 
68
- # Build update flags: always update DATABASE_URL + target env
69
- UPDATE_FLAGS="--env $DB_URL_ENV_NAME=$DATABASE_URL $FLY_ENV_FLAGS"
68
+ # Build update args array: always update DATABASE_URL + target env
69
+ UPDATE_ARGS=(--env "$DB_URL_ENV_NAME=$DATABASE_URL" "${FLY_ENV_ARGS[@]}")
70
70
 
71
71
  # Only update image if one was provided (--build was used)
72
72
  if [ -n "$FLY_IMAGE" ]; then
73
- UPDATE_FLAGS="$UPDATE_FLAGS --image $FLY_IMAGE"
73
+ UPDATE_ARGS+=(--image "$FLY_IMAGE")
74
74
  fi
75
75
 
76
- # shellcheck disable=SC2086
77
76
  fly machines update "$MACHINE_ID" --app "$FLY_APP" \
78
- $UPDATE_FLAGS \
77
+ "${UPDATE_ARGS[@]}" \
79
78
  --yes 2>&1
80
79
 
81
80
  # Start if not already running (update may auto-restart)
@@ -92,14 +91,13 @@ if [ -z "$MACHINE_ID" ]; then
92
91
 
93
92
  echo "Creating Fly machine (app: $FLY_APP, region: $FLY_REGION)"
94
93
 
95
- # shellcheck disable=SC2086
96
94
  if ! RESULT=$(fly machines run "$FLY_IMAGE" \
97
95
  --app "$FLY_APP" \
98
96
  --region "$FLY_REGION" \
99
97
  --vm-memory 512 \
100
98
  --autostop=stop \
101
99
  --env "$DB_URL_ENV_NAME=$DATABASE_URL" \
102
- $FLY_ENV_FLAGS \
100
+ "${FLY_ENV_ARGS[@]}" \
103
101
  --port "$FLY_PORT" \
104
102
  2>&1); then
105
103
  echo "ERROR: fly machines run failed:"
package/infra/neon-up.sh CHANGED
@@ -96,7 +96,10 @@ fi
96
96
  echo "$CONN_URI" > "$STATE_DIR/database_url"
97
97
 
98
98
  # ── Reset test data ─────────────────────────────────────────────────────
99
- if command -v psql &>/dev/null; then
99
+ NEON_RESET="${NEON_RESET:-true}"
100
+ if [ "$NEON_RESET" = "false" ]; then
101
+ echo "Reset disabled — keeping fork data"
102
+ elif command -v psql &>/dev/null; then
100
103
  echo "Resetting test data..."
101
104
  psql "$CONN_URI" -q -c "
102
105
  DO \$\$
package/lib/config.mjs CHANGED
@@ -176,6 +176,9 @@ function validateService(name, svc, manifestPath) {
176
176
  } else {
177
177
  requireString(errors, tk.neon, `${ctx}: testkit.neon.projectId`, "projectId");
178
178
  requireString(errors, tk.neon, `${ctx}: testkit.neon.dbName`, "dbName");
179
+ if (tk.neon.reset !== undefined && typeof tk.neon.reset !== "boolean") {
180
+ errors.push(`${ctx}: testkit.neon.reset must be a boolean`);
181
+ }
179
182
  }
180
183
 
181
184
  if (!isObject(tk.fly)) {
package/lib/runner.mjs CHANGED
@@ -64,6 +64,7 @@ export async function neonUp(config) {
64
64
  NEON_PROJECT_ID: tk.neon.projectId,
65
65
  NEON_DB_NAME: tk.neon.dbName,
66
66
  NEON_BRANCH_NAME: tk.neon.branchName || `${config.name}-test`,
67
+ NEON_RESET: tk.neon.reset === false ? "false" : "true",
67
68
  STATE_DIR: stateDir,
68
69
  });
69
70
  }
@@ -75,16 +76,16 @@ export async function flyUp(config) {
75
76
  const { productDir, stateDir, manifest } = config;
76
77
  const tk = manifest.testkit;
77
78
 
78
- // Generate fly-env.sh from manifest
79
+ // Generate fly-env.sh from manifest (bash array for safe quoting)
79
80
  const envLines = [];
80
81
  for (const [k, v] of Object.entries(tk.fly.env || {})) {
81
- envLines.push(` --env ${k}=${v}`);
82
+ envLines.push(` --env "${k}=${v}"`);
82
83
  }
83
84
  for (const k of tk.fly.secrets || []) {
84
- envLines.push(` --env ${k}=$${k}`); // shell substitution at source-time
85
+ envLines.push(` --env "${k}=\${${k}}"`); // shell substitution at source-time
85
86
  }
86
87
  const flyEnvPath = path.join(stateDir, "fly-env.sh");
87
- fs.writeFileSync(flyEnvPath, `FLY_ENV_FLAGS="\n${envLines.join("\n")}\n"\n`);
88
+ fs.writeFileSync(flyEnvPath, `FLY_ENV_ARGS=(\n${envLines.join("\n")}\n)\n`);
88
89
 
89
90
  await runScript("fly-up.sh", {
90
91
  FLY_APP: tk.fly.app,
@@ -127,16 +128,16 @@ async function flyUpDep(config, dep) {
127
128
  fs.copyFileSync(primaryDbUrl, path.join(depStateDir, "database_url"));
128
129
  }
129
130
 
130
- // Generate fly-env.sh for dependent
131
+ // Generate fly-env.sh for dependent (bash array for safe quoting)
131
132
  const envLines = [];
132
133
  for (const [k, v] of Object.entries(dep.fly.env || {})) {
133
- envLines.push(` --env ${k}=${v}`);
134
+ envLines.push(` --env "${k}=${v}"`);
134
135
  }
135
136
  for (const k of dep.fly.secrets || []) {
136
- envLines.push(` --env ${k}=$${k}`); // shell substitution at source-time
137
+ envLines.push(` --env "${k}=\${${k}}"`); // shell substitution at source-time
137
138
  }
138
139
  const flyEnvPath = path.join(depStateDir, "fly-env.sh");
139
- fs.writeFileSync(flyEnvPath, `FLY_ENV_FLAGS="\n${envLines.join("\n")}\n"\n`);
140
+ fs.writeFileSync(flyEnvPath, `FLY_ENV_ARGS=(\n${envLines.join("\n")}\n)\n`);
140
141
 
141
142
  await runScript("fly-up.sh", {
142
143
  FLY_APP: dep.fly.app,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "CLI for running k6 tests against real, ephemeral infrastructure",
5
5
  "type": "module",
6
6
  "bin": {