mirror of
https://github.com/ivuorinen/nvm-auto-use.fish.git
synced 2026-02-13 12:50:19 +00:00
feat: refactor plugin architecture, enhance linting, CI & tooling
- Major refactor of core Fish functions for modularity, caching, and error handling - Improved `.editorconfig` and Makefile for stricter formatting and linting standards - Expanded linting support: added EditorConfig checks, auto-install for missing tools, and Makefile targets - Enhanced CI workflow with clearer permissions and job steps in GitHub Actions - Updated documentation in `README.md` and `CLAUDE.md` to reflect new features, advanced developer tools, and contribution guidelines - Improved Node.js version manager detection, switching, and installation logic - Added/updated utility functions for configuration, silent mode, notifications, and version extraction - Various bug fixes, code quality improvements, and expanded test coverage
This commit is contained in:
90
Makefile
90
Makefile
@@ -1,6 +1,12 @@
|
||||
# Makefile for nvm-auto-use.fish
|
||||
|
||||
.PHONY: help install-tools lint lint-fish lint-markdown lint-json lint-fix lint-check test clean
|
||||
# URLs and constants
|
||||
FISHER_BASE := https://raw.githubusercontent.com/jorgebucaran/fisher/main
|
||||
FISHER_URL := $(FISHER_BASE)/functions/fisher.fish
|
||||
|
||||
.PHONY: help install-tools lint lint-fish lint-markdown lint-json \
|
||||
lint-fix lint-check lint-editorconfig test test-ci test-unit \
|
||||
test-integration clean
|
||||
|
||||
# Default target
|
||||
help:
|
||||
@@ -12,28 +18,28 @@ help:
|
||||
@echo " lint-json - Lint JSON files"
|
||||
@echo " lint-fix - Fix auto-fixable linting issues"
|
||||
@echo " lint-check - Check linting without fixing"
|
||||
@echo " lint-editorconfig - Check EditorConfig compliance"
|
||||
@echo " test - Run tests (install plugin locally)"
|
||||
@echo " test-ci - Run tests in CI environment"
|
||||
@echo " test-unit - Run unit tests only"
|
||||
@echo " test-integration - Run integration tests only"
|
||||
@echo " clean - Clean temporary files"
|
||||
|
||||
# Install all required linting tools
|
||||
install-tools:
|
||||
@echo "Installing linting tools..."
|
||||
# Install markdownlint-cli for markdown linting
|
||||
@if ! command -v markdownlint >/dev/null 2>&1; then \
|
||||
echo "Installing markdownlint-cli..."; \
|
||||
npm install -g markdownlint-cli; \
|
||||
else \
|
||||
echo "markdownlint-cli already installed"; \
|
||||
fi
|
||||
# Install jsonlint for JSON linting
|
||||
@if ! command -v jsonlint >/dev/null 2>&1; then \
|
||||
echo "Installing jsonlint..."; \
|
||||
npm install -g jsonlint; \
|
||||
else \
|
||||
echo "jsonlint already installed"; \
|
||||
fi
|
||||
# Install jq for JSON processing (backup)
|
||||
@if ! command -v jq >/dev/null 2>&1; then \
|
||||
echo "Installing jq..."; \
|
||||
if command -v brew >/dev/null 2>&1; then \
|
||||
@@ -51,18 +57,19 @@ install-tools:
|
||||
@echo "All linting tools installed!"
|
||||
|
||||
# Run all linting checks
|
||||
lint: lint-fish lint-markdown lint-json
|
||||
lint: lint-fish lint-markdown lint-json lint-editorconfig
|
||||
|
||||
# Lint Fish shell files
|
||||
lint-fish:
|
||||
@echo "Linting Fish files..."
|
||||
@find . -name "*.fish" -type f | while read -r file; do \
|
||||
echo "Checking $$file..."; \
|
||||
fish_indent --check "$$file" || { \
|
||||
echo "Formatting issues found in $$file"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
done
|
||||
@find . \
|
||||
-name "*.fish" \
|
||||
-type f \
|
||||
-exec sh -c \
|
||||
'echo "Checking $$1..."; \
|
||||
fish_indent --check "$$1" || { \
|
||||
echo "Formatting issues found in $$1"; exit 1; }' \
|
||||
sh {} \;
|
||||
@echo "Validating Fish syntax..."
|
||||
@fish -n functions/*.fish completions/*.fish 2>/dev/null || { \
|
||||
echo "Syntax errors found in Fish files"; \
|
||||
@@ -86,24 +93,36 @@ lint-markdown:
|
||||
# Lint JSON files
|
||||
lint-json:
|
||||
@echo "Linting JSON files..."
|
||||
@find . -name "*.json" -type f | while read -r file; do \
|
||||
echo "Checking $$file..."; \
|
||||
@find . \
|
||||
-name "*.json" \
|
||||
-type f \
|
||||
-exec sh -c \
|
||||
'file="$$1"; echo "Checking $$file..."; \
|
||||
if command -v jsonlint >/dev/null 2>&1; then \
|
||||
jsonlint "$$file" >/dev/null || { \
|
||||
echo "JSON syntax error in $$file"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
echo "JSON syntax error in $$file"; exit 1; }; \
|
||||
elif command -v jq >/dev/null 2>&1; then \
|
||||
jq empty "$$file" >/dev/null || { \
|
||||
echo "JSON syntax error in $$file"; \
|
||||
exit 1; \
|
||||
}; \
|
||||
echo "JSON syntax error in $$file"; exit 1; }; \
|
||||
else \
|
||||
echo "No JSON linter found, skipping $$file"; \
|
||||
fi; \
|
||||
done
|
||||
echo "No JSON linter found, skipping $$file"; fi' \
|
||||
sh {} \;
|
||||
@echo "JSON files passed linting!"
|
||||
|
||||
# Check EditorConfig compliance
|
||||
lint-editorconfig:
|
||||
@echo "Checking EditorConfig compliance..."
|
||||
@if command -v editorconfig-checker >/dev/null 2>&1; then \
|
||||
editorconfig-checker; \
|
||||
elif command -v ec >/dev/null 2>&1; then \
|
||||
ec; \
|
||||
else \
|
||||
echo "Installing editorconfig-checker..."; \
|
||||
.github/install_editorconfig-checker.sh; \
|
||||
editorconfig-checker; \
|
||||
fi
|
||||
@echo "EditorConfig compliance passed!"
|
||||
|
||||
# Fix auto-fixable linting issues
|
||||
lint-fix:
|
||||
@echo "Fixing linting issues..."
|
||||
@@ -134,7 +153,7 @@ test:
|
||||
test-ci:
|
||||
@echo "Testing plugin installation in CI..."
|
||||
@fish -c "\
|
||||
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source; \
|
||||
curl -sL $(FISHER_URL) | source; \
|
||||
fisher install jorgebucaran/fisher; \
|
||||
if fisher list | string match -q '*ivuorinen/nvm-auto-use.fish*'; \
|
||||
echo 'Plugin already installed, skipping installation'; \
|
||||
@@ -143,9 +162,30 @@ test-ci:
|
||||
end; \
|
||||
echo 'Plugin test completed successfully in CI!'"
|
||||
|
||||
# Run unit tests
|
||||
test-unit:
|
||||
@echo "Running unit tests..."
|
||||
@chmod +x tests/test_runner.fish
|
||||
@for test in tests/unit/*.fish; do \
|
||||
echo "Running $$test..."; \
|
||||
fish "$$test" || exit 1; \
|
||||
done
|
||||
@echo "Unit tests completed!"
|
||||
|
||||
# Run integration tests
|
||||
test-integration:
|
||||
@echo "Running integration tests..."
|
||||
@chmod +x tests/test_runner.fish
|
||||
@for test in tests/integration/*.fish; do \
|
||||
echo "Running $$test..."; \
|
||||
fish "$$test" || exit 1; \
|
||||
done
|
||||
@echo "Integration tests completed!"
|
||||
|
||||
# Clean temporary files
|
||||
clean:
|
||||
@echo "Cleaning temporary files..."
|
||||
@find . -name "*.tmp" -type f -delete 2>/dev/null || true
|
||||
@find . -name ".DS_Store" -type f -delete 2>/dev/null || true
|
||||
@echo "Cleanup complete!"
|
||||
@nvm_cache clear 2>/dev/null || true
|
||||
@echo "Cleanup complete!"
|
||||
|
||||
Reference in New Issue
Block a user