@eui/tools 6.12.30 → 6.12.32

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.30
1
+ 6.12.32
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ ## 6.12.32 (2023-07-24)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * added mywp-shared audit checks for no sub-entry usage - bypass style audit with disabled feature - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([03bf262e](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/03bf262e20662030ab31a5bbecaf5932b0f282f9))
7
+
8
+ * * *
9
+ * * *
10
+ ## 6.12.31 (2023-07-24)
11
+
12
+ ##### Chores
13
+
14
+ * **other:**
15
+ * adapted routes replacement generation for workspaces refactoring - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([35c997f9](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/35c997f94958ce10d4064017f3cd0a9604a18351))
16
+
17
+ * * *
18
+ * * *
1
19
  ## 6.12.30 (2023-07-21)
2
20
 
3
21
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.12.30",
3
+ "version": "6.12.32",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -93,6 +93,7 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
93
93
  htmlFilesCount: 0,
94
94
  htmlLinesCount: 0,
95
95
  scssLinescount: 0,
96
+ stylesAuditDisabledCount: 0,
96
97
  tsOver500: {
97
98
  count: 0,
98
99
  files: [],
@@ -153,6 +154,10 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
153
154
  count: 0,
154
155
  indices: []
155
156
  },
157
+ mywpSharedAll: {
158
+ count: 0,
159
+ indices: []
160
+ },
156
161
  finalReport: {},
157
162
  };
158
163
 
@@ -175,6 +180,11 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
175
180
  const fileContent = tools.getFileContent(filePath).trim();
176
181
  const linesCount = fileContent.split('\n').length;
177
182
 
183
+ if (fileContent.indexOf('styles-audit-disabled') !== -1) {
184
+ report.stylesAuditDisabledCount++;
185
+ return;
186
+ }
187
+
178
188
  if (fileContent === '') {
179
189
  report.scssEmptyFiles++;
180
190
  }
@@ -255,6 +265,11 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
255
265
  const fileContent = tools.getFileContent(filePath);
256
266
  const linesCount = fileContent.split('\n').length;
257
267
 
268
+ if (fileContent.indexOf('styles-audit-disabled') !== -1) {
269
+ report.stylesAuditDisabledCount++;
270
+ return;
271
+ }
272
+
258
273
  report.htmlLinesCount += linesCount;
259
274
 
260
275
  let result,
@@ -286,6 +301,11 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
286
301
  const fileContent = tools.getFileContent(filePath);
287
302
  const linesCount = fileContent.split('\n').length;
288
303
 
304
+ if (fileContent.indexOf('styles-audit-disabled') !== -1) {
305
+ report.stylesAuditDisabledCount++;
306
+ return;
307
+ }
308
+
289
309
  if (linesCount > 500) {
290
310
  report.tsOver500.count++;
291
311
  report.tsOver500.files.push(file);
@@ -324,6 +344,14 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
324
344
  }
325
345
  report.allModules.count += allModulesIndices.length;
326
346
  report.allModules.indices = [...report.allModules.indices, ...generateIndicesContent(allModulesIndices, file, fileContent)];
347
+
348
+ let mywpSharedAllIndices = [];
349
+ regex = /\@mywp\/shared'|\@mywp\/shared"/gi;
350
+ while ((result = regex.exec(fileContent))) {
351
+ mywpSharedAllIndices.push(result.index);
352
+ }
353
+ report.mywpSharedAll.count += mywpSharedAllIndices.length;
354
+ report.mywpSharedAll.indices = [...report.mywpSharedAll.indices, ...generateIndicesContent(mywpSharedAllIndices, file, fileContent)];
327
355
  });
328
356
 
329
357
  // Analyzing 3rd party dependencies usage
@@ -403,6 +431,15 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
403
431
  };
404
432
  }
405
433
 
434
+ if (report.stylesAuditDisabledCount !==0) {
435
+ report.finalReport['stylesAuditDisabledCount'] = {
436
+ description: 'audit disabled count',
437
+ value: report.stylesAuditDisabledCount,
438
+ status: report.stylesAuditDisabledCount !== 0 ? 'IMPROVE': 'OK',
439
+ comment : report.stylesAuditDisabledCount !==0 ? 'If not done yet, files to be checked by eUI team': null,
440
+ }
441
+ }
442
+
406
443
  // BALANCED - styles content
407
444
 
408
445
  if (report.scssFilesCount !== 0) {
@@ -492,6 +529,12 @@ const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
492
529
  status: report.allModules.count !== 0 ? 'CRITICAL' : 'OK',
493
530
  comment: report.allModules.count !== 0 ? 'Use only tree-shakable eUI module imports (as of 15+)' : null,
494
531
  };
532
+ report.finalReport['mywpSharedAll'] = {
533
+ description: 'Usage of @mywp/shared import without sub-entry',
534
+ value: report.mywpSharedAll.count,
535
+ status: report.mywpSharedAll.count !== 0 ? 'CRITICAL' : 'OK',
536
+ comment: report.mywpSharedAll.count !== 0 ? 'use only import of @mywp/shared/SUB_ENTRY (as of 16+)' : null,
537
+ };
495
538
 
496
539
  // IMPROVE ONLY
497
540
 
@@ -428,6 +428,7 @@ const generateLinks = (project, routes, envTargetFinal) => {
428
428
  r.menuLinkDefs.forEach((md) => {
429
429
  if (md.url === link.url) {
430
430
  routeDef = md;
431
+ routeDef.path = r.path;
431
432
  if (link.id) {
432
433
  routeDef.id = link.id;
433
434
  }
@@ -440,26 +441,11 @@ const generateLinks = (project, routes, envTargetFinal) => {
440
441
  if (link.dashboardWidgetDisabled) {
441
442
  routeDef.dashboardWidgetDisabled = link.dashboardWidgetDisabled;
442
443
  }
443
- return;
444
- }
445
- });
446
- }
447
- });
448
- }
449
-
450
- return routeDef;
451
- };
452
-
453
- const getRouteDefFromMenuLink = (link) => {
454
- let routeDef = null;
444
+ if (link.alwaysDisplayed) {
445
+ routeDef.alwaysDisplayed = link.alwaysDisplayed;
446
+ }
455
447
 
456
- if (link.url) {
457
- routeDefsBaseJSON.forEach((r) => {
458
- if (r.menuLinkDefs && r.menuLinkDefs.length > 0) {
459
- r.menuLinkDefs.forEach((md) => {
460
- if (md.url === link.url) {
461
- routeDef = r;
462
- return;
448
+ return;
463
449
  }
464
450
  });
465
451
  }
@@ -495,7 +481,7 @@ const generateLinks = (project, routes, envTargetFinal) => {
495
481
  const linksGenerated = [];
496
482
 
497
483
  routeDefsBaseLinksJSON.forEach((link) => {
498
- let newLink;
484
+ let newLink = null;
499
485
 
500
486
  if (link.parentId) {
501
487
  if (isLinkAllowed(link)) {
@@ -507,6 +493,16 @@ const generateLinks = (project, routes, envTargetFinal) => {
507
493
  const defRoute = getRouteMenuDef(subLink);
508
494
 
509
495
  if (defRoute) {
496
+ if (project.externalRoutesSources.routesFilenameTemplate.indexOf('playground') > 0) {
497
+ const routePathInInputRoutes = routes.filter(r => r.angularRouteDef.path === defRoute.path)[0];
498
+
499
+ if (!routePathInInputRoutes) {
500
+ defRoute.disabled = true;
501
+
502
+ } else {
503
+ tools.logInfo(`[${defRoute.url}] --> route found in input routes - enabled`);
504
+ }
505
+ }
510
506
  newLink.children.push(defRoute);
511
507
  }
512
508
  }
@@ -517,13 +513,18 @@ const generateLinks = (project, routes, envTargetFinal) => {
517
513
  const defRoute = getRouteMenuDef(link);
518
514
 
519
515
  if (defRoute) {
520
- newLink = defRoute;
521
- } else {
522
- newLink = link;
523
- }
516
+ if (project.externalRoutesSources.routesFilenameTemplate.indexOf('playground') > 0) {
517
+ const routePathInInputRoutes = routes.filter(r => r.angularRouteDef.path === defRoute.path)[0];
524
518
 
525
- if (link.alwaysDisplayed) {
526
- newLink.alwaysDisplayed = true;
519
+ if (!routePathInInputRoutes) {
520
+ defRoute.disabled = true;
521
+ } else {
522
+ tools.logInfo(`[${defRoute.url}] --> route found in input routes - enabled`);
523
+ }
524
+ }
525
+ newLink = {...defRoute};
526
+ } else {
527
+ newLink = {...link};
527
528
  }
528
529
  }
529
530
  }
@@ -531,71 +532,16 @@ const generateLinks = (project, routes, envTargetFinal) => {
531
532
  if (newLink) {
532
533
  linksGenerated.push(newLink);
533
534
  }
534
-
535
- if (debug) {
536
- console.log('Links generated');
537
- console.log(JSON.stringify(linksGenerated));
538
- }
539
535
  });
540
536
 
541
- tools.logInfo(`Links generated : ${linksGenerated.length} found`);
542
-
543
- // checking if in playground route mode (local dev), in this case we mark the non-existing routes
544
- // as disabled locally
545
- let finalLinksGenerated = [];
546
- if (project.externalRoutesSources.routesFilenameTemplate.indexOf('playground') > 0) {
547
- tools.logInfo('Disabling non-active routes for playground');
548
-
549
- linksGenerated.forEach((link) => {
550
- let newLink = link;
551
-
552
- if (link.parentId) {
553
- let newLinkChildren = [];
554
-
555
- link.children.forEach((subLink) => {
556
- const defRoute = getRouteDefFromMenuLink(subLink);
557
-
558
- if (defRoute) {
559
- const routePathInInputRoutes = routes.filter(r => r.angularRouteDef.path === defRoute.path)[0];
560
-
561
- if (!routePathInInputRoutes) {
562
- subLink.disabled = true;
563
-
564
- } else {
565
- tools.logInfo(`[${subLink.url}] --> route found in input routes - enabled`);
566
- }
567
- }
568
- newLinkChildren.push(subLink);
569
- });
570
- newLink.children = newLinkChildren;
571
-
572
- const enabledChildren = newLink.children.filter(c => !c.disabled);
573
- if (enabledChildren.length === 0) {
574
- newLink.disabled = true;
575
- }
576
-
577
- } else {
578
- const defRoute = getRouteDefFromMenuLink(link);
579
-
580
- if (defRoute) {
581
- const routePathInInputRoutes = routes.filter(r => r.angularRouteDef.path === defRoute.path)[0];
537
+ // if (debug) {
538
+ // console.log('Links generated');
539
+ // console.log(linksGenerated);
540
+ // }
582
541
 
583
- if (!routePathInInputRoutes) {
584
- newLink.disabled = true;
585
- } else {
586
- tools.logInfo(`[${link.url}] --> route found in input routes - enabled`);
587
- }
588
- }
589
- }
590
-
591
- finalLinksGenerated.push(newLink);
592
- });
593
-
594
- } else {
595
- finalLinksGenerated = linksGenerated;
596
- }
542
+ tools.logInfo(`Links generated : ${linksGenerated.length} found`);
597
543
 
598
- tools.writeJsonFileSync(path.join(project.paths.assetsPath, 'route-defs-links.json'), finalLinksGenerated);
544
+ tools.writeJsonFileSync(path.join(project.paths.assetsPath, 'route-defs-links.json'), linksGenerated);
599
545
  }
600
546
 
601
547