Skip to content

Commit c960ff9

Browse files
brijeshb42Copilot
andcommitted
Update packages/code-infra/src/utils/github.mjs
Co-authored-by: Copilot <[email protected]> Signed-off-by: Brijesh Bittu <[email protected]>
1 parent 336ae05 commit c960ff9

File tree

3 files changed

+85
-22
lines changed

3 files changed

+85
-22
lines changed

packages/code-infra/src/cli/cmdGithubAuth.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
2525
const gh = await import('../utils/github.mjs');
2626
if (args.clear) {
2727
await gh.clearGitHubAuth();
28-
console.log('✅ GitHub authentication cleared');
28+
console.log('✅ GitHub auth tokens cleared.');
2929
return;
3030
}
3131
if (args.authorize) {
3232
await gh.endToEndGhAuthGetToken(true);
33-
console.log('✅ GitHub authentication successful');
33+
console.log('✅ GitHub auth tokens successfully retrieved.');
3434
}
3535
},
3636
});

packages/code-infra/src/utils/github.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export const ERRORS = {
3737
TIMEOUT: 'TIMEOUT',
3838
};
3939

40+
const ONE_MINUTE = 60 * 1000;
41+
4042
export function persistentAuthStrategy() {
4143
function createCachedToken() {
4244
/**
@@ -53,8 +55,8 @@ export function persistentAuthStrategy() {
5355
const now = Date.now();
5456
timeSinceAccess += now - lastAccess;
5557
lastAccess = now;
56-
// Reset token if it has been more than 5 minutes since last access
57-
if (timeSinceAccess > 1 * 60 * 1000) {
58+
// Reset token if it has been more than a minute since last access
59+
if (timeSinceAccess > ONE_MINUTE) {
5860
timeSinceAccess = 0;
5961
token = '';
6062
}
@@ -104,11 +106,11 @@ export function persistentAuthStrategy() {
104106
* @param {string} data.code
105107
* @param {Object} options
106108
* @param {boolean} [options.openInBrowser=true] - Whether to open the URL in the default browser
107-
* @param {boolean} [options.copyToCliboard=true] - Whether to copy the code to clipboard
109+
* @param {boolean} [options.copyToClipboard=true] - Whether to copy the code to clipboard
108110
* @returns {Promise<void>}
109111
*/
110-
async function logAuthInformation(data, { openInBrowser = true, copyToCliboard = true } = {}) {
111-
if (copyToCliboard) {
112+
async function logAuthInformation(data, { openInBrowser = true, copyToClipboard = true } = {}) {
113+
if (copyToClipboard) {
112114
await clipboardy.write(data.code);
113115
console.warn(`Pasted authentication code ${data.code} to system clipboard...`);
114116
} else {

pnpm-lock.yaml

Lines changed: 76 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)