@@ -28,6 +28,10 @@ type Options = {
2828} ;
2929
3030export async function run ( options : Options ) {
31+ const allowedLogLevels = [ 'error' , 'query' ] as const ;
32+ const log = options . logLevel ?. filter ( ( level ) : level is ( typeof allowedLogLevels ) [ number ] =>
33+ allowedLogLevels . includes ( level as any ) ,
34+ ) ;
3135 const schemaFile = getSchemaFile ( options . schema ) ;
3236 console . log ( colors . gray ( `Loading ZModel schema from: ${ schemaFile } ` ) ) ;
3337
@@ -66,11 +70,6 @@ export async function run(options: Options) {
6670
6771 const schemaModule = ( await jiti . import ( path . join ( outputPath , 'schema' ) ) ) as any ;
6872
69- const allowedLogLevels = [ 'error' , 'query' ] as const ;
70- const log = options . logLevel ?. filter ( ( level ) : level is ( typeof allowedLogLevels ) [ number ] =>
71- allowedLogLevels . includes ( level as any ) ,
72- ) ;
73-
7473 const db = new ZenStackClient ( schemaModule . schema , {
7574 dialect : dialect ,
7675 log : log && log . length > 0 ? log : undefined ,
@@ -87,8 +86,17 @@ export async function run(options: Options) {
8786}
8887
8988function evaluateUrl ( value : string ) : string {
89+ // Remove surrounding quotes if present
90+ let trimmedValue = value . trim ( ) ;
91+ if (
92+ ( trimmedValue . startsWith ( '"' ) && trimmedValue . endsWith ( '"' ) ) ||
93+ ( trimmedValue . startsWith ( "'" ) && trimmedValue . endsWith ( "'" ) )
94+ ) {
95+ trimmedValue = trimmedValue . slice ( 1 , - 1 ) ;
96+ }
97+
9098 // Check if it's an env() function call
91- const envMatch = value . trim ( ) . match ( / ^ e n v \s * \( \s * [ ' " ] ( [ ^ ' " ] + ) [ ' " ] \s * \) $ / ) ;
99+ const envMatch = trimmedValue . match ( / ^ e n v \s * \( \s * [ ' " ] ( [ ^ ' " ] + ) [ ' " ] \s * \) $ / ) ;
92100 if ( envMatch ) {
93101 const varName = envMatch [ 1 ] ;
94102 const envValue = process . env [ varName ! ] ;
@@ -97,7 +105,7 @@ function evaluateUrl(value: string): string {
97105 }
98106 return envValue ;
99107 } else {
100- return value ;
108+ return trimmedValue ;
101109 }
102110}
103111
0 commit comments