-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache versions of extension into global settings
This is kind of a hack. I'm not sure why the extension walkthrough isn't opening when it first installs, but whatever we need to do this to ensure that walkthrough runs, because it's not running when users first download the extension (could be perhaps that we've already installed it so global settings is aware of it, idk but whatever) Adding a global config for `vscode-aiconfig.version`, and also changed the activate settings to activate upon vscode startup. This is fine because we moved the initialize step outside of here so there's no negative consequences of activating it. Will implement the actual functionality next PRs ## Test Plan Ok I don't know why I can't test directly bvy running the activation command, but instead I just hooked this up to the 'Set API Keys" command and ran it lol https://github.com/lastmile-ai/aiconfig/assets/151060367/449e599a-4ed7-457f-9543-7e7895337ebe
- Loading branch information
1 parent
7775a9c
commit 6f20d75
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export const PYTHON_INTERPRETER_CACHE_KEY_NAME = "pythonInterpreter"; | ||
|
||
// Used for prompting user to reload VS Code window on update, and ensuring | ||
// that walkthrough gets shown on first install | ||
export const VERSION_KEY_NAME = "version"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Utils file for handling actions to perform whenever user | ||
* installs or updates the extension. | ||
* VS Code automatically checks for version updates | ||
* (https://code.visualstudio.com/docs/editor/extension-marketplace#_extension-autoupdate) | ||
* but I haven't been able to find a way to use this to trigger any | ||
* actions. Also even though the Walkthrough documentation says | ||
* that this gets triggered on first install, I haven't been able | ||
* to trigger this either, so I am calling this manually | ||
* https://code.visualstudio.com/api/references/contribution-points#contributes.walkthroughs | ||
*/ | ||
|
||
import * as vscode from "vscode"; | ||
|
||
import { EXTENSION_NAME } from "../util"; | ||
import { VERSION_KEY_NAME } from "../constants"; | ||
|
||
export async function performVersionInstallAndUpdateActionsIfNeeded( | ||
context: vscode.ExtensionContext | ||
) { | ||
const extension = vscode.extensions.getExtension(context.extension.id); | ||
const currExtensionVersion = extension?.packageJSON.version; | ||
const config = vscode.workspace.getConfiguration(EXTENSION_NAME); | ||
const lastActivatedVersion = config.get<string>(VERSION_KEY_NAME); | ||
if (currExtensionVersion !== lastActivatedVersion) { | ||
await config.update( | ||
VERSION_KEY_NAME, | ||
currExtensionVersion, | ||
vscode.ConfigurationTarget.Global | ||
); | ||
} | ||
|
||
if (lastActivatedVersion === undefined || lastActivatedVersion === "") { | ||
// First time activating extension, show walkthrough | ||
// Will implement next PR | ||
// vscode.commands.executeCommand("workbench.action.openWalkthrough"); | ||
} else if ( | ||
currExtensionVersion > lastActivatedVersion | ||
// TODO: Add check for if version string follows format of %d.%d.%d | ||
) { | ||
// Extension has been updated, prompt user to refresh VS Code window | ||
// Will implement next PR | ||
} | ||
} |