Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error-handling to full reset script #1779

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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