diff --git a/package.json b/package.json index d9b1194cf4..7d724ea675 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/packages/realm-server/package.json b/packages/realm-server/package.json index bacef6864f..b5d5c1d8e2 100644 --- a/packages/realm-server/package.json +++ b/packages/realm-server/package.json @@ -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" diff --git a/packages/realm-server/scripts/full-reset.sh b/packages/realm-server/scripts/full-reset.sh deleted file mode 100755 index 6814639bcb..0000000000 --- a/packages/realm-server/scripts/full-reset.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -CURRENT_DIR="$(pwd)" -SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd)" - -cd ${SCRIPTS_DIR}/../../postgres -pnpm run drop-db boxel -pnpm run drop-db boxel_test -pnpm run drop-db boxel_base - -# clearing the DB means that we also lose all the info we have on the realm -# owners of the dynamic realms, which means that we should eliminate these as -# well. -rm -rf "${SCRIPTS_DIR}/../realms" - -# also now you will have users that have realm associations to realms that don't -# exist anymore, so we should clear the matrix state so it can be in sync with -# the DB state -cd "${SCRIPTS_DIR}/../../matrix" -pnpm stop:synapse -rm -rf ./synapse-data -pnpm start:synapse -pnpm register-all - -cd "${CURRENT_DIR}" - -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/']}) -" diff --git a/scripts/full-reset.sh b/scripts/full-reset.sh new file mode 100755 index 0000000000..6d4435945b --- /dev/null +++ b/scripts/full-reset.sh @@ -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