-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
193 lines (151 loc) · 4.77 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
-include .env
# BuildKit enables higher performance docker builds and caching possibility
# to decrease build times and increase productivity for free.
export DOCKER_BUILDKIT ?= 1
export COMPOSE_DOCKER_CLI_BUILD ?= 1
# https://github.com/vercel/turbo/issues/223
export FORCE_COLOR ?= 1
# Binary to use, when executing docker-compose tasks
DOCKER ?= docker
DOCKER_COMPOSE ?= docker-compose
# Support image with all needed binaries, like envsubst, mkcert, wait4x
SUPPORT_IMAGE ?= wayofdev/build-deps:alpine-latest
BUILDER_PARAMS ?= docker run \
--rm \
-i \
-v $(PWD):/app \
--workdir /app
BUILDER ?= $(BUILDER_PARAMS) $(SUPPORT_IMAGE)
NPM_BIN ?= pnpm
NPX_BIN ?= npx
# Self documenting Makefile code
# ------------------------------------------------------------------------------------
ifneq ($(TERM),)
BLACK := $(shell tput setaf 0)
RED := $(shell tput setaf 1)
GREEN := $(shell tput setaf 2)
YELLOW := $(shell tput setaf 3)
LIGHTPURPLE := $(shell tput setaf 4)
PURPLE := $(shell tput setaf 5)
BLUE := $(shell tput setaf 6)
WHITE := $(shell tput setaf 7)
RST := $(shell tput sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RST := ""
endif
MAKE_LOGFILE = /tmp/npm-shareable-configs.log
MAKE_CMD_COLOR := $(BLUE)
default: all
help: ## Show this menu
@echo 'Management commands for package:'
@echo 'Usage:'
@echo ' ${MAKE_CMD_COLOR}make${RST} Prepares and spins up project with default settings'
@grep -E '^[a-zA-Z_0-9%-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf " ${MAKE_CMD_COLOR}make %-21s${RST} %s\n", $$1, $$2}'
@echo
@echo ' 📑 Logs are stored in $(MAKE_LOGFILE)'
@echo
@echo ' 📦 Package npm-shareable-configs (github.com/wayofdev/npm-shareable-configs)'
@echo ' 🤠 Author Andrij Orlenko (github.com/lotyp)'
@echo ' 🏢 ${YELLOW}Org wayofdev (github.com/wayofdev)${RST}'
.PHONY: help
.EXPORT_ALL_VARIABLES:
# Default action
# Defines default command when `make` is executed without additional parameters
# ------------------------------------------------------------------------------------
all: install hooks
.PHONY: all
# System Actions
# ------------------------------------------------------------------------------------
i: ## Install dependencies
$(NPM_BIN) i
.PHONY: i
install: i ## Same as `make i`
.PHONY: install
update: ## Run pnpm to packages to their latest version based on the specified range
$(NPM_BIN) update
.PHONY: update
build: ## Build all packages inside monorepo
$(NPM_BIN) run build
.PHONY: build
purge: ## Deletes node modules and temporary files
find . | grep /node_modules$ | grep -v /node_modules/ | xargs rm -fR
find . | grep /.turbo$ | grep -v /.turbo/ | xargs rm -fR
rm -rf .pnpm-store pnpm-lock.yaml
.PHONY: purge
deps-check: ## Check for outdated dependencies
$(NPM_BIN) run deps:check
.PHONY: deps-check
deps-update: ## Check for outdated dependencies and automatically update them using pnpm
$(NPM_BIN) run deps:update
.PHONY: deps-update
login:
$(NPM_BIN) config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
.PHONY: login
# Testing and Code Quality
# ------------------------------------------------------------------------------------
lint: ## Run eslint task
$(NPM_BIN) run lint
.PHONY: lint
lint-staged:
$(NPM_BIN) run lint-staged
.PHONY: lint-staged
lint-commits:
$(NPM_BIN) commitlint --edit "$(1)"
.PHONY: lint-commits
lint-md: ## Lint markdown files
$(NPM_BIN) lint:md
.PHONY: lint-md
lint-dist:
$(NPM_BIN) lint:dist
.PHONY: lint-dist
lint-html: ## Lint html files
$(NPM_BIN) lint:html
.PHONY: lint-html
lint-css: ## Lint css files
$(NPM_BIN) lint:css
.PHONY: lint-css
lint-secrets: ## Check if there are any missed secret credentials in code
$(NPM_BIN) lint:secrets
.PHONY: lint-secrets
lint-yaml: ## Lints yaml files inside project
yamllint .
.PHONY: lint-yaml
lint-actions: ## Lint github actions using actionlint
$(BUILDER) actionlint -color
.PHONY: lint-actions
lint-types: ## Run typecheck
$(NPM_BIN) lint:types
.PHONY: lint-types
test: ## Run unit tests
$(NPM_BIN) test
.PHONY: test
format: ## Run prettier formatting
$(NPM_BIN) run format
.PHONY: format
sort: ## Sort package.json across project
$(NPM_BIN) lint:package-json
.PHONY: sort
# Release
# ------------------------------------------------------------------------------------
cs: ## Run changeset to generate changelog
$(NPM_BIN) changeset
.PHONY: cs
cs-version:
$(NPM_BIN) changeset version
.PHONY: version
cs-publish: ## Publish new version to npm
$(NPM_BIN) changeset publish
.PHONY: release
# Git Actions
# ------------------------------------------------------------------------------------
hooks: ## Install git hooks from husky
$(NPM_BIN) run prepare
.PHONY: hooks