mirror of
https://github.com/github/codeql-action.git
synced 2026-05-07 22:30:44 +00:00
30 lines
863 B
JavaScript
30 lines
863 B
JavaScript
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { globSync } from "glob";
|
|
import { compileFromFile } from 'json-schema-to-typescript';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const SRC_DIR = path.join(__dirname, "schemas");
|
|
const OUT_DIR = path.join(__dirname, "src");
|
|
|
|
async function generateTypings() {
|
|
const schemas = globSync(`${SRC_DIR}/*.json`);
|
|
for (const schema of schemas) {
|
|
const outPath = path.join(
|
|
OUT_DIR,
|
|
`${path.basename(schema, ".json")}.d.ts`,
|
|
);
|
|
const ts = await compileFromFile(schema, {
|
|
bannerComment:
|
|
"/* This file was automatically generated by `npm run generate:schemas`. Do not edit by hand. */",
|
|
});
|
|
fs.writeFileSync(outPath, ts, "utf-8");
|
|
}
|
|
}
|
|
|
|
await generateTypings();
|