55# 1. Hardhat compilation (generates artifacts and ethers-v6 types)
66# 2. Type generation (WAGMI and ethers-v5 types)
77# 3. TypeScript compilation (both v6 and v5 types)
8+ #
9+ # Usage:
10+ # build.sh - Minimal output (only shows actions taken, not skipped)
11+ # build.sh --verbose - Full output (shows all details)
812
913set -e # Exit on any error
1014
11- echo " 🔨 Starting build process..."
15+ # Parse flags
16+ VERBOSE=false
17+ if [[ " $1 " == " --verbose" ]]; then
18+ VERBOSE=true
19+ fi
20+
21+ # Logging helpers
22+ log_info () {
23+ # Only show in verbose mode (headers, status, skipped items)
24+ if [[ " $VERBOSE " == " true" ]]; then
25+ echo " $@ "
26+ fi
27+ }
28+
29+ log_action () {
30+ # Always show actions being taken
31+ echo " $@ "
32+ }
33+
34+ log_info " 🔨 Starting build process..."
1235
1336# Helper function to check if target is newer than sources
1437is_newer () {
@@ -38,42 +61,42 @@ find_files() {
3861}
3962
4063# Step 1: Hardhat compilation
41- echo " 📦 Compiling contracts with Hardhat..."
42- pnpm hardhat compile
64+ log_info " 📦 Compiling contracts with Hardhat..."
65+ pnpm hardhat compile $( [[ " $VERBOSE " != " true " ]] && echo " --quiet " )
4366
4467# Step 1.5: Generate interface IDs
4568node scripts/generateInterfaceIds.js
4669
4770# Step 2: Generate types (only if needed)
48- echo " 🏗️ Checking type definitions..."
71+ log_info " 🏗️ Checking type definitions..."
4972
5073# Check if WAGMI types need regeneration
5174wagmi_sources=(
5275 " wagmi.config.mts"
5376 $( find_files " ./artifacts/contracts/**/!(*.dbg).json" )
5477)
5578if ! is_newer " wagmi/generated.ts" " ${wagmi_sources[@]} " ; then
56- echo " - Generating WAGMI types..."
79+ log_action " - Generating WAGMI types..."
5780 pnpm wagmi generate
5881else
59- echo " - WAGMI types are up to date"
82+ log_info " - WAGMI types are up to date"
6083fi
6184
6285# Check if ethers-v5 types need regeneration
6386v5_artifacts=($( find_files " ./artifacts/contracts/**/!(*.dbg).json" ) $( find_files " ./artifacts/@openzeppelin/**/!(*.dbg).json" ) )
6487if ! is_newer " types-v5/index.ts" " ${v5_artifacts[@]} " ; then
65- echo " - Generating ethers-v5 types..."
88+ log_action " - Generating ethers-v5 types..."
6689 pnpm typechain \
6790 --target ethers-v5 \
6891 --out-dir types-v5 \
6992 ' artifacts/contracts/**/!(*.dbg).json' \
7093 ' artifacts/@openzeppelin/**/!(*.dbg).json'
7194else
72- echo " - ethers-v5 types are up to date"
95+ log_info " - ethers-v5 types are up to date"
7396fi
7497
7598# Step 3: TypeScript compilation (only if needed)
76- echo " 🔧 Checking TypeScript compilation..."
99+ log_info " 🔧 Checking TypeScript compilation..."
77100
78101# Check if v6 types need compilation
79102v6_sources=(
@@ -83,21 +106,21 @@ v6_sources=(
83106 $( find_files " ./wagmi/**/*.ts" )
84107)
85108if ! is_newer " dist/tsconfig.tsbuildinfo" " ${v6_sources[@]} " ; then
86- echo " - Compiling ethers-v6 types..."
109+ log_action " - Compiling ethers-v6 types..."
87110 pnpm tsc
88111 touch dist/tsconfig.tsbuildinfo
89112else
90- echo " - ethers-v6 types are up to date"
113+ log_info " - ethers-v6 types are up to date"
91114fi
92115
93116# Check if v5 types need compilation
94117v5_sources=($( find_files " ./types-v5/**/*.ts" ) )
95118if ! is_newer " dist-v5/tsconfig.v5.tsbuildinfo" " ${v5_sources[@]} " ; then
96- echo " - Compiling ethers-v5 types..."
119+ log_action " - Compiling ethers-v5 types..."
97120 pnpm tsc -p tsconfig.v5.json
98121 touch dist-v5/tsconfig.v5.tsbuildinfo
99122else
100- echo " - ethers-v5 types are up to date"
123+ log_info " - ethers-v5 types are up to date"
101124fi
102125
103126# Step 4: Merge v5 types into dist directory (only if needed)
@@ -119,15 +142,15 @@ if [[ -d "dist-v5" ]]; then
119142fi
120143
121144if [[ " $needs_copy " == " true" ]]; then
122- echo " 📁 Organizing compiled types..."
145+ log_action " 📁 Organizing compiled types..."
123146 mkdir -p dist/types-v5
124147 cp -r dist-v5/* dist/types-v5/
125148else
126- echo " 📁 Compiled types organization is up to date"
149+ log_info " 📁 Compiled types organization is up to date"
127150fi
128151
129- echo " ✅ Build completed successfully!"
130- echo " 📄 Generated types:"
131- echo " - ethers-v6: dist/types/"
132- echo " - ethers-v5: dist/types-v5/"
133- echo " - wagmi: dist/wagmi/"
152+ log_info " ✅ Build completed successfully!"
153+ log_info " 📄 Generated types:"
154+ log_info " - ethers-v6: dist/types/"
155+ log_info " - ethers-v5: dist/types-v5/"
156+ log_info " - wagmi: dist/wagmi/"
0 commit comments