@elench/testkit 0.1.8 → 0.1.9

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/lib/runner.mjs CHANGED
@@ -75,16 +75,16 @@ export async function flyUp(config) {
75
75
  const { productDir, stateDir, manifest } = config;
76
76
  const tk = manifest.testkit;
77
77
 
78
- // Generate fly-env.sh from manifest
78
+ // Generate fly-env.sh from manifest (bash array for safe quoting)
79
79
  const envLines = [];
80
80
  for (const [k, v] of Object.entries(tk.fly.env || {})) {
81
- envLines.push(` --env ${k}=${v}`);
81
+ envLines.push(` --env "${k}=${v}"`);
82
82
  }
83
83
  for (const k of tk.fly.secrets || []) {
84
- envLines.push(` --env ${k}=$${k}`); // shell substitution at source-time
84
+ envLines.push(` --env "${k}=\${${k}}"`); // shell substitution at source-time
85
85
  }
86
86
  const flyEnvPath = path.join(stateDir, "fly-env.sh");
87
- fs.writeFileSync(flyEnvPath, `FLY_ENV_FLAGS="\n${envLines.join("\n")}\n"\n`);
87
+ fs.writeFileSync(flyEnvPath, `FLY_ENV_ARGS=(\n${envLines.join("\n")}\n)\n`);
88
88
 
89
89
  await runScript("fly-up.sh", {
90
90
  FLY_APP: tk.fly.app,
@@ -127,16 +127,16 @@ async function flyUpDep(config, dep) {
127
127
  fs.copyFileSync(primaryDbUrl, path.join(depStateDir, "database_url"));
128
128
  }
129
129
 
130
- // Generate fly-env.sh for dependent
130
+ // Generate fly-env.sh for dependent (bash array for safe quoting)
131
131
  const envLines = [];
132
132
  for (const [k, v] of Object.entries(dep.fly.env || {})) {
133
- envLines.push(` --env ${k}=${v}`);
133
+ envLines.push(` --env "${k}=${v}"`);
134
134
  }
135
135
  for (const k of dep.fly.secrets || []) {
136
- envLines.push(` --env ${k}=$${k}`); // shell substitution at source-time
136
+ envLines.push(` --env "${k}=\${${k}}"`); // shell substitution at source-time
137
137
  }
138
138
  const flyEnvPath = path.join(depStateDir, "fly-env.sh");
139
- fs.writeFileSync(flyEnvPath, `FLY_ENV_FLAGS="\n${envLines.join("\n")}\n"\n`);
139
+ fs.writeFileSync(flyEnvPath, `FLY_ENV_ARGS=(\n${envLines.join("\n")}\n)\n`);
140
140
 
141
141
  await runScript("fly-up.sh", {
142
142
  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.9",
4
4
  "description": "CLI for running k6 tests against real, ephemeral infrastructure",
5
5
  "type": "module",
6
6
  "bin": {