← Commit history

add prepublish-check.sh: repair the mode bit before publishing

John Lauer ·6867543b6e ·1mo ago ·parent 72521f8
adom-wiki repo clone does not preserve file modes, and the registry requires scripts.install to be exactly ./install.sh for bootstrap packages (server-side validation rejects 'bash install.sh', so the executable bit cannot be designed away). Together those guarantee that a clone-edit-publish cycle ships install.sh un-runnable and every install fails with Permission denied. It has now happened three times: 0.4.0, 0.5.0 and 0.5.6. The publish linter does warn, but it is one line among many hints and a warning does not stop a publish. This repairs the modes and hard-fails if scripts.install has drifted.
1 file changed +36
prepublish-check.shadded+36
@@ -0,0 +1,36 @@+#!/usr/bin/env bash+# Run BEFORE `adom-wiki pkg publish`. Guards the one failure this package keeps shipping.+#+# WHY THIS EXISTS: `adom-wiki repo clone` does not preserve file modes, and the registry+# REQUIRES scripts.install to be exactly "./install.sh" for bootstrap packages (server-side+# validation rejects `bash install.sh`). Those two facts together mean a clone-edit-publish+# cycle ships install.sh with no executable bit, and every install then fails with+# Permission denied. It has happened three times: 0.4.0, 0.5.0, 0.5.6.+#+# The publish linter does warn, but it is one line inside a wall of hints, and a warning+# does not stop the publish.+set -euo pipefail+cd "$(dirname "${BASH_SOURCE[0]}")"++fail=0+for f in *.sh; do+    [ -f "$f" ] || continue+    if [ ! -x "$f" ]; then+        echo "FIXING: $f is not executable (repo clone drops the mode bit)"+        chmod +x "$f"+        fail=1+    fi+done++want='./install.sh'+got=$(python3 -c "import json;print((json.load(open('package.json')).get('scripts') or {}).get('install',''))")+if [ "$got" != "$want" ]; then+    echo "ERROR: scripts.install is '$got' but the registry requires '$want' for bootstrap packages" >&2+    exit 1+fi++if [ "$fail" -eq 1 ]; then+    echo "Mode bits repaired. Safe to publish."+else+    echo "OK: all *.sh executable, scripts.install correct."+fi