@@ -9,27 +9,22 @@ import {
99 ShouldApplyWithReason ,
1010} from '@app/unraid-api/unraid-file-modifier/file-modification' ;
1111
12- const WEB_COMPS_DIR = '/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/_nuxt/' as const ;
13-
14- const getJsFiles = async ( dir : string ) => {
15- const { glob } = await import ( 'glob' ) ;
16- const files = await glob ( `${ dir } /**/*.js` ) ;
17- return files . map ( ( file ) => file . replace ( '/usr/local/emhttp' , '' ) ) ;
18- } ;
19-
2012export default class AuthRequestModification extends FileModification {
2113 public filePath : string = '/usr/local/emhttp/auth-request.php' ;
14+ public webComponentsDirectory : string =
15+ '/usr/local/emhttp/plugins/dynamix.my.servers/unraid-components/_nuxt/' as const ;
2216 id : string = 'auth-request' ;
2317
24- constructor ( logger : Logger ) {
25- super ( logger ) ;
26- }
27-
18+ private getJsFiles = async ( dir : string ) => {
19+ const { glob } = await import ( 'glob' ) ;
20+ const files = await glob ( `${ dir } /**/*.js` ) ;
21+ return files . map ( ( file ) => file . replace ( '/usr/local/emhttp' , '' ) ) ;
22+ } ;
2823 protected async generatePatch ( ) : Promise < string > {
29- const JS_FILES = await getJsFiles ( WEB_COMPS_DIR ) ;
30- this . logger . debug ( `Found ${ JS_FILES . length } .js files in ${ WEB_COMPS_DIR } ` ) ;
24+ const jsFiles = await this . getJsFiles ( this . webComponentsDirectory ) ;
25+ this . logger . debug ( `Found ${ jsFiles . length } .js files in ${ this . webComponentsDirectory } ` ) ;
3126
32- const FILES_TO_ADD = [ '/webGui/images/partner-logo.svg' , ...JS_FILES ] ;
27+ const filesToAdd = [ '/webGui/images/partner-logo.svg' , ...jsFiles ] ;
3328
3429 if ( ! existsSync ( this . filePath ) ) {
3530 throw new Error ( `File ${ this . filePath } not found.` ) ;
@@ -41,7 +36,7 @@ export default class AuthRequestModification extends FileModification {
4136 throw new Error ( `$arrWhitelist array not found in the file.` ) ;
4237 }
4338
44- const filesToAddString = FILES_TO_ADD . map ( ( file ) => ` '${ file } ',` ) . join ( '\n' ) ;
39+ const filesToAddString = filesToAdd . map ( ( file ) => ` '${ file } ',` ) . join ( '\n' ) ;
4540
4641 // Create new content by finding the array declaration and adding our files after it
4742 const newContent = fileContent . replace ( / ( \$ a r r W h i t e l i s t \s * = \s * \[ ) / , `$1\n${ filesToAddString } ` ) ;
0 commit comments