@docupace/pipeline 1.0.85 → 1.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/next/deploy.js +56 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -564,7 +564,14 @@ export async function deployFromSite(
564
564
  `Deploying changes from ${fromSite} in ${fromEnv} to ${toSite} in ${toEnv}${jiraTicket ? ` approved by JIRA ticket ${jiraTicket}` : ''}`,
565
565
  );
566
566
 
567
- if (jiraTicket) {
567
+ if (toEnv === 'prod') {
568
+ if (!jiraTicket) {
569
+ console.error(
570
+ 'The deployment to prod environment requires a JIRA ticket to be provided',
571
+ );
572
+ process.exit(1);
573
+ }
574
+
568
575
  try {
569
576
  const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
570
577
  const docupacecInstance = response.fields.customfield_10045.value;
@@ -595,34 +602,59 @@ export async function deployFromSite(
595
602
  process.exit(1);
596
603
  }
597
604
 
598
- if (toEnv === 'prod') {
599
- if (docupacecInstance !== 'Production') {
600
- console.error(
601
- `The deployment to prod environment requires Docupace Instance to be "Production", but got "${docupacecInstance}"`,
602
- );
603
- console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
604
- process.exit(1);
605
- }
606
-
607
- if (fromSite !== toSite) {
608
- console.error(
609
- `The deployment to prod environment requires fromSite and toSite to be equal, but fromSite: "${fromSite}", toSite: "${toSite}"`,
610
- );
611
- console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
612
- process.exit(1);
613
- }
614
-
615
- console.log('Production deployment validations passed');
605
+ if (docupacecInstance !== 'Production') {
606
+ console.error(
607
+ `The deployment to prod environment requires Docupace Instance to be "Production", but got "${docupacecInstance}"`,
608
+ );
609
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
610
+ process.exit(1);
611
+ }
612
+
613
+ if (fromSite !== toSite) {
614
+ console.error(
615
+ `The deployment to prod environment requires fromSite and toSite to be equal, but fromSite: "${fromSite}", toSite: "${toSite}"`,
616
+ );
617
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
618
+ process.exit(1);
619
+ }
620
+
621
+ console.log('Production deployment validations passed');
622
+ } catch (error) {
623
+ console.error(`Failed to make a Jira request: ${error.message}`);
624
+ process.exit(1);
625
+ }
626
+ } else if (jiraTicket) {
627
+ try {
628
+ const response = await makeJiraRequest(`/rest/api/2/issue/${jiraTicket}`);
629
+ const siteUrl = response.fields.customfield_10041;
630
+ const status = response.fields.status.name;
631
+ const jiraBaseUrl = response.self.split('/rest/api')[0];
632
+ const jiraTicketUrl = `${jiraBaseUrl}/browse/${response.key}`;
633
+
634
+ console.log(`Docupace Site URL: ${siteUrl}`);
635
+ console.log(`JIRA Ticket Status: ${status}`);
636
+ console.log(`JIRA Ticket URL: ${jiraTicketUrl}`);
637
+
638
+ const allowedStatuses = ['To Do', 'In Progress'];
639
+ if (!allowedStatuses.includes(status)) {
640
+ console.error(
641
+ `The JIRA ticket status must be "To Do" or "In Progress", but got "${status}"`,
642
+ );
643
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
644
+ process.exit(1);
645
+ }
646
+
647
+ if (!siteUrl.includes(toSite)) {
648
+ console.error(
649
+ `The toSite "${toSite}" must be present in the Docupace Site URL: "${siteUrl}"`,
650
+ );
651
+ console.error(`Please check the JIRA ticket: ${jiraTicketUrl}`);
652
+ process.exit(1);
616
653
  }
617
654
  } catch (error) {
618
655
  console.error(`Failed to make a Jira request: ${error.message}`);
619
656
  process.exit(1);
620
657
  }
621
- } else if (toEnv === 'prod') {
622
- console.error(
623
- 'The deployment to prod environment requires a JIRA ticket to be provided',
624
- );
625
- process.exit(1);
626
658
  }
627
659
 
628
660
  if (isDeployCore === 'true') {