No entrypoint could change yarn.lock or go.mod: script/bootstrap installs with --frozen-lockfile, so adding a package meant running yarn by hand. make add-dependency PACKAGE=<name>@<version> shims to the new script/add-dependency: yarn add --dev, then yarn install --frozen-lockfile. make tidy shims to the new script/tidy, go mod tidy in backend/; a Go module is added by importing it, or moved by editing its require line, then make tidy. script/bootstrap is unchanged. Model: opus-5-5
This commit was merged in pull request #106.
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# script/add-dependency: add a frontend package, or move one to another
|
||||
# version, with yarn add, which changes package.json and yarn.lock
|
||||
# together; then install from yarn.lock with --frozen-lockfile, as
|
||||
# script/bootstrap does, to show it installs as written. --dev because
|
||||
# no frontend package is needed when the page runs: it ships as the
|
||||
# built dist/.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
usage() {
|
||||
echo "usage: make add-dependency PACKAGE=<name>@<version>" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
main() {
|
||||
# Exactly one package. A value beginning with - would reach yarn as
|
||||
# an option; yarn would quietly drop all but the first of several
|
||||
# packages given in one value.
|
||||
[ "$#" -eq 1 ] || usage
|
||||
case "$1" in
|
||||
"" | -* | *[[:space:]]*) usage ;;
|
||||
esac
|
||||
cd "$ROOT"
|
||||
yarn add --dev "$1"
|
||||
yarn install --frozen-lockfile
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# script/tidy: run go mod tidy in backend/, which adds the modules the
|
||||
# Go sources import, drops those they no longer do, and updates go.sum.
|
||||
set -eu
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd -P)"
|
||||
|
||||
main() {
|
||||
cd "$ROOT/backend"
|
||||
go mod tidy
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user