@@ -29,12 +29,17 @@ const getVercelToken = () => {
2929} ;
3030
3131const makeFnEnv = ( envTxt : string ) : string => {
32- return envTxt . split ( '\n' ) . filter ( l => l . match ( / ^ S U P A B A S E _ \w + _ K E Y / ) ) . map ( ( l ) => l . replace ( 'SUPABASE_' , 'SB_' ) ) . join ( '\n' ) ;
33- }
32+ return envTxt
33+ . split ( "\n" )
34+ . filter ( ( l ) => l . match ( / ^ S U P A B A S E _ \w + _ K E Y / ) )
35+ . map ( ( l ) => l . replace ( "SUPABASE_" , "SB_" ) )
36+ . join ( "\n" ) ;
37+ } ;
3438
3539const makeLocalEnv = ( ) => {
3640 execSync ( "supabase start" , {
37- cwd : projectRoot , stdio : "inherit"
41+ cwd : projectRoot ,
42+ stdio : "inherit" ,
3843 } ) ;
3944 const stdout = execSync ( "supabase status -o env" , {
4045 encoding : "utf8" ,
@@ -54,8 +59,8 @@ const makeLocalEnv = () => {
5459 ) ;
5560 writeFileSync (
5661 join ( projectRoot , "supabase/functions/.env" ) ,
57- makeFnEnv ( prefixed )
58- )
62+ makeFnEnv ( prefixed ) ,
63+ ) ;
5964} ;
6065
6166const makeBranchEnv = async ( vercel : Vercel , vercelToken : string ) => {
@@ -94,11 +99,11 @@ const makeBranchEnv = async (vercel: Vercel, vercelToken: string) => {
9499 throw err ;
95100 }
96101 appendFileSync ( ".env.branch" , `NEXT_API_ROOT="https://${ url } /api"\n` ) ;
97- const fromVercel = readFileSync ( ' .env.branch' ) . toString ( ) ;
102+ const fromVercel = readFileSync ( " .env.branch" ) . toString ( ) ;
98103 writeFileSync (
99104 join ( projectRoot , "supabase/functions/.env" ) ,
100- makeFnEnv ( fromVercel )
101- )
105+ makeFnEnv ( fromVercel ) ,
106+ ) ;
102107} ;
103108
104109const makeProductionEnv = async ( vercel : Vercel , vercelToken : string ) => {
@@ -117,33 +122,37 @@ const makeProductionEnv = async (vercel: Vercel, vercelToken: string) => {
117122 `vercel -t ${ vercelToken } env pull --environment production .env.production` ,
118123 ) ;
119124 appendFileSync ( ".env.production" , `NEXT_API_ROOT="https://${ url } /api"\n` ) ;
120- const fromVercel = readFileSync ( ' .env.production' ) . toString ( ) ;
125+ const fromVercel = readFileSync ( " .env.production" ) . toString ( ) ;
121126 writeFileSync (
122127 join ( projectRoot , "supabase/functions/.env" ) ,
123- makeFnEnv ( fromVercel )
124- )
128+ makeFnEnv ( fromVercel ) ,
129+ ) ;
125130} ;
126131
127132const main = async ( variant : Variant ) => {
128133 if ( process . env . ROAM_BUILD_SCRIPT ) {
129134 // special case: production build
130135 try {
131- const response = execSync ( 'curl https://discoursegraphs.com/api/supabase/env' ) ;
136+ const response = execSync (
137+ "curl https://discoursegraphs.com/api/supabase/env" ,
138+ ) ;
132139 const asJson = JSON . parse ( response . toString ( ) ) as Record < string , string > ;
133140 writeFileSync (
134141 join ( projectRoot , ".env" ) ,
135- Object . entries ( asJson ) . map ( ( [ k , v ] ) => `${ k } =${ v } ` ) . join ( '\n' )
142+ Object . entries ( asJson )
143+ . map ( ( [ k , v ] ) => `${ k } =${ v } ` )
144+ . join ( "\n" ) ,
136145 ) ;
137146 return ;
138147 } catch ( e ) {
139148 if ( process . env . SUPABASE_URL && process . env . SUPABASE_PUBLISHABLE_KEY )
140149 return ;
141150 throw new Error ( "Could not get environment from site" ) ;
142151 }
143- }
144- else if (
152+ } else if (
145153 process . env . HOME === "/vercel" ||
146- process . env . GITHUB_ACTIONS !== undefined
154+ ( process . env . GITHUB_ACTIONS !== undefined &&
155+ process . env . GITHUB_TEST !== "test" )
147156 )
148157 // Do not execute in deployment or github action.
149158 return ;
0 commit comments