You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: src/commands/login/index.ts
+25-12Lines changed: 25 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,6 @@ export const loginCommand = program
34
34
.option(
35
35
'-r, --region <region>',
36
36
`The region you would like to work in. Please keep in mind that the region must match the region of your space. This region flag will be used for the other cli's commands. You can use the values: ${allRegionsText}.`,
37
-
regions.EU,
38
37
)
39
38
.action(async(options: {
40
39
token: string;
@@ -46,10 +45,6 @@ export const loginCommand = program
46
45
// Command options
47
46
const{ token, region }=options;
48
47
49
-
if(!isRegion(region)){
50
-
handleError(newCommandError(`The provided region: ${region} is not valid. Please use one of the following values: ${Object.values(regions).join(' | ')}`));
@@ -59,17 +54,34 @@ export const loginCommand = program
59
54
return;
60
55
}
61
56
57
+
if(region&&!isRegion(region)){
58
+
handleError(newCommandError(`The provided region: ${region} is not valid. Please use one of the following values: ${Object.values(regions).join(' | ')}`));
59
+
return;
60
+
}
61
+
62
62
if(token){
63
63
constspinner=newSpinner({
64
64
verbose: !isVitest,
65
-
}).start(`Logging in with token`);
65
+
});
66
66
try{
67
-
const{ user }=awaitloginWithToken(token,region);
68
-
updateSession(user.email,token,region);
69
-
awaitpersistCredentials(region);
67
+
letuserRegion=region;
68
+
if(!userRegion){
69
+
userRegion=awaitselect({
70
+
message: 'Please select the region you would like to work in:',
const{ user }=awaitloginWithToken(token,userRegion);
80
+
updateSession(user.email,token,userRegion);
81
+
awaitpersistCredentials(userRegion);
70
82
spinner.succeed();
71
83
72
-
konsola.ok(`Successfully logged in. Welcome ${chalk.hex(colorPalette.PRIMARY)(user.friendly_name)}.`,true);
84
+
konsola.ok(`Successfully logged in to region ${chalk.hex(colorPalette.PRIMARY)(`${regionNames[userRegion]} (${userRegion})`)}. Welcome ${chalk.hex(colorPalette.PRIMARY)(user.friendly_name)}.`,true);
73
85
}
74
86
catch(error){
75
87
spinner.failed();
@@ -96,7 +108,7 @@ export const loginCommand = program
96
108
updateSession(user.email,userToken,region);
97
109
awaitpersistCredentials(region);
98
110
99
-
konsola.ok(`Successfully logged in. Welcome ${chalk.hex(colorPalette.PRIMARY)(user.friendly_name)}.`,true);
111
+
konsola.ok(`Successfully logged in to region ${chalk.hex(colorPalette.PRIMARY)(`${regionNames[region]} (${region})`)}. Welcome ${chalk.hex(colorPalette.PRIMARY)(user.friendly_name)}.`,true);
100
112
}
101
113
102
114
else{
@@ -123,6 +135,7 @@ export const loginCommand = program
@@ -143,7 +156,7 @@ export const loginCommand = program
143
156
}
144
157
awaitpersistCredentials(region);
145
158
146
-
konsola.ok(`Successfully logged in. Welcome ${chalk.hex(colorPalette.PRIMARY)(userEmail)}.`,true);
159
+
konsola.ok(`Successfully logged in to region ${chalk.hex(colorPalette.PRIMARY)(`${regionNames[userRegion]} (${userRegion})`)}. Welcome ${chalk.hex(colorPalette.PRIMARY)(userEmail)}.`,true);
0 commit comments