()
| 694 | } |
| 695 | |
| 696 | async #apiKey() { |
| 697 | const apiKey = getApiKey(this.#options.apiKey); |
| 698 | |
| 699 | if (apiKey.status === "invalid") { |
| 700 | throw new Error("Invalid API key"); |
| 701 | |
| 702 | // const chalk = (await import("chalk")).default; |
| 703 | // const terminalLink = (await import("terminal-link")).default; |
| 704 | |
| 705 | // throw new Error( |
| 706 | // `${chalk.red("Trigger.dev error")}: Invalid API key ("${chalk.italic( |
| 707 | // apiKey.apiKey |
| 708 | // )}"), please set the TRIGGER_API_KEY environment variable or pass the apiKey option to a valid value. ${terminalLink( |
| 709 | // "Get your API key here", |
| 710 | // "https://app.trigger.dev", |
| 711 | // { |
| 712 | // fallback(text, url) { |
| 713 | // return `${text} 👉 ${url}`; |
| 714 | // }, |
| 715 | // } |
| 716 | // )}` |
| 717 | // ); |
| 718 | } else if (apiKey.status === "missing") { |
| 719 | throw new Error("Missing API key"); |
| 720 | // const chalk = (await import("chalk")).default; |
| 721 | // const terminalLink = (await import("terminal-link")).default; |
| 722 | |
| 723 | // throw new Error( |
| 724 | // `${chalk.red( |
| 725 | // "Trigger.dev error" |
| 726 | // )}: Missing an API key, please set the TRIGGER_API_KEY environment variable or pass the apiKey option to the Trigger constructor. ${terminalLink( |
| 727 | // "Get your API key here", |
| 728 | // "https://app.trigger.dev", |
| 729 | // { |
| 730 | // fallback(text, url) { |
| 731 | // return `${text} 👉 ${url}`; |
| 732 | // }, |
| 733 | // } |
| 734 | // )}` |
| 735 | // ); |
| 736 | } |
| 737 | |
| 738 | return apiKey.apiKey; |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | function getApiKey(key?: string) { |
no test coverage detected