@@ -14,7 +14,11 @@ import {
1414 wrapCommandAction ,
1515} from "../cli/common.js" ;
1616import { chalkLink , prettyError } from "../utilities/cliOutput.js" ;
17- import { readAuthConfigProfile , writeAuthConfigProfile } from "../utilities/configFiles.js" ;
17+ import {
18+ readAuthConfigProfile ,
19+ writeAuthConfigProfile ,
20+ writeAuthConfigCurrentProfileName ,
21+ } from "../utilities/configFiles.js" ;
1822import { printInitialBanner } from "../utilities/initialBanner.js" ;
1923import { LoginResult } from "../utilities/session.js" ;
2024import { whoAmI } from "./whoami.js" ;
@@ -264,6 +268,11 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
264268 throw new Error ( whoAmIResult . error ) ;
265269 }
266270
271+ const profileName = options ?. profile ?? "default" ;
272+
273+ // Set this profile as the current default
274+ writeAuthConfigCurrentProfileName ( profileName ) ;
275+
267276 if ( opts . embedded ) {
268277 log . step ( "Logged in successfully" ) ;
269278 } else {
@@ -274,7 +283,7 @@ export async function login(options?: LoginOptions): Promise<LoginResult> {
274283
275284 return {
276285 ok : true as const ,
277- profile : options ?. profile ?? "default" ,
286+ profile : profileName ,
278287 userId : whoAmIResult . data . userId ,
279288 email : whoAmIResult . data . email ,
280289 dashboardUrl : whoAmIResult . data . dashboardUrl ,
0 commit comments