@@ -121,6 +121,7 @@ import {
121121} from "./local-queries" ;
122122import { getAstCfgCommands } from "./ast-cfg-commands" ;
123123import { getQueryEditorCommands } from "./query-editor" ;
124+ import { App } from "./common/app" ;
124125
125126/**
126127 * extension.ts
@@ -156,9 +157,18 @@ const extension = extensions.getExtension(extensionId);
156157 * Return all commands that are not tied to the more specific managers.
157158 */
158159function getCommands (
160+ app : App ,
159161 cliServer : CodeQLCliServer ,
160162 queryRunner : QueryRunner ,
161163) : BaseCommands {
164+ const getCliVersion = async ( ) => {
165+ try {
166+ return await cliServer . getVersion ( ) ;
167+ } catch {
168+ return "<missing>" ;
169+ }
170+ } ;
171+
162172 return {
163173 "codeQL.openDocumentation" : async ( ) => {
164174 await env . openExternal ( Uri . parse ( "https://codeql.github.com/docs/" ) ) ;
@@ -177,6 +187,27 @@ function getCommands(
177187 title : "Restarting Query Server" ,
178188 } ,
179189 ) ,
190+ "codeQL.copyVersion" : async ( ) => {
191+ const text = `CodeQL extension version: ${
192+ extension ?. packageJSON . version
193+ } \nCodeQL CLI version: ${ await getCliVersion ( ) } \nPlatform: ${ platform ( ) } ${ arch ( ) } `;
194+ await env . clipboard . writeText ( text ) ;
195+ void showAndLogInformationMessage ( text ) ;
196+ } ,
197+ "codeQL.authenticateToGitHub" : async ( ) => {
198+ /**
199+ * Credentials for authenticating to GitHub.
200+ * These are used when making API calls.
201+ */
202+ const octokit = await app . credentials . getOctokit ( ) ;
203+ const userInfo = await octokit . users . getAuthenticated ( ) ;
204+ void showAndLogInformationMessage (
205+ `Authenticated to GitHub as user: ${ userInfo . data . login } ` ,
206+ ) ;
207+ } ,
208+ "codeQL.showLogs" : async ( ) => {
209+ extLogger . show ( ) ;
210+ } ,
180211 } ;
181212}
182213
@@ -841,7 +872,7 @@ async function activateWithInstalledDistribution(
841872 void extLogger . log ( "Registering top-level command palette commands." ) ;
842873
843874 const allCommands : AllExtensionCommands = {
844- ...getCommands ( cliServer , qs ) ,
875+ ...getCommands ( app , cliServer , qs ) ,
845876 ...getQueryEditorCommands ( {
846877 queryRunner : qs ,
847878 cliServer,
@@ -896,44 +927,6 @@ async function activateWithInstalledDistribution(
896927 ) ;
897928 }
898929
899- ctx . subscriptions . push (
900- commandRunner ( "codeQL.copyVersion" , async ( ) => {
901- const text = `CodeQL extension version: ${
902- extension ?. packageJSON . version
903- } \nCodeQL CLI version: ${ await getCliVersion ( ) } \nPlatform: ${ platform ( ) } ${ arch ( ) } `;
904- await env . clipboard . writeText ( text ) ;
905- void showAndLogInformationMessage ( text ) ;
906- } ) ,
907- ) ;
908-
909- const getCliVersion = async ( ) => {
910- try {
911- return await cliServer . getVersion ( ) ;
912- } catch {
913- return "<missing>" ;
914- }
915- } ;
916-
917- ctx . subscriptions . push (
918- commandRunner ( "codeQL.authenticateToGitHub" , async ( ) => {
919- /**
920- * Credentials for authenticating to GitHub.
921- * These are used when making API calls.
922- */
923- const octokit = await app . credentials . getOctokit ( ) ;
924- const userInfo = await octokit . users . getAuthenticated ( ) ;
925- void showAndLogInformationMessage (
926- `Authenticated to GitHub as user: ${ userInfo . data . login } ` ,
927- ) ;
928- } ) ,
929- ) ;
930-
931- ctx . subscriptions . push (
932- commandRunner ( "codeQL.showLogs" , async ( ) => {
933- extLogger . show ( ) ;
934- } ) ,
935- ) ;
936-
937930 void extLogger . log ( "Starting language server." ) ;
938931 await client . start ( ) ;
939932 ctx . subscriptions . push ( {
0 commit comments