Skip to content

Commit 5a9d12e

Browse files
committed
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.
1 parent f9ef956 commit 5a9d12e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

  • extensions/ql-vscode/src

extensions/ql-vscode/src/cli.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { CompilationMessage } from "./pure/legacy-messages";
2828
import { sarifParser } from "./sarif-parser";
2929
import { dbSchemeToLanguage, walkDirectory } from "./helpers";
3030
import { App } from "./common/app";
31+
import { QueryLanguage } from "./qlpack-generator";
3132

3233
/**
3334
* The version of the SARIF format that we are using.
@@ -1216,6 +1217,23 @@ export class CodeQLCliServer implements Disposable {
12161217
);
12171218
}
12181219

1220+
/**
1221+
* Adds a list of QL library packs with optional version ranges as dependencies of
1222+
* the current package, and then installs them. This command modifies the qlpack.yml
1223+
* file of the current package. Formatting and comments will be removed.
1224+
* @param dir The directory where QL pack exists.
1225+
* @param language The language of the QL pack.
1226+
*/
1227+
async packAdd(dir: string, queryLanguage: QueryLanguage) {
1228+
const args = ["--dir", dir];
1229+
args.push(`codeql/${queryLanguage}-all`);
1230+
return this.runJsonCodeQlCliCommandWithAuthentication(
1231+
["pack", "add"],
1232+
args,
1233+
"Adding pack dependencies and installing them",
1234+
);
1235+
}
1236+
12191237
/**
12201238
* Downloads a specified pack.
12211239
* @param packs The `<package-scope/name[@version]>` of the packs to download.

0 commit comments

Comments
 (0)