(instanceUrl: string)
| 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 |
| 200 | const { apiKey } = await inquirer.prompt<{ apiKey: string }>({ |
| 201 | type: "password", |
| 202 | name: "apiKey", |
| 203 | message: `Enter your secret dev API key (Find yours ➡️ ${instanceUrl})`, |
| 204 | validate: (input) => { |
| 205 | // Make sure they enter something like tr_dev_******** |
| 206 | if (!input) { |
| 207 | return "Please enter your secret dev API key"; |
| 208 | } |
| 209 | |
| 210 | const result = checkApiKeyIsDevServer(input); |
| 211 | |
| 212 | if (result.success) { |
| 213 | return true; |
| 214 | } |
| 215 | |
| 216 | if (!result.type) { |
| 217 | return "Please enter a valid development API key (should start with tr_dev_)"; |
| 218 | } |
| 219 | |
| 220 | return `Please enter your secret dev API key, you've entered a ${result.type.environment} ${result.type.type} key`; |
| 221 | }, |
| 222 | }); |
| 223 | |
| 224 | return apiKey; |
| 225 | }; |
| 226 | |
| 227 | export const promptEndpointSlug = async (path: string): Promise<string> => { |
| 228 | const { endpointSlug } = await inquirer.prompt<{ |
no test coverage detected
searching dependent graphs…