@@ -70,6 +70,8 @@ import {
7070} from './commandRunner' ;
7171import { CodeQlStatusBarHandler } from './status-bar' ;
7272
73+ import { Credentials } from './authentication' ;
74+
7375/**
7476 * extension.ts
7577 * ------------
@@ -148,7 +150,7 @@ export interface CodeQLExtensionInterface {
148150 *
149151 * @returns CodeQLExtensionInterface
150152 */
151- export async function activate ( ctx : ExtensionContext ) : Promise < CodeQLExtensionInterface | { } > {
153+ export async function activate ( ctx : ExtensionContext ) : Promise < CodeQLExtensionInterface | Record < string , never > > {
152154 void logger . log ( `Starting ${ extensionId } extension` ) ;
153155 if ( extension === undefined ) {
154156 throw new Error ( `Can't find extension ${ extensionId } ` ) ;
@@ -298,13 +300,13 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
298300
299301 async function installOrUpdateThenTryActivate (
300302 config : DistributionUpdateConfig
301- ) : Promise < CodeQLExtensionInterface | { } > {
303+ ) : Promise < CodeQLExtensionInterface | Record < string , never > > {
302304
303305 await installOrUpdateDistribution ( config ) ;
304306
305307 // Display the warnings even if the extension has already activated.
306308 const distributionResult = await getDistributionDisplayingDistributionWarnings ( ) ;
307- let extensionInterface : CodeQLExtensionInterface | { } = { } ;
309+ let extensionInterface : CodeQLExtensionInterface | Record < string , never > = { } ;
308310 if ( ! beganMainExtensionActivation && distributionResult . kind !== FindDistributionResultKind . NoDistribution ) {
309311 extensionInterface = await activateWithInstalledDistribution (
310312 ctx ,
@@ -498,8 +500,7 @@ async function activateWithInstalledDistribution(
498500 void helpers . showAndLogErrorMessage (
499501 'Jumping from a .qlref file to the .ql file it references is not '
500502 + 'supported with the CLI version you are running.\n'
501- + `Please upgrade your CLI to version ${
502- CliVersionConstraint . CLI_VERSION_WITH_RESOLVE_QLREF
503+ + `Please upgrade your CLI to version ${ CliVersionConstraint . CLI_VERSION_WITH_RESOLVE_QLREF
503504 } or later to use this feature.`) ;
504505 }
505506 }
@@ -713,6 +714,18 @@ async function activateWithInstalledDistribution(
713714 void helpers . showAndLogInformationMessage ( text ) ;
714715 } ) ) ;
715716
717+ /**
718+ * Credentials for authenticating to GitHub.
719+ * Currently unused, but will be useful in the future when making API calls.
720+ */
721+ const credentials = await Credentials . initialize ( ctx ) ;
722+
723+ ctx . subscriptions . push (
724+ commandRunner ( 'codeQL.authenticateToGitHub' , async ( ) => {
725+ const octokit = await credentials . getOctokit ( ) ;
726+ const userInfo = await octokit . users . getAuthenticated ( ) ;
727+ void helpers . showAndLogInformationMessage ( `Authenticated to GitHub as user: ${ userInfo . data . login } ` ) ;
728+ } ) ) ;
716729
717730 void logger . log ( 'Starting language server.' ) ;
718731 ctx . subscriptions . push ( client . start ( ) ) ;
0 commit comments