diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4be103b..e52cf6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,10 +124,30 @@ jobs: cache: true - run: make smoke + templates: + name: built-in templates build and pass their tests + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: stable + cache: true + - uses: actions/setup-node@v4 + with: + node-version: 22 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Rust + run: rustup toolchain install stable --profile minimal && rustup default stable + - run: make templates + # Required status check: one name to protect in the branch rules. ci-ok: if: always() - needs: [test, lint, vulncheck, cross-build, smoke] + needs: [test, lint, vulncheck, cross-build, smoke, templates] runs-on: ubuntu-latest steps: - name: All jobs must have succeeded diff --git a/CHANGELOG.md b/CHANGELOG.md index e54ab15..a3ac0e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,22 @@ and versions follow [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [0.3.0] - 2026-10-16 + +### Added +- **Built-in templates** that ship inside the binary: `go-basic`, `go-http`, `node-basic`, `node-http`, + `typescript-basic`, `python-basic`, `python-http`, `rust-basic`, `static-site` and `blank`. `foundry new` works + right after installing; `--language` uses the built-in template of that language unless you set another. +- `foundry template export ` copies a built-in template so you can change it. +- `foundry template list --builtin` and `--saved`; built-in templates can be the default of a language. +- `scripts/test-templates.sh` and a CI job that create a project from every built-in template and run its + own build and tests. + +### Changed +- `foundry template list` shows built-in and saved templates (before: only saved ones). A template you saved + hides a built-in one with the same name. +- The example templates under `examples/` became built-in templates. + ## [0.2.0] - 2026-10-16 ### Security diff --git a/Makefile b/Makefile index 64e630e..a9ebafa 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none) DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) LDFLAGS := -s -w -X $(MODULE)/internal/cli.version=$(VERSION) -X $(MODULE)/internal/cli.commit=$(COMMIT) -X $(MODULE)/internal/cli.date=$(DATE) -.PHONY: all build test race cover vet fmt fmt-check check lint vuln smoke dist install clean +.PHONY: all build test race cover vet fmt fmt-check check lint vuln smoke templates dist install clean all: check build @@ -44,6 +44,10 @@ vuln: smoke: build FOUNDRY_BIN=$(CURDIR)/foundry scripts/smoke-test.sh +# Creates a project from every built-in template and runs that language's own tests on it. +templates: build + FOUNDRY_BIN=$(CURDIR)/foundry scripts/test-templates.sh + # Cross-compiled archives and checksums in dist/ (see scripts/dist.sh). dist: VERSION=$(VERSION) COMMIT=$(COMMIT) DATE=$(DATE) scripts/dist.sh diff --git a/README.md b/README.md index 3c2d005..34f9d42 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,9 @@ Foundry turns any directory into a reusable project template. Create a new proje name, author and license filled in, setup commands run and a first git commit made. ```console -$ foundry template add go-cli ./examples/go-cli -✓ Template "go-cli" saved - -$ foundry config Go go-cli # make it the default for Go $ foundry new my-api --language Go -Creating project "my-api" from go-cli -✓ Created 3 files in my-api +Creating project "my-api" from go-basic (built-in) +✓ Created 5 files in my-api ✓ Initialised a git repository. ✓ Added a .gitignore for Go. ✓ Created the first commit. @@ -73,24 +69,47 @@ cd Foundry make build # produces ./foundry ``` +## Built-in templates + +Foundry comes with templates for common starts, so `foundry new` works the moment it is installed. Each one +builds and passes its own tests, and uses only the language's standard tooling (no frameworks). + +| Template | Language | What you get | +| --- | --- | --- | +| `go-basic` | Go | Command line program with flags and tests | +| `go-http` | Go | HTTP service with health check, graceful shutdown and tests | +| `node-basic` | JavaScript | Node.js program, ES modules, built-in test runner | +| `node-http` | JavaScript | Node.js HTTP service with health check and tests | +| `typescript-basic` | TypeScript | TypeScript program compiled with `tsc`, built-in test runner | +| `python-basic` | Python | Command line program with `pyproject.toml` and `unittest` | +| `python-http` | Python | HTTP service with health check and `unittest`, standard library only | +| `rust-basic` | Rust | Command line program with a unit test | +| `static-site` | HTML | Plain HTML and CSS site | +| `blank` | any | An empty project: README and editor settings | + +`foundry new my-app --language Go` uses the built-in template of that language (marked as default in +`foundry template list`) unless you chose another. Want to change one? `foundry template export go-basic ./my-go` +copies it to a folder; edit it and save it as your own with `foundry template add`. Your own templates win when a +name is the same. + ## Quick start ```console -# 1. Save a directory as a template (the language is detected) -foundry template add go-cli ./examples/go-cli --description "Go CLI starter" -foundry template add node-cli ./examples/node-cli +# 1. Create a project from a built-in template +foundry new my-api --language Go # the default template of a language +foundry new my-tool --template node-basic # a specific template +foundry new my-app # choose from menus +foundry template list # see what is available -# 2. Optional: pick a default template per language -foundry config Go go-cli +# 2. Preview first: nothing is written +foundry new my-api --template go-http --dry-run -# 3. Create a project -foundry new my-api --language Go # default template of a language -foundry new my-tool --template node-cli # a specific template -foundry new my-app # choose from menus -foundry new my-site --git https://github.com/you/template # a repository as template +# 3. Make your own templates and defaults +foundry template add my-go ./path/to/directory # save any directory as a template +foundry config Go my-go # make it the default for Go -# 4. See what would happen without writing anything -foundry new my-api --template go-cli --dry-run +# 4. Other sources +foundry new my-site --git https://github.com/you/template # a repository as template ``` On the first run Foundry creates `~/.foundry/config.yaml`, detects the tools on your machine and @@ -117,14 +136,15 @@ Details, ignore rules and tips: [docs/templates.md](docs/templates.md). | --- | --- | | `foundry new ` | Create a project. Flags: `--template`, `--language`, `--git`, `--branch`, `--path`, `--var KEY=VALUE`, `--dry-run`, `--json` (with `--dry-run`), `--no-git`, `--no-post`, `--no-open`, `--non-interactive` | | `foundry template add ` | Save a directory as a template (`--description`, `--language`) | -| `foundry template list` | List templates (`--sort name\|language`, `--quiet`, `--json`) | +| `foundry template list` | List built-in and saved templates (`--saved`, `--builtin`, `--sort name\|language`, `--quiet`, `--json`) | | `foundry template show ` | Show details and files (`--files-only`, `--summary`, `--json`) | | `foundry template update [name...]` | Rescan templates so file lists stay current | | `foundry template edit ` | Change description, language, path or name | | `foundry template vars ` | List the placeholders a template uses | +| `foundry template export ` | Copy a built-in template to a folder so you can change it | | `foundry template remove ` | Forget a template (`--force` if it is a default); files stay | | `foundry config` | Show settings; set with `--user`, `--license`, `--default-language`, `--docker`, `--interactive`; `--json`, `--path` | -| `foundry config