Skip to content

Commit bf91c7b

Browse files
committed
local dev and hooks
1 parent 74a9059 commit bf91c7b

File tree

4 files changed

+362
-51
lines changed

4 files changed

+362
-51
lines changed

.githooks/pre-commit

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
3+
# Pre-commit hook to strip local aztec-packages resolutions from package.json
4+
# and clean up vite.config.ts fs.allow paths
5+
# This prevents accidentally committing local development paths
6+
7+
REPO_ROOT=$(git rev-parse --show-toplevel)
8+
9+
MODIFIED=0
10+
11+
# Check package.json
12+
PACKAGE_FILE="package.json"
13+
FULL_PATH="$REPO_ROOT/$PACKAGE_FILE"
14+
15+
if [ -f "$FULL_PATH" ] && git diff --cached --name-only | grep -q "^$PACKAGE_FILE$"; then
16+
# Check if resolutions field exists with link: entries
17+
if grep -q '"resolutions"' "$FULL_PATH" && grep -q '"link:' "$FULL_PATH"; then
18+
echo "Stripping local resolutions from $PACKAGE_FILE..."
19+
20+
# Use node to remove the resolutions field
21+
node -e "
22+
const fs = require('fs');
23+
const pkg = JSON.parse(fs.readFileSync('$FULL_PATH', 'utf-8'));
24+
if (pkg.resolutions) {
25+
delete pkg.resolutions;
26+
fs.writeFileSync('$FULL_PATH', JSON.stringify(pkg, null, 2) + '\n');
27+
}
28+
"
29+
30+
# Re-stage the file
31+
git add "$FULL_PATH"
32+
MODIFIED=1
33+
fi
34+
fi
35+
36+
# Check vite.config.ts for absolute aztec-packages paths
37+
VITE_CONFIG="vite.config.ts"
38+
VITE_PATH="$REPO_ROOT/$VITE_CONFIG"
39+
40+
if [ -f "$VITE_PATH" ] && git diff --cached --name-only | grep -q "^$VITE_CONFIG$"; then
41+
# Check if fs.allow contains absolute paths to aztec-packages
42+
if grep -q "allow:" "$VITE_PATH" && grep -E "'/.*aztec-packages/" "$VITE_PATH" > /dev/null 2>&1; then
43+
echo "Cleaning up vite.config.ts fs.allow paths..."
44+
45+
# Use node to clean up the vite config
46+
node -e "
47+
const fs = require('fs');
48+
let content = fs.readFileSync('$VITE_PATH', 'utf-8');
49+
50+
// Replace fs.allow block with minimal version
51+
const fsBlockRegex = /fs:\s*\{[\s\S]*?allow:\s*\[[\s\S]*?\],[\s\S]*?\},/;
52+
const minimalFsAllowBlock = \`fs: {
53+
allow: [searchForWorkspaceRoot(process.cwd())],
54+
},\`;
55+
56+
if (fsBlockRegex.test(content)) {
57+
content = content.replace(fsBlockRegex, minimalFsAllowBlock);
58+
fs.writeFileSync('$VITE_PATH', content);
59+
}
60+
"
61+
62+
# Re-stage the file
63+
git add "$VITE_PATH"
64+
MODIFIED=1
65+
fi
66+
fi
67+
68+
if [ $MODIFIED -eq 1 ]; then
69+
echo ""
70+
echo "Local development paths have been stripped."
71+
echo "The commit will proceed with the cleaned files."
72+
echo ""
73+
fi
74+
75+
exit 0

package.json

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"deploy:local": "node --experimental-transform-types scripts/deploy.ts --network local",
1717
"deploy:devnet": "node --experimental-transform-types scripts/deploy.ts --network devnet",
1818
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
19-
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src"
19+
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
20+
"local-aztec:enable": "node scripts/toggle-local-aztec.js enable",
21+
"local-aztec:disable": "node scripts/toggle-local-aztec.js disable",
22+
"local-aztec:status": "node scripts/toggle-local-aztec.js status"
2023
},
2124
"dependencies": {
2225
"@aztec/accounts": "v3.0.0-nightly.20260106",
@@ -58,46 +61,5 @@
5861
"typescript-eslint": "^8.11.0",
5962
"vite": "^7.1.4",
6063
"vite-plugin-node-polyfills": "^0.24.0"
61-
},
62-
"resolutions": {
63-
"@aztec/accounts": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/accounts",
64-
"@aztec/archiver": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/archiver",
65-
"@aztec/aztec.js": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/aztec.js",
66-
"@aztec/bb.js": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/barretenberg/ts",
67-
"@aztec/bb-prover": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/bb-prover",
68-
"@aztec/blob-client": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/blob-client",
69-
"@aztec/blob-lib": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/blob-lib",
70-
"@aztec/builder": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/builder",
71-
"@aztec/constants": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/constants",
72-
"@aztec/entrypoints": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/entrypoints",
73-
"@aztec/epoch-cache": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/epoch-cache",
74-
"@aztec/ethereum": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/ethereum",
75-
"@aztec/foundation": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/foundation",
76-
"@aztec/key-store": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/key-store",
77-
"@aztec/kv-store": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/kv-store",
78-
"@aztec/l1-artifacts": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/l1-artifacts",
79-
"@aztec/merkle-tree": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/merkle-tree",
80-
"@aztec/native": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/native",
81-
"@aztec/noir-acvm_js": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/noir/packages/acvm_js",
82-
"@aztec/noir-contracts.js": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/noir-contracts.js",
83-
"@aztec/noir-noir_codegen": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/noir/packages/noir_codegen",
84-
"@aztec/noir-noirc_abi": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/noir/packages/noirc_abi",
85-
"@aztec/noir-protocol-circuits-types": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/noir-protocol-circuits-types",
86-
"@aztec/noir-types": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/noir/packages/types",
87-
"@aztec/node-keystore": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/node-keystore",
88-
"@aztec/node-lib": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/node-lib",
89-
"@aztec/p2p": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/p2p",
90-
"@aztec/protocol-contracts": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/protocol-contracts",
91-
"@aztec/prover-client": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/prover-client",
92-
"@aztec/pxe": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/pxe",
93-
"@aztec/sequencer-client": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/sequencer-client",
94-
"@aztec/simulator": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/simulator",
95-
"@aztec/slasher": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/slasher",
96-
"@aztec/stdlib": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/stdlib",
97-
"@aztec/telemetry-client": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/telemetry-client",
98-
"@aztec/validator-client": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/validator-client",
99-
"@aztec/wallet-sdk": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/wallet-sdk",
100-
"@aztec/world-state": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/world-state",
101-
"@aztec/test-wallet": "link:/Users/gregoriojulianaquiros/Repos/aztec-packages/yarn-project/test-wallet"
10264
}
10365
}

0 commit comments

Comments
 (0)