-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
150 lines (120 loc) Β· 6.13 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
# Executables (local)
PKG_MANAGER = yarn
PKG_EXECUTE = yarn dlx
MONOREPO_TOOL = lerna
# Flags
# Modify these variables in local.mk to add flags to the commands, ie.
# YARN_FLAGS += --prefer-offline
PKG_MANAGER_FLAGS :=
# On CI servers, use the `yarn install --frozen-lockfile` installer to avoid introducing changes to the package-lock.json
# On developer machines, prefer the generally more flexible `yarn install`. πͺ
PKG_MANAGER_INSTALL := $(if $(CI), install --frozen-lockfile, install)
MONOREPO_TOOL_FLAGS :=
# Use `make target DEBUG=true` for enabling debug mode
MONOREPO_TOOL_NO_PUSH := $(if $(DEBUG), --no-git-tag-version)
# Misc
.DEFAULT_GOAL = help
.PHONY = help sh bash
# If this file exists, load it and add it to this makefile.
# Useful for defining per-developer variables or make targets. This file should not be under
# version control. β οΈ
-include local.mk
## ββ π» The Spirit Design System Makefile π» βββββββββββββββββββββββββββββββββ
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## ββ Dependencies π¦ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
install: ## Install dependencies
corepack enable
$(PKG_MANAGER) $(PKG_MANAGER_INSTALL) $(PKG_MANAGER_FLAGS) && touch node_modules
outdated: ## List outdated dependencies
$(PKG_MANAGER) outdated || true
$(PKG_MANAGER) $(MONOREPO_TOOL) exec "$(PKG_MANAGER) outdated || true"
unlock: pristine ## Unlock dependencies
rm -f yarn.lock packages/*/yarn.lock
touch package.json
touch yarn.lock
pristine: clean ## Remove all `node_modules`, `vendor` and files
-rm -rf node_modules {apps,configs,examples,exporters,packages}/*/node_modules
-rm -rf vendor {packages,apps}/*/vendor
## ββ Development ποΈ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
ifeq ($(pkg),)
start: ## Starts development environment, pass the parameter "pkg=" to start specific package environment, example: make start pkg=web
@$(eval pkg ?=)
@$(PKG_MANAGER) start
else
start:
@$(eval pkg ?=)
@$(PKG_MANAGER) run start --scope @lmc-eu/spirit-$(pkg)
endif
## ββ Testing π¦ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
format: ## Checks code formatting of all packages
$(PKG_MANAGER) format
format-fix: ## Fixes code formatting
$(PKG_MANAGER) format:fix
lint: ## Lints all packages
$(PKG_MANAGER) lint
lint-fix: ## Fixes lint errors in all packages
$(PKG_MANAGER) lint:fix
test: ## Run tests in all packages
$(PKG_MANAGER) test
test-e2e: ## Run End-to-End tests
./bin/make/e2e.sh
test-e2e-update: ## Update snapshots for End-to-End tests
./bin/make/e2e.sh --update
test-e2e-report: ## Open report for End-to-End tests
./bin/make/e2e.sh --report
test-e2e-ui: ## Open UI for End-to-End tests
./bin/make/e2e.sh --ui
types: ## Check types in all packages
$(PKG_MANAGER) types
## ββ Release π ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
build: ## Builds all packages
$(PKG_MANAGER) build
version: ## Create new release version of packages
# @see https://github.com/lerna/lerna/tree/main/commands/version#readme
# Bump version of packages changed since the last release
# --yes` - skip all confirmation prompts
$(PKG_MANAGER) $(MONOREPO_TOOL) version --create-release github --yes --no-push $(MONOREPO_TOOL_FLAGS) $(MONOREPO_TOOL_NO_PUSH)
preversion: ## Create new pre-release version of packages, use "preid=" parameter to specify pre-release identifier, example: make preversion preid=alpha
# @see https://github.com/lerna/lerna/tree/main/commands/version#readme
# Bump version of packages changed since the last release
# --yes` - skip all confirmation prompts
@$(eval preid ?=)
$(PKG_MANAGER) $(MONOREPO_TOOL) version --conventional-prerelease --preid $(preid) --create-release github --yes --no-push $(MONOREPO_TOOL_FLAGS) $(MONOREPO_TOOL_NO_PUSH)
graduate: ## Graduate a pre-release version of packages to stable
# @see https://github.com/lerna/lerna/tree/main/commands/version#readme
# Bump version of packages changed since the last release
# --yes` - skip all confirmation prompts
$(PKG_MANAGER) $(MONOREPO_TOOL) version --conventional-graduate --create-release github --yes --no-push $(MONOREPO_TOOL_FLAGS) $(MONOREPO_TOOL_NO_PUSH)
ifeq ($(pkg),web-twig)
publish: ## Publish packages to repository, pass the parameter "pkg=" to publish specific package (supports only `web-twig`), example: make publish pkg=web-twig
@$(eval pkg ?=)
git push web-twig-readonly `git subtree split --prefix packages/web-twig main`:main
else
publish:
@$(eval pkg ?=)
@$(eval dist-tag := $(strip $(dist-tag)))
@if [ -n "$(dist-tag)" ]; then \
$(PKG_EXECUTE) $(MONOREPO_TOOL) publish dist-tag=$(dist-tag) from-package --yes $(MONOREPO_TOOL_FLAGS); \
else \
$(PKG_EXECUTE) $(MONOREPO_TOOL) publish from-package --yes $(MONOREPO_TOOL_FLAGS); \
fi
endif
## ββ Miscellaneous π οΈ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
clean: ## Clean output files
find . -path ./node_modules -prune -o -type d \( \
-name '.nyc_output' -o \
-name 'coverage' -o \
-name '.coverage' -o \
-name '.cache' -o \
-name '.nx' -o \
-name 'dist' -o \
-name 'build' -o \
-name 'esm' -o \
-name 'cjs' -o \
-name 'umd' -o \
-name 'playwright-report' -o \
-name 'test-results' -o \
-name '.next' \
\) -exec rm -rf {} +
find . -path ./node_modules -prune -o -name '*.log' -print -delete