From 31362839705039dfce59eecd22b0e54aa02e4e73 Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Wed, 19 Jul 2023 16:06:45 +0800 Subject: [PATCH] Update DevChat dependency check and configuration update - Added version check for DevChat in checkDevChatDependency function. - Updated configuration in both Global and Workspace scopes. - Commented out the initial DevChat check in install.py and added --force flag to pip install command. --- src/contributes/commandsBase.ts | 8 +++++++- src/util/uiUtil_vscode.ts | 1 + tools/install.py | 26 +++++++++++++------------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/contributes/commandsBase.ts b/src/contributes/commandsBase.ts index a41db38..6500daf 100644 --- a/src/contributes/commandsBase.ts +++ b/src/contributes/commandsBase.ts @@ -31,7 +31,13 @@ export function checkDevChatDependency(pythonCommand: string, showError: boolean try { // Check if DevChat is installed - runCommand(`"${devChat}" --help`); + const expectVersion = 'DevChat 0.1.15'; + const devchatVersion = runCommand(`"${devChat}" --version`).toString().trim(); + if (devchatVersion < expectVersion) { + logger.channel()?.info("devchat version: ${devchatVersion}, but expect version: ${expectVersion}"); + return false; + } + logger.channel()?.info("devchat has installed.") return true; } catch(error) { diff --git a/src/util/uiUtil_vscode.ts b/src/util/uiUtil_vscode.ts index 92f5819..41fcf52 100644 --- a/src/util/uiUtil_vscode.ts +++ b/src/util/uiUtil_vscode.ts @@ -20,6 +20,7 @@ export class UiUtilVscode implements UiUtil { public async updateConfiguration(key1: string, key2: string, value: string): Promise { await vscode.workspace.getConfiguration(key1).update(key2, value, vscode.ConfigurationTarget.Global); + await vscode.workspace.getConfiguration(key1).update(key2, value, vscode.ConfigurationTarget.Workspace); } public async secretStorageGet(key: string): Promise { try { diff --git a/tools/install.py b/tools/install.py index aa16245..f75d363 100644 --- a/tools/install.py +++ b/tools/install.py @@ -89,23 +89,23 @@ def pip_install_devchat(pythoncmd): # if not, install devchat # first step: check if devchat is installed - try: - # before command run, output runnning command - print("run command: ", pythoncmd, "-m", "pip", "show", "devchat") - subprocess.run([pythoncmd, "-m", "pip", "show", "devchat"], check=True, stdout=sys.stdout, stderr=sys.stderr, text=True) + # try: + # # before command run, output runnning command + # print("run command: ", pythoncmd, "-m", "pip", "show", "devchat") + # subprocess.run([pythoncmd, "-m", "pip", "show", "devchat"], check=True, stdout=sys.stdout, stderr=sys.stderr, text=True) - pipCommandEnv = pythoncmd.replace("/python", "/devchat") - print("==> devchatCommandEnv: ", pipCommandEnv) + # pipCommandEnv = pythoncmd.replace("/python", "/devchat") + # print("==> devchatCommandEnv: ", pipCommandEnv) - return True - except Exception as error: - # devchat is not installed - print('devchat is not installed') - print(error) - pass + # return True + # except Exception as error: + # # devchat is not installed + # print('devchat is not installed') + # print(error) + # pass # second step: install devchat - if (pip_cmd_with_retries([pythoncmd, "-m", "pip", "install", "devchat"], 3, False)): + if (pip_cmd_with_retries([pythoncmd, "-m", "pip", "install", "devchat", "--force"], 3, False)): pip_command_env = pythoncmd.replace("/python", "/devchat") print("==> devchatCommandEnv: ", pip_command_env) return True