Skip to content

Commit

Permalink
Merge pull request #1779 from cardstack/realm/full-reset-cs-7500
Browse files Browse the repository at this point in the history
Add error-handling to full reset script
  • Loading branch information
habdelra authored Nov 15, 2024
2 parents 3c07142 + 8aae4b5 commit be3e93c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"deploy:boxel-motion:preview-staging": "cd packages/boxel-motion/addon && pnpm build && cd ../test-app && pnpm exec ember deploy s3-preview-staging --verbose",
"deploy:boxel-ui": "pnpm run build-common-deps && cd packages/boxel-ui/test-app && pnpm exec ember deploy",
"deploy:boxel-ui:preview-staging": "pnpm run build-common-deps && cd packages/boxel-ui/test-app && pnpm exec ember deploy s3-preview-staging --verbose",
"full-reset": "./scripts/full-reset.sh",
"lint": "pnpm run --filter './packages/**' --if-present -r lint",
"lint:fix": "pnpm run --filter './packages/**' --if-present -r lint:fix"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/realm-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:glint": "glint",
"full-reset": "./scripts/full-reset.sh"
"full-reset": "echo 'This script has moved to the root package.json'"
},
"volta": {
"extends": "../../package.json"
Expand Down
30 changes: 0 additions & 30 deletions packages/realm-server/scripts/full-reset.sh

This file was deleted.

46 changes: 46 additions & 0 deletions scripts/full-reset.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#! /bin/sh
CURRENT_DIR="$(pwd)"
SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)"

errors=()

run_command() {
"$@"
if [ $? -ne 0 ]; then
errors+=("Failed: $*")
fi
}

cd ${SCRIPTS_DIR}/../packages/postgres || errors+=("Failed: changing to postgres directory")
run_command pnpm run drop-db boxel
run_command pnpm run drop-db boxel_test
run_command pnpm run drop-db boxel_base

if ! rm -rf "${SCRIPTS_DIR}/../packages/realm-server/realms"; then
errors+=("Failed: removing realms directory")
fi

cd "${SCRIPTS_DIR}/../packages/matrix" || errors+=("Failed: changing to matrix directory")

run_command pnpm stop:synapse

if ! rm -rf ./synapse-data; then
errors+=("Failed: removing synapse-data")
fi

run_command pnpm start:synapse
run_command pnpm register-all

echo "
WARNING: Any matrix server authorization tokens cached in the browser's localstorage are now invalid. Make sure to clear browser localstorage. Also make sure to execute the following in the browser after logging in as 'user' to add the experiments realm:
window['@cardstack/host'].lookup('service:matrix-service')._client.setAccountData('com.cardstack.boxel.realms', {realms: ['http://localhost:4201/experiments/']})
"

if [ ${#errors[@]} -ne 0 ]; then
echo "\n\033[1;31mThe following errors occurred during execution:\033[0m"
printf '\033[1;31m%s\033[0m\n' "${errors[@]}"
exit 1
else
echo "\nAll operations completed successfully."
fi

0 comments on commit be3e93c

Please sign in to comment.