From 0ca15989f39de137f77554a79c14d46972537aea Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 23 Sep 2025 16:42:45 +0800 Subject: [PATCH 1/7] fix(cli): ensure --profile option displays correct profile name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CLI was displaying "default" or the first profile instead of the actual profile being used when the --profile option was specified. This fix ensures consistent profile resolution and display throughout the whoami command. - Added profileToUse variable that correctly resolves the profile name - Use readAuthConfigCurrentProfileName() for default profile resolution - Ensure all messages display the same profile name consistently 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- packages/cli-v3/src/commands/whoami.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/cli-v3/src/commands/whoami.ts b/packages/cli-v3/src/commands/whoami.ts index 54c5c1dea0..83548051b7 100644 --- a/packages/cli-v3/src/commands/whoami.ts +++ b/packages/cli-v3/src/commands/whoami.ts @@ -16,6 +16,7 @@ import { spinner } from "../utilities/windows.js"; import { loadConfig } from "../config.js"; import { resolveLocalEnvVars } from "../utilities/localEnvVars.js"; import { tryCatch } from "@trigger.dev/core"; +import { readAuthConfigCurrentProfileName } from "../utilities/configFiles.js"; type WhoAmIResult = | { @@ -73,8 +74,10 @@ export async function whoAmI( embedded: boolean = false, silent: boolean = false ): Promise { + const profileToUse = options?.profile ?? readAuthConfigCurrentProfileName(); + if (!embedded) { - intro(`Displaying your account details [${options?.profile ?? "default"}]`); + intro(`Displaying your account details [${profileToUse}]`); } const envVars = resolveLocalEnvVars(options?.envFile); @@ -101,7 +104,7 @@ export async function whoAmI( loadingSpinner.start("Checking your account details"); } - const authentication = await isLoggedIn(options?.profile); + const authentication = await isLoggedIn(profileToUse); if (!authentication.ok) { if (authentication.error === "fetch failed") { @@ -110,15 +113,11 @@ export async function whoAmI( if (embedded) { !silent && loadingSpinner.stop( - `Failed to check account details. You may want to run \`trigger.dev logout --profile ${ - options?.profile ?? "default" - }\` and try again.` + `Failed to check account details. You may want to run \`trigger.dev logout --profile ${profileToUse}\` and try again.` ); } else { loadingSpinner.stop( - `You must login first. Use \`trigger.dev login --profile ${ - options?.profile ?? "default" - }\` to login.` + `You must login first. Use \`trigger.dev login --profile ${profileToUse}\` to login.` ); outro(`Whoami failed: ${authentication.error}`); } @@ -148,7 +147,7 @@ export async function whoAmI( `User ID: ${userData.data.userId} Email: ${userData.data.email} URL: ${chalkLink(authentication.auth.apiUrl)}`, - `Account details [${authentication.profile}]` + `Account details [${profileToUse}]` ); const { project } = userData.data; From 45c19a87708b2be7b667f121a7572b4b346a6249 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 23 Sep 2025 17:17:20 +0800 Subject: [PATCH 2/7] refactor: trim profile input and use logical OR for consistency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address CodeRabbit review feedback: - Use logical OR (||) instead of nullish coalescing (??) to handle empty strings - Trim profile input to handle accidental whitespace from CLI This ensures more robust profile resolution when users provide input with accidental leading/trailing spaces. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- packages/cli-v3/src/commands/whoami.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli-v3/src/commands/whoami.ts b/packages/cli-v3/src/commands/whoami.ts index 83548051b7..e49fd0a1da 100644 --- a/packages/cli-v3/src/commands/whoami.ts +++ b/packages/cli-v3/src/commands/whoami.ts @@ -74,7 +74,7 @@ export async function whoAmI( embedded: boolean = false, silent: boolean = false ): Promise { - const profileToUse = options?.profile ?? readAuthConfigCurrentProfileName(); + const profileToUse = options?.profile?.trim() || readAuthConfigCurrentProfileName(); if (!embedded) { intro(`Displaying your account details [${profileToUse}]`); From 449ee2d78107ddac711a38950ff768e92d6527d9 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 23 Sep 2025 17:48:44 +0800 Subject: [PATCH 3/7] docs: clarify profile resolution logic with detailed comments Explains how profile resolution works: - No --profile: uses Zod default (readAuthConfigCurrentProfileName) - With --profile: trims whitespace, falls back to current if empty - Current profile defaults to 'default' when no config exists --- packages/cli-v3/src/commands/whoami.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cli-v3/src/commands/whoami.ts b/packages/cli-v3/src/commands/whoami.ts index e49fd0a1da..d94a79301c 100644 --- a/packages/cli-v3/src/commands/whoami.ts +++ b/packages/cli-v3/src/commands/whoami.ts @@ -74,6 +74,9 @@ export async function whoAmI( embedded: boolean = false, silent: boolean = false ): Promise { + // When no --profile is passed, Zod schema defaults to readAuthConfigCurrentProfileName() + // which returns the current profile from config or "default" if none exists. + // If --profile is passed, we trim whitespace and fallback to current profile if empty. const profileToUse = options?.profile?.trim() || readAuthConfigCurrentProfileName(); if (!embedded) { From 7ea6c378387fb3dfb8639838e0ee42a4e1026335 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 23 Sep 2025 18:13:12 +0800 Subject: [PATCH 4/7] refactor: simplify profile resolution to align with codebase patterns - Rely on Zod schema default (readAuthConfigCurrentProfileName) for --profile fallback - Use consistent 'default' fallback pattern like other commands - Remove redundant readAuthConfigCurrentProfileName call - Maintain whitespace trimming for user input robustness --- packages/cli-v3/src/commands/whoami.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/cli-v3/src/commands/whoami.ts b/packages/cli-v3/src/commands/whoami.ts index d94a79301c..10c2fc6780 100644 --- a/packages/cli-v3/src/commands/whoami.ts +++ b/packages/cli-v3/src/commands/whoami.ts @@ -74,10 +74,9 @@ export async function whoAmI( embedded: boolean = false, silent: boolean = false ): Promise { - // When no --profile is passed, Zod schema defaults to readAuthConfigCurrentProfileName() - // which returns the current profile from config or "default" if none exists. - // If --profile is passed, we trim whitespace and fallback to current profile if empty. - const profileToUse = options?.profile?.trim() || readAuthConfigCurrentProfileName(); + // Profile is provided by Zod schema with default from readAuthConfigCurrentProfileName() + // Trim whitespace and fallback to "default" for consistency with other commands + const profileToUse = options?.profile?.trim() || "default"; if (!embedded) { intro(`Displaying your account details [${profileToUse}]`); From 74c87410d2dd0cf76ea05ac827f68904d77dd0ed Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 25 Sep 2025 19:19:48 +0800 Subject: [PATCH 5/7] fix(cli): fix header profile display to use --profile option According to @nicktrn's review: - Reverted unnecessary changes to whoami command (it was already working correctly) - Fixed the actual issue: header display in printInitialBanner() and printStandloneInitialBanner() - Now all commands pass their --profile option to the banner functions - Banner functions now correctly display the profile specified via --profile option This ensures the CLI header consistently shows the profile being used, whether it's the default or specified via --profile flag. --- packages/cli-v3/src/commands/analyze.ts | 3 ++- packages/cli-v3/src/commands/deploy.ts | 2 +- packages/cli-v3/src/commands/dev.ts | 2 +- packages/cli-v3/src/commands/env.ts | 6 +++--- packages/cli-v3/src/commands/init.ts | 2 +- packages/cli-v3/src/commands/login.ts | 2 +- packages/cli-v3/src/commands/logout.ts | 2 +- packages/cli-v3/src/commands/preview.ts | 2 +- packages/cli-v3/src/commands/promote.ts | 2 +- packages/cli-v3/src/commands/trigger.ts | 2 +- packages/cli-v3/src/commands/update.ts | 2 +- packages/cli-v3/src/commands/whoami.ts | 21 +++++++++---------- .../cli-v3/src/utilities/initialBanner.ts | 12 +++++------ 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/cli-v3/src/commands/analyze.ts b/packages/cli-v3/src/commands/analyze.ts index e8264f9336..70a8854f4a 100644 --- a/packages/cli-v3/src/commands/analyze.ts +++ b/packages/cli-v3/src/commands/analyze.ts @@ -13,6 +13,7 @@ import { tryCatch } from "@trigger.dev/core"; const AnalyzeOptions = CommonCommandOptions.pick({ logLevel: true, skipTelemetry: true, + profile: true, }).extend({ verbose: z.boolean().optional().default(false), }); @@ -39,7 +40,7 @@ export function configureAnalyzeCommand(program: Command) { export async function analyzeCommand(dir: string | undefined, options: unknown) { return await wrapCommandAction("analyze", AnalyzeOptions, options, async (opts) => { - await printInitialBanner(false); + await printInitialBanner(false, opts.profile); return await analyze(dir, opts); }); } diff --git a/packages/cli-v3/src/commands/deploy.ts b/packages/cli-v3/src/commands/deploy.ts index ce55379267..164b43c18a 100644 --- a/packages/cli-v3/src/commands/deploy.ts +++ b/packages/cli-v3/src/commands/deploy.ts @@ -145,7 +145,7 @@ export function configureDeployCommand(program: Command) { ) .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await deployCommand(path, options); }); }) diff --git a/packages/cli-v3/src/commands/dev.ts b/packages/cli-v3/src/commands/dev.ts index 3253fdc573..f1d8f0bc2f 100644 --- a/packages/cli-v3/src/commands/dev.ts +++ b/packages/cli-v3/src/commands/dev.ts @@ -203,7 +203,7 @@ async function startDev(options: StartDevOptions) { logger.loggerLevel = options.logLevel; } - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); let displayedUpdateMessage = false; diff --git a/packages/cli-v3/src/commands/env.ts b/packages/cli-v3/src/commands/env.ts index 7a21218754..ac9b5f774c 100644 --- a/packages/cli-v3/src/commands/env.ts +++ b/packages/cli-v3/src/commands/env.ts @@ -71,7 +71,7 @@ export function configureEnvCommand(program: Command) { ) ).action(async (options) => { await handleTelemetry(async () => { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); await envListCommand(options); }); }); @@ -95,7 +95,7 @@ export function configureEnvCommand(program: Command) { ).action(async (name, options) => { await handleTelemetry(async () => { if (!options.raw) { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); } await envGetCommand({ ...options, name }); }); @@ -120,7 +120,7 @@ export function configureEnvCommand(program: Command) { .option("--force", "Overwrite the output file if it exists") ).action(async (options) => { await handleTelemetry(async () => { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); await envPullCommand(options); }); }); diff --git a/packages/cli-v3/src/commands/init.ts b/packages/cli-v3/src/commands/init.ts index 9e7ca46697..82c4d0e4e0 100644 --- a/packages/cli-v3/src/commands/init.ts +++ b/packages/cli-v3/src/commands/init.ts @@ -98,7 +98,7 @@ export function configureInitCommand(program: Command) { ) .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await initCommand(path, options); }); }); diff --git a/packages/cli-v3/src/commands/login.ts b/packages/cli-v3/src/commands/login.ts index bba0a68804..f3b46405a7 100644 --- a/packages/cli-v3/src/commands/login.ts +++ b/packages/cli-v3/src/commands/login.ts @@ -50,7 +50,7 @@ export function configureLoginCommand(program: Command) { .version(VERSION, "-v, --version", "Display the version number") .action(async (options) => { await handleTelemetry(async () => { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); await loginCommand(options); }); }); diff --git a/packages/cli-v3/src/commands/logout.ts b/packages/cli-v3/src/commands/logout.ts index 6fefa5f634..26cc677500 100644 --- a/packages/cli-v3/src/commands/logout.ts +++ b/packages/cli-v3/src/commands/logout.ts @@ -18,7 +18,7 @@ export function configureLogoutCommand(program: Command) { return commonOptions(program.command("logout").description("Logout of Trigger.dev")).action( async (options) => { await handleTelemetry(async () => { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); await logoutCommand(options); }); } diff --git a/packages/cli-v3/src/commands/preview.ts b/packages/cli-v3/src/commands/preview.ts index 2dab147a51..598d4e9ef6 100644 --- a/packages/cli-v3/src/commands/preview.ts +++ b/packages/cli-v3/src/commands/preview.ts @@ -53,7 +53,7 @@ export function configurePreviewCommand(program: Command) { ) ).action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await previewArchiveCommand(path, options); }); }); diff --git a/packages/cli-v3/src/commands/promote.ts b/packages/cli-v3/src/commands/promote.ts index 59452c9ec2..3895891922 100644 --- a/packages/cli-v3/src/commands/promote.ts +++ b/packages/cli-v3/src/commands/promote.ts @@ -49,7 +49,7 @@ export function configurePromoteCommand(program: Command) { ) ).action(async (version, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await promoteCommand(version, options); }); }); diff --git a/packages/cli-v3/src/commands/trigger.ts b/packages/cli-v3/src/commands/trigger.ts index 1bf6425d6a..c030def80f 100644 --- a/packages/cli-v3/src/commands/trigger.ts +++ b/packages/cli-v3/src/commands/trigger.ts @@ -48,7 +48,7 @@ export function configureTriggerTaskCommand(program: Command) { export async function triggerTaskCommand(taskName: string, options: unknown) { return await wrapCommandAction("trigger", TriggerTaskOptions, options, async (opts) => { - await printInitialBanner(false); + await printInitialBanner(false, opts.profile); return await triggerTask(taskName, opts); }); } diff --git a/packages/cli-v3/src/commands/update.ts b/packages/cli-v3/src/commands/update.ts index f67e9bf7db..db27f7ed5f 100644 --- a/packages/cli-v3/src/commands/update.ts +++ b/packages/cli-v3/src/commands/update.ts @@ -35,7 +35,7 @@ export function configureUpdateCommand(program: Command) { .option("--skip-telemetry", "Opt-out of sending telemetry") .action(async (path, options) => { wrapCommandAction("dev", UpdateCommandOptions, options, async (opts) => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await updateCommand(path, opts); }); }); diff --git a/packages/cli-v3/src/commands/whoami.ts b/packages/cli-v3/src/commands/whoami.ts index 10c2fc6780..5f04eb67fb 100644 --- a/packages/cli-v3/src/commands/whoami.ts +++ b/packages/cli-v3/src/commands/whoami.ts @@ -16,7 +16,6 @@ import { spinner } from "../utilities/windows.js"; import { loadConfig } from "../config.js"; import { resolveLocalEnvVars } from "../utilities/localEnvVars.js"; import { tryCatch } from "@trigger.dev/core"; -import { readAuthConfigCurrentProfileName } from "../utilities/configFiles.js"; type WhoAmIResult = | { @@ -57,7 +56,7 @@ export function configureWhoamiCommand(program: Command) { ) ).action(async (options) => { await handleTelemetry(async () => { - await printInitialBanner(false); + await printInitialBanner(false, options.profile); await whoAmICommand(options); }); }); @@ -74,12 +73,8 @@ export async function whoAmI( embedded: boolean = false, silent: boolean = false ): Promise { - // Profile is provided by Zod schema with default from readAuthConfigCurrentProfileName() - // Trim whitespace and fallback to "default" for consistency with other commands - const profileToUse = options?.profile?.trim() || "default"; - if (!embedded) { - intro(`Displaying your account details [${profileToUse}]`); + intro(`Displaying your account details [${options?.profile ?? "default"}]`); } const envVars = resolveLocalEnvVars(options?.envFile); @@ -106,7 +101,7 @@ export async function whoAmI( loadingSpinner.start("Checking your account details"); } - const authentication = await isLoggedIn(profileToUse); + const authentication = await isLoggedIn(options?.profile); if (!authentication.ok) { if (authentication.error === "fetch failed") { @@ -115,11 +110,15 @@ export async function whoAmI( if (embedded) { !silent && loadingSpinner.stop( - `Failed to check account details. You may want to run \`trigger.dev logout --profile ${profileToUse}\` and try again.` + `Failed to check account details. You may want to run \`trigger.dev logout --profile ${ + options?.profile ?? "default" + }\` and try again.` ); } else { loadingSpinner.stop( - `You must login first. Use \`trigger.dev login --profile ${profileToUse}\` to login.` + `You must login first. Use \`trigger.dev login --profile ${ + options?.profile ?? "default" + }\` to login.` ); outro(`Whoami failed: ${authentication.error}`); } @@ -149,7 +148,7 @@ export async function whoAmI( `User ID: ${userData.data.userId} Email: ${userData.data.email} URL: ${chalkLink(authentication.auth.apiUrl)}`, - `Account details [${profileToUse}]` + `Account details [${authentication.profile}]` ); const { project } = userData.data; diff --git a/packages/cli-v3/src/utilities/initialBanner.ts b/packages/cli-v3/src/utilities/initialBanner.ts index 20f4735597..c7a50c1dfe 100644 --- a/packages/cli-v3/src/utilities/initialBanner.ts +++ b/packages/cli-v3/src/utilities/initialBanner.ts @@ -11,8 +11,8 @@ import { } from "./configFiles.js"; import { CLOUD_API_URL } from "../consts.js"; -function getProfileInfo() { - const currentProfile = readAuthConfigCurrentProfileName(); +function getProfileInfo(profileOption?: string) { + const currentProfile = profileOption ?? readAuthConfigCurrentProfileName(); const profile = readAuthConfigProfile(currentProfile); if (currentProfile === DEFFAULT_PROFILE || !profile) { @@ -24,8 +24,8 @@ function getProfileInfo() { }`; } -export async function printInitialBanner(performUpdateCheck = true) { - const profileInfo = getProfileInfo(); +export async function printInitialBanner(performUpdateCheck = true, profileOption?: string) { + const profileInfo = getProfileInfo(profileOption); const text = `\n${logo()} ${chalkGrey(`(${VERSION})`)}${ profileInfo ? chalkGrey(` | ${profileInfo}`) : "" @@ -62,8 +62,8 @@ After installation, run Trigger.dev with \`npx trigger.dev\`.` } } -export async function printStandloneInitialBanner(performUpdateCheck = true) { - const profileInfo = getProfileInfo(); +export async function printStandloneInitialBanner(performUpdateCheck = true, profileOption?: string) { + const profileInfo = getProfileInfo(profileOption); const profileText = profileInfo ? chalkGrey(` | ${profileInfo}`) : ""; let versionText = `\n${logo()} ${chalkGrey(`(${VERSION})`)}`; From d89ac4f81dad82e3dcae52194321f6068313e1bb Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 25 Sep 2025 19:46:57 +0800 Subject: [PATCH 6/7] fix(cli): also fix header profile display for worker commands Added profile parameter to printStandloneInitialBanner calls in: - workers/build.ts - workers/run.ts - workers/list.ts - workers/create.ts This ensures worker commands also display the correct profile in their headers when using --profile option. --- packages/cli-v3/src/commands/workers/build.ts | 2 +- packages/cli-v3/src/commands/workers/create.ts | 2 +- packages/cli-v3/src/commands/workers/list.ts | 2 +- packages/cli-v3/src/commands/workers/run.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli-v3/src/commands/workers/build.ts b/packages/cli-v3/src/commands/workers/build.ts index 960d94cdde..310c9268ec 100644 --- a/packages/cli-v3/src/commands/workers/build.ts +++ b/packages/cli-v3/src/commands/workers/build.ts @@ -121,7 +121,7 @@ export function configureWorkersBuildCommand(program: Command) { .option("--save-logs", "If provided, will save logs even for successful builds") .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await workersBuildCommand(path, options); }); }); diff --git a/packages/cli-v3/src/commands/workers/create.ts b/packages/cli-v3/src/commands/workers/create.ts index 9f93c7ad73..dd314439e6 100644 --- a/packages/cli-v3/src/commands/workers/create.ts +++ b/packages/cli-v3/src/commands/workers/create.ts @@ -40,7 +40,7 @@ export function configureWorkersCreateCommand(program: Command) { ) .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await workersCreateCommand(path, options); }); }) diff --git a/packages/cli-v3/src/commands/workers/list.ts b/packages/cli-v3/src/commands/workers/list.ts index ae4467a107..e2f89aef5a 100644 --- a/packages/cli-v3/src/commands/workers/list.ts +++ b/packages/cli-v3/src/commands/workers/list.ts @@ -39,7 +39,7 @@ export function configureWorkersListCommand(program: Command) { ) .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await workersListCommand(path, options); }); }) diff --git a/packages/cli-v3/src/commands/workers/run.ts b/packages/cli-v3/src/commands/workers/run.ts index f4e9ab7c55..87b7703c45 100644 --- a/packages/cli-v3/src/commands/workers/run.ts +++ b/packages/cli-v3/src/commands/workers/run.ts @@ -44,7 +44,7 @@ export function configureWorkersRunCommand(program: Command) { .option("--network ", "The networking mode for the container", "host") .action(async (path, options) => { await handleTelemetry(async () => { - await printStandloneInitialBanner(true); + await printStandloneInitialBanner(true, options.profile); await workersRunCommand(path, options); }); }) From 5173721ed1e08ff6122e4cf302ec32dc27f5df0d Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 25 Sep 2025 19:50:20 +0800 Subject: [PATCH 7/7] fix: restore INSTALLING case that was accidentally removed --- packages/cli-v3/src/commands/deploy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cli-v3/src/commands/deploy.ts b/packages/cli-v3/src/commands/deploy.ts index 164b43c18a..7821dc71d2 100644 --- a/packages/cli-v3/src/commands/deploy.ts +++ b/packages/cli-v3/src/commands/deploy.ts @@ -676,6 +676,7 @@ async function failDeploy( switch (serverDeployment.status) { case "PENDING": + case "INSTALLING": case "DEPLOYING": case "BUILDING": { await doOutputLogs();