11import {
22 CancellationToken ,
33 commands ,
4+ env ,
45 EventEmitter ,
56 ExtensionContext ,
6- Uri ,
7- env ,
87} from "vscode" ;
9- import { nanoid } from "nanoid" ;
108import { join } from "path" ;
11- import { writeFile , readFile , remove , pathExists } from "fs-extra" ;
9+ import { pathExists , readFile , remove , writeFile } from "fs-extra" ;
1210import { EOL } from "os" ;
1311
1412import { CodeQLCliServer } from "../cli" ;
15- import { ProgressCallback } from "../commandRunner" ;
1613import {
17- createTimestampFile ,
1814 showAndLogErrorMessage ,
1915 showAndLogExceptionWithTelemetry ,
2016 showAndLogInformationMessage ,
2117 showInformationMessageWithAction ,
2218} from "../helpers" ;
2319import { Logger } from "../common" ;
24- import { prepareRemoteQueryRun } from "./run-remote-query" ;
2520import { RemoteQueriesView } from "./remote-queries-view" ;
26- import { buildRemoteQueryEntity , RemoteQuery } from "./remote-query" ;
21+ import { RemoteQuery } from "./remote-query" ;
2722import { RemoteQueriesMonitor } from "./remote-queries-monitor" ;
2823import {
2924 getRemoteQueryIndex ,
@@ -41,7 +36,6 @@ import { asError, assertNever, getErrorMessage } from "../pure/helpers-pure";
4136import { QueryStatus } from "../query-status" ;
4237import { DisposableObject } from "../pure/disposable-object" ;
4338import { AnalysisResults } from "./shared/analysis-result" ;
44- import { runRemoteQueriesApiRequest } from "./remote-queries-api" ;
4539import { App } from "../common/app" ;
4640import { redactableError } from "../pure/errors" ;
4741
@@ -85,7 +79,7 @@ export class RemoteQueriesManager extends DisposableObject {
8579 constructor (
8680 ctx : ExtensionContext ,
8781 private readonly app : App ,
88- private readonly cliServer : CodeQLCliServer ,
82+ cliServer : CodeQLCliServer ,
8983 private readonly storagePath : string ,
9084 logger : Logger ,
9185 ) {
@@ -167,62 +161,6 @@ export class RemoteQueriesManager extends DisposableObject {
167161 }
168162 }
169163
170- public async runRemoteQuery (
171- uri : Uri | undefined ,
172- progress : ProgressCallback ,
173- token : CancellationToken ,
174- ) : Promise < void > {
175- const {
176- actionBranch,
177- base64Pack,
178- repoSelection,
179- queryFile,
180- queryMetadata,
181- controllerRepo,
182- queryStartTime,
183- language,
184- } = await prepareRemoteQueryRun (
185- this . cliServer ,
186- this . app . credentials ,
187- uri ,
188- progress ,
189- token ,
190- ) ;
191-
192- const apiResponse = await runRemoteQueriesApiRequest (
193- this . app . credentials ,
194- actionBranch ,
195- language ,
196- repoSelection ,
197- controllerRepo ,
198- base64Pack ,
199- ) ;
200-
201- if ( ! apiResponse ) {
202- return ;
203- }
204-
205- const workflowRunId = apiResponse . workflow_run_id ;
206- const repositoryCount = apiResponse . repositories_queried . length ;
207- const query = await buildRemoteQueryEntity (
208- queryFile ,
209- queryMetadata ,
210- controllerRepo ,
211- queryStartTime ,
212- workflowRunId ,
213- language ,
214- repositoryCount ,
215- ) ;
216-
217- const queryId = this . createQueryId ( ) ;
218-
219- await this . prepareStorageDirectory ( queryId ) ;
220- await this . storeJsonFile ( queryId , "query.json" , query ) ;
221-
222- this . remoteQueryAddedEventEmitter . fire ( { queryId, query } ) ;
223- void commands . executeCommand ( "codeQL.monitorRemoteQuery" , queryId , query ) ;
224- }
225-
226164 public async monitorRemoteQuery (
227165 queryId : string ,
228166 remoteQuery : RemoteQuery ,
@@ -389,25 +327,6 @@ export class RemoteQueriesManager extends DisposableObject {
389327 }
390328 }
391329
392- /**
393- * Generates a unique id for this query, suitable for determining the storage location for the downloaded query artifacts.
394- * @returns A unique id for this query.
395- */
396- private createQueryId ( ) : string {
397- return nanoid ( ) ;
398- }
399-
400- /**
401- * Prepares a directory for storing analysis results for a single query run.
402- * This directory contains a timestamp file, which will be
403- * used by the query history manager to determine when the directory
404- * should be deleted.
405- *
406- */
407- private async prepareStorageDirectory ( queryId : string ) : Promise < void > {
408- await createTimestampFile ( join ( this . storagePath , queryId ) ) ;
409- }
410-
411330 private async getRemoteQueryResult (
412331 queryId : string ,
413332 ) : Promise < RemoteQueryResult > {
0 commit comments