@@ -4,7 +4,6 @@ import path from "path";
44import fs from "fs" ;
55import chalk from "chalk" ;
66import dotenv from "dotenv" ;
7- import { afLogger } from '../modules/logger.js' ;
87
98const currentFilePath = import . meta. url ;
109const currentFileFolder = path . dirname ( currentFilePath ) . replace ( "file:" , "" ) ;
@@ -21,7 +20,7 @@ export function callTsProxy(tsCode, silent=false) {
2120 dotenv . config ( { path : envPath , override : true } ) ;
2221 }
2322
24- afLogger . trace ( "🌐 Calling tsproxy with code:" , path . join ( currentFileFolder , "proxy.ts" ) ) ;
23+ process . env . HEAVY_DEBUG && console . log ( "🌐 Calling tsproxy with code:" , path . join ( currentFileFolder , "proxy.ts" ) ) ;
2524 return new Promise ( ( resolve , reject ) => {
2625 const child = spawn ( "tsx" , [ path . join ( currentFileFolder , "proxy.ts" ) ] , {
2726 env : process . env ,
@@ -43,7 +42,7 @@ export function callTsProxy(tsCode, silent=false) {
4342 const parsed = JSON . parse ( stdout ) ;
4443 if ( ! silent ) {
4544 parsed . capturedLogs . forEach ( ( log ) => {
46- afLogger . info ( ...log ) ;
45+ console . log ( ...log ) ;
4746 } ) ;
4847 }
4948
@@ -55,19 +54,19 @@ export function callTsProxy(tsCode, silent=false) {
5554 reject ( new Error ( "Invalid JSON from tsproxy: " + stdout ) ) ;
5655 }
5756 } else {
58- afLogger . error ( `tsproxy exited with non-0, this should never happen, stdout: ${ stdout } , stderr: ${ stderr } ` ) ;
57+ console . error ( `tsproxy exited with non-0, this should never happen, stdout: ${ stdout } , stderr: ${ stderr } ` ) ;
5958 reject ( new Error ( stderr ) ) ;
6059 }
6160 } ) ;
6261
63- afLogger . trace ( "🪲 Writing to tsproxy stdin...\n'''" , tsCode , "'''" ) ;
62+ process . env . HEAVY_DEBUG && console . log ( "🪲 Writing to tsproxy stdin...\n'''" , tsCode , "'''" ) ;
6463 child . stdin . write ( tsCode ) ;
6564 child . stdin . end ( ) ;
6665 } ) ;
6766}
6867
6968export async function findAdminInstance ( ) {
70- afLogger . trace ( "🌐 Finding admin instance..." ) ;
69+ process . env . HEAVY_DEBUG && console . log ( "🌐 Finding admin instance..." ) ;
7170 const currentDirectory = process . cwd ( ) ;
7271
7372 let files = fs . readdirSync ( currentDirectory ) ;
@@ -84,7 +83,7 @@ export async function findAdminInstance() {
8483 for ( const file of files ) {
8584 if ( file . endsWith ( ".ts" ) ) {
8685 const fileNoTs = file . replace ( / \. t s $ / , "" ) ;
87- afLogger . trace ( `🪲 Trying bundleing ${ file } ...` ) ;
86+ process . env . HEAVY_DEBUG && console . log ( `🪲 Trying bundleing ${ file } ...` ) ;
8887 try {
8988 const res = await callTsProxy ( `
9089 import { admin } from './${ fileNoTs } .js';
@@ -102,10 +101,10 @@ export async function findAdminInstance() {
102101 // and show the error so user can fix it
103102 const fileContent = fs . readFileSync ( file , "utf-8" ) ;
104103 if ( fileContent . includes ( "export const admin" ) ) {
105- afLogger . error ( `Error running ${ file } : ${ e } ` ) ;
104+ console . error ( chalk . red ( `Error running ${ file } :` , e ) ) ;
106105 process . exit ( 1 ) ;
107106 }
108- afLogger . trace ( `🪲 File ${ file } failed` , e ) ;
107+ process . env . HEAVY_DEBUG && console . log ( `🪲 File ${ file } failed` , e ) ;
109108 }
110109 }
111110 }
@@ -131,4 +130,4 @@ export async function findAdminInstance() {
131130// function exec() {
132131// return admin.doX();
133132// }
134- // `).then(afLogger.info ).catch(afLogger .error);
133+ // `).then(console.log ).catch(console .error);
0 commit comments