From d3c10afe70469bc228de7bd9a8e49c33e409a37f Mon Sep 17 00:00:00 2001 From: Matt Aitken Date: Thu, 1 May 2025 19:29:00 +0100 Subject: [PATCH] Give helpful hint if you pass a bad directory when deploying --- .changeset/wet-steaks-reflect.md | 5 +++++ packages/cli-v3/src/commands/deploy.ts | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .changeset/wet-steaks-reflect.md diff --git a/.changeset/wet-steaks-reflect.md b/.changeset/wet-steaks-reflect.md new file mode 100644 index 0000000000..3a77741689 --- /dev/null +++ b/.changeset/wet-steaks-reflect.md @@ -0,0 +1,5 @@ +--- +"trigger.dev": patch +--- + +If you pass a directory when calling deploy we validate it exists and give helpful hints diff --git a/packages/cli-v3/src/commands/deploy.ts b/packages/cli-v3/src/commands/deploy.ts index 224cf7d1a9..35042c6c1b 100644 --- a/packages/cli-v3/src/commands/deploy.ts +++ b/packages/cli-v3/src/commands/deploy.ts @@ -34,6 +34,7 @@ import { spinner } from "../utilities/windows.js"; import { login } from "./login.js"; import { updateTriggerPackages } from "./update.js"; import { setGithubActionsOutputAndEnvVars } from "../utilities/githubActions.js"; +import { isDirectory } from "../utilities/fileSystem.js"; const DeployCommandOptions = CommonCommandOptions.extend({ dryRun: z.boolean().default(false), @@ -168,7 +169,24 @@ async function _deployCommand(dir: string, options: DeployCommandOptions) { await updateTriggerPackages(dir, { ...options }, true, true); } - const projectPath = resolve(process.cwd(), dir); + const cwd = process.cwd(); + const projectPath = resolve(cwd, dir); + + if (dir !== "." && !isDirectory(projectPath)) { + if (dir === "staging" || dir === "prod") { + throw new Error(`To deploy to ${dir}, you need to pass "--env ${dir}", not just "${dir}".`); + } + + if (dir === "production") { + throw new Error(`To deploy to production, you need to pass "--env prod", not "production".`); + } + + if (dir === "stg") { + throw new Error(`To deploy to staging, you need to pass "--env staging", not "stg".`); + } + + throw new Error(`Directory "${dir}" not found at ${projectPath}`); + } const authorization = await login({ embedded: true,