@willbooster/wb 21.0.3 → 21.1.1

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,46 @@
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
+
15
+ # Inherited environment variables that share this script's internal names (they are all valid
16
+ # baked keys too) would be clobbered by the parsing below, so their original values are queued
17
+ # as leading `env` assignments — placed after the baked ones, they always win. Direct
18
+ # parameter expansion (not command substitution) preserves trailing newlines in the values.
19
+ if printenv env_path > /dev/null; then set -- "env_path=${env_path:-}" "$@"; fi
20
+ if printenv line > /dev/null; then set -- "line=${line:-}" "$@"; fi
21
+ if printenv key > /dev/null; then set -- "key=${key:-}" "$@"; fi
22
+ if printenv value > /dev/null; then set -- "value=${value:-}" "$@"; fi
23
+ if printenv assignments > /dev/null; then set -- "assignments=${assignments:-}" "$@"; fi
24
+
25
+ env_path=./.docker.env
26
+
27
+ # The applied values are handed to the child via `env` instead of shell assignments, so Bash
28
+ # readonly names (UID, EUID, ...) are valid baked keys.
29
+ assignments=()
30
+ if [[ -f "$env_path" ]]; then
31
+ # `|| [[ -n "$line" ]]` keeps a final line that lacks a trailing newline.
32
+ while IFS= read -r line || [[ -n "$line" ]]; do
33
+ key="${line%%=*}"
34
+ [[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]] || continue
35
+ # printenv inspects the inherited process environment, so a platform value deliberately
36
+ # set to the empty string survives and shell-internal names do not shadow baked keys.
37
+ printenv "$key" > /dev/null && continue
38
+ # Evaluate only the (single-quoted) value.
39
+ eval "value=${line#*=}"
40
+ assignments+=("$key=$value")
41
+ done < "$env_path"
42
+ fi
43
+
44
+ # Always route through env: with no assignments it simply runs the command, and a restored
45
+ # KEY=VALUE at the head of "$@" is then interpreted as an assignment, never as the command.
46
+ 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.3",
3
+ "version": "21.1.1",
4
4
  "description": "CLI tool for WillBooster projects",
5
5
  "repository": {
6
6
  "type": "git",