Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Where is Power Tools: Tools configuration saved? #10

Open
rubensa opened this issue Dec 21, 2022 · 5 comments
Open

Where is Power Tools: Tools configuration saved? #10

rubensa opened this issue Dec 21, 2022 · 5 comments

Comments

@rubensa
Copy link

rubensa commented Dec 21, 2022

I just created a new TCP proxy but I can't find where the configuration is saved.

I tried to find the config for the newly created proxy under .vscode/settings.json and ~/.config/Code/User/settings.json but no luck.

@mkloubert
Copy link
Collaborator

@rubensa

The extension uses the Memento API of the ExtensionContext:

public static loadList(extension: vscode.ExtensionContext): ego_contracts.TcpProxyListItem[] {

To find out, where the storage path might be on your own system, you can create a button, which shows the path in a new info window at the right bottom corner of VSCode:

exports.execute = async (args) => {
    // args => https://egomobile.github.io/vscode-powertools/api/interfaces/_contracts_.buttonactionscriptarguments.html

    // s. https://code.visualstudio.com/api/references/vscode-api
    const vscode = args.require('vscode');

    // args.extension => https://code.visualstudio.com/api/references/vscode-api#ExtensionContext
    vscode.window.showInformationMessage(
        "globalStatePath: " + args.extension.globalStoragePath
    );
};

On a Mac, this could be someting like: /Users/<USERNAME>/Library/Application Support/Code/User/globalStorage/egomobile.vscode-powertools

@rubensa
Copy link
Author

rubensa commented Dec 22, 2022

Hello @mkloubert
Thanks for the answer.
So... the tools config works differently from than the rest that can be configured by settings.xml
Can't this be "unified" so any configuration goes to settings.xml and allow config per user or workspace?

@rubensa
Copy link
Author

rubensa commented Dec 22, 2022

@mkloubert
Curious but, in my case, the reported path does not exists.

I'm using VSCode Dev Conteainer so my workspace is running inside a Docker container.
When I click the button I get globalStatePath: /home/user/.vscode-server/data/User/globalStorage/egomobile.vscode-powertools
/home/user is the $HOME of the user used under the Docker container and /home/user/.vscode-server/data/User/globalStorage/ exists but it does not contain a egomobile.vscode-powertools folder (despite I have a TCP proxy configured).

How this might be possible?

NOTE: Just in case I checked if /home/user/.vscode-server/data/User/globalStorage/egomobile.vscode-powertools existed in the host computer, but there is no such folder, and also checked in the host the path /home/rubensa/.config/Code/User/globalStorage/ (/home/rubensa is my $HOME in the host) but there is no egomobile.vscode-powertools folder there.

@rubensa
Copy link
Author

rubensa commented Dec 22, 2022

Ouch!! I think that I finally found where the data is persisted... and is a pain cause it can't be easily configured/modified.

Looking at the docs it appears that the extension.globalStoragePath (now deprecated and replaced by globalStorageUri) directory does not exists. It must be created by the extension if it needs it. It is supposed to be a "safe" place for the extension to save configuration (but must be done "manually").
Whatever you save using extension.globalState.update(key, value) (that is what proxies.ts is doing) is saved in a sqlite database file in ~/.config/Code/User/globalStorage/state.vscdb

Screenshot from 2022-12-22 08-14-35

@rubensa
Copy link
Author

rubensa commented Dec 22, 2022

Definitely it would be great if this configuration could be saved in settings.xml (like the rest of configurations for the extension).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants