-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
61 lines (53 loc) · 1.81 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
SHELL := /bin/bash -euo pipefail
NO_COLOR=\x1b[0m
TARGET_COLOR=\x1b[96m
ERROR_COLOR=\033[0;31m
PARAMETER_NAME=CustomResourceTestParameter
.PHONY: test
install:
@echo -e "$(TARGET_COLOR)Running install$(NO_COLOR)"
@npm clean-install --prefer-offline --cache .npm
@npm list
build: install
@echo -e "$(TARGET_COLOR)Running build$(NO_COLOR)"
@find . -type f \( -name "*.js" -o -name "*.d.ts" \) ! -path "./node_modules/*" ! -path "./test/node_modules/*" -exec rm -f {} +
@npx tsc
test:
@echo -e "$(TARGET_COLOR)Running test$(NO_COLOR)"
@\
cd test && \
$(MAKE) build && \
$(MAKE) deploy && \
$(MAKE) deploy && \
version=$$(aws ssm get-parameter --name "$(PARAMETER_NAME)" --query "Parameter.Version" --output text) && \
if [ "$${version}" -ne 2 ]; then \
echo -e "$(ERROR_COLOR)Error: Unexpected version of parameter $(PARAMETER_NAME) Got $${version} instead of 2.$(NO_COLOR)" >&2; \
$(MAKE) DESTROY; \
exit 1; \
fi && \
$(MAKE) DESTROY
publish: install
@echo -e "$(TARGET_COLOR)Running publish$(NO_COLOR)"
@npx tsc -p tsconfig.publish.json
@npm publish --dry-run 2>&1 | tee publish_output.txt
@if ! grep -q "src/index.js" publish_output.txt; then \
echo "❌ src/index.js is NOT included in the package"; \
exit 1; \
fi
@if ! grep -q "src/index.d.ts" publish_output.txt; then \
echo "❌ src/index.d.ts is NOT included in the package"; \
exit 1; \
fi
@file_count=$$(grep -o "npm notice total files:\s*[0-9]\+" publish_output.txt | awk '{print $$NF}'); \
if [[ "$${file_count}" -ne 5 ]]; then \
echo "❌ Package does not contain exactly 5 files"; \
exit 1; \
fi
@rm publish_output.txt
@if [[ -n "$${GITHUB_EVENT:-}" && "$${GITHUB_EVENT}" != "pull_request" ]]; then \
npm publish; \
fi
eslint:
@echo -e "$(TARGET_COLOR)Running eslint $$(npx eslint --version)$(NO_COLOR)"
@npx eslint .; \
echo "Passed"