MCPcopy
hub / github.com/triggerdotdev/trigger.dev / whoAmI

Function whoAmI

packages/cli-v3/src/commands/whoami.ts:52–117  ·  view source on GitHub ↗
(
  options?: WhoamiCommandOptions,
  embedded: boolean = false
)

Source from the content-addressed store, hash-verified

50}
51
52export async function whoAmI(
53 options?: WhoamiCommandOptions,
54 embedded: boolean = false
55): Promise<WhoAmIResult> {
56 if (!embedded) {
57 intro(`Displaying your account details [${options?.profile ?? "default"}]`);
58 }
59
60 const loadingSpinner = spinner();
61 loadingSpinner.start("Checking your account details");
62
63 const authentication = await isLoggedIn(options?.profile);
64
65 if (!authentication.ok) {
66 if (authentication.error === "fetch failed") {
67 loadingSpinner.stop("Fetch failed. Platform down?");
68 } else {
69 if (embedded) {
70 loadingSpinner.stop(
71 `Failed to check account details. You may want to run \`trigger.dev logout --profile ${
72 options?.profile ?? "default"
73 }\` and try again.`
74 );
75 } else {
76 loadingSpinner.stop(
77 `You must login first. Use \`trigger.dev login --profile ${
78 options?.profile ?? "default"
79 }\` to login.`
80 );
81 outro(`Whoami failed: ${authentication.error}`);
82 }
83 }
84
85 return {
86 success: false,
87 error: authentication.error,
88 };
89 }
90
91 const apiClient = new CliApiClient(authentication.auth.apiUrl, authentication.auth.accessToken);
92 const userData = await apiClient.whoAmI();
93
94 if (!userData.success) {
95 loadingSpinner.stop("Error getting your account details");
96 logger.error(userData.error);
97 return {
98 success: false,
99 error: userData.error,
100 };
101 }
102
103 if (!embedded) {
104 loadingSpinner.stop("Retrieved your account details");
105 note(
106 `User ID: ${userData.data.userId}
107Email: ${userData.data.email}
108URL: ${chalkLink(authentication.auth.apiUrl)}
109`,

Callers 2

whoAmICommandFunction · 0.85
loginFunction · 0.85

Calls 7

whoAmIMethod · 0.95
spinnerFunction · 0.85
isLoggedInFunction · 0.85
chalkLinkFunction · 0.85
errorMethod · 0.65
startMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…