@eui/tools 6.12.23 → 6.12.25
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 +18 -0
- package/package.json +1 -1
- package/sandbox.js +10 -2
- package/scripts/csdr/audit/styles.js +429 -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.25
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.12.25 (2023-06-27)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
* **other:**
|
|
6
|
+
* add exclusions to styles audit 3rd party deps scan - EUI-7121 [EUI-7121](https://webgate.ec.europa.eu/CITnet/jira/browse/EUI-7121) ([d82c9aa5](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/d82c9aa54e976f3ca7a5a01b3551d552e248b590))
|
|
7
|
+
|
|
8
|
+
* * *
|
|
9
|
+
* * *
|
|
10
|
+
## 6.12.24 (2023-06-27)
|
|
11
|
+
|
|
12
|
+
##### Chores
|
|
13
|
+
|
|
14
|
+
* **other:**
|
|
15
|
+
* 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))
|
|
16
|
+
|
|
17
|
+
* * *
|
|
18
|
+
* * *
|
|
1
19
|
## 6.12.23 (2023-06-26)
|
|
2
20
|
|
|
3
21
|
##### 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-flex-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,374 @@ 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;
|
|
187
284
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
[
|
|
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)];
|
|
298
|
+
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
+
const exclusions = ['ag-grid', 'file-saver'];
|
|
335
|
+
|
|
336
|
+
let thirdPartyDeps = [];
|
|
337
|
+
deps.forEach((d) => {
|
|
338
|
+
const scope = d.split('/')[0];
|
|
339
|
+
|
|
340
|
+
// checking against allowed CSDR known package scopes
|
|
341
|
+
if (!allowedScopes.includes(scope)) {
|
|
342
|
+
|
|
343
|
+
// exclusions known
|
|
344
|
+
let exclusionFound = false;
|
|
345
|
+
exclusions.forEach((exc) => {
|
|
346
|
+
if (scope.indexOf(exc) > -1) {
|
|
347
|
+
exclusionFound = true;
|
|
348
|
+
}
|
|
349
|
+
})
|
|
350
|
+
|
|
351
|
+
if (!exclusionFound) {
|
|
352
|
+
thirdPartyDeps.push(d);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
tools.logInfo('3rd party deps found for package :');
|
|
358
|
+
console.log(thirdPartyDeps);
|
|
359
|
+
|
|
360
|
+
report.thirdPartyDependencies.count = thirdPartyDeps.length;
|
|
361
|
+
report.thirdPartyDependencies.dependencies = thirdPartyDeps;
|
|
362
|
+
|
|
363
|
+
// GLOBAL STATS - ANALYZING DATA / SET STATUS
|
|
364
|
+
|
|
365
|
+
if (report.htmlFilesCount !== 0) {
|
|
366
|
+
const scssHtmlRatio = Math.floor((100 * report.scssFilesCount) / report.htmlFilesCount);
|
|
367
|
+
report.finalReport['scssHtmlRatio'] = {
|
|
368
|
+
description: 'scss/css files VS html files',
|
|
369
|
+
value: `${report.scssFilesCount} out of ${report.htmlFilesCount} (${scssHtmlRatio}%)`,
|
|
370
|
+
status: scssHtmlRatio >= 25 ? 'CRITICAL' : scssHtmlRatio >= 10 && scssHtmlRatio <= 25 ? 'IMPROVE' : 'OK',
|
|
371
|
+
comment: null,
|
|
372
|
+
};
|
|
373
|
+
if (report.finalReport['scssHtmlRatio'].status === 'CRITICAL') {
|
|
374
|
+
report.finalReport['scssHtmlRatio'].comment = 'The percentage of html files having styles declaration is too high';
|
|
375
|
+
}
|
|
431
376
|
}
|
|
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
|
|
377
|
+
|
|
378
|
+
if (report.htmlLinesCount !== 0) {
|
|
379
|
+
const scssHtmlLinesRatio = Math.floor((100 * report.scssLinescount) / report.htmlLinesCount);
|
|
380
|
+
report.finalReport['scssHtmlLinesRatio'] = {
|
|
381
|
+
description: 'css lines count VS html lines count',
|
|
382
|
+
value: `${report.scssLinescount} / ${report.htmlLinesCount} (${scssHtmlLinesRatio}%)`,
|
|
383
|
+
status: scssHtmlLinesRatio >= 25 ? 'CRITICAL' : scssHtmlLinesRatio >= 10 && scssHtmlLinesRatio <= 25 ? 'IMPROVE' : 'OK',
|
|
384
|
+
comment: null,
|
|
385
|
+
};
|
|
386
|
+
if (report.finalReport['scssHtmlLinesRatio'].status === 'CRITICAL') {
|
|
387
|
+
report.finalReport['scssHtmlLinesRatio'].comment = 'The percentage of scss lines is too high';
|
|
388
|
+
}
|
|
469
389
|
}
|
|
470
390
|
|
|
471
|
-
report.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
391
|
+
if (report.scssFilesCount !== 0) {
|
|
392
|
+
report.finalReport['scssEmptyFiles'] = {
|
|
393
|
+
description: 'scss/css empty files',
|
|
394
|
+
value: `${report.scssEmptyFiles} out of ${report.scssFilesCount} (${Math.floor(
|
|
395
|
+
(100 * report.scssEmptyFiles) / report.scssFilesCount
|
|
396
|
+
)}%)`,
|
|
397
|
+
status: report.scssEmptyFiles !== 0 ? 'IMPROVE' : 'OK',
|
|
398
|
+
comment: report.scssEmptyFiles !== 0 ? 'Scss files without content should be cleaned up' : null,
|
|
399
|
+
};
|
|
476
400
|
}
|
|
477
|
-
}
|
|
478
401
|
|
|
402
|
+
// BALANCED - styles content
|
|
479
403
|
|
|
404
|
+
if (report.scssFilesCount !== 0) {
|
|
405
|
+
report.finalReport['euiOverrides'] = {
|
|
406
|
+
description: 'eUI overrides found',
|
|
407
|
+
value: report.euiOverrides.count,
|
|
408
|
+
status: getStatus(report.euiOverrides.count),
|
|
409
|
+
comment: report.euiOverrides.count !== 0 ? 'No eUI overrides should be applied, contact eUI support for assistance' : null,
|
|
410
|
+
};
|
|
411
|
+
report.finalReport['sizesPxEm'] = {
|
|
412
|
+
description: 'Sizes in px usage found',
|
|
413
|
+
value: report.sizesPxEm.count,
|
|
414
|
+
status: getStatus(report.sizesPxEm.count),
|
|
415
|
+
comment: report.sizesPxEm.count !== 0 ? 'if sizes should be tweaked, usage of eUI CSS vars should be applied' : null,
|
|
416
|
+
};
|
|
417
|
+
report.finalReport['boxShadow'] = {
|
|
418
|
+
description: 'box-shadow usage found',
|
|
419
|
+
value: report.boxShadow.count,
|
|
420
|
+
status: getStatus(report.boxShadow.count),
|
|
421
|
+
comment:
|
|
422
|
+
report.boxShadow.count !== 0
|
|
423
|
+
? 'if box-shadow should be tweaked (on specific context), usage of eUI CSS vars should be applied'
|
|
424
|
+
: null,
|
|
425
|
+
};
|
|
426
|
+
report.finalReport['fontFamily'] = {
|
|
427
|
+
description: 'font-family usage found',
|
|
428
|
+
value: report.fontFamily.count,
|
|
429
|
+
status: getStatus(report.fontFamily.count),
|
|
430
|
+
comment:
|
|
431
|
+
report.fontFamily.count !== 0
|
|
432
|
+
? 'if font-family should be tweaked (on specific context), usage of eUI CSS vars should be applied'
|
|
433
|
+
: null,
|
|
434
|
+
};
|
|
435
|
+
report.finalReport['plainColors'] = {
|
|
436
|
+
description: 'Plain colors usage found',
|
|
437
|
+
value: report.plainColors.count,
|
|
438
|
+
status: getStatus(report.plainColors.count),
|
|
439
|
+
comment: report.plainColors.count !== 0 ? 'if colors should be used in scss, usage of eUI CSS vars should be applied' : null,
|
|
440
|
+
};
|
|
441
|
+
report.finalReport['important'] = {
|
|
442
|
+
description: '!important usage found',
|
|
443
|
+
value: report.important.count,
|
|
444
|
+
status: getStatus(report.important.count),
|
|
445
|
+
comment: report.important.count !== 0 ? 'No !important allowed' : null,
|
|
446
|
+
};
|
|
447
|
+
report.finalReport['ngDeep'] = {
|
|
448
|
+
description: '::ng-deep usage found',
|
|
449
|
+
value: report.ngDeep.count,
|
|
450
|
+
status: getStatus(report.ngDeep.count),
|
|
451
|
+
comment: report.ngDeep.count !== 0 ? 'Avoid ::ng-deep usage' : null,
|
|
452
|
+
};
|
|
453
|
+
report.finalReport['zIndex'] = {
|
|
454
|
+
description: 'z-index usage found',
|
|
455
|
+
value: report.zIndex.count,
|
|
456
|
+
status: getStatus(report.zIndex.count),
|
|
457
|
+
comment: report.zIndex.count !== 0 ? 'Avoid z-index setting, usage of eUI CSS vars should be applied' : null,
|
|
458
|
+
};
|
|
459
|
+
}
|
|
480
460
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
461
|
+
// CRITICAL ONLY
|
|
462
|
+
|
|
463
|
+
if (report.htmlLinesCount !== 0) {
|
|
464
|
+
report.finalReport['inlineStyles'] = {
|
|
465
|
+
description: 'inline styles found in HTML',
|
|
466
|
+
value: report.inlineStyles.count,
|
|
467
|
+
status: report.inlineStyles.count !== 0 ? 'CRITICAL' : 'OK',
|
|
468
|
+
comment:
|
|
469
|
+
report.inlineStyles.count !== 0
|
|
470
|
+
? 'No inline styles should be present in html, usage classes with scss / eUI utilities instead'
|
|
471
|
+
: null,
|
|
472
|
+
};
|
|
473
|
+
report.finalReport['material'] = {
|
|
474
|
+
description: 'material component usage found in HTML',
|
|
475
|
+
value: report.material.count,
|
|
476
|
+
status: report.material.count !== 0 ? 'CRITICAL' : 'OK',
|
|
477
|
+
comment: report.material.count !== 0 ? 'Usage of material should be avoided - this will be blocking as of eUI 16' : null,
|
|
478
|
+
};
|
|
479
|
+
report.finalReport['primeng'] = {
|
|
480
|
+
description: 'PrimeNG components usage found in HTML',
|
|
481
|
+
value: report.primeng.count,
|
|
482
|
+
status: report.primeng.count !== 0 ? 'CRITICAL' : 'OK',
|
|
483
|
+
comment: report.primeng.count !== 0 ? 'Remove any PrimeNG usage, deprecated in eUI - this will be blocking as of eUI 16' : null,
|
|
484
|
+
};
|
|
485
|
+
report.finalReport['allModules'] = {
|
|
486
|
+
description: 'Usage of EuiAllModule or UxAllModule',
|
|
487
|
+
value: report.allModules.count,
|
|
488
|
+
status: report.allModules.count !== 0 ? 'CRITICAL' : 'OK',
|
|
489
|
+
comment: report.allModules.count !== 0 ? 'Use only tree-shakable eUI module imports (as of 15+)' : null,
|
|
490
|
+
};
|
|
484
491
|
|
|
485
|
-
|
|
486
|
-
// Calculating score
|
|
492
|
+
// IMPROVE ONLY
|
|
487
493
|
|
|
488
|
-
|
|
494
|
+
report.finalReport['uxCmp'] = {
|
|
495
|
+
description: 'eUI ux- components usage found in HTML',
|
|
496
|
+
value: report.uxCmp.count,
|
|
497
|
+
status: report.uxCmp.count !== 0 ? 'IMPROVE' : 'OK',
|
|
498
|
+
comment: report.uxCmp.count !== 0 ? 'Replace by "eui-" components whenever possible, to ensure future proof migration' : null,
|
|
499
|
+
};
|
|
489
500
|
|
|
490
|
-
|
|
491
|
-
|
|
501
|
+
report.finalReport['tsOver500'] = {
|
|
502
|
+
description: 'TS file containing more than 500 lines',
|
|
503
|
+
value: report.tsOver500.count,
|
|
504
|
+
status: report.tsOver500.count !== 0 ? 'IMPROVE' : 'OK',
|
|
505
|
+
comment: report.tsOver500.count !== 0 ? 'Split TS files into multiple ones for readability' : null,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
492
508
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
});
|
|
509
|
+
report.finalReport['thirdPartyDependencies'] = {
|
|
510
|
+
description: 'Third party dependencies usage',
|
|
511
|
+
value: report.thirdPartyDependencies.count,
|
|
512
|
+
status: report.thirdPartyDependencies.count !== 0 ? 'IMPROVE' : 'OK',
|
|
513
|
+
comment: report.thirdPartyDependencies.count !== 0 ? 'Use 3rd party dependencies only if really necessary (bundle size increase) - contact eUI team for more info' : null,
|
|
514
|
+
};
|
|
502
515
|
|
|
503
|
-
report.score = score;
|
|
504
|
-
report.total = total;
|
|
505
|
-
report.pcScore = Math.floor(100 * score / total);
|
|
506
516
|
|
|
517
|
+
if (Object.keys(report.finalReport).length === 0) {
|
|
518
|
+
tools.logInfo('No sources to audit...skipping');
|
|
519
|
+
return null;
|
|
520
|
+
} else {
|
|
521
|
+
// Calculating score
|
|
507
522
|
|
|
508
|
-
|
|
523
|
+
let score = 0,
|
|
524
|
+
total = 0;
|
|
509
525
|
|
|
510
|
-
|
|
511
|
-
|
|
526
|
+
Object.entries(report.finalReport).forEach((v) => {
|
|
527
|
+
total++;
|
|
512
528
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
529
|
+
switch (v[1].status) {
|
|
530
|
+
case 'OK':
|
|
531
|
+
score++;
|
|
532
|
+
break;
|
|
533
|
+
case 'IMPROVE':
|
|
534
|
+
score += 0.5;
|
|
535
|
+
break;
|
|
536
|
+
}
|
|
537
|
+
});
|
|
516
538
|
|
|
539
|
+
report.score = score;
|
|
540
|
+
report.total = total;
|
|
541
|
+
report.pcScore = Math.floor((100 * score) / total);
|
|
517
542
|
|
|
543
|
+
// return JSON report
|
|
518
544
|
|
|
545
|
+
tools.logInfo('STATS report');
|
|
546
|
+
console.log(JSON.stringify(report, null, 2));
|
|
547
|
+
|
|
548
|
+
return report;
|
|
549
|
+
}
|
|
550
|
+
});
|
|
519
551
|
|
|
520
552
|
module.exports.audit = (pkg) => {
|
|
521
553
|
if (pkg.remote && pkg.name.indexOf('-ui') === -1) {
|
|
@@ -535,37 +567,39 @@ module.exports.audit = (pkg) => {
|
|
|
535
567
|
outputReport = report;
|
|
536
568
|
|
|
537
569
|
return Promise.resolve()
|
|
538
|
-
|
|
539
|
-
|
|
570
|
+
.then(() => {
|
|
571
|
+
// FINAL REPORT
|
|
540
572
|
|
|
541
|
-
|
|
573
|
+
let finalReportMessage = `*STYLES AUDIT REPORT for ${pkg.name}:*\n\n`;
|
|
542
574
|
|
|
543
|
-
|
|
544
|
-
|
|
575
|
+
Object.entries(report.finalReport).forEach((v) => {
|
|
576
|
+
let statusEmoji;
|
|
545
577
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
578
|
+
if (v[1].status === 'CRITICAL') {
|
|
579
|
+
statusEmoji = ':no_entry:';
|
|
580
|
+
} else if (v[1].status === 'IMPROVE') {
|
|
581
|
+
statusEmoji = ':warning:';
|
|
582
|
+
} else {
|
|
583
|
+
statusEmoji = ':large_green_circle:';
|
|
584
|
+
}
|
|
553
585
|
|
|
554
|
-
|
|
555
|
-
|
|
586
|
+
finalReportMessage += `${statusEmoji} *${v[1].description}*: found *${v[1].value}* - status: *${v[1].status}* ${
|
|
587
|
+
v[1].comment ? '==> ' + v[1].comment : ''
|
|
588
|
+
}\n`;
|
|
589
|
+
});
|
|
556
590
|
|
|
557
|
-
|
|
591
|
+
finalReportMessage += `\neUI compliance score : *${report.score}* out of *${report.total}* *(${report.pcScore}%)*`;
|
|
558
592
|
|
|
559
|
-
|
|
560
|
-
|
|
593
|
+
tools.logInfo('Sending final report message');
|
|
594
|
+
console.log(finalReportMessage);
|
|
561
595
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
596
|
+
return notificationUtils.package.sendPackageMessage({
|
|
597
|
+
package: pkg,
|
|
598
|
+
text: finalReportMessage,
|
|
599
|
+
});
|
|
600
|
+
})
|
|
567
601
|
|
|
568
|
-
|
|
602
|
+
.then(() => {
|
|
569
603
|
// getting config options for gates defined
|
|
570
604
|
const configOptions = configUtils.global.getConfigOptions();
|
|
571
605
|
|
|
@@ -588,19 +622,16 @@ module.exports.audit = (pkg) => {
|
|
|
588
622
|
if (pkg.build && pkg.build.stylesAuditCheck) {
|
|
589
623
|
tools.logInfo('All gates checks applied');
|
|
590
624
|
gates = allNewGates;
|
|
591
|
-
|
|
592
625
|
} else {
|
|
593
626
|
tools.logInfo('===> no forced gates flag detected ...');
|
|
594
627
|
tools.logInfo('Checking if package is newly created -- all versions gates are checked in that case');
|
|
595
628
|
|
|
596
629
|
if (metadataUtils.package.isNewPackageBuild(pkg)) {
|
|
597
630
|
gates = allNewGates;
|
|
598
|
-
|
|
599
631
|
} else {
|
|
600
632
|
if (euiVersionGates) {
|
|
601
633
|
tools.logInfo('eUI version gates found, applied to older packages where limited gates are set');
|
|
602
634
|
gates = euiVersionGates;
|
|
603
|
-
|
|
604
635
|
} else {
|
|
605
636
|
tools.logInfo('No gates found for local eUI version...');
|
|
606
637
|
return;
|
|
@@ -610,7 +641,6 @@ module.exports.audit = (pkg) => {
|
|
|
610
641
|
|
|
611
642
|
tools.logInfo(`Gates found : ${JSON.stringify(gates)}`);
|
|
612
643
|
|
|
613
|
-
|
|
614
644
|
// checking gates level if any
|
|
615
645
|
let gatesPassed = true;
|
|
616
646
|
|
|
@@ -629,37 +659,36 @@ module.exports.audit = (pkg) => {
|
|
|
629
659
|
tools.logInfo(`===> PASSED`);
|
|
630
660
|
}
|
|
631
661
|
}
|
|
632
|
-
})
|
|
662
|
+
});
|
|
633
663
|
|
|
634
664
|
if (!gatesPassed) {
|
|
635
665
|
throw new Error('AUDIT_STYLES_GATES_FAILED');
|
|
636
666
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
.then(() => {
|
|
640
|
-
// formatting report for metadata storage
|
|
667
|
+
})
|
|
641
668
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
total: outputReport.total,
|
|
645
|
-
pcScore: outputReport.pcScore,
|
|
646
|
-
};
|
|
669
|
+
.then(() => {
|
|
670
|
+
// formatting report for metadata storage
|
|
647
671
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
status: outputReport.finalReport[item].status,
|
|
672
|
+
const metadataReport = {
|
|
673
|
+
score: outputReport.score,
|
|
674
|
+
total: outputReport.total,
|
|
675
|
+
pcScore: outputReport.pcScore,
|
|
653
676
|
};
|
|
654
|
-
});
|
|
655
677
|
|
|
656
|
-
|
|
678
|
+
const summarizedFinalReport = {};
|
|
679
|
+
Object.keys(outputReport.finalReport).forEach((item) => {
|
|
680
|
+
summarizedFinalReport[item] = {
|
|
681
|
+
value: outputReport.finalReport[item].value,
|
|
682
|
+
status: outputReport.finalReport[item].status,
|
|
683
|
+
};
|
|
684
|
+
});
|
|
657
685
|
|
|
658
|
-
|
|
659
|
-
})
|
|
686
|
+
metadataReport.finalReport = summarizedFinalReport;
|
|
660
687
|
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
})
|
|
688
|
+
return metadataReport;
|
|
689
|
+
})
|
|
664
690
|
|
|
665
|
-
|
|
691
|
+
.catch((e) => {
|
|
692
|
+
throw e;
|
|
693
|
+
});
|
|
694
|
+
};
|
|
@@ -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;
|