11import * as vscode from "vscode"
22import { detectPackageManagerByName } from "../utils"
33import 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