@@ -13,6 +13,7 @@ import {
1313 generateSSLCertificate ,
1414 getCurrentGitBranch ,
1515 getGitRepoName ,
16+ git ,
1617 gitAddCommitPush ,
1718 uxLog ,
1819} from '../../../../common/utils/index.js' ;
@@ -116,12 +117,14 @@ The command's technical implementation involves a series of Git operations, file
116117 }
117118 const preRequisitesUrl = `${ CONSTANTS . DOC_URL_ROOT } /salesforce-monitoring-config-home/#instructions` ;
118119 uxLog ( "warning" , this , c . yellow ( 'Monitoring pre-requisites documentation: ' + c . bold ( preRequisitesUrl ) ) ) ;
120+ WebSocketClient . sendReportFileMessage ( preRequisitesUrl , 'Monitoring pre-requisites' , "docUrl" ) ;
121+ // Confirm pre-requisites
119122 const confirmPreRequisites = await prompts ( {
120123 type : 'select' ,
121124 name : 'value' ,
122125 choices : [
123- { title : 'Yes' , value : 'yes' } ,
124- { title : 'No, help me !' , value : 'no' } ,
126+ { title : '😎 Yes' , value : 'yes' } ,
127+ { title : 'ℹ️ No, bring me to the documentation !' , value : 'no' } ,
125128 ] ,
126129 message : c . cyanBright ( 'Did you configure the sfdx-hardis monitoring pre-requisites on your Git server ?' ) ,
127130 description : 'Confirm that you have set up the required CI/CD variables and permissions for monitoring' ,
@@ -179,10 +182,12 @@ The command's technical implementation involves a series of Git operations, file
179182 . replace ( / - - / gm, '__' )
180183 . replace ( / - / gm, '_' ) ;
181184
185+ uxLog ( "action" , this , c . cyan ( `Handling monitoring git branch ${ c . bold ( branchName ) } ...` ) ) ;
186+
182187 // Checkout branch, or create it if not existing (stash before if necessary)
183188 await execCommand ( 'git add --all' , this , { output : true , fail : false } ) ;
184189 await execCommand ( 'git stash' , this , { output : true , fail : false } ) ;
185- await ensureGitBranch ( branchName , { parent : 'main' } ) ;
190+ await ensureGitBranch ( branchName , { parent : 'main' , logAsAction : true } ) ;
186191
187192 // Create sfdx project if not existing yet
188193 if ( ! fs . existsSync ( 'sfdx-project.json' ) ) {
@@ -215,6 +220,26 @@ The command's technical implementation involves a series of Git operations, file
215220 './.sfdx-hardis.yml'
216221 ) ;
217222
223+ // Check if current branch is existing on remote origin, and if not suggest to push (with confirmation)
224+ const remoteBranches = await git ( ) . listRemote ( [ '--heads' , 'origin' ] ) ;
225+ const branchExistsOnRemote = remoteBranches . includes ( `refs/heads/${ branchName } ` ) ;
226+ if ( ! branchExistsOnRemote ) {
227+ const confirmPushToRemote = await prompts ( {
228+ type : 'confirm' ,
229+ initial : true ,
230+ message : c . cyanBright (
231+ `Branch ${ branchName } does not exist on server. Do you want to push it now? (it is harmless but required to configure Azure Pipelines for example)`
232+ ) ,
233+ description : 'This will create the branch on remote origin; if you don\'t understand this, just say yes 😊' ,
234+ } ) ;
235+ if ( confirmPushToRemote . value === true ) {
236+ uxLog ( "action" , this , c . cyan ( `Pushing branch ${ c . bold ( branchName ) } to git remote server...` ) ) ;
237+ await gitAddCommitPush ( {
238+ message : '[sfdx-hardis] Update monitoring configuration' ,
239+ } ) ;
240+ }
241+ }
242+
218243 // Generate SSL certificate (requires openssl to be installed on computer)
219244 await generateSSLCertificate ( branchName , './.ssh' , this , flags [ 'target-org' ] . getConnection ( ) , { } ) ;
220245
@@ -239,9 +264,9 @@ The command's technical implementation involves a series of Git operations, file
239264 }
240265 const branch = await getCurrentGitBranch ( ) ;
241266 uxLog (
242- "success " ,
267+ "warning " ,
243268 this ,
244- c . green (
269+ c . yellow (
245270 `Now you must schedule monitoring to run the job automatically every night on branch ${ c . bold ( branch ) } 😊`
246271 )
247272 ) ;
@@ -250,7 +275,23 @@ The command's technical implementation involves a series of Git operations, file
250275 'Please follow the instructions to schedule sfdx-hardis monitoring on your Git server: ' +
251276 c . bold ( scheduleMonitoringUrl ) ;
252277 uxLog ( "warning" , this , c . yellow ( msg ) ) ;
253- await open ( scheduleMonitoringUrl , { wait : true } ) ;
278+ WebSocketClient . sendReportFileMessage ( scheduleMonitoringUrl , 'Schedule sfdx-hardis monitoring' , "actionUrl" ) ;
279+ uxLog (
280+ "warning" ,
281+ this ,
282+ c . yellow (
283+ 'You can also configure Slack/Teams notifications and Grafana integration to visualize monitoring results more easily.'
284+ )
285+ ) ;
286+ const slackIntegrationUrl = `${ CONSTANTS . DOC_URL_ROOT } /salesforce-ci-cd-setup-integration-slack/` ;
287+ WebSocketClient . sendReportFileMessage ( slackIntegrationUrl , 'Slack integration' , "docUrl" ) ;
288+ const teamsIntegrationUrl = `${ CONSTANTS . DOC_URL_ROOT } /salesforce-ci-cd-setup-integration-ms-teams/` ;
289+ WebSocketClient . sendReportFileMessage ( teamsIntegrationUrl , 'Teams integration' , "docUrl" ) ;
290+ const grafanaIntegrationUrl = `${ CONSTANTS . DOC_URL_ROOT } /salesforce-ci-cd-setup-integration-api/` ;
291+ WebSocketClient . sendReportFileMessage ( grafanaIntegrationUrl , 'Grafana integration' , "docUrl" ) ;
292+ uxLog ( "log" , this , 'Slack integration doc: ' + slackIntegrationUrl ) ;
293+ uxLog ( "log" , this , 'Teams integration doc: ' + teamsIntegrationUrl ) ;
294+ uxLog ( "log" , this , 'Grafana integration doc: ' + grafanaIntegrationUrl ) ;
254295 // Return an object to be displayed with --json
255296 return { outputString : 'Configured branch for authentication' } ;
256297 }
0 commit comments