Skip to content

Commit 97bcdd8

Browse files
committed
Move script to pr-checks directory
1 parent e6c21da commit 97bcdd8

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

.github/workflows/script/tsconfig.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/update-bundle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
tools: https://github.com/github/codeql-action/releases/download/${{ github.event.release.tag_name }}/codeql-bundle-linux64.tar.gz
6565

6666
- name: Update built-in languages
67-
run: npx tsx .github/workflows/script/update-builtin-languages.ts "$CODEQL_PATH"
67+
run: npx tsx pr-checks/update-builtin-languages.ts "$CODEQL_PATH"
6868
env:
6969
CODEQL_PATH: ${{ steps.setup-codeql.outputs.codeql-path }}
7070

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"ava": "npm run transpile && ava --verbose",
1313
"test": "npm run ava -- src/",
1414
"test-debug": "npm run test -- --timeout=20m",
15-
"transpile": "tsc --build --verbose tsconfig.json .github/workflows/script/tsconfig.json"
15+
"transpile": "tsc --build --verbose tsconfig.json"
1616
},
1717
"license": "MIT",
1818
"workspaces": [

.github/workflows/script/update-builtin-languages.ts renamed to pr-checks/update-builtin-languages.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* - Language aliases (via `codeql resolve languages --format=betterjson --extractor-include-aliases`)
77
*
88
* Usage:
9-
* npx tsx .github/workflows/script/update-builtin-languages.ts [path-to-codeql]
9+
* npx tsx pr-checks/update-builtin-languages.ts [path-to-codeql]
1010
*
1111
* If no path is given, falls back to "codeql".
1212
*/
@@ -21,11 +21,9 @@ const codeqlPath = process.argv[2] || "codeql";
2121

2222
// Step 1: Resolve all language extractor directories.
2323
const resolveJson: Record<string, string[]> = JSON.parse(
24-
execFileSync(
25-
codeqlPath,
26-
["resolve", "languages", "--format=json"],
27-
{ encoding: "utf8" },
28-
),
24+
execFileSync(codeqlPath, ["resolve", "languages", "--format=json"], {
25+
encoding: "utf8",
26+
}),
2927
);
3028

3129
// Step 2: For each language, read codeql-extractor.yml and check default_queries.
@@ -36,14 +34,18 @@ for (const [language, dirs] of Object.entries(resolveJson)) {
3634
const extractorYmlPath = path.join(extractorDir, "codeql-extractor.yml");
3735

3836
if (!fs.existsSync(extractorYmlPath)) {
39-
throw new Error(`Extractor YAML not found for language '${language}' at expected path: ${extractorYmlPath}`);
37+
throw new Error(
38+
`Extractor YAML not found for language '${language}' at expected path: ${extractorYmlPath}`,
39+
);
4040
}
4141

4242
const extractorYml = yaml.parse(fs.readFileSync(extractorYmlPath, "utf8"));
4343
const defaultQueries: unknown[] | undefined = extractorYml.default_queries;
4444

4545
if (Array.isArray(defaultQueries) && defaultQueries.length > 0) {
46-
console.log(` ✅ ${language}: included (default_queries: ${JSON.stringify(defaultQueries)})`);
46+
console.log(
47+
` ✅ ${language}: included (default_queries: ${JSON.stringify(defaultQueries)})`,
48+
);
4749
languages.push(language);
4850
} else {
4951
console.log(` ❌ ${language}: excluded (no default queries)`);
@@ -56,7 +58,12 @@ languages.sort();
5658
const betterjsonOutput = JSON.parse(
5759
execFileSync(
5860
codeqlPath,
59-
["resolve", "languages", "--format=betterjson", "--extractor-include-aliases"],
61+
[
62+
"resolve",
63+
"languages",
64+
"--format=betterjson",
65+
"--extractor-include-aliases",
66+
],
6067
{ encoding: "utf8" },
6168
),
6269
);
@@ -72,14 +79,12 @@ const aliases: Record<string, string> = Object.fromEntries(
7279
const outputPath = path.join(
7380
__dirname,
7481
"..",
75-
"..",
76-
"..",
7782
"src",
7883
"languages",
7984
"builtin.json",
8085
);
8186

82-
const content = JSON.stringify({ languages, aliases }, null, 2) + "\n";
87+
const content = `${JSON.stringify({ languages, aliases }, null, 2)}\n`;
8388
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
8489
fs.writeFileSync(outputPath, content);
8590

0 commit comments

Comments
 (0)