Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 76 additions & 44 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:\
Expand Down