Skip to content

Commit 6a8e6ea

Browse files
committed
reform the Makefile
1 parent f1c0aa3 commit 6a8e6ea

File tree

3 files changed

+97
-25
lines changed

3 files changed

+97
-25
lines changed

Makefile

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,42 @@ SHELL := /bin/bash
77
usage:
88
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
99

10+
## Check if all required prerequisites are installed
11+
check:
12+
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
13+
@command -v node > /dev/null 2>&1 || { echo "Node.js is not installed. Please install Node.js and try again."; exit 1; }
14+
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
15+
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed. Please install LocalStack and try again."; exit 1; }
16+
@command -v cdk > /dev/null 2>&1 || { echo "CDK is not installed. Please install CDK and try again."; exit 1; }
17+
@command -v cdklocal > /dev/null 2>&1 || { echo "cdklocal is not installed. Please install cdklocal and try again."; exit 1; }
18+
@command -v yarn > /dev/null 2>&1 || { echo "Yarn is not installed. Please install Yarn and try again."; exit 1; }
19+
@echo "All required prerequisites are available."
20+
1021
## Install dependencies
1122
install:
12-
@which localstack || pip install localstack
13-
@which awslocal || pip install awscli-local
14-
15-
# Deploy the infrastructure
16-
build:
17-
yarn && yarn build:backend;
18-
19-
bootstrap:
20-
yarn cdklocal bootstrap;
23+
@if [ ! -d "node_modules" ]; then \
24+
echo "node_modules not found. Running yarn install..."; \
25+
yarn install; \
26+
fi
27+
@echo "All required dependencies are available."
28+
29+
## Build and deploy the frontend
30+
frontend:
31+
yarn prepare:frontend-local
32+
yarn build-frontend
33+
yarn cdklocal bootstrap --app="node dist/aws-sdk-js-notes-app-frontend.js"
34+
yarn cdklocal deploy --app="node dist/aws-sdk-js-notes-app-frontend.js"
2135

2236
## Deploy the infrastructure
2337
deploy:
38+
yarn build:backend;
39+
yarn cdklocal bootstrap;
2440
yarn cdklocal deploy;
2541

2642
## Start LocalStack in detached mode
2743
start:
2844
localstack start -d
2945

30-
## export configs for web app
31-
prepare-frontend-local:
32-
yarn prepare:frontend-local
33-
34-
build-frontend:
35-
yarn build:frontend
36-
37-
bootstrap-frontend:
38-
yarn cdklocal bootstrap --app="node dist/aws-sdk-js-notes-app-frontend.js";
39-
40-
deploy-frontend:
41-
yarn cdklocal deploy --app="node dist/aws-sdk-js-notes-app-frontend.js";
42-
4346
## Stop the Running LocalStack container
4447
stop:
4548
@echo
@@ -50,8 +53,8 @@ ready:
5053
@echo Waiting on the LocalStack container...
5154
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
5255

53-
## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run.
56+
## Save the logs in a separate file
5457
logs:
5558
@localstack logs > logs.txt
5659

57-
.PHONY: usage install run start stop ready logs
60+
.PHONY: usage install check start ready deploy frontend logs stop

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@
2828
"lint-staged": {
2929
"*.{ts,js,md}": "prettier --write"
3030
},
31-
"packageManager": "yarn@3.3.1"
31+
"packageManager": "yarn@3.3.1",
32+
"dependencies": {
33+
"glob": "^11.0.1"
34+
}
3235
}

yarn.lock

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,6 +3729,22 @@ __metadata:
37293729
languageName: node
37303730
linkType: hard
37313731

3732+
"glob@npm:^11.0.1":
3733+
version: 11.0.1
3734+
resolution: "glob@npm:11.0.1"
3735+
dependencies:
3736+
foreground-child: ^3.1.0
3737+
jackspeak: ^4.0.1
3738+
minimatch: ^10.0.0
3739+
minipass: ^7.1.2
3740+
package-json-from-dist: ^1.0.0
3741+
path-scurry: ^2.0.0
3742+
bin:
3743+
glob: dist/esm/bin.mjs
3744+
checksum: ffbbafe1d2dae2fa68f190ac76df7254e840b27f59df34129fd658bd9da0c50b538d144eb0962dc7fa71cdaccf3fe108f045d4a15b3f5815e465749a6bf00965
3745+
languageName: node
3746+
linkType: hard
3747+
37323748
"glob@npm:^7.1.3":
37333749
version: 7.2.3
37343750
resolution: "glob@npm:7.2.3"
@@ -4136,6 +4152,15 @@ __metadata:
41364152
languageName: node
41374153
linkType: hard
41384154

4155+
"jackspeak@npm:^4.0.1":
4156+
version: 4.1.0
4157+
resolution: "jackspeak@npm:4.1.0"
4158+
dependencies:
4159+
"@isaacs/cliui": ^8.0.2
4160+
checksum: cfc2b527e4b51e55a21961c091b37dfd177341196d089a355eb692f8895b24b6caac912b4f594b64cfaf6d2bdf085898361379b74f27936ed3d5e0ba75f96e94
4161+
languageName: node
4162+
linkType: hard
4163+
41394164
"js-tokens@npm:^3.0.0 || ^4.0.0, js-tokens@npm:^4.0.0":
41404165
version: 4.0.0
41414166
resolution: "js-tokens@npm:4.0.0"
@@ -4348,6 +4373,13 @@ __metadata:
43484373
languageName: node
43494374
linkType: hard
43504375

4376+
"lru-cache@npm:^11.0.0":
4377+
version: 11.1.0
4378+
resolution: "lru-cache@npm:11.1.0"
4379+
checksum: 6274e90b5fdff87570fe26fe971467a5ae1f25f132bebe187e71c5627c7cd2abb94b47addd0ecdad034107667726ebde1abcef083d80f2126e83476b2c4e7c82
4380+
languageName: node
4381+
linkType: hard
4382+
43514383
"lru-cache@npm:^5.1.1":
43524384
version: 5.1.1
43534385
resolution: "lru-cache@npm:5.1.1"
@@ -4426,6 +4458,15 @@ __metadata:
44264458
languageName: node
44274459
linkType: hard
44284460

4461+
"minimatch@npm:^10.0.0":
4462+
version: 10.0.1
4463+
resolution: "minimatch@npm:10.0.1"
4464+
dependencies:
4465+
brace-expansion: ^2.0.1
4466+
checksum: f5b63c2f30606091a057c5f679b067f84a2cd0ffbd2dbc9143bda850afd353c7be81949ff11ae0c86988f07390eeca64efd7143ee05a0dab37f6c6b38a2ebb6c
4467+
languageName: node
4468+
linkType: hard
4469+
44294470
"minimatch@npm:^3.0.5, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2":
44304471
version: 3.1.2
44314472
resolution: "minimatch@npm:3.1.2"
@@ -4518,6 +4559,13 @@ __metadata:
45184559
languageName: node
45194560
linkType: hard
45204561

4562+
"minipass@npm:^7.1.2":
4563+
version: 7.1.2
4564+
resolution: "minipass@npm:7.1.2"
4565+
checksum: 2bfd325b95c555f2b4d2814d49325691c7bee937d753814861b0b49d5edcda55cbbf22b6b6a60bb91eddac8668771f03c5ff647dcd9d0f798e9548b9cdc46ee3
4566+
languageName: node
4567+
linkType: hard
4568+
45214569
"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2":
45224570
version: 2.1.2
45234571
resolution: "minizlib@npm:2.1.2"
@@ -4719,6 +4767,13 @@ __metadata:
47194767
languageName: node
47204768
linkType: hard
47214769

4770+
"package-json-from-dist@npm:^1.0.0":
4771+
version: 1.0.1
4772+
resolution: "package-json-from-dist@npm:1.0.1"
4773+
checksum: 58ee9538f2f762988433da00e26acc788036914d57c71c246bf0be1b60cdbd77dd60b6a3e1a30465f0b248aeb80079e0b34cb6050b1dfa18c06953bb1cbc7602
4774+
languageName: node
4775+
linkType: hard
4776+
47224777
"parent-module@npm:^1.0.0":
47234778
version: 1.0.1
47244779
resolution: "parent-module@npm:1.0.1"
@@ -4778,6 +4833,16 @@ __metadata:
47784833
languageName: node
47794834
linkType: hard
47804835

4836+
"path-scurry@npm:^2.0.0":
4837+
version: 2.0.0
4838+
resolution: "path-scurry@npm:2.0.0"
4839+
dependencies:
4840+
lru-cache: ^11.0.0
4841+
minipass: ^7.1.2
4842+
checksum: 9953ce3857f7e0796b187a7066eede63864b7e1dfc14bf0484249801a5ab9afb90d9a58fc533ebb1b552d23767df8aa6a2c6c62caf3f8a65f6ce336a97bbb484
4843+
languageName: node
4844+
linkType: hard
4845+
47814846
"path-type@npm:^4.0.0":
47824847
version: 4.0.0
47834848
resolution: "path-type@npm:4.0.0"
@@ -5145,6 +5210,7 @@ __metadata:
51455210
version: 0.0.0-use.local
51465211
resolution: "root-workspace-0b6124@workspace:."
51475212
dependencies:
5213+
glob: ^11.0.1
51485214
husky: ^4.2.3
51495215
lint-staged: ^10.1.2
51505216
prettier: 2.4.1

0 commit comments

Comments
 (0)