@@ -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 logger . log ( `Starting ${ extensionId } extension` ) ;
153155 if ( extension === undefined ) {
154156 throw new Error ( `Can't find extension ${ extensionId } ` ) ;
@@ -294,13 +296,13 @@ export async function activate(ctx: ExtensionContext): Promise<CodeQLExtensionIn
294296
295297 async function installOrUpdateThenTryActivate (
296298 config : DistributionUpdateConfig
297- ) : Promise < CodeQLExtensionInterface | { } > {
299+ ) : Promise < CodeQLExtensionInterface | Record < string , never > > {
298300
299301 await installOrUpdateDistribution ( config ) ;
300302
301303 // Display the warnings even if the extension has already activated.
302304 const distributionResult = await getDistributionDisplayingDistributionWarnings ( ) ;
303- let extensionInterface : CodeQLExtensionInterface | { } = { } ;
305+ let extensionInterface : CodeQLExtensionInterface | Record < string , never > = { } ;
304306 if ( ! beganMainExtensionActivation && distributionResult . kind !== FindDistributionResultKind . NoDistribution ) {
305307 extensionInterface = await activateWithInstalledDistribution (
306308 ctx ,
@@ -494,8 +496,7 @@ async function activateWithInstalledDistribution(
494496 helpers . showAndLogErrorMessage (
495497 'Jumping from a .qlref file to the .ql file it references is not '
496498 + 'supported with the CLI version you are running.\n'
497- + `Please upgrade your CLI to version ${
498- CliVersionConstraint . CLI_VERSION_WITH_RESOLVE_QLREF
499+ + `Please upgrade your CLI to version ${ CliVersionConstraint . CLI_VERSION_WITH_RESOLVE_QLREF
499500 } or later to use this feature.`) ;
500501 }
501502 }
@@ -709,6 +710,18 @@ async function activateWithInstalledDistribution(
709710 helpers . showAndLogInformationMessage ( text ) ;
710711 } ) ) ;
711712
713+ /**
714+ * Credentials for authenticating to GitHub.
715+ * Currently unused, but will be useful in the future when making API calls.
716+ */
717+ const credentials = await Credentials . initialize ( ctx ) ;
718+
719+ ctx . subscriptions . push (
720+ commandRunner ( 'codeQL.authenticateToGitHub' , async ( ) => {
721+ const octokit = await credentials . getOctokit ( ) ;
722+ const userInfo = await octokit . users . getAuthenticated ( ) ;
723+ helpers . showAndLogInformationMessage ( `Authenticated to GitHub as user: ${ userInfo . data . login } ` ) ;
724+ } ) ) ;
712725
713726 logger . log ( 'Starting language server.' ) ;
714727 ctx . subscriptions . push ( client . start ( ) ) ;
0 commit comments