1- /* eslint-disable */
1+ import chalk from "chalk" ;
2+
3+ const red = chalk . redBright ;
4+ const green = chalk . greenBright ;
5+ const bold = chalk . bold ;
6+
7+ console . log ( chalk . greenBright ( bold ( `\nValidating environment variables` ) ) ) ;
8+
29const REQUIRED_CLIENT_ENVIRONMENT = [ ] ;
310
411// prettier-ignore
@@ -14,9 +21,6 @@ const REQUIRED_SERVER_ENVIRONMENT = [
1421// REQUIRED_SERVER_ENVIRONMENT.push("SENTRY_TOKEN");
1522// }
1623
17- const red = "\u001b[31m" ;
18- const resetColor = "\u001b[0m" ;
19-
2024const getInvalids = ( envs ) =>
2125 envs . reduce (
2226 ( invalids , env ) => ( process . env [ env ] ? invalids : [ ...invalids , env ] ) ,
@@ -30,25 +34,31 @@ const isServerEnvValid = getInvalids(REQUIRED_SERVER_ENVIRONMENT).length === 0;
3034const isClientEnvValid = getInvalids ( REQUIRED_CLIENT_ENVIRONMENT ) . length === 0 ;
3135
3236if ( isServerEnvValid && isClientEnvValid ) {
33- console . log ( "Environment validation succeded!" ) ;
37+ console . log ( bold ( green ( `\nEnvironment validation succeded!\n` ) ) ) ;
3438 process . exit ( 0 ) ;
3539}
40+
3641const invalids = [
3742 ...getInvalids ( REQUIRED_SERVER_ENVIRONMENT ) ,
3843 ...getInvalids ( REQUIRED_CLIENT_ENVIRONMENT ) ,
3944] ;
4045
46+ console . log (
47+ chalk . redBright (
48+ bold (
49+ `\nFound ${ invalids . length } missing ${ invalids . length > 1 ? "variables" : "variable" } .\n` ,
50+ ) ,
51+ ) ,
52+ ) ;
53+
4154invalids . forEach ( ( env ) => {
4255 const type = REQUIRED_SERVER_ENVIRONMENT . includes ( env ) ? "server" : "client" ;
4356 console . error (
44- `${ red } Missing ${ type } variable:${ resetColor } ${ env } ${ resetColor } is ${ getErrorType ( env ) } !` ,
57+ chalk . grey (
58+ `Missing ${ type } variable: ${ chalk . bold ( chalk . blue ( env ) ) } is ${ getErrorType ( env ) } !)` ,
59+ ) ,
4560 ) ;
4661} ) ;
4762
48- console . log (
49- `\nFound ${ invalids . length } missing ${ invalids . length > 1 ? "variables" : "variable" } .\n` ,
50- ) ;
51-
52- console . log ( "Environment validation failed!" ) ;
63+ console . log ( red . bold ( `\nEnvironment validation failed!\n` ) ) ;
5364process . exit ( 13 ) ;
54- /* eslint-enable */
0 commit comments