@eui/tools 6.12.0 → 6.12.2

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.12.0
1
+ 6.12.2
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.12.2 (2023-06-13)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * adjusted styles report - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([29457541](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/2945754155ec262c76c8443cee0885b205301fe4))
7
+
8
+ * * *
9
+ * * *
10
+ ## 6.12.1 (2023-06-13)
11
+
12
+ ##### Chores
13
+
14
+ * **other:**
15
+ * adapted styles audit report - metadata storage - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([6e03d9e6](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/6e03d9e68757f5d79be048332c3dc4bbc81577e3))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 6.12.0 (2023-06-13)
2
20
 
3
21
  ##### New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.12.0",
3
+ "version": "6.12.2",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
package/sandbox.js CHANGED
@@ -1251,15 +1251,22 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
1251
1251
 
1252
1252
  Promise.resolve()
1253
1253
  .then(() => {
1254
+ // old package without gates forced
1254
1255
  const pkg = configUtils.packages.getPackage('folio-fo-ui', true);
1255
1256
  console.log(metadataUtils.package.isNewPackageBuild(pkg));
1256
- const pkg2 = configUtils.packages.getPackage('cc-summa-shared-ui', true);
1257
+
1258
+ // existing pkg but forced to all gates
1259
+ const pkg2 = configUtils.packages.getPackage('mapar-administration-ui', true);
1257
1260
  console.log(metadataUtils.package.isNewPackageBuild(pkg2));
1258
1261
 
1259
- return auditUtils.styles.audit(pkg);
1262
+ // newly created pkg
1263
+ const pkg3 = configUtils.packages.getPackage('coli-management-ui', true);
1264
+ console.log(metadataUtils.package.isNewPackageBuild(pkg3));
1265
+
1266
+ return auditUtils.styles.audit(pkg2);
1260
1267
  })
1261
- .then(() => {
1262
- console.log('ok');
1268
+ .then((report) => {
1269
+ console.log(report);
1263
1270
  })
1264
1271
 
1265
1272
  .catch((e) => {
@@ -104,6 +104,10 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
104
104
  count: 0,
105
105
  indices: []
106
106
  },
107
+ zIndex: {
108
+ count: 0,
109
+ indices: []
110
+ },
107
111
  inlineStyles: {
108
112
  count: 0,
109
113
  indices: []
@@ -116,6 +120,10 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
116
120
  count: 0,
117
121
  indices: []
118
122
  },
123
+ allModules: {
124
+ count: 0,
125
+ indices: []
126
+ },
119
127
  uxCmp: {
120
128
  count: 0,
121
129
  // indices: []
@@ -205,6 +213,14 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
205
213
  }
206
214
  report.ngDeep.count += ngDeepIndices.length;
207
215
  report.ngDeep.indices = [...report.ngDeep.indices, ...generateIndicesContent(ngDeepIndices, file, fileContent)];
216
+
217
+ let zIndexIndices = [];
218
+ regex = /z-index/gi;
219
+ while ( (result = regex.exec(fileContent)) ) {
220
+ zIndexIndices.push(result.index);
221
+ }
222
+ report.zIndex.count += zIndexIndices.length;
223
+ report.zIndex.indices = [...report.zIndex.indices, ...generateIndicesContent(zIndexIndices, file, fileContent)];
208
224
  });
209
225
 
210
226
 
@@ -267,7 +283,20 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
267
283
  }
268
284
  report.material.count += materialIndices.length;
269
285
  report.material.indices = [...report.material.indices, ...generateIndicesContent(materialIndices, file, fileContent)];
270
- })
286
+
287
+ let allModulesIndices = [];
288
+ regex = /EuiAllModule/gi;
289
+ while ( (result = regex.exec(fileContent)) ) {
290
+ allModulesIndices.push(result.index);
291
+ }
292
+ regex = /UxAllModule/gi;
293
+ while ( (result = regex.exec(fileContent)) ) {
294
+ allModulesIndices.push(result.index);
295
+ }
296
+ report.allModules.count += allModulesIndices.length;
297
+ report.allModules.indices = [...report.allModules.indices, ...generateIndicesContent(allModulesIndices, file, fileContent)];
298
+
299
+ })
271
300
 
272
301
 
273
302
 
@@ -358,6 +387,12 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
358
387
  status: getStatus(report.ngDeep.count),
359
388
  comment: (report.ngDeep.count !== 0) ? 'Avoid ::ng-deep usage' : null
360
389
  }
390
+ report.finalReport['zIndex'] = {
391
+ description: 'z-index usage found',
392
+ value: report.zIndex.count,
393
+ status: getStatus(report.zIndex.count),
394
+ comment: (report.zIndex.count !== 0) ? 'Avoid z-index setting, usage of eUI CSS vars should be applied' : null
395
+ }
361
396
  }
362
397
 
363
398
  // CRITICAL ONLY
@@ -381,6 +416,12 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
381
416
  status: (report.primeng.count !== 0) ? 'CRITICAL' : 'OK',
382
417
  comment: (report.primeng.count !== 0) ? 'Remove any PrimeNG usage, deprecated in eUI - this will be blocking as of eUI 16' : null
383
418
  }
419
+ report.finalReport['allModules'] = {
420
+ description: 'Usage of EuiAllModule or UxAllModule',
421
+ value: report.allModules.count,
422
+ status: (report.allModules.count !== 0) ? 'CRITICAL' : 'OK',
423
+ comment: (report.allModules.count !== 0) ? 'Use only tree-shakable eUI module imports (as of 15+)' : null
424
+ }
384
425
 
385
426
  // IMPROVE ONLY
386
427
 
@@ -445,6 +486,8 @@ module.exports.audit = (pkg) => {
445
486
  return;
446
487
  }
447
488
 
489
+ let outputReport;
490
+
448
491
  tools.logTitle('Audit package styles');
449
492
 
450
493
  const report = runStylesAudit(pkg);
@@ -453,6 +496,8 @@ module.exports.audit = (pkg) => {
453
496
  return;
454
497
  }
455
498
 
499
+ outputReport = report;
500
+
456
501
  return Promise.resolve()
457
502
  .then(() => {
458
503
  // FINAL REPORT
@@ -496,27 +541,40 @@ module.exports.audit = (pkg) => {
496
541
  return;
497
542
  }
498
543
 
499
- // getting gates for euiVersion found
500
- let gates = configOptions.AUDIT_STYLES_GATES[euiVersion];
544
+ tools.logTitle(`Checking audit styles gates`);
501
545
 
502
- tools.logTitle(`Checking audit styles gates for local euiVersion : ${euiVersion}`);
546
+ // getting gates
547
+ let gates;
548
+ const euiVersionGates = configOptions.AUDIT_STYLES_GATES[euiVersion];
549
+ const allNewGates = configOptions.AUDIT_STYLES_GATES['ALL_NEW'];
503
550
 
504
- // if no gates found for corresponding version, checking if new package for new builds
505
- if (!gates) {
506
- tools.logInfo('No gates found for local eUI version...');
551
+ tools.logInfo('Checking if the package as gates forced');
552
+ if (pkg.build && pkg.build.stylesAuditCheck) {
553
+ tools.logInfo('All gates checks applied');
554
+ gates = allNewGates;
507
555
 
556
+ } else {
557
+ tools.logInfo('===> no forced gates flag detected ...');
508
558
  tools.logInfo('Checking if package is newly created -- all versions gates are checked in that case');
509
559
 
510
560
  if (metadataUtils.package.isNewPackageBuild(pkg)) {
511
- gates = configOptions.AUDIT_STYLES_GATES['ALL_NEW'];
561
+ gates = allNewGates;
562
+
512
563
  } else {
513
- tools.logInfo('Package is not a newly created package...skipping gates checks...');
514
- return;
564
+ if (euiVersionGates) {
565
+ tools.logInfo('eUI version gates found, applied to older packages where limited gates are set');
566
+ gates = euiVersionGates;
567
+
568
+ } else {
569
+ tools.logInfo('No gates found for local eUI version...');
570
+ return;
571
+ }
515
572
  }
516
573
  }
517
574
 
518
575
  tools.logInfo(`Gates found : ${JSON.stringify(gates)}`);
519
576
 
577
+
520
578
  // checking gates level if any
521
579
  let gatesPassed = true;
522
580
 
@@ -542,6 +600,28 @@ module.exports.audit = (pkg) => {
542
600
  }
543
601
  })
544
602
 
603
+ .then(() => {
604
+ // formatting report for metadata storage
605
+
606
+ const metadataReport = {
607
+ score: outputReport.score,
608
+ total: outputReport.total,
609
+ pcScore: outputReport.pcScore,
610
+ };
611
+
612
+ const summarizedFinalReport = {};
613
+ Object.keys(outputReport.finalReport).forEach((item) => {
614
+ summarizedFinalReport[item] = {
615
+ value: outputReport.finalReport[item].value,
616
+ status: outputReport.finalReport[item].status,
617
+ };
618
+ });
619
+
620
+ metadataReport.finalReport = summarizedFinalReport;
621
+
622
+ return metadataReport;
623
+ })
624
+
545
625
  .catch((e) => {
546
626
  throw e;
547
627
  })
@@ -391,8 +391,10 @@ module.exports.getConfigOptions = () => {
391
391
  "plainColors": gatesForVersion.plainColors,
392
392
  "important": gatesForVersion.important,
393
393
  "ngDeep": gatesForVersion.ngDeep,
394
+ "zIndex": gatesForVersion.zIndex,
394
395
  "inlineStyles": gatesForVersion.inlineStyles,
395
- "uxCmp": gatesForVersion.uxCmp
396
+ "uxCmp": gatesForVersion.uxCmp,
397
+ "allModules": gatesForVersion.allModules,
396
398
  };
397
399
  })
398
400
  }
@@ -37,7 +37,7 @@ module.exports.getMetadataSync = (pkg) => {
37
37
  return tools.getJsonFileContent(path.join(DEVOPS_METADATA_PATH, pkg.devopsVersionsMetadataFile));
38
38
  }
39
39
 
40
- module.exports.storeMetadata = (pkg, pkgVersion, pkgCompositeDeps, duration, envTarget, branches) => {
40
+ module.exports.storeMetadata = (pkg, pkgVersion, pkgCompositeDeps, duration, envTarget, branches, auditStylesReport) => {
41
41
  return Promise.resolve()
42
42
  .then(() => {
43
43
  tools.logInfo('Storing package version history metadata...');
@@ -75,6 +75,12 @@ module.exports.storeMetadata = (pkg, pkgVersion, pkgCompositeDeps, duration, env
75
75
  hotfix: isHotfixVersion,
76
76
  };
77
77
 
78
+ if (auditStylesReport) {
79
+ if (!pkg.backend && !pkg.remote) {
80
+ newVersionMetadata.auditStylesReport = auditStylesReport;
81
+ }
82
+ }
83
+
78
84
  if (pkg.remote) {
79
85
  tools.logInfo('Writing remote composite dependencies');
80
86
  newVersionMetadata.dependencies = pkgCompositeDeps;
@@ -17,13 +17,13 @@ const innerPackageVersions = require('./package-versions');
17
17
  const { dryRun } = tools.getArgs();
18
18
 
19
19
 
20
- module.exports.storeMetadata = (pkg, pkgVersion, pkgMetadata, branches, pkgCompositeDeps, duration, envTarget) => {
20
+ module.exports.storeMetadata = (pkg, pkgVersion, pkgMetadata, branches, pkgCompositeDeps, duration, envTarget, auditStylesReport) => {
21
21
 
22
22
  tools.logTitle('Storing central and package metadata...');
23
23
 
24
24
  return Promise.resolve()
25
25
  .then(() => {
26
- return innerPackageVersions.storeMetadata(pkg, pkgVersion, pkgCompositeDeps, duration, envTarget, branches);
26
+ return innerPackageVersions.storeMetadata(pkg, pkgVersion, pkgCompositeDeps, duration, envTarget, branches, auditStylesReport);
27
27
  })
28
28
 
29
29
  .then(() => {
@@ -253,18 +253,26 @@ module.exports.getPackageVersionFirst = (pkg) => {
253
253
  }
254
254
 
255
255
  module.exports.isNewPackageBuild = (pkg) => {
256
- tools.logInfo('Checking if package is a newly created one : first build date after 2023/06/01');
256
+ tools.logInfo('Checking if package is a newly created one : first build date after 2023/06/01 or never built for MASTER');
257
257
 
258
258
  const firstPackageVersion = this.getPackageVersionFirst(pkg);
259
+ const versionsLatest = this.getPackageVersionsLatest(pkg);
259
260
 
260
261
  if (firstPackageVersion) {
261
- const pkgDate = firstPackageVersion.date;
262
262
 
263
- const pivotDate = moment('20230601');
264
- const pkgDateM = moment(pkgDate, 'YYYYMMDD-HH:mm');
265
- tools.logInfo(`First package build version date : ${pkgDate}`);
266
- tools.logInfo(`==> NEW package : ${pkgDateM > pivotDate}`);
267
- return pkgDateM > pivotDate;
263
+ if (versionsLatest.length === 0) {
264
+ tools.logInfo(`==> package has never been built for MASTER / latest version, package is considered new`);
265
+ return true;
266
+
267
+ } else {
268
+ const pkgDate = firstPackageVersion.date;
269
+
270
+ const pivotDate = moment('20230601');
271
+ const pkgDateM = moment(pkgDate, 'YYYYMMDD-HH:mm');
272
+ tools.logInfo(`First package build version date : ${pkgDate}`);
273
+ tools.logInfo(`==> NEW package : ${pkgDateM > pivotDate}`);
274
+ return pkgDateM > pivotDate;
275
+ }
268
276
 
269
277
  } else {
270
278
  tools.logInfo(`==> no versions metadata found : first build, package is new`);
@@ -483,7 +483,7 @@ module.exports.runGitOperations = (pkg, version) => {
483
483
 
484
484
 
485
485
 
486
- module.exports.storeMetadata = (pkg, version, pkgMetadata, pkgCompositeDeps, duration, envTarget) => {
486
+ module.exports.storeMetadata = (pkg, version, pkgMetadata, pkgCompositeDeps, duration, envTarget, auditStylesReport) => {
487
487
  utils.tools.logBanner('STORE METADATA');
488
488
 
489
489
  const branches = this.getBranches();
@@ -495,7 +495,8 @@ module.exports.storeMetadata = (pkg, version, pkgMetadata, pkgCompositeDeps, dur
495
495
  branches,
496
496
  pkgCompositeDeps,
497
497
  duration,
498
- envTarget
498
+ envTarget,
499
+ auditStylesReport,
499
500
  );
500
501
  })
501
502
 
@@ -40,7 +40,7 @@ module.exports.run = () => {
40
40
 
41
41
 
42
42
  // local saved vars
43
- var newVersion, pkgMetadata, pkgCompositeDeps;
43
+ var newVersion, pkgMetadata, pkgCompositeDeps, auditStylesReport;
44
44
 
45
45
 
46
46
  return Promise.resolve()
@@ -119,6 +119,10 @@ module.exports.run = () => {
119
119
  .then(() => {
120
120
  return utils.buildPackage.build(pkg, branches.isMaster);
121
121
  })
122
+ .then((report) => {
123
+ // storing audit styles metadata for storage
124
+ auditStylesReport = report;
125
+ })
122
126
 
123
127
 
124
128
  // EXECUTING SONAR ANALYSIS
@@ -179,7 +183,7 @@ module.exports.run = () => {
179
183
  .then(() => {
180
184
  // get run duration
181
185
  const duration = utils.pipeline.getTimerDuration();
182
- return innerCommon.storeMetadata(pkg, newVersion, pkgMetadata, pkgCompositeDeps, duration, envTarget);
186
+ return innerCommon.storeMetadata(pkg, newVersion, pkgMetadata, pkgCompositeDeps, duration, envTarget, auditStylesReport);
183
187
  })
184
188
 
185
189
  // STORING PACKAGE HISTORY
@@ -19,6 +19,8 @@ module.exports.build = (pkg, isMaster) => {
19
19
  // FETCH ARGS
20
20
  let { deps, skipClean, skipLint, skipTest, skipCompile, skipDoc, build, skipAudit } = pkg.build? {...pkg.build, ...tools.getArgs()} : tools.getArgs();
21
21
 
22
+ let auditStylesReport;
23
+
22
24
  return Promise.resolve()
23
25
  .then(() => {
24
26
  if (deps === true) {
@@ -92,7 +94,11 @@ module.exports.build = (pkg, isMaster) => {
92
94
  return auditUtils.styles.audit(pkg);
93
95
  }
94
96
  })
95
- .then(() => {
97
+ .then((report) => {
98
+ if (report) {
99
+ auditStylesReport = report;
100
+ }
101
+
96
102
  if (!skipCompile) {
97
103
  tools.logInfo('Bundling package...');
98
104
  let args = ['--max_old_space_size=8096', ng, 'build', pkg.name];
@@ -218,6 +224,10 @@ module.exports.build = (pkg, isMaster) => {
218
224
  })
219
225
  })
220
226
 
227
+ .then(() => {
228
+ return auditStylesReport;
229
+ })
230
+
221
231
  .catch((e) => {
222
232
  throw e;
223
233
  });