Skip to content

Commit 64dcd49

Browse files
committed
frontend/Makefile: def all package.json scripts aliases in Makefile
1 parent f7a56cd commit 64dcd49

File tree

2 files changed

+101
-34
lines changed

2 files changed

+101
-34
lines changed

frontend/Makefile

Lines changed: 83 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,104 @@ help: ## Display this help message
77
awk 'BEGIN {FS = ":.*?## "}; \
88
{printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
99

10+
.PHONY: build
11+
build: ## Build the frontend
12+
ng build
13+
14+
.PHONY: build-dev
15+
build-dev: ## Build the frontend for development
16+
ng build --configuration development
17+
18+
.PHONY: build-prod
19+
build-prod: ## Build the frontend for production
20+
ng build --configuration production && $(MAKE) sentry-sourcemaps
21+
22+
.PHONY: check-prettify
23+
check-prettify: ## Check if files are formatted with Prettier
24+
npx prettier --check 'src/**/*.{ts,js,html,scss,css,json}'
25+
26+
.PHONY: clean
27+
clean: ## Clean build artifacts and node_modules
28+
rm -rf dist node_modules
29+
30+
.PHONY: copy-env
31+
copy-env: ## Copy webnode.js to env.js
32+
cp dist/frontend/browser/assets/environments/webnode.js \
33+
dist/frontend/browser/assets/environments/env.js
34+
35+
.PHONY: deploy
36+
deploy: ## Deploy the application
37+
$(MAKE) prebuild && $(MAKE) build-prod && $(MAKE) copy-env && \
38+
firebase deploy
39+
40+
.PHONY: deploy-leaderboard
41+
deploy-leaderboard: ## Deploy the leaderboard application
42+
$(MAKE) prebuild && $(MAKE) build-prod && \
43+
cp dist/frontend/browser/assets/environments/leaderboard.js \
44+
dist/frontend/browser/assets/environments/env.js && \
45+
firebase deploy
46+
47+
.PHONY: docker
48+
docker: ## Build and push Docker image
49+
$(MAKE) build-prod && \
50+
docker buildx build --platform linux/amd64 -t openmina/frontend:latest . && \
51+
docker push openmina/frontend:latest
52+
1053
.PHONY: install
1154
install: ## Install npm dependencies
1255
npm install
1356

57+
.PHONY: install-deps
58+
install-deps: ## Install npm dependencies (alias)
59+
npm install
60+
61+
.PHONY: prebuild
62+
prebuild: ## Run prebuild script to update version
63+
node scripts/update-frontend-version.js
64+
1465
.PHONY: prettify
1566
prettify: ## Format HTML, SCSS, TypeScript, and JavaScript files with Prettier
1667
npx prettier --write 'src/**/*.{ts,js,html,scss,css,json}'
1768

18-
.PHONY: check-prettify
19-
check-prettify: ## Check if files are formatted with Prettier
20-
npx prettier --check 'src/**/*.{ts,js,html,scss,css,json}'
69+
.PHONY: rebuild
70+
rebuild: clean install build ## Clean, reinstall dependencies, and rebuild
71+
72+
.PHONY: sentry-sourcemaps
73+
sentry-sourcemaps: ## Upload sourcemaps to Sentry
74+
sentry-cli sourcemaps inject --org openmina-uv --project openmina \
75+
./dist/frontend/browser && \
76+
sentry-cli sourcemaps upload --org openmina-uv --project openmina \
77+
./dist/frontend/browser
2178

2279
.PHONY: start
2380
start: ## Start the development server
24-
npm start
81+
npm install && ng serve --configuration local --open
2582

26-
.PHONY: build
27-
build: ## Build the frontend for production
28-
npm run build:prod
83+
.PHONY: start-bundle
84+
start-bundle: ## Serve the built bundle
85+
serve dist/frontend/browser -s -l 4200
86+
87+
.PHONY: start-dev
88+
start-dev: ## Start the development server (dev configuration)
89+
ng serve --configuration development
90+
91+
.PHONY: start-dev-mobile
92+
start-dev-mobile: ## Start the development server for mobile (accessible on network)
93+
ng serve --configuration development --host 0.0.0.0
94+
95+
.PHONY: start-fuzzing
96+
start-fuzzing: ## Start the fuzzing build and serve
97+
$(MAKE) install-deps && ng build --configuration fuzzing && \
98+
$(MAKE) start-bundle
99+
100+
.PHONY: start-webnode
101+
start-webnode: ## Start the webnode development server
102+
npm install && ng serve --configuration webnodelocal --open
29103

30104
.PHONY: test
31105
test: ## Run Cypress tests
32-
npm run tests
106+
npx cypress open --config baseUrl=http://localhost:4200
33107

34108
.PHONY: test-headless
35109
test-headless: ## Run Cypress tests in headless mode
36-
npm run tests:headless
37-
38-
.PHONY: clean
39-
clean: ## Clean build artifacts and node_modules
40-
rm -rf dist node_modules
41-
42-
.PHONY: rebuild
43-
rebuild: clean install build ## Clean, reinstall dependencies, and rebuild
110+
npx cypress run --headless --config baseUrl=http://localhost:4200

frontend/package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
"name": "frontend",
33
"version": "1.0.184",
44
"scripts": {
5-
"install:deps": "npm install",
6-
"start": "npm install && ng serve --configuration local --open",
7-
"start:dev": "ng serve --configuration development",
8-
"start:webnode": "npm install && ng serve --configuration webnodelocal --open",
9-
"start:dev:mobile": "ng serve --configuration development --host 0.0.0.0",
10-
"start:fuzzing": "npm run install:deps && ng build --configuration fuzzing && npm run start:bundle",
11-
"build": "ng build",
12-
"build:dev": "ng build --configuration development",
13-
"build:prod": "ng build --configuration production && npm run sentry:sourcemaps",
14-
"tests": "npx cypress open --config baseUrl=http://localhost:4200",
15-
"tests:headless": "npx cypress run --headless --config baseUrl=http://localhost:4200",
16-
"docker": "npm run build:prod && docker buildx build --platform linux/amd64 -t openmina/frontend:latest . && docker push openmina/frontend:latest",
17-
"start:bundle": "serve dist/frontend/browser -s -l 4200",
18-
"prebuild": "node scripts/update-frontend-version.js",
19-
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org openmina-uv --project openmina ./dist/frontend/browser && sentry-cli sourcemaps upload --org openmina-uv --project openmina ./dist/frontend/browser",
20-
"copy-env": "cp dist/frontend/browser/assets/environments/webnode.js dist/frontend/browser/assets/environments/env.js",
21-
"deploy": "npm run prebuild && npm run build:prod && npm run copy-env && firebase deploy",
22-
"deploy:leaderboard": "npm run prebuild && npm run build:prod && cp dist/frontend/browser/assets/environments/leaderboard.js dist/frontend/browser/assets/environments/env.js && firebase deploy",
5+
"install:deps": "make install-deps",
6+
"start": "make start",
7+
"start:dev": "make start-dev",
8+
"start:webnode": "make start-webnode",
9+
"start:dev:mobile": "make start-dev-mobile",
10+
"start:fuzzing": "make start-fuzzing",
11+
"build": "make build",
12+
"build:dev": "make build-dev",
13+
"build:prod": "make build-prod",
14+
"tests": "make test",
15+
"tests:headless": "make test-headless",
16+
"docker": "make docker",
17+
"start:bundle": "make start-bundle",
18+
"prebuild": "make prebuild",
19+
"sentry:sourcemaps": "make sentry-sourcemaps",
20+
"copy-env": "make copy-env",
21+
"deploy": "make deploy",
22+
"deploy:leaderboard": "make deploy-leaderboard",
2323
"prettify": "make prettify",
2424
"check-prettify": "make check-prettify"
2525
},

0 commit comments

Comments
 (0)