Skip to content

Commit 26c0769

Browse files
committed
chore: refactor implementation
1 parent 0e898e0 commit 26c0769

File tree

10 files changed

+206
-254
lines changed

10 files changed

+206
-254
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,15 +1065,15 @@
10651065
"@types/mocha": "^10.0.6",
10661066
"@types/node": "20.4.1",
10671067
"@types/util.promisify": "^1.0.8",
1068-
"@types/vscode": "^1.84.2",
1068+
"@types/vscode": "^1.85.0",
10691069
"@typescript-eslint/eslint-plugin": "^6.13.2",
10701070
"@typescript-eslint/parser": "^6.13.2",
10711071
"@vscode/test-electron": "^2.3.8",
10721072
"changelogen": "^0.5.5",
10731073
"eslint": "^8.55.0",
10741074
"nuxi-edge": "3.9.1-1697113884.a6acb6a",
10751075
"taze": "^0.11.4",
1076-
"terser": "^5.25.0",
1076+
"terser": "^5.26.0",
10771077
"tsup": "^7.3.0",
10781078
"typescript": "^5.3.3"
10791079
},

pnpm-lock.yaml

Lines changed: 70 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
import * as vscode from "vscode"
22
import { detectPackageManagerByName } from "../utils"
33
import pm from "../content/pm"
4-
import { newTerminal, getInstallationCommand, runCommand } from "../utils"
4+
import { newTerminal } from "../utils";
55

66

7-
let currentRequest: any // Store the current request promise
8-
let timeout: NodeJS.Timeout | undefined // Store the timeout reference
9-
10-
const github: vscode.QuickInputButton = {
11-
iconPath: new vscode.ThemeIcon("nuxtr-github"),
12-
tooltip: "Github",
13-
}
14-
15-
const npm: vscode.QuickInputButton = {
16-
iconPath: new vscode.ThemeIcon("nuxtr-npm"),
17-
tooltip: "NPM Page",
18-
}
19-
20-
const installDependencies = () => {
7+
export const installDependencies = () => {
218
const packageManager = detectPackageManagerByName()
229

2310
const items: vscode.QuickPickItem[] = pm.map((item) => {
@@ -49,51 +36,4 @@ const installDependencies = () => {
4936
}
5037
newTerminal("Install Dependencies", packageManager.installCommand)
5138
}
52-
}
53-
54-
function showSearchResults(
55-
results: any[],
56-
quickPick: vscode.QuickPick<vscode.QuickPickItem>
57-
) {
58-
const resultItems = results.map((result) => {
59-
const item: vscode.QuickPickItem & { package: any } = {
60-
label: result.package.name,
61-
description: result.package.description,
62-
package: result.package,
63-
}
64-
65-
item.buttons = [github, npm]
66-
67-
return item
68-
})
69-
70-
quickPick.items = resultItems
71-
72-
quickPick.onDidTriggerItemButton(async (e) => {
73-
const selectedItem = e.item as vscode.QuickPickItem & { package: any }
74-
75-
if (e.button === github) {
76-
vscode.env.openExternal(selectedItem.package.links.repository)
77-
}
78-
79-
if (e.button === npm) {
80-
vscode.env.openExternal(selectedItem.package.links.npm)
81-
}
82-
})
83-
84-
quickPick.onDidChangeSelection(async (item: any) => {
85-
quickPick.dispose()
86-
87-
let chosenPackage = item[0]
88-
const command = await getInstallationCommand(chosenPackage.label, true)
89-
90-
await runCommand({
91-
command,
92-
message: `Installing ${chosenPackage.label}...`,
93-
successMessage: `${chosenPackage.label} installed successfully`,
94-
errorMessage: `${chosenPackage.label} installation failed`,
95-
})
96-
})
97-
}
98-
99-
export { installDependencies }
39+
}

0 commit comments

Comments
 (0)