Script to fix submodules (#2018)

### Description

I keep finding myself running a few commands in sequence because of the
submodules so I figured it was about time to turn it into a script to
make things easier for us.

### Drive-by changes

None

### Related issues

### Backward compatibility

_Are these changes backward compatible?_

Yes

_Are there any infrastructure implications, e.g. changes that would
prohibit deploying older commits using this infra tooling?_

None


### Testing

_What kind of testing have these changes undergone?_

Manual
pull/2190/head
Mattie Conover 2 years ago committed by GitHub
parent 355b5ed44e
commit 95d8fdd330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      package.json
  2. 33
      scripts/sync-submodules.sh

@ -17,6 +17,7 @@
"scripts": {
"build": "yarn workspaces foreach --verbose --parallel --topological run build",
"clean": "yarn workspaces foreach --verbose --parallel run clean",
"sync-submodules": "./scripts/sync-submodules.sh",
"postinstall": "husky install",
"prettier": "yarn workspaces foreach --verbose --parallel run prettier",
"lint-ts": "eslint . --ext .ts",

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# This is designed to synchronize the typescript submodules in the current state with the committed
# submodule version and then clean and build the typescript codebase. This will not update the
# submodules, only bring them to the same version as they are in `.gitmodules`.
set -e
DIRNAME=$(basename "$PWD")
if [[ "$DIRNAME" != "hyperlane-monorepo" ]]; then
echo "Must be run from the root of the monorepo"
exit 1
fi
DIRS=$(git submodule status | grep -oE "typescript/[a-zA-Z0-9_-]+")
for DIR in $DIRS ; do
echo "Removing '$DIR'"
rm -rf "$DIR"
done
git submodule init
git submodule update
for DIR in $DIRS ; do
echo "Cleaning '$DIR'"
pushd "$DIR" || continue
rm -rf yarn.lock node_modules
popd || exit 1
done
yarn clean
yarn install
yarn build
Loading…
Cancel
Save