diff --git a/README.md b/README.md index e0a9745b..03d83eef 100644 --- a/README.md +++ b/README.md @@ -120,12 +120,14 @@ yarn flow # launch flow yarn test # launch unit tests ``` -### Programmaically reset hard the app - -Stop the app and to clean accounts, settings, etc, run +### Programmatically reset app files ```bash -rm -rf ~/Library/Application\ Support/Electron/ +# clear the dev electron user data directory +# it remove sqlite db, accounts, settings +# useful to start from a fresh state + +yarn reset-files ``` ## File structure diff --git a/package.json b/package.json index afa5a012..c41bca4b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "release": "bash ./scripts/release.sh", "start": "bash ./scripts/start.sh", "storybook": "NODE_ENV=development STORYBOOK_ENV=1 start-storybook -s ./static -p 4444", - "trans": "node scripts/trans" + "reset-files": "bash ./scripts/reset-files.sh" }, "electronWebpack": { "title": true, diff --git a/scripts/reset-files.sh b/scripts/reset-files.sh new file mode 100644 index 00000000..11820bc7 --- /dev/null +++ b/scripts/reset-files.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +echo "> Getting user data folder..." + +TMP_FILE=`mktemp` +cat < $TMP_FILE +const { app } = require('electron') +console.log(app.getPath('userData')) +EOF +USER_DATA_FOLDER=`timeout --preserve-status 0.5 electron $TMP_FILE || echo` # echo used to ensure status 0 +rm $TMP_FILE + +read -p "> Remove folder \"$USER_DATA_FOLDER\"? (y/n) " -n 1 -r +echo +if [[ $REPLY == "y" ]] +then + rm -rf "$USER_DATA_FOLDER" +else + echo "> Nothing done. Bye" +fi