Skip to content

Commit c9f6799

Browse files
feat: added login verbose option (#2338)
1 parent e75718a commit c9f6799

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

.changeset/strong-moles-beg.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@redocly/openapi-core": patch
3+
"@redocly/cli": patch
4+
---
5+
6+
Added support for the `verbose` option in the `login` command to provide additional output during authentication.

packages/cli/src/auth/oauth-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class RedoclyOAuthClient {
3636

3737
const credentials = await deviceFlow.run();
3838
if (!credentials) {
39-
throw new Error('Failed to login');
39+
throw new Error('Failed to login. No credentials received.');
4040
}
4141
this.saveCredentials(credentials);
4242
}

packages/cli/src/commands/auth.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@ import type { CommandArgs } from '../wrapper.js';
88
export type LoginArgv = {
99
residency?: string;
1010
config?: string;
11+
verbose?: boolean;
1112
};
1213

1314
export async function handleLogin({ argv, config }: CommandArgs<LoginArgv>) {
1415
const reuniteUrl = getReuniteUrl(config, argv.residency);
1516
try {
1617
const oauthClient = new RedoclyOAuthClient();
18+
19+
if (argv.verbose) {
20+
logger.info(`OAuth client initialized.\n`);
21+
logger.info(`Local credentials file path: ${oauthClient.credentialsFilePath}\n`);
22+
}
23+
1724
await oauthClient.login(reuniteUrl);
18-
} catch {
25+
} catch (error) {
26+
if (argv.verbose) {
27+
logger.error(`Residency: ${argv.residency}.\n`);
28+
logger.error(`Login URL: ${reuniteUrl}.\n`);
29+
logger.error(error.stack || error.message);
30+
}
31+
1932
if (argv.residency) {
2033
exitWithError(`❌ Connection to ${reuniteUrl} failed.`);
2134
} else {

packages/cli/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ yargs(hideBin(process.argv))
490490
requiresArg: true,
491491
type: 'string',
492492
},
493+
verbose: {
494+
alias: 'v',
495+
describe: 'Apply verbose mode.',
496+
type: 'boolean',
497+
},
493498
}),
494499
(argv) => {
495500
commandWrapper(handleLogin)(argv);

0 commit comments

Comments
 (0)