@@ -21,9 +21,9 @@ export interface Token {
21
21
const promptForAuthMethod = async ( ) => {
22
22
const authChoiceNetlify = 'Authorize with GitHub through app.netlify.com'
23
23
const authChoiceToken = 'Authorize with a GitHub personal access token'
24
- const authChoices = [ authChoiceNetlify , authChoiceToken ]
24
+ const authChoices = [ authChoiceNetlify , authChoiceToken ] as const
25
25
26
- const { authMethod } = await inquirer . prompt ( [
26
+ const { authMethod } = await inquirer . prompt < { authMethod : typeof authChoices [ number ] } > ( [
27
27
{
28
28
type : 'list' ,
29
29
name : 'authMethod' ,
@@ -53,7 +53,7 @@ export const authWithNetlify = async (): Promise<Token> => {
53
53
`${
54
54
"<html><head><title>Logged in</title><script>if(history.replaceState){history.replaceState({},'','/')}</script><style>html{font-family:system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';line-height:1.5;background:rgb(18 24 31)}body{overflow:hidden;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;width:100vw;}h3{margin:0}p{margin: 1rem 0 0.5rem}.card{position:relative;display:flex;flex-direction:column;width:75%;max-width:364px;padding:24px;background:white;color:rgb(18 24 31);border-radius:8px;box-shadow:rgb(6 11 16 / 20%) 0px 16px 24px, rgb(6 11 16 / 30%) 0px 6px 30px, rgb(6 11 16 / 40%) 0px 8px 10px;}</style></head>" +
55
55
"<body><div class=card><h3>Logged in</h3><p>You're now logged into Netlify CLI with your "
56
- } ${ parameters . get ( 'provider' ) } credentials. Please close this window.</p></div>`,
56
+ } ${ parameters . get ( 'provider' ) ?? '' } credentials. Please close this window.</p></div>`,
57
57
)
58
58
server . close ( )
59
59
return
@@ -70,9 +70,9 @@ export const authWithNetlify = async (): Promise<Token> => {
70
70
} )
71
71
} )
72
72
73
- const webUI = process . env . NETLIFY_WEB_UI || 'https://app.netlify.com'
73
+ const webUI = process . env . NETLIFY_WEB_UI ?? 'https://app.netlify.com'
74
74
const urlParams = new URLSearchParams ( {
75
- host : `http://localhost:${ port } ` ,
75
+ host : `http://localhost:${ port . toString ( ) } ` ,
76
76
provider : 'github' ,
77
77
} )
78
78
const url = `${ webUI } /cli?${ urlParams . toString ( ) } `
@@ -82,13 +82,13 @@ export const authWithNetlify = async (): Promise<Token> => {
82
82
return deferredPromise
83
83
}
84
84
85
- const getPersonalAccessToken = async ( ) => {
86
- const { token } = await inquirer . prompt ( [
85
+ const getPersonalAccessToken = async ( ) : Promise < { token : string } > => {
86
+ const { token } = await inquirer . prompt < { token : string } > ( [
87
87
{
88
88
type : 'password' ,
89
89
name : 'token' ,
90
90
message : 'Your GitHub personal access token:' ,
91
- filter : ( input ) => input . trim ( ) ,
91
+ filter : ( input : string ) => input . trim ( ) ,
92
92
} ,
93
93
] )
94
94
@@ -105,8 +105,9 @@ const authWithToken = async (): Promise<Token> => {
105
105
}
106
106
107
107
const octokit = new Octokit ( { auth : `token ${ token } ` } )
108
- // @ts -expect-error -- XXX(serhalp): actual bug - fixed in stacked PR
109
- const { login : user } = await octokit . users . getAuthenticated ( )
108
+ const {
109
+ data : { login : user } ,
110
+ } = await octokit . users . getAuthenticated ( )
110
111
111
112
return { token, user, provider : 'github' }
112
113
}
0 commit comments