feat: implement plinth CLI (new / doctor / version)#1
Merged
Conversation
Single-binary, stdlib-only Go CLI that scaffolds modules from the
plinth-dev/starter-{web,api} tags via GitHub's tar.gz endpoint.
`plinth new <name>` fetches the starter, rewrites the Go module path
and bare service-name tokens, optionally `git init`s the result. The
rename engine skips binaries, lockfiles, and dependency dirs; the
fetch tarball extractor strips the codeload `<repo>-<ref>/` prefix
and rejects path traversal.
`plinth doctor` checks go/git/node/pnpm minimums and reports docker
as optional. `plinth version` reports a Version + Commit baked in
via -ldflags from the Makefile.
Tests cover the rename engine, fetch+extract (with httptest tarball
fixtures), the new-command happy path, name validation, target
collisions, and the doctor's PASS/FAIL/SKIP states. CI runs vet +
race+cover tests + a build smoke on Go 1.25.
End-to-end smoke against the real plinth-dev/starter-{web,api}@v0.1.0
tags scaffolds cleanly: go vet passes on the rewritten API and the
web package.json/instrumentation/env-schema all carry the new name.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
new,doctor,version.plinth new <name>fetchesplinth-dev/starter-{web,api}over HTTPS via GitHub's tar.gz endpoint (default refv0.1.0), strips the codeload<repo>-<ref>/prefix, rewrites the Go module path + bare service-name tokens, andgit inits the result. Targets are<name>-api/and<name>-web/under--dir(default.);--module-pathoverrides the API module path (defaultgithub.com/example/<name>-api).plinth doctorreports OK/FAIL/SKIP for go (≥1.25), git (≥2.30), node (≥20), pnpm (≥9), and docker (optional).plinth versionprints aVersion+Commitinjected at build time via-ldflags; the Makefile feedsgit describeandgit rev-parse --short HEAD.Implementation notes
flagper subcommand;extractNamepulls the positional<name>out of argv before parse so flags can come before or after.node_modules,.git,.next,dist,vendor, lockfiles (go.sum,pnpm-lock.yaml), and binary content (NUL-byte probe in first 8 KiB). Order-sensitive replacement: full Go module path before the bare service-name token, sogithub.com/plinth-dev/starter-apirewrites cleanly without corruptinggithub.com/plinth-dev/sdk-go/...deps.End-to-end smoke
Locally scaffolded against the real
plinth-dev/starter-{web,api}@v0.1.0tags (plinth new smoketest --module-path github.com/acme/smoketest-api --no-git):go vet ./...clean on the rewritten API.package.jsonname,instrumentation-client.tsserviceName, andsrc/lib/env.tsSERVICE_NAME default all carry the new name; sdk-go imports untouched.Test plan
make build && ./bin/plinth versionworks locally../bin/plinth new <name>against a clean dir produces a buildable starter pair.🤖 Generated with Claude Code