-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
206 lines (179 loc) · 5.6 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
194
195
196
197
198
199
200
201
202
203
204
205
206
# File: /Makefile
# Project: react-native-ignore-warnings
# File Created: 09-07-2021 18:35:16
# Author: Clay Risser <email@clayrisser.com>
# -----
# Last Modified: 09-07-2021 18:58:09
# Modified By: Clay Risser <email@clayrisser.com>
# -----
# Silicon Hills LLC (c) Copyright 2021
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
export MAKE_CACHE := $(shell pwd)/node_modules/.make
export PARENT := true
include blackmagic.mk
BABEL ?= node_modules/.bin/babel
BABEL_NODE ?= node_modules/.bin/babel-node
CLOC ?= node_modules/.bin/cloc
CSPELL ?= node_modules/.bin/cspell
ESLINT ?= node_modules/.bin/eslint
JEST ?= node_modules/.bin/jest
LOCKFILE_LINT ?= node_modules/.bin/lockfile-lint
MAJESTIC ?= node_modules/.bin/majestic
PRETTIER ?= node_modules/.bin/prettier
TMP_DIR ?= node_modules/.tmp
TSC ?= node_modules/.bin/tsc
COLLECT_COVERAGE_FROM := ["src/**/*.{js,jsx,ts,tsx}"]
.PHONY: all
all: build
ACTIONS += install
INSTALL_DEPS := $(patsubst %,$(DONE)/_install/%,package.json)
INSTALL_TARGET := $(INSTALL_DEPS) $(ACTION)/install
$(ACTION)/install:
@$(NPM) install
@$(call done,install)
.PHONY: postinstall
postinstall: patch
.PHONY: patch
patch:
@rm -rf \
node_modules/.pnpm/@types+node* \
node_modules/.pnpm/@types+graceful-fs* $(NOFAIL)
ACTIONS += format~install
FORMAT_DEPS := $(call deps,format,$(shell $(GIT) ls-files 2>$(NULL) | \
grep -E "\.((json)|(ya?ml)|(md)|([jt]sx?))$$"))
FORMAT_TARGET := $(FORMAT_DEPS) $(ACTION)/format
$(ACTION)/format:
# @for i in $$($(call get_deps,format)); do echo $$i | \
# grep -E "\.[jt]sx?$$"; done | xargs $(ESLINT) --fix >/dev/null ||true
@$(PRETTIER) --write $(shell $(call get_deps,format))
@$(call done,format)
ACTIONS += spellcheck~format
SPELLCHECK_DEPS := $(call deps,spellcheck,$(shell $(GIT) ls-files 2>$(NULL) | \
$(GIT) ls-files | grep -E "\.(md)$$"))
SPELLCHECK_TARGET := $(SPELLCHECK_DEPS) $(ACTION)/spellcheck
$(ACTION)/spellcheck:
@mkdir -p $(TMP_DIR)
@node -e "console.log(JSON.stringify({language:'en',version:'0.1',words:require('./.vscode/settings.json')['cSpell.words']}, null, 2))" > \
$(TMP_DIR)/cspellrc.json
-@$(CSPELL) --config $(TMP_DIR)/cspellrc.json $(shell $(call get_deps,spellcheck))
@$(call done,spellcheck)
ACTIONS += lint~spellcheck
LINT_DEPS := $(call deps,lint,$(shell $(GIT) ls-files 2>$(NULL) | \
grep -E "\.([jt]sx?)$$"))
LINT_TARGET := $(LINT_DEPS) $(ACTION)/lint
$(ACTION)/lint:
# -@$(LOCKFILE_LINT) --type npm --path package-lock.json --validate-https
-@$(ESLINT) -f json -o node_modules/.tmp/eslintReport.json $(shell $(call get_deps,lint)) $(NOFAIL)
-@$(ESLINT) $(shell $(call get_deps,lint))
@$(call done,lint)
ACTIONS += test~lint
TEST_DEPS := $(call deps,test,$(shell $(GIT) ls-files 2>$(NULL) | \
grep -E "\.([jt]sx?)$$"))
TEST_TARGET := $(TEST_DEPS) $(ACTION)/test
$(ACTION)/test:
-@$(JEST) --json --outputFile=node_modules/.tmp/jestTestResults.json --coverage \
--coverageDirectory=node_modules/.tmp/coverage --testResultsProcessor=jest-sonar-reporter \
--collectCoverageFrom='$(COLLECT_COVERAGE_FROM)' --findRelatedTests $(shell $(call get_deps,test))
@$(call done,test)
ACTIONS += build~test
BUILD_DEPS := $(call deps,build,$(shell $(GIT) ls-files 2>$(NULL) | \
grep -E "\.([jt]sx?)$$"))
BUILD_TARGET := $(BUILD_DEPS) $(ACTION)/build
$(ACTION)/build: es/index.js lib/index.js ;
@if [ ! -f $(MAKE_CACHE)/^build ]; then \
$(MAKE) -s $(ACTION)/^build; \
fi
@$(call clear_cache,$(ACTION)/^build)
es/index.js:
@$(MAKE) -s $(ACTION)/^build
lib/index.js:
@$(MAKE) -s $(ACTION)/^build
$(ACTION)/^build:
@$(BABEL) --env-name umd src -d lib --extensions '.js,.jsx,.ts,.tsx' --source-maps
@$(BABEL) --env-name esm src -d es --extensions '.js,.jsx,.ts,.tsx' --source-maps
@$(TSC) -p tsconfig.app.json -d --emitDeclarationOnly
@$(call cache,$@)
@$(call done,build)
.PHONY: prepare
prepare: ;
.PHONY: upgrade
upgrade:
@$(NPM) upgrade --latest
.PHONY: inc
inc:
@npm version patch --git=false $(NOFAIL)
.PHONY: count
count:
@$(CLOC) $(shell $(GIT) ls-files)
.PHONY: publish +publish
publish: build
@$(MAKE) -s +publish
+publish:
@$(NPM) publish
.PHONY: pack +pack
pack: build
@$(MAKE) -s +pack
+pack:
@$(NPM) pack
.PHONY: coverage
coverage: ~lint
@$(MAKE) -s +coverage
+coverage:
@$(JEST) --coverage --collectCoverageFrom='$(COLLECT_COVERAGE_FROM)' $(ARGS)
.PHONY: test-ui
test-ui: ~lint
@$(MAKE) -s +test-ui
+test-ui:
@$(MAJESTIC) $(ARGS)
.PHONY: test-watch
test-watch: ~lint
@$(MAKE) -s +test-watch
+test-watch:
@$(JEST) --watch $(ARGS)
.PHONY: start +start
start: ~format
@$(MAKE) -s +start
+start:
@$(BABEL_NODE) --extensions '.ts,.tsx' src $(ARGS)
.PHONY: clean
clean:
-@$(call clean)
-@$(JEST) --clearCache $(NOFAIL)
-@$(GIT) clean -fXd \
-e $(BANG)/node_modules \
-e $(BANG)/node_modules/**/* \
-e $(BANG)/package-lock.json \
-e $(BANG)/pnpm-lock.yaml \
-e $(BANG)/yarn.lock $(NOFAIL)
-@rm -rf node_modules/.cache $(NOFAIL)
-@rm -rf node_modules/.tmp $(NOFAIL)
.PHONY: purge
purge: clean
-@$(GIT) clean -fXd
-include $(patsubst %,$(_ACTIONS)/%,$(ACTIONS))
+%:
@$(MAKE) -e -s $(shell echo $@ | $(SED) 's/^\+//g')
%: ;
CACHE_ENVS += \
BABEL \
BABEL_NODE \
CLOC \
CSPELL \
ESLINT \
JEST \
LOCKFILE_LINT \
MAJESTIC \
PRETTIER \
TMP_DIR \
TSC