mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-14 08:36:07 +00:00
7078abc14a
Storybook existed only as an undocumented local tool: 9 of 24 reusable components had stories, autodocs pages were bare prop tables, nothing built or tested the stories, and no contributor doc mentioned the workbench existed. Every reusable component under src/components/ now has a co-located story with enriched autodocs (component descriptions plus per-prop argTypes, kept as string metadata since the repo bans line comments). Stories double as headless Chromium tests through the Storybook vitest addon, with axe accessibility checks enforced as errors and play-function interaction tests covering the modals, the RHF field bridge, the config block, and the select-all buttons. The preview now mirrors the panel's real theme DOM (body class, shared AntD theme config, seeded theme storage) so what stories render matches production. CI and make verify gain a static Storybook build as a compile gate, and the frontend test job installs Chromium so story tests run on every PR. Contributor docs (frontend README, CONTRIBUTING, agent guides) document the workbench, the story conventions, and the Controls setup. Node engines move to 24 LTS and gen:api drops the type-stripping flags that Node 24 makes default.
80 lines
2.3 KiB
Makefile
80 lines
2.3 KiB
Makefile
# Canonical task runner. Mirrors .github/workflows/ci.yml so `make verify`
|
|
# reproduces the PR gate locally. Run `make help` for the list.
|
|
|
|
SHELL := bash
|
|
GO_PKGS = $(shell go list ./... | grep -v '/frontend/node_modules/')
|
|
FRONTEND = frontend
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
.PHONY: help
|
|
help: ## Show this help
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf " %-14s %s\n", $$1, $$2}'
|
|
|
|
# go:embed of internal/web/dist needs the dir to exist even when the
|
|
# frontend bundle has not been built. CI stubs it the same way.
|
|
.PHONY: dist-stub
|
|
dist-stub:
|
|
@mkdir -p internal/web/dist && touch internal/web/dist/.gitkeep
|
|
|
|
.PHONY: gen
|
|
gen: ## Regenerate Zod schemas + OpenAPI from Go sources
|
|
cd $(FRONTEND) && npm run gen
|
|
|
|
.PHONY: gen-check
|
|
gen-check: gen ## Fail if generated files are stale
|
|
git diff --exit-code -- frontend/src/generated frontend/public/openapi.json
|
|
|
|
.PHONY: lint-go
|
|
lint-go: dist-stub ## golangci-lint on Go sources
|
|
golangci-lint run
|
|
|
|
.PHONY: lint-fe
|
|
lint-fe: ## ESLint on frontend sources
|
|
cd $(FRONTEND) && npm run lint
|
|
|
|
.PHONY: lint
|
|
lint: lint-go lint-fe ## All linters
|
|
|
|
.PHONY: typecheck
|
|
typecheck: ## tsc --noEmit
|
|
cd $(FRONTEND) && npm run typecheck
|
|
|
|
.PHONY: test-go
|
|
test-go: dist-stub ## Go tests (shuffle, no cache)
|
|
go test -shuffle=on -count=1 $(GO_PKGS)
|
|
|
|
.PHONY: race
|
|
race: dist-stub ## Go tests with the race detector (needs a C compiler)
|
|
go test -race -shuffle=on -count=1 $(GO_PKGS)
|
|
|
|
.PHONY: test-fe
|
|
test-fe: ## Frontend tests (vitest)
|
|
cd $(FRONTEND) && npm test
|
|
|
|
.PHONY: test
|
|
test: test-go test-fe ## All tests
|
|
|
|
.PHONY: vulncheck
|
|
vulncheck: dist-stub ## govulncheck
|
|
go run golang.org/x/vuln/cmd/govulncheck@latest ./...
|
|
|
|
.PHONY: build-fe
|
|
build-fe: ## Build the Vite bundles into internal/web/dist
|
|
cd $(FRONTEND) && npm run build
|
|
|
|
.PHONY: build
|
|
build: build-fe ## Build the frontend then the Go binary
|
|
go build ./...
|
|
|
|
.PHONY: build-storybook
|
|
build-storybook: ## Build the static Storybook (compile-checks all stories)
|
|
cd $(FRONTEND) && npm run build-storybook
|
|
|
|
# The PR gate. Matches ci.yml: codegen freshness, both linters, typecheck,
|
|
# both test suites, a full build, and the Storybook compile-check.
|
|
.PHONY: verify
|
|
verify: gen-check lint typecheck test build build-storybook ## Full local gate (mirrors CI)
|
|
@echo "verify: OK"
|