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

projects.json is not created in a code-insiders only environment #22

Closed
satokaz opened this issue Apr 7, 2016 · 18 comments
Closed

projects.json is not created in a code-insiders only environment #22

satokaz opened this issue Apr 7, 2016 · 18 comments
Assignees
Labels
bug depends on Depends on issues from VS Code
Milestone

Comments

@satokaz
Copy link
Contributor

satokaz commented Apr 7, 2016

projects.json is dependent on the PATH of the vscode stable.

vscode stable:
$HOME/Library/Application Support/Code/User/

vscode-insiders
$HOME/Library/Application Support/Code - Insiders/

projectFile is hardcoded to "Code/User/projects.json".
"$HOME/Library/Application Support/Code/" directory is not create to be to launch the vscode-stable.
need to support to insiders build.

https://github.com/alefragnani/vscode-project-manager/blob/master/extension.ts#L18-L19

It does not come to mind a little good idea...

Mac OS X 10.11.3

@satokaz
Copy link
Contributor Author

satokaz commented Apr 8, 2016

Just idea.
It is a way to switch to add a projectManager.useInsiders setting item.

"projectManager.useInsiders": true

Windows and Linux is also not possible to confirm whether the same behavior. But I believe that's the same.

diff --git a/extension.ts b/extension.ts
index 38faa42..04d06d1 100644
--- a/extension.ts
+++ b/extension.ts
@@ -12,17 +12,23 @@ export function activate() {
     // Use the console to output diagnostic information (console.log) and errors (console.error)
     // This line of code will only be executed once when your extension is activated
     console.log('Congratulations, your extension "project-manager" is now active!');
-
-    //
-    let projectFile: string;
-    let appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : '/var/local');
-    projectFile = path.join(appdata, "Code/User/projects.json");
-
-    // in linux, it may not work with /var/local, then try to use /home/myuser/.config
-    if ((process.platform == 'linux') && (!fs.existsSync(projectFile))) {
-        let os = require('os');
-        projectFile = path.join(os.homedir(), '.config/Code/User/projects.json');
-    }
+
+    //
+    let projectFile: string;
+    let appdata = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : '/var/local');
+    // ProjectFil path
+    let useInsiders = vscode.workspace.getConfiguration('projectManager').get('useInsiders', false);
+    if (useInsiders == false) {
+        projectFile = path.join(appdata, "Code/User/projects.json");
+    } else {
+        projectFile = path.join(appdata, "Code - Insiders/User/projects.json");
+    }
+
+    // in linux, it may not work with /var/local, then try to use /home/myuser/.config
+    if ((process.platform == 'linux') && (!fs.existsSync(projectFile))) {
+        let os = require('os');
+        projectFile = path.join(os.homedir(), '.config/Code/User/projects.json');
+    }

     // Save the Projects
     vscode.commands.registerCommand('projectManager.saveProject', () => {
diff --git a/package.json b/package.json
index 4ec044a..e65caa0 100644
--- a/package.json
+++ b/package.json
@@ -69,6 +69,11 @@
                                        "type": "boolean",
                                        "default": false,
                                        "description": "Should use the alternative approach in Mac OS X?"
+                               },
+                               "projectManager.useInsiders": {
+                                       "type": "boolean",
+                                       "default": false,
+                                       "description": "Should use the alternative approach in Code - Insiders?"
                                }
                        }
                },

@alefragnani
Copy link
Owner

Hi @satokaz

I noted that last week when running on a machine that only had the Insider version installed. I will try to find a way to detect the release kind, otherwise I could use your idea 👍

Thanks

@alefragnani alefragnani added the bug label Apr 8, 2016
@alefragnani alefragnani self-assigned this Apr 8, 2016
@alefragnani alefragnani added this to the 0.6.0 milestone Apr 16, 2016
@bbak
Copy link

bbak commented Apr 18, 2016

Same here on Win 10 (of course). Changing extension.js:16 to projectFile = path.join(appdata, "Code - Insiders/User/projects.json"); resolves the issue.

@alefragnani
Copy link
Owner

Yep, it has the same issue no matter the platform.

I created this issue microsoft/vscode#5297 and will be using the proposed solution, until a native API is available.

I hope an update to be available in a couple of days

@alefragnani alefragnani modified the milestones: 0.7.0, 0.6.0 May 15, 2016
@alefragnani alefragnani removed this from the 0.7.0 milestone May 27, 2016
@alefragnani alefragnani added the depends on Depends on issues from VS Code label Jul 11, 2016
@texastoland
Copy link

Tracked in microsoft/vscode#2741.

@kumarharsh
Copy link

@alefragnani until the proposed fix in vscode lands, can the solution proposed here be implemented? It's really irritating that I can't use PM until vscode team implements that API (which I think is still some way off in the future).

Right now, I'm manually changing the extension.js file to fix it, but after every update it breaks. I'd also be happy to re-submit a PR if it's ok with you.

@texastoland
Copy link

All I had to do was create the non Insiders directory to work around.

@alefragnani
Copy link
Owner

@kumarharsh @texastoland

I was expecting the new API to be released back in April, but since then, they evolved the idea and postponed the final release. I agree with you that's irritating to be forced to patch the extension, or create the non Insiders folder 👍 .

But don't worry. I will release a workaround until the weekend and fix this.

The idea is to create a new user setting called projectManager.projectsLocation to define the subfolder where the projects.json file is located. So for those that patched the extension to use Code - Insiders, or those that want to keep different projects for Stable and Insiders version, just define Code - Insiders/User/ in the Insiders install and it will work. And for those that want to share the projects between Stable and Insiders version, just use Code/User/ and it will also work.

Maybe, just maybe 😄 , also use the $HOME variable idea and let you to decide the entire path where the projects.json file is located, so you could easily sync. I will see how it goes.

Hope this finally solves this issue 👍

@alefragnani alefragnani added this to the 0.9.0 milestone Jul 28, 2016
@alefragnani
Copy link
Owner

Better yet,

The new user setting will be the full folder path (not _subfolder) where projects.json will be stored. So, you may define any folder.

If you don't config anything, it will detect which channel you are and use the appropriate folder.

So, for those of you that patched the extension, you don't have to do anything. And those of you that created the \Code\User\ folder, just define the user setting.

Stay tunned

@kumarharsh
Copy link

@texastoland not everyone is going to create the missing folders - especially when it serves no other purpose apart from being a hack to get this plugin to work. Hacks are prone to breaking, and only people who have actually taken time to read into the source-code of this plugin would even know that. Most people might thing that "eh, it doesn't work, its broken" and never use the plugin again.

@texastoland
Copy link

I misread his proposal.

@alefragnani
Copy link
Owner

That's right.

There will be no need to manually create folders. Each VSCode channel (Stable and Insider) has its own $APPDATA folder, and right from the beginning, the extension should know that and store the projects.json in the appropriate folder. But since I had both installed right from the beginning, I didn't note this. My bad.

So, with the new release, each VSCode channel will have it's own projects.json file, so, if you only have the Insider version, your projects.json file will be in $APPDATA\Code - Insiders\Code.

And with the new setting, if you want to share the projects between Stable and Insider versions, just choose the path.

Is that ok?

@texastoland
Copy link

texastoland commented Jul 29, 2016

Sounds good. My misunderstanding wasn't about creating a folder but it just working without configuration. Sounds intuitive!

@alefragnani
Copy link
Owner

Great 👍

@texastoland
Copy link

WFM 👏

@satokaz
Copy link
Contributor Author

satokaz commented Jul 30, 2016

@alefragnani

Thanks! 🎉

@kumarharsh
Copy link

Sweet!

@alefragnani
Copy link
Owner

Great! Glad to see it worked for all of you 👍

Thanks for your patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug depends on Depends on issues from VS Code
Projects
None yet
Development

No branches or pull requests

5 participants