@eui/tools 6.12.23 → 6.12.24
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.
- package/.version.properties +1 -1
- package/CHANGELOG.md +9 -0
- package/package.json +1 -1
- package/sandbox.js +10 -2
- package/scripts/csdr/audit/styles.js +414 -400
- package/scripts/csdr/config/packages.js +8 -0
- package/scripts/csdr/install/packages.js +7 -0
package/.version.properties
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.12.
|
|
1
|
+
6.12.24
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## 6.12.24 (2023-06-27)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* added 3rd party dependencies check on styles audit report - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([6e45e6eb](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/6e45e6eb890646c9ba085fa188a83683028e752d))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
1
10
|
## 6.12.23 (2023-06-26)
|
|
2
11
|
|
|
3
12
|
##### Bug Fixes
|
package/package.json
CHANGED
package/sandbox.js
CHANGED
|
@@ -1248,11 +1248,18 @@ const versionUtils = require('./scripts/csdr/version/version-utils');
|
|
|
1248
1248
|
// console.log(e);
|
|
1249
1249
|
// process.exit(1);
|
|
1250
1250
|
// })
|
|
1251
|
-
|
|
1251
|
+
// Promise.resolve()
|
|
1252
|
+
// .then(() => {
|
|
1253
|
+
// const scopes = configUtils.packages.getPackageScopes();
|
|
1254
|
+
// console.log(scopes);
|
|
1255
|
+
// })
|
|
1256
|
+
// .catch((e) => {
|
|
1257
|
+
// console.log(e);
|
|
1258
|
+
// })
|
|
1252
1259
|
Promise.resolve()
|
|
1253
1260
|
.then(() => {
|
|
1254
1261
|
// old package without gates forced
|
|
1255
|
-
const pkg = configUtils.packages.getPackage('cc-
|
|
1262
|
+
const pkg = configUtils.packages.getPackage('cc-echecklist-admin-ui', true);
|
|
1256
1263
|
console.log(pkg);
|
|
1257
1264
|
|
|
1258
1265
|
return auditUtils.styles.audit(pkg);
|
|
@@ -1264,3 +1271,4 @@ Promise.resolve()
|
|
|
1264
1271
|
.catch((e) => {
|
|
1265
1272
|
console.log(e);
|
|
1266
1273
|
})
|
|
1274
|
+
|
|
@@ -9,22 +9,21 @@ const tools = require('../../utils/tools');
|
|
|
9
9
|
const notificationUtils = require('../../utils/notification/notification-utils');
|
|
10
10
|
const configUtils = require('../config/config-utils');
|
|
11
11
|
const metadataUtils = require('../metadata/metadata-utils');
|
|
12
|
+
const installUtils = require('../install/install-utils');
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
15
|
-
|
|
14
|
+
const runStylesAudit = (module.exports.runStylesAudit = (pkg, customPath) => {
|
|
16
15
|
const generateIndicesContent = (indices, file, fileContent, exclusions = []) => {
|
|
17
16
|
let content = [];
|
|
18
17
|
|
|
19
18
|
indices.forEach((i) => {
|
|
20
|
-
for (var pos = i-1; pos >=0; pos--) {
|
|
19
|
+
for (var pos = i - 1; pos >= 0; pos--) {
|
|
21
20
|
if (fileContent.charAt(pos) === '\n') {
|
|
22
21
|
break;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
const remaining = fileContent.substring(pos+1).trim();
|
|
24
|
+
const remaining = fileContent.substring(pos + 1).trim();
|
|
26
25
|
const breakPos = remaining.indexOf('\n');
|
|
27
|
-
const indiceContent = remaining.substring(0, breakPos-1);
|
|
26
|
+
const indiceContent = remaining.substring(0, breakPos - 1);
|
|
28
27
|
|
|
29
28
|
const lineNumber = fileContent.substring(0, i).split('\n').length;
|
|
30
29
|
|
|
@@ -36,19 +35,19 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
36
35
|
if (indiceContent === '') {
|
|
37
36
|
excluded = true;
|
|
38
37
|
}
|
|
39
|
-
})
|
|
38
|
+
});
|
|
40
39
|
|
|
41
40
|
if (!excluded) {
|
|
42
41
|
content.push({
|
|
43
42
|
file: file,
|
|
44
43
|
lineNumber: lineNumber,
|
|
45
44
|
content: indiceContent,
|
|
46
|
-
})
|
|
45
|
+
});
|
|
47
46
|
}
|
|
48
|
-
})
|
|
47
|
+
});
|
|
49
48
|
|
|
50
49
|
return content;
|
|
51
|
-
}
|
|
50
|
+
};
|
|
52
51
|
|
|
53
52
|
const recalculateIndicesCount = (indicesContent) => {
|
|
54
53
|
let count = 0;
|
|
@@ -60,16 +59,11 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
return count;
|
|
63
|
-
}
|
|
62
|
+
};
|
|
64
63
|
|
|
65
64
|
const getStatus = (count) => {
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
return count > 5 ? 'CRITICAL' : count > 0 && count <= 5 ? 'IMPROVE' : 'OK';
|
|
66
|
+
};
|
|
73
67
|
|
|
74
68
|
// checking params
|
|
75
69
|
|
|
@@ -87,7 +81,6 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
87
81
|
tools.logTitle(`Auditing : ${pkg.name}`);
|
|
88
82
|
}
|
|
89
83
|
|
|
90
|
-
|
|
91
84
|
// setting default report object
|
|
92
85
|
|
|
93
86
|
const report = {
|
|
@@ -102,64 +95,67 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
102
95
|
scssLinescount: 0,
|
|
103
96
|
tsOver500: {
|
|
104
97
|
count: 0,
|
|
105
|
-
files: []
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
files: [],
|
|
99
|
+
},
|
|
100
|
+
thirdPartyDependencies: {
|
|
101
|
+
count: 0,
|
|
102
|
+
dependencies: [],
|
|
103
|
+
},
|
|
104
|
+
euiOverrides: {
|
|
105
|
+
count: 0,
|
|
106
|
+
indices: [],
|
|
110
107
|
},
|
|
111
108
|
sizesPxEm: {
|
|
112
109
|
count: 0,
|
|
113
|
-
indices: []
|
|
110
|
+
indices: [],
|
|
114
111
|
},
|
|
115
112
|
boxShadow: {
|
|
116
113
|
count: 0,
|
|
117
|
-
indices: []
|
|
114
|
+
indices: [],
|
|
118
115
|
},
|
|
119
116
|
fontFamily: {
|
|
120
117
|
count: 0,
|
|
121
|
-
indices: []
|
|
118
|
+
indices: [],
|
|
122
119
|
},
|
|
123
120
|
important: {
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
count: 0,
|
|
122
|
+
indices: [],
|
|
126
123
|
},
|
|
127
124
|
plainColors: {
|
|
128
125
|
count: 0,
|
|
129
|
-
indices: []
|
|
126
|
+
indices: [],
|
|
130
127
|
},
|
|
131
128
|
ngDeep: {
|
|
132
129
|
count: 0,
|
|
133
|
-
indices: []
|
|
130
|
+
indices: [],
|
|
134
131
|
},
|
|
135
132
|
zIndex: {
|
|
136
133
|
count: 0,
|
|
137
|
-
indices: []
|
|
134
|
+
indices: [],
|
|
138
135
|
},
|
|
139
136
|
inlineStyles: {
|
|
140
137
|
count: 0,
|
|
141
|
-
indices: []
|
|
138
|
+
indices: [],
|
|
142
139
|
},
|
|
143
140
|
material: {
|
|
144
141
|
count: 0,
|
|
145
|
-
indices: []
|
|
142
|
+
indices: [],
|
|
146
143
|
},
|
|
147
144
|
primeng: {
|
|
148
145
|
count: 0,
|
|
149
|
-
indices: []
|
|
146
|
+
indices: [],
|
|
150
147
|
},
|
|
151
148
|
allModules: {
|
|
152
149
|
count: 0,
|
|
153
|
-
indices: []
|
|
150
|
+
indices: [],
|
|
154
151
|
},
|
|
155
152
|
uxCmp: {
|
|
156
153
|
count: 0,
|
|
157
154
|
// indices: []
|
|
158
155
|
},
|
|
159
|
-
finalReport: {}
|
|
156
|
+
finalReport: {},
|
|
160
157
|
};
|
|
161
158
|
|
|
162
|
-
|
|
163
159
|
if (customPath) {
|
|
164
160
|
report.package = customPath;
|
|
165
161
|
} else {
|
|
@@ -174,7 +170,7 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
174
170
|
|
|
175
171
|
report.scssFilesCount += files.length;
|
|
176
172
|
|
|
177
|
-
files.forEach(file => {
|
|
173
|
+
files.forEach((file) => {
|
|
178
174
|
const filePath = path.join(srcPath, file);
|
|
179
175
|
const fileContent = tools.getFileContent(filePath).trim();
|
|
180
176
|
const linesCount = fileContent.split('\n').length;
|
|
@@ -184,338 +180,359 @@ const runStylesAudit = module.exports.runStylesAudit = (pkg, customPath) => {
|
|
|
184
180
|
}
|
|
185
181
|
report.scssLinescount += linesCount;
|
|
186
182
|
|
|
183
|
+
let result,
|
|
184
|
+
euiIndices = [];
|
|
185
|
+
let regex = /\.eui|\.ux/gi;
|
|
186
|
+
while ((result = regex.exec(fileContent))) {
|
|
187
|
+
euiIndices.push(result.index);
|
|
188
|
+
}
|
|
189
|
+
report.euiOverrides.count += euiIndices.length;
|
|
190
|
+
report.euiOverrides.indices = [...report.euiOverrides.indices, ...generateIndicesContent(euiIndices, file, fileContent)];
|
|
191
|
+
|
|
192
|
+
let sizesIndices = [];
|
|
193
|
+
regex = /px/gi;
|
|
194
|
+
while ((result = regex.exec(fileContent))) {
|
|
195
|
+
sizesIndices.push(result.index);
|
|
196
|
+
}
|
|
197
|
+
report.sizesPxEm.count += sizesIndices.length;
|
|
198
|
+
report.sizesPxEm.indices = [...report.sizesPxEm.indices, ...generateIndicesContent(sizesIndices, file, fileContent)];
|
|
199
|
+
|
|
200
|
+
let boxShadowIndices = [];
|
|
201
|
+
regex = /box-shadow/gi;
|
|
202
|
+
while ((result = regex.exec(fileContent))) {
|
|
203
|
+
boxShadowIndices.push(result.index);
|
|
204
|
+
}
|
|
205
|
+
report.boxShadow.count += boxShadowIndices.length;
|
|
206
|
+
report.boxShadow.indices = [...report.boxShadow.indices, ...generateIndicesContent(boxShadowIndices, file, fileContent)];
|
|
207
|
+
|
|
208
|
+
let fontFamilyIndices = [];
|
|
209
|
+
regex = /font-family/gi;
|
|
210
|
+
while ((result = regex.exec(fileContent))) {
|
|
211
|
+
fontFamilyIndices.push(result.index);
|
|
212
|
+
}
|
|
213
|
+
report.fontFamily.count += fontFamilyIndices.length;
|
|
214
|
+
report.fontFamily.indices = [...report.fontFamily.indices, ...generateIndicesContent(fontFamilyIndices, file, fileContent)];
|
|
215
|
+
|
|
216
|
+
let importantIndices = [];
|
|
217
|
+
regex = /!important/gi;
|
|
218
|
+
while ((result = regex.exec(fileContent))) {
|
|
219
|
+
importantIndices.push(result.index);
|
|
220
|
+
}
|
|
221
|
+
report.important.count += importantIndices.length;
|
|
222
|
+
report.important.indices = [...report.important.indices, ...generateIndicesContent(importantIndices, file, fileContent)];
|
|
223
|
+
|
|
224
|
+
let colorsIndices = [];
|
|
225
|
+
regex = /#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|rgba|hsl/gi;
|
|
226
|
+
while ((result = regex.exec(fileContent))) {
|
|
227
|
+
colorsIndices.push(result.index);
|
|
228
|
+
}
|
|
229
|
+
report.plainColors.count += colorsIndices.length;
|
|
230
|
+
report.plainColors.indices = [...report.plainColors.indices, ...generateIndicesContent(colorsIndices, file, fileContent)];
|
|
231
|
+
|
|
232
|
+
let ngDeepIndices = [];
|
|
233
|
+
regex = /::ng-deep/gi;
|
|
234
|
+
while ((result = regex.exec(fileContent))) {
|
|
235
|
+
ngDeepIndices.push(result.index);
|
|
236
|
+
}
|
|
237
|
+
report.ngDeep.count += ngDeepIndices.length;
|
|
238
|
+
report.ngDeep.indices = [...report.ngDeep.indices, ...generateIndicesContent(ngDeepIndices, file, fileContent)];
|
|
239
|
+
|
|
240
|
+
let zIndexIndices = [];
|
|
241
|
+
regex = /z-index/gi;
|
|
242
|
+
while ((result = regex.exec(fileContent))) {
|
|
243
|
+
zIndexIndices.push(result.index);
|
|
244
|
+
}
|
|
245
|
+
report.zIndex.count += zIndexIndices.length;
|
|
246
|
+
report.zIndex.indices = [...report.zIndex.indices, ...generateIndicesContent(zIndexIndices, file, fileContent)];
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
files = glob.sync('**/*.html', { cwd: srcPath, nodir: true, follow: true, dot: true });
|
|
250
|
+
|
|
251
|
+
report.htmlFilesCount += files.length;
|
|
252
|
+
|
|
253
|
+
files.forEach((file) => {
|
|
254
|
+
const filePath = path.join(srcPath, file);
|
|
255
|
+
const fileContent = tools.getFileContent(filePath);
|
|
256
|
+
const linesCount = fileContent.split('\n').length;
|
|
257
|
+
|
|
258
|
+
report.htmlLinesCount += linesCount;
|
|
259
|
+
|
|
260
|
+
let result,
|
|
261
|
+
inlineStylesIndices = [];
|
|
262
|
+
let regex = /style=/gi;
|
|
263
|
+
while ((result = regex.exec(fileContent))) {
|
|
264
|
+
inlineStylesIndices.push(result.index);
|
|
265
|
+
}
|
|
266
|
+
report.inlineStyles.count += inlineStylesIndices.length;
|
|
267
|
+
report.inlineStyles.indices = [...report.inlineStyles.indices, ...generateIndicesContent(inlineStylesIndices, file, fileContent)];
|
|
268
|
+
|
|
269
|
+
let uxCmpIndices = [];
|
|
270
|
+
regex = /ux-/gi;
|
|
271
|
+
while ((result = regex.exec(fileContent))) {
|
|
272
|
+
uxCmpIndices.push(result.index);
|
|
273
|
+
}
|
|
274
|
+
report.uxCmp.count += uxCmpIndices.length;
|
|
275
|
+
// report.uxCmp.indices = [...report.uxCmp.indices, ...generateIndicesContent(uxCmpIndices, file, fileContent)];
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
files = glob.sync('**/*.ts', { cwd: srcPath, nodir: true, follow: true, dot: true });
|
|
279
|
+
|
|
280
|
+
files.forEach((file) => {
|
|
281
|
+
const filePath = path.join(srcPath, file);
|
|
282
|
+
const fileContent = tools.getFileContent(filePath);
|
|
283
|
+
const linesCount = fileContent.split('\n').length;
|
|
284
|
+
|
|
285
|
+
if (linesCount > 500) {
|
|
286
|
+
report.tsOver500.count++;
|
|
287
|
+
report.tsOver500.files.push(file);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
let result,
|
|
291
|
+
primengIndices = [];
|
|
292
|
+
let regex = /primeng/gi;
|
|
293
|
+
while ((result = regex.exec(fileContent))) {
|
|
294
|
+
primengIndices.push(result.index);
|
|
295
|
+
}
|
|
296
|
+
report.primeng.count += primengIndices.length;
|
|
297
|
+
report.primeng.indices = [...report.primeng.indices, ...generateIndicesContent(primengIndices, file, fileContent)];
|
|
187
298
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
report.euiOverrides.indices = [...report.euiOverrides.indices, ...generateIndicesContent(euiIndices, file, fileContent)];
|
|
195
|
-
|
|
196
|
-
let sizesIndices = [];
|
|
197
|
-
regex = /px/gi;
|
|
198
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
199
|
-
sizesIndices.push(result.index);
|
|
200
|
-
}
|
|
201
|
-
report.sizesPxEm.count += sizesIndices.length;
|
|
202
|
-
report.sizesPxEm.indices = [...report.sizesPxEm.indices, ...generateIndicesContent(sizesIndices, file, fileContent)];
|
|
203
|
-
|
|
204
|
-
let boxShadowIndices = [];
|
|
205
|
-
regex = /box-shadow/gi;
|
|
206
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
207
|
-
boxShadowIndices.push(result.index);
|
|
208
|
-
}
|
|
209
|
-
report.boxShadow.count += boxShadowIndices.length;
|
|
210
|
-
report.boxShadow.indices = [...report.boxShadow.indices, ...generateIndicesContent(boxShadowIndices, file, fileContent)];
|
|
211
|
-
|
|
212
|
-
let fontFamilyIndices = [];
|
|
213
|
-
regex = /font-family/gi;
|
|
214
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
215
|
-
fontFamilyIndices.push(result.index);
|
|
216
|
-
}
|
|
217
|
-
report.fontFamily.count += fontFamilyIndices.length;
|
|
218
|
-
report.fontFamily.indices = [...report.fontFamily.indices, ...generateIndicesContent(fontFamilyIndices, file, fileContent)];
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
let importantIndices = [];
|
|
222
|
-
regex = /!important/gi;
|
|
223
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
224
|
-
importantIndices.push(result.index);
|
|
225
|
-
}
|
|
226
|
-
report.important.count += importantIndices.length;
|
|
227
|
-
report.important.indices = [...report.important.indices, ...generateIndicesContent(importantIndices, file, fileContent)];
|
|
228
|
-
|
|
229
|
-
let colorsIndices = [];
|
|
230
|
-
regex = /#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})|rgba|hsl/gi;
|
|
231
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
232
|
-
colorsIndices.push(result.index);
|
|
233
|
-
}
|
|
234
|
-
report.plainColors.count += colorsIndices.length;
|
|
235
|
-
report.plainColors.indices = [...report.plainColors.indices, ...generateIndicesContent(colorsIndices, file, fileContent)];
|
|
236
|
-
|
|
237
|
-
let ngDeepIndices = [];
|
|
238
|
-
regex = /::ng-deep/gi;
|
|
239
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
240
|
-
ngDeepIndices.push(result.index);
|
|
241
|
-
}
|
|
242
|
-
report.ngDeep.count += ngDeepIndices.length;
|
|
243
|
-
report.ngDeep.indices = [...report.ngDeep.indices, ...generateIndicesContent(ngDeepIndices, file, fileContent)];
|
|
244
|
-
|
|
245
|
-
let zIndexIndices = [];
|
|
246
|
-
regex = /z-index/gi;
|
|
247
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
248
|
-
zIndexIndices.push(result.index);
|
|
249
|
-
}
|
|
250
|
-
report.zIndex.count += zIndexIndices.length;
|
|
251
|
-
report.zIndex.indices = [...report.zIndex.indices, ...generateIndicesContent(zIndexIndices, file, fileContent)];
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
files = glob.sync('**/*.html', { cwd: srcPath, nodir: true, follow: true, dot: true });
|
|
257
|
-
|
|
258
|
-
report.htmlFilesCount += files.length;
|
|
259
|
-
|
|
260
|
-
files.forEach(file => {
|
|
261
|
-
const filePath = path.join(srcPath, file);
|
|
262
|
-
const fileContent = tools.getFileContent(filePath);
|
|
263
|
-
const linesCount = fileContent.split('\n').length;
|
|
264
|
-
|
|
265
|
-
report.htmlLinesCount += linesCount;
|
|
266
|
-
|
|
267
|
-
let result, inlineStylesIndices = [];
|
|
268
|
-
let regex = /style=/gi;
|
|
269
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
270
|
-
inlineStylesIndices.push(result.index);
|
|
271
|
-
}
|
|
272
|
-
report.inlineStyles.count += inlineStylesIndices.length;
|
|
273
|
-
report.inlineStyles.indices = [...report.inlineStyles.indices, ...generateIndicesContent(inlineStylesIndices, file, fileContent)];
|
|
274
|
-
|
|
275
|
-
let uxCmpIndices = [];
|
|
276
|
-
regex = /ux-/gi;
|
|
277
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
278
|
-
uxCmpIndices.push(result.index);
|
|
279
|
-
}
|
|
280
|
-
report.uxCmp.count += uxCmpIndices.length;
|
|
281
|
-
// report.uxCmp.indices = [...report.uxCmp.indices, ...generateIndicesContent(uxCmpIndices, file, fileContent)];
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
files = glob.sync('**/*.ts', { cwd: srcPath, nodir: true, follow: true, dot: true });
|
|
288
|
-
|
|
289
|
-
files.forEach(file => {
|
|
290
|
-
const filePath = path.join(srcPath, file);
|
|
291
|
-
const fileContent = tools.getFileContent(filePath);
|
|
292
|
-
const linesCount = fileContent.split('\n').length;
|
|
293
|
-
|
|
294
|
-
if (linesCount > 500) {
|
|
295
|
-
report.tsOver500.count++;
|
|
296
|
-
report.tsOver500.files.push(file);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
let result, primengIndices = [];
|
|
300
|
-
let regex = /primeng/gi;
|
|
301
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
302
|
-
primengIndices.push(result.index);
|
|
303
|
-
}
|
|
304
|
-
report.primeng.count += primengIndices.length;
|
|
305
|
-
report.primeng.indices = [...report.primeng.indices, ...generateIndicesContent(primengIndices, file, fileContent)];
|
|
306
|
-
|
|
307
|
-
let materialIndices = [];
|
|
308
|
-
regex = /@angular\/material/gi;
|
|
309
|
-
while ( (result = regex.exec(fileContent)) ) {
|
|
310
|
-
materialIndices.push(result.index);
|
|
311
|
-
}
|
|
312
|
-
const indicesContent = generateIndicesContent(
|
|
313
|
-
materialIndices, file, fileContent,
|
|
314
|
-
[
|
|
299
|
+
let materialIndices = [];
|
|
300
|
+
regex = /@angular\/material/gi;
|
|
301
|
+
while ((result = regex.exec(fileContent))) {
|
|
302
|
+
materialIndices.push(result.index);
|
|
303
|
+
}
|
|
304
|
+
const indicesContent = generateIndicesContent(materialIndices, file, fileContent, [
|
|
315
305
|
'@angular/material/core',
|
|
316
|
-
'@angular/material-moment-adapter'
|
|
317
|
-
]
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
description: 'scss/css empty files',
|
|
372
|
-
value: `${report.scssEmptyFiles} out of ${report.scssFilesCount} (${Math.floor(100 * report.scssEmptyFiles / report.scssFilesCount)}%)`,
|
|
373
|
-
status: (report.scssEmptyFiles !== 0) ? 'IMPROVE' : 'OK',
|
|
374
|
-
comment: (report.scssEmptyFiles !== 0) ? 'Scss files without content should be cleaned up' : null
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
// BALANCED - styles content
|
|
381
|
-
|
|
382
|
-
if (report.scssFilesCount !== 0) {
|
|
383
|
-
|
|
384
|
-
report.finalReport['euiOverrides'] = {
|
|
385
|
-
description: 'eUI overrides found',
|
|
386
|
-
value: report.euiOverrides.count,
|
|
387
|
-
status: getStatus(report.euiOverrides.count),
|
|
388
|
-
comment: (report.euiOverrides.count !== 0) ? 'No eUI overrides should be applied, contact eUI support for assistance' : null
|
|
389
|
-
}
|
|
390
|
-
report.finalReport['sizesPxEm'] = {
|
|
391
|
-
description: 'Sizes in px usage found',
|
|
392
|
-
value: report.sizesPxEm.count,
|
|
393
|
-
status: getStatus(report.sizesPxEm.count),
|
|
394
|
-
comment: (report.sizesPxEm.count !== 0) ? 'if sizes should be tweaked, usage of eUI CSS vars should be applied' : null
|
|
395
|
-
}
|
|
396
|
-
report.finalReport['boxShadow'] = {
|
|
397
|
-
description: 'box-shadow usage found',
|
|
398
|
-
value: report.boxShadow.count,
|
|
399
|
-
status: getStatus(report.boxShadow.count),
|
|
400
|
-
comment: (report.boxShadow.count !== 0) ? 'if box-shadow should be tweaked (on specific context), usage of eUI CSS vars should be applied' : null
|
|
401
|
-
}
|
|
402
|
-
report.finalReport['fontFamily'] = {
|
|
403
|
-
description: 'font-family usage found',
|
|
404
|
-
value: report.fontFamily.count,
|
|
405
|
-
status: getStatus(report.fontFamily.count),
|
|
406
|
-
comment: (report.fontFamily.count !== 0) ? 'if font-family should be tweaked (on specific context), usage of eUI CSS vars should be applied' : null
|
|
407
|
-
}
|
|
408
|
-
report.finalReport['plainColors'] = {
|
|
409
|
-
description: 'Plain colors usage found',
|
|
410
|
-
value: report.plainColors.count,
|
|
411
|
-
status: getStatus(report.plainColors.count),
|
|
412
|
-
comment: (report.plainColors.count !== 0) ? 'if colors should be used in scss, usage of eUI CSS vars should be applied' : null
|
|
413
|
-
}
|
|
414
|
-
report.finalReport['important'] = {
|
|
415
|
-
description: '!important usage found',
|
|
416
|
-
value: report.important.count,
|
|
417
|
-
status: getStatus(report.important.count),
|
|
418
|
-
comment: (report.important.count !== 0) ? 'No !important allowed' : null
|
|
419
|
-
}
|
|
420
|
-
report.finalReport['ngDeep'] = {
|
|
421
|
-
description: '::ng-deep usage found',
|
|
422
|
-
value: report.ngDeep.count,
|
|
423
|
-
status: getStatus(report.ngDeep.count),
|
|
424
|
-
comment: (report.ngDeep.count !== 0) ? 'Avoid ::ng-deep usage' : null
|
|
425
|
-
}
|
|
426
|
-
report.finalReport['zIndex'] = {
|
|
427
|
-
description: 'z-index usage found',
|
|
428
|
-
value: report.zIndex.count,
|
|
429
|
-
status: getStatus(report.zIndex.count),
|
|
430
|
-
comment: (report.zIndex.count !== 0) ? 'Avoid z-index setting, usage of eUI CSS vars should be applied' : null
|
|
306
|
+
'@angular/material-moment-adapter',
|
|
307
|
+
]);
|
|
308
|
+
|
|
309
|
+
report.material.count += recalculateIndicesCount(indicesContent);
|
|
310
|
+
report.material.indices = [...report.material.indices, ...indicesContent];
|
|
311
|
+
|
|
312
|
+
let allModulesIndices = [];
|
|
313
|
+
regex = /EuiAllModule/gi;
|
|
314
|
+
while ((result = regex.exec(fileContent))) {
|
|
315
|
+
allModulesIndices.push(result.index);
|
|
316
|
+
}
|
|
317
|
+
regex = /UxAllModule/gi;
|
|
318
|
+
while ((result = regex.exec(fileContent))) {
|
|
319
|
+
allModulesIndices.push(result.index);
|
|
320
|
+
}
|
|
321
|
+
report.allModules.count += allModulesIndices.length;
|
|
322
|
+
report.allModules.indices = [...report.allModules.indices, ...generateIndicesContent(allModulesIndices, file, fileContent)];
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
// Analyzing 3rd party dependencies usage
|
|
326
|
+
|
|
327
|
+
tools.logInfo('Analyzing package deps for 3rd parties usage');
|
|
328
|
+
let deps = installUtils.packages.getLocalPackageDepsAll(pkg);
|
|
329
|
+
tools.logInfo('Deps found for package :');
|
|
330
|
+
deps = Object.keys(deps);
|
|
331
|
+
console.log(deps);
|
|
332
|
+
|
|
333
|
+
const allowedScopes = configUtils.packages.getPackageScopes();
|
|
334
|
+
let thirdPartyDeps = [];
|
|
335
|
+
deps.forEach((d) => {
|
|
336
|
+
const scope = d.split('/')[0];
|
|
337
|
+
if (!allowedScopes.includes(scope)) {
|
|
338
|
+
thirdPartyDeps.push(d);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
tools.logInfo('3rd party deps found for package :');
|
|
343
|
+
console.log(thirdPartyDeps);
|
|
344
|
+
|
|
345
|
+
report.thirdPartyDependencies.count = thirdPartyDeps.length;
|
|
346
|
+
report.thirdPartyDependencies.dependencies = thirdPartyDeps;
|
|
347
|
+
|
|
348
|
+
// GLOBAL STATS - ANALYZING DATA / SET STATUS
|
|
349
|
+
|
|
350
|
+
if (report.htmlFilesCount !== 0) {
|
|
351
|
+
const scssHtmlRatio = Math.floor((100 * report.scssFilesCount) / report.htmlFilesCount);
|
|
352
|
+
report.finalReport['scssHtmlRatio'] = {
|
|
353
|
+
description: 'scss/css files VS html files',
|
|
354
|
+
value: `${report.scssFilesCount} out of ${report.htmlFilesCount} (${scssHtmlRatio}%)`,
|
|
355
|
+
status: scssHtmlRatio >= 25 ? 'CRITICAL' : scssHtmlRatio >= 10 && scssHtmlRatio <= 25 ? 'IMPROVE' : 'OK',
|
|
356
|
+
comment: null,
|
|
357
|
+
};
|
|
358
|
+
if (report.finalReport['scssHtmlRatio'].status === 'CRITICAL') {
|
|
359
|
+
report.finalReport['scssHtmlRatio'].comment = 'The percentage of html files having styles declaration is too high';
|
|
360
|
+
}
|
|
431
361
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
description: 'material component usage found in HTML',
|
|
445
|
-
value: report.material.count,
|
|
446
|
-
status: (report.material.count !== 0) ? 'CRITICAL' : 'OK',
|
|
447
|
-
comment: (report.material.count !== 0) ? 'Usage of material should be avoided - this will be blocking as of eUI 16' : null
|
|
448
|
-
}
|
|
449
|
-
report.finalReport['primeng'] = {
|
|
450
|
-
description: 'PrimeNG components usage found in HTML',
|
|
451
|
-
value: report.primeng.count,
|
|
452
|
-
status: (report.primeng.count !== 0) ? 'CRITICAL' : 'OK',
|
|
453
|
-
comment: (report.primeng.count !== 0) ? 'Remove any PrimeNG usage, deprecated in eUI - this will be blocking as of eUI 16' : null
|
|
454
|
-
}
|
|
455
|
-
report.finalReport['allModules'] = {
|
|
456
|
-
description: 'Usage of EuiAllModule or UxAllModule',
|
|
457
|
-
value: report.allModules.count,
|
|
458
|
-
status: (report.allModules.count !== 0) ? 'CRITICAL' : 'OK',
|
|
459
|
-
comment: (report.allModules.count !== 0) ? 'Use only tree-shakable eUI module imports (as of 15+)' : null
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// IMPROVE ONLY
|
|
463
|
-
|
|
464
|
-
report.finalReport['uxCmp'] = {
|
|
465
|
-
description: 'eUI ux- components usage found in HTML',
|
|
466
|
-
value: report.uxCmp.count,
|
|
467
|
-
status: (report.uxCmp.count !== 0) ? 'IMPROVE' : 'OK',
|
|
468
|
-
comment: (report.uxCmp.count !== 0) ? 'Replace by "eui-" components whenever possible, to ensure future proof migration' : null
|
|
362
|
+
|
|
363
|
+
if (report.htmlLinesCount !== 0) {
|
|
364
|
+
const scssHtmlLinesRatio = Math.floor((100 * report.scssLinescount) / report.htmlLinesCount);
|
|
365
|
+
report.finalReport['scssHtmlLinesRatio'] = {
|
|
366
|
+
description: 'css lines count VS html lines count',
|
|
367
|
+
value: `${report.scssLinescount} / ${report.htmlLinesCount} (${scssHtmlLinesRatio}%)`,
|
|
368
|
+
status: scssHtmlLinesRatio >= 25 ? 'CRITICAL' : scssHtmlLinesRatio >= 10 && scssHtmlLinesRatio <= 25 ? 'IMPROVE' : 'OK',
|
|
369
|
+
comment: null,
|
|
370
|
+
};
|
|
371
|
+
if (report.finalReport['scssHtmlLinesRatio'].status === 'CRITICAL') {
|
|
372
|
+
report.finalReport['scssHtmlLinesRatio'].comment = 'The percentage of scss lines is too high';
|
|
373
|
+
}
|
|
469
374
|
}
|
|
470
375
|
|
|
471
|
-
report.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
376
|
+
if (report.scssFilesCount !== 0) {
|
|
377
|
+
report.finalReport['scssEmptyFiles'] = {
|
|
378
|
+
description: 'scss/css empty files',
|
|
379
|
+
value: `${report.scssEmptyFiles} out of ${report.scssFilesCount} (${Math.floor(
|
|
380
|
+
(100 * report.scssEmptyFiles) / report.scssFilesCount
|
|
381
|
+
)}%)`,
|
|
382
|
+
status: report.scssEmptyFiles !== 0 ? 'IMPROVE' : 'OK',
|
|
383
|
+
comment: report.scssEmptyFiles !== 0 ? 'Scss files without content should be cleaned up' : null,
|
|
384
|
+
};
|
|
476
385
|
}
|
|
477
|
-
}
|
|
478
386
|
|
|
387
|
+
// BALANCED - styles content
|
|
479
388
|
|
|
389
|
+
if (report.scssFilesCount !== 0) {
|
|
390
|
+
report.finalReport['euiOverrides'] = {
|
|
391
|
+
description: 'eUI overrides found',
|
|
392
|
+
value: report.euiOverrides.count,
|
|
393
|
+
status: getStatus(report.euiOverrides.count),
|
|
394
|
+
comment: report.euiOverrides.count !== 0 ? 'No eUI overrides should be applied, contact eUI support for assistance' : null,
|
|
395
|
+
};
|
|
396
|
+
report.finalReport['sizesPxEm'] = {
|
|
397
|
+
description: 'Sizes in px usage found',
|
|
398
|
+
value: report.sizesPxEm.count,
|
|
399
|
+
status: getStatus(report.sizesPxEm.count),
|
|
400
|
+
comment: report.sizesPxEm.count !== 0 ? 'if sizes should be tweaked, usage of eUI CSS vars should be applied' : null,
|
|
401
|
+
};
|
|
402
|
+
report.finalReport['boxShadow'] = {
|
|
403
|
+
description: 'box-shadow usage found',
|
|
404
|
+
value: report.boxShadow.count,
|
|
405
|
+
status: getStatus(report.boxShadow.count),
|
|
406
|
+
comment:
|
|
407
|
+
report.boxShadow.count !== 0
|
|
408
|
+
? 'if box-shadow should be tweaked (on specific context), usage of eUI CSS vars should be applied'
|
|
409
|
+
: null,
|
|
410
|
+
};
|
|
411
|
+
report.finalReport['fontFamily'] = {
|
|
412
|
+
description: 'font-family usage found',
|
|
413
|
+
value: report.fontFamily.count,
|
|
414
|
+
status: getStatus(report.fontFamily.count),
|
|
415
|
+
comment:
|
|
416
|
+
report.fontFamily.count !== 0
|
|
417
|
+
? 'if font-family should be tweaked (on specific context), usage of eUI CSS vars should be applied'
|
|
418
|
+
: null,
|
|
419
|
+
};
|
|
420
|
+
report.finalReport['plainColors'] = {
|
|
421
|
+
description: 'Plain colors usage found',
|
|
422
|
+
value: report.plainColors.count,
|
|
423
|
+
status: getStatus(report.plainColors.count),
|
|
424
|
+
comment: report.plainColors.count !== 0 ? 'if colors should be used in scss, usage of eUI CSS vars should be applied' : null,
|
|
425
|
+
};
|
|
426
|
+
report.finalReport['important'] = {
|
|
427
|
+
description: '!important usage found',
|
|
428
|
+
value: report.important.count,
|
|
429
|
+
status: getStatus(report.important.count),
|
|
430
|
+
comment: report.important.count !== 0 ? 'No !important allowed' : null,
|
|
431
|
+
};
|
|
432
|
+
report.finalReport['ngDeep'] = {
|
|
433
|
+
description: '::ng-deep usage found',
|
|
434
|
+
value: report.ngDeep.count,
|
|
435
|
+
status: getStatus(report.ngDeep.count),
|
|
436
|
+
comment: report.ngDeep.count !== 0 ? 'Avoid ::ng-deep usage' : null,
|
|
437
|
+
};
|
|
438
|
+
report.finalReport['zIndex'] = {
|
|
439
|
+
description: 'z-index usage found',
|
|
440
|
+
value: report.zIndex.count,
|
|
441
|
+
status: getStatus(report.zIndex.count),
|
|
442
|
+
comment: report.zIndex.count !== 0 ? 'Avoid z-index setting, usage of eUI CSS vars should be applied' : null,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
480
445
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
446
|
+
// CRITICAL ONLY
|
|
447
|
+
|
|
448
|
+
if (report.htmlLinesCount !== 0) {
|
|
449
|
+
report.finalReport['inlineStyles'] = {
|
|
450
|
+
description: 'inline styles found in HTML',
|
|
451
|
+
value: report.inlineStyles.count,
|
|
452
|
+
status: report.inlineStyles.count !== 0 ? 'CRITICAL' : 'OK',
|
|
453
|
+
comment:
|
|
454
|
+
report.inlineStyles.count !== 0
|
|
455
|
+
? 'No inline styles should be present in html, usage classes with scss / eUI utilities instead'
|
|
456
|
+
: null,
|
|
457
|
+
};
|
|
458
|
+
report.finalReport['material'] = {
|
|
459
|
+
description: 'material component usage found in HTML',
|
|
460
|
+
value: report.material.count,
|
|
461
|
+
status: report.material.count !== 0 ? 'CRITICAL' : 'OK',
|
|
462
|
+
comment: report.material.count !== 0 ? 'Usage of material should be avoided - this will be blocking as of eUI 16' : null,
|
|
463
|
+
};
|
|
464
|
+
report.finalReport['primeng'] = {
|
|
465
|
+
description: 'PrimeNG components usage found in HTML',
|
|
466
|
+
value: report.primeng.count,
|
|
467
|
+
status: report.primeng.count !== 0 ? 'CRITICAL' : 'OK',
|
|
468
|
+
comment: report.primeng.count !== 0 ? 'Remove any PrimeNG usage, deprecated in eUI - this will be blocking as of eUI 16' : null,
|
|
469
|
+
};
|
|
470
|
+
report.finalReport['allModules'] = {
|
|
471
|
+
description: 'Usage of EuiAllModule or UxAllModule',
|
|
472
|
+
value: report.allModules.count,
|
|
473
|
+
status: report.allModules.count !== 0 ? 'CRITICAL' : 'OK',
|
|
474
|
+
comment: report.allModules.count !== 0 ? 'Use only tree-shakable eUI module imports (as of 15+)' : null,
|
|
475
|
+
};
|
|
484
476
|
|
|
485
|
-
|
|
486
|
-
// Calculating score
|
|
477
|
+
// IMPROVE ONLY
|
|
487
478
|
|
|
488
|
-
|
|
479
|
+
report.finalReport['uxCmp'] = {
|
|
480
|
+
description: 'eUI ux- components usage found in HTML',
|
|
481
|
+
value: report.uxCmp.count,
|
|
482
|
+
status: report.uxCmp.count !== 0 ? 'IMPROVE' : 'OK',
|
|
483
|
+
comment: report.uxCmp.count !== 0 ? 'Replace by "eui-" components whenever possible, to ensure future proof migration' : null,
|
|
484
|
+
};
|
|
489
485
|
|
|
490
|
-
|
|
491
|
-
|
|
486
|
+
report.finalReport['tsOver500'] = {
|
|
487
|
+
description: 'TS file containing more than 500 lines',
|
|
488
|
+
value: report.tsOver500.count,
|
|
489
|
+
status: report.tsOver500.count !== 0 ? 'IMPROVE' : 'OK',
|
|
490
|
+
comment: report.tsOver500.count !== 0 ? 'Split TS files into multiple ones for readability' : null,
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
report.finalReport['thirdPartyDependencies'] = {
|
|
495
|
+
description: 'Third party dependencies usage',
|
|
496
|
+
value: report.thirdPartyDependencies.count,
|
|
497
|
+
status: report.thirdPartyDependencies.count !== 0 ? 'CRITICAL' : 'OK',
|
|
498
|
+
comment: report.thirdPartyDependencies.count !== 0 ? 'Use 3rd party dependencies only if really necessary (bundle size increase) - contact eUI team for more info' : null,
|
|
499
|
+
};
|
|
492
500
|
|
|
493
|
-
switch(v[1].status) {
|
|
494
|
-
case 'OK':
|
|
495
|
-
score++;
|
|
496
|
-
break;
|
|
497
|
-
case 'IMPROVE':
|
|
498
|
-
score+=0.5;
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
501
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
502
|
+
if (Object.keys(report.finalReport).length === 0) {
|
|
503
|
+
tools.logInfo('No sources to audit...skipping');
|
|
504
|
+
return null;
|
|
505
|
+
} else {
|
|
506
|
+
// Calculating score
|
|
506
507
|
|
|
508
|
+
let score = 0,
|
|
509
|
+
total = 0;
|
|
507
510
|
|
|
508
|
-
|
|
511
|
+
Object.entries(report.finalReport).forEach((v) => {
|
|
512
|
+
total++;
|
|
509
513
|
|
|
510
|
-
|
|
511
|
-
|
|
514
|
+
switch (v[1].status) {
|
|
515
|
+
case 'OK':
|
|
516
|
+
score++;
|
|
517
|
+
break;
|
|
518
|
+
case 'IMPROVE':
|
|
519
|
+
score += 0.5;
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
});
|
|
512
523
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
524
|
+
report.score = score;
|
|
525
|
+
report.total = total;
|
|
526
|
+
report.pcScore = Math.floor((100 * score) / total);
|
|
516
527
|
|
|
528
|
+
// return JSON report
|
|
517
529
|
|
|
530
|
+
tools.logInfo('STATS report');
|
|
531
|
+
console.log(JSON.stringify(report, null, 2));
|
|
518
532
|
|
|
533
|
+
return report;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
519
536
|
|
|
520
537
|
module.exports.audit = (pkg) => {
|
|
521
538
|
if (pkg.remote && pkg.name.indexOf('-ui') === -1) {
|
|
@@ -535,37 +552,39 @@ module.exports.audit = (pkg) => {
|
|
|
535
552
|
outputReport = report;
|
|
536
553
|
|
|
537
554
|
return Promise.resolve()
|
|
538
|
-
|
|
539
|
-
|
|
555
|
+
.then(() => {
|
|
556
|
+
// FINAL REPORT
|
|
540
557
|
|
|
541
|
-
|
|
558
|
+
let finalReportMessage = `*STYLES AUDIT REPORT for ${pkg.name}:*\n\n`;
|
|
542
559
|
|
|
543
|
-
|
|
544
|
-
|
|
560
|
+
Object.entries(report.finalReport).forEach((v) => {
|
|
561
|
+
let statusEmoji;
|
|
545
562
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
563
|
+
if (v[1].status === 'CRITICAL') {
|
|
564
|
+
statusEmoji = ':no_entry:';
|
|
565
|
+
} else if (v[1].status === 'IMPROVE') {
|
|
566
|
+
statusEmoji = ':warning:';
|
|
567
|
+
} else {
|
|
568
|
+
statusEmoji = ':large_green_circle:';
|
|
569
|
+
}
|
|
553
570
|
|
|
554
|
-
|
|
555
|
-
|
|
571
|
+
finalReportMessage += `${statusEmoji} *${v[1].description}*: found *${v[1].value}* - status: *${v[1].status}* ${
|
|
572
|
+
v[1].comment ? '==> ' + v[1].comment : ''
|
|
573
|
+
}\n`;
|
|
574
|
+
});
|
|
556
575
|
|
|
557
|
-
|
|
576
|
+
finalReportMessage += `\neUI compliance score : *${report.score}* out of *${report.total}* *(${report.pcScore}%)*`;
|
|
558
577
|
|
|
559
|
-
|
|
560
|
-
|
|
578
|
+
tools.logInfo('Sending final report message');
|
|
579
|
+
console.log(finalReportMessage);
|
|
561
580
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
581
|
+
return notificationUtils.package.sendPackageMessage({
|
|
582
|
+
package: pkg,
|
|
583
|
+
text: finalReportMessage,
|
|
584
|
+
});
|
|
585
|
+
})
|
|
567
586
|
|
|
568
|
-
|
|
587
|
+
.then(() => {
|
|
569
588
|
// getting config options for gates defined
|
|
570
589
|
const configOptions = configUtils.global.getConfigOptions();
|
|
571
590
|
|
|
@@ -588,19 +607,16 @@ module.exports.audit = (pkg) => {
|
|
|
588
607
|
if (pkg.build && pkg.build.stylesAuditCheck) {
|
|
589
608
|
tools.logInfo('All gates checks applied');
|
|
590
609
|
gates = allNewGates;
|
|
591
|
-
|
|
592
610
|
} else {
|
|
593
611
|
tools.logInfo('===> no forced gates flag detected ...');
|
|
594
612
|
tools.logInfo('Checking if package is newly created -- all versions gates are checked in that case');
|
|
595
613
|
|
|
596
614
|
if (metadataUtils.package.isNewPackageBuild(pkg)) {
|
|
597
615
|
gates = allNewGates;
|
|
598
|
-
|
|
599
616
|
} else {
|
|
600
617
|
if (euiVersionGates) {
|
|
601
618
|
tools.logInfo('eUI version gates found, applied to older packages where limited gates are set');
|
|
602
619
|
gates = euiVersionGates;
|
|
603
|
-
|
|
604
620
|
} else {
|
|
605
621
|
tools.logInfo('No gates found for local eUI version...');
|
|
606
622
|
return;
|
|
@@ -610,7 +626,6 @@ module.exports.audit = (pkg) => {
|
|
|
610
626
|
|
|
611
627
|
tools.logInfo(`Gates found : ${JSON.stringify(gates)}`);
|
|
612
628
|
|
|
613
|
-
|
|
614
629
|
// checking gates level if any
|
|
615
630
|
let gatesPassed = true;
|
|
616
631
|
|
|
@@ -629,37 +644,36 @@ module.exports.audit = (pkg) => {
|
|
|
629
644
|
tools.logInfo(`===> PASSED`);
|
|
630
645
|
}
|
|
631
646
|
}
|
|
632
|
-
})
|
|
647
|
+
});
|
|
633
648
|
|
|
634
649
|
if (!gatesPassed) {
|
|
635
650
|
throw new Error('AUDIT_STYLES_GATES_FAILED');
|
|
636
651
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
.then(() => {
|
|
640
|
-
// formatting report for metadata storage
|
|
652
|
+
})
|
|
641
653
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
total: outputReport.total,
|
|
645
|
-
pcScore: outputReport.pcScore,
|
|
646
|
-
};
|
|
654
|
+
.then(() => {
|
|
655
|
+
// formatting report for metadata storage
|
|
647
656
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
status: outputReport.finalReport[item].status,
|
|
657
|
+
const metadataReport = {
|
|
658
|
+
score: outputReport.score,
|
|
659
|
+
total: outputReport.total,
|
|
660
|
+
pcScore: outputReport.pcScore,
|
|
653
661
|
};
|
|
654
|
-
});
|
|
655
662
|
|
|
656
|
-
|
|
663
|
+
const summarizedFinalReport = {};
|
|
664
|
+
Object.keys(outputReport.finalReport).forEach((item) => {
|
|
665
|
+
summarizedFinalReport[item] = {
|
|
666
|
+
value: outputReport.finalReport[item].value,
|
|
667
|
+
status: outputReport.finalReport[item].status,
|
|
668
|
+
};
|
|
669
|
+
});
|
|
657
670
|
|
|
658
|
-
|
|
659
|
-
})
|
|
671
|
+
metadataReport.finalReport = summarizedFinalReport;
|
|
660
672
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
})
|
|
673
|
+
return metadataReport;
|
|
674
|
+
})
|
|
664
675
|
|
|
665
|
-
|
|
676
|
+
.catch((e) => {
|
|
677
|
+
throw e;
|
|
678
|
+
});
|
|
679
|
+
};
|
|
@@ -341,3 +341,11 @@ module.exports.getTSConfigFileName = (tsConfigPath) => {
|
|
|
341
341
|
return tsConfigPath.split('/')[tsConfigPath.split('/').length - 1];
|
|
342
342
|
}
|
|
343
343
|
|
|
344
|
+
module.exports.getPackageScopes = () => {
|
|
345
|
+
const packagesObj = this.getCsdrPackages();
|
|
346
|
+
let packages = Object.keys(packagesObj);
|
|
347
|
+
packages = packages.map(p => packagesObj[p]).filter(p => !p.backend && !p.remote && p.npmPkg !== undefined);
|
|
348
|
+
const scopes = packages.map(p => p.npmPkg.split('/')[0]);
|
|
349
|
+
|
|
350
|
+
return tools.removeArrayDuplicates(scopes);
|
|
351
|
+
}
|
|
@@ -189,6 +189,13 @@ module.exports.getLocalPackagesCompositeDepsRemapped = () => {
|
|
|
189
189
|
})
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
module.exports.getLocalPackageDepsAll = (pkg) => {
|
|
193
|
+
return {
|
|
194
|
+
...getLocalPackageDeps(pkg),
|
|
195
|
+
...getLocalPackageBaseDeps(pkg),
|
|
196
|
+
...getLocalPackageCompositeDeps(pkg)
|
|
197
|
+
};
|
|
198
|
+
}
|
|
192
199
|
|
|
193
200
|
module.exports.installDeps = (prj, pkg, isMaster) => {
|
|
194
201
|
let compositeDeps, localPkgDeps, localPkgCompositeDeps, remappedDeps, localPkgBaseDeps;
|