Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
164 lines (128 loc) · 5.16 KB
/
Copy pathMakefile
File metadata and controls
164 lines (128 loc) · 5.16 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# CipherScan - Zcash blockchain explorer
# Run `make help` to list available targets.
.DEFAULT_GOAL := help
# Sub-projects with their own package.json / build.
API_DIR := server/api
INDEXER_DIR := server/indexer
DECODER_DIR := packages/zcash-decoder
WASM_DIR := wasm
JOBS_DIR := server/jobs
.PHONY: help
help: ## Ask for help!
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# ---------------------------------------------------------------------------
# Setup / install
# ---------------------------------------------------------------------------
.PHONY: setup
setup: install ## Setup development environment (alias for install)
.PHONY: install
install: install-frontend install-api install-indexer install-decoder \
install-jobs ## Install all dependencies (frontend, api, indexer, jobs)
.PHONY: install-frontend
install-frontend: ## Install frontend (Next.js) dependencies
npm ci
.PHONY: install-api
install-api: ## Install Express API backend dependencies
cd $(API_DIR) && npm ci
.PHONY: install-indexer
install-indexer: ## Install indexer dependencies
cd $(INDEXER_DIR) && npm ci
.PHONY: install-decoder
install-decoder: ## Install zcash-decoder package dependencies
cd $(DECODER_DIR) && npm ci
.PHONY: install-jobs
install-jobs: ## Install Python ML job dependencies
cd $(JOBS_DIR) && pip install --require-hashes -r requirements.txt
# ---------------------------------------------------------------------------
# Build
# ---------------------------------------------------------------------------
.PHONY: build
build: build-wasm build-decoder build-frontend ## Build everything
.PHONY: build-frontend
build-frontend: ## Build the Next.js frontend
npm run build
.PHONY: build-decoder
build-decoder: ## Build the zcash-decoder package
cd $(DECODER_DIR) && npm run build
.PHONY: build-wasm
build-wasm: ## Build the Rust WASM module and copy to public/wasm
cd $(WASM_DIR) && wasm-pack build --target web --release
mkdir -p public/wasm
cp $(WASM_DIR)/pkg/zcash_wasm.js public/wasm/
cp $(WASM_DIR)/pkg/zcash_wasm_bg.wasm public/wasm/
cp $(WASM_DIR)/pkg/zcash_wasm.d.ts public/wasm/
# ---------------------------------------------------------------------------
# Run (development)
# ---------------------------------------------------------------------------
.PHONY: dev
dev: ## Run the Next.js dev server
npm run dev
.PHONY: dev-api
dev-api: ## Run the Express API backend (nodemon)
cd $(API_DIR) && npm run dev
.PHONY: start
start: ## Run the production Next.js server (after `make build`)
npm run start
.PHONY: start-api
start-api: ## Run the production Express API backend
cd $(API_DIR) && npm start
# ---------------------------------------------------------------------------
# Lint / type-check
# ---------------------------------------------------------------------------
.PHONY: check
check: verify-fast ## Run the fast pre-push checks
.PHONY: verify-fast
verify-fast: ## Run the same fast frontend checks used by CI
npm run verify:fast
.PHONY: verify-full
verify-full: ## Run all CI-equivalent checks (requires setup + wasm-pack)
npm run verify:frontend
cd $(API_DIR) && npm run verify
npm run test:server-regressions
cd $(INDEXER_DIR) && npm run verify
cd $(DECODER_DIR) && npm run build
cd $(WASM_DIR) && cargo clippy --target wasm32-unknown-unknown -- -D warnings
cd $(WASM_DIR) && wasm-pack build --target web --release
cd $(JOBS_DIR) && python3 -c "import pathlib; [compile(path.read_text(), str(path), 'exec') for path in pathlib.Path('.').rglob('*.py')]"
$(MAKE) lint-shell
.PHONY: lint
lint: ## Lint the frontend (next lint)
npm run lint
.PHONY: typecheck
typecheck: ## Type-check the frontend (tsc --noEmit)
npx tsc --noEmit
.PHONY: lint-shell
lint-shell: ## Lint shell scripts with shellcheck
@find . -name '*.sh' -not -path '*/node_modules/*' -not -path './.netlify/*' -not -path './.next/*' \
-print0 | xargs -0 -r shellcheck --severity=warning
.PHONY: clippy
clippy: ## Run clippy on the WASM crate
cd $(WASM_DIR) && cargo clippy \
--target wasm32-unknown-unknown -- -D warnings
# ---------------------------------------------------------------------------
# Security audit
# ---------------------------------------------------------------------------
.PHONY: audit
audit: audit-npm audit-cargo audit-python ## Run all dependency audits
.PHONY: audit-npm
audit-npm: ## npm audit across all JS packages
npm audit --audit-level=high || true
cd $(API_DIR) && npm audit --audit-level=high || true
cd $(INDEXER_DIR) && npm audit --audit-level=high || true
cd $(DECODER_DIR) && npm audit --audit-level=high || true
.PHONY: audit-cargo
audit-cargo: ## cargo audit on the WASM crate (needs cargo-audit)
cd $(WASM_DIR) && cargo audit
.PHONY: audit-python
audit-python: ## pip-audit on Python jobs (needs pip-audit)
cd $(JOBS_DIR) && pip-audit -r requirements.txt
# ---------------------------------------------------------------------------
# Clean
# ---------------------------------------------------------------------------
.PHONY: clean
clean: ## Remove build artifacts
rm -rf .next out
rm -rf $(WASM_DIR)/pkg $(WASM_DIR)/target
rm -rf $(DECODER_DIR)/dist