@appdirect/sfb-toolkit 4.0.9 → 4.0.11
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/coverage/clover.xml +32 -32
- package/coverage/coverage-final.json +4 -4
- package/coverage/lcov-report/constants/customUserAttributesMock.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/pageUrls.js.html +1 -1
- package/coverage/lcov-report/constants/userMock.js.html +1 -1
- package/coverage/lcov-report/controllers/controllers-utils/assetsUtils.js.html +1 -1
- package/coverage/lcov-report/controllers/controllers-utils/index.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/bootstrap-data-filter.js.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/call-to-actions-filter.js.html +1 -1
- package/coverage/lcov-report/controllers/data-filters/index.html +1 -1
- package/coverage/lcov-report/controllers/index.html +1 -1
- package/coverage/lcov-report/controllers/index.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/base/ResultItem.js.html +7 -7
- package/coverage/lcov-report/front-end-utils/src/components/base/SearchBar.js.html +3 -3
- package/coverage/lcov-report/front-end-utils/src/components/base/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/base/item.js.html +11 -11
- package/coverage/lcov-report/front-end-utils/src/components/container.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/data-view.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/header-view.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/components/search.js.html +13 -13
- package/coverage/lcov-report/front-end-utils/src/constants/index.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/pageUrl.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/roleType.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/constants/searchType.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/utils/debounce.js.html +1 -1
- package/coverage/lcov-report/front-end-utils/src/utils/index.html +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/middlewares/config.js.html +1 -1
- package/coverage/lcov-report/middlewares/index.html +1 -1
- package/coverage/lcov.info +81 -81
- package/npm-shrinkwrap.json +4988 -4155
- package/package.json +3 -3
- package/readme.md +3 -2
- package/src/front-end-utils/dist/toolbar.bundle.js +1 -1
- package/src/front-end-utils/dist/toolbar.bundle.js.LICENSE.txt +1 -1
- package/src/tools/toolkit-common-fun.js +253 -1
|
@@ -169,10 +169,256 @@ const updateCustomComponentsMetadata = (data) => {
|
|
|
169
169
|
if(sfbThemeComponentsVersion) {
|
|
170
170
|
data = data.replace(/data-sfb-theme-components-version=".*"/, `data-sfb-theme-components-version="${sfbThemeComponentsVersion}"`);
|
|
171
171
|
}
|
|
172
|
+
if (customComponents) {
|
|
173
|
+
const { overridesJavaScript, overridesSass, userDefinedCustomComponents } = getCustomComponentsInfo();
|
|
174
|
+
if(data.includes("data-custom-components-overrides-js")) {
|
|
175
|
+
data = data.replace(/data-custom-components-overrides-js=".*"/, `data-custom-components-overrides-js="${overridesJavaScript.join(',')}"`);
|
|
176
|
+
data = data.replace(/data-custom-components-overrides-scss=".*"/, `data-custom-components-overrides-scss="${overridesSass.join(',')}"`);
|
|
177
|
+
data = data.replace(/data-custom-components-user-defined=".*"/, `data-custom-components-user-defined="${userDefinedCustomComponents.join(',')}"`);
|
|
178
|
+
} else {
|
|
179
|
+
const start = data.indexOf('data-sfb-theme-components-version');
|
|
180
|
+
data = data.substring(0, start)
|
|
181
|
+
+ `data-custom-components-overrides-js="${overridesJavaScript.join(',')}"`
|
|
182
|
+
+ `\n data-custom-components-overrides-scss="${overridesSass.join(',')}"`
|
|
183
|
+
+ `\n data-custom-components-user-defined="${userDefinedCustomComponents.join(',')}"\n `
|
|
184
|
+
+ data.substring(start);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
172
187
|
}
|
|
173
188
|
return data;
|
|
174
189
|
}
|
|
175
190
|
|
|
191
|
+
const removeCurrentFolderPathPrefix = (path) => {
|
|
192
|
+
return path.replace(/^\.\//, '').trim();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const getExportList = (fileData, prefixPath = '') => {
|
|
196
|
+
const exportList = [];
|
|
197
|
+
const defaultExports = [];
|
|
198
|
+
const pathPattern = /['|"|`](.+)['|"|`]/;
|
|
199
|
+
const exportedComponentPattern = /default\s*as\s*(\w+).*['|"|`](.+)['|"|`]/;
|
|
200
|
+
const filterOutComments = fileData.replace(/\/\/+.*\s*/g, '');
|
|
201
|
+
const filterOutNewlines = filterOutComments.replace(/\r?\n$/g, '');
|
|
202
|
+
const dataList = filterOutNewlines.split(/\r?\n/);
|
|
203
|
+
dataList.forEach(item => {
|
|
204
|
+
const directExportItem = exportedComponentPattern.exec(item);
|
|
205
|
+
if(directExportItem) {
|
|
206
|
+
defaultExports.push({
|
|
207
|
+
alias: directExportItem[1].trim(),
|
|
208
|
+
path: prefixPath + removeCurrentFolderPathPrefix(directExportItem[2])
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
} else {
|
|
212
|
+
const exportItem = pathPattern.exec(item);
|
|
213
|
+
if(exportItem) {
|
|
214
|
+
exportList.push(prefixPath + removeCurrentFolderPathPrefix(exportItem[1]));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
return {
|
|
220
|
+
exportList,
|
|
221
|
+
defaultExports
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const getPathToUse = (usePath) => {
|
|
226
|
+
let fullPath;
|
|
227
|
+
let isPathToFolder = false;
|
|
228
|
+
const basePath = `${ACTIVE_THEME_PATH}/customComponents/${usePath}`;
|
|
229
|
+
const jsFilePath = `${basePath}.js`;
|
|
230
|
+
const jsxFilePath = `${basePath}.jsx`;
|
|
231
|
+
const indexFilePath = `${basePath}/index.js`;
|
|
232
|
+
|
|
233
|
+
if(!(/\.jsx?$/.test(basePath))) {
|
|
234
|
+
if(fs.existsSync(jsxFilePath)) {
|
|
235
|
+
fullPath = jsxFilePath;
|
|
236
|
+
} else if (fs.existsSync(jsFilePath)) {
|
|
237
|
+
fullPath = jsFilePath;
|
|
238
|
+
} else if (fs.existsSync(indexFilePath)) {
|
|
239
|
+
fullPath = indexFilePath;
|
|
240
|
+
isPathToFolder = true;
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
if(fs.existsSync(basePath)) {
|
|
244
|
+
fullPath = basePath;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
fullPath,
|
|
250
|
+
isPathToFolder
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const customComponentsExportsTraversal = (pathsToTraverse) => {
|
|
255
|
+
let paths = [...pathsToTraverse];
|
|
256
|
+
let allDefaultExports = [];
|
|
257
|
+
const overridenScss = new Set();
|
|
258
|
+
while(paths.length > 0) {
|
|
259
|
+
let pathItem = paths.pop();
|
|
260
|
+
let usePath = pathItem.path || pathItem;
|
|
261
|
+
let prefixPath = usePath;
|
|
262
|
+
const { fullPath, isPathToFolder } = getPathToUse(usePath);
|
|
263
|
+
|
|
264
|
+
if (fullPath) {
|
|
265
|
+
const fileData = fs.readFileSync(fullPath, 'utf8');
|
|
266
|
+
const filterOutComments = fileData.replace(/\/\/+.*\s*/g, '');
|
|
267
|
+
|
|
268
|
+
// check if file content is a component
|
|
269
|
+
const component = filterOutComments.match(/export\s+default\s+(?:\w*\((\w+)\)|(\w+));?/);
|
|
270
|
+
|
|
271
|
+
if(component) {
|
|
272
|
+
foundComponent = component[1] || component[2];
|
|
273
|
+
const allScssImports = filterOutComments.matchAll(/['|"|`](.*\/(\w+)\.s?css)['|"|`]/g);
|
|
274
|
+
for(const match of allScssImports) {
|
|
275
|
+
const sfbLibraryScssImport = match[1].includes(THEME_COMPONENT_MODULE);
|
|
276
|
+
if(!sfbLibraryScssImport) {
|
|
277
|
+
if(pathItem.alias) {
|
|
278
|
+
overridenScss.add(pathItem.alias);
|
|
279
|
+
} else {
|
|
280
|
+
// catches the case: export * from 'somePath'
|
|
281
|
+
overridenScss.add(match[2]);
|
|
282
|
+
allDefaultExports.push(match[2]);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
if(!isPathToFolder || usePath.match(/jsx?/)) {
|
|
288
|
+
prefixPath = usePath.match(/(.+)\/.*$/)[1];
|
|
289
|
+
};
|
|
290
|
+
const {
|
|
291
|
+
exportList,
|
|
292
|
+
defaultExports
|
|
293
|
+
} = getExportList(fileData, prefixPath + "/");
|
|
294
|
+
paths.push(...exportList);
|
|
295
|
+
paths.push(...defaultExports);
|
|
296
|
+
|
|
297
|
+
allDefaultExports.push(...defaultExports);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return {
|
|
303
|
+
// converts to Set to filter duplicates then back to a list
|
|
304
|
+
allDefaultExports: [...new Set(allDefaultExports)],
|
|
305
|
+
overridenScss: [...overridenScss]
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const getSfbThemeComponentsList = () => {
|
|
310
|
+
const sfbThemeComponentsPath = `${ACTIVE_THEME_PATH}/node_modules/${THEME_COMPONENT_MODULE}/src/components/index.js`;
|
|
311
|
+
const sfbThemeComponents = fs.existsSync(sfbThemeComponentsPath);
|
|
312
|
+
const defaultExportAliasList = []
|
|
313
|
+
if (sfbThemeComponents) {
|
|
314
|
+
const fileData = fs.readFileSync(sfbThemeComponentsPath, 'utf8');
|
|
315
|
+
const { defaultExports } = getExportList(fileData);
|
|
316
|
+
for(const exportItem of defaultExports) {
|
|
317
|
+
defaultExportAliasList.push(exportItem.alias);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return defaultExportAliasList;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const getCustomComponentsInfo = () => {
|
|
324
|
+
try {
|
|
325
|
+
const overridesJavaScript = new Set();
|
|
326
|
+
const overridesSass = new Set();
|
|
327
|
+
const userDefinedCustomComponents = new Set();
|
|
328
|
+
const sfbConfigPath = CURRENT_PATH;
|
|
329
|
+
const currentTheme = JSON.parse(fs.readFileSync(`${sfbConfigPath}/.sfbconfig`)).current;
|
|
330
|
+
const customComponentsFilesPath = `${sfbConfigPath}/themes/${currentTheme}/customComponents/index.js`;
|
|
331
|
+
const customComponents = fs.existsSync(customComponentsFilesPath);
|
|
332
|
+
|
|
333
|
+
if(customComponents) {
|
|
334
|
+
let componentsPathsLoadedBeforeUiLibrary = [];
|
|
335
|
+
let componentsPathsLoadedAfterUiLibrary = [];
|
|
336
|
+
let uiLibraryPassed = false;
|
|
337
|
+
const indexFileData = fs.readFileSync(customComponentsFilesPath, 'utf8');
|
|
338
|
+
const { exportList, defaultExports }= getExportList(indexFileData);
|
|
339
|
+
const sfbDirectExportsList = getSfbThemeComponentsList();
|
|
340
|
+
const {
|
|
341
|
+
overridenScss: rootIndexOverridenScss
|
|
342
|
+
} = customComponentsExportsTraversal(defaultExports);
|
|
343
|
+
|
|
344
|
+
defaultExports.forEach(exportedItem => {
|
|
345
|
+
if(sfbDirectExportsList.includes(exportedItem.alias)) {
|
|
346
|
+
overridesJavaScript.add(exportedItem.alias);
|
|
347
|
+
if(rootIndexOverridenScss.includes(exportedItem.alias)) {
|
|
348
|
+
overridesSass.add(exportedItem.alias);
|
|
349
|
+
}
|
|
350
|
+
} else {
|
|
351
|
+
userDefinedCustomComponents.add(exportedItem.alias);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
exportList.forEach(exportPath => {
|
|
356
|
+
if(uiLibraryPassed) {
|
|
357
|
+
componentsPathsLoadedAfterUiLibrary.push(exportPath);
|
|
358
|
+
} else {
|
|
359
|
+
if(exportPath.includes(THEME_COMPONENT_MODULE)) {
|
|
360
|
+
uiLibraryPassed = true;
|
|
361
|
+
} else {
|
|
362
|
+
componentsPathsLoadedBeforeUiLibrary.push(exportPath);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
const {
|
|
368
|
+
allDefaultExports: directExportsBeforeUiLibrary,
|
|
369
|
+
overridenScss: overridenScssBefore
|
|
370
|
+
} = customComponentsExportsTraversal(componentsPathsLoadedBeforeUiLibrary);
|
|
371
|
+
|
|
372
|
+
const {
|
|
373
|
+
allDefaultExports: directExportsAfterUiLibrary,
|
|
374
|
+
overridenScss: overridenScssAfter
|
|
375
|
+
} = customComponentsExportsTraversal(componentsPathsLoadedAfterUiLibrary);
|
|
376
|
+
|
|
377
|
+
directExportsBeforeUiLibrary.forEach(exportedItem => {
|
|
378
|
+
if(sfbDirectExportsList.includes(exportedItem.alias)) {
|
|
379
|
+
overridesJavaScript.add(exportedItem.alias);
|
|
380
|
+
if(overridenScssBefore.includes(exportedItem.alias)) {
|
|
381
|
+
overridesSass.add(exportedItem.alias);
|
|
382
|
+
}
|
|
383
|
+
} else if (sfbDirectExportsList.includes(exportedItem)) {
|
|
384
|
+
if(overridenScssBefore.includes(exportedItem)) {
|
|
385
|
+
overridesSass.add(exportedItem);
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
userDefinedCustomComponents.add(exportedItem.alias);
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
directExportsAfterUiLibrary.forEach(exportedItem => {
|
|
393
|
+
if(sfbDirectExportsList.includes(exportedItem.alias)) {
|
|
394
|
+
if(overridenScssAfter.includes(exportedItem.alias)) {
|
|
395
|
+
overridesSass.add(exportedItem.alias);
|
|
396
|
+
}
|
|
397
|
+
} else if(sfbDirectExportsList.includes(exportedItem)) {
|
|
398
|
+
if(overridenScssAfter.includes(exportedItem)) {
|
|
399
|
+
overridesSass.add(exportedItem);
|
|
400
|
+
}
|
|
401
|
+
} else {
|
|
402
|
+
userDefinedCustomComponents.add(exportedItem.alias);
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return {
|
|
408
|
+
overridesJavaScript: [...overridesJavaScript].sort(),
|
|
409
|
+
overridesSass: [...overridesSass].sort(),
|
|
410
|
+
userDefinedCustomComponents: [...userDefinedCustomComponents].sort()
|
|
411
|
+
}
|
|
412
|
+
} catch (error) {
|
|
413
|
+
console.error(chalk.red(`\n ERROR: Unable to obtain Custom Components information due to: ${error}.\n`));
|
|
414
|
+
return {
|
|
415
|
+
overridesJavaScript: [],
|
|
416
|
+
overridesSass: [],
|
|
417
|
+
userDefinedCustomComponents: []
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
176
422
|
const addMetadata = (metadata = {}, themePath) => {
|
|
177
423
|
const sfbConfigPath = themePath || CURRENT_PATH;
|
|
178
424
|
const currentTheme = JSON.parse(fs.readFileSync(`${sfbConfigPath}/.sfbconfig`)).current;
|
|
@@ -227,6 +473,8 @@ const addMetadata = (metadata = {}, themePath) => {
|
|
|
227
473
|
}
|
|
228
474
|
}
|
|
229
475
|
|
|
476
|
+
const { overridesJavaScript, overridesSass, userDefinedCustomComponents } = getCustomComponentsInfo();
|
|
477
|
+
|
|
230
478
|
const output = baseFileData.substring(0, headElemIndex)
|
|
231
479
|
+ ` <ad-theme`
|
|
232
480
|
+ (themeTemplate ? `\n data-theme-template="${themeTemplate}"` : '')
|
|
@@ -234,6 +482,9 @@ const addMetadata = (metadata = {}, themePath) => {
|
|
|
234
482
|
+ (createdBy ? `\n data-created-by="${createdBy}"` :'')
|
|
235
483
|
+ (createdAt ? `\n data-created-at="${createdAt}"` : '')
|
|
236
484
|
+ `\n data-custom-components="${customComponents}"`
|
|
485
|
+
+ `\n data-custom-components-overrides-js="${overridesJavaScript.join(',')}"`
|
|
486
|
+
+ `\n data-custom-components-overrides-scss="${overridesSass.join(',')}"`
|
|
487
|
+
+ `\n data-custom-components-user-defined="${userDefinedCustomComponents.join(',')}"`
|
|
237
488
|
+ `\n data-sfb-theme-components-version="${sfbThemeComponentsVersion}">`
|
|
238
489
|
+ `\n </ad-theme>\n`
|
|
239
490
|
+ baseFileData.substring(headElemIndex);
|
|
@@ -265,5 +516,6 @@ module.exports = {
|
|
|
265
516
|
createCustomThemePacakgeJson,
|
|
266
517
|
updateCustomComponentsMetadata,
|
|
267
518
|
addMetadata,
|
|
268
|
-
installSass
|
|
519
|
+
installSass,
|
|
520
|
+
getCustomComponentsInfo
|
|
269
521
|
}
|