From c8a5cfb375b498475503c12cc83fcdba39f2ec5f Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Thu, 14 Sep 2023 00:31:19 +0100 Subject: [PATCH] feat: build_manifest default tweaks. (#2287) If rebuildPatterns are not provided in build_manifest.json, default to the project dir. Can also exclude empty dependencies. --- build-system/scripts/query_manifest | 35 +++-- build_manifest.json | 120 +++++------------- yarn-project/acir-simulator/package.json | 2 - yarn-project/archiver/package.json | 2 - yarn-project/aztec-node/package.json | 2 - yarn-project/aztec-rpc/package.json | 2 - yarn-project/aztec-sandbox/package.json | 2 - yarn-project/aztec.js/package.json | 2 - yarn-project/circuits.js/package.json | 2 - yarn-project/cli/package.json | 2 - yarn-project/end-to-end/package.json | 2 - yarn-project/ethereum/package.json | 2 - yarn-project/foundation/package.json | 2 - yarn-project/key-store/package.json | 2 - yarn-project/l1-artifacts/package.json | 2 - yarn-project/merkle-tree/package.json | 2 - yarn-project/noir-compiler/package.json | 2 - yarn-project/noir-contracts/package.json | 2 - yarn-project/p2p-bootstrap/package.json | 2 - yarn-project/p2p/package.json | 2 - yarn-project/package.common.json | 2 - yarn-project/prover-client/package.json | 2 - yarn-project/rollup-provider/package.json | 2 - yarn-project/sequencer-client/package.json | 2 - yarn-project/types/package.json | 2 - yarn-project/world-state/package.json | 2 - .../scripts/update_build_manifest.mjs | 106 ---------------- 27 files changed, 57 insertions(+), 252 deletions(-) delete mode 100644 yarn-project/yarn-project-base/scripts/update_build_manifest.mjs diff --git a/build-system/scripts/query_manifest b/build-system/scripts/query_manifest index 51eac1df79d..85ccbf1e96d 100755 --- a/build-system/scripts/query_manifest +++ b/build-system/scripts/query_manifest @@ -15,6 +15,7 @@ function get_deps { local TYPE=$(jq -r ".\"$1\".dependencies | type" $MANIFEST) if [ "$TYPE" == "string" ]; then # Execute string as command relative to buildDir to retrieve dependencies. + local BUILD_DIR=$($0 buildDir $1) local CMD=$BUILD_DIR/$(jq -r ".\"$1\".dependencies") if [ ! -f "$CMD" ]; then >&2 echo "Dependency script not found: $CMD" @@ -24,10 +25,11 @@ function get_deps { DEPS=($($CMD $PROJECT_DIR)) elif [ "$TYPE" == "null" ]; then # Execute default script relative to buildDir to retrieve dependencies. + local BUILD_DIR=$($0 buildDir $1) local CMD=$BUILD_DIR/scripts/get_dependencies.sh if [ ! -f "$CMD" ]; then - >&2 echo "Dependency script not found: $CMD" - exit 1 + DEPS=() + return fi local PROJECT_DIR=$($0 projectDir $1) DEPS=($($CMD $PROJECT_DIR)) @@ -43,22 +45,25 @@ function add_rebuild_patterns { local TYPE=$(jq -r ".\"$1\".rebuildPatterns | type" $MANIFEST) if [ "$TYPE" == "string" ]; then local FILE=$(jq -r ".\"$1\".rebuildPatterns" $MANIFEST) - local BUILD_DIR=$($0 buildDir $1) - PATTERNS=(${PATTERNS[@]} $(cat $BUILD_DIR/$FILE)) + local PROJECT_DIR=$($0 projectDir $1) + PATTERNS=(${PATTERNS[@]} $(cat $PROJECT_DIR/$FILE)) elif [ "$TYPE" == "array" ]; then PATTERNS=(${PATTERNS[@]} $(jq -r ".\"$1\".rebuildPatterns | .[]" $MANIFEST)) + elif [ "$TYPE" == "null" ]; then + local PROJECT_DIR=$($0 relativeProjectDir $1) + PATTERNS=(${PATTERNS[@]} "^$PROJECT_DIR/") else - >&2 echo "Missing rebuildPatterns property. Either filename as string, or patterns as array." + >&2 echo "rebuildPatterns must be array, string, or null." exit 1 fi } case "$CMD" in dockerfile) - # In the manifest, the path is relative to buildDir. Return absolute path. - BUILD_DIR=$($0 buildDir $REPO) + # In the manifest, the path is relative to projectDir. Return absolute path. + PROJECT_DIR=$($0 projectDir $REPO) DOCKERFILE=$(jq -r ".\"$REPO\".dockerfile // \"Dockerfile\"" $MANIFEST) - echo $BUILD_DIR/$DOCKERFILE + echo $PROJECT_DIR/$DOCKERFILE ;; buildDir) # In the manifest, the path is relative to the repo root. Return absolute path. @@ -71,10 +76,15 @@ case "$CMD" in echo $ROOT_PATH/$PROJECT_DIR ;; relativeProjectDir) + # Return the relative path as it is in the manifest. jq -r ".\"$REPO\".projectDir // .\"$REPO\".buildDir" $MANIFEST ;; dependencies) - BUILD_DIR=$($0 buildDir $REPO) + # Get dependencies for a given repo. + # If no entry in the manifest file, attempt to call /scripts/get_dependencies.sh if exists, else empty. + # If a string, attempt to call / if exists, else error. + # If an array, the array lists the dependencies. + # Recursively descend "unvisited" dependencies to collect all dependencies. declare -A ALL_DEPS add_deps() { if [[ -v ALL_DEPS[$1] ]]; then @@ -87,11 +97,18 @@ case "$CMD" in done } add_deps $REPO + # Remove ourself as a dependency. + unset ALL_DEPS["$REPO"] for KEY in "${!ALL_DEPS[@]}"; do echo $KEY done | sort ;; rebuildPatterns) + # Get rebuild patterns for a given repo (the file patterns that if changed result in rebuilds). + # First add rebuild patterns for requested repo, then add rebuild patterns for each dependency. + # If no rebuild patterns are given, the result is ["^/"]. + # If a projects rebuildPattern is a string, the rebuild patterns are in /. + # If an array, the array lists the rebuild patterns. DEPS=($($0 dependencies $REPO)) PATTERNS=() add_rebuild_patterns $REPO diff --git a/build_manifest.json b/build_manifest.json index 0f7316595d7..3a24db1ef01 100644 --- a/build_manifest.json +++ b/build_manifest.json @@ -2,48 +2,40 @@ "barretenberg-x86_64-linux-clang": { "buildDir": "barretenberg/cpp", "dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang", - "rebuildPatterns": ".rebuild_patterns", - "dependencies": [] + "rebuildPatterns": ".rebuild_patterns" }, "barretenberg-x86_64-linux-clang-assert": { "buildDir": "barretenberg/cpp", "dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-assert", - "rebuildPatterns": ".rebuild_patterns", - "dependencies": [] + "rebuildPatterns": ".rebuild_patterns" }, "barretenberg-x86_64-linux-clang-fuzzing": { "buildDir": "barretenberg/cpp", "dockerfile": "dockerfiles/Dockerfile.x86_64-linux-clang-fuzzing", - "rebuildPatterns": ".rebuild_patterns", - "dependencies": [] + "rebuildPatterns": ".rebuild_patterns" }, "barretenberg-x86_64-linux-gcc": { "buildDir": "barretenberg/cpp", "dockerfile": "dockerfiles/Dockerfile.x86_64-linux-gcc", - "rebuildPatterns": ".rebuild_patterns", - "dependencies": [] + "rebuildPatterns": ".rebuild_patterns" }, "barretenberg-wasm-linux-clang": { "buildDir": "barretenberg/cpp", "dockerfile": "dockerfiles/Dockerfile.wasm-linux-clang", - "rebuildPatterns": ".rebuild_patterns", - "dependencies": [] + "rebuildPatterns": ".rebuild_patterns" }, "bb.js": { "buildDir": "barretenberg/ts", - "rebuildPatterns": ["^barretenberg/ts/"], "dependencies": ["barretenberg-wasm-linux-clang"] }, "barretenberg-acir-tests-bb": { "buildDir": "barretenberg/acir_tests", "dockerfile": "Dockerfile.bb", - "rebuildPatterns": ["^barretenberg/acir_tests/"], "dependencies": ["barretenberg-x86_64-linux-clang-assert"] }, "barretenberg-acir-tests-bb.js": { "buildDir": "barretenberg/acir_tests", "dockerfile": "Dockerfile.bb.js", - "rebuildPatterns": ["^barretenberg/acir_tests/"], "dependencies": ["bb.js"] }, "circuits-wasm-linux-clang": { @@ -79,19 +71,14 @@ "docs": { "buildDir": ".", "dockerfile": "docs/Dockerfile", - "rebuildPatterns": ["^docs/", "^.*.cpp$", "^.*.ts$"], - "dependencies": [] + "rebuildPatterns": ["^docs/", "^.*.cpp$", "^.*.ts$"] }, "l1-contracts": { - "buildDir": "l1-contracts", - "dockerfile": "Dockerfile", - "rebuildPatterns": ["^l1-contracts/"], - "dependencies": [] + "buildDir": "l1-contracts" }, "l1-artifacts": { "buildDir": "yarn-project", "projectDir": "yarn-project/l1-artifacts", - "dockerfile": "l1-artifacts/Dockerfile", "rebuildPatterns": ["^l1-contracts/", "^yarn-project/l1-artifacts/"], "dependencies": [] }, @@ -111,92 +98,65 @@ }, "acir-simulator": { "buildDir": "yarn-project", - "projectDir": "yarn-project/acir-simulator", - "dockerfile": "acir-simulator/Dockerfile", - "rebuildPatterns": ["^yarn-project/acir-simulator/"] + "projectDir": "yarn-project/acir-simulator" }, "archiver": { "buildDir": "yarn-project", - "projectDir": "yarn-project/archiver", - "dockerfile": "archiver/Dockerfile", - "rebuildPatterns": ["^yarn-project/archiver/"] + "projectDir": "yarn-project/archiver" }, "cli": { "buildDir": "yarn-project", - "projectDir": "yarn-project/cli", - "dockerfile": "cli/Dockerfile", - "rebuildPatterns": ["^yarn-project/cli/"] + "projectDir": "yarn-project/cli" }, "aztec-rpc": { "buildDir": "yarn-project", - "projectDir": "yarn-project/aztec-rpc", - "dockerfile": "aztec-rpc/Dockerfile", - "rebuildPatterns": ["^yarn-project/aztec-rpc/"] + "projectDir": "yarn-project/aztec-rpc" }, "aztec-sandbox": { "buildDir": "yarn-project", - "projectDir": "yarn-project/aztec-sandbox", - "dockerfile": "aztec-sandbox/Dockerfile", - "rebuildPatterns": ["^yarn-project/aztec-sandbox/"] + "projectDir": "yarn-project/aztec-sandbox" }, "aztec.js": { "buildDir": "yarn-project", - "projectDir": "yarn-project/aztec.js", - "dockerfile": "aztec.js/Dockerfile", - "rebuildPatterns": ["^yarn-project/aztec.js/"] + "projectDir": "yarn-project/aztec.js" }, "canary-build": { "buildDir": "yarn-project", "projectDir": "yarn-project/canary", - "dockerfile": "canary/Dockerfile.build", - "rebuildPatterns": ["^yarn-project/canary/"] + "dockerfile": "Dockerfile.build" }, "canary": { "buildDir": "yarn-project", - "projectDir": "yarn-project/canary", - "dockerfile": "canary/Dockerfile", - "rebuildPatterns": ["^yarn-project/canary/"] + "projectDir": "yarn-project/canary" }, "circuits.js": { "buildDir": "yarn-project", - "projectDir": "yarn-project/circuits.js", - "dockerfile": "circuits.js/Dockerfile", - "rebuildPatterns": ["^yarn-project/circuits.js/"] + "projectDir": "yarn-project/circuits.js" }, "end-to-end": { "buildDir": "yarn-project", - "projectDir": "yarn-project/end-to-end", - "dockerfile": "end-to-end/Dockerfile", - "rebuildPatterns": ["^yarn-project/end-to-end/"] + "projectDir": "yarn-project/end-to-end" }, "ethereum": { "buildDir": "yarn-project", - "projectDir": "yarn-project/ethereum", - "dockerfile": "ethereum/Dockerfile", - "rebuildPatterns": ["^yarn-project/ethereum/"] + "projectDir": "yarn-project/ethereum" }, "foundation": { "buildDir": "yarn-project", - "projectDir": "yarn-project/foundation", - "dockerfile": "foundation/Dockerfile", - "rebuildPatterns": ["^yarn-project/foundation/"] + "projectDir": "yarn-project/foundation" }, "key-store": { "buildDir": "yarn-project", - "projectDir": "yarn-project/key-store", - "dockerfile": "key-store/Dockerfile", - "rebuildPatterns": ["^yarn-project/key-store/"] + "projectDir": "yarn-project/key-store" }, "merkle-tree": { "buildDir": "yarn-project", - "projectDir": "yarn-project/merkle-tree", - "dockerfile": "merkle-tree/Dockerfile", - "rebuildPatterns": ["^yarn-project/merkle-tree/"] + "projectDir": "yarn-project/merkle-tree" }, "noir-contracts-build": { "buildDir": "yarn-project", "projectDir": "yarn-project/noir-contracts", - "dockerfile": "noir-contracts/Dockerfile.build", + "dockerfile": "Dockerfile.build", "rebuildPatterns": [ "^yarn-project/noir-contracts/", "^yarn-project/aztec-nr/" @@ -205,7 +165,6 @@ "noir-contracts": { "buildDir": "yarn-project", "projectDir": "yarn-project/noir-contracts", - "dockerfile": "noir-contracts/Dockerfile", "rebuildPatterns": [ "^yarn-project/noir-contracts/", "^yarn-project/aztec-nr/" @@ -213,56 +172,39 @@ }, "noir-compiler": { "buildDir": "yarn-project", - "projectDir": "yarn-project/noir-compiler", - "dockerfile": "noir-compiler/Dockerfile", - "rebuildPatterns": ["^yarn-project/noir-compiler/"] + "projectDir": "yarn-project/noir-compiler" }, "p2p": { "buildDir": "yarn-project", - "projectDir": "yarn-project/p2p", - "dockerfile": "p2p/Dockerfile", - "rebuildPatterns": ["^yarn-project/p2p/"] + "projectDir": "yarn-project/p2p" }, "p2p-bootstrap": { "buildDir": "yarn-project", "projectDir": "yarn-project/p2p-bootstrap", - "dockerfile": "p2p/Dockerfile", - "rebuildPatterns": ["^yarn-project/p2p-bootstrap/"] + "dockerfile": "../p2p/Dockerfile" }, "prover-client": { "buildDir": "yarn-project", - "projectDir": "yarn-project/prover-client", - "dockerfile": "prover-client/Dockerfile", - "rebuildPatterns": ["^yarn-project/prover-client/"] + "projectDir": "yarn-project/prover-client" }, "rollup-provider": { "buildDir": "yarn-project", - "projectDir": "yarn-project/rollup-provider", - "dockerfile": "rollup-provider/Dockerfile", - "rebuildPatterns": ["^yarn-project/rollup-provider/"] + "projectDir": "yarn-project/rollup-provider" }, "aztec-node": { "buildDir": "yarn-project", - "projectDir": "yarn-project/aztec-node", - "dockerfile": "aztec-node/Dockerfile", - "rebuildPatterns": ["^yarn-project/aztec-node/"] + "projectDir": "yarn-project/aztec-node" }, "sequencer-client": { "buildDir": "yarn-project", - "projectDir": "yarn-project/sequencer-client", - "dockerfile": "sequencer-client/Dockerfile", - "rebuildPatterns": ["^yarn-project/sequencer-client/"] + "projectDir": "yarn-project/sequencer-client" }, "types": { "buildDir": "yarn-project", - "projectDir": "yarn-project/types", - "dockerfile": "types/Dockerfile", - "rebuildPatterns": ["^yarn-project/types/"] + "projectDir": "yarn-project/types" }, "world-state": { "buildDir": "yarn-project", - "projectDir": "yarn-project/world-state", - "dockerfile": "world-state/Dockerfile", - "rebuildPatterns": ["^yarn-project/world-state/"] + "projectDir": "yarn-project/world-state" } } diff --git a/yarn-project/acir-simulator/package.json b/yarn-project/acir-simulator/package.json index ef6fd4d3bfc..d11b6d6fafa 100644 --- a/yarn-project/acir-simulator/package.json +++ b/yarn-project/acir-simulator/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index 4dbc4a5465e..48867bed693 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index ec5beb82863..8e785e5b058 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -12,8 +12,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/aztec-rpc/package.json b/yarn-project/aztec-rpc/package.json index 7ac8adacfc0..78f906e82b5 100644 --- a/yarn-project/aztec-rpc/package.json +++ b/yarn-project/aztec-rpc/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/aztec-sandbox/package.json b/yarn-project/aztec-sandbox/package.json index 041da41d296..d176756f835 100644 --- a/yarn-project/aztec-sandbox/package.json +++ b/yarn-project/aztec-sandbox/package.json @@ -14,13 +14,11 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", "build": "yarn clean && tsc -b", "start": "node --no-warnings ./dest/bin", "clean": "rm -rf ./dest .tsbuildinfo", "formatting": "run -T prettier --check ./src && run -T eslint ./src", "formatting:fix": "run -T prettier -w ./src", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build:dev": "tsc -b --watch", "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --passWithNoTests", "run:example:token": "DEBUG='aztec:*' node ./dest/examples/private_token_contract.js", diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index 0a67c34d5b3..44e2441449b 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -16,8 +16,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b && webpack", "build:web": "webpack", "build:dev": "tsc -b --watch", diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index b2fbac5e846..58628aaf169 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -18,8 +18,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index e2541e50de8..fe7da02af0b 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -14,8 +14,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/end-to-end/package.json b/yarn-project/end-to-end/package.json index 1e7e6a34e01..01e14a2ecb1 100644 --- a/yarn-project/end-to-end/package.json +++ b/yarn-project/end-to-end/package.json @@ -4,8 +4,6 @@ "type": "module", "exports": "./dest/index.js", "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/ethereum/package.json b/yarn-project/ethereum/package.json index 82a2402ad32..90e6f2ee7c1 100644 --- a/yarn-project/ethereum/package.json +++ b/yarn-project/ethereum/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 7441da40186..3e8e058f4be 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -35,8 +35,6 @@ "./committable": "./dest/committable/index.js" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/key-store/package.json b/yarn-project/key-store/package.json index e9b76370219..d43c019eef9 100644 --- a/yarn-project/key-store/package.json +++ b/yarn-project/key-store/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/l1-artifacts/package.json b/yarn-project/l1-artifacts/package.json index c1f000e2d95..57e271c6927 100644 --- a/yarn-project/l1-artifacts/package.json +++ b/yarn-project/l1-artifacts/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && yarn generate && tsc -b", "clean": "rm -rf ./dest ./generated .tsbuildinfo", "formatting": "run -T prettier --check ./generated && run -T eslint ./generated", diff --git a/yarn-project/merkle-tree/package.json b/yarn-project/merkle-tree/package.json index 163d6fc8dba..d551bb84868 100644 --- a/yarn-project/merkle-tree/package.json +++ b/yarn-project/merkle-tree/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/noir-compiler/package.json b/yarn-project/noir-compiler/package.json index 7ef409d0bb4..d9efa71dc52 100644 --- a/yarn-project/noir-compiler/package.json +++ b/yarn-project/noir-compiler/package.json @@ -17,8 +17,6 @@ "aztec-compile": "dest/cli.js" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/noir-contracts/package.json b/yarn-project/noir-contracts/package.json index b9d7e5eb3fb..0739cee5976 100644 --- a/yarn-project/noir-contracts/package.json +++ b/yarn-project/noir-contracts/package.json @@ -8,8 +8,6 @@ "./types": "./dest/types/index.js" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/p2p-bootstrap/package.json b/yarn-project/p2p-bootstrap/package.json index 89fc049dba2..646ba2c4abf 100644 --- a/yarn-project/p2p-bootstrap/package.json +++ b/yarn-project/p2p-bootstrap/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/p2p/package.json b/yarn-project/p2p/package.json index f3213003702..2b8e317e603 100644 --- a/yarn-project/p2p/package.json +++ b/yarn-project/p2p/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/package.common.json b/yarn-project/package.common.json index d6231d92f89..6b6f7471258 100644 --- a/yarn-project/package.common.json +++ b/yarn-project/package.common.json @@ -1,7 +1,5 @@ { "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/prover-client/package.json b/yarn-project/prover-client/package.json index fb946ce8d2b..40741c4cc3a 100644 --- a/yarn-project/prover-client/package.json +++ b/yarn-project/prover-client/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/rollup-provider/package.json b/yarn-project/rollup-provider/package.json index 84d68c96dc8..abb5e816970 100644 --- a/yarn-project/rollup-provider/package.json +++ b/yarn-project/rollup-provider/package.json @@ -12,8 +12,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index ab89bd8f455..1018b1e7959 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/types/package.json b/yarn-project/types/package.json index 6aaac90d5e8..78977f0c5f4 100644 --- a/yarn-project/types/package.json +++ b/yarn-project/types/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/world-state/package.json b/yarn-project/world-state/package.json index 36ae514d0ea..67d3c5a7f36 100644 --- a/yarn-project/world-state/package.json +++ b/yarn-project/world-state/package.json @@ -11,8 +11,6 @@ "tsconfig": "./tsconfig.json" }, "scripts": { - "prepare": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json", - "prepare:check": "node ../yarn-project-base/scripts/update_build_manifest.mjs package.json --check", "build": "yarn clean && tsc -b", "build:dev": "tsc -b --watch", "clean": "rm -rf ./dest .tsbuildinfo", diff --git a/yarn-project/yarn-project-base/scripts/update_build_manifest.mjs b/yarn-project/yarn-project-base/scripts/update_build_manifest.mjs deleted file mode 100644 index b915dd8733d..00000000000 --- a/yarn-project/yarn-project-base/scripts/update_build_manifest.mjs +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env node -// Updates build manifest for a package based on a package.json -import { existsSync, readFileSync, writeFileSync } from 'fs'; -import { basename, dirname, join, resolve } from 'path'; -import { cwd } from 'process'; - -// Update build_manifest.json with new dependencies -function updateBuildManifest(buildManifestFile, allDependencies, projectKey, options) { - // Check if build_manifest.json exists - if (!existsSync(buildManifestFile)) { - console.error(`Error: ${buildManifestFile} not found (cwd ${cwd()}).`); - process.exit(2); - } - - // Read build_manifest.json - const buildManifestData = JSON.parse(readFileSync(buildManifestFile, 'utf-8')); - - if (projectKey in buildManifestData) { - // Filter package names from dependencies that start with "@aztec/" - const aztecDependencies = Object.keys(allDependencies).filter(packageName => packageName.startsWith('@aztec/')); - - // Update the "dependencies" key in the corresponding section of the buildManifestData - // Take just the folder name component - // Filter out dependencies that are not themselves in the manifest: - const updatedDependencies = aztecDependencies - .map(packageName => packageName.split('/')[1]) - .filter(depProjectKey => !!buildManifestData[depProjectKey]); - - // If we are just checking, throw if dependencies don't match - if (options.checkOnly) { - const currentDependencies = buildManifestData[projectKey]['dependencies']; - if ( - updatedDependencies.length !== currentDependencies.length || - !updatedDependencies.reduce((ret, val, idx) => ret && val === currentDependencies[idx], true) - ) { - console.error( - `Dependencies for project ${projectKey} have changed and the build_manifest needs to be updated. Run yarn prepare on the yarn-project root.`, - `\n Current: ${JSON.stringify(currentDependencies)}`, - `\n Updated: ${JSON.stringify(updatedDependencies)}`, - ); - process.exit(10); - } - } - // Otherwise, update them - else { - buildManifestData[projectKey]['dependencies'] = updatedDependencies; - } - - // Write the updated data back to build_manifest.json - writeFileSync(buildManifestFile, JSON.stringify(buildManifestData, null, 2)); - } else { - console.error(`Error: '${projectKey}' not found in build_manifest.json`); - process.exit(3); - } -} - -// Entry point for the script -function main() { - try { - // Check if the path to the package.json file is provided as a command-line argument - if (process.argv.length === 2) { - console.error(`Usage: ${process.argv[0]} path/to/package.json`); - process.exit(1); - } - - const packageJsonFile = process.argv[2]; - - // Check if package.json exists - if (!existsSync(packageJsonFile)) { - console.error(`Error: ${packageJsonFile} not found.`); - process.exit(2); - } - - // Process options if any - const options = { checkOnly: false }; - for (const arg of process.argv.slice(3)) { - if (arg === '--check') { - options.checkOnly = true; - } else { - console.error(`Unknown option ${arg}`); - process.exit(3); - } - } - - // Read package.json - const packageData = JSON.parse(readFileSync(packageJsonFile, 'utf-8')); - - // Get the directory name of the directory that holds package.json - const projectKey = basename(dirname(resolve(packageJsonFile))); - - // Add the path to the build-manifest.json file - const buildManifestFile = join(dirname(packageJsonFile), '..', '..', 'build_manifest.json'); - - // Update build_manifest.json with the new dependencies - updateBuildManifest( - buildManifestFile, - { ...packageData.dependencies, ...packageData.devDependencies }, - projectKey, - options, - ); - } catch (err) { - console.error(`Failed updating ${resolve(process.argv[2])}`); - console.error(err); - } -} -main();