Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: saml-to/cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.27
Choose a base ref
...
head repository: saml-to/cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b8ddde22dd295513fee6937d2ff438a45f2f2f9c
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jan 17, 2022

  1. update awaits

    cnuss committed Jan 17, 2022
    Copy the full SHA
    b8ddde2 View commit details
Showing with 39 additions and 31 deletions.
  1. +6 −2 cli/index.ts
  2. +17 −22 src/command.ts
  3. +16 −7 src/helpers/browserHelper.ts
8 changes: 6 additions & 2 deletions cli/index.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@ import { Command } from '../src/command';

(async () => {
const command = new Command(process.argv);
await command.run(process.argv);
process.exit(0);
try {
await command.run(process.argv);
process.exit(0);
} catch (e) {
process.exit(-1);
}
})();
39 changes: 17 additions & 22 deletions src/command.ts
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ export class Command {
.command({
command: 'list-logins',
describe: `Show providers that are available to login`,
handler: async ({ org, provider, refresh }) =>
handler: ({ org, provider, refresh }) =>
loginWrapper(this.messagesHelper, 'user:email', () =>
this.show.handle(
'logins' as ShowSubcommands,
@@ -113,7 +113,7 @@ export class Command {
.command({
command: 'list-roles',
describe: `Show roles that are available to assume`,
handler: async ({ org, provider, refresh }) =>
handler: ({ org, provider, refresh }) =>
loginWrapper(this.messagesHelper, 'user:email', () =>
this.show.handle(
'roles' as ShowSubcommands,
@@ -146,7 +146,7 @@ export class Command {
.command({
command: 'login [provider]',
describe: `Login to a provider`,
handler: async ({ org, provider }) =>
handler: ({ org, provider }) =>
loginWrapper(this.messagesHelper, 'user:email', () =>
this.login.handle(provider as string | undefined, org as string | undefined),
),
@@ -166,7 +166,7 @@ export class Command {
.command({
command: 'assume [role]',
describe: 'Assume a role',
handler: async ({ role, org, provider, headless }) =>
handler: ({ role, org, provider, headless }) =>
loginWrapper(this.messagesHelper, 'user:email', () =>
this.assume.handle(
role as string,
@@ -202,9 +202,7 @@ export class Command {
.command({
command: 'init',
describe: '(Administrative) Initialize SAML.to with a GitHub Repository',
handler: async ({ force }) => {
await this.init.handle(force as boolean | undefined);
},
handler: ({ force }) => this.init.handle(force as boolean | undefined),
builder: {
force: {
demand: false,
@@ -216,7 +214,7 @@ export class Command {
.command({
command: 'add [type] [name]',
describe: '(Administrative) Add providers or permissions to the configuration',
handler: async ({
handler: ({
type,
name,
entityId,
@@ -226,8 +224,8 @@ export class Command {
nameIdFormat,
role,
attribute,
}) => {
await loginWrapper(this.messagesHelper, 'repo', () =>
}) =>
loginWrapper(this.messagesHelper, 'repo', () =>
this.add.handle(
type as AddSubcommands,
name as string | undefined,
@@ -239,8 +237,7 @@ export class Command {
role as string | undefined,
attribute as AddAttributes | undefined,
),
);
},
),
builder: {
type: {
demand: true,
@@ -312,8 +309,8 @@ export class Command {
.command({
command: 'set [name] [subcommand]',
describe: '(Administrative) Set a provider setting (e.g. provisioning)',
handler: async ({ name, subcommand, type, endpoint, token }) => {
await loginWrapper(this.messagesHelper, 'repo', () =>
handler: ({ name, subcommand, type, endpoint, token }) =>
loginWrapper(this.messagesHelper, 'repo', () =>
this.set.handle(
subcommand as SetSubcommands,
name as string,
@@ -323,8 +320,7 @@ export class Command {
token: token as string | undefined,
} as SetHandleOpts,
),
);
},
),
builder: {
name: {
demand: true,
@@ -353,18 +349,17 @@ export class Command {
.command({
command: 'show [subcommand]',
describe: `(Administrative) Show various configurations (metadata, certificate, entityId, config, etc.)`,
handler: async ({ org, provider, subcommand, save, refresh, raw }) => {
await loginWrapper(this.messagesHelper, 'user:email', async () => {
await this.show.handle(
handler: ({ org, provider, subcommand, save, refresh, raw }) =>
loginWrapper(this.messagesHelper, 'user:email', async () =>
this.show.handle(
subcommand as ShowSubcommands,
org as string | undefined,
provider as string | undefined,
save as boolean | undefined,
refresh as boolean | undefined,
raw as boolean | undefined,
);
});
},
),
),
builder: {
subcommand: {
demand: true,
23 changes: 16 additions & 7 deletions src/helpers/browserHelper.ts
Original file line number Diff line number Diff line change
@@ -8,16 +8,25 @@ export const openBrowser = (url: string): Promise<void> => {
open(url, {
wait,
}).then((proc) => {
if (process.platform === 'win32') {
proc.addListener('close', () => {
resolve();
});
return;
} else if (wait && proc.exitCode !== 0) {
if (wait && proc.exitCode !== 0) {
ui.updateBottomBar('');
console.log(url);
resolve();
} else {
console.log(`Browser opened to ${new URL(url).origin}`);
resolve();
}
// if (process.platform === 'win32') {
// proc.addListener('close', () => {
// resolve();
// });
// return;
// } else if (wait && proc.exitCode !== 0) {
// console.log(url);
// resolve();
// } else {
// console.log(`Browser opened to ${new URL(url).origin}`);
// resolve();
// }
});
});
};