@@ -8,8 +8,8 @@ import { askForLanguage, isFolderAlreadyInWorkspace } from "./helpers";
88import { getErrorMessage } from "./pure/helpers-pure" ;
99import { QlPackGenerator } from "./qlpack-generator" ;
1010import { DatabaseItem , DatabaseManager } from "./local-databases" ;
11- import * as databaseFetcher from "./databaseFetcher" ;
1211import { ProgressCallback , UserCancellationException } from "./progress" ;
12+ import { askForGitHubRepo , downloadGitHubDatabase } from "./databaseFetcher" ;
1313
1414type QueryLanguagesToDatabaseMap = Record < string , string > ;
1515
@@ -69,7 +69,14 @@ export class SkeletonQueryWizard {
6969 }
7070
7171 // open a query file
72- await this . openExampleFile ( ) ;
72+
73+ try {
74+ await this . openExampleFile ( ) ;
75+ } catch ( e : unknown ) {
76+ void this . extLogger . log (
77+ `Could not open example query file: ${ getErrorMessage ( e ) } ` ,
78+ ) ;
79+ }
7380 }
7481
7582 private async openExampleFile ( ) {
@@ -81,15 +88,9 @@ export class SkeletonQueryWizard {
8188 join ( this . qlPackStoragePath , this . folderName , this . fileName ) ,
8289 ) ;
8390
84- try {
85- void workspace . openTextDocument ( queryFileUri ) . then ( ( doc ) => {
86- void Window . showTextDocument ( doc ) ;
87- } ) ;
88- } catch ( e : unknown ) {
89- void this . extLogger . log (
90- `Could not open example query file: ${ getErrorMessage ( e ) } ` ,
91- ) ;
92- }
91+ void workspace . openTextDocument ( queryFileUri ) . then ( ( doc ) => {
92+ void Window . showTextDocument ( doc ) ;
93+ } ) ;
9394 }
9495
9596 public getFirstStoragePath ( ) {
@@ -117,7 +118,7 @@ export class SkeletonQueryWizard {
117118 this . progress ( {
118119 message : "Choose language" ,
119120 step : 1 ,
120- maxStep : 1 ,
121+ maxStep : 3 ,
121122 } ) ;
122123
123124 return await askForLanguage ( this . cliServer , false ) ;
@@ -131,7 +132,7 @@ export class SkeletonQueryWizard {
131132 this . progress ( {
132133 message : "Creating skeleton QL pack around query" ,
133134 step : 2 ,
134- maxStep : 2 ,
135+ maxStep : 3 ,
135136 } ) ;
136137
137138 try {
@@ -159,7 +160,7 @@ export class SkeletonQueryWizard {
159160 message :
160161 "Skeleton query pack already exists. Creating additional query example file." ,
161162 step : 2 ,
162- maxStep : 2 ,
163+ maxStep : 3 ,
163164 } ) ;
164165
165166 try {
@@ -181,21 +182,21 @@ export class SkeletonQueryWizard {
181182
182183 private async determineNextFileName ( folderName : string ) : Promise < string > {
183184 if ( this . qlPackStoragePath === undefined ) {
184- throw new Error ( "Workspace storage path is undefined" ) ;
185+ throw new Error ( "QL Pack storage path is undefined" ) ;
185186 }
186187
187188 const folderUri = Uri . file ( join ( this . qlPackStoragePath , folderName ) ) ;
188189 const files = await workspace . fs . readDirectory ( folderUri ) ;
189190 const qlFiles = files . filter ( ( [ filename , _fileType ] ) =>
190- filename . match ( / e x a m p l e [ 0 - 9 ] * .q l / ) ,
191+ filename . match ( / ^ e x a m p l e [ 0 - 9 ] * \ .q l $ / ) ,
191192 ) ;
192193
193194 return `example${ qlFiles . length + 1 } .ql` ;
194195 }
195196
196197 private async downloadDatabase ( ) {
197198 if ( this . qlPackStoragePath === undefined ) {
198- throw new Error ( "Workspace storage path is undefined" ) ;
199+ throw new Error ( "QL Pack storage path is undefined" ) ;
199200 }
200201
201202 if ( this . databaseStoragePath === undefined ) {
@@ -213,16 +214,13 @@ export class SkeletonQueryWizard {
213214 } ) ;
214215
215216 const githubRepoNwo = QUERY_LANGUAGE_TO_DATABASE_REPO [ this . language ] ;
216- const chosenRepo = await databaseFetcher . askForGitHubRepo (
217- undefined ,
218- githubRepoNwo ,
219- ) ;
217+ const chosenRepo = await askForGitHubRepo ( undefined , githubRepoNwo ) ;
220218
221219 if ( ! chosenRepo ) {
222220 throw new UserCancellationException ( "No GitHub repository provided" ) ;
223221 }
224222
225- await databaseFetcher . downloadGitHubDatabase (
223+ await downloadGitHubDatabase (
226224 chosenRepo ,
227225 this . databaseManager ,
228226 this . databaseStoragePath ,
@@ -240,7 +238,7 @@ export class SkeletonQueryWizard {
240238 }
241239
242240 if ( this . qlPackStoragePath === undefined ) {
243- throw new Error ( "Workspace storage path is undefined" ) ;
241+ throw new Error ( "QL Pack storage path is undefined" ) ;
244242 }
245243
246244 const databaseNwo = QUERY_LANGUAGE_TO_DATABASE_REPO [ this . language ] ;
0 commit comments