-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
117 lines (87 loc) · 2.99 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Makefile preamble (https://tech.davis-hansson.com/p/make/)
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifeq ($(origin .RECIPEPREFIX), undefined)
$(error This Make does not support .RECIPEPREFIX. Please use GNU Make 4.0 or later)
endif
.RECIPEPREFIX = >
ifndef VERBOSE
MAKEFLAGS += --no-print-directory
endif
.PHONY: help all \
> check-tool-pnpm \
> dist install clean \
> changelog \
> build build-watch \
> lint lint-watch \
> test test-unit \
> target-dir publish publish-prerelease \
> version-bump-major version-bump-minor version-bump-patch version-bump-prerelease
all: install build
help: ## Display this help
> @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_\-.*]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
PNPM ?= pnpm
NPM ?= npm
TAPE ?= ./node_modules/.bin/tape
GIT ?= git
PACKAGE_NAME ?= nestjs-logger-roarr
VERSION ?= $(shell grep version package.json | cut -d ' ' -f 4 | tr -d ,\")
check-tool-pnpm:
> @which pnpm > /dev/null || (echo -e "\n[ERROR] please install pnpm (http://pnpmpkg.com/)" && exit 1)
install: dist
> @echo -e "=> running pnpm install..."
> $(PNPM) install
###############
# Development #
###############
print-version: ## print project version
> @echo -n "$(VERSION)"
CHANGELOG_FILE_PATH ?= CHANGELOG
changelog: ## generate changelog
> $(GIT) cliff --unreleased --tag=$(VERSION) --prepend=$(CHANGELOG_FILE_PATH)
build: dist ## build the project
> $(PNPM) build
build-watch: dist ## build the project (continuously)
> $(PNPM) build-watch
clean: ## clean the output directory
> rm -rf dist/*
#########
# Tests #
#########
test: test-unit test-int # run all tests
test-unit: check-tool-pnpm # run unit tests
> $(PNPM) test-unit
test-int: check-tool-pnpm # run integration tests
> $(PNPM) test-int
#############
# Packaging #
#############
PACKAGE_FILENAME ?= $(PACKAGE_NAME)-$(VERSION).tgz
PACKAGE_PATH ?= $(PACKAGE_FILENAME)
print-package-filename: # print package filename
> @echo "$(PACKAGE_FILENAME)"
version-bump-prerelease:
> $(PNPM) version prerelease --preid=rc
version-bump-major:
> $(MAKE) changelog
> $(GIT) commit -am "chore(release): update CHANGELOG"
> $(PNPM) version major
version-bump-minor:
> $(MAKE) changelog
> $(GIT) commit -am "chore(release): update CHANGELOG"
> $(PNPM) version minor
version-bump-patch:
> $(MAKE) changelog
> $(GIT) commit -am "chore(release): update CHANGELOG"
> $(PNPM) version patch
# NOTE: if you try to test this package locally (ex. using `pnpm add path/to/nodejs-logger-roarr-<version>.tgz`),
# you will have to `pnpm cache clean` between every update.
# as one command: `pnpm cache clean && pnpm remove nodejs-logger-roarr && pnpm add path/to/nodejs-logger-roarr-v0.1.0.tgz`
package: clean build # package the project
> $(PNPM) pack
publish: package # package & publish to NPM
> $(PNPM) publish $(PACKAGE_PATH)