Skip to content

Commit

Permalink
feat(login) - bit login add option to pass custom login url (#7143)
Browse files Browse the repository at this point in the history
  • Loading branch information
guysaar223 committed Mar 13, 2023
1 parent 89d13a2 commit 4f83b70
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/api/consumer/lib/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default (async function loginAction(
suppressBrowserLaunch: boolean,
npmrcPath: string,
skipRegistryConfig: boolean,
machineName: string | null | undefined
machineName: string | null | undefined,
hubDomainLogin?: string
): Promise<{ isAlreadyLoggedIn?: boolean; username?: string; npmrcPath?: string }> {
return loginToBitSrc(port, suppressBrowserLaunch, npmrcPath, skipRegistryConfig, machineName);
return loginToBitSrc(port, suppressBrowserLaunch, npmrcPath, skipRegistryConfig, machineName, hubDomainLogin);
});
13 changes: 9 additions & 4 deletions src/cli/commands/public-cmds/login-cmd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class Login implements LegacyCommand {
alias = '';
skipWorkspace = true;
opts = [
['d', 'hub-domain-login <url>', 'hub domain login url (default https://bit.cloud)'],
['p', 'port <port>', 'port number to open for localhost server (default 8085)'],
['', 'suppress-browser-launch', 'do not open a browser for authentication'],
['', 'npmrc-path <path>', `path to npmrc file to configure ${getCloudDomain()} registry`],
Expand All @@ -25,23 +26,27 @@ export default class Login implements LegacyCommand {
action(
[], // eslint-disable-line no-empty-pattern
{
hubDomainLogin,
port,
suppressBrowserLaunch = false,
npmrcPath,
skipRegistryConfig = false,
machineName,
}: {
hubDomainLogin?: string;
port: string;
suppressBrowserLaunch?: boolean;
npmrcPath: string;
skipRegistryConfig: boolean;
machineName?: string;
}
): Promise<any> {
return login(port, suppressBrowserLaunch, npmrcPath, skipRegistryConfig, machineName).then((results) => ({
...results,
skipRegistryConfig,
}));
return login(port, suppressBrowserLaunch, npmrcPath, skipRegistryConfig, machineName, hubDomainLogin).then(
(results) => ({
...results,
skipRegistryConfig,
})
);
}
report({
isAlreadyLoggedIn = false,
Expand Down
5 changes: 3 additions & 2 deletions src/consumer/login/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function loginToBitSrc(
suppressBrowserLaunch: boolean,
npmrcPath: string,
skipRegistryConfig: boolean,
machineName: string | null | undefined
machineName: string | null | undefined,
hubDomainLogin?: string
): Promise<{
isAlreadyLoggedIn?: boolean;
username?: string;
Expand Down Expand Up @@ -115,7 +116,7 @@ export default function loginToBitSrc(
}

const encoded = encodeURI(
`${getSync(CFG_HUB_LOGIN_KEY) || DEFAULT_HUB_LOGIN}?port=${
`${hubDomainLogin || getSync(CFG_HUB_LOGIN_KEY) || DEFAULT_HUB_LOGIN}?port=${
port || DEFAULT_PORT
}&clientId=${clientGeneratedId}&responseType=token&deviceName=${machineName || os.hostname()}&os=${
process.platform
Expand Down

0 comments on commit 4f83b70

Please sign in to comment.