refactor cli
This commit is contained in:
@@ -38,49 +38,6 @@ import type { CliFeatures, VersionAndFeatures } from "./cli-version";
|
||||
import { ExitCodeError, getCliError } from "./cli-errors";
|
||||
import { UserCancellationException } from "../common/vscode/progress";
|
||||
|
||||
// /**
|
||||
// * The version of the SARIF format that we are using.
|
||||
// */
|
||||
// const SARIF_FORMAT = "sarifv2.1.0";
|
||||
|
||||
// /**
|
||||
// * The string used to specify CSV format.
|
||||
// */
|
||||
// const CSV_FORMAT = "csv";
|
||||
|
||||
// /**
|
||||
// * The expected output of `codeql resolve queries --format bylanguage`.
|
||||
// */
|
||||
// export interface QueryInfoByLanguage {
|
||||
// // Using `unknown` as a placeholder. For now, the value is only ever an empty object.
|
||||
// byLanguage: Record<string, Record<string, unknown>>;
|
||||
// noDeclaredLanguage: Record<string, unknown>;
|
||||
// multipleDeclaredLanguages: Record<string, unknown>;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * The expected output of `codeql resolve database`.
|
||||
// */
|
||||
// export interface DbInfo {
|
||||
// sourceLocationPrefix: string;
|
||||
// columnKind: string;
|
||||
// unicodeNewlines: boolean;
|
||||
// sourceArchiveZip: string;
|
||||
// sourceArchiveRoot: string;
|
||||
// datasetFolder: string;
|
||||
// logsFolder: string;
|
||||
// languages: string[];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * The expected output of `codeql resolve upgrades`.
|
||||
// */
|
||||
// interface UpgradesInfo {
|
||||
// scripts: string[];
|
||||
// finalDbscheme: string;
|
||||
// matchesTarget?: boolean;
|
||||
// }
|
||||
|
||||
const SARIF_FORMAT = "sarifv2.1.0";
|
||||
const CSV_FORMAT = "csv";
|
||||
|
||||
@@ -97,66 +54,29 @@ export interface DbInfo {
|
||||
|
||||
export type QueryInfoByLanguage = Record<string, never>; // If it's always empty
|
||||
|
||||
/**
|
||||
* The expected output of `codeql resolve qlpacks`.
|
||||
*/
|
||||
export type QlpacksInfo = { [name: string]: string[] };
|
||||
export type QlpacksInfo = Record<string, string[]>; // `codeql resolve qlpacks`
|
||||
type LanguagesInfo = Record<string, string[]>; // `codeql resolve languages`
|
||||
|
||||
/**
|
||||
* The expected output of `codeql resolve languages`.
|
||||
*/
|
||||
type LanguagesInfo = { [name: string]: string[] };
|
||||
type MlModelInfo = { checksum: string; path: string };
|
||||
type MlModelsInfo = { models: MlModelInfo[] }; // `codeql resolve ml-models`
|
||||
|
||||
/** Information about an ML model, as resolved by `codeql resolve ml-models`. */
|
||||
type MlModelInfo = {
|
||||
checksum: string;
|
||||
path: string;
|
||||
};
|
||||
|
||||
/** The expected output of `codeql resolve ml-models`. */
|
||||
type MlModelsInfo = { models: MlModelInfo[] };
|
||||
|
||||
/** Information about a data extension predicate, as resolved by `codeql resolve extensions`. */
|
||||
type DataExtensionResult = {
|
||||
predicate: string;
|
||||
file: string;
|
||||
index: number;
|
||||
};
|
||||
|
||||
/** The expected output of `codeql resolve extensions`. */
|
||||
type DataExtensionResult = { predicate: string; file: string; index: number };
|
||||
type ResolveExtensionsResult = {
|
||||
models: MlModelInfo[];
|
||||
data: {
|
||||
[path: string]: DataExtensionResult[];
|
||||
};
|
||||
data: Record<string, DataExtensionResult[]>; // `codeql resolve extensions`
|
||||
};
|
||||
|
||||
type GenerateExtensiblePredicateMetadataResult = {
|
||||
// There are other properties in this object, but they are
|
||||
// not relevant for its use in the extension, so we omit them.
|
||||
extensible_predicates: Array<{
|
||||
// pack relative path
|
||||
path: string;
|
||||
}>;
|
||||
extensible_predicates: Array<{ path: string }>; // Pack-relative path
|
||||
};
|
||||
|
||||
type PackDownloadResult = {
|
||||
// There are other properties in this object, but they are
|
||||
// not relevant for its use in the extension, so we omit them.
|
||||
packs: Array<{
|
||||
name: string;
|
||||
version: string;
|
||||
}>;
|
||||
packs: Array<{ name: string; version: string }>;
|
||||
packDir: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* The expected output of `codeql resolve qlref`.
|
||||
*/
|
||||
type QlrefInfo = { resolvedPath: string };
|
||||
type QlrefInfo = { resolvedPath: string }; // `codeql resolve qlref`
|
||||
|
||||
// `codeql bqrs interpret` requires both of these to be present or
|
||||
// both absent.
|
||||
export interface SourceInfo {
|
||||
sourceArchive: string;
|
||||
sourceLocationPrefix: string;
|
||||
@@ -1451,12 +1371,8 @@ export class CodeQLCliServer implements Disposable {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the `DbInfo` for a database.
|
||||
* @param databasePath Path to the CodeQL database to obtain information from.
|
||||
*/
|
||||
resolveDatabase(databasePath: string): Promise<DbInfo> {
|
||||
return this.runJsonCodeQlCliCommand(
|
||||
resolveDatabase(databasePath: string) {
|
||||
return this.runJsonCodeQlCliCommand<DbInfo>(
|
||||
["resolve", "database"],
|
||||
[databasePath],
|
||||
"Resolving database",
|
||||
|
||||
Reference in New Issue
Block a user