@@ -274,58 +274,14 @@ export async function activate(
274274 // Checking the vscode version should not block extension activation.
275275 void assertVSCodeVersionGreaterThan ( MIN_VERSION , ctx ) ;
276276
277- async function getDistributionDisplayingDistributionWarnings ( ) : Promise < FindDistributionResult > {
278- const result = await distributionManager . getDistribution ( ) ;
279- switch ( result . kind ) {
280- case FindDistributionResultKind . CompatibleDistribution :
281- void extLogger . log (
282- `Found compatible version of CodeQL CLI (version ${ result . version . raw } )` ,
283- ) ;
284- break ;
285- case FindDistributionResultKind . IncompatibleDistribution : {
286- const fixGuidanceMessage = ( ( ) => {
287- switch ( result . distribution . kind ) {
288- case DistributionKind . ExtensionManaged :
289- return 'Please update the CodeQL CLI by running the "CodeQL: Check for CLI Updates" command.' ;
290- case DistributionKind . CustomPathConfig :
291- return `Please update the \"CodeQL CLI Executable Path\" setting to point to a CLI in the version range ${ codeQlVersionRange } .` ;
292- case DistributionKind . PathEnvironmentVariable :
293- return (
294- `Please update the CodeQL CLI on your PATH to a version compatible with ${ codeQlVersionRange } , or ` +
295- `set the \"CodeQL CLI Executable Path\" setting to the path of a CLI version compatible with ${ codeQlVersionRange } .`
296- ) ;
297- }
298- } ) ( ) ;
299-
300- void showAndLogWarningMessage (
301- `The current version of the CodeQL CLI (${ result . version . raw } ) ` +
302- `is incompatible with this extension. ${ fixGuidanceMessage } ` ,
303- ) ;
304- break ;
305- }
306- case FindDistributionResultKind . UnknownCompatibilityDistribution :
307- void showAndLogWarningMessage (
308- "Compatibility with the configured CodeQL CLI could not be determined. " +
309- "You may experience problems using the extension." ,
310- ) ;
311- break ;
312- case FindDistributionResultKind . NoDistribution :
313- void showAndLogErrorMessage ( "The CodeQL CLI could not be found." ) ;
314- break ;
315- default :
316- assertNever ( result ) ;
317- }
318- return result ;
319- }
320-
321277 async function installOrUpdateThenTryActivate (
322278 config : DistributionUpdateConfig ,
323279 ) : Promise < CodeQLExtensionInterface | Record < string , never > > {
324280 await installOrUpdateDistribution ( ctx , distributionManager , config ) ;
325281
326282 // Display the warnings even if the extension has already activated.
327283 const distributionResult =
328- await getDistributionDisplayingDistributionWarnings ( ) ;
284+ await getDistributionDisplayingDistributionWarnings ( distributionManager ) ;
329285 let extensionInterface : CodeQLExtensionInterface | Record < string , never > =
330286 { } ;
331287 if (
@@ -531,6 +487,52 @@ async function installOrUpdateDistribution(
531487 }
532488}
533489
490+ async function getDistributionDisplayingDistributionWarnings (
491+ distributionManager : DistributionManager ,
492+ ) : Promise < FindDistributionResult > {
493+ const result = await distributionManager . getDistribution ( ) ;
494+ switch ( result . kind ) {
495+ case FindDistributionResultKind . CompatibleDistribution :
496+ void extLogger . log (
497+ `Found compatible version of CodeQL CLI (version ${ result . version . raw } )` ,
498+ ) ;
499+ break ;
500+ case FindDistributionResultKind . IncompatibleDistribution : {
501+ const fixGuidanceMessage = ( ( ) => {
502+ switch ( result . distribution . kind ) {
503+ case DistributionKind . ExtensionManaged :
504+ return 'Please update the CodeQL CLI by running the "CodeQL: Check for CLI Updates" command.' ;
505+ case DistributionKind . CustomPathConfig :
506+ return `Please update the \"CodeQL CLI Executable Path\" setting to point to a CLI in the version range ${ codeQlVersionRange } .` ;
507+ case DistributionKind . PathEnvironmentVariable :
508+ return (
509+ `Please update the CodeQL CLI on your PATH to a version compatible with ${ codeQlVersionRange } , or ` +
510+ `set the \"CodeQL CLI Executable Path\" setting to the path of a CLI version compatible with ${ codeQlVersionRange } .`
511+ ) ;
512+ }
513+ } ) ( ) ;
514+
515+ void showAndLogWarningMessage (
516+ `The current version of the CodeQL CLI (${ result . version . raw } ) ` +
517+ `is incompatible with this extension. ${ fixGuidanceMessage } ` ,
518+ ) ;
519+ break ;
520+ }
521+ case FindDistributionResultKind . UnknownCompatibilityDistribution :
522+ void showAndLogWarningMessage (
523+ "Compatibility with the configured CodeQL CLI could not be determined. " +
524+ "You may experience problems using the extension." ,
525+ ) ;
526+ break ;
527+ case FindDistributionResultKind . NoDistribution :
528+ void showAndLogErrorMessage ( "The CodeQL CLI could not be found." ) ;
529+ break ;
530+ default :
531+ assertNever ( result ) ;
532+ }
533+ return result ;
534+ }
535+
534536const PACK_GLOBS = [
535537 "**/codeql-pack.yml" ,
536538 "**/qlpack.yml" ,
0 commit comments