-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmodule.config.js
100 lines (92 loc) · 2.73 KB
/
module.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* @typedef {Object} ConfigFeature
* @property {string[]} skippedFeatures
* @property {Object} features
* @property {Object} features.assessments
* @property {string[]} features.assessments.pages
* @property {Object} features.dashboard
* @property {string[]} features.dashboard.pages
* @property {Object[]} features.dashboard.components
* @property {string} features.dashboard.components[].name
* @property {string} features.dashboard.components[].path
* @property {string[]} [skippedComponents] // Optional property
* @property {function(string): void} includes
*/
/**
* @type {ConfigFeature}
*/
const configFeatures = {
skippedFeatures: [""],
features: {
Assessments: {
pages: ["./src/pages/assessments/index.tsx", "./src/pages/assessments/user/[userId]/index.tsx", "./src/pages/assessments/user/[userId]/subject/[subjectId]/index.tsx"],
components: [{
name: "AssessmentReportCard",
path: "./src/components/AssessmentReportCard.tsx"
},
{
name: "AssessmentReport",
path: "./src/components/AssessmentReport.tsx"
}
],
},
Events: {
pages: ["./src/pages/centers/[cohortId]/events/[date]/index.tsx"],
components:
[
{
name: "SessionCard",
path: "./src/components/SessionCard.tsx"
},
{
name: "SessionCardFooter",
path: "./src/components/SessionCardFooter.tsx"
},
{
name: "DeleteSession",
path: "./src/components/DeleteSession.tsx"
},
{
name: "PlannedSession",
path: "./src/components/PlannedSession.tsx"
},
{
name: "Schedule",
path: "./src/components/Schedule.tsx"
},
]
},
// Sample Format to skip pages and components
// featureName: {
// pages: ["./src/pages/pageName.tsx"],
// components: [{
// name: "componentName",
// path: "./src/components/componentName.tsx"
// }],
// }
},
includes: function (componentName) {
console.log(componentName);
}
};
/**
* @param {ConfigFeature} config
* @returns {string[]}
*/
const extractSkippedComponents = (config) => {
const skippedComponents = [];
Object.keys(config.features).forEach((featureKey) => {
const feature = config.features[featureKey];
if (feature.components) {
feature.components.forEach((component) => {
if (component.name) {
skippedComponents.push(component.name);
}
});
}
});
return skippedComponents;
};
// Extract and add skipped components to the config
configFeatures.skippedComponents = extractSkippedComponents(configFeatures);
module.exports = configFeatures;