Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/cli/src/projects/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthOptions>;
};

Expand Down Expand Up @@ -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);
Expand Down