-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
95 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { getAccessToken } from "@replay-cli/shared/authentication/getAccessToken"; | ||
import { getAuthInfo } from "@replay-cli/shared/graphql/getAuthInfo"; | ||
import { exitProcess } from "@replay-cli/shared/process/exitProcess"; | ||
import { dim, emphasize, highlight, link } from "@replay-cli/shared/theme"; | ||
import { registerCommand } from "../utils/commander/registerCommand"; | ||
import { name as packageName } from "../../package.json"; | ||
|
||
registerCommand("whoami", { | ||
checkForNpmUpdate: false, | ||
checkForRuntimeUpdate: false, | ||
requireAuthentication: false, | ||
}) | ||
.description("Display info about the current user") | ||
.action(info); | ||
|
||
const DOCS_URL = "https://docs.replay.io/reference/api-keys"; | ||
|
||
async function info() { | ||
const { accessToken, apiKeySource } = await getAccessToken(); | ||
if (accessToken) { | ||
const authInfo = await getAuthInfo(accessToken); | ||
|
||
if (apiKeySource) { | ||
console.log(`You are authenticated by API key ${dim(`(process.env.${apiKeySource})`)}`); | ||
console.log(""); | ||
if (authInfo.type === "user") { | ||
console.log(`This is a ${emphasize("personal")} API key`); | ||
console.log(`Recordings you upload are ${emphasize("private")} by default`); | ||
} else { | ||
console.log(`This is a ${emphasize("team")} API key`); | ||
console.log(`Recordings you upload are ${emphasize("shared with other team members")}`); | ||
} | ||
console.log(""); | ||
console.log(`Learn more about API keys at ${link(DOCS_URL)}`); | ||
} else { | ||
console.log( | ||
`You signed into your Replay account using an ${emphasize("email and password")}` | ||
); | ||
console.log(""); | ||
console.log(`Recordings you upload are ${emphasize("private")} by default`); | ||
console.log(""); | ||
console.log(`Learn about other ways to sign in at ${link(DOCS_URL)}`); | ||
} | ||
} else { | ||
console.log("You are not authenticated"); | ||
console.log(""); | ||
console.log(`Sign in by running ${highlight(`${packageName} login`)}`); | ||
console.log(""); | ||
console.log("You can also authenticate with an API key"); | ||
console.log(`Learn more at ${link(DOCS_URL)}`); | ||
} | ||
|
||
await exitProcess(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
packages/replayio/src/utils/initialization/checkAuthentication.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters