@willbooster/wb 21.0.2 → 21.1.0

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.
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+
3
+ set -eu
4
+
5
+ if [[ "$#" -eq 0 ]]; then
6
+ echo "Usage: apply-docker-env.sh <command> [args...]" >&2
7
+ exit 64
8
+ fi
9
+
10
+ # Applies the baked non-secret env file (`wb gen-docker-env` output) before running the given
11
+ # command, passing only keys absent from the inherited environment, so build args and
12
+ # platform-injected runtime values — including deliberately empty ones — always win over the
13
+ # baked defaults (colon-less `${KEY=...}` semantics).
14
+ # An explicitly configured path must exist: silently starting without the baked configuration
15
+ # would be the very silent-degradation mode this helper exists to prevent.
16
+ if [[ -n "${DOCKER_ENV_PATH:-}" && ! -f "$DOCKER_ENV_PATH" ]]; then
17
+ echo "apply-docker-env.sh: DOCKER_ENV_PATH=$DOCKER_ENV_PATH does not exist." >&2
18
+ exit 1
19
+ fi
20
+
21
+ # Inherited environment variables that share this script's internal names (they are all valid
22
+ # baked keys too) would be clobbered by the parsing below, so their original values are queued
23
+ # as leading `env` assignments — placed after the baked ones, they always win. Direct
24
+ # parameter expansion (not command substitution) preserves trailing newlines in the values.
25
+ if printenv env_path > /dev/null; then set -- "env_path=${env_path:-}" "$@"; fi
26
+ if printenv candidate > /dev/null; then set -- "candidate=${candidate:-}" "$@"; fi
27
+ if printenv line > /dev/null; then set -- "line=${line:-}" "$@"; fi
28
+ if printenv key > /dev/null; then set -- "key=${key:-}" "$@"; fi
29
+ if printenv value > /dev/null; then set -- "value=${value:-}" "$@"; fi
30
+ if printenv assignments > /dev/null; then set -- "assignments=${assignments:-}" "$@"; fi
31
+
32
+ env_path="${DOCKER_ENV_PATH:-}"
33
+ if [[ -z "$env_path" ]]; then
34
+ for candidate in ./.docker.env ./.env; do
35
+ if [[ -f "$candidate" ]]; then
36
+ env_path="$candidate"
37
+ break
38
+ fi
39
+ done
40
+ fi
41
+
42
+ # The applied values are handed to the child via `env` instead of shell assignments, so Bash
43
+ # readonly names (UID, EUID, ...) are valid baked keys.
44
+ assignments=()
45
+ if [[ -n "$env_path" ]]; then
46
+ # `|| [[ -n "$line" ]]` keeps a final line that lacks a trailing newline.
47
+ while IFS= read -r line || [[ -n "$line" ]]; do
48
+ key="${line%%=*}"
49
+ [[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] || continue
50
+ # printenv inspects the inherited process environment, so a platform value deliberately
51
+ # set to the empty string survives and shell-internal names do not shadow baked keys.
52
+ printenv "$key" > /dev/null && continue
53
+ # Evaluate only the (single-quoted) value.
54
+ eval "value=${line#*=}"
55
+ assignments+=("$key=$value")
56
+ done < "$env_path"
57
+ fi
58
+
59
+ # Always route through env: with no assignments it simply runs the command, and a restored
60
+ # KEY=VALUE at the head of "$@" is then interpreted as an assignment, never as the command.
61
+ exec env ${assignments+"${assignments[@]}"} "$@"
@@ -7,6 +7,25 @@ if [[ "$#" -eq 0 ]]; then
7
7
  exit 64
8
8
  fi
9
9
 
10
+ # Fail fast when the config references environment variables (e.g. the ${VAR} placeholders of
11
+ # `wb db create-litestream-config --env-refs`) that the platform did not supply: Litestream
12
+ # itself only logs and retries replica errors, which would silently disable backups.
13
+ # LITESTREAM_CONFIG is Litestream's own config-path override, so the validated file is always
14
+ # the file `litestream replicate` below actually reads.
15
+ config_path="${LITESTREAM_CONFIG:-/etc/litestream.yml}"
16
+ if [[ -f "$config_path" ]]; then
17
+ # Full-line YAML comments are stripped first: a documentation example mentioning ${VAR} must
18
+ # not become a runtime dependency. Inline comments are kept because a textual strip cannot
19
+ # tell a comment from a `#` inside a quoted scalar, and a missed placeholder (silent backup
20
+ # loss) is worse than a spurious requirement from an inline comment.
21
+ while IFS= read -r key; do
22
+ if [[ -z "$(printenv "$key" || true)" ]]; then
23
+ echo "run-litestream.sh: environment variable $key is required by $config_path but is not set." >&2
24
+ exit 1
25
+ fi
26
+ done < <(sed -e '/^[[:space:]]*#/d' "$config_path" | grep -o '\${[A-Za-z_][A-Za-z0-9_]*}' | tr -d '${}' | sort -u)
27
+ fi
28
+
10
29
  litestream replicate -exec "$*" &
11
30
  litestream_pid=$!
12
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/wb",
3
- "version": "21.0.2",
3
+ "version": "21.1.0",
4
4
  "description": "CLI tool for WillBooster projects",
5
5
  "repository": {
6
6
  "type": "git",