generated from mathias/template-go-web
template: substitute placeholders
This commit is contained in:
@@ -5,10 +5,10 @@
|
|||||||
#
|
#
|
||||||
# `golangci-lint run ./...` and friends cannot see this template's entrypoint.
|
# `golangci-lint run ./...` and friends cannot see this template's entrypoint.
|
||||||
# Go skips directories whose names begin with "_" or "." when expanding package
|
# Go skips directories whose names begin with "_" or "." when expanding package
|
||||||
# patterns, and the entrypoint lives in cmd/__PROJECT_NAME__:
|
# patterns, and the entrypoint lives in cmd/spatial-agent-app:
|
||||||
#
|
#
|
||||||
# $ go list ./...
|
# $ go list ./...
|
||||||
# __MODULE_PATH__/internal/web <- no cmd package
|
# git.d-ma.be/mathias/spatial-agent-app/internal/web <- no cmd package
|
||||||
#
|
#
|
||||||
# After substitution the directory has a real name, becomes visible, and any
|
# After substitution the directory has a real name, becomes visible, and any
|
||||||
# defect in it appears — in the child, not here. That is how template-go-agent
|
# defect in it appears — in the child, not here. That is how template-go-agent
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
# (template-go-agent#1, #2).
|
# (template-go-agent#1, #2).
|
||||||
#
|
#
|
||||||
# Linting the directory by name is not a fix: `golangci-lint run
|
# Linting the directory by name is not a fix: `golangci-lint run
|
||||||
# ./cmd/__PROJECT_NAME__` works, but reports formatter findings that do not
|
# ./cmd/spatial-agent-app` works, but reports formatter findings that do not
|
||||||
# exist in a generated repo, because gofumpt's import grouping depends on the
|
# exist in a generated repo, because gofumpt's import grouping depends on the
|
||||||
# module path and this one is a placeholder.
|
# module path and this one is a placeholder.
|
||||||
#
|
#
|
||||||
@@ -55,16 +55,16 @@ tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
|
|||||||
cp "$ROOT/$f" "$tmp/$f"
|
cp "$ROOT/$f" "$tmp/$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ! -d "$tmp/cmd/__PROJECT_NAME__" ]; then
|
if [ ! -d "$tmp/cmd/spatial-agent-app" ]; then
|
||||||
bad "the template still has a placeholder entrypoint directory" \
|
bad "the template still has a placeholder entrypoint directory" \
|
||||||
"cmd/__PROJECT_NAME__ not found — has the layout changed?"
|
"cmd/spatial-agent-app not found — has the layout changed?"
|
||||||
echo; echo "$pass passed, $fail failed"; exit 1
|
echo; echo "$pass passed, $fail failed"; exit 1
|
||||||
fi
|
fi
|
||||||
mv "$tmp/cmd/__PROJECT_NAME__" "$tmp/cmd/childproj"
|
mv "$tmp/cmd/spatial-agent-app" "$tmp/cmd/childproj"
|
||||||
find "$tmp" -type f \( -name '*.go' -o -name '*.templ' -o -name '*.mod' -o -name '*.yml' -o -name '*.md' -o -name 'Dockerfile' \) \
|
find "$tmp" -type f \( -name '*.go' -o -name '*.templ' -o -name '*.mod' -o -name '*.yml' -o -name '*.md' -o -name 'Dockerfile' \) \
|
||||||
-exec sed -i \
|
-exec sed -i \
|
||||||
-e 's|__MODULE_PATH__|git.d-ma.be/mathias/childproj|g' \
|
-e 's|git.d-ma.be/mathias/spatial-agent-app|git.d-ma.be/mathias/childproj|g' \
|
||||||
-e 's|__PROJECT_NAME__|childproj|g' {} +
|
-e 's|spatial-agent-app|childproj|g' {} +
|
||||||
|
|
||||||
# Generated files are gitignored, so the child arrives without them — exactly as
|
# Generated files are gitignored, so the child arrives without them — exactly as
|
||||||
# a freshly scaffolded repo does. Generating here also proves the pinned
|
# a freshly scaffolded repo does. Generating here also proves the pinned
|
||||||
@@ -98,7 +98,7 @@ out="$(cd "$tmp" && go vet ./... 2>&1)"
|
|||||||
# human-readable summary instead scores a CRASHED linter as a pass -- bad
|
# human-readable summary instead scores a CRASHED linter as a pass -- bad
|
||||||
# config, unwritable TMPDIR, OOM, or simply a future change to its output
|
# config, unwritable TMPDIR, OOM, or simply a future change to its output
|
||||||
# format all produce non-matching text. Since this harness is the only gate
|
# format all produce non-matching text. Since this harness is the only gate
|
||||||
# covering the entrypoint, that would leave cmd/__PROJECT_NAME__ unchecked with
|
# covering the entrypoint, that would leave cmd/spatial-agent-app unchecked with
|
||||||
# CI green, which is precisely the defect class this file exists to end.
|
# CI green, which is precisely the defect class this file exists to end.
|
||||||
out="$(cd "$tmp" && golangci-lint run ./... 2>&1)"; rc=$?
|
out="$(cd "$tmp" && golangci-lint run ./... 2>&1)"; rc=$?
|
||||||
case "$rc" in
|
case "$rc" in
|
||||||
|
|||||||
Reference in New Issue
Block a user