@@ -71,9 +71,9 @@ function isFulfilled<T>(result: PromiseSettledResult<T>): result is PromiseFulfi
7171}
7272
7373function notifyWatcherIssue ( limit ) {
74- afLogger . info ( 'Ran out of file handles after watching %s files.' , limit ) ;
75- afLogger . info ( 'Falling back to polling which uses more CPU.' ) ;
76- afLogger . info ( 'Run ulimit -n 10000 to increase the limit for open files.' ) ;
74+ console . log ( 'Ran out of file handles after watching %s files.' , limit ) ;
75+ console . log ( 'Falling back to polling which uses more CPU.' ) ;
76+ console . log ( 'Run ulimit -n 10000 to increase the limit for open files.' ) ;
7777}
7878
7979class CodeInjector implements ICodeInjector {
@@ -128,7 +128,7 @@ class CodeInjector implements ICodeInjector {
128128 }
129129
130130 cleanup ( ) {
131- afLogger . info ( 'Cleaning up...' ) ;
131+ console . log ( 'Cleaning up...' ) ;
132132 this . allWatchers . forEach ( ( watcher ) => {
133133 watcher . removeAll ( ) ;
134134 } ) ;
@@ -178,10 +178,10 @@ class CodeInjector implements ICodeInjector {
178178 // On Windows, npm/pnpm is npm/pnpm.cmd, on Unix systems it's npm/pnpm
179179 let packageExecutable
180180 if ( doesUserHavePnpmLock ) {
181- afLogger . trace ( `User has pnpm-lock.yaml, using pnpm for installing custom components` ) ;
181+ process . env . HEAVY_DEBUG && console . log ( `User has pnpm-lock.yaml, using pnpm for installing custom components` ) ;
182182 packageExecutable = process . platform === 'win32' ? 'pnpm.cmd' : 'pnpm' ;
183183 } else {
184- afLogger . trace ( `User does not have pnpm-lock.yaml, falling back to npm for installing custom components` ) ;
184+ process . env . HEAVY_DEBUG && console . log ( `User does not have pnpm-lock.yaml, falling back to npm for installing custom components` ) ;
185185 packageExecutable = process . platform === 'win32' ? 'npm.cmd' : 'npm' ;
186186 }
187187 const packagePath = path . join ( path . dirname ( nodeBinary ) , packageExecutable ) ; // Path to the package executable
@@ -193,8 +193,8 @@ class CodeInjector implements ICodeInjector {
193193 ...envOverrides ,
194194 } ;
195195
196- afLogger . trace ( `⚙️ exec: ${ packageExecutable } ${ command } ` ) ;
197- afLogger . trace ( `🪲 ${ packageExecutable } ${ command } cwd: ${ cwd } ` ) ;
196+ process . env . HEAVY_DEBUG && console . log ( `⚙️ exec: ${ packageExecutable } ${ command } ` ) ;
197+ process . env . HEAVY_DEBUG && console . log ( `🪲 ${ packageExecutable } ${ command } cwd: ${ cwd } ` ) ;
198198
199199 let execCommand : string ;
200200 if ( process . platform === 'win32' ) {
@@ -218,10 +218,10 @@ class CodeInjector implements ICodeInjector {
218218 }
219219
220220 const { stderr : err } = await execAsync ( execCommand , execOptions ) ;
221- afLogger . trace ( `${ packageExecutable } ${ command } done in` ) ;
221+ process . env . HEAVY_DEBUG && console . log ( `${ packageExecutable } ${ command } done in` ) ;
222222
223223 if ( err ) {
224- afLogger . trace ( `🪲${ packageExecutable } ${ command } errors/warnings: ${ err } ` ) ;
224+ process . env . HEAVY_DEBUG && console . log ( `🪲${ packageExecutable } ${ command } errors/warnings: ${ err } ` ) ;
225225 }
226226 }
227227
@@ -340,7 +340,7 @@ class CodeInjector implements ICodeInjector {
340340 dereference : true , // needed to dereference types
341341 // preserveTimestamps: true, // needed to not invalidate any caches
342342 } ) ;
343- afLogger . trace ( `🪲⚙️ fsExtra.copy copy single file, ${ src } , ${ dest } ` ) ;
343+ process . env . HEAVY_DEBUG && console . log ( `🪲⚙️ fsExtra.copy copy single file, ${ src } , ${ dest } ` ) ;
344344 } ) ) ;
345345 }
346346 async migrateLegacyCustomLayout ( oldMeta ) {
@@ -445,7 +445,7 @@ class CodeInjector implements ICodeInjector {
445445 registerSettingPages ( this . adminforth . config . auth . userMenuSettingsPages ) ;
446446 const spaDir = this . getSpaDir ( ) ;
447447
448- afLogger . trace ( `🪲⚙️ fsExtra.copy from ${ spaDir } -> ${ this . spaTmpPath ( ) } ` ) ;
448+ process . env . HEAVY_DEBUG && console . log ( `🪲⚙️ fsExtra.copy from ${ spaDir } -> ${ this . spaTmpPath ( ) } ` ) ;
449449
450450 // try to rm <spa tmp path>/src/types directory
451451 try {
@@ -462,7 +462,7 @@ class CodeInjector implements ICodeInjector {
462462 const filterPasses = ! src . includes ( `${ path . sep } adminforth${ path . sep } spa${ path . sep } node_modules` ) && ! src . includes ( `${ path . sep } adminforth${ path . sep } spa${ path . sep } dist` )
463463 && ! src . includes ( `${ path . sep } dist${ path . sep } spa${ path . sep } node_modules` ) && ! src . includes ( `${ path . sep } dist${ path . sep } spa${ path . sep } dist` ) ;
464464 if ( ! filterPasses ) {
465- afLogger . trace ( `🪲⚙️ fsExtra.copy filtered out, ${ src } ` ) ;
465+ process . env . HEAVY_DEBUG && console . log ( `🪲⚙️ fsExtra.copy filtered out, ${ src } ` ) ;
466466 }
467467
468468 return filterPasses
@@ -491,7 +491,7 @@ class CodeInjector implements ICodeInjector {
491491
492492 for ( const [ src , dest ] of Object . entries ( this . srcFoldersToSync ) ) {
493493 const to = path . join ( this . spaTmpPath ( ) , 'src' , 'custom' , dest ) ;
494- afLogger . trace ( `🪲⚙️ srcFoldersToSync: fsExtra.copy from ${ src } , ${ to } ` ) ;
494+ process . env . HEAVY_DEBUG && console . log ( `🪲⚙️ srcFoldersToSync: fsExtra.copy from ${ src } , ${ to } ` ) ;
495495
496496 await fsExtra . copy ( src , to , {
497497 recursive : true ,
@@ -751,7 +751,7 @@ class CodeInjector implements ICodeInjector {
751751
752752 // for every installed plugin generate packages
753753 for ( const plugin of this . adminforth . activatedPlugins ) {
754- afLogger . trace ( `🔧 Checking packages for plugin, ${ plugin . constructor . name } , ${ plugin . customFolderPath } ` ) ;
754+ process . env . HEAVY_DEBUG && console . log ( `🔧 Checking packages for plugin, ${ plugin . constructor . name } , ${ plugin . customFolderPath } ` ) ;
755755 const [ lockHash , packages ] = await this . packagesFromPnpm ( plugin . customFolderPath ) ;
756756 if ( packages . length ) {
757757 pluginPackages . push ( {
@@ -773,14 +773,14 @@ class CodeInjector implements ICodeInjector {
773773 const existingHash = await fs . promises . readFile ( hashPath , 'utf-8' ) ;
774774 await this . checkIconNames ( icons ) ;
775775 if ( existingHash === fullHash ) {
776- afLogger . trace ( `🪲Hashes match, skipping pnpm install, from file: ${ existingHash } , actual: ${ fullHash } ` ) ;
776+ process . env . HEAVY_DEBUG && console . log ( `🪲Hashes match, skipping pnpm install, from file: ${ existingHash } , actual: ${ fullHash } ` ) ;
777777 return ;
778778 } else {
779- afLogger . trace ( `🪲 Hashes do not match: from file: ${ existingHash } actual: ${ fullHash } , proceeding with pnpm install` ) ;
779+ process . env . HEAVY_DEBUG && console . log ( `🪲 Hashes do not match: from file: ${ existingHash } actual: ${ fullHash } , proceeding with pnpm install` ) ;
780780 }
781781 } catch ( e ) {
782782 // ignore
783- afLogger . trace ( `🪲Hash file does not exist, proceeding with pnpm install, ${ e } ` ) ;
783+ process . env . HEAVY_DEBUG && console . log ( `🪲Hash file does not exist, proceeding with pnpm install, ${ e } ` ) ;
784784 }
785785
786786 // install --frozen-lockfile works for npm and pnpm
@@ -834,7 +834,7 @@ class CodeInjector implements ICodeInjector {
834834 } ;
835835 await collectDirectories ( spaPath ) ;
836836
837- afLogger . trace ( `🪲🔎 Watch for: ${ directories . join ( ',' ) } ` ) ;
837+ process . env . HEAVY_DEBUG && console . log ( `🪲🔎 Watch for: ${ directories . join ( ',' ) } ` ) ;
838838
839839 const watcher = filewatcher ( { debounce : 30 } ) ;
840840 directories . forEach ( ( dir ) => {
@@ -843,7 +843,7 @@ class CodeInjector implements ICodeInjector {
843843 files . forEach ( ( file ) => {
844844 const fullPath = path . join ( dir , file ) ;
845845 if ( fs . lstatSync ( fullPath ) . isFile ( ) ) {
846- afLogger . trace ( `🪲🔎 Watch for file ${ fullPath } ` ) ;
846+ process . env . HEAVY_DEBUG && console . log ( `🪲🔎 Watch for file ${ fullPath } ` ) ;
847847 watcher . add ( fullPath ) ;
848848 }
849849 } )
@@ -852,7 +852,7 @@ class CodeInjector implements ICodeInjector {
852852 watcher . on (
853853 'change' ,
854854 async ( file ) => {
855- afLogger . trace ( `🐛 File ${ file } changed (SPA), preparing sources...` ) ;
855+ process . env . HEAVY_DEBUG && console . log ( `🐛 File ${ file } changed (SPA), preparing sources...` ) ;
856856 await this . updatePartials ( { filesUpdated : [ file . replace ( spaPath + path . sep , '' ) ] } ) ;
857857 }
858858 )
@@ -868,7 +868,7 @@ class CodeInjector implements ICodeInjector {
868868 try {
869869 await fs . promises . access ( customComponentsDir , fs . constants . F_OK ) ;
870870 } catch ( e ) {
871- afLogger . trace ( `🪲Custom components dir ${ customComponentsDir } does not exist, skipping watching` ) ;
871+ process . env . HEAVY_DEBUG && console . log ( `🪲Custom components dir ${ customComponentsDir } does not exist, skipping watching` ) ;
872872 return ;
873873 }
874874
@@ -900,25 +900,25 @@ class CodeInjector implements ICodeInjector {
900900
901901 const watcher = filewatcher ( { debounce : 30 } ) ;
902902 files . forEach ( ( file ) => {
903- afLogger . trace ( `🪲🔎 Watch for file ${ file } ` ) ;
903+ process . env . HEAVY_DEBUG && console . log ( `🪲🔎 Watch for file ${ file } ` ) ;
904904 watcher . add ( file ) ;
905905 } ) ;
906906
907- afLogger . trace ( `🪲🔎 Watch for: ${ directories . join ( ',' ) } ` ) ;
907+ process . env . HEAVY_DEBUG && console . log ( `🪲🔎 Watch for: ${ directories . join ( ',' ) } ` ) ;
908908
909909 watcher . on (
910910 'change' ,
911911 async ( fileOrDir ) => {
912912 // copy one file
913913 const relativeFilename = fileOrDir . replace ( customComponentsDir + path . sep , '' ) ;
914- afLogger . trace ( `🔎 fileOrDir ${ fileOrDir } changed` ) ;
915- afLogger . trace ( `🔎 relativeFilename ${ relativeFilename } ` ) ;
916- afLogger . trace ( `🔎 customComponentsDir ${ customComponentsDir } ` ) ;
917- afLogger . trace ( `🔎 destination ${ destination } ` ) ;
914+ process . env . HEAVY_DEBUG && console . log ( `🔎 fileOrDir ${ fileOrDir } changed` ) ;
915+ process . env . HEAVY_DEBUG && console . log ( `🔎 relativeFilename ${ relativeFilename } ` ) ;
916+ process . env . HEAVY_DEBUG && console . log ( `🔎 customComponentsDir ${ customComponentsDir } ` ) ;
917+ process . env . HEAVY_DEBUG && console . log ( `🔎 destination ${ destination } ` ) ;
918918 const isFile = fs . lstatSync ( fileOrDir ) . isFile ( ) ;
919919 if ( isFile ) {
920920 const destPath = path . join ( this . spaTmpPath ( ) , 'src' , 'custom' , destination , relativeFilename ) ;
921- afLogger . trace ( `🔎 Copying file ${ fileOrDir } to ${ destPath } ` ) ;
921+ process . env . HEAVY_DEBUG && console . log ( `🔎 Copying file ${ fileOrDir } to ${ destPath } ` ) ;
922922 await fsExtra . copy ( fileOrDir , destPath ) ;
923923 return ;
924924 } else {
@@ -938,7 +938,7 @@ class CodeInjector implements ICodeInjector {
938938 return content ;
939939 } catch ( e ) {
940940 // file does not exist
941- afLogger . trace ( `🪲File ${ filePath } does not exist, returning null` ) ;
941+ process . env . HEAVY_DEBUG && console . log ( `🪲File ${ filePath } does not exist, returning null` ) ;
942942 return null ;
943943 }
944944 }
@@ -998,7 +998,7 @@ class CodeInjector implements ICodeInjector {
998998 map [ rel ] = hash ;
999999 } catch ( e ) {
10001000 // If a file can't be read (binary or permission), log and continue
1001- afLogger . trace ( `🪲File ${ filePath } read error: ${ e } ` ) ;
1001+ process . env . HEAVY_DEBUG && console . log ( `🪲File ${ filePath } read error: ${ e } ` ) ;
10021002 return ;
10031003 }
10041004 }
@@ -1013,12 +1013,12 @@ class CodeInjector implements ICodeInjector {
10131013 const root = this . spaTmpPath ( ) ;
10141014 const outPath = path . join ( root , outputFileName ) ;
10151015 await fs . promises . writeFile ( outPath , JSON . stringify ( hashMap , null , 2 ) , 'utf-8' ) ;
1016- afLogger . trace ( `🪲 Saved sources hashes to ${ outPath } ` ) ;
1016+ process . env . HEAVY_DEBUG && console . log ( `🪲 Saved sources hashes to ${ outPath } ` ) ;
10171017 return outPath ;
10181018 }
10191019
10201020 async bundleNow ( { hotReload = false } : { hotReload : boolean } ) {
1021- afLogger . info ( `${ this . adminforth . formatAdminForth ( ) } Bundling ${ hotReload ? 'and listening for changes (🔥 Hotreload)' : ' (no hot reload)' } ` ) ;
1021+ console . log ( `${ this . adminforth . formatAdminForth ( ) } Bundling ${ hotReload ? 'and listening for changes (🔥 Hotreload)' : ' (no hot reload)' } ` ) ;
10221022 this . adminforth . runningHotReload = hotReload ;
10231023
10241024 await this . prepareSources ( ) ;
@@ -1041,7 +1041,7 @@ class CodeInjector implements ICodeInjector {
10411041
10421042 const allFiles = [ ] ;
10431043 const sourcesHash = await this . computeSourcesHash ( this . spaTmpPath ( ) , allFiles ) ;
1044- afLogger . trace ( `🪲🪲 allFiles:, ${ JSON . stringify (
1044+ process . env . HEAVY_DEBUG && console . log ( `🪲🪲 allFiles:, ${ JSON . stringify (
10451045 allFiles . sort ( ( a , b ) => a . localeCompare ( b ) ) , null , 1 ) } `) ;
10461046
10471047 const buildHash = await this . tryReadFile ( path . join ( serveDir , '.adminforth_build_hash' ) ) ;
@@ -1050,7 +1050,7 @@ class CodeInjector implements ICodeInjector {
10501050 const skipBuild = buildHash === sourcesHash ;
10511051 const skipExtract = messagesHash === sourcesHash ;
10521052
1053- afLogger . trace ( `🪲 SPA messages hash: ${ messagesHash } ` ) ;
1053+ process . env . HEAVY_DEBUG && console . log ( `🪲 SPA messages hash: ${ messagesHash } ` ) ;
10541054
10551055 if ( ! skipBuild ) {
10561056 // remove serveDir if exists
@@ -1074,7 +1074,7 @@ class CodeInjector implements ICodeInjector {
10741074 // save hash
10751075 await fs . promises . writeFile ( path . join ( serveDir , '.adminforth_messages_hash' ) , sourcesHash ) ;
10761076 } else {
1077- afLogger . info ( `AdminForth i18n message extraction skipped — build already performed for the current sources.` ) ;
1077+ console . log ( `AdminForth i18n message extraction skipped — build already performed for the current sources.` ) ;
10781078 }
10791079
10801080 if ( ! hotReload ) {
@@ -1135,15 +1135,15 @@ class CodeInjector implements ICodeInjector {
11351135 // save sources hashes to file for later debugging if needed
11361136 await this . saveSourcesHashesToFile ( 'hashes.json' , hashMap ) ;
11371137 } else {
1138- afLogger . info ( `Skipping AdminForth SPA bundling - already completed for the current sources.` ) ;
1138+ console . log ( `Skipping AdminForth SPA bundling - already completed for the current sources.` ) ;
11391139 }
11401140 } else {
11411141
11421142 const command = 'run dev' ;
11431143 const usersPackageManager = await this . doesUserHasPnpmLockFile ( this . adminforth . config . customization . customComponentsDir ) ? 'pnpm' : 'npm' ;
1144- afLogger . info ( `⚙️ spawn: ${ usersPackageManager } ${ command } ...` ) ;
1144+ console . log ( `⚙️ spawn: ${ usersPackageManager } ${ command } ...` ) ;
11451145 if ( process . env . VITE_ADMINFORTH_PUBLIC_PATH ) {
1146- afLogger . info ( `⚠️ Your VITE_ADMINFORTH_PUBLIC_PATH: ${ process . env . VITE_ADMINFORTH_PUBLIC_PATH } has no effect` ) ;
1146+ console . log ( `⚠️ Your VITE_ADMINFORTH_PUBLIC_PATH: ${ process . env . VITE_ADMINFORTH_PUBLIC_PATH } has no effect` ) ;
11471147 }
11481148 const env = {
11491149 VITE_ADMINFORTH_PUBLIC_PATH : this . adminforth . config . baseUrl ,
@@ -1167,14 +1167,14 @@ class CodeInjector implements ICodeInjector {
11671167 // parse port from message " ➜ Local: http://localhost:xyz/"
11681168 const s = stripAnsiCodes ( data . toString ( ) ) ;
11691169
1170- afLogger . trace ( `🪲 devServer stdout ➜ (port detect): ${ s } ` ) ;
1170+ process . env . HEAVY_DEBUG && console . log ( `🪲 devServer stdout ➜ (port detect): ${ s } ` ) ;
11711171 const portMatch = s . match ( / .+ ?h t t p : \/ \/ .+ ?: ( \d + ) .+ ?/ m) ;
11721172 if ( portMatch ) {
11731173 this . devServerPort = parseInt ( portMatch [ 1 ] ) ;
11741174 }
11751175 } else {
1176- afLogger . trace ( `[AdminForth SPA]:` ) ;
1177- afLogger . trace ( data . toString ( ) ) ;
1176+ process . env . HEAVY_DEBUG && console . log ( `[AdminForth SPA]:` ) ;
1177+ process . env . HEAVY_DEBUG && console . log ( data . toString ( ) ) ;
11781178 }
11791179 } ) ;
11801180 devServer . stderr . on ( 'data' , ( data ) => {
0 commit comments