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

[vscode] support globalStoragePath #6354

Merged
merged 1 commit into from
Oct 10, 2019
Merged

Conversation

svenefftinge
Copy link
Contributor

What it does

Added globalStoragePath to the ExtensionContext object.

How to test

Install an extension that accesses this property (e.g. git graph).

Review checklist

Reminder for reviewers

@AlexTugarev
Copy link
Contributor

Screen Shot 2019-10-09 at 16 14 13

@svenefftinge how did you get the git graph extension working?

@svenefftinge
Copy link
Contributor Author

I did not. Webviews are not really supported by theia atm.

@AlexTugarev
Copy link
Contributor

I see so the check is to see if any error is logged related to this.

@AlexTugarev
Copy link
Contributor

checked with current master.

the extension fails to activate because getPathFromStr(context.globalStoragePath) fails with this stacktrace:

root ERROR [hosted-plugin: 7093] Error on activation of git-graph TypeError: Cannot read property 'replace' of undefined
    at Object.getPathFromStr (/tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/utils.js:26:16)
    at new ExtensionState (/tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/extensionState.js:24:42)
    at /tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/extension.js:28:32
    at Generator.next (<anonymous>)
    at /tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/extension.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/extension.js:4:12)
    at activate (/tmp/vscode-unpacked/git-graph-1.17.0.vsix/extension/out/extension.js:25:12)
    at PluginManagerExtImpl.<anonymous> (/workspace/theia/packages/plugin-ext/lib/plugin/plugin-manager.js:429:87)
    at step (/workspace/theia/packages/plugin-ext/lib/plugin/plugin-manager.js:47:23)

}
return globalStorage;
}
const globalStoragePath = join(configStorage.hostGlobalStoragePath || (await defaultGlobalStorage()), plugin.model.id);
Copy link
Contributor

Choose a reason for hiding this comment

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

e.g.~/.theia/globalStorage/mhutchie.git-graph
I think this fine now, thanks!

@@ -266,6 +268,18 @@ export class PluginManagerExtImpl implements PluginManagerExt, PluginManager {
const asAbsolutePath = (relativePath: string): string => join(plugin.pluginFolder, relativePath);
const logPath = join(configStorage.hostLogPath, plugin.model.id); // todo check format
const storagePath = join(configStorage.hostStoragePath || '', plugin.model.id);
async function defaultGlobalStorage(): Promise<string> {
const homeTheia = join(os.homedir(), '.theia');
if (!(await fs.pathExists(homeTheia))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

there is a short cut for this in fs-extra: fs.ensureDir(join(os.homedir(), '.theia', 'globalStorage'))

Copy link
Contributor

@AlexTugarev AlexTugarev left a comment

Choose a reason for hiding this comment

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

Works nicely! 👍

ensureDir if you like

Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
@svenefftinge svenefftinge merged commit 4a1ab3d into master Oct 10, 2019
@svenefftinge svenefftinge deleted the se/globalStoragePath branch October 10, 2019 13:30
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.

2 participants