Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wet-steaks-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trigger.dev": patch
---

If you pass a directory when calling deploy we validate it exists and give helpful hints
20 changes: 19 additions & 1 deletion packages/cli-v3/src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down