@willbooster/wb 19.6.1 → 19.7.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,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Force-overwrites the npm / yarn / bun config files inside a Docker image with the
|
|
4
|
+
# organization-standard content. The release-age gate values come from the wbfy-generated
|
|
5
|
+
# bunfig.toml in the current directory, so the image needs no other source of the org policy.
|
|
6
|
+
#
|
|
7
|
+
# Unconditional overwrites are intentional: images never hold package-manager credentials
|
|
8
|
+
# (private packages are materialized on the host; see WillBooster/shared#964), and a production
|
|
9
|
+
# image never runs `bun test`, so existing config lines and `[test]` sections need no preserving.
|
|
10
|
+
# Like the wbfy global gate, this assumes up-to-date package managers (e.g. Yarn >= 4.10 for
|
|
11
|
+
# npmMinimalAgeGate); older versions must be upgraded, not accommodated.
|
|
12
|
+
|
|
13
|
+
set -euo pipefail
|
|
14
|
+
|
|
15
|
+
seconds=$(sed -n 's/^minimumReleaseAge = \([0-9]*\).*/\1/p' bunfig.toml)
|
|
16
|
+
# sed exits 0 on no match, so an unregenerated bunfig.toml (older than wbfy's gate) must be
|
|
17
|
+
# rejected here; otherwise the gate silently becomes 0 and the generated bunfig.toml is invalid.
|
|
18
|
+
case "${seconds}" in
|
|
19
|
+
'' | *[!0-9]*)
|
|
20
|
+
echo 'bunfig.toml has no numeric minimumReleaseAge; run wbfy to regenerate it.' >&2
|
|
21
|
+
exit 1
|
|
22
|
+
;;
|
|
23
|
+
esac
|
|
24
|
+
excludes=$(sed -n '/^minimumReleaseAgeExcludes = \[/,/^]/s/^[[:space:]]*"\(.*\)",$/\1/p' bunfig.toml)
|
|
25
|
+
days=$((seconds / 86400))
|
|
26
|
+
minutes=$((seconds / 60))
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
echo "min-release-age=${days}"
|
|
30
|
+
for package in ${excludes}; do
|
|
31
|
+
echo "min-release-age-exclude[]=${package}"
|
|
32
|
+
done
|
|
33
|
+
} > ~/.npmrc
|
|
34
|
+
|
|
35
|
+
{
|
|
36
|
+
echo "npmMinimalAgeGate: ${minutes} # ${days} days"
|
|
37
|
+
echo 'npmPreapprovedPackages:'
|
|
38
|
+
for package in ${excludes}; do
|
|
39
|
+
echo " - '${package}'"
|
|
40
|
+
done
|
|
41
|
+
} > ~/.yarnrc.yml
|
|
42
|
+
|
|
43
|
+
# Keep the wbfy-generated bunfig.toml as the single source of the Bun settings; drop only the
|
|
44
|
+
# project-owned [test] sections and force globalStore off (a single-use image never reuses a
|
|
45
|
+
# global store, and store symlinks outside the project root break multi-stage COPY of
|
|
46
|
+
# node_modules).
|
|
47
|
+
awk '/^\[/ { inTestSection = ($0 ~ /^\[test/) } !inTestSection' bunfig.toml |
|
|
48
|
+
sed 's/^globalStore = true$/globalStore = false/' > bunfig.toml.tmp
|
|
49
|
+
mv bunfig.toml.tmp bunfig.toml
|