Skip to content

Commit 1570bf1

Browse files
committed
Remove packDownload()
1 parent 30383e4 commit 1570bf1

File tree

3 files changed

+6
-107
lines changed

3 files changed

+6
-107
lines changed

src/analyze.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ test("status report fields", async (t) => {
4444
for (const language of Object.values(Language)) {
4545
setCodeQL({
4646
databaseRunQueries: async () => {},
47-
packDownload: async () => ({ packs: [] }),
4847
databaseInterpretResults: async (
4948
_db: string,
5049
_queriesRun: string[],

src/codeql.ts

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,6 @@ export interface CodeQL {
128128
language: string,
129129
): Promise<ResolveBuildEnvironmentOutput>;
130130

131-
/**
132-
* Run 'codeql pack download'.
133-
*/
134-
packDownload(
135-
packs: string[],
136-
qlconfigFile: string | undefined,
137-
): Promise<PackDownloadOutput>;
138-
139131
/**
140132
* Run 'codeql database cleanup'.
141133
*/
@@ -240,17 +232,6 @@ export interface ResolveBuildEnvironmentOutput {
240232
};
241233
}
242234

243-
export interface PackDownloadOutput {
244-
packs: PackDownloadItem[];
245-
}
246-
247-
interface PackDownloadItem {
248-
name: string;
249-
version: string;
250-
packDir: string;
251-
installResult: string;
252-
}
253-
254235
/**
255236
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
256237
* Can be overridden in tests using `setCodeQL`.
@@ -450,7 +431,6 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
450431
partialCodeql,
451432
"resolveBuildEnvironment",
452433
),
453-
packDownload: resolveFunction(partialCodeql, "packDownload"),
454434
databaseCleanup: resolveFunction(partialCodeql, "databaseCleanup"),
455435
databaseBundle: resolveFunction(partialCodeql, "databaseBundle"),
456436
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
@@ -861,58 +841,6 @@ export async function getCodeQLForCmd(
861841
return await runCli(cmd, codeqlArgs);
862842
},
863843

864-
/**
865-
* Download specified packs into the package cache. If the specified
866-
* package and version already exists (e.g., from a previous analysis run),
867-
* then it is not downloaded again (unless the extra option `--force` is
868-
* specified).
869-
*
870-
* If no version is specified, then the latest version is
871-
* downloaded. The check to determine what the latest version is is done
872-
* each time this package is requested.
873-
*
874-
* Optionally, a `qlconfigFile` is included. If used, then this file
875-
* is used to determine which registry each pack is downloaded from.
876-
*/
877-
async packDownload(
878-
packs: string[],
879-
qlconfigFile: string | undefined,
880-
): Promise<PackDownloadOutput> {
881-
const qlconfigArg = qlconfigFile
882-
? [`--qlconfig-file=${qlconfigFile}`]
883-
: ([] as string[]);
884-
885-
const codeqlArgs = [
886-
"pack",
887-
"download",
888-
...qlconfigArg,
889-
"--format=json",
890-
"--resolve-query-specs",
891-
...getExtraOptionsFromEnv(["pack", "download"]),
892-
...packs,
893-
];
894-
895-
const output = await runCli(cmd, codeqlArgs);
896-
897-
try {
898-
const parsedOutput: PackDownloadOutput = JSON.parse(output);
899-
if (
900-
Array.isArray(parsedOutput.packs) &&
901-
// TODO PackDownloadOutput will not include the version if it is not specified
902-
// in the input. The version is always the latest version available.
903-
// It should be added to the output, but this requires a CLI change
904-
parsedOutput.packs.every((p) => p.name /* && p.version */)
905-
) {
906-
return parsedOutput;
907-
} else {
908-
throw new Error("Unexpected output from pack download");
909-
}
910-
} catch (e) {
911-
throw new Error(
912-
`Attempted to download specified packs but got an error:\n${output}\n${e}`,
913-
);
914-
}
915-
},
916844
async databaseCleanup(
917845
databasePath: string,
918846
cleanupLevel: string,

src/config-utils.test.ts

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ import * as sinon from "sinon";
99
import * as actionsUtil from "./actions-util";
1010
import * as api from "./api-client";
1111
import { CachingKind } from "./caching-utils";
12-
import {
13-
CodeQL,
14-
getCachedCodeQL,
15-
PackDownloadOutput,
16-
setCodeQL,
17-
} from "./codeql";
12+
import { CodeQL, getCachedCodeQL, setCodeQL } from "./codeql";
1813
import * as configUtils from "./config-utils";
1914
import { Feature } from "./feature-flags";
2015
import * as gitUtils from "./git-utils";
@@ -130,11 +125,7 @@ test("load empty config", async (t) => {
130125
const logger = getRunnerLogger(true);
131126
const languages = "javascript,python";
132127

133-
const codeql = setCodeQL({
134-
async packDownload(): Promise<PackDownloadOutput> {
135-
return { packs: [] };
136-
},
137-
});
128+
const codeql = setCodeQL({});
138129

139130
const config = await configUtils.initConfig(
140131
createTestInitConfigInputs({
@@ -164,11 +155,7 @@ test("loading config saves config", async (t) => {
164155
return await withTmpDir(async (tempDir) => {
165156
const logger = getRunnerLogger(true);
166157

167-
const codeql = setCodeQL({
168-
async packDownload(): Promise<PackDownloadOutput> {
169-
return { packs: [] };
170-
},
171-
});
158+
const codeql = setCodeQL({});
172159

173160
// Sanity check the saved config file does not already exist
174161
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
@@ -285,11 +272,7 @@ test("load non-existent input", async (t) => {
285272

286273
test("load non-empty input", async (t) => {
287274
return await withTmpDir(async (tempDir) => {
288-
const codeql = setCodeQL({
289-
async packDownload(): Promise<PackDownloadOutput> {
290-
return { packs: [] };
291-
},
292-
});
275+
const codeql = setCodeQL({});
293276

294277
// Just create a generic config object with non-default values for all fields
295278
const inputFileContents = `
@@ -374,11 +357,7 @@ test("Using config input and file together, config input should be used.", async
374357

375358
fs.mkdirSync(path.join(tempDir, "foo"));
376359

377-
const codeql = setCodeQL({
378-
async packDownload(): Promise<PackDownloadOutput> {
379-
return { packs: [] };
380-
},
381-
});
360+
const codeql = setCodeQL({});
382361

383362
// Only JS, python packs will be ignored
384363
const languagesInput = "javascript";
@@ -400,11 +379,7 @@ test("Using config input and file together, config input should be used.", async
400379

401380
test("API client used when reading remote config", async (t) => {
402381
return await withTmpDir(async (tempDir) => {
403-
const codeql = setCodeQL({
404-
async packDownload(): Promise<PackDownloadOutput> {
405-
return { packs: [] };
406-
},
407-
});
382+
const codeql = setCodeQL({});
408383

409384
const inputFileContents = `
410385
name: my config
@@ -505,9 +480,6 @@ test("No detected languages", async (t) => {
505480
async resolveLanguages() {
506481
return {};
507482
},
508-
async packDownload(): Promise<PackDownloadOutput> {
509-
return { packs: [] };
510-
},
511483
});
512484

513485
try {

0 commit comments

Comments
 (0)