1- import find from " lodash/find" ;
2- import { resolve } from " path" ;
3- import { existsSync } from "fs" ;
4- import isEmpty from " lodash/isEmpty" ;
5- import includes from " lodash/includes" ;
6- import { cliux as ux } from " @contentstack/cli-utilities" ;
1+ import find from ' lodash/find' ;
2+ import { resolve } from ' path' ;
3+ import { existsSync } from 'fs' ;
4+ import isEmpty from ' lodash/isEmpty' ;
5+ import includes from ' lodash/includes' ;
6+ import { cliux as ux } from ' @contentstack/cli-utilities' ;
77
8- import BaseClass from " ./base-class" ;
9- import { getRemoteUrls } from " ../util" ;
8+ import BaseClass from ' ./base-class' ;
9+ import { getRemoteUrls } from ' ../util' ;
1010
1111export default class PreCheck extends BaseClass {
1212 public projectBasePath : string = process . cwd ( ) ;
@@ -44,17 +44,17 @@ export default class PreCheck extends BaseClass {
4444 } else {
4545 this . validateLaunchConfig ( ) ;
4646
47- this . log ( " Existing launch project identified" , " info" ) ;
47+ this . log ( ' Existing launch project identified' , ' info' ) ;
4848
4949 await this . displayPreDeploymentDetails ( ) ;
50-
51- if (
52- ! ( await ux . inquire ( {
53- type : " confirm" ,
54- name : " deployLatestSource" ,
55- message : " Redeploy latest commit/code?" ,
56- } ) )
57- ) {
50+ const deployLatestCode =
51+ this . config [ 'redeploy-latest' ] ||
52+ ( await ux . inquire ( {
53+ type : ' confirm' ,
54+ name : ' deployLatestSource' ,
55+ message : ' Redeploy latest commit/code?' ,
56+ } ) ) ;
57+ if ( ! deployLatestCode ) {
5858 this . exit ( 1 ) ;
5959 }
6060 }
@@ -68,34 +68,31 @@ export default class PreCheck extends BaseClass {
6868 */
6969 async displayPreDeploymentDetails ( ) {
7070 if ( this . config . config && ! isEmpty ( this . config . currentConfig ) ) {
71- this . log ( "" ) ; // Empty line
72- this . log ( "Current Project details:" , { bold : true , color : "green" } ) ;
73- this . log ( "" ) ; // Empty line
74- const { name, projectType, repository, environments } =
75- this . config . currentConfig ;
71+ this . log ( '' ) ; // Empty line
72+ this . log ( 'Current Project details:' , { bold : true , color : 'green' } ) ;
73+ this . log ( '' ) ; // Empty line
74+ const { name, projectType, repository, environments } = this . config . currentConfig ;
7675 const [ environment ] = environments ;
7776
7877 const detail : Record < string , any > = {
79- "Project Name" : name ,
80- "Project Type" :
81- ( this . config . providerMapper as Record < string , any > ) [ projectType ] ||
82- "" ,
78+ 'Project Name' : name ,
79+ 'Project Type' : ( this . config . providerMapper as Record < string , any > ) [ projectType ] || '' ,
8380 Environment : environment . name ,
84- " Framework Preset" :
81+ ' Framework Preset' :
8582 find ( this . config . listOfFrameWorks , {
8683 value : environment . frameworkPreset ,
87- } ) ?. name || "" ,
84+ } ) ?. name || '' ,
8885 } ;
8986
9087 if ( repository ?. repositoryName ) {
91- detail [ " Repository" ] = repository . repositoryName ;
88+ detail [ ' Repository' ] = repository . repositoryName ;
9289 }
9390
9491 ux . table ( [ detail , { } ] , {
95- " Project Name" : {
92+ ' Project Name' : {
9693 minWidth : 7 ,
9794 } ,
98- " Project Type" : {
95+ ' Project Type' : {
9996 minWidth : 7 ,
10097 } ,
10198 Environment : {
@@ -104,7 +101,7 @@ export default class PreCheck extends BaseClass {
104101 Repository : {
105102 minWidth : 7 ,
106103 } ,
107- " Framework Preset" : {
104+ ' Framework Preset' : {
108105 minWidth : 7 ,
109106 } ,
110107 } ) ;
@@ -120,7 +117,7 @@ export default class PreCheck extends BaseClass {
120117 try {
121118 // NOTE Perform validations here
122119 if ( isEmpty ( require ( this . config . config as string ) ) ) {
123- this . log ( " Invalid Launch config!" , " warn" ) ;
120+ this . log ( ' Invalid Launch config!' , ' warn' ) ;
124121 this . exit ( 1 ) ;
125122 }
126123 } catch ( error ) { }
@@ -133,19 +130,17 @@ export default class PreCheck extends BaseClass {
133130 * @memberof PreCheck
134131 */
135132 async identifyWhatProjectItIs ( ) : Promise < void > {
136- const localRemoteUrl =
137- ( await getRemoteUrls ( resolve ( this . config . projectBasePath , ".git/config" ) ) )
138- ?. origin || "" ;
133+ const localRemoteUrl = ( await getRemoteUrls ( resolve ( this . config . projectBasePath , '.git/config' ) ) ) ?. origin || '' ;
139134
140135 switch ( true ) {
141136 case includes ( localRemoteUrl , 'github.' ) :
142137 this . config . provider = 'GitHub' ;
143138 this . log ( 'Git project identified' , 'info' ) ;
144139 break ;
145140 default :
146- if ( existsSync ( resolve ( this . config . projectBasePath , " .git" ) ) ) {
147- this . log ( " Git config found but remote URL not found in the config!" , {
148- color : " yellow" ,
141+ if ( existsSync ( resolve ( this . config . projectBasePath , ' .git' ) ) ) {
142+ this . log ( ' Git config found but remote URL not found in the config!' , {
143+ color : ' yellow' ,
149144 bold : true ,
150145 } ) ;
151146 }
0 commit comments