Add better comments and error messages for pack-related changes

This commit is contained in:
Andrew Eisenberg 2021-06-04 10:18:24 -07:00
parent 86a804f9a7
commit 6cee818bf3
9 changed files with 35 additions and 17 deletions

16
lib/codeql.js generated
View file

@ -499,10 +499,16 @@ function getCodeQLForCmd(cmd) {
}).exec();
return output;
},
// Download specified packs into the package cache. If the specified
// package and version already exists (e.g., from a previous analysis run),
// then it is not downloaded again (unless the extra option `--force` is
// specified).
/**
* Download specified packs into the package cache. If the specified
* package and version already exists (e.g., from a previous analysis run),
* then it is not downloaded again (unless the extra option `--force` is
* specified).
*
* If no version is specified, then the latest version is
* downloaded. The check to determine what the latest version is is done
* each time this package is requested.
*/
async packDownload(packs) {
const args = [
"pack",
@ -523,7 +529,7 @@ function getCodeQLForCmd(cmd) {
return JSON.parse(output);
}
catch (e) {
throw new Error(`Attempted to download specified packs but got error ${e}.`);
throw new Error(`Attempted to download specified packs but got an error:${"\n"}${output}.`);
}
},
};

File diff suppressed because one or more lines are too long

5
lib/config-utils.js generated
View file

@ -537,7 +537,10 @@ async function loadConfig(languagesInput, queriesInput, configFile, dbLocation,
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
};
}
// Only alpha-numeric characters, with `-` allowed as long as not the first or last char
/**
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
* and `-` allowed as long as not the first or last char.
**/
const PACK_IDENTIFIER_PATTERN = (function () {
const alphaNumeric = "[a-z0-9]";
const alphaNumericDash = "[a-z0-9-]";

File diff suppressed because one or more lines are too long

View file

@ -786,7 +786,7 @@ ava_1.default("two packs with language", parsePacksMacro, {
ava_1.default("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
ava_1.default("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
ava_1.default("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
ava_1.default(invalidPackNameMacro, "c");
ava_1.default(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
ava_1.default(invalidPackNameMacro, "c-/d");
ava_1.default(invalidPackNameMacro, "-c/d");
ava_1.default(invalidPackNameMacro, "c/d_d");

File diff suppressed because one or more lines are too long

View file

@ -767,10 +767,16 @@ function getCodeQLForCmd(cmd: string): CodeQL {
return output;
},
// Download specified packs into the package cache. If the specified
// package and version already exists (e.g., from a previous analysis run),
// then it is not downloaded again (unless the extra option `--force` is
// specified).
/**
* Download specified packs into the package cache. If the specified
* package and version already exists (e.g., from a previous analysis run),
* then it is not downloaded again (unless the extra option `--force` is
* specified).
*
* If no version is specified, then the latest version is
* downloaded. The check to determine what the latest version is is done
* each time this package is requested.
*/
async packDownload(packs: PackWithVersion[]): Promise<PackDownloadOutput> {
const args = [
"pack",
@ -793,7 +799,7 @@ function getCodeQLForCmd(cmd: string): CodeQL {
return JSON.parse(output) as PackDownloadOutput;
} catch (e) {
throw new Error(
`Attempted to download specified packs but got error ${e}.`
`Attempted to download specified packs but got an error:${"\n"}${output}.`
);
}
},

View file

@ -1411,7 +1411,7 @@ test(
/The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/
);
test(invalidPackNameMacro, "c");
test(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
test(invalidPackNameMacro, "c-/d");
test(invalidPackNameMacro, "-c/d");
test(invalidPackNameMacro, "c/d_d");

View file

@ -1016,7 +1016,10 @@ async function loadConfig(
};
}
// Only alpha-numeric characters, with `-` allowed as long as not the first or last char
/**
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
* and `-` allowed as long as not the first or last char.
**/
const PACK_IDENTIFIER_PATTERN = (function () {
const alphaNumeric = "[a-z0-9]";
const alphaNumericDash = "[a-z0-9-]";