@@ -151,6 +151,9 @@ class InitCommand extends Command {
151151 ( project ) => project . id === selectedProjectId
152152 ) ;
153153
154+ const remoteHasuraVersion = project . hasura_gqe_version ;
155+ const dockerImage = `nhost/hasura-cli-docker:${ remoteHasuraVersion } ` ;
156+
154157 // create root nhost folder
155158 await mkdir ( nhostDir ) ;
156159 // .nhost is used for nhost specific configuration
@@ -198,7 +201,7 @@ class InitCommand extends Command {
198201
199202 try {
200203 // clear current migration information from remote
201- const qres = await fetch ( `${ hasuraEndpoint } /v1/query` , {
204+ await fetch ( `${ hasuraEndpoint } /v1/query` , {
202205 method : "POST" ,
203206 headers : {
204207 "Content-Type" : "application/json" ,
@@ -216,20 +219,20 @@ class InitCommand extends Command {
216219
217220 // create migrations from remote
218221 spinner . text = "Create migrations" ;
219- let command = `hasura migrate create "init" --from-server --schema "public" --schema "auth" ${ commonOptions } ` ;
222+ let command = `docker run --rm -v $(pwd):/hasuracli ${ dockerImage } migrate create "init" --from-server --schema "public" --schema "auth" ${ commonOptions } ` ;
220223 await exec ( command , { cwd : nhostDir } ) ;
221224
222- // mark this migration as applied (--skip-execution) on the remote server
223- // so that it doesn't get run again when promoting local
224- // changes to that environment
225+ // // mark this migration as applied (--skip-execution) on the remote server
226+ // // so that it doesn't get run again when promoting local
227+ // // changes to that environment
225228 const initMigration = fs . readdirSync ( migrationDirectory ) [ 0 ] ;
226229 const version = initMigration . match ( / ^ \d + / ) [ 0 ] ;
227- command = `hasura migrate apply --version "${ version } " --skip-execution ${ commonOptions } ` ;
230+ command = `docker run --rm -v $(pwd):/hasuracli nhost/ hasura-cli-docker migrate apply --version "${ version } " --skip-execution ${ commonOptions } ` ;
228231 await exec ( command , { cwd : nhostDir } ) ;
229232
230233 // create metadata from remote
231234 spinner . text = "Create Hasura metadata" ;
232- command = `hasura metadata export ${ commonOptions } ` ;
235+ command = `docker run --rm -v $(pwd):/hasuracli ${ dockerImage } metadata export ${ commonOptions } ` ;
233236 await exec ( command , { cwd : nhostDir } ) ;
234237
235238 // auth.roles and auth.providers plus any enum compatible tables that might exist
@@ -255,7 +258,7 @@ class InitCommand extends Command {
255258 ""
256259 ) ;
257260 if ( fromTables ) {
258- command = `hasura seeds create enum ${ fromTables } ${ commonOptions } ` ;
261+ command = `docker run --rm -v $(pwd):/hasuracli ${ dockerImage } seeds create roles_and_providers ${ fromTables } ${ commonOptions } ` ;
259262 await exec ( command , { cwd : nhostDir } ) ;
260263 }
261264
@@ -291,22 +294,23 @@ class InitCommand extends Command {
291294
292295 // write ENV variables to .env.development
293296 spinner . text = "Adding env vars to .env.development" ;
294- await this . _writeToFileSync (
297+ await writeFile (
295298 envFile ,
296299 project . project_env_vars
297300 . map ( ( envVar ) => `${ envVar . name } =${ envVar . dev_value } ` )
298301 . join ( "\n" )
299302 ) ;
300303
301- await this . _writeToFileSync (
304+ await writeFile (
302305 envFile ,
303306 `\nREGISTRATION_CUSTOM_FIELDS=${ project . hbp_REGISTRATION_CUSTOM_FIELDS } \n`
304307 ) ;
305308
306309 if ( project . backend_user_fields ) {
307310 await this . _writeToFileSync (
308311 envFile ,
309- `\JWT_CUSTOM_FIELDS=${ project . backend_user_fields } \n`
312+ `JWT_CUSTOM_FIELDS=${ project . backend_user_fields } \n` ,
313+ { flag : "a" }
310314 ) ;
311315 }
312316
0 commit comments