From c15b8919ca55deebd0f7e19d677a77badf6d9207 Mon Sep 17 00:00:00 2001 From: Levi Yan Date: Tue, 6 May 2025 23:00:03 +0800 Subject: [PATCH] feat: two new global state variable( localSystemName, localSSHConfigPath) used to support first connect in remote environment --- src/main.ts | 6 +++++- src/utils.ts | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 3b2fc72..3ce35b4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -85,7 +85,11 @@ export class DevStarExtension { this.registerGlobalCommands(context); if (vscode.env.remoteName === undefined) { - // 如果处于local,且localSystemName未存储,则存储 + // 本地环境,存储localSystemName, localSSHConfigPath,以备远程环境使用 + const localSSHConfigPath = utils.getLocalSSHConfigPath(context) + if (localSSHConfigPath === undefined || localSSHConfigPath === "") { + utils.updateLocalSSHConfigPath(context) + } const localSystemName = utils.getLocalSystemName(context) if (localSystemName === undefined || localSystemName === "") { utils.updateLocalSystemName(context) diff --git a/src/utils.ts b/src/utils.ts index effa0ee..0b6693f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,6 +3,7 @@ import * as https from 'https'; import * as vscode from 'vscode'; import * as os from 'os'; import { exec } from 'child_process'; +import * as path from 'path'; const { generateKeyPairSync, @@ -125,4 +126,12 @@ export function updateLocalSystemName(context: vscode.ExtensionContext) { export function getLocalSystemName(context: vscode.ExtensionContext): string | undefined { return context.globalState.get('localSystemName') +} + +export function updateLocalSSHConfigPath(context: vscode.ExtensionContext) { + context.globalState.update('localSSHConfigPath', path.join(os.homedir(), '.ssh', 'config')) +} + +export function getLocalSSHConfigPath(context: vscode.ExtensionContext): undefined | string{ + return context.globalState.get('localSSHConfigPath') } \ No newline at end of file