Skip to content

Commit 0ca1598

Browse files
hongkongkiwiclaude
andcommitted
fix(cli): ensure --profile option displays correct profile name
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 <[email protected]>
1 parent 49728b5 commit 0ca1598

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/cli-v3/src/commands/whoami.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { spinner } from "../utilities/windows.js";
1616
import { loadConfig } from "../config.js";
1717
import { resolveLocalEnvVars } from "../utilities/localEnvVars.js";
1818
import { tryCatch } from "@trigger.dev/core";
19+
import { readAuthConfigCurrentProfileName } from "../utilities/configFiles.js";
1920

2021
type WhoAmIResult =
2122
| {
@@ -73,8 +74,10 @@ export async function whoAmI(
7374
embedded: boolean = false,
7475
silent: boolean = false
7576
): Promise<WhoAmIResult> {
77+
const profileToUse = options?.profile ?? readAuthConfigCurrentProfileName();
78+
7679
if (!embedded) {
77-
intro(`Displaying your account details [${options?.profile ?? "default"}]`);
80+
intro(`Displaying your account details [${profileToUse}]`);
7881
}
7982

8083
const envVars = resolveLocalEnvVars(options?.envFile);
@@ -101,7 +104,7 @@ export async function whoAmI(
101104
loadingSpinner.start("Checking your account details");
102105
}
103106

104-
const authentication = await isLoggedIn(options?.profile);
107+
const authentication = await isLoggedIn(profileToUse);
105108

106109
if (!authentication.ok) {
107110
if (authentication.error === "fetch failed") {
@@ -110,15 +113,11 @@ export async function whoAmI(
110113
if (embedded) {
111114
!silent &&
112115
loadingSpinner.stop(
113-
`Failed to check account details. You may want to run \`trigger.dev logout --profile ${
114-
options?.profile ?? "default"
115-
}\` and try again.`
116+
`Failed to check account details. You may want to run \`trigger.dev logout --profile ${profileToUse}\` and try again.`
116117
);
117118
} else {
118119
loadingSpinner.stop(
119-
`You must login first. Use \`trigger.dev login --profile ${
120-
options?.profile ?? "default"
121-
}\` to login.`
120+
`You must login first. Use \`trigger.dev login --profile ${profileToUse}\` to login.`
122121
);
123122
outro(`Whoami failed: ${authentication.error}`);
124123
}
@@ -148,7 +147,7 @@ export async function whoAmI(
148147
`User ID: ${userData.data.userId}
149148
Email: ${userData.data.email}
150149
URL: ${chalkLink(authentication.auth.apiUrl)}`,
151-
`Account details [${authentication.profile}]`
150+
`Account details [${profileToUse}]`
152151
);
153152

154153
const { project } = userData.data;

0 commit comments

Comments
 (0)