Extract Alpine.js in script/test so the pre-commit hook works
check / check (push) Successful in 3m15s

The extraction moves from the Makefile's assets target into
script/assets. script/test runs it before the tests, so make test,
make check, script/check and the pre-commit hook all get the file on a
fresh clone; make assets, make build and make dev call the same script.
The README now says only that nothing downloads Alpine.js.

Model: opus-5-5
This commit is contained in:
2026-09-29 10:21:23 +00:00
parent 4df11f5de8
commit 98fe2a9e12
5 changed files with 40 additions and 25 deletions
+19 -18
View File
@@ -1247,16 +1247,16 @@ What that means for an operator:
This repository adheres to the
[Scripts to Rule Them All](https://github.com/github/scripts-to-rule-them-all)
standard: normalized scripts in `script/` are the entrypoints for the
development workflow. Nine of the Makefile's seventeen targets are thin
shims that call them; `assets`, `build`, `run`, `dev`, `deps`, `clean`,
`css` and `version` are inline commands with no script behind them,
though `build` and `version` both take their value from
`script/version`.
development workflow. Ten of the Makefile's seventeen targets are thin
shims that call them; `build`, `run`, `dev`, `deps`, `clean`, `css` and
`version` are inline commands with no script behind them, though `build`
and `version` both take their value from `script/version`.
`make test`, `make check`, `make build` and `make dev` each run
`make assets` first, which writes the ignored `static/js/alpine.min.js`
(see [Third-party browser assets](#third-party-browser-assets)), so
`make check` works on a fresh clone without a separate setup step.
`script/test`, `make build` and `make dev` each run `script/assets`
first, which writes the ignored `static/js/alpine.min.js` (see
[Third-party browser assets](#third-party-browser-assets)), so
`make test`, `make check` and the pre-commit hook work on a fresh clone
without a separate step.
We provide:
@@ -1264,6 +1264,8 @@ We provide:
- `script/setup` — make a fresh clone ready for development
(bootstrap, then install-precommit)
- `script/projectname` — output the project name ("webhooker")
- `script/assets` — extract Alpine.js from its tarball in `3p/` (see
[Third-party browser assets](#third-party-browser-assets))
- `script/test` — run the test suite
- `script/lint` — run golangci-lint in Docker (see Linting below)
- `script/fmt` — format all code (writes)
@@ -1292,19 +1294,18 @@ publishes it. It is a dependency, not this repo's build output, so
The directory is `3p/` rather than `vendor/` because Go treats a root
`vendor/` directory as its module vendor directory.
`make assets` extracts the browser build, `package/dist/cdn.min.js`, from the
tarball to `static/js/alpine.min.js`, where `go:embed` picks it up.
`make test`, `make check`, `make build` and `make dev` run it first, and the
Dockerfile builds through them, so no build downloads anything. The extracted
file is not committed, and `.dockerignore` keeps any host copy out of the
build context.
`script/assets` (`make assets`) extracts the browser build,
`package/dist/cdn.min.js`, from the tarball to `static/js/alpine.min.js`,
where `go:embed` picks it up. `script/test`, `make build` and `make dev` run
it first, and the Dockerfile builds through `make test` and `make build`, so
nothing downloads Alpine.js. The extracted file is not committed, and
`.dockerignore` keeps any host copy out of the build context.
To move to a new version: download
`https://registry.npmjs.org/alpinejs/-/alpinejs-<version>.tgz`, check it
against the `dist.integrity` hash listed at
`https://registry.npmjs.org/alpinejs/<version>`, replace the tarball in `3p/`
with it, update its file name in the Makefile's `assets` target, and run
`make check`.
with it, update its file name in `script/assets`, and run `make check`.
## Rationale
@@ -2883,7 +2884,7 @@ webhooker/
├── script/ # Scripts to Rule Them All entrypoints
├── Dockerfile # Three stages: lint, test+build, Alpine runtime
├── Dockerfile.lint # Lint-only image built by script/lint
├── Makefile # 9 of 17 targets shim script/; 8 are inline
├── Makefile # 10 of 17 targets shim script/; 7 are inline
├── go.mod / go.sum
└── .golangci.yml # Linter configuration
```