19 lines
894 B
Shell
19 lines
894 B
Shell
|
|
#!/bin/sh
|
||
|
|
# Narrows the workspace in ./pubspec.yaml to the members named, for an image that builds
|
||
|
|
# only those (the Dockerfiles of Learn's server and curator): pub then resolves without
|
||
|
|
# the other members, whose folders the image doesn't hold. Fails if one named isn't a
|
||
|
|
# member, so a renamed package fails the build loudly.
|
||
|
|
#
|
||
|
|
# sh tool/workspace_only.sh apps/learn/halkyon_learn_server packages/halkyon_base_server
|
||
|
|
set -eu
|
||
|
|
awk -v keep="$*" '
|
||
|
|
BEGIN { n = split(keep, k, " "); for (i = 1; i <= n; i++) wanted[" - " k[i]] = 1 }
|
||
|
|
/^workspace:/ { block = 1; print; next }
|
||
|
|
block && /^ - / { if ($0 in wanted) { print; found[$0] = 1 }; next }
|
||
|
|
{ block = 0; print }
|
||
|
|
END {
|
||
|
|
for (w in wanted) if (!(w in found)) { print "Not a workspace member:" substr(w, 4) > "/dev/stderr"; failed = 1 }
|
||
|
|
exit failed
|
||
|
|
}
|
||
|
|
' pubspec.yaml >pubspec.yaml.narrowed
|
||
|
|
mv pubspec.yaml.narrowed pubspec.yaml
|