diff --git a/scripts/generate-types.js b/scripts/generate-types.js index 98d5c7164..f1f783095 100644 --- a/scripts/generate-types.js +++ b/scripts/generate-types.js @@ -2,7 +2,7 @@ import { readdir, mkdir, rm, writeFile, copyFile } from "node:fs/promises"; import { basename } from "node:path"; import * as prettier from "prettier"; -import openapiTS from "openapi-typescript"; +import openapiTS, { astToString, COMMENT_HEADER } from "openapi-typescript"; if (!process.env.OCTOKIT_OPENAPI_VERSION) { throw new Error("OCTOKIT_OPENAPI_VERSION is not set"); @@ -87,9 +87,15 @@ type Repository = components["schemas"]["full-repository"] await writeFile( `packages/${packageName}/types.d.ts`, - await prettier.format(await openapiTS(`cache/${name}.json`), { - parser: "typescript", - }), + await prettier.format( + COMMENT_HEADER + + astToString( + await openapiTS(new URL(`../cache/${name}.json`, import.meta.url)), + ), + { + parser: "typescript", + }, + ), ); console.log(`packages/${packageName}/types.d.ts written`); }