@eui/tools 6.12.0 → 6.12.1

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.1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 6.12.1 (2023-06-13)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * 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))
7
+
8
+ * * *
9
+ * * *
1
10
  ## 6.12.0 (2023-06-13)
2
11
 
3
12
  ##### 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.1",
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('cc-summa-shared-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) => {
@@ -116,6 +116,10 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
116
116
  count: 0,
117
117
  indices: []
118
118
  },
119
+ allModules: {
120
+ count: 0,
121
+ indices: []
122
+ },
119
123
  uxCmp: {
120
124
  count: 0,
121
125
  // indices: []
@@ -267,7 +271,20 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
267
271
  }
268
272
  report.material.count += materialIndices.length;
269
273
  report.material.indices = [...report.material.indices, ...generateIndicesContent(materialIndices, file, fileContent)];
270
- })
274
+
275
+ let allModulesIndices = [];
276
+ regex = /EuiAllModule/gi;
277
+ while ( (result = regex.exec(fileContent)) ) {
278
+ allModulesIndices.push(result.index);
279
+ }
280
+ regex = /UxAllModule/gi;
281
+ while ( (result = regex.exec(fileContent)) ) {
282
+ allModulesIndices.push(result.index);
283
+ }
284
+ report.allModules.count += allModulesIndices.length;
285
+ report.allModules.indices = [...report.allModules.indices, ...generateIndicesContent(allModulesIndices, file, fileContent)];
286
+
287
+ })
271
288
 
272
289
 
273
290
 
@@ -381,6 +398,12 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
381
398
  status: (report.primeng.count !== 0) ? 'CRITICAL' : 'OK',
382
399
  comment: (report.primeng.count !== 0) ? 'Remove any PrimeNG usage, deprecated in eUI - this will be blocking as of eUI 16' : null
383
400
  }
401
+ report.finalReport['allModules'] = {
402
+ description: 'Usage of EuiAllModule or UxAllModule',
403
+ value: report.allModules.count,
404
+ status: (report.allModules.count !== 0) ? 'CRITICAL' : 'OK',
405
+ comment: (report.allModules.count !== 0) ? 'Use only tree-shakable eUI module imports (as of 15+)' : null
406
+ }
384
407
 
385
408
  // IMPROVE ONLY
386
409
 
@@ -445,6 +468,8 @@ module.exports.audit = (pkg) => {
445
468
  return;
446
469
  }
447
470
 
471
+ let outputReport;
472
+
448
473
  tools.logTitle('Audit package styles');
449
474
 
450
475
  const report = runStylesAudit(pkg);
@@ -453,6 +478,8 @@ module.exports.audit = (pkg) => {
453
478
  return;
454
479
  }
455
480
 
481
+ outputReport = report;
482
+
456
483
  return Promise.resolve()
457
484
  .then(() => {
458
485
  // FINAL REPORT
@@ -496,27 +523,40 @@ module.exports.audit = (pkg) => {
496
523
  return;
497
524
  }
498
525
 
499
- // getting gates for euiVersion found
500
- let gates = configOptions.AUDIT_STYLES_GATES[euiVersion];
526
+ tools.logTitle(`Checking audit styles gates`);
501
527
 
502
- tools.logTitle(`Checking audit styles gates for local euiVersion : ${euiVersion}`);
528
+ // getting gates
529
+ let gates;
530
+ const euiVersionGates = configOptions.AUDIT_STYLES_GATES[euiVersion];
531
+ const allNewGates = configOptions.AUDIT_STYLES_GATES['ALL_NEW'];
503
532
 
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...');
533
+ tools.logInfo('Checking if the package as gates forced');
534
+ if (pkg.build && pkg.build.stylesAuditCheck) {
535
+ tools.logInfo('All gates checks applied');
536
+ gates = allNewGates;
507
537
 
538
+ } else {
539
+ tools.logInfo('===> no forced gates flag detected ...');
508
540
  tools.logInfo('Checking if package is newly created -- all versions gates are checked in that case');
509
541
 
510
542
  if (metadataUtils.package.isNewPackageBuild(pkg)) {
511
- gates = configOptions.AUDIT_STYLES_GATES['ALL_NEW'];
543
+ gates = allNewGates;
544
+
512
545
  } else {
513
- tools.logInfo('Package is not a newly created package...skipping gates checks...');
514
- return;
546
+ if (euiVersionGates) {
547
+ tools.logInfo('eUI version gates found, applied to older packages where limited gates are set');
548
+ gates = euiVersionGates;
549
+
550
+ } else {
551
+ tools.logInfo('No gates found for local eUI version...');
552
+ return;
553
+ }
515
554
  }
516
555
  }
517
556
 
518
557
  tools.logInfo(`Gates found : ${JSON.stringify(gates)}`);
519
558
 
559
+
520
560
  // checking gates level if any
521
561
  let gatesPassed = true;
522
562
 
@@ -542,6 +582,28 @@ module.exports.audit = (pkg) => {
542
582
  }
543
583
  })
544
584
 
585
+ .then(() => {
586
+ // formatting report for metadata storage
587
+
588
+ const metadataReport = {
589
+ score: outputReport.score,
590
+ total: outputReport.total,
591
+ pcScore: outputReport.pcScore,
592
+ };
593
+
594
+ const summarizedFinalReport = {};
595
+ Object.keys(outputReport.finalReport).forEach((item) => {
596
+ summarizedFinalReport[item] = {
597
+ value: outputReport.finalReport[item].value,
598
+ status: outputReport.finalReport[item].status,
599
+ };
600
+ });
601
+
602
+ metadataReport.finalReport = summarizedFinalReport;
603
+
604
+ return metadataReport;
605
+ })
606
+
545
607
  .catch((e) => {
546
608
  throw e;
547
609
  })
@@ -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(() => {
@@ -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
  });