From afea0f26f238086145b2c03e00565ab486ce8b34 Mon Sep 17 00:00:00 2001 From: jabahum Date: Sat, 24 Oct 2026 19:51:21 +0300 Subject: [PATCH] Align project commands and document all workflows --- .github/workflows/ci.yml | 24 +- .github/workflows/release.yml | 4 +- CHANGELOG.md | 5 + Makefile | 56 +-- README.md | 76 ++-- assets.go | 6 +- docs/commands.md | 327 ++++++++++++++++++ internal/add/add.go | 8 +- internal/cli/cli.go | 75 +++- internal/cli/cli_test.go | 62 ++++ internal/doctor/doctor.go | 2 +- internal/generator/generator_test.go | 4 +- internal/generator/scripts_test.go | 175 ++++++++++ scripts/build-release.sh | 75 ++-- scripts/smoke.sh | 40 +++ templates/flutter_foundations/README.md | 52 ++- templates/flutter_foundations/pubspec.yaml | 16 +- .../flutter_foundations/scripts/run_flavor.sh | 20 +- .../flutter_foundations/scripts/setup.sh | 8 +- .../scripts/validate_bricks.sh | 9 +- templates/go-foundations/Makefile | 63 +++- templates/go-foundations/README.md | 34 ++ .../scripts/generate-dev-keys.sh | 7 + templates/react-foundations/README.md | 22 ++ templates/react-foundations/package.json | 3 +- templates/react-foundations/scripts/clean.js | 7 + templates/rust-foundations/README.md | 47 ++- templates/rust-foundations/scripts/check.ps1 | 33 ++ templates/rust-foundations/scripts/check.sh | 17 + templates/vanilla-js-foundations/README.md | 22 ++ templates/vanilla-js-foundations/package.json | 3 +- .../vanilla-js-foundations/scripts/clean.js | 7 + 32 files changed, 1140 insertions(+), 169 deletions(-) create mode 100644 docs/commands.md create mode 100644 internal/generator/scripts_test.go create mode 100755 scripts/smoke.sh create mode 100644 templates/react-foundations/scripts/clean.js create mode 100644 templates/rust-foundations/scripts/check.ps1 create mode 100755 templates/rust-foundations/scripts/check.sh create mode 100644 templates/vanilla-js-foundations/scripts/clean.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a580660..859642a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ jobs: - run: go test ./... - run: go vet ./... - run: go build -trimpath ./cmd/foundry + - name: Embedded generation smoke check + if: runner.os == 'Linux' + run: make smoke formatting: name: Formatting @@ -34,7 +37,7 @@ jobs: with: go-version: '1.23.x' cache: true - - run: test -z "$(gofmt -l .)" + - run: make format-check cross-compile: name: Cross-compile release targets @@ -45,7 +48,7 @@ jobs: with: go-version: '1.23.x' cache: true - - run: ./scripts/build-release.sh ci + - run: make release VERSION=ci web-templates: name: Web template (${{ matrix.template }}, Node ${{ matrix.node }}) @@ -86,6 +89,8 @@ jobs: toolchain: '1.85.0' env: RUSTDOCFLAGS: -D warnings + RUSTUP_TOOLCHAIN: ${{ matrix.toolchain }} + CARGO_NET_OFFLINE: 'true' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -96,13 +101,12 @@ jobs: run: rustup toolchain install ${{ matrix.toolchain }} --profile minimal --component rustfmt --component clippy - name: Generate the bundled template run: go run ./cmd/foundry new rust-check --template rust --destination "${{ runner.temp }}/foundry-rust" --no-hooks - - run: cargo +${{ matrix.toolchain }} fmt --all -- --check + - name: Rust quality gate (POSIX) + if: runner.os != 'Windows' + run: bash scripts/check.sh working-directory: ${{ runner.temp }}/foundry-rust - - run: cargo +${{ matrix.toolchain }} test --locked --offline - working-directory: ${{ runner.temp }}/foundry-rust - - run: cargo +${{ matrix.toolchain }} clippy --locked --offline --all-targets -- -D warnings - working-directory: ${{ runner.temp }}/foundry-rust - - run: cargo +${{ matrix.toolchain }} doc --locked --offline --no-deps - working-directory: ${{ runner.temp }}/foundry-rust - - run: cargo +${{ matrix.toolchain }} build --release --locked --offline + - name: Rust quality gate (PowerShell) + if: runner.os == 'Windows' + shell: pwsh + run: ./scripts/check.ps1 working-directory: ${{ runner.temp }}/foundry-rust diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ab1e9a..32c3492 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,8 +37,8 @@ jobs: else echo "value=$INPUT_VERSION" >> "$GITHUB_OUTPUT" fi - - name: Test - run: go test ./... + - name: Check Foundry + run: make check - name: Build archives and checksums env: RELEASE_VERSION: ${{ steps.version.outputs.value }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b945e8..042f06a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +- Align quality command meanings across the CLI repository and all five foundations; retain existing Make/Melos aliases. +- Add comprehensive command/workflow documentation, script help, CWD-independent helpers, and native PowerShell Rust checks. +- Make Go contract generation explicit, isolate smoke tests, and checksum only the current release's six executable archives. +- Correct use-case argument parsing so a trailing --project flag is honored; return success for command help. + - Add embedded Rust 2024 foundations with a thin CLI, reusable library, feature modules, typed errors, unit/integration/doc tests, rustfmt, and Clippy. - Validate generated Rust projects across Linux, macOS, Windows, and the minimum Rust version. diff --git a/Makefile b/Makefile index 5088b65..b17e427 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,47 @@ BINARY := bin/foundry VERSION ?= dev LDFLAGS := -s -w -X github.com/jabahum/foundry/internal/cli.Version=$(VERSION) +.DEFAULT_GOAL := help -.PHONY: build test fmt fmt-check vet check smoke install release-snapshot clean +.PHONY: help build test format format-check lint check ci smoke install release clean fmt fmt-check vet release-snapshot -build: +help: ## Show commands; see docs/commands.md for prerequisites and side effects. + @awk 'BEGIN {FS = ":.*## "; print "Foundry commands:"} /^[a-zA-Z_-]+:.*## / {printf " make %-18s %s\n", $$1, $$2}' $(MAKEFILE_LIST) + +build: ## Build bin/foundry for this machine (VERSION defaults to dev). mkdir -p bin CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $(BINARY) ./cmd/foundry -test: +test: ## Run Foundry tests, including embedded generation for all five templates. go test ./... -fmt: - gofmt -w cmd internal +format: ## Format Foundry's Go source; does not format generated template projects. + gofmt -w assets.go cmd internal -fmt-check: - test -z "$$(gofmt -l .)" +format-check: ## Check Foundry formatting without rewriting source. + test -z "$$(gofmt -l assets.go cmd internal)" -vet: +lint: ## Run go vet on Foundry packages. go vet ./... -check: fmt-check test vet - -smoke: build - ./$(BINARY) version - ./$(BINARY) list - rm -rf .tmp-smoke - ./$(BINARY) new .tmp-smoke --template go --module example.com/smoke --no-hooks - test -f .tmp-smoke/go.mod - grep -q 'module example.com/smoke' .tmp-smoke/go.mod - ./$(BINARY) add migration create_smoke --project .tmp-smoke - test -f .tmp-smoke/migrations/000007_create_smoke.up.sql - ./$(BINARY) add service smoke --project .tmp-smoke - test -f .tmp-smoke/api/proto/smoke/v1/smoke.proto - rm -rf .tmp-smoke - -install: +check: format-check lint test build ## Check formatting, lint, tests, and the native build. + +ci: check smoke ## Run Foundry checks and the isolated generation/add smoke test. + +smoke: build ## Generate all five templates and exercise Go add commands in a temporary folder. + ./scripts/smoke.sh + +install: ## Install Foundry into GOBIN or GOPATH/bin. go install -trimpath -ldflags "$(LDFLAGS)" ./cmd/foundry -release-snapshot: +release: ## Build six executable archives and checksums; does not publish (VERSION=dev). ./scripts/build-release.sh "$(VERSION)" -clean: - rm -rf bin dist .tmp-smoke +clean: ## Remove local bin/ and dist/ artifacts. + rm -rf bin dist + +# Compatibility aliases. Prefer the canonical names above in new automation. +fmt: format +fmt-check: format-check +vet: lint +release-snapshot: release diff --git a/README.md b/README.md index 3d21e90..3e7fb4e 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ Install directly from source with Go 1.23 or newer: go install github.com/jabahum/foundry/cmd/foundry@latest ``` +For the complete CLI, script, template, and release reference, see [Commands and workflows](docs/commands.md). Each generated template also documents its own commands in its README. + For local development: ```bash @@ -68,14 +70,20 @@ foundry new users-service \ --module github.com/your-org/users-service ``` -Flutter app: +Flutter workspace and app: ```bash -foundry new mediguide \ - --template flutter \ - --org ug.go.health +foundry new mediguide --template flutter --no-hooks +cd mediguide +bash scripts/setup.sh +fvm dart pub global run mason_cli:mason make flutter_app \ + --name mediguide --organization ug.go.health +# Add apps/mediguide to workspace: in pubspec.yaml. +fvm dart pub get ``` +Configure native platform folders, permissions, and signing in the app before a platform build. The template README explains the remaining app setup. + Vanilla JavaScript: ```bash @@ -108,7 +116,7 @@ cargo lint The Rust starter has no third-party dependencies. Its toolchain file selects stable Rust with rustfmt and Clippy, and its minimum supported version is Rust 1.85. Domain rules live in feature modules, with CLI input/output at the boundary. Foundry does not run Cargo automatically. -All templates are available offline. Optional generation hooks may invoke installed SDKs and their package managers; use `--no-hooks` to skip them. +All templates are available offline. For the FVM/Mason workflow, generate Flutter with `--no-hooks` and run `bash scripts/setup.sh` explicitly. Optional generation hooks may invoke installed SDKs and their package managers; use `--no-hooks` to skip them. ## Extend an existing project @@ -150,33 +158,27 @@ Template changes ship with a new Foundry build/release. There is no external tem To update a template, edit its source files and rebuild Foundry with `make build`. -## Commands +## Commands and workflows -```text -foundry -foundry new --template -foundry add service -foundry add migration -foundry add feature -foundry add package +[The command reference](docs/commands.md) documents every CLI command and flag, each template's native commands, setup requirements, generated outputs, side effects, Windows alternatives, and CI/release behavior. + +```sh +foundry help +foundry new --help foundry template list -foundry list -foundry info