@@ -6,8 +6,8 @@ import * as toolcache from "@actions/tool-cache";
66import { pki } from "node-forge" ;
77
88import * as actionsUtil from "./actions-util" ;
9- import * as util from "./util" ;
109import { getActionsLogger , Logger } from "./logging" ;
10+ import * as util from "./util" ;
1111
1212const UPDATEJOB_PROXY = "update-job-proxy" ;
1313const UPDATEJOB_PROXY_VERSION = "v2.0.20240722180912" ;
@@ -100,7 +100,11 @@ async function runWrapper() {
100100
101101 // Get the configuration options
102102 const credentials = getCredentials ( logger ) ;
103- logger . info ( `Credentials loaded for the following registries:\n ${ credentials . map ( c => credentialToStr ( c ) ) . join ( "\n" ) } ` ) ;
103+ logger . info (
104+ `Credentials loaded for the following registries:\n ${ credentials
105+ . map ( ( c ) => credentialToStr ( c ) )
106+ . join ( "\n" ) } `,
107+ ) ;
104108
105109 const ca = generateCertificateAuthority ( ) ;
106110 const proxyAuth = getProxyAuth ( ) ;
@@ -116,7 +120,12 @@ async function runWrapper() {
116120 await startProxy ( proxyBin , proxyConfig , proxyLogFilePath , logger ) ;
117121}
118122
119- async function startProxy ( binPath : string , config : ProxyConfig , logFilePath : string , logger : Logger ) {
123+ async function startProxy (
124+ binPath : string ,
125+ config : ProxyConfig ,
126+ logFilePath : string ,
127+ logger : Logger ,
128+ ) {
120129 const host = "127.0.0.1" ;
121130 let port = 49152 ;
122131 try {
@@ -170,10 +179,12 @@ async function startProxy(binPath: string, config: ProxyConfig, logFilePath: str
170179// It prefers `registries_credentials` over `registry_secrets`.
171180// If neither is set, it returns an empty array.
172181function getCredentials ( logger : Logger ) : Credential [ ] {
173- const registriesCredentials = actionsUtil . getOptionalInput ( "registries_credentials" ) ;
182+ const registriesCredentials = actionsUtil . getOptionalInput (
183+ "registries_credentials" ,
184+ ) ;
174185 const registrySecrets = actionsUtil . getOptionalInput ( "registry_secrets" ) ;
175186
176- var credentialsStr : string ;
187+ let credentialsStr : string ;
177188 if ( registriesCredentials !== undefined ) {
178189 logger . info ( `Using registries_credentials input.` ) ;
179190 credentialsStr = Buffer . from ( registriesCredentials , "base64" ) . toString ( ) ;
@@ -187,36 +198,35 @@ function getCredentials(logger: Logger): Credential[] {
187198
188199 // Parse and validate the credentials
189200 const parsed = JSON . parse ( credentialsStr ) as Credential [ ] ;
190- let out : Credential [ ] = [ ]
191- parsed . forEach ( e => {
201+ const out : Credential [ ] = [ ] ;
202+ for ( const e of parsed ) {
192203 if ( e . url === undefined && e . host === undefined ) {
193- throw "Invalid credentials - must specify host or url"
204+ throw new Error ( "Invalid credentials - must specify host or url" ) ;
194205 }
195206 out . push ( {
196- type : e . type ,
197- host : e . host ,
198- url : e . url ,
199- username : e . username ,
200- password : e . password ,
201- token : e . token ,
202- } )
203- } ) ;
207+ type : e . type ,
208+ host : e . host ,
209+ url : e . url ,
210+ username : e . username ,
211+ password : e . password ,
212+ token : e . token ,
213+ } ) ;
214+ }
204215 return out ;
205216}
206217
207218// getProxyAuth returns the authentication information for the proxy itself.
208- function getProxyAuth ( ) : BasicAuthCredentials | undefined {
219+ function getProxyAuth ( ) : BasicAuthCredentials | undefined {
209220 const proxy_password = actionsUtil . getOptionalInput ( "proxy_password" ) ;
210221 if ( proxy_password ) {
211222 return {
212223 username : PROXY_USER ,
213224 password : proxy_password ,
214225 } ;
215226 }
216- return ;
227+ return ;
217228}
218229
219-
220230async function getProxyBinaryPath ( ) : Promise < string > {
221231 let proxyBin = toolcache . find ( UPDATEJOB_PROXY , UPDATEJOB_PROXY_VERSION ) ;
222232 if ( ! proxyBin ) {
@@ -233,8 +243,9 @@ async function getProxyBinaryPath(): Promise<string> {
233243}
234244
235245function credentialToStr ( c : Credential ) : string {
236- return `Type: ${ c . type } ; Host: ${ c . host } ; Url: ${ c . url } Username: ${ c . username } ; Password: ${ c . password !== undefined } ; Token: ${ c . token !== undefined } `
246+ return `Type: ${ c . type } ; Host: ${ c . host } ; Url: ${ c . url } Username: ${
247+ c . username
248+ } ; Password: ${ c . password !== undefined } ; Token: ${ c . token !== undefined } `;
237249}
238250
239-
240251void runWrapper ( ) ;
0 commit comments