Skip to content

Commit 852ff58

Browse files
committed
re-format using pretter
1 parent b53b990 commit 852ff58

File tree

5 files changed

+60
-60
lines changed

5 files changed

+60
-60
lines changed

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"printWidth": 100
3+
}

lib/accounts.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import autocomplete from "inquirer-autocomplete-prompt";
44
import { buildError } from "./error.js";
55
import { listAccounts, listAccountRoles, getRoleCredentials, createAWSClient } from "./aws.js";
66

7-
const prompt = inquirer.createPromptModule({ output: process.stderr })
7+
const prompt = inquirer.createPromptModule({ output: process.stderr });
88
prompt.registerPrompt("autocomplete", autocomplete);
99

1010
export const chooseAccount = async (accessToken, region) => {
@@ -17,11 +17,15 @@ export const chooseAccount = async (accessToken, region) => {
1717
pageSize: 20,
1818
source: (result, input) => {
1919
return input
20-
? fuse.search(input).map((result) => `${result.item.accountName} (${result.item.accountId})`)
20+
? fuse
21+
.search(input)
22+
.map((result) => `${result.item.accountName} (${result.item.accountId})`)
2123
: accounts.map((account) => `${account.accountName} (${account.accountId})`);
2224
},
2325
});
24-
return accounts.find((account) => `${account.accountName} (${account.accountId})` === answer.account);
26+
return accounts.find(
27+
(account) => `${account.accountName} (${account.accountId})` === answer.account
28+
);
2529
};
2630

2731
export const chooseRole = async (accessToken, accountId, region) => {

lib/auth.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import open from "open";
2-
import chalk from "chalk"
2+
import chalk from "chalk";
33
import readline from "readline";
44
import { createAWSClient, registerClient, startDeviceAuthorization, createToken } from "./aws.js";
55

66
const keypress = async (keyName) => {
7-
console.error('\n', chalk.bold.green(`Press ${keyName.toUpperCase()} to continue`));
7+
console.error("\n", chalk.bold.green(`Press ${keyName.toUpperCase()} to continue`));
88
process.stdin.resume();
99
readline.emitKeypressEvents(process.stdin);
1010
return new Promise((resolve) =>
@@ -51,9 +51,10 @@ export const refreshCredentials = async (config, forceNewToken = false) => {
5151
? await requestClient(AWSClient)
5252
: config.client;
5353

54-
const token = forceNewToken || !isValid(config?.token?.tokenExpiresAt)
55-
? await requestToken(client, config.startUrl, AWSClient)
56-
: config.token;
54+
const token =
55+
forceNewToken || !isValid(config?.token?.tokenExpiresAt)
56+
? await requestToken(client, config.startUrl, AWSClient)
57+
: config.token;
5758

5859
return { ...config, client, token };
5960
};

lib/error.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,17 @@ export const handleError = (error) => {
99
console.error(
1010
"Error: Profile not found in config. Add it using the 'add-profile' command first."
1111
);
12-
}
13-
else if (error.code === "ERR_NO_PROFILE") {
12+
} else if (error.code === "ERR_NO_PROFILE") {
1413
console.error("Error: No profile found. Add one first using the 'add-profile' command.");
15-
}
16-
else if (error.code === "ERR_ACCOUNT_NOT_FOUND") {
14+
} else if (error.code === "ERR_ACCOUNT_NOT_FOUND") {
1715
console.error(
1816
"Error: The specified account name could not be found within your SSO directory."
1917
);
20-
}
21-
else if (error.code === "ERR_ROLE_NOT_FOUND") {
18+
} else if (error.code === "ERR_ROLE_NOT_FOUND") {
2219
console.error("Error: The specified role could not be found for the specified AWS account.");
23-
}
24-
else if (error.code === "ERR_GET_SIGNIN_URL") {
20+
} else if (error.code === "ERR_GET_SIGNIN_URL") {
2521
console.error(error.message);
26-
}
27-
else {
22+
} else {
2823
console.error(error);
2924
}
3025
process.exit(1);

lib/profiles.js

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import inquirer from "inquirer";
22
import autocomplete from "inquirer-autocomplete-prompt";
33
import { buildError } from "./error.js";
44

5-
const prompt = inquirer.createPromptModule({ output: process.stderr })
5+
const prompt = inquirer.createPromptModule({ output: process.stderr });
66
prompt.registerPrompt("autocomplete", autocomplete);
77

8-
98
const regions = [
109
"us-east-2",
1110
"us-east-1",
@@ -33,52 +32,50 @@ const regions = [
3332
];
3433

3534
export const addProfile = (configstore) =>
36-
prompt([
37-
{
38-
type: "input",
39-
name: "profileName",
40-
message: "Name of your SSO profile:",
35+
prompt([
36+
{
37+
type: "input",
38+
name: "profileName",
39+
message: "Name of your SSO profile:",
40+
},
41+
{
42+
type: "autocomplete",
43+
name: "region",
44+
message: "Select the region where your AWS SSO service is running.",
45+
source: (result, input) => {
46+
return regions.filter((str) => str.includes(input || ""));
4147
},
42-
{
43-
type: "autocomplete",
44-
name: "region",
45-
message: "Select the region where your AWS SSO service is running.",
46-
source: (result, input) => {
47-
return regions.filter((str) => str.includes(input || ""));
48-
},
48+
},
49+
{
50+
type: "input",
51+
name: "startUrl",
52+
message: "Your SSO start URL (e.g. https://<your-alias>.awsapps.com/start):",
53+
validate: (value) => {
54+
return value.match(/^https?:\/\/\w+\.awsapps.com\/start$/g) ? true : "Invalid start URL.";
4955
},
50-
{
51-
type: "input",
52-
name: "startUrl",
53-
message: "Your SSO start URL (e.g. https://<your-alias>.awsapps.com/start):",
54-
validate: (value) => {
55-
return value.match(/^https?:\/\/\w+\.awsapps.com\/start$/g) ? true : "Invalid start URL.";
56-
},
56+
},
57+
]).then(({ profileName, region, startUrl }) => {
58+
configstore.set({
59+
[profileName]: {
60+
region: region,
61+
startUrl: startUrl,
5762
},
58-
])
59-
.then(({ profileName, region, startUrl }) => {
60-
configstore.set({
61-
[profileName]: {
62-
region: region,
63-
startUrl: startUrl,
64-
},
65-
});
6663
});
64+
});
6765

6866
export const deleteProfile = (configstore) =>
69-
prompt({
70-
type: "list",
71-
name: "profile",
72-
message: "Select the profile you with to remove.",
73-
choices: Object.keys(configstore.all),
74-
})
75-
.then(({ profile }) => {
76-
console.error(profile);
77-
if (!(profile in configstore.all)) {
78-
throw buildError("ERR_INVALID_PROFILE");
79-
}
80-
configstore.delete(profile);
81-
});
67+
prompt({
68+
type: "list",
69+
name: "profile",
70+
message: "Select the profile you with to remove.",
71+
choices: Object.keys(configstore.all),
72+
}).then(({ profile }) => {
73+
console.error(profile);
74+
if (!(profile in configstore.all)) {
75+
throw buildError("ERR_INVALID_PROFILE");
76+
}
77+
configstore.delete(profile);
78+
});
8279

8380
export const chooseProfile = async (configstore) => {
8481
if (!configstore || !Object.keys(configstore.all).length) {

0 commit comments

Comments
 (0)