diff --git a/Makefile b/Makefile index fa0fdd3..30f193a 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,9 @@ BUILDABLE := $(shell node -p "Boolean(require('./package.json').scripts?.build)" PACKAGE_NAME := $(shell node -p "require('./package.json').name") BUNDLE_NAME := $(subst @patternslib/,,$(subst @plone/,,$(PACKAGE_NAME))) + ## +## User targets +# # Repeat this install target in consuming packages' Makefiles: on a fresh # checkout, @patternslib/dev and this shared Makefile are not installed yet. @@ -47,10 +50,6 @@ update: -git commit package.json -m"maint: Update dependencies." -git commit pnpm-lock.yaml -m"pnpm-lock.yaml: Update." -n -.git/hooks/commit-msg: - echo "npx commitlint --edit" > .git/hooks/commit-msg - chmod u+x .git/hooks/commit-msg - .PHONY: clean-dist clean-dist: @@ -62,41 +61,92 @@ clean: clean-dist rm -Rf node_modules/ -.PHONY: eslint +.PHONY: lint eslint +lint: eslint eslint: install $(ESLINT) ./src -.PHONY: prettier +.PHONY: format prettier +format: prettier prettier: install $(PRETTIER) --write . -.PHONY: check +# NOTE: Needs a package.json script. Not implemented here. +.PHONY: test check +test: check check: install eslint $(PNPM) run test -.PHONY: bundle-pre -bundle-pre:: - @# Override this in your project to add some tasks before the bundle is built. - @# Please use double-colons `::` so that the base bundle-pre is also run. - @# Example: Unlink any linked dependencies. - @# bundle-pre:: - @# -pnpm unlink --recursive - @# pnpm install - npx update-browserslist-db@latest +# NOTE: Needs a package.json script. Not implemented here. +.PHONY: start serve +start: serve +serve: install + $(PNPM) run start + + +# NOTE: Needs a package.json script. Not implemented here. +.PHONY: watch +watch: install + $(PNPM) run watch # Compile the bundle. +# NOTE: Needs a package.json script. Not implemented here. # NOTE: When using the normal workflow - e.g. `make release-minor`, the # relase-it config runs `make bundle` after the version bump. -.PHONY: bundle +.PHONY: build bundle +build: bundle bundle: clean-dist bundle-pre install ifeq ($(BUILDABLE),true) $(PNPM) run build endif +.PHONY: release-major +release-major: + $(MAKE) LEVEL=major release + + +.PHONY: release-minor +release-minor: + $(MAKE) LEVEL=minor release + + +.PHONY: release-patch +release-patch: + $(MAKE) LEVEL=patch release + +.PHONY: prerelease-alpha +prerelease-alpha: + $(MAKE) LEVEL=alpha release + +.PHONY: prerelease-beta +prerelease-beta: + $(MAKE) LEVEL=beta release + + + ## +## Helper targets +# + + +.git/hooks/commit-msg: + echo "npx commitlint --edit" > .git/hooks/commit-msg + chmod u+x .git/hooks/commit-msg + + +.PHONY: bundle-pre +bundle-pre:: + @# Override this in your project to add some tasks before the bundle is built. + @# Please use double-colons `::` so that the base bundle-pre is also run. + @# Example: Unlink any linked dependencies. + @# bundle-pre:: + @# -pnpm unlink --recursive + @# pnpm install + npx update-browserslist-db@latest + # Create a ZIP file from the bundle which is uploaded to the GitHub release tag. # NOTE: When using the normal workflow - e.g. `make release-minor`, the @@ -136,7 +186,12 @@ endif release: clean install check prepare-release @# Note: The consuming package must include dist/ in its package.json files list. - $(eval PACKAGE_VERSION := $(shell npx release-it $(RELEASE_IT_LEVEL) --release-version)) + @# Get the version to be released. + @# `--release-version` implies CI mode, where release-it cannot do the + @# interactive npm login and would fail with no output if not logged in. + @# Skip the npm checks here - they are done in the real release run below. + $(eval PACKAGE_VERSION := $(shell npx release-it $(RELEASE_IT_LEVEL) --release-version --npm.skipChecks)) + $(if $(PACKAGE_VERSION),,$(error Could not determine the release version via release-it)) ifeq ($(BUILDABLE),true) $(eval RELEASE_IT_GITHUB_OPTIONS += --github.assets=$(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip) endif @@ -153,32 +208,9 @@ endif -rm $(BUNDLE_NAME)-bundle-$(PACKAGE_VERSION).zip -.PHONY: release-major -release-major: - $(MAKE) LEVEL=major release - - -.PHONY: release-minor -release-minor: - $(MAKE) LEVEL=minor release - - -.PHONY: release-patch -release-patch: - $(MAKE) LEVEL=patch release - -.PHONY: prerelease-alpha -prerelease-alpha: - $(MAKE) LEVEL=alpha release - -.PHONY: prerelease-beta -prerelease-beta: - $(MAKE) LEVEL=beta release - - -.PHONY: serve -serve: install - $(PNPM) run start + ## +## Upgrades +# upgrade:\