()
| 143 | }); |
| 144 | |
| 145 | export const promptTriggerUrl = async (): Promise<string> => { |
| 146 | const { instanceType } = await inquirer.prompt<{ |
| 147 | instanceType: "cloud" | "self-hosted"; |
| 148 | }>([ |
| 149 | { |
| 150 | type: "list", |
| 151 | name: "instanceType", |
| 152 | message: "Are you using the Trigger.dev cloud or self-hosted?", |
| 153 | choices: [ |
| 154 | { |
| 155 | name: `Trigger.dev Cloud (${CLOUD_TRIGGER_URL})`, |
| 156 | value: "cloud", |
| 157 | default: true, |
| 158 | }, |
| 159 | { |
| 160 | name: "Self hosted", |
| 161 | value: "self-hosted", |
| 162 | }, |
| 163 | ], |
| 164 | }, |
| 165 | ]); |
| 166 | |
| 167 | if (instanceType === "cloud") { |
| 168 | return CLOUD_TRIGGER_URL; |
| 169 | } |
| 170 | |
| 171 | const { triggerUrl } = await inquirer.prompt<{ triggerUrl: string }>({ |
| 172 | type: "input", |
| 173 | name: "triggerUrl", |
| 174 | message: "Enter the URL of your self-hosted Trigger.dev instance", |
| 175 | filter: (input) => { |
| 176 | return tryToCreateValidUrlFromValue(input); |
| 177 | }, |
| 178 | validate: (input) => { |
| 179 | if (!input) { |
| 180 | return "Please enter the URL of your self-hosted Trigger.dev instance"; |
| 181 | } |
| 182 | |
| 183 | const possibleUrl = tryToCreateValidUrlFromValue(input); |
| 184 | |
| 185 | try { |
| 186 | new URL(possibleUrl); |
| 187 | } catch (e) { |
| 188 | return "Please enter a valid URL"; |
| 189 | } |
| 190 | |
| 191 | return true; |
| 192 | }, |
| 193 | }); |
| 194 | |
| 195 | return triggerUrl; |
| 196 | }; |
| 197 | |
| 198 | export const promptApiKey = async (instanceUrl: string): Promise<string> => { |
| 199 | // First prompt if they want to enter their API key now, and if they say Yes, then prompt for it and return it |
no test coverage detected
searching dependent graphs…