From 3422db65673db5b0c8285e0baa944268dab2cc2b Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 2 Mar 2026 11:02:07 +0100 Subject: [PATCH] chore: more graceful error on missing GITHUB_TOKEN in codegen --- codegen.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/codegen.ts b/codegen.ts index 4b41e4df4..48963d9d2 100644 --- a/codegen.ts +++ b/codegen.ts @@ -3,11 +3,20 @@ import dotenv from 'dotenv'; dotenv.config(); +if (!process.env.GITHUB_TOKEN) { + // biome-ignore lint/suspicious/noConsole: CLI script output + console.warn( + '\x1b[33m⚠ GITHUB_TOKEN is not set. Skipping GraphQL codegen.\n' + + ' To generate updated types, create a .env file with a valid GitHub PAT.\n' + + ' See .env.template for details.\x1b[0m', + ); + process.exit(0); +} + const config: CodegenConfig = { overwrite: true, schema: { 'https://api.github.com/graphql': { - // Add a custom header for authorization using your PAT headers: { Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, },