Skip to content

Commit

Permalink
build: update script for openapi-typescript v7
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Jul 4, 2024
1 parent f87b7e2 commit 337c71b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions scripts/generate-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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`);
}
Expand Down

0 comments on commit 337c71b

Please sign in to comment.