@@ -3,6 +3,7 @@ import 'dotenv/config';
33
44const fs = require ( 'fs' ) ;
55const path = require ( 'path' ) ;
6+ const { URL } = require ( 'url' ) ;
67
78// === CommonJS-friendly requires for generated Prisma clients
89const { PrismaClient : TargetPrisma } = require ( '../generated/target' ) ;
@@ -21,6 +22,37 @@ const sourceIdentity = new SourceIdentityPrisma();
2122// ---- Tunables
2223const BATCH_SIZE = 1000 ;
2324
25+ function redactCredentials ( raw : string ) {
26+ return raw . replace ( / \/ \/ ( [ ^ @ ] * ?) @ / , '//***@' ) ;
27+ }
28+
29+ function summarizeConnection ( raw : string ) {
30+ try {
31+ const parsed = new URL ( raw ) ;
32+ const hostPart = `${ parsed . protocol } //${ parsed . hostname } ${ parsed . port ? `:${ parsed . port } ` : '' } ${ parsed . pathname } ` ;
33+ const authStatus =
34+ parsed . username || parsed . password ? 'credentials set' : 'no credentials' ;
35+ const queryStatus = parsed . search ? 'query params present' : 'no query params' ;
36+ return `${ hostPart } (${ authStatus } ; ${ queryStatus } )` ;
37+ } catch ( err : any ) {
38+ return `unable to parse (${ err . message } ); raw=${ redactCredentials ( raw ) } ` ;
39+ }
40+ }
41+
42+ function logConnectionDetails ( label : string , envVar : string , rawValue ?: string ) {
43+ if ( ! rawValue ) {
44+ console . warn ( `[config] ${ label } : environment variable ${ envVar } is not set` ) ;
45+ return ;
46+ }
47+ console . log ( `[config] ${ label } (${ envVar } ): ${ summarizeConnection ( rawValue ) } ` ) ;
48+ }
49+
50+ [
51+ { label : 'Target identity database' , envVar : 'IDENTITY_DB_URL' } ,
52+ { label : 'Source auth database' , envVar : 'SOURCE_AUTH_MYSQL_URL' } ,
53+ { label : 'Source identity database' , envVar : 'SOURCE_IDENTITY_PG_URL' } ,
54+ ] . forEach ( ( { label, envVar } ) => logConnectionDetails ( label , envVar , process . env [ envVar ] ) ) ;
55+
2456
2557// ensure ./logs exists
2658function ensureLogDir ( ) {
0 commit comments