@@ -2,12 +2,20 @@ import fs from 'fs-extra';
22import path from 'path' ;
33import cliProgress from 'cli-progress' ;
44import { CommanderStatic } from 'commander' ;
5- import { CubeCloudClient , DeployController } from '@cubejs-backend/cloud' ;
5+ import { AuthObject , CubeCloudClient , DeployController } from '@cubejs-backend/cloud' ;
66import { ConfigCli } from '../config' ;
77
88import { logStage , displayError , event } from '../utils' ;
99
10- const deploy = async ( { directory, auth, uploadEnv, token } : any ) => {
10+ type DeployOptions = {
11+ directory : string ,
12+ auth : AuthObject ,
13+ uploadEnv : boolean ,
14+ replaceEnv : boolean ,
15+ token : string
16+ } ;
17+
18+ const deploy = async ( { directory, auth, uploadEnv, replaceEnv, token } : DeployOptions ) => {
1119 if ( ! ( await fs . pathExists ( path . join ( process . cwd ( ) , 'node_modules' , '@cubejs-backend/server-core' ) ) ) ) {
1220 await displayError (
1321 '@cubejs-backend/server-core dependency not found. Please run deploy command from project root directory and ensure npm install has been run.'
@@ -28,10 +36,10 @@ const deploy = async ({ directory, auth, uploadEnv, token }: any) => {
2836 hideCursor : true
2937 } ) ;
3038
31- const envVariables = uploadEnv ? await config . envFile ( `${ directory } /.env` ) : { } ;
39+ const envVariables = uploadEnv || replaceEnv ? await config . envFile ( `${ directory } /.env` ) : { } ;
3240
3341 const cubeCloudClient = new CubeCloudClient ( auth || ( await config . deployAuthForCurrentDir ( ) ) ) ;
34- const deployController = new DeployController ( cubeCloudClient , envVariables , {
42+ const deployController = new DeployController ( cubeCloudClient , { envVariables, replaceEnv } , {
3543 onStart : async ( deploymentName , files ) => {
3644 await logStage ( `Deploying ${ deploymentName } ...` , 'Cube Cloud CLI Deploy' ) ;
3745 bar . start ( files . length , 0 , {
@@ -58,6 +66,7 @@ export function configureDeployCommand(program: CommanderStatic) {
5866 . command ( 'deploy' )
5967 . description ( 'Deploy project to Cube Cloud' )
6068 . option ( '--upload-env' , 'Upload .env file to CubeCloud' )
69+ . option ( '--replace-env' , 'Upload .env file to CubeCloud, allowing to replace existing variables' )
6170 . option ( '--token <token>' , 'Add auth token to CubeCloud' )
6271 . option ( '--directory [path]' , 'Specify path to conf directory' , './' )
6372 . action (
0 commit comments