Skip to content

Commit

Permalink
fixing coloring issues CLI auth listings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexagod committed Jan 6, 2025
1 parent a355d91 commit 5d6448f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"cli-columns": "^4.0.0",
"cli-select": "^1.1.2",
"cli-table": "^0.3.11",
"commander": "^9.0.0",
"commander": "^13.0.0",
"cookie-session": "^2.0.0",
"cross-fetch": "^3.1.5",
"express": "^4.17.3",
Expand Down
20 changes: 10 additions & 10 deletions src/shell/commands/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async function showAuthenticationOption(options: any) {
let currentWebId = getConfigCurrentWebID();
if (options.pretty) {
let head = [
chalk.cyan.bold("WebID"),
chalk.cyan("WebID"),
"has auth token",
"has active session",
]
Expand All @@ -156,9 +156,9 @@ ${table.toString()}`
let activeSession = entries[webId]?.session
if (webId === currentWebId) console.log(
chalk.cyan.bold(webId),
entries[webId].hasToken ? `- ${chalk.bold('auth token')}` : "",
entries[webId].hasToken ? `- ${chalk('auth token')}` : "",
!!activeSession && !! activeSession.expirationDate &&
activeSession.expirationDate > new Date() ? `- ${chalk.bold('active session')}` : ""
activeSession.expirationDate > new Date() ? `- ${chalk('active session')}` : ""
)
}
}
Expand All @@ -177,7 +177,7 @@ async function listAuthenticationOptions(options: any) {
let entries = getAllConfigEntries();
for (let webId of Object.keys(entries)) {
let activeSession = entries[webId]?.session
table.push([webId, entries[webId].hasToken,
table.push([colorWebID(webId), entries[webId].hasToken,
!!activeSession && !! activeSession.expirationDate && activeSession.expirationDate > new Date()])
}
console.log(`
Expand Down Expand Up @@ -208,9 +208,9 @@ async function setAuthenticationOption(options: any) {
let entries = getAllConfigEntries();
let values: Record<string, string> = {}
let activeSession = entries[webId]?.session
values["cancel"] = `${chalk.bold.redBright("Cancel operation")}`
values["new"] = `${chalk.bold.blueBright("Authenticate using new WebID")}`
values["clear"] = `${chalk.bold.red("Clear current authentication option")}`
values["cancel"] = `${chalk.redBright("Cancel operation")}`
values["new"] = `${chalk.blueBright("Authenticate using new WebID")}`
values["clear"] = `${chalk.red("Clear current authentication option")}`
for (let webId of Object.keys(entries)) {
values[webId] =
`${colorWebID(webId)} ${entries[webId].hasToken ? `- ${chalk.bold("auth token")}` : ""} ${!!activeSession && !! activeSession?.expirationDate && activeSession.expirationDate > new Date() ? `- ${chalk.bold("active session")}` : ""}`
Expand Down Expand Up @@ -410,10 +410,10 @@ async function removeAuthenticationOption(options?: any) {
let entries = getAllConfigEntries();
let values: Record<string, string> = {}
let activeSession = entries[webId]?.session
values["all"] = `${chalk.bold.redBright("Delete all saved auth information (including tokens)")}`
values["all"] = `${chalk.redBright("Delete all saved auth information (including tokens)")}`
for (let webId of Object.keys(entries)) {
values[webId] =
`${colorWebID(webId)} ${entries[webId].hasToken ? `- ${chalk.bold("auth token")}` : ""} ${!!activeSession && !! activeSession?.expirationDate && activeSession.expirationDate > new Date() ? `- ${chalk.bold("active session")}` : ""}`
`${colorWebID(webId)} ${entries[webId].hasToken ? `- ${chalk("auth token")}` : ""} ${!!activeSession && !! activeSession?.expirationDate && activeSession.expirationDate > new Date() ? `- ${chalk("active session")}` : ""}`
}

let selected = await new Promise((resolve, reject) => {
Expand Down Expand Up @@ -447,5 +447,5 @@ async function removeAuthenticationOption(options?: any) {


function colorWebID(webId: string) {
return getConfigCurrentWebID() === webId ? chalk.bold.cyan(webId) : chalk.bold(webId)
return getConfigCurrentWebID() === webId ? chalk.bold(webId) : chalk(webId)
}

0 comments on commit 5d6448f

Please sign in to comment.