-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
144 lines (109 loc) · 7.52 KB
/
Makefile
File metadata and controls
144 lines (109 loc) · 7.52 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
139
140
141
142
143
# Makefile for TaskNexus
# =======================
# Comprehensive commands for development, building, formatting, linting,
# AWS infra provisioning, Lambda packaging, and asset deployment.
# ────────────────────────────────────────────────────────────────────────────────
# VARIABLES
# ────────────────────────────────────────────────────────────────────────────────
# Package managers
YARN := yarn
NPM := npm
# Expo commands
EXPO := $(YARN) expo
# AWS / Terraform
AWS_DIR := aws
SHELL_DIR := shell
# Web assets directory
WEB_ASSETS_DIR := web-assets
# Terraform CLI wrapper
TERRAFORM := terraform
TF_INIT_ARGS := -chdir=$(AWS_DIR) init
TF_APPLY_ARGS := -chdir=$(AWS_DIR) apply -auto-approve
TF_DESTROY_ARGS := -chdir=$(AWS_DIR) destroy -auto-approve
TF_PLAN_ARGS := -chdir=$(AWS_DIR) plan
# Lambda packaging
LAMBDA_SRC := $(AWS_DIR)/lambda/taskReminder
LAMBDA_ZIP := $(LAMBDA_SRC).zip
# ────────────────────────────────────────────────────────────────────────────────
# PHONY TARGETS
# ────────────────────────────────────────────────────────────────────────────────
.PHONY: help \
install deps lint format test type-check start build build-web \
aws-init aws-plan aws-apply aws-destroy \
lambda-package lambda-update \
deploy-assets \
clean
# ────────────────────────────────────────────────────────────────────────────────
# HELP
# ────────────────────────────────────────────────────────────────────────────────
help:
@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?##"}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
# ────────────────────────────────────────────────────────────────────────────────
# DEPENDENCIES
# ────────────────────────────────────────────────────────────────────────────────
install: ## Install all JS dependencies via Yarn
$(YARN) install
deps: install ## Alias for install
lint: ## Run ESLint
$(YARN) lint
format: ## Run Prettier to format code
$(YARN) format
test: ## Run tests
$(YARN) test
type-check: ## Run TypeScript compiler in check mode
$(NPM) run tsc -- --noEmit
# ────────────────────────────────────────────────────────────────────────────────
# EXPO / APP
# ────────────────────────────────────────────────────────────────────────────────
start: ## Start Expo in development mode
$(EXPO) start
build: ## Build standalone apps for distribution
$(EXPO) build
build-web: ## Build web assets to $(WEB_ASSETS_DIR)
$(EXPO) build:web --output $(WEB_ASSETS_DIR)
# ────────────────────────────────────────────────────────────────────────────────
# AWS INFRA (TERRAFORM)
# ────────────────────────────────────────────────────────────────────────────────
aws-init: ## terraform init + apply all infra in aws/
@echo "🌱 Initializing & applying AWS infra..."
$(TERRAFORM) $(TF_INIT_ARGS)
$(TERRAFORM) $(TF_APPLY_ARGS)
aws-plan: ## terraform plan (preview infra changes)
@echo "🔍 Planning AWS infra changes..."
$(TERRAFORM) $(TF_PLAN_ARGS)
aws-apply: ## terraform apply only (after init)
@echo "🚀 Applying AWS infra changes..."
$(TERRAFORM) $(TF_APPLY_ARGS)
aws-destroy: ## terraform destroy infra when cleaning up
@echo "⚠️ Destroying AWS infra..."
$(TERRAFORM) $(TF_DESTROY_ARGS)
# ────────────────────────────────────────────────────────────────────────────────
# LAMBDA PACKAGE & UPDATE
# ────────────────────────────────────────────────────────────────────────────────
lambda-package: ## Zip up Lambda function source for Terraform
@echo "📦 Packaging Lambda code..."
@rm -f $(LAMBDA_ZIP)
@cd $(LAMBDA_SRC) && zip -r ../../taskReminder.zip ./*
@echo "✅ $(LAMBDA_ZIP) created."
lambda-update: lambda-package ## Re-package Lambda and apply only the Lambda function
@echo "🔄 Updating Lambda in AWS..."
@cd $(AWS_DIR) && $(TERRAFORM) apply -target=aws_lambda_function.task_reminder -auto-approve
@echo "✅ Lambda function updated."
# ────────────────────────────────────────────────────────────────────────────────
# ASSETS DEPLOYMENT
# ────────────────────────────────────────────────────────────────────────────────
deploy-assets: ## Sync local web assets into S3 bucket
@echo "📥 Fetching S3 bucket name..."
BUCKET=$$(terraform -chdir=$(AWS_DIR) output -raw s3_bucket) && \
echo "📤 Syncing $(WEB_ASSETS_DIR) → s3://$$BUCKET" && \
aws s3 sync $(WEB_ASSETS_DIR) s3://$$BUCKET --acl public-read --delete && \
echo "✅ Assets deployed."
# ────────────────────────────────────────────────────────────────────────────────
# CLEANUP
# ────────────────────────────────────────────────────────────────────────────────
clean: ## Remove build artifacts
@echo "🧹 Cleaning up..."
@rm -rf $(WEB_ASSETS_DIR)
@rm -f $(LAMBDA_ZIP)
@echo "✅ Cleaned."