Skip to content

Commit

Permalink
feat: delete project will delete remote-ssh remotePlatform config item
Browse files Browse the repository at this point in the history
  • Loading branch information
mlhiter committed Nov 14, 2024
1 parent 482a5de commit e4d3879
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,33 @@ class ProjectTreeDataProvider
}
}

GlobalStateManager.remove(deletedHost)
// TODO:抽象出一个 crud ssh 文件的模型
try {
// 1. remove global state
GlobalStateManager.remove(deletedHost)

// 2. remove remote-ssh config
const existingSSHHostPlatforms = vscode.workspace
.getConfiguration('remote.SSH')
.get<{ [host: string]: string }>('remotePlatform', {})
const newSSHHostPlatforms = Object.keys(existingSSHHostPlatforms).reduce(
(acc: { [host: string]: string }, host: string) => {
if (host.startsWith(deletedHost)) {
return acc
}
acc[host] = existingSSHHostPlatforms[host]
return acc
},
{}
)
await vscode.workspace
.getConfiguration('remote.SSH')
.update(
'remotePlatform',
newSSHHostPlatforms,
vscode.ConfigurationTarget.Global
)

// 3. remove ssh config
const content = await fs.promises.readFile(
defaultDevboxSSHConfigPath,
'utf8'
Expand Down

0 comments on commit e4d3879

Please sign in to comment.