-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
200 lines (154 loc) · 4.22 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
export DIR_PACKAGES := packages
export DIR_BUILD_WORKSPACE := build/workspace
export DIR_BUILD_PACKAGE := build/package
.PHONY: default
default:
#
# --
# -- Code Formatting
# --
.PHONY: \
code \
code.fix
code:
npx eslint \
--cache \
--cache-location .eslintcache \
--format codeframe \
./packages
code.fix:
npx eslint \
--cache \
--cache-location .eslintcache \
--fix \
--format codeframe \
./packages
# --
# -- Testing
# --
.PHONY: \
test \
test.watch \
test.coverage.open
test:
npx vitest run -c vitest.config.ts --coverage
test.watch:
npx vitest watch -c vitest.config.ts
test.coverage.open:
open build/coverage/index.html
# Assumes the dependencies have been installed or placed before running.
# This will require that the workspaces are linked so cross-package references work.
test.build:
cd ./${DIR_BUILD_WORKSPACE} && npx jest --verbose --colors --no-watchman
# --
# -- Package Build
# --
.PHONY: \
build \
build.clean \
build.setup \
build.compile \
build.compile.clean \
build.compile.packages \
build.compile.verify
build: \
build.clean \
build.setup \
build.compile \
build.compile.clean \
build.compile.verify
build.clean:
rm -rf ./${DIR_BUILD_WORKSPACE}/*
build.setup:
mkdir -p ./${DIR_BUILD_WORKSPACE}
build.compile:
npx tsc -p build/tsconfig.json
build.compile.clean:
rm -rf ./${DIR_BUILD_WORKSPACE}/packages/index.js
rm -rf ./${DIR_BUILD_WORKSPACE}/packages/index.d.ts
find ./${DIR_BUILD_WORKSPACE}/packages -type f -name "*.test.js" -delete
find ./${DIR_BUILD_WORKSPACE}/packages -type f -name "*.test.d.ts" -delete
find ./${DIR_BUILD_WORKSPACE}/packages -type f -name "*.proof.js" -delete
find ./${DIR_BUILD_WORKSPACE}/packages -type f -name "*.proof.d.ts" -delete
build.compile.verify:
test -d ./${DIR_BUILD_WORKSPACE}/packages
test -d ./${DIR_BUILD_WORKSPACE}/packages/@phasma/handler
test -d ./${DIR_BUILD_WORKSPACE}/packages/@phasma/handler-aws
# This is an isolated target from main process that needs running manually in some cases.
# Will prepare the build directory by installing dependencies.
build.root.install:
cd ./${DIR_BUILD_WORKSPACE} && npm ci --ignore-scripts
# --
# -- Package Build
# --
.PHONY: \
package \
package.assert \
package.clean \
package.prepare \
package.prepare.source \
package.prepare.metadata \
package.prepare.imports \
package.preview
package: \
package.assert \
package.clean \
package.prepare \
package.prepare.source \
package.prepare.metadata \
package.prepare.imports \
package.preview
package.assert:
test ! -z "${PACKAGE_NAME}"
test -d ./${DIR_BUILD_WORKSPACE}/packages/${PACKAGE_NAME}
package.clean:
rm -rf ./${DIR_BUILD_PACKAGE}/*
package.prepare:
mkdir -p ./${DIR_BUILD_PACKAGE}
package.prepare.source:
cp -R ./${DIR_BUILD_WORKSPACE}/packages/${PACKAGE_NAME}/src/* ./${DIR_BUILD_PACKAGE}
package.prepare.metadata:
cp ./${DIR_PACKAGES}/${PACKAGE_NAME}/package.json ./${DIR_BUILD_PACKAGE}/package.json
cp ./${DIR_PACKAGES}/${PACKAGE_NAME}/README.md ./${DIR_BUILD_PACKAGE}/README.md
package.prepare.imports:
find ${DIR_BUILD_PACKAGE} -type f \( -name '*.js' -o -name '*.ts' \) \
-exec $(if $(shell which gsed),gsed,sed) -i -E 's|\/src\/index||g' {} \; \
-exec $(if $(shell which gsed),gsed,sed) -i -E 's|\/src||g' {} \;
package.preview:
npm publish --dry-run ./${DIR_BUILD_PACKAGE}
package.publish:
npm publish --access public ./${DIR_BUILD_PACKAGE}
package.publish.next:
npm publish --access public --tag next ./${DIR_BUILD_PACKAGE}
# --
# -- Versioning
# --
.PHONY: \
version.assert \
version.major \
version.minor \
version.patch
version.assert:
test ! -z "${PACKAGE_NAME}"
version.major: version.assert
npm version --no-git-tag-version -w ${DIR_PACKAGES}/${PACKAGE_NAME} major
version.minor: version.assert
npm version --no-git-tag-version -w ${DIR_PACKAGES}/${PACKAGE_NAME} minor
version.patch: version.assert
npm version --no-git-tag-version -w ${DIR_PACKAGES}/${PACKAGE_NAME} patch
# --
# -- Packages
# --
.PHONY: \
phasma \
create-phasma \
@phasma/handler \
@phasma/handler-aws
phasma:
$(MAKE) build package PACKAGE_NAME=$@
create-phasma:
$(MAKE) build package PACKAGE_NAME=$@
@phasma/handler:
$(MAKE) build package PACKAGE_NAME=$@
@phasma/handler-aws:
$(MAKE) build package PACKAGE_NAME=$@