@eui/tools 6.4.2 → 6.4.3

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.
@@ -1 +1 @@
1
- 6.4.2
1
+ 6.4.3
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 6.4.3 (2023-02-23)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * limit the number of commit output for MS Teams message - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([616070b3](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/616070b3daaaae67fc5753c490290c14f9790738))
7
+ * adapted teams notification message for exception and commits outpuy - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([58f0f958](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/58f0f9587af636311c43d9a979ea3d4acb5c5511))
8
+
9
+ * * *
10
+ * * *
1
11
  ## 6.4.2 (2023-02-22)
2
12
 
3
13
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.4.2",
3
+ "version": "6.4.3",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -1181,9 +1181,22 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1181
1181
  // })
1182
1182
 
1183
1183
 
1184
- const teamsUtils = require('./scripts/utils/notification/teams-utils');
1184
+ // const teamsUtils = require('./scripts/utils/notification/teams-utils');
1185
+
1186
+ // Promise.resolve()
1187
+ // .then(() => {
1188
+ // console.log(teamsUtils.getChannelHook('pipeline-ui-edui'));
1189
+ // })
1185
1190
 
1186
1191
  Promise.resolve()
1187
1192
  .then(() => {
1188
- console.log(teamsUtils.getChannelHook('pipeline-ui-edui'));
1193
+
1194
+ var startTime = moment('03-01-2021 01:01:01', 'DD-MM-YYYY hh:mm:ss');
1195
+ var endTime = moment('03-01-2021 01:04:53', 'DD-MM-YYYY hh:mm:ss');
1196
+
1197
+ var secondsDiff = endTime.diff(startTime, 's');
1198
+
1199
+ const getMinSec = (s) => { return(s-(s%=60))/60+'m'+(9<s?':':':0')+s+'s'; }
1200
+ const minSec = getMinSec(secondsDiff);
1201
+ console.log(minSec);
1189
1202
  })
@@ -12,6 +12,7 @@ module.exports.getMessage = (options) => {
12
12
  mainText: null,
13
13
  detailTitle: null,
14
14
  detailText: null,
15
+ detailTextArray: [],
15
16
  text: options.text || null,
16
17
  status: null,
17
18
  statusColor: null
@@ -41,55 +42,57 @@ module.exports.getMessage = (options) => {
41
42
  switch (options.exception) {
42
43
  case 'NO_VALID_COMMIT_FOUND':
43
44
  message.detailTitle = 'NO VALID COMMIT FOUND!';
44
- message.detailText = 'No valid commit found since last release tag\n' + '...Check trace file for details';
45
+ message.detailTextArray.push('No valid commit found since last release tag');
45
46
  break;
46
47
 
47
48
  case 'NO_ISSUE_FOUND':
48
49
  message.detailTitle = 'NO ISSUE FOUND!';
49
- message.detailText = 'No issue found on commits since last release tag\n' + '...Check trace file for details\n';
50
+ message.detailTextArray.push('No issue found on commits since last release tag');
51
+ message.detailTextArray.push('Commit details:');
50
52
  if (options.metadata.commits && options.metadata.commits.length !== 0) {
51
- message.detailText += options.metadata.commits.map((commit) => {
53
+ const commits = options.metadata.commits.map((commit) => {
52
54
  return metadataUtils.commit.formatCommit(commit);
53
- }).join('\n');
55
+ });
56
+ message.detailTextArray = [...message.detailTextArray, ...commits];
54
57
  }
55
58
  break;
56
59
 
57
60
  case 'GLOBAL_PIPELINE_DISABLED':
58
61
  message.detailTitle = 'PIPELINE GLOBALLY DISABLED!';
59
- message.detailText = 'Due to maintenance, all pipeline jobs have been temporary disabled - retry later';
62
+ message.detailTextArray.push('Due to maintenance, all pipeline jobs have been temporary disabled - retry later');
60
63
  break;
61
64
 
62
65
  case 'PACKAGE_LOCKED':
63
66
  message.detailTitle = 'CONCURRENT BUILD DETECTED FOR PACKAGE - ABORTING!';
64
- message.detailText = 'Another build has been detected for the current package being build\n Retry again this build after 15m, lock will be auto-cleared';
67
+ message.detailTextArray.push('Another build has been detected for the current package being build\n Retry again this build after 15m, lock will be auto-cleared');
65
68
  break;
66
69
 
67
70
  case 'MULTIPLE_LOCAL_EUI_VERSIONS_FOUND':
68
71
  message.detailTitle = 'MULTIPLE eUI VERSIONS FOUND IN LOCAL PROJECT - ABORTING!';
69
- message.detailText = 'Uncompatible version of eUI found installed in the local CSDR project, please adjust and keep same compatible versions of eUI packages and projects';
72
+ message.detailTextArray.push('Uncompatible version of eUI found installed in the local CSDR project, please adjust and keep same compatible versions of eUI packages and projects');
70
73
  break;
71
74
 
72
75
  case 'BRANCH_NOT_PROVIDED':
73
76
  message.detailTitle = 'RELEASE BRANCH missing - ABORTING!';
74
- message.detailText = 'Package release needs to have a branch to build from as parameter from Bamboo';
77
+ message.detailTextArray.push('Package release needs to have a branch to build from as parameter from Bamboo');
75
78
  break;
76
79
 
77
80
  case 'REMOTE_ENVTARGET_NOT_MASTER_BRANCH':
78
81
  message.detailTitle = 'REMOTE envTarget type branchis different from master - ABORTING!';
79
- message.detailText = 'For envTarget remote delivery or "à la carte", only the master branch is allowed for build, contact support if any question';
82
+ message.detailTextArray.push('For envTarget remote delivery or "à la carte", only the master branch is allowed for build, contact support if any question');
80
83
  break;
81
84
 
82
85
  case 'AUDIT_DEPENDENCIES_GATES_FAILED':
83
- message.detailTitle = 'Audit dependencies gates for current eUI version contains blocking vulnerabilities - ABORTING!';
84
- message.detailText = 'Check logs for more info or contact eUI support for detailed checks';
86
+ message.detailTitle = 'AUDIT DEPENDENCIES GATES FAILED';
87
+ message.detailTextArray.push('Audit dependencies gates for current eUI version contains blocking vulnerabilities - ABORTING!');
85
88
  break;
86
89
 
87
90
  default:
88
91
  message.detailTitle = 'GENERAL ERROR!';
89
- message.detailText = options.exception;
92
+ message.detailTextArray.push(options.exception);
90
93
  };
91
94
 
92
-
95
+ message.detailText = message.detailTextArray.join('\n');
93
96
 
94
97
  } else {
95
98
 
@@ -106,12 +109,16 @@ module.exports.getMessage = (options) => {
106
109
 
107
110
  if (options.metadata && options.metadata.commits && options.metadata.commits.length !== 0) {
108
111
  message.detailTitle = 'Commit history since last release tag';
109
- message.detailText = options.metadata.commits.map((commit) => {
112
+ const formattedCommits = options.metadata.commits.map((commit) => {
110
113
  return metadataUtils.commit.formatCommit(commit);
111
- }).join('\n ');
114
+ });
115
+ message.detailText = formattedCommits.join('\n ');
116
+ message.detailTextArray = formattedCommits;
112
117
 
113
118
  if (options.metadata.issues && options.metadata.issues.length !== 0) {
114
- message.detailText += '\nExtracted issues : ' + options.metadata.issues;
119
+ const extractedIssuesText = 'Extracted issues : ' + options.metadata.issues;
120
+ message.detailText += '\n' + extractedIssuesText;
121
+ message.detailTextArray.push(extractedIssuesText);
115
122
  }
116
123
  }
117
124
  }
@@ -22,6 +22,7 @@ const messageContent = {
22
22
  startTimestamp: null,
23
23
  endTimestamp: null,
24
24
  duration: null,
25
+ durationSeconds: null,
25
26
  durationMinSec: null
26
27
  };
27
28
 
@@ -33,7 +34,9 @@ module.exports.endStack = () => {
33
34
  messageContent.endTimestamp = moment();
34
35
  messageContent.duration = messageContent.endTimestamp - messageContent.startTimestamp;
35
36
  const start = messageContent.startTimestamp, end = messageContent.endTimestamp;
36
- messageContent.durationMinSec = `${end.diff(start, 'm')}m:${end.diff(start, 's')}s`;
37
+ messageContent.durationSeconds = end.diff(start, 's');
38
+ const getMinSec = (s) => { return(s-(s%=60))/60+'m'+(9<s?':':':0')+s+'s'; }
39
+ messageContent.durationMinSec = getMinSec(messageContent.durationSeconds);
37
40
  }
38
41
 
39
42
  module.exports.pushMessage = (message) => {
@@ -54,11 +54,19 @@ const createPayload = (messageContent) => {
54
54
  const version = finalMessage.version;
55
55
 
56
56
  // set commit history
57
- const commitHistory = "```" + finalMessage.detailText;
57
+ let commitHistory = [], exceptionDetails = [];
58
+ if (status === statuses.success) {
59
+ commitHistory = finalMessage.detailTextArray;
60
+ } else {
61
+ exceptionDetails = finalMessage.detailTextArray;
62
+ }
58
63
 
59
64
  // set summary
60
65
  const itemName = messageContent.buffer[0].scope;
61
- const summary = `${status.emoji} :: ${status.text} - ${itemName} - ${version}`;
66
+ let summary = `${status.emoji} :: ${status.text} - ${itemName}`;
67
+ if (version) {
68
+ summary += ` - ${version}`;
69
+ }
62
70
 
63
71
  // set release sections
64
72
  const publications = messageContent.buffer.filter(m => m.text !== null && m.text.indexOf(':rocket:') > -1);
@@ -71,11 +79,29 @@ const createPayload = (messageContent) => {
71
79
  }
72
80
  });
73
81
 
74
- sections.push({
75
- "startGroup": true,
76
- "activityTitle": "Commit history since last release tag",
77
- "activityText": commitHistory
78
- });
82
+ if (commitHistory.length > 0) {
83
+ sections.push({
84
+ "startGroup": true,
85
+ "activityTitle": "Commit history since last release tag"
86
+ });
87
+ commitHistory.slice(0, 5).forEach((commit) => {
88
+ sections.push({
89
+ "activityText": commit
90
+ });
91
+ });
92
+ }
93
+
94
+ if (exceptionDetails.length > 0) {
95
+ sections.push({
96
+ "startGroup": true,
97
+ "activityTitle": finalMessage.detailTitle
98
+ });
99
+ exceptionDetails.forEach((exd) => {
100
+ sections.push({
101
+ "activityText": exd
102
+ });
103
+ });
104
+ }
79
105
 
80
106
  sections.push({
81
107
  "startGroup": true,
@@ -78,8 +78,8 @@ function getArgs() {
78
78
  const newItem = {};
79
79
  newItem[subItemSplit[0].trim()] = subItemSplit[1].trim();
80
80
  array.push(newItem);
81
- args[item.split(':')[0]] = array;
82
81
  })
82
+ args[item.split(':')[0]] = array;
83
83
 
84
84
  // otherwise normal key/value pairs - example format : test1:test1,test2:test2
85
85
  } else {