@willbooster/wbfy 17.0.1 → 18.0.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.
- package/configs/applyReleaseAgeGate.sh +81 -0
- package/configs/releaseAgeGate.json +31 -0
- package/dist/index.js +101 -111
- package/package.json +3 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Writes the organization's minimum-release-age policy — releaseAgeGate.json next to this script is
|
|
3
|
+
# its single source of truth — into the global package-manager configs of the user running it:
|
|
4
|
+
# ~/.npmrc (npm, bun, yarn 1), ~/.yarnrc.yml (Yarn Berry), ~/.bunfig.toml (bun) and bun's copies
|
|
5
|
+
# under $XDG_CONFIG_HOME. Run it once per user whose configs must be gated: `sudo -H env -u
|
|
6
|
+
# XDG_CONFIG_HOME bash applyReleaseAgeGate.sh` covers root, whose configs `sudo npm install
|
|
7
|
+
# --global` reads.
|
|
8
|
+
#
|
|
9
|
+
# Every managed setting is rewritten on each run, so a hand-weakened gate never survives:
|
|
10
|
+
# - .npmrc and .yarnrc.yml keep every setting except the gate keys, because npm and Yarn append
|
|
11
|
+
# settings a user writes later (e.g. `npm config set`, `yarn config set --home`) below them.
|
|
12
|
+
# $NPMRC_HEADER / $YARNRC_HEADER replace what is kept when the caller provisions those settings
|
|
13
|
+
# itself (self-host-utils passes the Takumi Guard proxy that way).
|
|
14
|
+
# - .bunfig.toml is replaced wholesale: bun reads its registry settings and credentials from
|
|
15
|
+
# .npmrc, so the organization keeps nothing else in this file.
|
|
16
|
+
#
|
|
17
|
+
# A failed write aborts the run instead of moving on: leaving some package managers ungated must be
|
|
18
|
+
# reported, not silently downgraded. Only up-to-date package managers are supported: npm >= 12
|
|
19
|
+
# (`min-release-age-exclude`), Yarn Berry >= 4.11 (`npmMinimalAgeGate`) and bun >= 1.3
|
|
20
|
+
# (`minimumReleaseAge`) — older ones must be upgraded instead of accommodated.
|
|
21
|
+
|
|
22
|
+
set -euo pipefail
|
|
23
|
+
umask 077
|
|
24
|
+
|
|
25
|
+
gateJsonPath="$(dirname "${BASH_SOURCE[0]}")/releaseAgeGate.json"
|
|
26
|
+
days=$(sed -n 's/.*"days"[^0-9]*\([0-9]*\).*/\1/p' "$gateJsonPath")
|
|
27
|
+
# `sed -n …p` prints only on a match, so a truncated array (no closing bracket) yields nothing.
|
|
28
|
+
excludes=$(tr -d ' \n' < "$gateJsonPath" | sed -n 's/.*"excludes":\[\(.*\)].*/\1/p' | tr -d '"' | tr ',' '\n')
|
|
29
|
+
# Without this, a truncated or stale JSON would write a disabled gate (`min-release-age=`,
|
|
30
|
+
# `minimumReleaseAge = 0`) or a silently shortened exclusion list while reporting success.
|
|
31
|
+
[ "$days" -gt 0 ] 2> /dev/null && [ -n "$excludes" ] ||
|
|
32
|
+
{ echo "$gateJsonPath is not a valid release-age gate." >&2; exit 1; }
|
|
33
|
+
|
|
34
|
+
emitHeader() {
|
|
35
|
+
[ -n "$1" ] && printf '%s\n' "$1"
|
|
36
|
+
return 0
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# `! [ -e … ] ||` skips an absent file but lets a read failure abort the run: overwriting a config
|
|
40
|
+
# whose current settings could not be read would silently drop them.
|
|
41
|
+
npmrcHeader=${NPMRC_HEADER-$(! [ -e "$HOME/.npmrc" ] || sed '/^min-release-age/d' "$HOME/.npmrc")}
|
|
42
|
+
# Drop the two managed top-level keys with their indented values, keep every other key.
|
|
43
|
+
yarnrcHeader=${YARNRC_HEADER-$(! [ -e "$HOME/.yarnrc.yml" ] || awk '
|
|
44
|
+
/^[^ ]/ { drop = ($1 == "npmMinimalAgeGate:" || $1 == "npmPreapprovedPackages:") }
|
|
45
|
+
!drop' "$HOME/.yarnrc.yml")}
|
|
46
|
+
|
|
47
|
+
npmrc=$(
|
|
48
|
+
emitHeader "$npmrcHeader"
|
|
49
|
+
echo "min-release-age=$days"
|
|
50
|
+
echo "$excludes" | sed 's|^|min-release-age-exclude[]=|'
|
|
51
|
+
)
|
|
52
|
+
# Minutes as a plain number: Yarn parses a unit-less value in the setting's own unit, while duration
|
|
53
|
+
# strings were misparsed by pre-DURATION versions of the setting (yarnpkg/berry#6942).
|
|
54
|
+
yarnrc=$(
|
|
55
|
+
emitHeader "$yarnrcHeader"
|
|
56
|
+
echo "npmMinimalAgeGate: $((days * 24 * 60))"
|
|
57
|
+
echo 'npmPreapprovedPackages:'
|
|
58
|
+
echo "$excludes" | sed "s|^| - '|; s|$|'|"
|
|
59
|
+
)
|
|
60
|
+
bunfig=$(
|
|
61
|
+
echo '[install]'
|
|
62
|
+
echo "minimumReleaseAge = $((days * 24 * 60 * 60))"
|
|
63
|
+
echo 'minimumReleaseAgeExcludes = ['
|
|
64
|
+
echo "$excludes" | sed 's|^| "|; s|$|",|'
|
|
65
|
+
echo ']'
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
printf '%s\n' "$npmrc" > "$HOME/.npmrc"
|
|
69
|
+
printf '%s\n' "$yarnrc" > "$HOME/.yarnrc.yml"
|
|
70
|
+
printf '%s\n' "$bunfig" > "$HOME/.bunfig.toml"
|
|
71
|
+
|
|
72
|
+
# Once $XDG_CONFIG_HOME is set, bun reads BOTH its .bunfig.toml and its .npmrc from there and never
|
|
73
|
+
# falls back to $HOME (verified with bun 1.3.14), so its installs would otherwise run ungated and
|
|
74
|
+
# bypass the registry settings. npm and Yarn Berry always read $HOME, hence no .yarnrc.yml here.
|
|
75
|
+
if [ -n "${XDG_CONFIG_HOME:-}" ]; then
|
|
76
|
+
mkdir -p "$XDG_CONFIG_HOME"
|
|
77
|
+
printf '%s\n' "$npmrc" > "$XDG_CONFIG_HOME/.npmrc"
|
|
78
|
+
printf '%s\n' "$bunfig" > "$XDG_CONFIG_HOME/.bunfig.toml"
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
echo "Applied the ${days}-day minimum-release-age policy to ${HOME}'s global package-manager configs."
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"days": 7,
|
|
3
|
+
"excludes": [
|
|
4
|
+
"@exercode/problem-utils",
|
|
5
|
+
"@willbooster-private/agentic-workflows",
|
|
6
|
+
"@willbooster-private/ai-ocr",
|
|
7
|
+
"@willbooster-private/judge",
|
|
8
|
+
"@willbooster-private/llm-proxy",
|
|
9
|
+
"@willbooster/agent-skills",
|
|
10
|
+
"@willbooster/babel-configs",
|
|
11
|
+
"@willbooster/monaco-loader",
|
|
12
|
+
"@willbooster/monaco-react",
|
|
13
|
+
"@willbooster/oxfmt-config",
|
|
14
|
+
"@willbooster/oxlint-config",
|
|
15
|
+
"@willbooster/prettier-config",
|
|
16
|
+
"@willbooster/react-frame-component",
|
|
17
|
+
"@willbooster/shared-lib",
|
|
18
|
+
"@willbooster/shared-lib-blitz-next",
|
|
19
|
+
"@willbooster/shared-lib-next",
|
|
20
|
+
"@willbooster/shared-lib-node",
|
|
21
|
+
"@willbooster/shared-lib-react",
|
|
22
|
+
"@willbooster/wb",
|
|
23
|
+
"@willbooster/wbfy",
|
|
24
|
+
"agent-runtime-kit",
|
|
25
|
+
"at-decorators",
|
|
26
|
+
"build-ts",
|
|
27
|
+
"gen-i18n-ts",
|
|
28
|
+
"one-way-git-sync",
|
|
29
|
+
"vinext-progress"
|
|
30
|
+
]
|
|
31
|
+
}
|