/** Represents the settings needed to launch a dockerized shadowbox. */ export interface ShadowboxSettings { imageId : string ; metricsUrl : string ; sentryApiUrl ? : string ; watchtowerRefreshSeconds ? : number ; } export function getShellExportCommands ( settings , serverName ) { const variables = { 'SB_IMAGE' : settings . imageId , 'WATCHTOWER_REFRESH_SECONDS' : settings . watchtowerRefreshSeconds , 'SENTRY_API_URL' : settings . sentryApiUrl , 'SB_METRICS_URL' : settings . metricsUrl , } ; const lines = [ ] ; for ( const name in variables ) { if ( variables [ name ] ) { lines . push ( `export ${ name }='${ variables [ name ] }'` ) ; } } lines . push ( `export SB_DEFAULT_SERVER_NAME="$(printf '${ bashEscape ( serverName ) }')"` ) ; return lines . join ( '\n' ) + '\n' ; } function bashEscape ( s ) { return s . replace ( /\P{ASCII}/gu , c => '\\u' + c . charCodeAt ( 0 ) . toString ( 16 ) . padStart ( 4 , '0' ) ) ; }