Introduce wrapper for codeql pack add CLI command

Similar to what we do with `codeql pack install`.

Tnis will simulate us running `codeql pack add codeql/<language>-all`.

We're going to need in order to:
- generate a lock file (codeql-pack.lock.yaml)
- install the correct packages for our skeleton QL pack based on the
lock file.
This commit is contained in:
Elena Tanasoiu
2023-02-07 22:16:37 +00:00
parent f9ef9567cf
commit 5a9d12ea60

View File

@@ -28,6 +28,7 @@ import { CompilationMessage } from "./pure/legacy-messages";
import { sarifParser } from "./sarif-parser";
import { dbSchemeToLanguage, walkDirectory } from "./helpers";
import { App } from "./common/app";
import { QueryLanguage } from "./qlpack-generator";
/**
* The version of the SARIF format that we are using.
@@ -1216,6 +1217,23 @@ export class CodeQLCliServer implements Disposable {
);
}
/**
* Adds a list of QL library packs with optional version ranges as dependencies of
* the current package, and then installs them. This command modifies the qlpack.yml
* file of the current package. Formatting and comments will be removed.
* @param dir The directory where QL pack exists.
* @param language The language of the QL pack.
*/
async packAdd(dir: string, queryLanguage: QueryLanguage) {
const args = ["--dir", dir];
args.push(`codeql/${queryLanguage}-all`);
return this.runJsonCodeQlCliCommandWithAuthentication(
["pack", "add"],
args,
"Adding pack dependencies and installing them",
);
}
/**
* Downloads a specified pack.
* @param packs The `<package-scope/name[@version]>` of the packs to download.