-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (108 loc) Β· 2.92 KB
/
Makefile
File metadata and controls
138 lines (108 loc) Β· 2.92 KB
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
.PHONY: build build_cloudformation build_typescript clean clean_cache clean_dist clean_modules clean_tmp deploy deployci deploy_cloudformation destroy destroy_cloudformation lint lintfix
#### input params for aws cloud
#### Please change the value as required like region, stack & profile
debug = debug
maintenance = false
region = eu-central-1
stack = typescript-lambda-backend-app # decide a <stack-name> for the app
stage = v1
substage = sazal # add x/<DeveloperName>
tests = unit
####
#### cloud params
profile = sazal-dev # add the name of aws cli configured profile
stackname = ${stack}
####
#### info
help:
@echo ""
@echo "supported targets:"
@echo ""
@echo "- build: builds service. runs subtargets."
@echo " - build_cloudformation: builds cloudformation."
@echo " - build_typescript: builds typescript."
@echo ""
@echo "- clean: cleans service. runs subtargets."
@echo " - clean_cache: cleans .cache folder."
@echo " - clean_dist: cleans .aws-sam folder."
@echo " - clean_modules: cleans node_modules folder."
@echo " - clean_tmp: cleans .tmp folder."
@echo ""
@echo "- deploy: deploys service. runs build. runs subtargets."
@echo " - deploy_cloudformation: deploys cloudformation."
@echo ""
@echo "- destroy: destroys service. runs subtargets."
@echo " - destroy_cloudformation: destroys cloudformation."
@echo ""
@echo "- lint: lints service."
@echo "- lintfix: lint fix service."
@echo ""
@echo "- test: for testing all the features by jest."
@echo ""
####
#### validate
install:
@npm i
#### validate
validate:
@sam validate -t serverless.yml --profile sazal-dev
#### build
build: build_typescript build_cloudformation
build_cloudformation:
@sam build -b .aws-sam/build -t serverless.yml \
--cached \
--cache-dir .cache \
--parallel
build_typescript:
@npx --no-install tsc
####
#### clean
clean: clean_cache clean_dist clean_modules clean_coverage clean_tmp
clean_cache:
@rm -rf .cache
clean_dist:
@rm -rf .aws-sam
clean_modules:
# @rm -rf node_modules
clean_coverage:
@rm -rf coverage
clean_tmp:
@rm -rf .tmp
####
#### deploy
deploy: build deploy_cloudformation
deployci: deploy_cloudformation
deploy_cloudformation:
@sam deploy -t .aws-sam/build/template.yaml \
--capabilities CAPABILITY_IAM \
--no-fail-on-empty-changeset \
--parameter-overrides \
DEBUG=${debug} \
MAINTENANCE=${maintenance} \
STACK=${stack} \
STAGE=${stage} \
SUBSTAGE=${substage} \
--profile ${profile} \
--region ${region} \
--resolve-s3 \
--stack-name ${stackname}
####
#### destroy
destroy: destroy_cloudformation
destroy_cloudformation:
@sam delete \
--no-prompts \
--profile ${profile} \
--region ${region} \
--stack-name ${stackname}
####
#### lint
lint:
@npx --no-install prettier --check '{src,__tests__}/**/*.{js,ts}'
lintfix:
@npx --no-install prettier --write '{src,__tests__}/**/*.{js,ts}'
####
#### Test
test:
@npm run test
####