@eui/tools 6.3.45 → 6.4.0

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.3.45
1
+ 6.4.0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 6.4.0 (2023-02-22)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * cleanup teams token - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([8b7658d4](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/8b7658d41d48ddc4e6bd90df1c909a436969641c))
7
+ ##### New Features
8
+
9
+ * **other:**
10
+ * refactor to handle ms teams notification - EUI-7146 [EUI-7146](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7146) ([2cefe68d](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/2cefe68d356a1d9b5106d3ea2e1cb5bc1b910da4))
11
+
12
+ * * *
13
+ * * *
14
+ ## 6.3.46 (2023-02-21)
15
+
16
+ ##### Chores
17
+
18
+ * **other:**
19
+ * added block container for dynamically handle conditional block generation for v15 remotes - MWP-9204 [MWP-9204](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-9204) ([63126feb](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/63126feb485893f0092fc5fa9e85fe7a5215678a))
20
+
21
+ * * *
22
+ * * *
1
23
  ## 6.3.45 (2023-02-21)
2
24
 
3
25
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.3.45",
3
+ "version": "6.4.0",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -41,7 +41,7 @@
41
41
  "mocha": "10.2.0",
42
42
  "chai": "4.3.7",
43
43
  "nyc": "15.1.0",
44
- "node-fetch": "3.3.0",
44
+ "node-fetch": "2.6.9",
45
45
  "sendmail": "1.6.1",
46
46
  "svg-sprite": "2.0.2",
47
47
  "imagemin": "7.0.1",
package/sandbox.js CHANGED
@@ -1167,17 +1167,22 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1167
1167
  // console.log(remotes);
1168
1168
  // })
1169
1169
 
1170
- const prj = configUtils.projects.getCsdrProject('my-workplace-host-playground');
1170
+ // const prj = configUtils.projects.getCsdrProject('my-workplace-host-playground');
1171
+
1172
+
1173
+ // Promise.resolve()
1174
+ // .then(() => {
1175
+ // return installUtils.projects.getLocalProjectRemoteDeps(prj);
1176
+ // })
1177
+ // .then((deps) => {
1178
+ // return installUtils.projects.importLocalProjectRemotes(prj, deps);
1179
+ // })
1180
+ // .then(() => {
1181
+ // })
1171
1182
 
1172
1183
 
1173
1184
  Promise.resolve()
1174
1185
  .then(() => {
1175
- return installUtils.projects.getLocalProjectRemoteDeps(prj);
1186
+ const config = configUtils.global.getConfigOptions();
1187
+ console.log(config);
1176
1188
  })
1177
- .then((deps) => {
1178
- return installUtils.projects.importLocalProjectRemotes(prj, deps);
1179
- })
1180
- .then(() => {
1181
- })
1182
-
1183
-
@@ -222,11 +222,20 @@ module.exports.getConfigOptions = () => {
222
222
  NPM_REGISTRY_DEFAULT: null,
223
223
  NPM_REGISTRY_DEFAULT_2: null,
224
224
  NPM_REGISTRY_INSTALL: null,
225
+ NPM_FIXED_DEPENDENCIES: null,
225
226
  SONAR_HOST: null,
227
+ NOTIFICATION_CLIENT: null,
226
228
  SLACK_HOOK: null,
227
229
  SLACK_CHANNEL_FRONTEND: null,
228
230
  SLACK_CHANNEL_BACKEND: null,
229
231
  SLACK_CHANNEL_PROJECT: null,
232
+ MAIL_ADDRESS_FRONTEND: null,
233
+ MAIL_ADDRESS_BACKEND: null,
234
+ MAIL_ADDRESS_PROJECT: null,
235
+ MSTEAMS_HOST: null,
236
+ MSTEAMS_FRONTEND_CHANNEL: null,
237
+ MSTEAMS_BACKEND_CHANNEL: null,
238
+ MSTEAMS_PROJECT_CHANNEL: null,
230
239
  API_HOST: null,
231
240
  AUDIT_DEPENDENCIES_GATES: null,
232
241
  }
@@ -270,6 +279,9 @@ module.exports.getConfigOptions = () => {
270
279
  if (npm.registry && npm.registry.default2) {
271
280
  configOptions.NPM_REGISTRY_DEFAULT_2 = npm.registry.default2;
272
281
  }
282
+ if (npm.fixedDependencies) {
283
+ configOptions.NPM_FIXED_DEPENDENCIES = npm.fixedDependencies;
284
+ }
273
285
  }
274
286
 
275
287
  // getting sonar options
@@ -280,60 +292,37 @@ module.exports.getConfigOptions = () => {
280
292
  }
281
293
  }
282
294
 
283
- // getting slack options
284
- const slack = config && config.slack;
285
-
286
- if (slack) {
287
- if (slack.host && slack.hookToken) {
288
- configOptions.SLACK_HOOK = slack.host + '/' + slack.hookToken;
289
- }
290
- if (slack.channels) {
291
- if (slack.channels.frontend) {
292
- configOptions.SLACK_CHANNEL_FRONTEND = slack.channels.frontend;
293
- }
294
- if (slack.channels.backend) {
295
- configOptions.SLACK_CHANNEL_BACKEND = slack.channels.backend;
296
- }
297
- if (slack.channels.project) {
298
- configOptions.SLACK_CHANNEL_PROJECT = slack.channels.project;
299
- }
300
- }
301
-
302
- }
303
-
304
295
  // getting notification options (replacing slack only above)
305
296
  const notification = config && config.notification;
306
297
 
307
- configOptions.notification = {};
308
-
309
298
  if (notification) {
310
299
  if (notification.defaultClient) {
311
- configOptions.notification.CLIENT = notification.defaultClient;
300
+ configOptions.NOTIFICATION_CLIENT = notification.defaultClient;
312
301
  }
313
302
 
314
303
  const slack = notification.slack;
315
304
 
316
305
  if (slack) {
317
306
  if (slack.host && slack.hookToken) {
318
- configOptions.notification.SLACK_HOOK = slack.host + '/' + slack.hookToken;
307
+ configOptions.SLACK_HOOK = slack.host + '/' + slack.hookToken;
319
308
  }
320
309
  if (slack.channels) {
321
310
  if (slack.channels.frontend) {
322
- configOptions.notification.SLACK_CHANNEL_FRONTEND = slack.channels.frontend;
311
+ configOptions.SLACK_CHANNEL_FRONTEND = slack.channels.frontend;
323
312
  } else {
324
- configOptions.notification.SLACK_CHANNEL_FRONTEND = slack.defaultChannel;
313
+ configOptions.SLACK_CHANNEL_FRONTEND = slack.defaultChannel;
325
314
  }
326
315
 
327
316
  if (slack.channels.backend) {
328
- configOptions.notification.SLACK_CHANNEL_BACKEND = slack.channels.backend;
317
+ configOptions.SLACK_CHANNEL_BACKEND = slack.channels.backend;
329
318
  } else {
330
- configOptions.notification.SLACK_CHANNEL_BACKEND = slack.defaultChannel;
319
+ configOptions.SLACK_CHANNEL_BACKEND = slack.defaultChannel;
331
320
  }
332
321
 
333
322
  if (slack.channels.project) {
334
- configOptions.notification.SLACK_CHANNEL_PROJECT = slack.channels.project;
323
+ configOptions.SLACK_CHANNEL_PROJECT = slack.channels.project;
335
324
  } else {
336
- configOptions.notification.SLACK_CHANNEL_PROJECT = slack.defaultChannel;
325
+ configOptions.SLACK_CHANNEL_PROJECT = slack.defaultChannel;
337
326
  }
338
327
  }
339
328
  }
@@ -342,16 +331,34 @@ module.exports.getConfigOptions = () => {
342
331
 
343
332
  if (mail) {
344
333
  if (mail.channels) {
345
- const defaultChannelPrefix = this.getNotificationMailChannel(mail.defaultChannel);
346
-
347
334
  if (mail.channels.frontend) {
348
- configOptions.notification.MAIL_CHANNEL_FRONTEND = this.getNotificationMailAddress(mail.channels.frontend);
335
+ configOptions.MAIL_ADDRESS_FRONTEND = this.getNotificationMailAddress(mail.channels.frontend);
349
336
  }
350
337
  if (mail.channels.backend) {
351
- configOptions.notification.MAIL_CHANNEL_BACKEND = this.getNotificationMailAddress(mail.channels.backend);
338
+ configOptions.MAIL_ADDRESS_BACKEND = this.getNotificationMailAddress(mail.channels.backend);
352
339
  }
353
340
  if (mail.channels.project) {
354
- configOptions.notification.MAIL_CHANNEL_PROJECT = this.getNotificationMailAddress(mail.channels.project);
341
+ configOptions.MAIL_ADDRESS_PROJECT = this.getNotificationMailAddress(mail.channels.project);
342
+ }
343
+ }
344
+ }
345
+
346
+ const msteams = notification.msteams;
347
+
348
+ if (msteams) {
349
+ if (msteams.host) {
350
+ configOptions.MSTEAMS_HOST = msteams.host;
351
+ }
352
+
353
+ if (msteams.channels) {
354
+ if (msteams.channels.frontend) {
355
+ configOptions.MSTEAMS_FRONTEND_CHANNEL = msteams.channels.frontend;
356
+ }
357
+ if (msteams.channels.backend) {
358
+ configOptions.MSTEAMS_BACKEND_CHANNEL = msteams.channels.backend;
359
+ }
360
+ if (msteams.channels.project) {
361
+ configOptions.MSTEAMS_PROJECT_CHANNEL = msteams.channels.project;
355
362
  }
356
363
  }
357
364
  }
@@ -405,7 +412,20 @@ module.exports.getNotificationMailChannel = (channelName) => {
405
412
  module.exports.getNotificationMailAddress = (channelName) => {
406
413
  const config = this.getConfig();
407
414
 
408
- const channelPrefix = this.getNotificationMailChannel(channelName);
415
+ const getChannel = (channelName) => {
416
+ let channelPrefix;
417
+
418
+ if (config && config.notification && config.notification.mail && config.notification.mail.channelsMap) {
419
+ channelPrefix = config.notification.mail.channelsMap[channelName];
420
+ if (!channelPrefix) {
421
+ channelPrefix = config.notification.mail.channelsMap[config.notification.mail.defaultChannel];
422
+ }
423
+ }
424
+
425
+ return channelPrefix;
426
+ }
427
+
428
+ const channelPrefix = getChannel(channelName);
409
429
 
410
430
  return channelPrefix + config.notification.mail.addressSuffix;
411
431
  }
@@ -17,7 +17,7 @@ enum ElementStatus {
17
17
  <div style="height: 100%"></div>
18
18
  </eui-block-content>
19
19
  <ng-container *ngIf="moduleStatus === ElementStatus.Loaded">
20
- <@block.container.name@ [block]="block"></@block.container.name@>
20
+ <!-- BLOCK_CONTAINER_PLACEHOLDER -->
21
21
  </ng-container>
22
22
  <ng-container *ngIf="moduleStatus === ElementStatus.Error">
23
23
  <div class="error-container">
@@ -211,10 +211,21 @@ module.exports.generateVirtualRemote = (remoteName, cloneRemote = true) => {
211
211
  if (remote.skeletonConfig.options.participant) {
212
212
  tools.copy(optionParticipantPath, remoteSrcPath);
213
213
  pushContent(optionParticipantDef);
214
- }
215
214
 
216
- if (remote.skeletonConfig.options.participant) {
217
- tools.replaceInPath(remoteSrcPath, '@block.container.name@', remote.skeletonConfig.blockContainerName);
215
+ let blockContainerPlaceholder = '';
216
+ if (remote.skeletonConfig.blockContainerName) {
217
+ blockContainerPlaceholder = `<${remote.skeletonConfig.blockContainerName} [block]="block"></${remote.skeletonConfig.blockContainerName}>`;
218
+ }
219
+ if (remote.skeletonConfig.blockContainerTypes) {
220
+ remote.skeletonConfig.blockContainerTypes.forEach((bc) => {
221
+ blockContainerPlaceholder += `
222
+ <ng-container *ngIf="${bc.condition}">
223
+ <${bc.name} [block]="block"></${bc.name}>
224
+ </ng-container>
225
+ `;
226
+ });
227
+ }
228
+ tools.replaceInPath(remoteSrcPath, '<!-- BLOCK_CONTAINER_PLACEHOLDER -->', blockContainerPlaceholder);
218
229
  }
219
230
  }
220
231
 
@@ -106,7 +106,7 @@ module.exports.install = () => {
106
106
 
107
107
  // Parse dependencies against carrets ones for projects
108
108
  .then(() => {
109
- const fixedDeps = configUtils.global.getConfig().npm.fixedDependencies;
109
+ const fixedDeps = configUtils.global.getConfigOptions().NPM_FIXED_DEPENDENCIES;
110
110
 
111
111
  const configDeps = { ...resolvedDeps, ...fixedDeps };
112
112
 
@@ -255,7 +255,7 @@ module.exports.installDeps = (prj, pkg, isMaster) => {
255
255
  prjDeps = tools.getJsonFileContent(prjJsonFile) || {};
256
256
  }
257
257
 
258
- const fixedDeps = configUtils.global.getConfig().npm.fixedDependencies;
258
+ const fixedDeps = configUtils.global.getConfigOptions().NPM_FIXED_DEPENDENCIES;
259
259
 
260
260
  if (pkg.build && pkg.build.ownDepsOnly) {
261
261
  return innerCommon.installDeps({ ...localPkgBaseDeps, ...remappedDeps, ...localPkgDeps, ...fixedDeps});
@@ -159,7 +159,7 @@ module.exports.installDeps = (prj, envTarget, compositeType) => {
159
159
  tools.logInfo('Found base dependencies:');
160
160
  console.log(prjBaseDeps);
161
161
 
162
- const fixedDeps = configUtils.global.getConfig().npm.fixedDependencies;
162
+ const fixedDeps = configUtils.global.getConfigOptions().NPM_FIXED_DEPENDENCIES;
163
163
 
164
164
  return innerCommon.installDeps({ ...prjBaseDeps, ...compositeDeps, ...prjFixedDeps, ...fixedDeps });
165
165
  })
@@ -100,7 +100,7 @@ module.exports.run = () => {
100
100
  console.log(project);
101
101
 
102
102
  // start mailStack
103
- utils.notification.mailstack.startMailStack();
103
+ utils.notification.messageStack.startStack();
104
104
 
105
105
  return utils.notification.project.sendProjectMessage({
106
106
  project: project,
@@ -389,9 +389,7 @@ module.exports.run = () => {
389
389
  })
390
390
 
391
391
  .then(() => {
392
- utils.notification.mailstack.endMailStack();
393
-
394
- return utils.notification.mailstack.sendMailStackProject(project);
392
+ utils.notification.messageStack.endStack();
395
393
  })
396
394
  })
397
395
 
@@ -415,9 +413,8 @@ module.exports.run = () => {
415
413
  return utils.notification.config.storeProjectConfig(project);
416
414
  })
417
415
  .then(() => {
418
- utils.notification.mailstack.endMailStack();
419
-
420
- return utils.notification.mailstack.sendMailStackProject(project);
416
+ utils.notification.messageStack.endStack();
417
+ return utils.notification.messageStack.sendProjectMessage(project);
421
418
  })
422
419
 
423
420
  .then(() => {
@@ -104,7 +104,7 @@ module.exports.init = (pkg, envTarget, compositeType) => {
104
104
  // Starting the release flow
105
105
  .then(() => {
106
106
  // initiating mail buffer
107
- utils.notification.mailstack.startMailStack();
107
+ utils.notification.messageStack.startStack();
108
108
 
109
109
  // run start
110
110
  console.log('\n\n');
@@ -671,8 +671,6 @@ module.exports.sendSuccessNotification = (pkg, version, pkgMetadata) => {
671
671
  module.exports.sendErrorNotification = (pkg, exception, pkgMetadata) => {
672
672
  utils.tools.logBanner('SEND ERROR NOTIFICATION');
673
673
 
674
- // console.log(pkgMetadata);
675
-
676
674
  return Promise.resolve()
677
675
  .then(() => {
678
676
  utils.tools.logTitle('ERROR !!!!! an unexpected error occured....');
@@ -724,12 +722,8 @@ module.exports.close = (pkg) => {
724
722
 
725
723
  return Promise.resolve()
726
724
  .then(() => {
727
- return utils.notification.mailstack.endMailStack();
728
- })
729
-
730
- .then(() => {
731
- const branches = this.getBranches();
732
- return utils.notification.mailstack.sendMailStackPackage(pkg, branches);
725
+ utils.notification.messageStack.endStack();
726
+ return utils.notification.messageStack.sendPackageMessage(pkg);
733
727
  })
734
728
 
735
729
  .catch((e) => {
@@ -142,15 +142,17 @@ module.exports.run = () => {
142
142
  .then(() => {
143
143
  return innerCommon.sendSuccessNotification(pkg, newVersion, pkgMetadata)
144
144
  .then(() => {
145
- innerCommon.close(pkg);
145
+ return innerCommon.close(pkg);
146
146
  });
147
147
  })
148
148
 
149
149
  .catch((e) => {
150
150
  return innerCommon.sendErrorNotification(pkg, e, pkgMetadata)
151
151
  .then(() => {
152
- innerCommon.close(pkg);
152
+ return innerCommon.close(pkg);
153
+ })
154
+ .then(() => {
153
155
  process.exit(1);
154
- });
156
+ })
155
157
  })
156
158
  }
@@ -15,7 +15,7 @@ module.exports.run = () => {
15
15
  // npm run pkg:release mywp-dashboard-eui15-remote-el-ui -- --dryRun --branch master --remoteBuild true --virtual true --envTarget DEV --skipInstall
16
16
 
17
17
  // normal UI package / old style remote
18
- // npm run pkg:release csdr-core-ui -- --dryRun --branch develop --skipInstall
18
+ // npm run pkg:release eui-tools -- --dryRun --branch develop --skipInstall --skipCompile --skipTest --skipDoc --skipClone
19
19
 
20
20
 
21
21
  return Promise.resolve()
@@ -185,15 +185,17 @@ module.exports.run = () => {
185
185
  .then(() => {
186
186
  return innerCommon.sendSuccessNotification(pkg, newVersion, pkgMetadata)
187
187
  .then(() => {
188
- innerCommon.close(pkg);
188
+ return innerCommon.close(pkg);
189
189
  });
190
190
  })
191
191
 
192
192
  .catch((e) => {
193
193
  return innerCommon.sendErrorNotification(pkg, e, pkgMetadata)
194
194
  .then(() => {
195
- innerCommon.close(pkg);
195
+ return innerCommon.close(pkg);
196
+ })
197
+ .then(() => {
196
198
  process.exit(1);
197
- });
199
+ })
198
200
  })
199
201
  }
@@ -10,10 +10,17 @@ const configUtils = require('../../config/config-utils');
10
10
  const auditUtils = require('../../audit/audit-utils');
11
11
  const tools = require('../../../utils/tools');
12
12
 
13
+ // ARGS
14
+ const { skipInstall } = tools.getArgs();
13
15
 
14
16
  module.exports.install = (pkg, isMaster) => {
15
17
  tools.logBanner('INSTALL');
16
18
 
19
+ if (skipInstall) {
20
+ tools.logInfo('Installation skipped...aborting');
21
+ return Promise.resolve;
22
+ }
23
+
17
24
  return Promise.resolve()
18
25
 
19
26
  // FETCHING CURRENT PACKAGES & INSTALL
package/scripts/index.js CHANGED
@@ -32,11 +32,12 @@ module.exports.cleanUtils = require('./utils/clean/clean-utils');
32
32
  module.exports.notificationCommon = require('./utils/notification/common');
33
33
  module.exports.notificationConfig = require('./utils/notification/config');
34
34
  module.exports.notificationMailUtils = require('./utils/notification/mail-utils');
35
- module.exports.notificationMailStack = require('./utils/notification/mailstack');
35
+ module.exports.notificationMessageStack = require('./utils/notification/message-stack');
36
36
  module.exports.notificationUtils = require('./utils/notification/notification-utils');
37
37
  module.exports.notificationPackage = require('./utils/notification/package');
38
38
  module.exports.notificationProject = require('./utils/notification/project');
39
39
  module.exports.notificationSlackUtils = require('./utils/notification/slack-utils');
40
+ module.exports.notificationTeamsUtils = require('./utils/notification/teams-utils');
40
41
 
41
42
  // utils - pre-build
42
43
  module.exports.prebuildUtilsElements = require('./utils/pre-build/elements');
@@ -88,7 +88,7 @@ module.exports.get = (pathName) => {
88
88
  }
89
89
 
90
90
 
91
- module.exports.post = (pathName, body) => {
91
+ module.exports.authPost = (pathName, body) => {
92
92
  const fetch = require('node-fetch');
93
93
  const { API_HOST } = configUtils.global.getConfigOptions();
94
94
 
@@ -124,3 +124,29 @@ module.exports.post = (pathName, body) => {
124
124
  }
125
125
 
126
126
 
127
+ module.exports.post = (host, pathName, body) => {
128
+ const fetch = require('node-fetch');
129
+
130
+ tools.logInfo(`API post - host: ${host}`);
131
+
132
+ return Promise.resolve()
133
+ .then(() => {
134
+ return fetch(`${host}${pathName}`, {
135
+ method: 'POST',
136
+ headers: {
137
+ 'content-type': 'application/json'
138
+ },
139
+ body: JSON.stringify(body)
140
+ })
141
+ })
142
+ .then((res) => {
143
+ handleResponse(res);
144
+ return res.json();
145
+ })
146
+ .catch(e => {
147
+ tools.logDebugTrace(__filename, 'post', e);
148
+ throw e;
149
+ });
150
+ }
151
+
152
+
@@ -41,6 +41,8 @@ module.exports.build = (pkg, isMaster) => {
41
41
  })
42
42
 
43
43
  .then(() => {
44
+ // throw new Error('FAKE FAILURE');
45
+
44
46
  return notificationUtils.package.sendPackageMessage({
45
47
  package: pkg
46
48
  })
@@ -15,6 +15,8 @@ const preBuildUtils = require('./pre-build/pre-build-utils');
15
15
  const publishUtils = require('./publish/publish-utils');
16
16
  const sonarUtils = require('./sonar/sonar-utils');
17
17
  const apiUtils = require('./api-utils');
18
+ const testUtils = require('./test/test-utils');
19
+ const remoteUtils = require('./remotes/remotes-utils');
18
20
 
19
21
  module.exports = {
20
22
  changelog: changelogUtils,
@@ -31,4 +33,6 @@ module.exports = {
31
33
  publish: publishUtils,
32
34
  sonar: sonarUtils,
33
35
  api: apiUtils,
36
+ test: testUtils,
37
+ remote: remoteUtils
34
38
  }
@@ -6,13 +6,13 @@ const metadataUtils = require('../../csdr/metadata/metadata-utils');
6
6
  module.exports.getMessage = (options) => {
7
7
  const message = {
8
8
  scope: null,
9
- version: options.version,
10
- exception: options.exception,
9
+ version: options.version || null,
10
+ exception: options.exception || null,
11
11
  mainTitle: null,
12
12
  mainText: null,
13
13
  detailTitle: null,
14
14
  detailText: null,
15
- text: options.text,
15
+ text: options.text || null,
16
16
  status: null,
17
17
  statusColor: null
18
18
  };
@@ -12,28 +12,35 @@ module.exports.getPackageConfig = (pkg) => {
12
12
  // Fetching global config - default if not overriden in package own config
13
13
  const globalConfig = configUtils.global.getConfigOptions();
14
14
 
15
- var slackChannel, mailChannel;
15
+ var slackChannel, mailAdress, msTeamsChannel, msTeamsHook;
16
16
 
17
17
  if (pkg.backend) {
18
- slackChannel = globalConfig.notification.SLACK_CHANNEL_BACKEND;
19
- mailChannel = globalConfig.notification.MAIL_CHANNEL_BACKEND;
18
+ slackChannel = globalConfig.SLACK_CHANNEL_BACKEND;
19
+ mailAdress = globalConfig.MAIL_ADDRESS_BACKEND;
20
+ msTeamsChannel = globalConfig.MSTEAMS_BACKEND_CHANNEL;
20
21
  } else {
21
- slackChannel = globalConfig.notification.SLACK_CHANNEL_FRONTEND;
22
- mailChannel = globalConfig.notification.MAIL_CHANNEL_FRONTEND;
22
+ slackChannel = globalConfig.SLACK_CHANNEL_FRONTEND;
23
+ mailAdress = globalConfig.MAIL_ADDRESS_FRONTEND;
24
+ msTeamsChannel = globalConfig.MSTEAMS_FRONTEND_CHANNEL;
23
25
  }
24
26
 
25
27
  // checking package notification strategy override
26
28
  if (!pkg.notification && !pkg.slack) {
27
- if (globalConfig.notification.CLIENT === 'SLACK') {
29
+ if (globalConfig.NOTIFICATION_CLIENT === 'SLACK') {
28
30
  return {
29
- CLIENT: globalConfig.notification.CLIENT,
31
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
30
32
  SLACK_HOOK: globalConfig.SLACK_HOOK,
31
33
  SLACK_CHANNEL: slackChannel
32
34
  }
33
- } else {
35
+ } else if (globalConfig.NOTIFICATION_CLIENT === 'MAIL') {
34
36
  return {
35
- CLIENT: globalConfig.notification.CLIENT,
36
- MAIL_ADDRESS: configUtils.global.getNotificationMailAddress(mailChannel)
37
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
38
+ MAIL_ADDRESS: mailAdress
39
+ }
40
+ } else if (globalConfig.NOTIFICATION_CLIENT === 'SLACK') {
41
+ return {
42
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
43
+ MSTEAMS_CHANNEL: msTeamsChannel,
37
44
  }
38
45
  }
39
46
 
@@ -47,18 +54,23 @@ module.exports.getPackageConfig = (pkg) => {
47
54
 
48
55
  // new method, notification config can be either slack or mail
49
56
  } else {
50
- if (pkg.notification.channel) {
57
+ if (pkg.notification) {
51
58
  if (pkg.notification.client === 'SLACK') {
52
59
  return {
53
60
  CLIENT: pkg.notification.client,
54
61
  SLACK_HOOK: globalConfig.SLACK_HOOK,
55
62
  SLACK_CHANNEL: pkg.notification.channel
56
63
  }
57
- } else {
64
+ } else if (pkg.notification.client === 'MAIL') {
58
65
  return {
59
66
  CLIENT: pkg.notification.client,
60
67
  MAIL_ADDRESS: configUtils.global.getNotificationMailAddress(pkg.notification.channel)
61
68
  }
69
+ } else if (pkg.notification.client === 'MSTEAMS') {
70
+ return {
71
+ CLIENT: pkg.notification.client,
72
+ MSTEAMS_CHANNEL: pkg.notification.channel,
73
+ }
62
74
  }
63
75
  }
64
76
  }
@@ -70,16 +82,21 @@ module.exports.getProjectConfig = (project) => {
70
82
 
71
83
  // checking project notification strategy override
72
84
  if (!project.notification && !project.slack) {
73
- if (globalConfig.notification.CLIENT === 'SLACK') {
85
+ if (globalConfig.NOTIFICATION_CLIENT === 'SLACK') {
74
86
  return {
75
- CLIENT: globalConfig.notification.CLIENT,
87
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
76
88
  SLACK_HOOK: globalConfig.SLACK_HOOK,
77
- SLACK_CHANNEL: globalConfig.notification.SLACK_CHANNEL_PROJECT
89
+ SLACK_CHANNEL: globalConfig.SLACK_CHANNEL_PROJECT
78
90
  }
79
- } else {
91
+ } else if (globalConfig.NOTIFICATION_CLIENT === 'MAIL') {
80
92
  return {
81
- CLIENT: globalConfig.notification.CLIENT,
82
- MAIL_ADDRESS: configUtils.global.getNotificationMailAddress(globalConfig.notification.MAIL_CHANNEL_PROJECT)
93
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
94
+ MAIL_ADDRESS: globalConfig.MAIL_ADDRESS_PROJECT
95
+ }
96
+ } else if (globalConfig.NOTIFICATION_CLIENT === 'MSTEAMS') {
97
+ return {
98
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
99
+ MSTEAMS_CHANNEL: globalConfig.MSTEAMS_PROJECT_CHANNEL,
83
100
  }
84
101
  }
85
102
 
@@ -93,31 +110,37 @@ module.exports.getProjectConfig = (project) => {
93
110
 
94
111
  // new method, notification config can be either slack or mail
95
112
  } else {
96
- if (project.notification.channel) {
113
+ if (project.notification) {
97
114
  if (project.notification.client === 'SLACK') {
98
115
  return {
99
116
  CLIENT: project.notification.client,
100
117
  SLACK_HOOK: globalConfig.SLACK_HOOK,
101
118
  SLACK_CHANNEL: project.notification.channel
102
119
  }
103
- } else {
120
+ } else if (project.notification.client === 'MAIL') {
104
121
  return {
105
122
  CLIENT: project.notification.client,
106
123
  MAIL_ADDRESS: configUtils.global.getNotificationMailAddress(project.notification.channel)
107
124
  }
125
+ } else if (project.notification.client === 'MSTEAMS') {
126
+ return {
127
+ CLIENT: globalConfig.NOTIFICATION_CLIENT,
128
+ MSTEAMS_CHANNEL: project.notification.channel,
129
+ }
108
130
  }
109
131
  }
110
132
  }
111
133
  }
112
134
 
113
135
 
114
- module.exports.storeConfig = (rootPath, slackHook, slackChannel, mailAddress) => {
136
+ module.exports.storeConfig = (rootPath, slackHook, slackChannel, mailAddress, msTeamsChannel) => {
115
137
  return Promise.resolve()
116
138
  .then(() => {
117
139
  var content = '';
118
140
  content += `export SLACK_HOOK=${slackHook}\n`;
119
141
  content += `export SLACK_CHANNEL=${slackChannel}\n`;
120
142
  content += `export MAIL_ADDRESS=${mailAddress}\n`;
143
+ content += `export MSTEAMS_CHANNEL=${msTeamsChannel}\n`;
121
144
  return pipelineUtils.setVariables(rootPath, content);
122
145
  })
123
146
 
@@ -130,7 +153,9 @@ module.exports.storePackageConfig = (pkg) => {
130
153
  return Promise.resolve()
131
154
  .then(() => {
132
155
  const config = this.getPackageConfig(pkg);
133
- return this.storeConfig(process.cwd(), config.SLACK_HOOK, config.SLACK_CHANNEL, config.MAIL_ADDRESS);
156
+ return this.storeConfig(
157
+ process.cwd(), config.SLACK_HOOK, config.SLACK_CHANNEL, config.MAIL_ADDRESS, config.MSTEAMS_CHANNEL
158
+ );
134
159
  })
135
160
 
136
161
  .catch((e) => {
@@ -142,7 +167,9 @@ module.exports.storeProjectConfig = (project) => {
142
167
  return Promise.resolve()
143
168
  .then(() => {
144
169
  const config = this.getProjectConfig(project);
145
- return this.storeConfig(project.paths.rootPath, config.SLACK_HOOK, config.SLACK_CHANNEL, config.MAIL_ADDRESS);
170
+ return this.storeConfig(
171
+ project.paths.rootPath, config.SLACK_HOOK, config.SLACK_CHANNEL, config.MAIL_ADDRESS, config.MSTEAMS_CHANNEL
172
+ );
146
173
  })
147
174
 
148
175
  .catch((e) => {
@@ -1,14 +1,15 @@
1
1
  'use strict';
2
2
 
3
- // GLOBALS
4
- const sendmail = require('sendmail')();
5
3
 
6
4
  // LOCALS
7
5
  const tools = require('../tools');
6
+
8
7
  let { dryRun, debug} = tools.getArgs();
9
8
 
10
9
 
11
10
  const sendCore = (subject, body, recipient) => {
11
+ const sendmail = require('sendmail')();
12
+
12
13
  tools.logInfo(`Sending mail to : ${recipient}`);
13
14
  tools.logInfo('Message subject / body :');
14
15
  console.log(subject);
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ // GLOBAL
4
+ const moment = require('moment');
5
+
6
+ // LOCAL
7
+ const tools = require('../tools');
8
+
9
+ // INNER MODS
10
+ const innerConfig = require('./config');
11
+ const innerTeamsUtils = require('./teams-utils');
12
+
13
+ // ARGS
14
+ const { dryRun, debug, notificationActive } = tools.getArgs();
15
+
16
+
17
+ // ---------------------------------------------------------------------------------------
18
+ // MESSAGE BUFFER
19
+ // - used for storing all message happening during a run
20
+ // - used for aggregating messages on a pipeline run to a single mail / ms teams push
21
+ // ---------------------------------------------------------------------------------------
22
+
23
+ const messageContent = {
24
+ buffer: [],
25
+ startTimestamp: null,
26
+ endTimestamp: null,
27
+ duration: null,
28
+ durationMinSec: null
29
+ };
30
+
31
+ module.exports.startStack = () => {
32
+ messageContent.startTimestamp = moment();
33
+ }
34
+
35
+ module.exports.endStack = () => {
36
+ messageContent.endTimestamp = moment();
37
+ messageContent.duration = messageContent.endTimestamp - messageContent.startTimestamp;
38
+ const start = messageContent.startTimestamp, end = messageContent.endTimestamp;
39
+ messageContent.durationMinSec = `${end.diff(start, 'm')}m:${end.diff(start, 's')}s`;
40
+ }
41
+
42
+ module.exports.pushMessage = (message) => {
43
+ messageContent.buffer.push(message);
44
+ }
45
+
46
+
47
+
48
+ const sendMessage = (config) => {
49
+
50
+ if (config.CLIENT === 'SLACK') {
51
+ return Promise.resolve();
52
+ }
53
+
54
+ if (!notificationActive) {
55
+ tools.logInfo('No notifications config found...skipping');
56
+
57
+ if (debug) {
58
+ console.log(messageContent);
59
+ }
60
+
61
+ return Promise.resolve();
62
+
63
+ } else {
64
+ return Promise.resolve()
65
+ .then(() => {
66
+ if (config.CLIENT === 'MSTEAMS') {
67
+ return innerTeamsUtils.sendMessage(config, messageContent);
68
+
69
+ } else if (config.CLIENT === 'MAIL') {
70
+ // TODO IF MAIL NOTIF IS NEEDED...
71
+ }
72
+ })
73
+ .catch((e) => {
74
+ throw e;
75
+ })
76
+ }
77
+ }
78
+
79
+
80
+ module.exports.sendPackageMessage = (pkg) => {
81
+ tools.logTitle(`Sending package message for ${pkg.name}`);
82
+
83
+ const config = innerConfig.getPackageConfig(pkg);
84
+
85
+ tools.logInfo('Notification config : ');
86
+ console.log(config);
87
+
88
+ return Promise.resolve()
89
+ .then(() => {
90
+ return sendMessage(config);
91
+ })
92
+ .catch((e) => {
93
+ throw e;
94
+ })
95
+ }
96
+
97
+
98
+ module.exports.sendProjectMessage = (project) => {
99
+ tools.logTitle(`Sending project message for ${project.name}`);
100
+
101
+ const config = innerConfig.getProjectConfig(project);
102
+
103
+ tools.logInfo('Notification config : ');
104
+ console.log(config);
105
+
106
+ return Promise.resolve()
107
+ .then(() => {
108
+ return sendMessage(config);
109
+ })
110
+ .catch((e) => {
111
+ throw e;
112
+ })
113
+ }
@@ -4,10 +4,10 @@ const innerCommon = require('./common');
4
4
  const innerConfig = require('./config');
5
5
  const innerPackage = require('./package');
6
6
  const innerProject = require('./project');
7
- const innerMailstack = require('./mailstack');
7
+ const innerMessageStack = require('./message-stack');
8
8
 
9
9
  module.exports.common = innerCommon;
10
10
  module.exports.config = innerConfig;
11
11
  module.exports.package = innerPackage;
12
12
  module.exports.project = innerProject;
13
- module.exports.mailstack = innerMailstack;
13
+ module.exports.messageStack = innerMessageStack;
@@ -9,16 +9,24 @@ const tools = require('../tools');
9
9
  // INNER
10
10
  const innerCommon = require('./common');
11
11
  const innerConfig = require('./config');
12
- const innerMailstack = require('./mailstack');
12
+ const innerMessageStack = require('./message-stack');
13
13
 
14
+ // ARGS
15
+ const { debug } = tools.getArgs();
14
16
 
15
17
 
16
18
  module.exports.sendPackageMessage = (options) => {
19
+ tools.logTitle('Sending package message');
17
20
 
18
21
  const message = innerCommon.getMessage(options);
19
22
 
23
+ if (debug) {
24
+ tools.logInfo('Message content :');
25
+ console.log(message);
26
+ }
27
+
20
28
  // buffer message
21
- innerMailstack.bufferMessage(message);
29
+ innerMessageStack.pushMessage(message);
22
30
 
23
31
  // getting package notification config
24
32
  const config = innerConfig.getPackageConfig(options.package);
@@ -41,18 +49,25 @@ module.exports.sendPackageMessage = (options) => {
41
49
 
42
50
 
43
51
  module.exports.sendPackageDiffReportMessage = (pkg, diffMetadata) => {
44
- return Promise.resolve()
45
- .then(() => {
46
- const config = innerConfig.getPackageConfig(pkg);
52
+ tools.logTitle('Sending package difference report message');
47
53
 
48
- return slackUtils.sendPackageDiffReportMessage(
49
- diffMetadata,
50
- config.SLACK_HOOK,
51
- config.SLACK_CHANNEL
52
- );
53
- })
54
+ if (config.CLIENT === 'SLACK') {
55
+ return Promise.resolve()
56
+ .then(() => {
57
+ const config = innerConfig.getPackageConfig(pkg);
54
58
 
55
- .catch((e) => {
56
- throw e;
57
- })
59
+ return slackUtils.sendPackageDiffReportMessage(
60
+ diffMetadata,
61
+ config.SLACK_HOOK,
62
+ config.SLACK_CHANNEL
63
+ );
64
+ })
65
+
66
+ .catch((e) => {
67
+ throw e;
68
+ })
69
+
70
+ } else {
71
+ return Promise.resolve();
72
+ }
58
73
  }
@@ -9,17 +9,25 @@ const tools = require('../tools');
9
9
  // INNER
10
10
  const innerCommon = require('./common');
11
11
  const innerConfig = require('./config');
12
- const innerMailstack = require('./mailstack');
12
+ const innerMessageStack = require('./message-stack');
13
+
14
+ // ARGS
15
+ const { debug } = tools.getArgs();
13
16
 
14
17
 
15
18
  module.exports.sendProjectMessage = (options) => {
16
19
 
17
- tools.logInfo('Sending project message');
20
+ tools.logTitle('Sending project message');
18
21
 
19
22
  const message = innerCommon.getMessage(options);
20
23
 
24
+ if (debug) {
25
+ tools.logInfo('Message content :');
26
+ console.log(message);
27
+ }
28
+
21
29
  // buffer message
22
- innerMailstack.bufferMessage(message);
30
+ innerMessageStack.pushMessage(message);
23
31
 
24
32
  // getting package notification config
25
33
  const config = innerConfig.getProjectConfig(options.project);
@@ -42,6 +50,8 @@ module.exports.sendProjectMessage = (options) => {
42
50
 
43
51
 
44
52
  module.exports.sendProjectDiffReportMessage = (project, diffMetadata) => {
53
+ tools.logTitle('Sending project difference report message');
54
+
45
55
  return Promise.resolve()
46
56
  .then(() => {
47
57
  const config = innerConfig.getProjectConfig(project);
@@ -8,9 +8,6 @@ const HttpsProxyAgent = require('https-proxy-agent');
8
8
  // LOCAL
9
9
  const tools = require('../tools');
10
10
 
11
- // INNER
12
- const innerCommon = require('./common.js');
13
-
14
11
  // FETCH COMMAND-LINE ARGS
15
12
  let { dryRun, slackFeedback, debug } = tools.getArgs();
16
13
 
@@ -130,7 +127,7 @@ const getFields = (scope, version) => {
130
127
 
131
128
 
132
129
  const sendProjectMessage = (hook, channel, message) => {
133
- tools.logTitle('Sending project message');
130
+ tools.logInfo('Sending project message');
134
131
 
135
132
  // do nothing if at least hook / channel for package can't be found
136
133
  if (!hook || !channel) {
@@ -162,7 +159,7 @@ const sendProjectMessage = (hook, channel, message) => {
162
159
 
163
160
 
164
161
  const sendProjectDiffReportMessage = (diffMetadata, slackHook, slackChannel) => {
165
- tools.logTitle('Sending diff report message');
162
+ tools.logInfo('Sending diff report message');
166
163
 
167
164
  // do nothing if at least hook / channel for project can't be found
168
165
  if (!slackHook || !slackChannel) {
@@ -191,29 +188,11 @@ const sendProjectDiffReportMessage = (diffMetadata, slackHook, slackChannel) =>
191
188
 
192
189
 
193
190
 
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
191
 
213
192
 
214
193
 
215
194
  const sendPackageMessage = (hook, channel, message) => {
216
- tools.logTitle('Sending package message');
195
+ tools.logInfo('Sending package message');
217
196
 
218
197
  // do nothing if at least hook / channel for package can't be found
219
198
  if (!hook || !channel) {
@@ -244,11 +223,8 @@ const sendPackageMessage = (hook, channel, message) => {
244
223
  }
245
224
 
246
225
 
247
-
248
-
249
-
250
226
  const sendPackageDiffReportMessage = (diffMetadata, slackHook, slackChannel) => {
251
- tools.logTitle('Sending diff report message');
227
+ tools.logInfo('Sending diff report message');
252
228
 
253
229
  // do nothing if at least hook / channel for project can't be found
254
230
  if (!slackHook || !slackChannel) {
@@ -276,17 +252,6 @@ const sendPackageDiffReportMessage = (diffMetadata, slackHook, slackChannel) =>
276
252
  }
277
253
 
278
254
 
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
255
  // EXPORTS
291
256
 
292
257
  module.exports = {
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ // LOCALS
4
+ const tools = require('../tools');
5
+ const apiUtils = require('../api-utils');
6
+ const configUtils = require('../../csdr/config/config-utils');
7
+
8
+ // ARGS
9
+ const { dryRun, debug} = tools.getArgs();
10
+
11
+
12
+ const getChannelHook = (channelName) => {
13
+ // const { msteamsHookMap } = tools.getArgs();
14
+ // TODO channel/hook map parser (incoming from _CSDR_ARGS gitlab defs)
15
+ return msteamsHook;
16
+ }
17
+
18
+
19
+ const createPayload = (messageContent) => {
20
+ const emojis = {
21
+ rocket: "&#x1f680;",
22
+ sucess: "✅",
23
+ failure: "❌"
24
+ };
25
+
26
+ const statuses = {
27
+ success: { text: '[BUILD SUCCESS]', color: '26A65B', emoji: emojis.sucess},
28
+ failure: { text: '[BUILD FAILED]', color: 'D91E18', emoji: emojis.failure}
29
+ };
30
+
31
+
32
+ // set color : success or failure
33
+ let status = statuses.success;
34
+ if (messageContent.buffer.filter(m => m.status === 'SUCCESS').length === 0) {
35
+ status = statuses.failure;
36
+ }
37
+
38
+ // final status message on the stack
39
+ const finalMessage = messageContent.buffer.slice(-1)[0];
40
+
41
+ // set released version
42
+ const version = finalMessage.version;
43
+
44
+ // set commit history
45
+ const commitHistory = "```" + finalMessage.detailText;
46
+
47
+ // set summary
48
+ const itemName = messageContent.buffer[0].scope;
49
+ const summary = `${status.emoji} :: ${status.text} - ${itemName} - ${version}`;
50
+
51
+ // set release sections
52
+ const publications = messageContent.buffer.filter(m => m.text !== null && m.text.indexOf(':rocket:') > -1);
53
+
54
+ let sections = publications.map((p) => {
55
+ return {
56
+ "activityTitle": version,
57
+ "facts": [],
58
+ "activityText": p.text.replace(':rocket:', emojis.rocket).replace('- *VERSION*', '')
59
+ }
60
+ });
61
+
62
+ sections.push({
63
+ "startGroup": true,
64
+ "activityTitle": "Commit history since last release tag",
65
+ "activityText": commitHistory
66
+ });
67
+
68
+ sections.push({
69
+ "startGroup": true,
70
+ "facts": [
71
+ {
72
+ "name": "Duration",
73
+ "value": `**${messageContent.durationMinSec}**`
74
+ },
75
+ ]
76
+ });
77
+
78
+ // return payload
79
+ return {
80
+ "@type": "MessageCard",
81
+ "@context": "https://schema.org/extensions",
82
+ "summary": summary,
83
+ "themeColor": status.color,
84
+ "title": summary,
85
+ "sections": sections
86
+ };
87
+ }
88
+
89
+
90
+ module.exports.sendMessage = (config, messageContent) => {
91
+ tools.logTitle('Sending MS teams message');
92
+
93
+ const channelHook = getChannelHook(config.MSTEAMS_CHANNEL);
94
+ const payload = createPayload(messageContent);
95
+
96
+ return Promise.resolve()
97
+ .then(() => {
98
+ if (debug) {
99
+ console.log(messageContent);
100
+ console.log(JSON.parse(JSON.stringify(payload, null, 2)));
101
+ }
102
+ })
103
+ .then(() => {
104
+ const host = configUtils.global.getConfigOptions().MSTEAMS_HOST;
105
+
106
+ return apiUtils.post(host, channelHook, JSON.parse(JSON.stringify(payload, null, 2)));
107
+ })
108
+ .then((response) => {
109
+ console.log(response);
110
+ })
111
+ .catch(e => {
112
+ throw e;
113
+ })
114
+ }