diff --git a/ng-dev/ai/fix.ts b/ng-dev/ai/fix.ts index b945c1dbd..f017d5bc6 100644 --- a/ng-dev/ai/fix.ts +++ b/ng-dev/ai/fix.ts @@ -79,8 +79,10 @@ function builder(argv: Argv): Argv { /** Yargs command handler for the command. */ async function handler(options: Arguments) { + const apiKey = options.apiKey || DEFAULT_API_KEY; + assert( - options.apiKey, + apiKey, [ 'No API key configured. A Gemini API key must be set as the `GEMINI_API_KEY` environment ' + 'variable, or passed in using the `--api-key` flag.', @@ -89,7 +91,7 @@ async function handler(options: Arguments) { ); const fixedContents = await fixFilesWithAI( - options.apiKey, + apiKey, options.files, options.error, options.model, diff --git a/ng-dev/ai/migrate.ts b/ng-dev/ai/migrate.ts index 147324157..5e37f2064 100644 --- a/ng-dev/ai/migrate.ts +++ b/ng-dev/ai/migrate.ts @@ -72,15 +72,16 @@ function builder(argv: Argv): Argv { .option('apiKey', { type: 'string', alias: 'a', - default: DEFAULT_API_KEY, description: 'API key used when making calls to the Gemini API', }); } /** Yargs command handler for the command. */ async function handler(options: Arguments) { + const apiKey = options.apiKey || DEFAULT_API_KEY; + assert( - options.apiKey, + apiKey, [ 'No API key configured. A Gemini API key must be set as the `GEMINI_API_KEY` environment ' + 'variable, or passed in using the `--api-key` flag.', @@ -98,7 +99,7 @@ async function handler(options: Arguments) { process.exit(1); } - const ai = new GoogleGenAI({apiKey: options.apiKey}); + const ai = new GoogleGenAI({apiKey}); const progressBar = new SingleBar({}, Presets.shades_grey); const failures: {name: string; error: string}[] = []; const running = new Set>();