generated from nginx/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Biome: Use biome.json version as main #395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,4 +33,7 @@ exampleSite/hugo | |
# Playwright | ||
/coverage | ||
*/test-results | ||
*/playwright-report | ||
*/playwright-report | ||
|
||
# Biome | ||
biome.rb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,74 @@ | ||
BIOME_BASE_CMD := $(if $(shell which biome),biome,npx @biomejs/[email protected]) | ||
# Read the Biome version from biome.json "$schema" | ||
# Uses BSD/GNU compatible sed with -E for extended regex. | ||
BIOME_VERSION := $(shell sed -nE 's/.*schemas\/([0-9]+\.[0-9]+\.[0-9]+)\/schema\.json.*/\1/p' biome.json) | ||
|
||
# Detect local biome and its version (if any) | ||
HAVE_BIOME := $(shell command -v biome >/dev/null 2>&1 && echo yes || echo no) | ||
LOCAL_BIOME_VERSION := $(shell biome --version 2>/dev/null | sed -E 's/[^0-9]*([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | ||
|
||
# Choose which command to run. Prefer local only if versions match. | ||
ifeq ($(strip $(BIOME_VERSION)),) | ||
$(warning Could not determine Biome version from biome.json; defaulting to npx @biomejs/biome) | ||
BIOME_BASE_CMD := npx -y @biomejs/biome | ||
else | ||
ifeq ($(HAVE_BIOME),yes) | ||
ifeq ($(LOCAL_BIOME_VERSION),$(BIOME_VERSION)) | ||
BIOME_BASE_CMD := biome | ||
else | ||
$(warning Found biome $(LOCAL_BIOME_VERSION) on PATH, but required $(BIOME_VERSION). Falling back to npx.) | ||
BIOME_BASE_CMD := npx -y @biomejs/biome@$(BIOME_VERSION) | ||
endif | ||
else | ||
BIOME_BASE_CMD := npx -y @biomejs/biome@$(BIOME_VERSION) | ||
endif | ||
endif | ||
|
||
# Optional: allow forcing use of local biome anyway (not recommended) | ||
# Usage: make ... FORCE_LOCAL_BIOME=1 | ||
ifeq ($(FORCE_LOCAL_BIOME),1) | ||
BIOME_BASE_CMD := biome | ||
endif | ||
|
||
WRITE_FLAG := --write | ||
|
||
.PHONY: list help | ||
list help:: | ||
$(info Available Make targets:) | ||
.PHONY: list help biome-format biome-lint biome-all setup-pre-commit tests build-example-site check-biome install-help tests-update-screenshots | ||
|
||
list help: | ||
@echo "Available Make targets:" | ||
@echo "<COMMON>" | ||
@echo " list | help: Print these available make targets" | ||
@echo " list | help: Print these available make targets" | ||
@echo "<LINTING AND FORMATTING>" | ||
@echo " biome-format: Runs the biome formatter." | ||
@echo " biome-lint: Runs the biome linter." | ||
@echo " biome-all: Runs both the lint and formatting commands." | ||
@echo " build-example-site: Builds hugo exampleSite." | ||
@echo "(Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))" | ||
@echo " biome-format: Runs the biome formatter." | ||
@echo " biome-lint: Runs the biome linter." | ||
@echo " biome-all: Runs both the lint and formatting commands." | ||
@echo "(Set BIOME_ARGS=write to enable --write, e.g.: make biome-all BIOME_ARGS=write)" | ||
@echo "<BUILD>" | ||
@echo " build-example-site: Builds hugo exampleSite." | ||
@echo "<PRE-COMMIT>" | ||
@echo " setup-pre-commit: Sets up pre-commit (assuming it is installed)" | ||
@echo " setup-pre-commit: Sets up pre-commit (assuming it is installed)" | ||
@echo "<PLAYWRIGHT TESTS>" | ||
@echo " tests: Runs playwright against the new theme." | ||
@echo " tests-update-screenshots: Runs playwright against the new theme." | ||
@echo " tests: Runs playwright against the new theme." | ||
@echo " tests-update-screenshots: Runs playwright against the new theme and generates screenshots." | ||
@echo "<BIOME UTILITIES>" | ||
@echo " check-biome: Shows required vs local biome versions and the command that will run." | ||
@echo " install-help: Shows how to install Biome globally via brew or npm." | ||
|
||
.PHONY: biome-format biome-lint biome-all setup-pre-commit tests build-example-site | ||
FLAG := | ||
ifeq ($(BIOME_ARGS), write) | ||
FLAG := $(WRITE_FLAG) | ||
FLAG := $(WRITE_FLAG) | ||
endif | ||
|
||
biome-format: | ||
$(BIOME_BASE_CMD) format $(FLAG) | ||
|
||
biome-lint: | ||
$(BIOME_BASE_CMD) lint $(FLAG) | ||
|
||
biome-all: | ||
$(BIOME_BASE_CMD) check $(FLAG) | ||
|
||
setup-pre-commit: | ||
@if ! command -v pre-commit &> /dev/null; then \ | ||
@if ! command -v pre-commit >/dev/null 2>&1; then \ | ||
echo "WARNING: 'pre-commit' is not installed. Please install it using: pip install pre-commit or brew install pre-commit"; \ | ||
else \ | ||
echo "pre-commit is installed! Proceeding with hook installation."; \ | ||
|
@@ -43,7 +79,38 @@ setup-pre-commit: | |
|
||
build-example-site: | ||
cd exampleSite && hugo mod get && hugo build --gc -e production | ||
|
||
tests: | ||
cd tests && npx playwright test | ||
|
||
tests-update-screenshots: | ||
cd tests && npx playwright test --update-snapshots | ||
|
||
check-biome: | ||
@echo "Required Biome version: $(BIOME_VERSION)" | ||
@echo "System Biome version: $(LOCAL_BIOME_VERSION)" | ||
@echo "Command that will run: $(BIOME_BASE_CMD)" | ||
@if ! command -v biome >/dev/null 2>&1 || [ "$(LOCAL_BIOME_VERSION)" != "$(BIOME_VERSION)" ]; then \ | ||
echo ""; \ | ||
echo "⚠️ Local biome version does not match required."; \ | ||
$(MAKE) install-help; \ | ||
fi | ||
|
||
install-help: | ||
@echo "" | ||
@echo "🛠️ Install options for biome v$(BIOME_VERSION):" | ||
@echo "" | ||
@echo "1) 🧪 Install manually via Homebrew (advanced):" | ||
@echo " # Find the correct commit SHA for biome $(BIOME_VERSION) here:" | ||
@echo " # https://github.com/Homebrew/homebrew-core/commits/master/Formula/biome.rb" | ||
@echo " curl -sSL https://raw.githubusercontent.com/Homebrew/homebrew-core/<COMMIT_SHA>/Formula/biome.rb -o biome.rb" | ||
@echo " brew install ./biome.rb" | ||
@echo " brew pin biome" | ||
@echo "" | ||
@echo "2) 🚀 Install via npm (global):" | ||
@echo " npm install -g @biomejs/biome@$(BIOME_VERSION)" | ||
@echo "" | ||
@echo "3) 🧰 Use temporarily via npx (auto fallback in Makefile):" | ||
@echo " npx -y @biomejs/biome@$(BIOME_VERSION) <command>" | ||
@echo "" | ||
@echo "Note: This Makefile will automatically fall back to npx if the right version is not found locally." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,4 @@ while read -r line; do | |
fi | ||
|
||
done <"$commit_file" | ||
exit 0 | ||
exit 0 |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.