@@ -48,6 +48,7 @@ import { Glob } from "glob";
48
48
const DeployCommandOptions = CommonCommandOptions . extend ( {
49
49
skipTypecheck : z . boolean ( ) . default ( false ) ,
50
50
skipDeploy : z . boolean ( ) . default ( false ) ,
51
+ ignoreEnvVarCheck : z . boolean ( ) . default ( false ) ,
51
52
env : z . enum ( [ "prod" , "staging" ] ) ,
52
53
loadImage : z . boolean ( ) . default ( false ) ,
53
54
buildPlatform : z . enum ( [ "linux/amd64" , "linux/arm64" ] ) . default ( "linux/amd64" ) ,
@@ -73,7 +74,11 @@ export function configureDeployCommand(program: Command) {
73
74
"Deploy to a specific environment (currently only prod and staging are supported)" ,
74
75
"prod"
75
76
)
76
- . option ( "-T, --skip-typecheck" , "Whether to skip the pre-build typecheck" )
77
+ . option ( "--skip-typecheck" , "Whether to skip the pre-build typecheck" )
78
+ . option (
79
+ "--ignore-env-var-check" ,
80
+ "Detected missing environment variables won't block deployment"
81
+ )
77
82
. option ( "-c, --config <config file>" , "The name of the config file, found at [path]" )
78
83
. option (
79
84
"-p, --project-ref <project ref>" ,
@@ -425,7 +430,11 @@ async function checkEnvVars(
425
430
environmentVariablesSpinner . stop (
426
431
`Found missing env vars in ${ options . env } : ${ arrayToSentence (
427
432
missingEnvironmentVariables
428
- ) } . Aborting deployment. ${ chalk . bgBlueBright (
433
+ ) } . ${
434
+ options . ignoreEnvVarCheck
435
+ ? "Continuing deployment because of --ignore-env-var-check. "
436
+ : "Aborting deployment. "
437
+ } ${ chalk . bgBlueBright (
429
438
terminalLink (
430
439
"Manage env vars" ,
431
440
`${ apiUrl } /projects/v3/${ config . project } /environment-variables`
@@ -437,7 +446,12 @@ async function checkEnvVars(
437
446
"envVars.missing" : missingEnvironmentVariables ,
438
447
} ) ;
439
448
440
- throw new SkipLoggingError ( "Found missing environment variables" ) ;
449
+ if ( ! options . ignoreEnvVarCheck ) {
450
+ throw new SkipLoggingError ( "Found missing environment variables" ) ;
451
+ } else {
452
+ span . end ( ) ;
453
+ return ;
454
+ }
441
455
}
442
456
443
457
environmentVariablesSpinner . stop ( `Environment variable check passed` ) ;
@@ -1309,15 +1323,19 @@ async function findAllEnvironmentVariableReferencesInFile(filePath: string) {
1309
1323
return findAllEnvironmentVariableReferences ( fileContents ) ;
1310
1324
}
1311
1325
1326
+ const IGNORED_ENV_VARS = [ "NODE_ENV" , "SHELL" , "HOME" , "PWD" , "LOGNAME" , "USER" , "PATH" ] ;
1327
+
1312
1328
function findAllEnvironmentVariableReferences ( code : string ) : string [ ] {
1313
1329
const regex = / \b p r o c e s s \. e n v \. ( [ a - z A - Z _ ] [ a - z A - Z 0 - 9 _ ] * ) \b / g;
1314
1330
1315
1331
const matches = code . matchAll ( regex ) ;
1316
1332
1317
1333
const matchesArray = Array . from ( matches , ( match ) => match [ 1 ] ) . filter ( Boolean ) as string [ ] ;
1318
1334
1335
+ const filteredMatches = matchesArray . filter ( ( match ) => ! IGNORED_ENV_VARS . includes ( match ) ) ;
1336
+
1319
1337
// Make sure and remove duplicates
1320
- return Array . from ( new Set ( matchesArray ) ) ;
1338
+ return Array . from ( new Set ( filteredMatches ) ) ;
1321
1339
}
1322
1340
1323
1341
function arrayToSentence ( items : string [ ] ) : string {
0 commit comments