refactor(10.2-01): nest framework packages under modules
- Move remaining beach packages and embedded admin assets\n- Rewrite framework, example, build, and gate paths
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# Drift gate for the committed admin SPA build (D-04). Rebuilds admin/ from
|
||||
# the committed lockfile into a temporary directory and fails when the result
|
||||
# differs from boardwalk/dist, the tree the Go binary embeds. After changing
|
||||
# the SPA, rebuild with `npm --prefix admin run build` and commit the result.
|
||||
# differs from modules/boardwalk/dist, the tree the Go binary embeds. After
|
||||
# changing the SPA, rebuild with `npm --prefix admin run build` and commit the result.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
@@ -19,8 +19,8 @@ trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
(cd admin && node_modules/.bin/vite build --outDir "$TMP/dist" --emptyOutDir --logLevel warn)
|
||||
|
||||
if ! diff -r "$TMP/dist" boardwalk/dist; then
|
||||
echo "check-admin-dist: boardwalk/dist is stale; run npm --prefix admin run build and commit boardwalk/dist" >&2
|
||||
if ! diff -r "$TMP/dist" modules/boardwalk/dist; then
|
||||
echo "check-admin-dist: modules/boardwalk/dist is stale; run npm --prefix admin run build and commit modules/boardwalk/dist" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "check-admin-dist: boardwalk/dist matches a fresh build"
|
||||
echo "check-admin-dist: modules/boardwalk/dist matches a fresh build"
|
||||
|
||||
@@ -29,7 +29,7 @@ TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
go run github.com/swaggo/swag/cmd/swag@v1.16.6 init \
|
||||
--dir cabana \
|
||||
--dir modules/cabana \
|
||||
--generalInfo admin_openapi.go \
|
||||
--output "$TMP" \
|
||||
--outputTypes json \
|
||||
|
||||
@@ -157,7 +157,7 @@ expect_detect() {
|
||||
}
|
||||
|
||||
# The directories the hygiene stage scans, copied for the self-test.
|
||||
HYGIENE_DIRS=(admin/src admin/tests admin/openapi admin/package.json boardwalk cabana phrasebook)
|
||||
HYGIENE_DIRS=(admin/src admin/tests admin/openapi admin/package.json modules/boardwalk modules/cabana modules/phrasebook)
|
||||
|
||||
run_self_test() {
|
||||
bash -n "${BASH_SOURCE[0]}"
|
||||
@@ -165,7 +165,7 @@ run_self_test() {
|
||||
expect_detect fail 1 '{"Action":"pass","Package":"p","Test":"TestA"}
|
||||
{"Action":"fail","Package":"p","Test":"TestPhase10CSRF"}'
|
||||
expect_detect skip 2 '{"Action":"skip","Package":"p","Test":"TestPhase10AssembledAcceptance"}'
|
||||
expect_detect zero 3 '{"Action":"pass","Package":"git.golem15.com/golem15/summercms/cabana"}'
|
||||
expect_detect zero 3 '{"Action":"pass","Package":"git.golem15.com/golem15/summercms/modules/cabana"}'
|
||||
expect_detect nonjson 4 '{"Action":"pass",'
|
||||
expect_detect build 1 '{"Action":"build-fail","ImportPath":"p"}
|
||||
{"Action":"pass","Package":"q","Test":"TestA"}'
|
||||
@@ -250,10 +250,10 @@ run_go() {
|
||||
}
|
||||
|
||||
run_security() {
|
||||
phase10_tests "$ROOT" ./cabana TestPhase10CookieAuth TestPhase10CSRF TestPhase10Prefix TestPhase10RelationForgedID TestPhase10Bundle TestPhase10Coverage
|
||||
phase10_tests "$ROOT" ./bouncer TestPhase10CookieGuard
|
||||
phase10_tests "$ROOT" ./surf TestPhase10AdminPrefixCollision
|
||||
phase10_go "$ROOT" ./boardwalk
|
||||
phase10_tests "$ROOT" ./modules/cabana TestPhase10CookieAuth TestPhase10CSRF TestPhase10Prefix TestPhase10RelationForgedID TestPhase10Bundle TestPhase10Coverage
|
||||
phase10_tests "$ROOT" ./modules/bouncer TestPhase10CookieGuard
|
||||
phase10_tests "$ROOT" ./modules/surf TestPhase10AdminPrefixCollision
|
||||
phase10_go "$ROOT" ./modules/boardwalk
|
||||
phase10_tests "$APP" ./plugins/golem15/fonoteka TestPhase10CollectionOwnerReadOnly TestPhase10AdminAuth
|
||||
"$ROOT/scripts/check-phase9.sh" --security
|
||||
echo "phase10 security passed"
|
||||
@@ -262,7 +262,7 @@ run_security() {
|
||||
run_postgres() {
|
||||
phase10_tests "$APP" ./plugins/golem15/fonoteka TestPhase10TracerSPA TestPhase10AdminAuth TestPhase10AlbumRelations \
|
||||
TestPhase10Controllers TestPhase10AssembledAcceptance
|
||||
phase10_tests "$ROOT" ./cabana TestPhase10RelationOptions TestPhase10RelationSave TestPhase10OpenAPIConformance TestPhase10Coverage
|
||||
phase10_tests "$ROOT" ./modules/cabana TestPhase10RelationOptions TestPhase10RelationSave TestPhase10OpenAPIConformance TestPhase10Coverage
|
||||
echo "phase10 postgres passed"
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ run_spa() {
|
||||
|
||||
run_openapi() {
|
||||
"$ROOT/scripts/check-admin-openapi.sh" --check
|
||||
phase10_tests "$ROOT" ./cabana TestPhase10OpenAPIConformance TestPhase09ContractInventory
|
||||
phase10_tests "$ROOT" ./modules/cabana TestPhase10OpenAPIConformance TestPhase09ContractInventory
|
||||
(cd "$APP" && bash scripts/check-openapi.sh)
|
||||
if ! git -C "$APP" diff --quiet -- docs/openapi.json; then
|
||||
git -C "$APP" diff --stat -- docs/openapi.json >&2
|
||||
@@ -313,7 +313,7 @@ hygiene_checks() {
|
||||
local hits
|
||||
# Application or Polish catalogue names in framework code, tests and build.
|
||||
hits="$(cd "$tree" && grep -rniIE 'pl[yý]tarium|fonoteka|albumy|kolekcj|winyl|p[lł]yt[aęy]' \
|
||||
admin/src admin/tests admin/openapi boardwalk cabana phrasebook 2>/dev/null || true)"
|
||||
admin/src admin/tests admin/openapi modules/boardwalk modules/cabana modules/phrasebook 2>/dev/null || true)"
|
||||
[[ -z "$hits" ]] || fail "application names in the framework: $hits"
|
||||
# Plugin and server strings are rendered as text only.
|
||||
hits="$(cd "$tree" && grep -rnE 'v-html|innerHTML|outerHTML|insertAdjacentHTML' admin/src 2>/dev/null || true)"
|
||||
@@ -334,11 +334,11 @@ hygiene_checks() {
|
||||
grep -v '^admin/src/state/useSidebar.ts:' || true)"
|
||||
[[ -z "$hits" ]] || fail "browser storage outside admin/src/state/useSidebar.ts: $hits"
|
||||
# The embedded build loads nothing from another origin.
|
||||
hits="$(cd "$tree" && grep -noE '(src|href)="(https?:)?//[^"]*"|url\((["'"'"']?)(https?:)?//' boardwalk/dist/index.html boardwalk/dist/assets/*.css 2>/dev/null || true)"
|
||||
[[ -z "$hits" ]] || fail "boardwalk/dist references another origin: $hits"
|
||||
hits="$(cd "$tree" && grep -ohE 'https?://[A-Za-z0-9.-]+' boardwalk/dist/assets/*.js 2>/dev/null | sort -u |
|
||||
hits="$(cd "$tree" && grep -noE '(src|href)="(https?:)?//[^"]*"|url\((["'"'"']?)(https?:)?//' modules/boardwalk/dist/index.html modules/boardwalk/dist/assets/*.css 2>/dev/null || true)"
|
||||
[[ -z "$hits" ]] || fail "modules/boardwalk/dist references another origin: $hits"
|
||||
hits="$(cd "$tree" && grep -ohE 'https?://[A-Za-z0-9.-]+' modules/boardwalk/dist/assets/*.js 2>/dev/null | sort -u |
|
||||
grep -vxE 'http://www\.w3\.org|https://vuejs\.org|http://local' || true)"
|
||||
[[ -z "$hits" ]] || fail "boardwalk/dist JS names another origin: $hits"
|
||||
[[ -z "$hits" ]] || fail "modules/boardwalk/dist JS names another origin: $hits"
|
||||
# Icons: named imports only, and never the deprecated lucide package.
|
||||
hits="$(cd "$tree" && grep -rnE "import \* as [A-Za-z_]+ from '@lucide/vue'|lucide-vue-next" admin/src admin/package.json 2>/dev/null || true)"
|
||||
[[ -z "$hits" ]] || fail "lucide namespace import or deprecated package: $hits"
|
||||
|
||||
@@ -129,7 +129,7 @@ fi
|
||||
cd "$ROOT"
|
||||
go build -o "$SMOKE_DIR/summer" ./cmd/summer
|
||||
"$SMOKE_DIR/summer" parity:record \
|
||||
--spec tide/testdata/one-route-spec.yaml \
|
||||
--spec modules/tide/testdata/one-route-spec.yaml \
|
||||
--target "http://127.0.0.1:${SMOKE_PORT}" \
|
||||
--output "$SMOKE_DIR/sample.yaml"
|
||||
"$SMOKE_DIR/summer" parity:replay \
|
||||
|
||||
@@ -113,7 +113,7 @@ fi
|
||||
cd "$ROOT"
|
||||
go build -o "$SMOKE_DIR/summer" ./cmd/summer
|
||||
"$SMOKE_DIR/summer" parity:record \
|
||||
--spec tide/testdata/one-route-spec.yaml \
|
||||
--spec modules/tide/testdata/one-route-spec.yaml \
|
||||
--target "http://127.0.0.1:${SMOKE_PORT}" \
|
||||
--output "$SMOKE_DIR/sample.yaml"
|
||||
"$SMOKE_DIR/summer" parity:replay \
|
||||
|
||||
@@ -31,6 +31,6 @@ echo "==> hello go test"
|
||||
go -C examples/hello test ./...
|
||||
|
||||
echo "==> race internal/build phrasebook postcard"
|
||||
go test -race ./internal/build ./phrasebook ./postcard
|
||||
go test -race ./internal/build ./modules/phrasebook ./modules/postcard
|
||||
|
||||
echo "phase4 check passed"
|
||||
|
||||
@@ -101,7 +101,7 @@ run_self_test() {
|
||||
phase9_detect "$log"
|
||||
rm -f "$log"
|
||||
expect_detect_fails skip '{"Action":"skip","Test":"TestPhase09MigrationsFreshRollback"}'
|
||||
expect_detect_fails zero '{"Action":"pass","Package":"git.golem15.com/golem15/summercms/lagoon"}'
|
||||
expect_detect_fails zero '{"Action":"pass","Package":"git.golem15.com/golem15/summercms/modules/lagoon"}'
|
||||
expect_detect_fails fail '{"Action":"fail","Test":"TestPhase09ContractInventory"}'
|
||||
for flag in --self-test --security --postgres --openapi --evidence --all; do
|
||||
grep -q -- "$flag" "${BASH_SOURCE[0]}" || {
|
||||
@@ -113,20 +113,20 @@ run_self_test() {
|
||||
}
|
||||
|
||||
run_security() {
|
||||
phase9_go "$ROOT" ./bouncer ./cabana -run '^TestPhase09'
|
||||
phase9_go "$ROOT" ./modules/bouncer ./modules/cabana -run '^TestPhase09'
|
||||
phase9_go "$APP" ./plugins/golem15/fonoteka -run '^TestPhase09Security'
|
||||
echo "phase9 security passed"
|
||||
}
|
||||
|
||||
run_postgres() {
|
||||
phase9_go "$ROOT" ./lagoon -run '^TestPhase09MigrationsFreshRollback$'
|
||||
phase9_go "$ROOT" ./modules/lagoon -run '^TestPhase09MigrationsFreshRollback$'
|
||||
phase9_go "$APP" ./plugins/golem15/fonoteka -run '^TestPhase09AssembledAcceptance$'
|
||||
echo "phase9 postgres passed"
|
||||
}
|
||||
|
||||
run_openapi() {
|
||||
(cd "$APP" && bash scripts/check-openapi.sh)
|
||||
phase9_go "$ROOT" ./cabana -run '^TestPhase09ContractInventory$'
|
||||
phase9_go "$ROOT" ./modules/cabana -run '^TestPhase09ContractInventory$'
|
||||
echo "phase9 openapi passed"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user