Skip to content

Commit e3f0710

Browse files
authored
Merge pull request #1468 from o1-labs/dw/frontend-makefile-targets
Frontend/Makefile: improve and sync with package.json
2 parents c4b5581 + 8d72f07 commit e3f0710

File tree

3 files changed

+107
-36
lines changed

3 files changed

+107
-36
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
is tested accordingly in the CI at every push.
2323
- **Website**: add comparison list of implemented and missing GraphQL endpoints
2424
([#1486](https://github.com/o1-labs/mina-rust/pull/1466))
25+
- **Frontend**: use a Makefile for scripts in package.json
26+
([#1468](https://github.com/o1-labs/mina-rust/pull/1468))
2527

2628
### Changed
2729

frontend/Makefile

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,108 @@
33
.PHONY: help
44
help: ## Display this help message
55
@echo "Frontend Makefile - Available targets:"
6-
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
6+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
7+
awk 'BEGIN {FS = ":.*?## "}; \
8+
{printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
9+
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
752

853
.PHONY: install
954
install: ## Install npm dependencies
1055
npm install
1156

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+
1265
.PHONY: prettify
1366
prettify: ## Format HTML, SCSS, TypeScript, and JavaScript files with Prettier
1467
npx prettier --write 'src/**/*.{ts,js,html,scss,css,json}'
1568

16-
.PHONY: check-prettify
17-
check-prettify: ## Check if files are formatted with Prettier
18-
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
1978

2079
.PHONY: start
2180
start: ## Start the development server
22-
npm start
81+
npm install && ng serve --configuration local --open
2382

24-
.PHONY: build
25-
build: ## Build the frontend for production
26-
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
27103

28104
.PHONY: test
29105
test: ## Run Cypress tests
30-
npm run tests
106+
npx cypress open --config baseUrl=http://localhost:4200
31107

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

frontend/package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
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+
"build": "make build",
6+
"build:dev": "make build-dev",
7+
"build:prod": "make build-prod",
8+
"check-prettify": "make check-prettify",
9+
"copy-env": "make copy-env",
10+
"deploy": "make deploy",
11+
"deploy:leaderboard": "make deploy-leaderboard",
12+
"docker": "make docker",
13+
"install:deps": "make install-deps",
14+
"prebuild": "make prebuild",
2315
"prettify": "make prettify",
24-
"check-prettify": "make check-prettify"
16+
"sentry:sourcemaps": "make sentry-sourcemaps",
17+
"start": "make start",
18+
"start:bundle": "make start-bundle",
19+
"start:dev": "make start-dev",
20+
"start:dev:mobile": "make start-dev-mobile",
21+
"start:fuzzing": "make start-fuzzing",
22+
"start:webnode": "make start-webnode",
23+
"tests": "make test",
24+
"tests:headless": "make test-headless"
2525
},
2626
"private": true,
2727
"dependencies": {

0 commit comments

Comments
 (0)