@willbooster/wbfy 18.0.1 → 18.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.
- package/configs/applyReleaseAgeGate.sh +30 -6
- package/dist/index.js +2 -1
- package/package.json +2 -2
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
#
|
|
17
17
|
# A failed write aborts the run instead of moving on: leaving some package managers ungated must be
|
|
18
18
|
# reported, not silently downgraded. Only up-to-date package managers are supported: npm >= 12
|
|
19
|
-
# (`min-release-age-exclude`), Yarn Berry >= 4.
|
|
19
|
+
# (`min-release-age-exclude`), Yarn Berry >= 4.10.3 (`npmMinimalAgeGate`) and bun >= 1.3
|
|
20
20
|
# (`minimumReleaseAge`) — older ones must be upgraded instead of accommodated.
|
|
21
21
|
|
|
22
22
|
set -euo pipefail
|
|
@@ -65,17 +65,41 @@ bunfig=$(
|
|
|
65
65
|
echo ']'
|
|
66
66
|
)
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
# Staged and renamed into place: a package manager installing on this machine while the configs are
|
|
69
|
+
# rewritten must never read a half-written file and resolve packages ungated or from the wrong
|
|
70
|
+
# registry. It also replaces a pre-existing symlink instead of writing through it.
|
|
71
|
+
# The staging file holds the credentials kept from the existing config, so an aborted or signalled
|
|
72
|
+
# run must not leave it behind. One write finishes before the next starts, so a single global path
|
|
73
|
+
# covers them all.
|
|
74
|
+
staging=''
|
|
75
|
+
trap 'rm -f "$staging"' EXIT
|
|
76
|
+
# Explicit exits: a cleanup-only signal trap would swallow the signal, and the run would go on to
|
|
77
|
+
# finish and report success after being cancelled.
|
|
78
|
+
trap 'exit 130' INT
|
|
79
|
+
trap 'exit 143' TERM
|
|
80
|
+
|
|
81
|
+
writeFile() { # $1: content, $2: destination
|
|
82
|
+
# `mv` would move the staging file INTO a destination directory and report success, leaving the
|
|
83
|
+
# config unwritten while this script claims the policy was applied.
|
|
84
|
+
[ ! -d "$2" ] || { echo "$2 is a directory, not a package-manager config." >&2; exit 1; }
|
|
85
|
+
# mktemp, not a fixed name: two concurrent runs would otherwise publish each other's half-written
|
|
86
|
+
# staging file. It also creates the file with mode 600, which the rename preserves.
|
|
87
|
+
staging=$(mktemp "$2.XXXXXX")
|
|
88
|
+
printf '%s\n' "$1" > "$staging"
|
|
89
|
+
mv -f "$staging" "$2"
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
writeFile "$npmrc" "$HOME/.npmrc"
|
|
93
|
+
writeFile "$yarnrc" "$HOME/.yarnrc.yml"
|
|
94
|
+
writeFile "$bunfig" "$HOME/.bunfig.toml"
|
|
71
95
|
|
|
72
96
|
# Once $XDG_CONFIG_HOME is set, bun reads BOTH its .bunfig.toml and its .npmrc from there and never
|
|
73
97
|
# falls back to $HOME (verified with bun 1.3.14), so its installs would otherwise run ungated and
|
|
74
98
|
# bypass the registry settings. npm and Yarn Berry always read $HOME, hence no .yarnrc.yml here.
|
|
75
99
|
if [ -n "${XDG_CONFIG_HOME:-}" ]; then
|
|
76
100
|
mkdir -p "$XDG_CONFIG_HOME"
|
|
77
|
-
|
|
78
|
-
|
|
101
|
+
writeFile "$npmrc" "$XDG_CONFIG_HOME/.npmrc"
|
|
102
|
+
writeFile "$bunfig" "$XDG_CONFIG_HOME/.bunfig.toml"
|
|
79
103
|
fi
|
|
80
104
|
|
|
81
105
|
echo "Applied the ${days}-day minimum-release-age policy to ${HOME}'s global package-manager configs."
|