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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VSCode settings and extensions backup/reinstall, pip3 backup. #205

Merged
merged 22 commits into from
Jan 7, 2019
Merged

Added VSCode settings and extensions backup/reinstall, pip3 backup. #205

merged 22 commits into from
Jan 7, 2019

Conversation

AlexanderProd
Copy link
Contributor

This should fix #45 on macOS and Linux. I haven't tested it but it should work. 馃槃

Copy link
Owner

@alichtman alichtman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, thank you for the PR. This would be a great feature to have.


I haven't tested it but it should work.

For your own software development knowledge, it's horribly bad practice to put anything untested on master. Knowing that bugs slip through even when code is tested (you've even found some yourself) should hammer home the importance of testing everything before it goes on master, even if it's just a "simple" 6 line change.


Regardless, on to the code review.

Your solution should work, functionally. It's kind of like what I did with Sublime, but that was a quick and dirty fix. I'm not happy with my solution, and I don't really want to back up other IDEs in the same manner. I don't see a reason to back up the caches or <INSERT NON-CONFIGURATION FILE HERE>. The end goal is to have a minimum set of files to recreate the user's configuration at the end of a reinstall.

It's not as simple as just backing up the parent VSCode folder and calling it a day. (Sorry for not being more specific in #45.) We really only want to back up a list of the extensions that were installed, their settings, and the VSCode settings. From that, we can likely reconstruct the VSCode installation exactly as the user had it.

One way to approach this could be: Generate a list of the installed extensions instead of backing up the whole folder, and see if there is a tool to reinstall them. (Or see if you can interface with VSCode itself to reinstall them?) This should go in the packages backup section. Separately, we want to back up the VSCode settings and keymappings. Those can be found here: /Users/alichtman/Library/Application Support/Code/User/{settings.json | keymap.json}. From what I can tell, everything else in the Code directory is essentially trash.

Does this make sense?

@@ -47,7 +47,8 @@ def get_default_config():
],
"dotfolders" : [
".ssh",
".vim"
".vim",
".vscode"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This folder doesn't actually hold any configuration files and doesn't really belong in this section, imo.

On my machine, it stores the downloaded extensions, and I'm not sure we should be backing up the actual source code for the extensions when we should be able to reinstall them.

See comment on PR for more details.

Note: I'm not thrilled with the Sublime backup solution I have at the moment. It backs up a ton of dead weight, and I don't want to establish that as the status quo. The initial goal of this project was to compress the backup size as much as possible. We should only back up the settings and extensions for VSCode / Sublime / Atom / etc.

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Dec 22, 2018

Yeah you're totally right that I've tested it before submitting but my local Python environment isn't working and I given the small changes I wanted to put out the PR still. Yeah my bad. I've actually just replicated the backup process how you did it wit Sublime Text not knowing that this was just a quick and dirty fix that you didn't want to use anymore.

But I understand that you only want to backup as little as possible. I know there's a VSCode Extension out there that does practically the same, we can look how they did the extension backup and built it in similarly.

@alichtman
Copy link
Owner

alichtman commented Dec 22, 2018

my local Python environment isn't working

I've had these issues before. I understand your pain. :(


That VSCode Backup extension will definitely be helpful when putting this feature together. I glanced at it and noticed it was written in TypeScript. I'm hesitant to add it as a pseudo-dependency (installing it from within shallow-backup and using it from there), although that's definitely the least work. I'd much rather implement the functionality natively to minimize external dependencies and keep everything together in one package.

I'd look at how it creates the backup (both in terms of which files are important and how the backup is structured) and how they reinstallation process works. After you get a sense for that, we can talk about how it best fits into shallow-backup, or you can just give implementing it a shot and we'll go from there.

@alichtman
Copy link
Owner

@AlexanderProd any update on this PR?

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 2, 2019 via email

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 5, 2019

@alichtman Do I have to create a completely new backup when I added new paths in compatibility.py? Because I wanted to test my local changes but the new config paths weren't included in the backup.

Also I've noticed that Atom packages are still being backuped completely not just a reference to them, is this wanted behavior or subject to change?

@alichtman
Copy link
Owner

alichtman commented Jan 5, 2019

Do I have to create a completely new backup when I added new paths in compatibility.py?

No, just the config file needs to be updated.

Also I've noticed that Atom packages are still being backuped completely not just a reference to them, is this wanted behavior or subject to change?

This is not the wanted behavior. We just want package settings and general settings. I'll open an issue to make sure this isn't missed. (#210)

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 5, 2019

@alichtman

This is not the wanted behavior. We just want package settings and general settings.

I guess the only thing missing is settings of individual packages, since we're already creating a list of all atom packages right?

EDIT: got it working.

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 5, 2019

This PR contains VSCode config backup, Extensions aren't being backuped.
Also because only the required configs are being backuped the code for the paths got a little bit ugly.

vscode_path_1 = os.path.join(get_home(), "Library/Application Support/Code/User/settings.json")
vscode_path_2 = os.path.join(get_home(), "Library/Application Support/Code/User/Snippets")
vscode_path_3 = os.path.join(get_home(), "Library/Application Support/Code/User/keybindings.json")

If we want to backup extensions settings we probably have to backup the whole extensions folder since every extensions handles settings differently.

@alichtman
Copy link
Owner

I'll do a code review on this later tonight and see if we can get it in soon!

@alichtman
Copy link
Owner

Let's make the vscode backup all within a directory in the configs folder. I'm not a huge fan of leaving it like this:

image

It should look like this:

image

Additionally, some thought should be given about how to reinstall these. Do we want to throw that functionality into this PR?

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 5, 2019 via email

@alichtman
Copy link
Owner

I鈥榙 make a separate PR for restoring the backup.

Sounds good. Let's open an issue to make sure it doesn't get lost in the mix.

@alichtman alichtman mentioned this pull request Jan 5, 2019
@AlexanderProd
Copy link
Contributor Author

Configs are now saved into a dedicated folder.

@alichtman
Copy link
Owner

alichtman commented Jan 5, 2019

It worked without having to create it explicitly? Awesome.

Same changes need to be made to the macOS configs.

@AlexanderProd
Copy link
Contributor Author

Yeah tested on MacOS and it worked, can't test in on Linux but I assume it would work as well.

@alichtman
Copy link
Owner

alichtman commented Jan 5, 2019

Just tested. Approved.

Note: This does not backup the extensions, and it should. Let's sort that out before I merge this in.

Nice work, @AlexanderProd

Copy link
Owner

@alichtman alichtman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to back up extensions as well.

@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 5, 2019 via email

Repository owner deleted a comment Jan 6, 2019
Repository owner deleted a comment Jan 6, 2019
@AlexanderProd
Copy link
Contributor Author

AlexanderProd commented Jan 6, 2019

I've added simple list style backup for VSCode extensions.
It creates a .txt file inside of the packages folder that looks like this.

dbaeumer.vscode-eslint@1.7.2
file-icons.file-icons@1.0.16
icrawl.discord-vscode@3.2.1
kodetech.electron-debug@18.11.0
ms-python.python@2018.12.1
ms-vscode.atom-keybindings@3.0.4
msjsdiag.debugger-for-chrome@4.11.1
robinbentley.sass-indented@1.5.1
Shan.code-settings-sync@3.2.4
vsmobile.vscode-react-native@0.7.0
zhuangtongfa.Material-theme@2.18.1

I've also quickly included the pip3 fix. #211

Copy link
Owner

@alichtman alichtman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we automate vscode reinstallation? That's the last thing I want to explore.

EDIT: Yes, we can. Run through the list of extensions saved and run code --install-extension <extension_id>. Should be pretty easy to implement.

Everything else looks good here (although we do lose VSCode Extension settings, but we can open a separate issue for that if you don't want to figure that out in this PR.)

@AlexanderProd
Copy link
Contributor Author

VScode Extensions reinstallation is working now.

Repository owner deleted a comment Jan 7, 2019
@alichtman
Copy link
Owner

Awesome. Looks good to me. Will merge next time I'm on a laptop.

@alichtman alichtman changed the title Added VSCode settings and extension backup. Added VSCode settings and extensions backup/reinstall, pip3 backup. Jan 7, 2019
@alichtman alichtman merged commit b907c83 into alichtman:master Jan 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode Backup
2 participants