@@ -16,16 +16,16 @@ export async function importFromRegistry(scope?: vscode.ConfigurationScope) {
16
16
regQueryCache . clear ( ) ;
17
17
18
18
return vscode . window . withProgress ( {
19
- "location" : vscode . ProgressLocation . Notification ,
20
- "cancellable" : true
19
+ cancellable : true ,
20
+ location : vscode . ProgressLocation . Notification ,
21
21
} , async ( progress , cancellationToken ) => {
22
22
progress . report ( { message : "Loading server definitions from Windows registry..." } ) ;
23
23
cancellationToken . onCancellationRequested ( ( ) => {
24
24
vscode . window . showInformationMessage ( "Cancelled server import." ) ;
25
25
} ) ;
26
26
27
27
// This forces the progress bar to actually show before the possibly long-running load of registry data
28
- await new Promise ( resolve => setTimeout ( resolve , 0 ) ) ;
28
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 0 ) ) ;
29
29
30
30
overwriteCount = await loadRegistryData ( config , serverDefinitions , serversMissingUsernames , newServerNames ) ;
31
31
@@ -37,9 +37,9 @@ export async function importFromRegistry(scope?: vscode.ConfigurationScope) {
37
37
if ( ! keepGoing ) {
38
38
return ;
39
39
}
40
-
40
+
41
41
if ( overwriteCount > 0 ) {
42
- if ( await vscode . window . showWarningMessage ( `${ overwriteCount } existing definition${ overwriteCount > 1 ? "s" : "" } will be overwritten. Continue?` , { modal : true } , "Yes" ) !== "Yes" ) {
42
+ if ( await vscode . window . showWarningMessage ( `${ overwriteCount } existing definition${ overwriteCount > 1 ? "s" : "" } will be overwritten. Continue?` , { modal : true } , "Yes" ) !== "Yes" ) {
43
43
vscode . window . showInformationMessage ( "Cancelled server import." ) ;
44
44
return ;
45
45
}
@@ -62,7 +62,12 @@ export async function importFromRegistry(scope?: vscode.ConfigurationScope) {
62
62
} ) ;
63
63
}
64
64
65
- async function loadRegistryData ( config : vscode . WorkspaceConfiguration , serverDefinitions , serversMissingUsernames : string [ ] , newServerNames : string [ ] ) : Promise < number > {
65
+ async function loadRegistryData (
66
+ config : vscode . WorkspaceConfiguration ,
67
+ serverDefinitions ,
68
+ serversMissingUsernames : string [ ] ,
69
+ newServerNames : string [ ] ,
70
+ ) : Promise < number > {
66
71
const cmd = require ( "node-cmd" ) ;
67
72
const subFolder = "\\Intersystems\\Cache\\Servers" ;
68
73
const fullPaths : string [ ] = [ ] ;
@@ -85,14 +90,14 @@ async function loadRegistryData(config: vscode.WorkspaceConfiguration, serverDef
85
90
return ;
86
91
}
87
92
// For WOW6432Node, skip the line for the subfolder itself
88
- if ( ( serverName . split ( subFolder ) . pop ( ) ?? "" ) . length === 0 ) {
93
+ if ( ( serverName . split ( subFolder ) . pop ( ) ?? "" ) . length === 0 ) {
89
94
return ;
90
95
}
91
96
92
97
// remove HKEY_LOCAL_MACHINE\ and whitespace from the server name
93
98
const path = serverName . substring ( hive . length + 1 ) . trim ( ) ;
94
99
95
- const originalName : string = ( serverName . split ( "\\" ) . pop ( ) ?? "" ) . trim ( ) ;
100
+ const originalName : string = ( serverName . split ( "\\" ) . pop ( ) ?? "" ) . trim ( ) ;
96
101
// Enforce the rules from package.json on the server name
97
102
const name = originalName . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 - _ ~ ] / g, "~" ) ;
98
103
if ( name === "" ) {
@@ -126,13 +131,12 @@ async function loadRegistryData(config: vscode.WorkspaceConfiguration, serverDef
126
131
username,
127
132
webServer : {
128
133
host : getProperty ( "WebServerAddress" ) || getProperty ( "Address" ) ,
129
- pathPrefix : instanceName ? '/' + instanceName : undefined ,
134
+ pathPrefix : instanceName ? "/" + instanceName : undefined ,
130
135
port : parseInt ( getProperty ( "WebServerPort" ) || "" , 10 ) ,
131
136
scheme : usesHttps ? "https" : "http" ,
132
137
} ,
133
- }
134
- }
135
- else if ( ! name . startsWith ( "/" ) ) {
138
+ } ;
139
+ } else if ( ! name . startsWith ( "/" ) ) {
136
140
if ( ! existingUserNames . includes ( name ) ) {
137
141
existingUserNames . push ( name ) ;
138
142
overwriteCount ++ ;
@@ -145,7 +149,7 @@ async function loadRegistryData(config: vscode.WorkspaceConfiguration, serverDef
145
149
146
150
async function promptForUsernames ( serverDefinitions : any , serversMissingUsernames : string [ ] ) : Promise < boolean > {
147
151
if ( serversMissingUsernames . length ) {
148
- let serverName = serversMissingUsernames . splice ( 0 , 1 ) [ 0 ] ;
152
+ let serverName = serversMissingUsernames . splice ( 0 , 1 ) [ 0 ] ;
149
153
let username = await vscode . window . showInputBox ( {
150
154
ignoreFocusOut : true ,
151
155
placeHolder : "Enter a username. Leave empty to be prompted at connect time." ,
@@ -155,7 +159,7 @@ async function promptForUsernames(serverDefinitions: any, serversMissingUsername
155
159
// Was cancelled
156
160
return false ;
157
161
}
158
- if ( username === '' ) {
162
+ if ( username === "" ) {
159
163
// If unspecified, actually set to undefined to leave it empty in serverDefinitions
160
164
username = undefined ;
161
165
}
@@ -171,7 +175,7 @@ async function promptForUsernames(serverDefinitions: any, serversMissingUsername
171
175
const result = await vscode . window . showQuickPick ( items , {
172
176
canPickMany : false ,
173
177
ignoreFocusOut : true ,
174
- placeHolder : `${ serversMissingUsernames . length } more servers lack a username. What do you want to do?`
178
+ placeHolder : `${ serversMissingUsernames . length } more servers lack a username. What do you want to do?` ,
175
179
} ) ;
176
180
if ( result === undefined || result . label === items [ 2 ] . label ) {
177
181
return false ;
@@ -202,10 +206,10 @@ async function promptForUsernames(serverDefinitions: any, serversMissingUsername
202
206
203
207
async function promptForPasswords ( serverDefinitions : any , newServerNames : string [ ] ) : Promise < void > {
204
208
let reusePassword ;
205
- let password : string | undefined = '' ;
209
+ let password : string | undefined = "" ;
206
210
const promptServerNames = new Array ( ) ;
207
211
// Only prompt for servers with a username specified, of course.
208
- newServerNames . forEach ( name => {
212
+ newServerNames . forEach ( ( name ) => {
209
213
if ( serverDefinitions [ name ] . username !== undefined ) {
210
214
promptServerNames . push ( name ) ;
211
215
}
@@ -217,20 +221,20 @@ async function promptForPasswords(serverDefinitions: any, newServerNames: string
217
221
password : true ,
218
222
placeHolder : "Enter password to store in keychain. Leave empty to be prompted at connect time." ,
219
223
prompt : `Password for connection to InterSystems server '${ serverName } '
220
- as ${ serverDefinitions [ serverName ] . username } `
224
+ as ${ serverDefinitions [ serverName ] . username } ` ,
221
225
} ) ;
222
226
223
227
if ( password === undefined ) {
224
228
return ;
225
229
}
226
230
227
- if ( password === '' ) {
231
+ if ( password === "" ) {
228
232
password = undefined ;
229
233
}
230
234
}
231
235
232
236
if ( ( reusePassword === undefined ) && ( promptServerNames . length > 1 ) ) {
233
- const placeHolder = ( password === undefined ) ? `Enter password later for remaining ${ promptServerNames . length - 1 } server(s)?` : `Store the same password for remaining ${ promptServerNames . length - 1 } server(s)?`
237
+ const placeHolder = ( password === undefined ) ? `Enter password later for remaining ${ promptServerNames . length - 1 } server(s)?` : `Store the same password for remaining ${ promptServerNames . length - 1 } server(s)?` ;
234
238
const items = [
235
239
`No` ,
236
240
`Yes` ,
@@ -240,7 +244,7 @@ async function promptForPasswords(serverDefinitions: any, newServerNames: string
240
244
const result = await vscode . window . showQuickPick ( items , {
241
245
canPickMany : false ,
242
246
ignoreFocusOut : true ,
243
- placeHolder
247
+ placeHolder,
244
248
} ) ;
245
249
if ( result === undefined || result . label === items [ 2 ] . label ) {
246
250
return ;
@@ -261,10 +265,10 @@ function preloadRegistryCache(cmd, fullPath) {
261
265
if ( ! regData . data ) {
262
266
return ;
263
267
}
264
- regData . data . split ( "\r\n\r\n" ) . forEach ( pathResult => {
268
+ regData . data . split ( "\r\n\r\n" ) . forEach ( ( pathResult ) => {
265
269
// Equivalent of running "reg query " + queryPath
266
270
const lines = pathResult . split ( "\r\n" ) ;
267
- const queryPath = lines . splice ( 0 , 1 ) [ 0 ] ;
271
+ const queryPath = lines . splice ( 0 , 1 ) [ 0 ] ;
268
272
const queryResult = lines . join ( "\r\n" ) ;
269
273
regQueryCache . set ( queryPath , { data : queryResult } ) ;
270
274
} ) ;
@@ -279,14 +283,14 @@ function getStringRegKey(cmd, hive, path, key): string | undefined {
279
283
regQueryCache . set ( queryPath , regData ) ;
280
284
const results = regData . data . split ( "\r\n" )
281
285
// Result lines from reg query are 4-space-delimited
282
- . map ( line => line . split ( ' ' ) )
286
+ . map ( ( line ) => line . split ( " " ) )
283
287
// Registry has format [<empty>, key, type, value]
284
- . filter ( line => line . length === 4 )
288
+ . filter ( ( line ) => line . length === 4 )
285
289
// We're only interested in the specified key
286
- . filter ( line => line [ 1 ] === key )
290
+ . filter ( ( line ) => line [ 1 ] === key )
287
291
// We want the value...
288
- . map ( line => line [ 3 ] )
292
+ . map ( ( line ) => line [ 3 ] )
289
293
// ... and we'll treat empty strings as undefined
290
- . filter ( result => result != '' ) ;
294
+ . filter ( ( result ) => result !== "" ) ;
291
295
return results [ 0 ] ;
292
296
}
0 commit comments