11import { EOL } from "os" ;
22import { spawn } from "child-process-promise" ;
3- import * as child_process from "child_process" ;
3+ import {
4+ ChildProcessWithoutNullStreams ,
5+ execFile ,
6+ spawn as spawnChildProcess ,
7+ } from "child_process" ;
48import { readFile } from "fs-extra" ;
59import { delimiter , dirname , join } from "path" ;
6- import * as sarif from "sarif" ;
10+ import { Log } from "sarif" ;
711import { SemVer } from "semver" ;
812import { Readable } from "stream" ;
913import tk from "tree-kill" ;
@@ -51,16 +55,6 @@ const CSV_FORMAT = "csv";
5155 */
5256const LOGGING_FLAGS = [ "-v" , "--log-to-stderr" ] ;
5357
54- /**
55- * The expected output of `codeql resolve library-path`.
56- */
57- export interface QuerySetup {
58- libraryPath : string [ ] ;
59- dbscheme : string ;
60- relativeName ?: string ;
61- compilationCache ?: string ;
62- }
63-
6458/**
6559 * The expected output of `codeql resolve queries --format bylanguage`.
6660 */
@@ -88,7 +82,7 @@ export interface DbInfo {
8882/**
8983 * The expected output of `codeql resolve upgrades`.
9084 */
91- export interface UpgradesInfo {
85+ interface UpgradesInfo {
9286 scripts : string [ ] ;
9387 finalDbscheme : string ;
9488 matchesTarget ?: boolean ;
@@ -102,33 +96,33 @@ export type QlpacksInfo = { [name: string]: string[] };
10296/**
10397 * The expected output of `codeql resolve languages`.
10498 */
105- export type LanguagesInfo = { [ name : string ] : string [ ] } ;
99+ type LanguagesInfo = { [ name : string ] : string [ ] } ;
106100
107101/** Information about an ML model, as resolved by `codeql resolve ml-models`. */
108- export type MlModelInfo = {
102+ type MlModelInfo = {
109103 checksum : string ;
110104 path : string ;
111105} ;
112106
113107/** The expected output of `codeql resolve ml-models`. */
114- export type MlModelsInfo = { models : MlModelInfo [ ] } ;
108+ type MlModelsInfo = { models : MlModelInfo [ ] } ;
115109
116110/** Information about a data extension predicate, as resolved by `codeql resolve extensions`. */
117- export type DataExtensionResult = {
111+ type DataExtensionResult = {
118112 predicate : string ;
119113 file : string ;
120114 index : number ;
121115} ;
122116
123117/** The expected output of `codeql resolve extensions`. */
124- export type ResolveExtensionsResult = {
118+ type ResolveExtensionsResult = {
125119 models : MlModelInfo [ ] ;
126120 data : {
127121 [ path : string ] : DataExtensionResult [ ] ;
128122 } ;
129123} ;
130124
131- export type GenerateExtensiblePredicateMetadataResult = {
125+ type GenerateExtensiblePredicateMetadataResult = {
132126 // There are other properties in this object, but they are
133127 // not relevant for its use in the extension, so we omit them.
134128 extensible_predicates : Array < {
@@ -140,7 +134,7 @@ export type GenerateExtensiblePredicateMetadataResult = {
140134/**
141135 * The expected output of `codeql resolve qlref`.
142136 */
143- export type QlrefInfo = { resolvedPath : string } ;
137+ type QlrefInfo = { resolvedPath : string } ;
144138
145139// `codeql bqrs interpret` requires both of these to be present or
146140// both absent.
@@ -152,17 +146,17 @@ export interface SourceInfo {
152146/**
153147 * The expected output of `codeql resolve queries`.
154148 */
155- export type ResolvedQueries = string [ ] ;
149+ type ResolvedQueries = string [ ] ;
156150
157151/**
158152 * The expected output of `codeql resolve tests`.
159153 */
160- export type ResolvedTests = string [ ] ;
154+ type ResolvedTests = string [ ] ;
161155
162156/**
163157 * A compilation message for a test message (either an error or a warning)
164158 */
165- export interface CompilationMessage {
159+ interface CompilationMessage {
166160 /**
167161 * The text of the message
168162 */
@@ -205,7 +199,7 @@ interface BqrsDecodeOptions {
205199 entities ?: string [ ] ;
206200}
207201
208- export type OnLineCallback = (
202+ type OnLineCallback = (
209203 line : string ,
210204) => Promise < string | undefined > | string | undefined ;
211205
@@ -219,7 +213,7 @@ type VersionChangedListener = (newVersion: SemVer | undefined) => void;
219213 */
220214export class CodeQLCliServer implements Disposable {
221215 /** The process for the cli server, or undefined if one doesn't exist yet */
222- process ?: child_process . ChildProcessWithoutNullStreams ;
216+ process ?: ChildProcessWithoutNullStreams ;
223217 /** Queue of future commands*/
224218 commandQueue : Array < ( ) => void > ;
225219 /** Whether a command is running */
@@ -335,7 +329,7 @@ export class CodeQLCliServer implements Disposable {
335329 /**
336330 * Launch the cli server
337331 */
338- private async launchProcess ( ) : Promise < child_process . ChildProcessWithoutNullStreams > {
332+ private async launchProcess ( ) : Promise < ChildProcessWithoutNullStreams > {
339333 const codeQlPath = await this . getCodeQlPath ( ) ;
340334 const args = [ ] ;
341335 if ( shouldDebugCliServer ( ) ) {
@@ -1101,7 +1095,7 @@ export class CodeQLCliServer implements Disposable {
11011095 interpretedResultsPath : string ,
11021096 sourceInfo ?: SourceInfo ,
11031097 args ?: string [ ] ,
1104- ) : Promise < sarif . Log > {
1098+ ) : Promise < Log > {
11051099 const additionalArgs = [
11061100 // TODO: This flag means that we don't group interpreted results
11071101 // by primary location. We may want to revisit whether we call
@@ -1592,7 +1586,7 @@ export function spawnServer(
15921586 stderrListener : ( data : any ) => void ,
15931587 stdoutListener ?: ( data : any ) => void ,
15941588 progressReporter ?: ProgressReporter ,
1595- ) : child_process . ChildProcessWithoutNullStreams {
1589+ ) : ChildProcessWithoutNullStreams {
15961590 // Enable verbose logging.
15971591 const args = command . concat ( commandArgs ) . concat ( LOGGING_FLAGS ) ;
15981592
@@ -1603,7 +1597,7 @@ export function spawnServer(
16031597 progressReporter . report ( { message : `Starting ${ name } ` } ) ;
16041598 }
16051599 void logger . log ( `Starting ${ name } using CodeQL CLI: ${ base } ${ argsString } ` ) ;
1606- const child = child_process . spawn ( base , args ) ;
1600+ const child = spawnChildProcess ( base , args ) ;
16071601 if ( ! child || ! child . pid ) {
16081602 throw new Error (
16091603 `Failed to start ${ name } using command ${ base } ${ argsString } .` ,
@@ -1670,7 +1664,7 @@ export async function runCodeQlCliCommand(
16701664 void logger . log (
16711665 `${ description } using CodeQL CLI: ${ codeQlPath } ${ argsString } ...` ,
16721666 ) ;
1673- const result = await promisify ( child_process . execFile ) ( codeQlPath , args ) ;
1667+ const result = await promisify ( execFile ) ( codeQlPath , args ) ;
16741668 void logger . log ( result . stderr ) ;
16751669 void logger . log ( "CLI command succeeded." ) ;
16761670 return result . stdout ;
@@ -1710,7 +1704,7 @@ export function shouldDebugQueryServer() {
17101704 return isEnvTrue ( "QUERY_SERVER_JAVA_DEBUG" ) ;
17111705}
17121706
1713- export function shouldDebugCliServer ( ) {
1707+ function shouldDebugCliServer ( ) {
17141708 return isEnvTrue ( "CLI_SERVER_JAVA_DEBUG" ) ;
17151709}
17161710
0 commit comments