vscode-project-manager icon indicating copy to clipboard operation
vscode-project-manager copied to clipboard

[FEATURE] - Sync projects definitions via native Settings Sync feature

Open enoversum opened this issue 4 years ago • 29 comments

Hi @alefragnani , just a quick question, I may simply be mislead at some point. Does (local, not GIT) projects sync through the regular VS Code sync normally work?

So far, natively, your project manager saves the 'projects.json' in the user folder in the VS Code folder, and as far as I experienced, the regular settings sync (not the plugin/extension) done through the Microsoft account won't sync projects from one machine to another. I understand I can set "projectManager.projectsLocation" to accept a different place, and I did just that with a folder I sync through another service. Just wanting to know, is there something wrong on my end that VS Code doesn't want to sync projects by the normal MS sync?

enoversum avatar Nov 03 '20 14:11 enoversum

Hi @enoversum ,

I didn't play with Settings Sync yet, but as far as I remember from the release notes (while in Insiders release) and the official documentation (after landing on Stable), it seems session data are not synchronized. If that's the case then no, the projects.json won't be synchronized.

I also don't remember any API which extension authors could use, in order to add their own data to the syncing process. So, unless such API exists/appears, Settings Sync couldn't be used to sync your projects. At least, not today.

I wonder if it would worth to change how the extension itself works. I mean, instead of using an external file (project.json) to store user's projects, store them on User Settings directly. Personally, I'm not comfortable about touching (updating) user settings, but maybe that would be the case

Hope this helps

alefragnani avatar Nov 04 '20 01:11 alefragnani

Hi @alefragnani , thanks for getting back so quickly. I know little about how VS Code stores data and what kind of data there is. Most other extensions seem to write their settings into the big settings.json, or into files directly in the project folders (like SFTP settings). I am completely happy with the custom projects.json location setting you're offering. Since I sync my files for my projects anyway, I now have them synced as well. Of course, it would be easier for people to have it synced natively. But anyway, thanks for your extension, it works really beautifully. Especially the wildcard file watching is time-saving. I had been on Atom until recently, where you had to specify files directly to watch. Plus it was quite slower and had no native sync.

Thanks again :)!

enoversum avatar Nov 04 '20 09:11 enoversum

Hi @enoversum ,

First of all, thank you for your kind words. I'm glad to know you like the extension 😁

The extension's settings, just like other extensions, are stored in User Settings, but the projects are considered extension's data, so are stored elsewhere. Since the beginning my intention was to be able to sync it somehow (started with Dropbox, them moved to GitHub repo), so instead of using the extension's data sandbox (which VS Code provides for every extension), I decided to use this User folder, which is mostly a VS Code sandbox location and exits on every VS Code install.

I don't need (personally speaking) any sync feature anymore, but I'm interested on embracing the native Sync on the extension, if possible.

This is the first issue asking about the native Sync feature, but I guess a lot of users could take advantage of this. I'll take a better look on its documentation and open issues, to find out how this could be accomplished.

Hope this helps

alefragnani avatar Nov 04 '20 10:11 alefragnani

Hey @alefragnani ,

from what I gather, it's rather cumbersome to store projects in settings.json, that's for sure, so I hope - if you're as eager as I perceive :) - you'll find a working way to use the native sync functionality of VS Code. I kind of get what you're saying about the sandbox. One thing to keep in mind is that, while having the project list at hand, a user only benefits from synced projects if he somehow also syncs the actual project files and folders - so he has to have some kind of file syncing in place anyway, which could also incorporate the projects.json at a custom location. For starters, I'd probably edit the documentation and explain shortly that there is no official sync integration, but advise one could set "projectManager.projectsLocation" to where projects themselves are synced.

And don't see my question here as an 'issue' (even though it's listed here as such) - there is no rush, I was just kind of curious if I missed out on official sync capabilities for projects, but your extension works astonishingly well anyway :) !

enoversum avatar Nov 04 '20 10:11 enoversum

Hi @enoversum ,

I only found this issue, which maybe could work

Instead of saving the projects in projects.json, the extension should use extension's state. Doing so, this API would do the trick. The downside is, I guess it could be wiped out if you uninstall the extension, or when some VS Code upgrade occurs (I remember at least one release where this occurred).

Other than that, I see no way to accomplish your request.

And you are right, not only the projects.json should be synced but you should need have your projects location synchronised too, which in this case, is not handled by VS Code sync feature.

I'll let you know if I have any news

alefragnani avatar Nov 05 '20 21:11 alefragnani

Hey @alefragnani ,

don't you take this too seriously - I am happily syncing projects with a custom projects.json location now, right were the actual project files are, that way everything for me is working fine. If you're eager to find out if and how you can accomplish projects sync right inside VS Code, you're welcome, but don't see this as a task to be done with high priority for me :) !

Anyway, thanks for your commitment :)!

enoversum avatar Nov 05 '20 21:11 enoversum

Hi @enoversum ,

Not eager, just curious to know if it was doable, so I could give you proper feedback 😁.

Thank you

alefragnani avatar Nov 05 '20 21:11 alefragnani

@alefragnani Being eager and enthusiastic isn't that bad, you know 😄 ? Please do let me know in any case 😃 !

enoversum avatar Nov 05 '20 21:11 enoversum

My 2cent: I've synced settings & projects with https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync without any problem (you just have to add the projects.json to the sync manually).

Currently i also try to use the vscode core sync .. just to have less plugins installed. But yeah.. same problem here.. no projects sync.

thomasfrobieter avatar Nov 12 '20 06:11 thomasfrobieter

@thomasfrobieter ,

Thanks for your 2cents 👍

I decided to take a look at Settings Sync extension's documentation/issues, and it appears it does sync the VS Code internal files. That would explain why it does sync projects.json and other related files. You can even see, on its README, the possibility to ignore some files, and use this extension as an exemple.

alefragnani avatar Nov 12 '20 12:11 alefragnani

Sorry, I'm not entirely clear from the discussion, is there currently a way to have the native Settings Sync feature in VS Code sync the project list managed by the Project Manager extension?

I recently switched jobs (and therefore machines) and while all my settings in VS Code came over due to settings sync, I was a little surprised to see no projects listed under projects manager (not a huge deal, most of the projects were from my old job so would no longer be relevant anyway).

pzelnip avatar Jan 29 '21 18:01 pzelnip

Hi @pzelnip ,

No, there is no way, and as you already noticed, syncing the project list wouldn’t sync the projects itself 😁 .

It’s not possible because there is no API available in the Settings Sync feature to allow an extension to define additional files to be synced.

When you save a project, it is stored inside a file called projects.json. The Settings Sync feature does not monitor any file created by the extension, only settings and state. If they don’t provide a proper API, the only way to accomplish this would be to move the projects out of the projects.json file, to one of the locations mentioned above.

I found this issue https://github.com/microsoft/vscode/issues/113774, which asks a similar idea, but has no few upvotes, and I guess it will be closed/canceled soon.

Hope this helps

alefragnani avatar Jan 29 '21 23:01 alefragnani

I've created https://github.com/microsoft/vscode/issues/120142 to request the possibility to synchronize “additional resources”, because I didn't find an issue for that.

It was closed as a duplicate of https://github.com/microsoft/vscode/issues/113774, so I'll keep an eye on that.

alefragnani avatar Mar 30 '21 11:03 alefragnani

Just thought about it today, again, and two ideas came to mind:

  • Reconsider to use User Settings as storage, probably as an alternative for remote scenarios and/or Codespaces only.
    • The good: easier to do because it will use the same projects.json inside user settings
    • The bad: will be wasted when Settings Sync support is released (https://github.com/microsoft/vscode/issues/113774)
  • (Hack) Add a new field on each project in projects.json to tell the project should be synced. When true, I could use globalState.setKeysForSync to store the synced projects.
    • The good: can be ignored/removed when Settings Sync support is released (https://github.com/microsoft/vscode/issues/113774)
    • The bad: It’s a hack; The user wont be able to Edit Projects; It’s a hack 😬
  • Use GitHub Gist as storage, just like the older Settings Sync extension
    • The good: easy to do because can use other extensions as sample
    • The bad: Depends on user having GitHub account and GitHub authentication turned on in VS Code

alefragnani avatar Mar 31 '21 21:03 alefragnani

the older settings sync extension used a GitHub gist for storing the settings... you could potentially do that as well. Plus you can use the new Auth provider API so you don't have to deal with any of the auth details.

TylerLeonhardt avatar Apr 01 '21 20:04 TylerLeonhardt

That's true. I totally forgot.

Updated the comment above with some details about that.

Thanks

alefragnani avatar Apr 01 '21 21:04 alefragnani

The bad: Depends on user having GitHub account and GitHub authentication turned on in VS Code

To be fair, if they are already using in-box Settings Sync with their GitHub account, this isn't much of a problem. It'd only be a problem for folks who:

  1. Use the Microsoft auth for Settings Sync
  2. Don't use Settings Sync at all

In #2's case they either don't want sync (so they probably don't want this feature), or are doing something custom to sync their settings... to which they can probably apply that same process to pick up the projects.json file.

TylerLeonhardt avatar Apr 02 '21 20:04 TylerLeonhardt

Totally agree. But remember these scenarios are just workarounds, until proper Settings Sync API is released 😉

Following the Gist approach is probably the safest bet. The original Settings Sync extension works this way, and it is a huge success.

Let’s go to learn a new API 🏃

alefragnani avatar Apr 02 '21 23:04 alefragnani

@TylerLeonhardt ,

Finally could play a little with the Authentication API and octokit, and wow! Really simple to use. I think the approaches below could be fairly easy to use, on a users perspective

The simplest way

Step 1. The user toggles a setting to say "Use GitHub Gists to store your projects", and that's it.

The extension will take care of creating a new secret gist with a yet to be defined name (something like VSCode - Project Manager Extension - Projects), and store a projects.json file there

The complex way

Step 1. The user toggles a setting to say "Use GitHub Gists to store your projects"
Step 2. The user defines the name of the Gist to be used

The extension will take care of creating a new secret gist with the name provided by the user (if not available yet) and store a projects.json file there.

This scenario is useful if the user would like to share the projects between Stable and Insiders release, just like the projectsLocation setting that already exists today

Because I can use Authentication API, there is no need to use Token, Gist ID or something more complex (like Settings Sync apparently still uses).

What do you think?

alefragnani avatar Jun 25 '21 04:06 alefragnani

Personally I think they are stepping stones. You could start with the simple solution until someone comes along and says "I wanna change the name" and then offer a setting to change the name.

TylerLeonhardt avatar Jun 25 '21 05:06 TylerLeonhardt

That's great! I didn't have to use this kind of integration yet, so it's good to know the steps I thought are ok.

Right after posting that, I thought about a third option. Instead of creating a new setting to define the Gist name, why not reuse the projectsLocation setting, and allow a gist scheme, like gist:theGistNameYouWant.

Let's hold this to upcoming releases, as you said 😄

Thank you

alefragnani avatar Jun 25 '21 13:06 alefragnani

The bad: will be wasted when Settings Sync support is released (Allow syncing custom user files like emmet snippets microsoft/vscode#113774)

It doesn't look like this will get implemented any time soon. I don't see a downside of keeping settings among User settings, the setting itself is also quite small. However, for the best benefit extension should support environment variables in path specification so that it could work cross platform.

The absence of this feature is most troubling for me. I work on several different machines all the time and keeping projects in sync is pain.

majkinetor avatar Jan 18 '22 15:01 majkinetor

I have a similar feeling, that’s why I created #525, and plan to add this for upcoming releases.

About environment variables, you can use ˜ or $home as alternatives to your home folder. But, if you have more complex scenarios, maybe you have the same request as #550 .

Hope this helps

alefragnani avatar Jan 18 '22 16:01 alefragnani

OK, gist is an option too, whatever really, just let them sync. Its IMO better to move settings to user ones as with gist, you need more lengthy ceremony on each machine, but its more important that it works somehow.

˜ or $home as alternatives to your home folder

One env var is not much better then 0, particularly if somebody else dictates where projects are stored on particular system. For example on Windows it might be c:/Projects and on Linux /projects and env var $PROJECTS_ROOT could be set appropriately for sync just to work.

majkinetor avatar Jan 18 '22 16:01 majkinetor

For example on Windows it might be c:/Projects and on Linux /projects and env var $PROJECTS_ROOT could be set appropriately for sync just to work.

You don’t need an env var for that. Simply add all folders in settings and it will recognize the projects on each machine, independently.

OK, gist is an option too, whatever really, just let them sync

It is VS Code which provides (and will be responsible for) syncing, not this extension. Creating manual sync via Gist is just a workaround for a missing API. Otherwise, I suggest you to take a look at the Settings Sync extension (https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync ), which this native Settings Sync provided by VS Code is trying to replace. This extension has been created years ago and already syncs projects.json file automatically. I never used, but read a lot about it.

It seems you are disappointed with the Settings Sync feature provided natively by VS Code (if you compare to the Settings Sync extension created years ago), so I suggest you to upvote/comment on that issue, so they are able to see not only extension developers, but also users complaining by the missing API.

alefragnani avatar Jan 18 '22 17:01 alefragnani

You don’t need an env var for that. Simply add all folders in settings and it will recognize the projects on each machine, independently.

OK, that is alternative solution which does require repeating entire config on each environment instead of creating single env var.

I suggest you to take a look at the Settings Sync extension

I was using it before, but integrated sync is much better IMO and more controllable. It worked OK with projects.

It seems you are disappointed with the Settings Sync feature provided natively by VS Code

Ofc I did upvote on original ticket and added a comment to pin it up for those that sort by updated date :) However, the ticket exists for more then a year and has only 10 upvotes (30 are required for it to be considered. I doubt that will happen soon.

majkinetor avatar Jan 18 '22 17:01 majkinetor

What is the reason against moving project.json to User settings ? Maybe it could be an option and default could be compatible with current settings ? :)

majkinetor avatar Jan 18 '22 17:01 majkinetor

Historically speaking, there are some details here: https://github.com/alefragnani/vscode-project-manager/issues/431#issuecomment-721639197

About the sync feature, it has its pros and cons, as you can see here: https://github.com/alefragnani/vscode-project-manager/issues/431#issuecomment-811485275

alefragnani avatar Jan 18 '22 19:01 alefragnani

great****

lahcenassmira avatar Feb 12 '22 16:02 lahcenassmira

I suggest my issue microsoft/vscode#113774 mentioned several times here be referenced in the first post inciting people to upvote it. It currently has 20 upvotes and miraculously escaped from their bot killing issue which have not enough attention.

What I did to sync those kind of settings was using the old sync settings extension. Now I consider to move files not synchronized by the built-in settings sync to a folder in my onedrive if all my extensions allow to.

Fred-Vatin avatar Nov 23 '22 04:11 Fred-Vatin