@trigger.dev/cli: Don't require the TRIGGER_API_URL to be set (it has a default)

This commit is contained in:
Eric Allam
2023-08-03 14:49:46 +01:00
parent ed15bb0618
commit fc78854ed4
2 changed files with 12 additions and 6 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/cli": patch
---
Don't require the TRIGGER_API_URL to be set (it has a default)
+7 -6
View File
@@ -11,6 +11,7 @@ import { pathExists, readFile } from "../utils/fileSystem.js";
import { logger } from "../utils/logger.js";
import { resolvePath } from "../utils/parseNameAndPath.js";
import { TriggerApi } from "../utils/triggerApi.js";
import { CLOUD_API_URL } from "../consts.js";
export const DevCommandOptionsSchema = z.object({
port: z.coerce.number(),
@@ -250,26 +251,26 @@ async function getTriggerApiDetails(path: string, envFile: string) {
]);
if (!resolvedEnvFile) {
logger.error(`You must add TRIGGER_API_KEY and TRIGGER_API_URL to your ${envFile} file.`);
logger.error(`You must add TRIGGER_API_KEY to your ${envFile} file.`);
return;
}
const parsedEnvFile = dotenv.parse(resolvedEnvFile.content);
if (!parsedEnvFile.TRIGGER_API_KEY || !parsedEnvFile.TRIGGER_API_KEY) {
logger.error(`You must add TRIGGER_API_KEY and TRIGGER_API_URL to your ${envFile} file.`);
if (!parsedEnvFile) {
logger.error(`You must add TRIGGER_API_KEY to your ${envFile} file.`);
return;
}
const apiKey = parsedEnvFile.TRIGGER_API_KEY;
const apiUrl = parsedEnvFile.TRIGGER_API_URL;
if (!apiKey || !apiUrl) {
logger.error(`You must add TRIGGER_API_KEY and TRIGGER_API_URL to your ${envFile} file.`);
if (!apiKey) {
logger.error(`You must add TRIGGER_API_KEY to your ${envFile} file.`);
return;
}
return { apiKey, apiUrl, envFile: resolvedEnvFile.fileName };
return { apiKey, apiUrl: apiUrl ?? CLOUD_API_URL, envFile: resolvedEnvFile.fileName };
}
async function resolveEndpointUrl(apiUrl: string, port: number) {