33
44const originalEmitWarning = process . emitWarning ;
55process . emitWarning = ( warning , ...args ) => {
6- const message = typeof warning === 'string' ? warning : warning ?. message || '' ;
6+ const message =
7+ typeof warning === 'string' ? warning : warning ?. message || '' ;
78
8- if ( message . includes ( 'DEPRECATION WARNING' ) ) {
9- return ;
10- }
11- // If not the BoxClient deprecation warning, call the original emitWarning function
12- originalEmitWarning . call ( process , warning , ...args ) ;
9+ if ( message . includes ( 'DEPRECATION WARNING' ) ) {
10+ return ;
11+ }
12+ // If not the BoxClient deprecation warning, call the original emitWarning function
13+ originalEmitWarning . call ( process , warning , ...args ) ;
1314} ;
1415
1516const { Command, Flags } = require ( '@oclif/core' ) ;
@@ -367,7 +368,10 @@ class BoxCommand extends Command {
367368 } catch ( err ) {
368369 // In bulk mode, we don't want to write directly to console and kill the command
369370 // Instead, we should buffer the error output so subsequent commands might be able to succeed
370- DEBUG . execute ( 'Caught error from bulk input entry %d' , bulkEntryIndex ) ;
371+ DEBUG . execute (
372+ 'Caught error from bulk input entry %d' ,
373+ bulkEntryIndex
374+ ) ;
371375 this . bulkErrors . push ( {
372376 index : bulkEntryIndex ,
373377 data : bulkData ,
@@ -391,7 +395,9 @@ class BoxCommand extends Command {
391395 _handleBulkErrors ( ) {
392396 const numErrors = this . bulkErrors . length ;
393397 if ( numErrors === 0 ) {
394- this . info ( chalk `{green All bulk input entries processed successfully.}` ) ;
398+ this . info (
399+ chalk `{green All bulk input entries processed successfully.}`
400+ ) ;
395401 return ;
396402 }
397403 this . info (
@@ -409,7 +415,11 @@ class BoxCommand extends Command {
409415 ) ;
410416 let err = errorInfo . error ;
411417 let contextInfo ;
412- if ( err . response && err . response . body && err . response . body . context_info ) {
418+ if (
419+ err . response &&
420+ err . response . body &&
421+ err . response . body . context_info
422+ ) {
413423 contextInfo = formatObject ( err . response . body . context_info ) ;
414424 // Remove color codes from context info
415425 // eslint-disable-next-line no-control-regex
@@ -536,7 +546,9 @@ class BoxCommand extends Command {
536546 ) ;
537547 }
538548 // Filter out any undefined values, which can arise when the input file contains extraneous keys
539- bulkCalls = bulkCalls . map ( ( args ) => args . filter ( ( o ) => o !== undefined ) ) ;
549+ bulkCalls = bulkCalls . map ( ( args ) =>
550+ args . filter ( ( o ) => o !== undefined )
551+ ) ;
540552 DEBUG . execute (
541553 'Read %d entries from bulk file %s' ,
542554 bulkCalls . length ,
@@ -622,7 +634,8 @@ class BoxCommand extends Command {
622634 // @NOTE : For now, we only support nesting keys this way one level deep
623635 return Object . keys ( value ) . map ( ( nestedKey ) => {
624636 let nestedMatchKey =
625- matchKey + nestedKey . toLowerCase ( ) . replace ( / [ - _ ] / gu, '' ) ;
637+ matchKey +
638+ nestedKey . toLowerCase ( ) . replace ( / [ - _ ] / gu, '' ) ;
626639 let nestedField = fieldMapping [ nestedMatchKey ] ;
627640 return nestedField
628641 ? { ...nestedField , value : value [ nestedKey ] }
@@ -632,7 +645,10 @@ class BoxCommand extends Command {
632645 // Arrays can be one of two things: an array of values for a single key,
633646 // or an array of grouped flags/args as objects
634647 // First, check if everything in the array is either all object or all non-object
635- let types = value . reduce ( ( acc , t ) => acc . concat ( typeof t ) , [ ] ) ;
648+ let types = value . reduce (
649+ ( acc , t ) => acc . concat ( typeof t ) ,
650+ [ ]
651+ ) ;
636652 if (
637653 types . some ( ( t ) => t !== 'object' ) &&
638654 types . some ( ( t ) => t === 'object' )
@@ -647,7 +663,9 @@ class BoxCommand extends Command {
647663 return value . map ( ( o ) => flattenObjectToArgs ( o ) ) ;
648664 }
649665 // If the array is of values for this field, just return those
650- return field ? value . map ( ( v ) => ( { ...field , value : v } ) ) : [ ] ;
666+ return field
667+ ? value . map ( ( v ) => ( { ...field , value : v } ) )
668+ : [ ] ;
651669 }
652670 return field ? { ...field , value } : undefined ;
653671 } ) ;
@@ -752,9 +770,14 @@ class BoxCommand extends Command {
752770
753771 let configObj ;
754772 try {
755- configObj = JSON . parse ( fs . readFileSync ( environment . boxConfigFilePath ) ) ;
773+ configObj = JSON . parse (
774+ fs . readFileSync ( environment . boxConfigFilePath )
775+ ) ;
756776 } catch ( ex ) {
757- throw new BoxCLIError ( 'Could not read environments config file' , ex ) ;
777+ throw new BoxCLIError (
778+ 'Could not read environments config file' ,
779+ ex
780+ ) ;
758781 }
759782
760783 const { enterpriseID } = configObj ;
@@ -817,17 +840,20 @@ class BoxCommand extends Command {
817840 : new CLITokenCache ( environmentsObj . default ) ;
818841 let configObj ;
819842 try {
820- configObj = JSON . parse ( fs . readFileSync ( environment . boxConfigFilePath ) ) ;
843+ configObj = JSON . parse (
844+ fs . readFileSync ( environment . boxConfigFilePath )
845+ ) ;
821846 } catch ( ex ) {
822- throw new BoxCLIError ( 'Could not read environments config file' , ex ) ;
847+ throw new BoxCLIError (
848+ 'Could not read environments config file' ,
849+ ex
850+ ) ;
823851 }
824852
825853 if ( ! environment . hasInLinePrivateKey ) {
826854 try {
827- configObj . boxAppSettings . appAuth . privateKey = fs . readFileSync (
828- environment . privateKeyPath ,
829- 'utf8'
830- ) ;
855+ configObj . boxAppSettings . appAuth . privateKey =
856+ fs . readFileSync ( environment . privateKeyPath , 'utf8' ) ;
831857 DEBUG . init (
832858 'Loaded JWT private key from %s' ,
833859 environment . privateKeyPath
@@ -915,9 +941,14 @@ class BoxCommand extends Command {
915941
916942 let configObj ;
917943 try {
918- configObj = JSON . parse ( fs . readFileSync ( environment . boxConfigFilePath ) ) ;
944+ configObj = JSON . parse (
945+ fs . readFileSync ( environment . boxConfigFilePath )
946+ ) ;
919947 } catch ( ex ) {
920- throw new BoxCLIError ( 'Could not read environments config file' , ex ) ;
948+ throw new BoxCLIError (
949+ 'Could not read environments config file' ,
950+ ex
951+ ) ;
921952 }
922953
923954 const { enterpriseID } = configObj ;
@@ -932,13 +963,13 @@ class BoxCommand extends Command {
932963 clientSecret,
933964 userId : ccgUser ,
934965 tokenStorage : tokenCache ,
935- }
966+ }
936967 : {
937968 clientId,
938969 clientSecret,
939970 enterpriseId : enterpriseID ,
940971 tokenStorage : tokenCache ,
941- }
972+ }
942973 ) ;
943974 let ccgAuth = new BoxTSSDK . BoxCcgAuth ( { config : ccgConfig } ) ;
944975 client = new BoxTSSDK . BoxClient ( {
@@ -984,17 +1015,20 @@ class BoxCommand extends Command {
9841015 : new CLITokenCache ( environmentsObj . default ) ;
9851016 let configObj ;
9861017 try {
987- configObj = JSON . parse ( fs . readFileSync ( environment . boxConfigFilePath ) ) ;
1018+ configObj = JSON . parse (
1019+ fs . readFileSync ( environment . boxConfigFilePath )
1020+ ) ;
9881021 } catch ( ex ) {
989- throw new BoxCLIError ( 'Could not read environments config file' , ex ) ;
1022+ throw new BoxCLIError (
1023+ 'Could not read environments config file' ,
1024+ ex
1025+ ) ;
9901026 }
9911027
9921028 if ( ! environment . hasInLinePrivateKey ) {
9931029 try {
994- configObj . boxAppSettings . appAuth . privateKey = fs . readFileSync (
995- environment . privateKeyPath ,
996- 'utf8'
997- ) ;
1030+ configObj . boxAppSettings . appAuth . privateKey =
1031+ fs . readFileSync ( environment . privateKeyPath , 'utf8' ) ;
9981032 DEBUG . init (
9991033 'Loaded JWT private key from %s' ,
10001034 environment . privateKeyPath
@@ -1012,7 +1046,8 @@ class BoxCommand extends Command {
10121046 clientSecret : configObj . boxAppSettings . clientSecret ,
10131047 jwtKeyId : configObj . boxAppSettings . appAuth . publicKeyID ,
10141048 privateKey : configObj . boxAppSettings . appAuth . privateKey ,
1015- privateKeyPassphrase : configObj . boxAppSettings . appAuth . passphrase ,
1049+ privateKeyPassphrase :
1050+ configObj . boxAppSettings . appAuth . passphrase ,
10161051 enterpriseId : environment . enterpriseId ,
10171052 tokenStorage : tokenCache ,
10181053 } ) ;
@@ -1130,9 +1165,8 @@ class BoxCommand extends Command {
11301165 this . settings . enableAnalyticsClient &&
11311166 this . settings . analyticsClient . name
11321167 ) {
1133- additionalHeaders [
1134- 'X-Box-UA'
1135- ] = `${ DEFAULT_ANALYTICS_CLIENT_NAME } ${ this . settings . analyticsClient . name } ` ;
1168+ additionalHeaders [ 'X-Box-UA' ] =
1169+ `${ DEFAULT_ANALYTICS_CLIENT_NAME } ${ this . settings . analyticsClient . name } ` ;
11361170 } else {
11371171 additionalHeaders [ 'X-Box-UA' ] = DEFAULT_ANALYTICS_CLIENT_NAME ;
11381172 }
@@ -1162,9 +1196,14 @@ class BoxCommand extends Command {
11621196 // Format each object individually and then flatten in case this an array of arrays,
11631197 // which happens when a command that outputs a collection gets run in bulk
11641198 formattedOutputData = _ . flatten (
1165- await Promise . all ( content . map ( ( o ) => this . _formatOutputObject ( o ) ) )
1199+ await Promise . all (
1200+ content . map ( ( o ) => this . _formatOutputObject ( o ) )
1201+ )
1202+ ) ;
1203+ DEBUG . output (
1204+ 'Formatted %d output entries for display' ,
1205+ content . length
11661206 ) ;
1167- DEBUG . output ( 'Formatted %d output entries for display' , content . length ) ;
11681207 } else {
11691208 formattedOutputData = await this . _formatOutputObject ( content ) ;
11701209 DEBUG . output ( 'Formatted output content for display' ) ;
@@ -1205,12 +1244,17 @@ class BoxCommand extends Command {
12051244 await this . logStream ( stringifiedOutput ) ;
12061245 } ;
12071246 } else {
1208- stringifiedOutput = await this . _stringifyOutput ( formattedOutputData ) ;
1247+ stringifiedOutput =
1248+ await this . _stringifyOutput ( formattedOutputData ) ;
12091249
12101250 writeFunc = async ( savePath ) => {
1211- await utils . writeFileAsync ( savePath , stringifiedOutput + os . EOL , {
1212- encoding : 'utf8' ,
1213- } ) ;
1251+ await utils . writeFileAsync (
1252+ savePath ,
1253+ stringifiedOutput + os . EOL ,
1254+ {
1255+ encoding : 'utf8' ,
1256+ }
1257+ ) ;
12141258 } ;
12151259
12161260 logFunc = ( ) => this . log ( stringifiedOutput ) ;
@@ -1254,7 +1298,9 @@ class BoxCommand extends Command {
12541298 while ( ! entry . done ) {
12551299 output . push ( entry . value ) ;
12561300
1257- if ( this . maxItemsReached ( this . flags [ 'max-items' ] , output . length ) ) {
1301+ if (
1302+ this . maxItemsReached ( this . flags [ 'max-items' ] , output . length )
1303+ ) {
12581304 break ;
12591305 }
12601306
@@ -1326,7 +1372,9 @@ class BoxCommand extends Command {
13261372 return csvString . replace ( / \r ? \n $ / u, '' ) ;
13271373 } else if ( Array . isArray ( outputData ) ) {
13281374 let str = outputData
1329- . map ( ( o ) => `${ formatObjectHeader ( o ) } ${ os . EOL } ${ formatObject ( o ) } ` )
1375+ . map (
1376+ ( o ) => `${ formatObjectHeader ( o ) } ${ os . EOL } ${ formatObject ( o ) } `
1377+ )
13301378 . join ( os . EOL . repeat ( 2 ) ) ;
13311379 DEBUG . output ( 'Processed collection into human-readable output' ) ;
13321380 return str ;
@@ -1558,7 +1606,11 @@ class BoxCommand extends Command {
15581606 return ;
15591607 }
15601608 let contextInfo ;
1561- if ( err . response && err . response . body && err . response . body . context_info ) {
1609+ if (
1610+ err . response &&
1611+ err . response . body &&
1612+ err . response . body . context_info
1613+ ) {
15621614 contextInfo = formatObject ( err . response . body . context_info ) ;
15631615 // Remove color codes from context info
15641616 // eslint-disable-next-line no-control-regex
@@ -1668,7 +1720,10 @@ class BoxCommand extends Command {
16681720 let keys = [ ] ;
16691721 if ( typeof object === 'object' ) {
16701722 for ( let key in object ) {
1671- if ( typeof object [ key ] === 'object' && ! Array . isArray ( object [ key ] ) ) {
1723+ if (
1724+ typeof object [ key ] === 'object' &&
1725+ ! Array . isArray ( object [ key ] )
1726+ ) {
16721727 let subKeys = this . getNestedKeys ( object [ key ] ) ;
16731728 subKeys = subKeys . map ( ( x ) => `${ key } .${ x } ` ) ;
16741729 keys = keys . concat ( subKeys ) ;
@@ -1859,11 +1914,21 @@ class BoxCommand extends Command {
18591914 DEBUG . init ( 'Created config folder at %s' , CONFIG_FOLDER_PATH ) ;
18601915 }
18611916 if ( ! fs . existsSync ( ENVIRONMENTS_FILE_PATH ) ) {
1862- await this . updateEnvironments ( { } , this . _getDefaultEnvironments ( ) ) ;
1863- DEBUG . init ( 'Created environments config at %s' , ENVIRONMENTS_FILE_PATH ) ;
1917+ await this . updateEnvironments (
1918+ { } ,
1919+ this . _getDefaultEnvironments ( )
1920+ ) ;
1921+ DEBUG . init (
1922+ 'Created environments config at %s' ,
1923+ ENVIRONMENTS_FILE_PATH
1924+ ) ;
18641925 }
18651926 if ( ! fs . existsSync ( SETTINGS_FILE_PATH ) ) {
1866- let settingsJSON = JSON . stringify ( this . _getDefaultSettings ( ) , null , 4 ) ;
1927+ let settingsJSON = JSON . stringify (
1928+ this . _getDefaultSettings ( ) ,
1929+ null ,
1930+ 4
1931+ ) ;
18671932 fs . writeFileSync ( SETTINGS_FILE_PATH , settingsJSON , 'utf8' ) ;
18681933 DEBUG . init (
18691934 'Created settings file at %s %O' ,
@@ -1872,7 +1937,10 @@ class BoxCommand extends Command {
18721937 ) ;
18731938 }
18741939 } catch ( ex ) {
1875- throw new BoxCLIError ( 'Could not initialize CLI home directory' , ex ) ;
1940+ throw new BoxCLIError (
1941+ 'Could not initialize CLI home directory' ,
1942+ ex
1943+ ) ;
18761944 }
18771945
18781946 let settings ;
@@ -1917,7 +1985,10 @@ class BoxCommand extends Command {
19171985 */
19181986 _getDefaultSettings ( ) {
19191987 return {
1920- boxReportsFolderPath : path . join ( os . homedir ( ) , 'Documents/Box-Reports' ) ,
1988+ boxReportsFolderPath : path . join (
1989+ os . homedir ( ) ,
1990+ 'Documents/Box-Reports'
1991+ ) ,
19211992 boxReportsFileFormat : 'txt' ,
19221993 boxDownloadsFolderPath : path . join (
19231994 os . homedir ( ) ,
0 commit comments