-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
167 lines (131 loc) · 4.55 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
# Explorer-1 GNUMakefile
ifneq (,)
This makefile requires GNU Make.
endif
NODE_VERSION ?= $(shell node --version)
NPM_VERSION ?= $(shell npm --version)
NVM_EXISTS := $(shell if [ -d "${HOME}/.nvm" ]; then echo "nvm installed"; fi)
TERM_TEXT := tput -Txterm
GREEN := $(shell $(TERM_TEXT) setaf 2)
YELLOW := $(shell $(TERM_TEXT) setaf 3)
RESET := $(shell $(TERM_TEXT) sgr0)
TARGET_MAX_CHAR_NUM := 23
.DEFAULT_GOAL := help
nvm-use:
. ${HOME}/.nvm/nvm.sh && nvm use
check-nvm:
ifndef NVM_EXISTS
@echo '$(YELLOW)Node Version Manager not found 😿$(RESET)'
@( read -p "$(YELLOW)Please install nvm: https://github.com/nvm-sh/nvm$(RESET)")
else
if [ -d "$(HOME)/.nvm/.git" ]; then echo "🚚 installing dependencies from $(YELLOW)package.json$(RESET)..."; fi
@echo ' --------------------'
@echo '📦 $(GREEN)Node Version Manager$(RESET)'
@echo ' $(YELLOW)node: $(NODE_VERSION)$(RESET)'
@echo ' $(YELLOW)npm: v$(NPM_VERSION)$(RESET)'
@echo '👀 looking for $(YELLOW).nvmrc$(RESET) file with expected node version...'
@make nvm-use
@echo '⏳ it can take a few minutes to install all of the $(YELLOW)node_modules$(RESET)'
@echo '🙆 this could be a good opportunity to have a stretch... '
@echo '⏭️ postinstall will check $(GREEN)workspaces$(RESET) with $(YELLOW)manypkg$(RESET)...'
endif
nvm:
make check-nvm && $(CMD)
## Install: node_modules dependencies with pnpm
install: check-nvm
pnpm install
i: install
## Clean: remove node_modules
clean:
pnpm run clean
## Version: Create a Changeset (walkthrough versioning)
changeset:
pnpm run changeset
## Refresh: remove node_modules and install
refresh:
pnpm run refresh
fresh: refresh
## Nuke: clean and reinstall node_modules
nuke:
pnpm run nuke
## HTML: run Storybook
html-storybook:
pnpm --filter @explorer-1/html-storybook dev
## HTML: run Storybook with --force-build-preview
html-storybook-force:
pnpm --filter @explorer-1/html-storybook dev --force-build-preview
## HTML: build Storybook
html-storybook-build:
pnpm --filter @explorer-1/html-storybook build
## HTML: run Vite
html-dev:
pnpm --filter @explorer-1/html dev
html: html-dev
## HTML: build assets
html-build:
pnpm --filter @explorer-1/html build
## Vue: run Storybook
vue-storybook:
pnpm --filter @explorer-1/vue-storybook dev
## Vue: build Storybook
vue-storybook-build:
pnpm --filter @explorer-1/vue-storybook build
## HTML: run Storybook with --force-build-preview
vue-storybook-force:
pnpm --filter @explorer-1/vue-storybook dev --force-build-preview
## Vue: run Vite
vue-dev:
pnpm --filter @explorer-1/vue dev
vue: vue-dev
## Vue: build assets
vue-build:
pnpm --filter @explorer-1/vue build
## Nuxt: run module playground
nuxt-dev:
pnpm --filter @explorer-1/nuxt dev
nuxt: nuxt-dev
## Nuxt: build module
nuxt-build:
pnpm --filter @explorer-1/nuxt build
## Lint: run ESLint
lint:
pnpm run lint
## Lint fix: run ESLint
lint-fix:
pnpm run lint:fix
# how to use pnpm to upgrade storybook
# npx storybook@latest upgrade --package-manager pnpm
# TODO: Below helper commands not running as expected change dir first, then pnpm dlx...
# ## HTML: update Storybook
# html-storybook-update:
# pnpm --dir apps/html-storybook dlx storybook@latest upgrade --config-dir apps/html-storybook/.storybook
# ## HTML: run Storybook automigrations
# html-storybook-migrate:
# pnpm --dir apps/html-storybook dlx storybook automigrate --config-dir apps/html-storybook/.storybook
# ## HTML: check Storybook health
# html-storybook-doctor:
# pnpm --dir apps/html-storybook dlx storybook doctor --config-dir apps/html-storybook/.storybook
# ## Vue: update Storybook
# vue-storybook-update:
# pnpm --dir apps/vue-storybook dlx storybook@latest upgrade --config-dir apps/vue-storybook/.storybook
# ## Vue: run Storybook automigrations
# vue-storybook-migrate:
# pnpm --dir apps/vue-storybook dlx storybook automigrate --config-dir apps/vue-storybook/.storybook
# ## Vue: check Storybook health
# vue-storybook-doctor:
# pnpm --dir apps/vue-storybook dlx storybook doctor --config-dir apps/vue-storybook/.storybook
## General: Show Makefile help / View all commands @default make target
help:
@echo ''
@echo 'Makefile Usage:'
@echo ' ${GREEN}make${RESET} ${GREEN}[command]${RESET}'
@echo 'Available Commands:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)