@@ -123,6 +123,7 @@ import {
123123 showResultsForCompletedQuery ,
124124} from "./local-queries" ;
125125import { getAstCfgCommands } from "./ast-cfg-commands" ;
126+ import { App } from "./common/app" ;
126127
127128/**
128129 * extension.ts
@@ -158,9 +159,18 @@ const extension = extensions.getExtension(extensionId);
158159 * Return all commands that are not tied to the more specific managers.
159160 */
160161function getCommands (
162+ app : App ,
161163 cliServer : CodeQLCliServer ,
162164 queryRunner : QueryRunner ,
163165) : BaseCommands {
166+ const getCliVersion = async ( ) => {
167+ try {
168+ return await cliServer . getVersion ( ) ;
169+ } catch {
170+ return "<missing>" ;
171+ }
172+ } ;
173+
164174 return {
165175 "codeQL.openDocumentation" : async ( ) => {
166176 await env . openExternal ( Uri . parse ( "https://codeql.github.com/docs/" ) ) ;
@@ -179,6 +189,27 @@ function getCommands(
179189 title : "Restarting Query Server" ,
180190 } ,
181191 ) ,
192+ "codeQL.copyVersion" : async ( ) => {
193+ const text = `CodeQL extension version: ${
194+ extension ?. packageJSON . version
195+ } \nCodeQL CLI version: ${ await getCliVersion ( ) } \nPlatform: ${ platform ( ) } ${ arch ( ) } `;
196+ await env . clipboard . writeText ( text ) ;
197+ void showAndLogInformationMessage ( text ) ;
198+ } ,
199+ "codeQL.authenticateToGitHub" : async ( ) => {
200+ /**
201+ * Credentials for authenticating to GitHub.
202+ * These are used when making API calls.
203+ */
204+ const octokit = await app . credentials . getOctokit ( ) ;
205+ const userInfo = await octokit . users . getAuthenticated ( ) ;
206+ void showAndLogInformationMessage (
207+ `Authenticated to GitHub as user: ${ userInfo . data . login } ` ,
208+ ) ;
209+ } ,
210+ "codeQL.showLogs" : async ( ) => {
211+ extLogger . show ( ) ;
212+ } ,
182213 } ;
183214}
184215
@@ -833,7 +864,7 @@ async function activateWithInstalledDistribution(
833864 void extLogger . log ( "Registering top-level command palette commands." ) ;
834865
835866 const allCommands : AllCommands = {
836- ...getCommands ( cliServer , qs ) ,
867+ ...getCommands ( app , cliServer , qs ) ,
837868 ...localQueryResultsView . getCommands ( ) ,
838869 ...qhm . getCommands ( ) ,
839870 ...variantAnalysisManager . getCommands ( ) ,
@@ -915,44 +946,6 @@ async function activateWithInstalledDistribution(
915946 } ) ,
916947 ) ;
917948
918- ctx . subscriptions . push (
919- commandRunner ( "codeQL.copyVersion" , async ( ) => {
920- const text = `CodeQL extension version: ${
921- extension ?. packageJSON . version
922- } \nCodeQL CLI version: ${ await getCliVersion ( ) } \nPlatform: ${ platform ( ) } ${ arch ( ) } `;
923- await env . clipboard . writeText ( text ) ;
924- void showAndLogInformationMessage ( text ) ;
925- } ) ,
926- ) ;
927-
928- const getCliVersion = async ( ) => {
929- try {
930- return await cliServer . getVersion ( ) ;
931- } catch {
932- return "<missing>" ;
933- }
934- } ;
935-
936- ctx . subscriptions . push (
937- commandRunner ( "codeQL.authenticateToGitHub" , async ( ) => {
938- /**
939- * Credentials for authenticating to GitHub.
940- * These are used when making API calls.
941- */
942- const octokit = await app . credentials . getOctokit ( ) ;
943- const userInfo = await octokit . users . getAuthenticated ( ) ;
944- void showAndLogInformationMessage (
945- `Authenticated to GitHub as user: ${ userInfo . data . login } ` ,
946- ) ;
947- } ) ,
948- ) ;
949-
950- ctx . subscriptions . push (
951- commandRunner ( "codeQL.showLogs" , async ( ) => {
952- extLogger . show ( ) ;
953- } ) ,
954- ) ;
955-
956949 void extLogger . log ( "Starting language server." ) ;
957950 await client . start ( ) ;
958951 ctx . subscriptions . push ( {
0 commit comments