mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 02:17:25 +02:00
* feat(api): add OpenAPI v1 spec skeleton, lint ruleset and bundle tooling vacuum v0.30.6's `bundle --composed` mangles component names for this spec's multi-file layout (duplicates Problem as Problem__schemas etc.), so api-bundle uses the Redocly CLI (npx @redocly/cli bundle) instead. * fix(api): pin the Redocly CLI version Tried moving components out of the root document (per libopenapi's nested_files example) so vacuum's own bundler could produce clean names, but any component declared via $ref inside components.* still gets a __<parent>-suffixed twin regardless of collisions elsewhere, so vacuum's --composed bundler can't cleanly bundle this spec. Pin the already-working Redocly fallback to an exact version instead of @latest. * fix(api): bundle the OpenAPI spec with vacuum vacuum's --composed bundler suffixes any component reached via a $ref written directly inside the root document's own components.* block, regardless of collisions elsewhere. Dropping the root-level schemas/ parameters/responses declarations (keeping only securitySchemes, and leaving every component file under api/openapi/components/ untouched) lets vacuum bundle cleanly with no __ suffixes, going back to Go-only tooling. Components nothing references yet (ListMeta, offset, limit, BadRequest, Unauthorized, Forbidden, NotFound) are absent from the bundle until a later task's operation references them. * fix(api): make spec lint rules cover all schemas and error codes nd-schema-property-descriptions targeted $.components.schemas, but our schemas live in path/response files, not the root document, so it was dead code; switched to $..properties[*] to walk every resolved schema wherever it ends up. nd-error-responses-are-problems only checked a hardcoded status-code list; switched to a patternProperties schema matching the full 4xx/5xx range. Also: api-diff now diffs against the merge-base with API_DIFF_BASE (falling back to its tip with a notice if no merge-base exists), gen no longer depends on api-gen until Task 3 wires up oapi-codegen, and api-lint suppresses vacuum's banner. * feat(api): embed the bundled OpenAPI spec and expose its version * feat(api): generate the v1 server interface with oapi-codegen * feat(api): add RFC 9457 problem responses for API v1 * feat(api): add API v1 router with /server discovery and spec routes * fix(api): serve the OpenAPI document without range support * feat(api): mount API v1 behind the DevAPIv1 flag * chore(ci): lint, regenerate and diff the OpenAPI v1 spec * refactor(api): tighten spec version access, lint rules and test naming * refactor(api): simplify spec routes, tests and OpenAPI tooling Share one If-None-Match parser (utils/req) between the image and spec routes, declare the YAML spec response as an object so tests need no decoder override, and reuse ETag/304 spec components. Install the OpenAPI tools only when missing or at a different version, fail api-diff when its base ref does not exist, and in CI cache the tools, fold regeneration into the go generate check, and fetch only the PR base commit for the breaking-change gate. * refactor(api): raise the list limit maximum to 2000 and drop the flag test * feat(api): treat added enum values as non-breaking Enums in API v1 are open: clients must accept unknown values. api-diff now downgrades response-property-enum-value-added to INFO, while removing a value from a request enum stays breaking. * feat(api): gate breaking changes on x-stability-level Every operation declares x-stability-level (alpha, beta, stable). oasdiff ignores breaking changes to alpha operations and rejects lowering a level, so unreleased endpoints can evolve while beta and stable ones stay additive. All current operations start as alpha. * feat(api): declare loginMethods as an enum Prefix generated enum constants with their type name so enums sharing a value (for example password) cannot collide in package apiv1. * feat(api): send Allow on 405 and answer HEAD wherever GET is routed chi only sets Allow in its default 405 handler, so the problem-format handler now builds it by matching each method against the v1 router. HEAD requests fall back to the GET route, as RFC 9110 expects. * refactor(api): hash the spec ETag with xxh3 The bytes are compiled in, and the digest was truncated to 64 bits anyway, so this matches the artwork ETags instead of paying for cryptographic strength we discard. * docs(api): explain the about:blank problem type * feat(api): make code the problem identifier and omit a blank type RFC 9457 says clients switch on the type URI, but no adopter surveyed ships both a populated type and a separate code. Declare code as an enum, and send type only once a problem has semantics of its own. * fix(api): advertise the configured base path in the served OpenAPI spec With BaseURL=/music the API is mounted at /music/api/v1, but the spec told clients to call /api/v1 at the host root. The server now rewrites servers[0].url to BasePath + /api/v1 when it serves the document. Relative server URLs were tested first: "." and "../v1" work in openapi-generator, Swagger UI and Redoc, but Scalar resolves them against the page origin, so it breaks even without a base path. The committed bundle keeps /api/v1, and a test pins that it appears exactly once, which the rewrite relies on.
371 lines
16 KiB
Makefile
371 lines
16 KiB
Makefile
GO_VERSION=$(shell grep "^go " go.mod | cut -f 2 -d ' ')
|
|
NODE_VERSION=$(shell cat .nvmrc)
|
|
|
|
comma:=,
|
|
GO_BUILD_TAGS=netgo,sqlite_fts5$(if $(EXTRA_BUILD_TAGS),$(comma)$(EXTRA_BUILD_TAGS))
|
|
|
|
# Set global environment variables, required for most targets
|
|
export ND_ENABLEINSIGHTSCOLLECTOR=false
|
|
|
|
ifneq ("$(wildcard .git/HEAD)","")
|
|
GIT_SHA=$(shell git rev-parse --short HEAD)
|
|
GIT_TAG=$(shell git describe --tags --abbrev=0 2>/dev/null || echo v0.0.0)-SNAPSHOT
|
|
else
|
|
GIT_SHA=source_archive
|
|
GIT_TAG=$(patsubst navidrome-%,v%,$(notdir $(PWD)))-SNAPSHOT
|
|
endif
|
|
|
|
SUPPORTED_PLATFORMS ?= linux/amd64,linux/arm64,linux/arm/v5,linux/arm/v6,linux/arm/v7,linux/386,linux/riscv64,darwin/amd64,darwin/arm64,windows/amd64,windows/386
|
|
IMAGE_PLATFORMS ?= $(shell echo $(SUPPORTED_PLATFORMS) | tr ',' '\n' | grep "linux" | grep -v "arm/v5" | tr '\n' ',' | sed 's/,$$//')
|
|
PLATFORMS ?= $(SUPPORTED_PLATFORMS)
|
|
DOCKER_TAG ?= deluan/navidrome:develop
|
|
|
|
GOLANGCI_LINT_VERSION ?= v2.14.0
|
|
VACUUM_VERSION ?= v0.30.6
|
|
OAPI_CODEGEN_VERSION ?= v2.8.0
|
|
OASDIFF_VERSION ?= v1.32.1
|
|
API_DIFF_BASE ?= origin/master
|
|
|
|
UI_SRC_FILES := $(shell find ui -type f -not -path "ui/build/*" -not -path "ui/node_modules/*")
|
|
|
|
setup: check_env download-deps install-golangci-lint setup-git ##@1_Run_First Install dependencies and prepare development environment
|
|
@echo Downloading Node dependencies...
|
|
@(cd ./ui && npm ci)
|
|
.PHONY: setup
|
|
|
|
dev: check_env ##@Development Start Navidrome in development mode, with hot-reload for both frontend and backend
|
|
npx foreman -j Procfile.dev -p 4533 start
|
|
.PHONY: dev
|
|
|
|
server: check_go_env buildjs ##@Development Start the backend in development mode
|
|
go tool reflex -d none -c reflex.conf
|
|
.PHONY: server
|
|
|
|
stop: ##@Development Stop development servers (UI and backend)
|
|
@echo "Stopping development servers..."
|
|
@-pkill -f "vite"
|
|
@-pkill -f "go tool reflex.*reflex.conf"
|
|
@-pkill -f "go run.*netgo"
|
|
@echo "Development servers stopped."
|
|
.PHONY: stop
|
|
|
|
watch: ##@Development Start Go tests in watch mode (re-run when code changes)
|
|
go tool ginkgo watch -tags=$(GO_BUILD_TAGS) -notify ./...
|
|
.PHONY: watch
|
|
|
|
PKG ?= ./...
|
|
test: ##@Development Run Go tests. Use PKG variable to specify packages to test, e.g. make test PKG=./server
|
|
go test -tags $(GO_BUILD_TAGS) $(PKG)
|
|
.PHONY: test
|
|
|
|
test-ndpgen: ##@Development Run tests for ndpgen plugin
|
|
cd plugins/cmd/ndpgen && go test ./......
|
|
.PHONY: test-ndpgen
|
|
|
|
testall: test test-ndpgen test-i18n test-js ##@Development Run Go and JS tests
|
|
.PHONY: testall
|
|
|
|
test-race: ##@Development Run Go tests with race detector
|
|
go test -tags $(GO_BUILD_TAGS) -race -shuffle=on $(PKG)
|
|
.PHONY: test-race
|
|
|
|
test-js: ##@Development Run JS tests
|
|
@(cd ./ui && npm run test)
|
|
.PHONY: test-js
|
|
|
|
test-i18n: ##@Development Validate all translations files
|
|
./.github/workflows/validate-translations.sh
|
|
.PHONY: test-i18n
|
|
|
|
install-golangci-lint: ##@Development Install golangci-lint if not present
|
|
@INSTALL=false; \
|
|
if PATH=./bin:$$PATH which golangci-lint > /dev/null 2>&1; then \
|
|
CURRENT_VERSION=$$(PATH=./bin:$$PATH golangci-lint version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1); \
|
|
REQUIRED_VERSION=$$(echo "$(GOLANGCI_LINT_VERSION)" | sed 's/^v//'); \
|
|
if [ "$$CURRENT_VERSION" != "$$REQUIRED_VERSION" ]; then \
|
|
echo "Found golangci-lint $$CURRENT_VERSION, but $$REQUIRED_VERSION is required. Reinstalling..."; \
|
|
rm -f ./bin/golangci-lint; \
|
|
INSTALL=true; \
|
|
fi; \
|
|
else \
|
|
INSTALL=true; \
|
|
fi; \
|
|
if [ "$$INSTALL" = "true" ]; then \
|
|
echo "Installing golangci-lint $(GOLANGCI_LINT_VERSION)..."; \
|
|
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s $(GOLANGCI_LINT_VERSION); \
|
|
fi
|
|
.PHONY: install-golangci-lint
|
|
|
|
install-api-tools: ##@Development Install OpenAPI tools (vacuum, oapi-codegen, oasdiff) into ./bin
|
|
@STAMP=bin/.api-tools-$(VACUUM_VERSION)-$(OAPI_CODEGEN_VERSION)-$(OASDIFF_VERSION); \
|
|
if [ ! -f $$STAMP ] || [ ! -x bin/vacuum ] || [ ! -x bin/oapi-codegen ] || [ ! -x bin/oasdiff ]; then \
|
|
echo "Installing OpenAPI tools..."; \
|
|
GOBIN=$(CURDIR)/bin go install github.com/daveshanley/vacuum@$(VACUUM_VERSION) && \
|
|
GOBIN=$(CURDIR)/bin go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@$(OAPI_CODEGEN_VERSION) && \
|
|
GOBIN=$(CURDIR)/bin go install github.com/oasdiff/oasdiff@$(OASDIFF_VERSION) && \
|
|
rm -f bin/.api-tools-* && touch $$STAMP; \
|
|
fi
|
|
.PHONY: install-api-tools
|
|
|
|
api-lint: install-api-tools ##@Development Lint the OpenAPI spec
|
|
./bin/vacuum lint -r api/.vacuum.yaml -d -q -b --fail-severity error api/openapi/openapi.yaml
|
|
.PHONY: api-lint
|
|
|
|
api-bundle: install-api-tools ##@Development Bundle the multi-file OpenAPI spec into api/bundled
|
|
./bin/vacuum bundle -q --composed -p api/openapi api/openapi/openapi.yaml api/bundled/openapi.yaml
|
|
./bin/vacuum bundle -q --composed --format json -p api/openapi api/openapi/openapi.yaml api/bundled/openapi.json
|
|
.PHONY: api-bundle
|
|
|
|
api-gen: api-bundle ##@Development Generate the API v1 server code from the bundled spec
|
|
./bin/oapi-codegen -config server/apiv1/oapi-codegen.yaml api/bundled/openapi.json
|
|
.PHONY: api-gen
|
|
|
|
api-diff: api-bundle ##@Development Fail on breaking OpenAPI changes against the merge-base with $(API_DIFF_BASE)
|
|
@git rev-parse --verify --quiet $(API_DIFF_BASE)^{commit} >/dev/null || { echo "Base ref $(API_DIFF_BASE) not found; set API_DIFF_BASE"; exit 1; }; \
|
|
BASE="$$(git merge-base HEAD $(API_DIFF_BASE) 2>/dev/null)"; \
|
|
if [ -z "$$BASE" ]; then \
|
|
echo "No merge-base with $(API_DIFF_BASE); falling back to its tip"; \
|
|
BASE=$(API_DIFF_BASE); \
|
|
fi; \
|
|
if git cat-file -e $$BASE:api/bundled/openapi.json 2>/dev/null; then \
|
|
git show $$BASE:api/bundled/openapi.json > $(CURDIR)/bin/api-base.json && \
|
|
./bin/oasdiff breaking $(CURDIR)/bin/api-base.json api/bundled/openapi.json --fail-on ERR --severity-levels api/.oasdiff-levels.txt; \
|
|
else \
|
|
echo "No bundled spec at $$BASE; skipping breaking-change check"; \
|
|
fi
|
|
.PHONY: api-diff
|
|
|
|
lint: install-golangci-lint ##@Development Lint Go code
|
|
PATH=./bin:$$PATH golangci-lint run --timeout 5m
|
|
.PHONY: lint
|
|
|
|
lintall: lint ##@Development Lint Go and JS code
|
|
@(cd ./ui && npm run check-formatting) || (echo "\n\nPlease run 'npm run prettier' to fix formatting issues." && exit 1)
|
|
@(cd ./ui && npm run lint)
|
|
.PHONY: lintall
|
|
|
|
format: ##@Development Format code
|
|
@(cd ./ui && npm run prettier)
|
|
@go tool goimports -w `find . -name '*.go' | grep -v _gen.go$$ | grep -v .pb.go$$`
|
|
@go mod tidy
|
|
.PHONY: format
|
|
|
|
wire: check_go_env ##@Development Update Dependency Injection
|
|
go tool wire gen -tags="$$(echo '$(GO_BUILD_TAGS)' | tr ',' ' ')" ./...
|
|
.PHONY: wire
|
|
|
|
gen: check_go_env api-gen ##@Development Run go generate for code generation
|
|
go generate ./...
|
|
cd plugins/cmd/ndpgen && go run . -shared-types -input=../../types -output=../../pdk -go -rust
|
|
cd plugins/cmd/ndpgen && go run . -host-wrappers -input=../../host -package=host -shared=../../types
|
|
cd plugins/cmd/ndpgen && go run . -input=../../host -output=../../pdk -go -rust -shared=../../types
|
|
cd plugins/cmd/ndpgen && go run . -capability-only -input=../../capabilities -output=../../pdk -go -rust -shared=../../types
|
|
cd plugins/cmd/ndpgen && go run . -schemas -input=../../capabilities -shared=../../types
|
|
go mod tidy -C plugins/pdk/go
|
|
.PHONY: gen
|
|
|
|
snapshots: ##@Development Update (GoLang) Snapshot tests
|
|
UPDATE_SNAPSHOTS=true go tool ginkgo ./server/subsonic/responses/...
|
|
.PHONY: snapshots
|
|
|
|
migration-sql: ##@Development Create an empty SQL migration file
|
|
@if [ -z "${name}" ]; then echo "Usage: make migration-sql name=name_of_migration_file"; exit 1; fi
|
|
go run github.com/pressly/goose/v3/cmd/goose@latest -dir db/migrations create ${name} sql
|
|
.PHONY: migration
|
|
|
|
migration-go: ##@Development Create an empty Go migration file
|
|
@if [ -z "${name}" ]; then echo "Usage: make migration-go name=name_of_migration_file"; exit 1; fi
|
|
go run github.com/pressly/goose/v3/cmd/goose@latest -dir db/migrations create ${name}
|
|
.PHONY: migration
|
|
|
|
setup-dev: setup
|
|
.PHONY: setup-dev
|
|
|
|
setup-git: ##@Development Setup Git hooks (pre-commit and pre-push)
|
|
@echo Setting up git hooks
|
|
@mkdir -p .git/hooks
|
|
@(cd .git/hooks && ln -sf ../../git/* .)
|
|
.PHONY: setup-git
|
|
|
|
build: check_go_env buildjs ##@Build Build the project
|
|
go build -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)" -tags=$(GO_BUILD_TAGS)
|
|
.PHONY: build
|
|
|
|
buildall: deprecated build
|
|
.PHONY: buildall
|
|
|
|
debug-build: check_go_env buildjs ##@Build Build the project (with remote debug on)
|
|
go build -gcflags="all=-N -l" -ldflags="-X github.com/navidrome/navidrome/consts.gitSha=$(GIT_SHA) -X github.com/navidrome/navidrome/consts.gitTag=$(GIT_TAG)" -tags=$(GO_BUILD_TAGS)
|
|
.PHONY: debug-build
|
|
|
|
buildjs: check_node_env ui/build/index.html ##@Build Build only frontend
|
|
.PHONY: buildjs
|
|
|
|
docker-buildjs: ##@Build Build only frontend using Docker
|
|
docker build --output "./ui" --target ui-bundle .
|
|
.PHONY: docker-buildjs
|
|
|
|
ui/build/index.html: $(UI_SRC_FILES)
|
|
@(cd ./ui && npm run build)
|
|
|
|
docker-platforms: ##@Cross_Compilation List supported platforms
|
|
@echo "Supported platforms:"
|
|
@echo "$(SUPPORTED_PLATFORMS)" | tr ',' '\n' | sort | sed 's/^/ /'
|
|
@echo "\nUsage: make PLATFORMS=\"linux/amd64\" docker-build"
|
|
@echo " make IMAGE_PLATFORMS=\"linux/amd64\" docker-image"
|
|
.PHONY: docker-platforms
|
|
|
|
docker-build: ##@Cross_Compilation Cross-compile for any supported platform (check `make docker-platforms`)
|
|
docker buildx build \
|
|
--platform $(PLATFORMS) \
|
|
--build-arg GIT_TAG=${GIT_TAG} \
|
|
--build-arg GIT_SHA=${GIT_SHA} \
|
|
--output "./binaries" --target binary .
|
|
.PHONY: docker-build
|
|
|
|
docker-image: ##@Cross_Compilation Build Docker image, tagged as `deluan/navidrome:develop`, override with DOCKER_TAG var. Use IMAGE_PLATFORMS to specify target platforms
|
|
@echo $(IMAGE_PLATFORMS) | grep -q "windows" && echo "ERROR: Windows is not supported for Docker builds" && exit 1 || true
|
|
@echo $(IMAGE_PLATFORMS) | grep -q "darwin" && echo "ERROR: macOS is not supported for Docker builds" && exit 1 || true
|
|
@echo $(IMAGE_PLATFORMS) | grep -q "arm/v5" && echo "ERROR: Linux ARMv5 is not supported for Docker builds" && exit 1 || true
|
|
docker buildx build \
|
|
--platform $(IMAGE_PLATFORMS) \
|
|
--build-arg GIT_TAG=${GIT_TAG} \
|
|
--build-arg GIT_SHA=${GIT_SHA} \
|
|
--tag $(DOCKER_TAG) .
|
|
.PHONY: docker-image
|
|
|
|
docker-msi: ##@Cross_Compilation Build MSI installer for Windows
|
|
make docker-build PLATFORMS=windows/386,windows/amd64
|
|
DOCKER_CLI_HINTS=false docker build -q -t navidrome-msi-builder -f release/wix/msitools.dockerfile .
|
|
@rm -rf binaries/msi
|
|
docker run -it --rm -v $(PWD):/workspace -v $(PWD)/binaries:/workspace/binaries -e GIT_TAG=${GIT_TAG} \
|
|
navidrome-msi-builder sh -c "release/wix/build_msi.sh /workspace 386 && release/wix/build_msi.sh /workspace amd64"
|
|
@du -h binaries/msi/*.msi
|
|
.PHONY: docker-msi
|
|
|
|
docker-run: ##@Development Run a Navidrome Docker image. Usage: make docker-run tag=<tag>
|
|
@if [ -z "$(tag)" ]; then echo "Usage: make docker-run tag=<tag>"; exit 1; fi
|
|
@TAG_DIR="tmp/$$(echo '$(tag)' | tr '/:' '_')"; mkdir -p "$$TAG_DIR"; \
|
|
VOLUMES="-v $(PWD)/$$TAG_DIR:/data"; \
|
|
if [ -f navidrome.toml ]; then \
|
|
VOLUMES="$$VOLUMES -v $(PWD)/navidrome.toml:/data/navidrome.toml:ro"; \
|
|
MUSIC_FOLDER=$$(grep '^MusicFolder' navidrome.toml | head -n1 | sed 's/.*= *"//' | sed 's/".*//'); \
|
|
if [ -n "$$MUSIC_FOLDER" ] && [ -d "$$MUSIC_FOLDER" ]; then \
|
|
VOLUMES="$$VOLUMES -v $$MUSIC_FOLDER:/music:ro"; \
|
|
fi; \
|
|
fi; \
|
|
echo "Running: docker run --rm -p 4533:4533 $$VOLUMES $(tag)"; docker run --rm -p 4533:4533 $$VOLUMES $(tag)
|
|
.PHONY: docker-run
|
|
|
|
package: docker-build ##@Cross_Compilation Create binaries and packages for ALL supported platforms
|
|
@if [ -z `which goreleaser` ]; then echo "Please install goreleaser first: https://goreleaser.com/install/"; exit 1; fi
|
|
goreleaser release -f release/goreleaser.yml --clean --skip=publish --snapshot
|
|
.PHONY: package
|
|
|
|
get-music: ##@Development Download some free music from Navidrome's demo instance
|
|
mkdir -p music
|
|
( cd music; \
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=2Y3qQA6zJC3ObbBrF9ZBoV" > brock.zip; \
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=04HrSORpypcLGNUdQp37gn" > back_on_earth.zip; \
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=5xcMPJdeEgNrGtnzYbzAqb" > ugress.zip; \
|
|
curl "https://demo.navidrome.org/rest/download?u=demo&p=demo&f=json&v=1.8.0&c=dev_download&id=1jjQMAZrG3lUsJ0YH6ZRS0" > voodoocuts.zip; \
|
|
for file in *.zip; do unzip -n $${file}; done )
|
|
@echo "Done. Remember to set your MusicFolder to ./music"
|
|
.PHONY: get-music
|
|
|
|
|
|
##########################################
|
|
#### Worktrees
|
|
|
|
WORKTREES_DIR := .worktrees
|
|
|
|
wt: check_go_env ##@Worktrees Create and setup a git worktree. Usage: make wt name=feature-name [go=1]
|
|
@if [ -z "${name}" ]; then echo "Usage: make wt name=<branch-name> [go=1]"; exit 1; fi
|
|
@mkdir -p $(WORKTREES_DIR)
|
|
@echo "Creating worktree for branch '${name}'..."
|
|
@git worktree add $(WORKTREES_DIR)/${name} -b ${name} 2>/dev/null || \
|
|
git worktree add $(WORKTREES_DIR)/${name} ${name}
|
|
@if [ -n "${go}" ]; then \
|
|
./scripts/setup-worktree.sh $(WORKTREES_DIR)/${name} --go-only; \
|
|
else \
|
|
./scripts/setup-worktree.sh $(WORKTREES_DIR)/${name}; \
|
|
fi
|
|
@echo "\nWorktree ready at $(WORKTREES_DIR)/${name}"
|
|
@echo " cd $(WORKTREES_DIR)/${name}"
|
|
.PHONY: wt
|
|
|
|
rm-wt: ##@Worktrees Remove a git worktree. Usage: make rm-wt name=feature-name
|
|
@if [ -z "${name}" ]; then echo "Usage: make rm-wt name=<branch-name>"; exit 1; fi
|
|
@if [ ! -d "$(WORKTREES_DIR)/${name}" ]; then echo "Worktree '${name}' not found in $(WORKTREES_DIR)/"; exit 1; fi
|
|
@echo "Removing worktree '${name}'..."
|
|
@git worktree remove --force $(WORKTREES_DIR)/${name}
|
|
@echo "Worktree '${name}' removed."
|
|
@echo "Note: branch '${name}' still exists. Delete it with: git branch -D ${name}"
|
|
.PHONY: rm-wt
|
|
|
|
ls-wt: ##@Worktrees List all active git worktrees
|
|
@git worktree list
|
|
.PHONY: ls-wt
|
|
|
|
##########################################
|
|
#### Miscellaneous
|
|
|
|
clean:
|
|
@rm -rf ./binaries ./dist ./ui/build/*
|
|
@touch ./ui/build/.gitkeep
|
|
.PHONY: clean
|
|
|
|
release:
|
|
@if [[ ! "${V}" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$$ ]]; then echo "Usage: make release V=X.X.X"; exit 1; fi
|
|
go mod tidy
|
|
@if [ -n "`git status -s`" ]; then echo "\n\nThere are pending changes. Please commit or stash first"; exit 1; fi
|
|
make pre-push
|
|
git tag v${V}
|
|
git push origin v${V} --no-verify
|
|
.PHONY: release
|
|
|
|
download-deps:
|
|
@echo Downloading Go dependencies...
|
|
@go mod download
|
|
@go mod tidy # To revert any changes made by the `go mod download` command
|
|
.PHONY: download-deps
|
|
|
|
check_env: check_go_env check_node_env
|
|
.PHONY: check_env
|
|
|
|
check_go_env:
|
|
@(hash go) || (echo "\nERROR: GO environment not setup properly!\n"; exit 1)
|
|
@current_go_version=`go version | cut -d ' ' -f 3 | cut -c3-` && \
|
|
echo "$(GO_VERSION) $$current_go_version" | \
|
|
tr ' ' '\n' | sort -V | tail -1 | \
|
|
grep -q "^$${current_go_version}$$" || \
|
|
(echo "\nERROR: Please upgrade your GO version\nThis project requires at least the version $(GO_VERSION)"; exit 1)
|
|
.PHONY: check_go_env
|
|
|
|
check_node_env:
|
|
@(hash node) || (echo "\nERROR: Node environment not setup properly!\n"; exit 1)
|
|
@current_node_version=`node --version` && \
|
|
echo "$(NODE_VERSION) $$current_node_version" | \
|
|
tr ' ' '\n' | sort -V | tail -1 | \
|
|
grep -q "^$${current_node_version}$$" || \
|
|
(echo "\nERROR: Please check your Node version. Should be at least $(NODE_VERSION)\n"; exit 1)
|
|
.PHONY: check_node_env
|
|
|
|
pre-push: lintall testall
|
|
.PHONY: pre-push
|
|
|
|
deprecated:
|
|
@echo "WARNING: This target is deprecated and will be removed in future releases. Use 'make build' instead."
|
|
.PHONY: deprecated
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
HELP_FUN = \
|
|
%help; while(<>){push@{$$help{$$2//'options'}},[$$1,$$3] \
|
|
if/^([\w-_]+)\s*:.*\#\#(?:@(\w+))?\s(.*)$$/}; \
|
|
print"$$_:\n", map" $$_->[0]".(" "x(20-length($$_->[0])))."$$_->[1]\n",\
|
|
@{$$help{$$_}},"\n" for sort keys %help; \
|
|
|
|
help: ##@Miscellaneous Show this help
|
|
@echo "Usage: make [target] ...\n"
|
|
@perl -e '$(HELP_FUN)' $(MAKEFILE_LIST)
|