diff --git a/.changeset/warm-eagles-itch.md b/.changeset/warm-eagles-itch.md new file mode 100644 index 0000000000..f9947954bc --- /dev/null +++ b/.changeset/warm-eagles-itch.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +Fixed misleading error message in the CLI when config file is missing ("maxDuration" is now required). A useful error message is now shown, including a hint about the `--config` flag. diff --git a/packages/cli-v3/src/config.ts b/packages/cli-v3/src/config.ts index 3e4d27d7a3..af5623e017 100644 --- a/packages/cli-v3/src/config.ts +++ b/packages/cli-v3/src/config.ts @@ -22,6 +22,7 @@ import { import { prettyWarning } from "./utilities/cliOutput.js"; import type { InstrumentationModuleDefinition } from "@opentelemetry/instrumentation"; import { builtinModules } from "node:module"; +import { OutroCommandError } from "./cli/common.js"; export type ResolveConfigOptions = { cwd?: string; @@ -162,6 +163,21 @@ async function resolveConfig( ? dirname(packageJsonPath) : cwd; + // `trigger.config` is the fallback value set by c12 + const missingConfigFile = !result.configFile || result.configFile === "trigger.config"; + + if (missingConfigFile) { + throw new OutroCommandError( + [ + "Couldn't find your trigger.config.ts file.", + "", + "Make sure you are in the directory of your Trigger.dev project, or specify the path to your config file using the `--config ` flag.", + "", + "Alternatively, you can initialize a new project using `npx trigger.dev@latest init`.", + ].join("\n") + ); + } + const config = "config" in result.config ? (result.config.config as TriggerConfig) : result.config;