diff --git a/packages/cli/src/projects/util.ts b/packages/cli/src/projects/util.ts index be6f8b1a0..634349c5d 100644 --- a/packages/cli/src/projects/util.ts +++ b/packages/cli/src/projects/util.ts @@ -32,8 +32,11 @@ export const loadAppAuthConfig = ( config.endpoint = OPENFN_ENDPOINT; } - // TODO probably need to throw - + if (!config.apiKey) { + throw new CLIError( + 'OPENFN_API_KEY is required. Set it in .env, pass --api-key, or set the environment variable.' + ); + } return config as Required; }; @@ -93,6 +96,12 @@ export const getLightningUrl = ( path: string = '', snapshots?: string[] ) => { + if (!endpoint) { + throw new CLIError( + 'OPENFN_ENDPOINT is required. Set it in .env, pass --endpoint, or set the environment variable.\n' + + 'Example: OPENFN_ENDPOINT=https://app.openfn.org' + ); + } const params = new URLSearchParams(); snapshots?.forEach((snapshot) => params.append('snapshots[]', snapshot)); return new URL(`/api/provision/${path}?${params.toString()}`, endpoint);