Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/portability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ jobs:

- name: Self-conformance (the library is itself lossless here)
run: bin/rosetta selftest

- name: README status block is current (scripts/readme-sync.sh --check)
run: sh scripts/readme-sync.sh --check
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
if [ "$PKG" != "$TAG" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match package.json version $PKG"; exit 1
fi
- name: README status block matches this version (no stale docs ship)
run: sh scripts/readme-sync.sh --check
- name: Publish to npm (with provenance)
run: npm publish --provenance --access public
env:
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
> natively in **bash 3.2 ↔ zsh ↔ POSIX sh** (and ksh) with byte-identical
> behavior. Think i18n, but for shells: **service localization** for scripts.

**License:** MIT · **Status:** v0.1.0 (draft) · **Locales verified:** bash 3.2.57,
<!-- readme-sync:begin (generated by scripts/readme-sync.sh; edit package.json or web/SURFACES.tsv) -->
**License:** MIT · **Status:** v0.1.3 · **Locales verified:** bash 3.2.57,
bash 5.3, zsh 5.9, dash (POSIX), /bin/sh, ksh93 — all against one shared
[conformance suite](conformance/).

**Try it live:**

- [Rosetta Voice](https://rosetta-shell.arcs.care/voice): say or type a shell construct and hear the portable fix, with what was heard shown word for word
<!-- readme-sync:end -->

**In one line:** the constructs that silently break a script when it moves
environments — associative arrays, `${v,,}`, arrays, `echo -e`, process
substitution — get one portable shim each, and a conformance runner proves the
Expand Down
6 changes: 6 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ npm version patch # or minor / major — bumps package.json AND makes the g
git push --follow-tags
```

`npm version` also runs `scripts/readme-sync.sh` (the `version` script in
package.json), so the README status block and its live-surface list land in
the same tag commit. `test.sh` fails if that block is stale, so a release
cannot ship docs that disagree with package.json. To add a live surface, add a
row to `web/SURFACES.tsv`, never edit the block by hand.

That's it. The `release` workflow fires on the `v*` tag and:
1. verifies the tag matches `package.json`,
2. `npm publish --provenance --access public`,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"LICENSE"
],
"scripts": {
"test": "sh test.sh"
"test": "sh test.sh",
"version": "sh scripts/readme-sync.sh && git add README.md"
},
"keywords": [
"shell",
Expand Down
53 changes: 53 additions & 0 deletions scripts/readme-sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env sh
# readme-sync.sh: render README.md's status block from package.json + web/SURFACES.tsv.
# Idempotent: running it twice changes nothing. The README block is a cast; this is the mold.
# sh scripts/readme-sync.sh rewrite the block in place
# sh scripts/readme-sync.sh --check exit 1 if the block is stale (test.sh runs this)
# npm's "version" lifecycle runs it, so `npm version <x>` folds the new version into the tag commit.
set -eu
_self=$0
case "$_self" in */*) _dir=${_self%/*} ;; *) _dir=. ;; esac
ROOT=$(cd "$_dir/.." && pwd)
README="$ROOT/README.md"
BEGIN='<!-- readme-sync:begin (generated by scripts/readme-sync.sh; edit package.json or web/SURFACES.tsv) -->'
END='<!-- readme-sync:end -->'

[ -f "$ROOT/web/SURFACES.tsv" ] || { echo "readme-sync: web/SURFACES.tsv missing" >&2; exit 2; }
ver=$(sed -n 's/^[[:space:]]*"version":[[:space:]]*"\([^"]*\)".*/\1/p' "$ROOT/package.json" | head -n 1)
[ -n "$ver" ] || { echo "readme-sync: no version in package.json" >&2; exit 2; }

block=$(mktemp); out=$(mktemp)
trap 'rm -f "$block" "$out"' EXIT
{
echo "$BEGIN"
echo "**License:** MIT · **Status:** v$ver · **Locales verified:** bash 3.2.57,"
echo "bash 5.3, zsh 5.9, dash (POSIX), /bin/sh, ksh93 — all against one shared"
echo "[conformance suite](conformance/)."
_tab=$(printf '\t')
grep -v '^#' "$ROOT/web/SURFACES.tsv" | grep -v '^[[:space:]]*$' | {
_first=1
while IFS="$_tab" read -r url label what; do
if [ "$_first" = 1 ]; then echo; echo "**Try it live:**"; echo; _first=0; fi
echo "- [$label]($url): $what"
done
}
echo "$END"
} > "$block"

grep -qF "$BEGIN" "$README" || { echo "readme-sync: begin marker missing in README.md" >&2; exit 2; }
grep -qF "$END" "$README" || { echo "readme-sync: end marker missing in README.md" >&2; exit 2; }

awk -v b="$BEGIN" -v e="$END" -v f="$block" '
$0 == b { while ((getline l < f) > 0) print l; skip = 1; next }
$0 == e { skip = 0; next }
!skip { print }
' "$README" > "$out"

if [ "${1:-}" = "--check" ]; then
if cmp -s "$README" "$out"; then echo " [PASS] README status block matches package.json v$ver + web/SURFACES.tsv"; exit 0; fi
echo "FAIL: README.md status block is stale; run: sh scripts/readme-sync.sh" >&2
diff "$README" "$out" >&2 || true
exit 1
fi
cmp -s "$README" "$out" || cat "$out" > "$README"
echo "readme-sync: README.md at v$ver"
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ else
echo " [SKIP] no web/ in this copy"
fi

echo
echo "# README status block matches package.json and web/SURFACES.tsv"
sh "$ROOT/scripts/readme-sync.sh" --check

echo
echo "ALL SMOKE CHECKS PASSED"
2 changes: 2 additions & 0 deletions web/SURFACES.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# url<TAB>label<TAB>what it does. One row per live surface; scripts/readme-sync.sh renders these into README.md.
https://rosetta-shell.arcs.care/voice Rosetta Voice say or type a shell construct and hear the portable fix, with what was heard shown word for word
Loading