@modern-js/generator-cases 1.0.0-rc.10
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/CHANGELOG.md +79 -0
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/js/modern/index.js +209 -0
- package/dist/js/node/index.js +257 -0
- package/dist/js/treeshaking/index.js +233 -0
- package/dist/types/index.d.ts +28 -0
- package/modern.config.js +2 -0
- package/package.json +41 -0
- package/src/index.ts +254 -0
- package/tests/__snapshots__/index.test.ts.snap +3694 -0
- package/tests/index.test.ts +35 -0
- package/tests/tsconfig.json +11 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
+
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
16
|
+
|
|
17
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
|
|
19
|
+
import make from 'covertable';
|
|
20
|
+
import { Solution, PackageManager, Language, RunWay, BooleanConfig, ClientRoute, MWAActionTypes, MWAActionTypesMap, Framework, BFFType, ActionElement, ActionFunction, ModuleActionTypes, ModuleActionTypesMap, SubSolution } from '@modern-js/generator-common';
|
|
21
|
+
export var LanguageValues = Object.values(Language);
|
|
22
|
+
export var PackageManagerValues = Object.values(PackageManager);
|
|
23
|
+
export var RunWayValues = Object.values(RunWay);
|
|
24
|
+
export var BooleanConfigValues = Object.values(BooleanConfig);
|
|
25
|
+
export var ClientRouteValues = Object.values(ClientRoute);
|
|
26
|
+
export var FrameworkValues = Object.values(Framework);
|
|
27
|
+
export var BFFTypeValues = Object.values(BFFType);
|
|
28
|
+
export var MWAValueMap = {
|
|
29
|
+
language: LanguageValues,
|
|
30
|
+
packageManager: PackageManagerValues,
|
|
31
|
+
runWay: RunWayValues,
|
|
32
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
33
|
+
clientRoute: ClientRouteValues,
|
|
34
|
+
disableStateManagement: BooleanConfigValues,
|
|
35
|
+
enableLess: BooleanConfigValues,
|
|
36
|
+
enableSass: BooleanConfigValues
|
|
37
|
+
};
|
|
38
|
+
export var ModuleValueMap = {
|
|
39
|
+
language: LanguageValues,
|
|
40
|
+
packageManager: PackageManagerValues,
|
|
41
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
42
|
+
enableLess: BooleanConfigValues,
|
|
43
|
+
enableSass: BooleanConfigValues
|
|
44
|
+
};
|
|
45
|
+
export var MonorepoValueMap = {
|
|
46
|
+
packageManager: PackageManagerValues
|
|
47
|
+
};
|
|
48
|
+
export var getMWACases = function getMWACases() {
|
|
49
|
+
var cases = make(MWAValueMap, {
|
|
50
|
+
length: Object.keys(MWAValueMap).length,
|
|
51
|
+
postFilter: function postFilter(row) {
|
|
52
|
+
if (row.needModifyMWAConfig === BooleanConfig.NO && (row.disableStateManagement !== BooleanConfig.NO || row.clientRoute !== ClientRoute.SelfControlRoute || row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return cases.map(function (item) {
|
|
60
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
61
|
+
solution: Solution.MWA
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
export var getModuleCases = function getModuleCases() {
|
|
66
|
+
var cases = make(ModuleValueMap, {
|
|
67
|
+
length: Object.keys(ModuleValueMap).length,
|
|
68
|
+
postFilter: function postFilter(row) {
|
|
69
|
+
if (row.needModifyModuleConfig === BooleanConfig.NO && (row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return cases.map(function (item) {
|
|
77
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
78
|
+
solution: Solution.Module
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
export var getMonorepoCases = function getMonorepoCases() {
|
|
83
|
+
var cases = make(MonorepoValueMap, {
|
|
84
|
+
length: Object.keys(MonorepoValueMap).length
|
|
85
|
+
});
|
|
86
|
+
return cases.map(function (item) {
|
|
87
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
88
|
+
solution: Solution.Monorepo
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
export var MWAEntryValueMap = {
|
|
93
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
94
|
+
clientRoute: ClientRouteValues,
|
|
95
|
+
disableStateManagement: BooleanConfigValues
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
var getMWAEntryCases = function getMWAEntryCases() {
|
|
99
|
+
var cases = make(MWAEntryValueMap, {
|
|
100
|
+
length: Object.keys(MWAEntryValueMap).length
|
|
101
|
+
});
|
|
102
|
+
return cases.map(function (item) {
|
|
103
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
104
|
+
name: Object.values(item).join('-')
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export var MWAServerValueMap = {
|
|
110
|
+
framework: FrameworkValues
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var getMWAServerCases = function getMWAServerCases() {
|
|
114
|
+
return make(MWAServerValueMap, {
|
|
115
|
+
length: Object.keys(MWAServerValueMap).length
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export var MWABFFValueMap = {
|
|
120
|
+
bffType: BFFTypeValues,
|
|
121
|
+
framework: FrameworkValues
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
var getMWABFFCases = function getMWABFFCases() {
|
|
125
|
+
return make(MWABFFValueMap, {
|
|
126
|
+
length: Object.keys(MWABFFValueMap).length
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export var getMWANewCases = function getMWANewCases() {
|
|
131
|
+
var cases = [];
|
|
132
|
+
MWAActionTypes.forEach(function (action) {
|
|
133
|
+
var config = {
|
|
134
|
+
actionType: action
|
|
135
|
+
};
|
|
136
|
+
MWAActionTypesMap[action].forEach(function (option) {
|
|
137
|
+
config[action] = option;
|
|
138
|
+
|
|
139
|
+
var currentConfig = _objectSpread(_objectSpread({}, config), {}, _defineProperty({}, action, option));
|
|
140
|
+
|
|
141
|
+
if (option === ActionElement.Entry) {
|
|
142
|
+
var entryCases = getMWAEntryCases();
|
|
143
|
+
entryCases.forEach(function (c) {
|
|
144
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), c));
|
|
145
|
+
});
|
|
146
|
+
} else if (option === ActionElement.Server) {
|
|
147
|
+
// server only can enable once
|
|
148
|
+
var serverCases = getMWAServerCases();
|
|
149
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), serverCases[Math.round(Math.random() * serverCases.length)]));
|
|
150
|
+
} else if (option === ActionFunction.BFF) {
|
|
151
|
+
// bff only can enable once
|
|
152
|
+
var bffCases = getMWABFFCases();
|
|
153
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), bffCases[Math.round(Math.random() * bffCases.length)]));
|
|
154
|
+
} else {
|
|
155
|
+
cases.push(currentConfig);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
return cases;
|
|
160
|
+
};
|
|
161
|
+
export var getModuleNewCases = function getModuleNewCases() {
|
|
162
|
+
var cases = [];
|
|
163
|
+
ModuleActionTypes.forEach(function (action) {
|
|
164
|
+
var config = {
|
|
165
|
+
actionType: action
|
|
166
|
+
};
|
|
167
|
+
ModuleActionTypesMap[action].forEach(function (option) {
|
|
168
|
+
var currentConfig = _objectSpread(_objectSpread({}, config), {}, _defineProperty({}, action, option));
|
|
169
|
+
|
|
170
|
+
cases.push(currentConfig);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
return cases;
|
|
174
|
+
};
|
|
175
|
+
export var MWASubProjectValueMap = {
|
|
176
|
+
language: LanguageValues,
|
|
177
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
178
|
+
clientRoute: ClientRouteValues,
|
|
179
|
+
disableStateManagement: BooleanConfigValues,
|
|
180
|
+
enableLess: BooleanConfigValues,
|
|
181
|
+
enableSass: BooleanConfigValues
|
|
182
|
+
};
|
|
183
|
+
export var ModuleSubProjectValueMap = {
|
|
184
|
+
language: LanguageValues,
|
|
185
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
186
|
+
enableLess: BooleanConfigValues,
|
|
187
|
+
enableSass: BooleanConfigValues
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
var getMWASubProjectCases = function getMWASubProjectCases(isTest) {
|
|
191
|
+
var cases = make(MWASubProjectValueMap, {
|
|
192
|
+
length: Object.keys(MWASubProjectValueMap).length,
|
|
193
|
+
postFilter: function postFilter(row) {
|
|
194
|
+
if (row.needModifyMWAConfig === BooleanConfig.NO && (row.disableStateManagement !== BooleanConfig.NO || row.clientRoute !== ClientRoute.SelfControlRoute || row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
return cases.map(function (item) {
|
|
202
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
203
|
+
packageName: Object.values(item).join('-'),
|
|
204
|
+
packagePath: Object.values(item).join('-'),
|
|
205
|
+
solution: isTest ? SubSolution.MWATest : SubSolution.MWA
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var getModuleSubProjectCases = function getModuleSubProjectCases(isInner) {
|
|
211
|
+
var cases = make(ModuleSubProjectValueMap, {
|
|
212
|
+
length: Object.keys(ModuleSubProjectValueMap).length,
|
|
213
|
+
postFilter: function postFilter(row) {
|
|
214
|
+
if (row.needModifyModuleConfig === BooleanConfig.NO && (row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
return cases.map(function (item) {
|
|
222
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
223
|
+
packageName: Object.values(item).join('-'),
|
|
224
|
+
packagePath: Object.values(item).join('-'),
|
|
225
|
+
solution: isInner ? SubSolution.InnerModule : SubSolution.Module
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export var getMonorepoNewCases = function getMonorepoNewCases() {
|
|
231
|
+
var cases = [].concat(_toConsumableArray(getMWASubProjectCases(false)), _toConsumableArray(getMWASubProjectCases(true)), _toConsumableArray(getModuleSubProjectCases(false)), _toConsumableArray(getModuleSubProjectCases(true)));
|
|
232
|
+
return cases;
|
|
233
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Solution, PackageManager, Language, RunWay, BooleanConfig, ClientRoute, Framework, BFFType } from '@modern-js/generator-common';
|
|
2
|
+
export declare const LanguageValues: Language[];
|
|
3
|
+
export declare const PackageManagerValues: PackageManager[];
|
|
4
|
+
export declare const RunWayValues: RunWay[];
|
|
5
|
+
export declare const BooleanConfigValues: BooleanConfig[];
|
|
6
|
+
export declare const ClientRouteValues: ClientRoute[];
|
|
7
|
+
export declare const FrameworkValues: Framework[];
|
|
8
|
+
export declare const BFFTypeValues: BFFType[];
|
|
9
|
+
export declare const MWAValueMap: Record<string, string[]>;
|
|
10
|
+
export declare const ModuleValueMap: Record<string, string[]>;
|
|
11
|
+
export declare const MonorepoValueMap: Record<string, string[]>;
|
|
12
|
+
export declare const getMWACases: () => {
|
|
13
|
+
solution: Solution;
|
|
14
|
+
}[];
|
|
15
|
+
export declare const getModuleCases: () => {
|
|
16
|
+
solution: Solution;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const getMonorepoCases: () => {
|
|
19
|
+
solution: Solution;
|
|
20
|
+
}[];
|
|
21
|
+
export declare const MWAEntryValueMap: Record<string, string[]>;
|
|
22
|
+
export declare const MWAServerValueMap: Record<string, string[]>;
|
|
23
|
+
export declare const MWABFFValueMap: Record<string, string[]>;
|
|
24
|
+
export declare const getMWANewCases: () => Record<string, string>[];
|
|
25
|
+
export declare const getModuleNewCases: () => Record<string, string>[];
|
|
26
|
+
export declare const MWASubProjectValueMap: Record<string, string[]>;
|
|
27
|
+
export declare const ModuleSubProjectValueMap: Record<string, string[]>;
|
|
28
|
+
export declare const getMonorepoNewCases: () => Record<string, string>[];
|
package/modern.config.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modern-js/generator-cases",
|
|
3
|
+
"version": "1.0.0-rc.10",
|
|
4
|
+
"jsnext:source": "./src/index.ts",
|
|
5
|
+
"types": "./dist/types/index.d.ts",
|
|
6
|
+
"main": "./dist/js/node/index.js",
|
|
7
|
+
"module": "./dist/js/treeshaking/index.js",
|
|
8
|
+
"jsnext:modern": "./dist/js/modern/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"node": {
|
|
12
|
+
"import": "./dist/js/modern/index.js",
|
|
13
|
+
"require": "./dist/js/node/index.js"
|
|
14
|
+
},
|
|
15
|
+
"default": "./dist/js/treeshaking/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@babel/runtime": "^7",
|
|
20
|
+
"execa": "^5.1.1",
|
|
21
|
+
"covertable": "^2.2.2",
|
|
22
|
+
"@modern-js/generator-common": "1.0.0-rc.11"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/jest": "^26",
|
|
26
|
+
"@types/node": "^14",
|
|
27
|
+
"typescript": "^4",
|
|
28
|
+
"@modern-js/module-tools": "^1.0.0-rc.10",
|
|
29
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.10"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"registry": "https://registry.npmjs.org/",
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"new": "modern new",
|
|
38
|
+
"build": "modern build",
|
|
39
|
+
"test": "modern test --passWithNoTests"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import make from 'covertable';
|
|
2
|
+
import {
|
|
3
|
+
Solution,
|
|
4
|
+
PackageManager,
|
|
5
|
+
Language,
|
|
6
|
+
RunWay,
|
|
7
|
+
BooleanConfig,
|
|
8
|
+
ClientRoute,
|
|
9
|
+
MWAActionTypes,
|
|
10
|
+
MWAActionTypesMap,
|
|
11
|
+
Framework,
|
|
12
|
+
BFFType,
|
|
13
|
+
ActionElement,
|
|
14
|
+
ActionFunction,
|
|
15
|
+
ModuleActionTypes,
|
|
16
|
+
ModuleActionTypesMap,
|
|
17
|
+
SubSolution,
|
|
18
|
+
} from '@modern-js/generator-common';
|
|
19
|
+
|
|
20
|
+
export const LanguageValues = Object.values(Language);
|
|
21
|
+
export const PackageManagerValues = Object.values(PackageManager);
|
|
22
|
+
export const RunWayValues = Object.values(RunWay);
|
|
23
|
+
export const BooleanConfigValues = Object.values(BooleanConfig);
|
|
24
|
+
export const ClientRouteValues = Object.values(ClientRoute);
|
|
25
|
+
export const FrameworkValues = Object.values(Framework);
|
|
26
|
+
export const BFFTypeValues = Object.values(BFFType);
|
|
27
|
+
|
|
28
|
+
export const MWAValueMap: Record<string, string[]> = {
|
|
29
|
+
language: LanguageValues,
|
|
30
|
+
packageManager: PackageManagerValues,
|
|
31
|
+
runWay: RunWayValues,
|
|
32
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
33
|
+
clientRoute: ClientRouteValues,
|
|
34
|
+
disableStateManagement: BooleanConfigValues,
|
|
35
|
+
enableLess: BooleanConfigValues,
|
|
36
|
+
enableSass: BooleanConfigValues,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const ModuleValueMap: Record<string, string[]> = {
|
|
40
|
+
language: LanguageValues,
|
|
41
|
+
packageManager: PackageManagerValues,
|
|
42
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
43
|
+
enableLess: BooleanConfigValues,
|
|
44
|
+
enableSass: BooleanConfigValues,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const MonorepoValueMap: Record<string, string[]> = {
|
|
48
|
+
packageManager: PackageManagerValues,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const getMWACases = () => {
|
|
52
|
+
const cases = make(MWAValueMap, {
|
|
53
|
+
length: Object.keys(MWAValueMap).length,
|
|
54
|
+
postFilter: (row: Record<string, any>) => {
|
|
55
|
+
if (
|
|
56
|
+
row.needModifyMWAConfig === BooleanConfig.NO &&
|
|
57
|
+
(row.disableStateManagement !== BooleanConfig.NO ||
|
|
58
|
+
row.clientRoute !== ClientRoute.SelfControlRoute ||
|
|
59
|
+
row.enableLess !== BooleanConfig.NO ||
|
|
60
|
+
row.enableSass !== BooleanConfig.NO)
|
|
61
|
+
) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
return cases.map(item => ({
|
|
68
|
+
...item,
|
|
69
|
+
solution: Solution.MWA,
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const getModuleCases = () => {
|
|
74
|
+
const cases = make(ModuleValueMap, {
|
|
75
|
+
length: Object.keys(ModuleValueMap).length,
|
|
76
|
+
postFilter: (row: Record<string, any>) => {
|
|
77
|
+
if (
|
|
78
|
+
row.needModifyModuleConfig === BooleanConfig.NO &&
|
|
79
|
+
(row.enableLess !== BooleanConfig.NO ||
|
|
80
|
+
row.enableSass !== BooleanConfig.NO)
|
|
81
|
+
) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return cases.map(item => ({
|
|
88
|
+
...item,
|
|
89
|
+
solution: Solution.Module,
|
|
90
|
+
}));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const getMonorepoCases = () => {
|
|
94
|
+
const cases = make(MonorepoValueMap, {
|
|
95
|
+
length: Object.keys(MonorepoValueMap).length,
|
|
96
|
+
});
|
|
97
|
+
return cases.map(item => ({
|
|
98
|
+
...item,
|
|
99
|
+
solution: Solution.Monorepo,
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const MWAEntryValueMap: Record<string, string[]> = {
|
|
104
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
105
|
+
clientRoute: ClientRouteValues,
|
|
106
|
+
disableStateManagement: BooleanConfigValues,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const getMWAEntryCases = () => {
|
|
110
|
+
const cases = make(MWAEntryValueMap, {
|
|
111
|
+
length: Object.keys(MWAEntryValueMap).length,
|
|
112
|
+
});
|
|
113
|
+
return cases.map(item => ({
|
|
114
|
+
...item,
|
|
115
|
+
name: Object.values(item).join('-'),
|
|
116
|
+
}));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const MWAServerValueMap: Record<string, string[]> = {
|
|
120
|
+
framework: FrameworkValues,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const getMWAServerCases = () =>
|
|
124
|
+
make(MWAServerValueMap, {
|
|
125
|
+
length: Object.keys(MWAServerValueMap).length,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
export const MWABFFValueMap: Record<string, string[]> = {
|
|
129
|
+
bffType: BFFTypeValues,
|
|
130
|
+
framework: FrameworkValues,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const getMWABFFCases = () =>
|
|
134
|
+
make(MWABFFValueMap, {
|
|
135
|
+
length: Object.keys(MWABFFValueMap).length,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
export const getMWANewCases = () => {
|
|
139
|
+
const cases: Array<Record<string, string>> = [];
|
|
140
|
+
MWAActionTypes.forEach(action => {
|
|
141
|
+
const config: Record<string, any> = { actionType: action };
|
|
142
|
+
MWAActionTypesMap[action].forEach(option => {
|
|
143
|
+
config[action] = option;
|
|
144
|
+
const currentConfig = { ...config, [action]: option };
|
|
145
|
+
if (option === ActionElement.Entry) {
|
|
146
|
+
const entryCases = getMWAEntryCases();
|
|
147
|
+
entryCases.forEach(c => {
|
|
148
|
+
cases.push({ ...currentConfig, ...c });
|
|
149
|
+
});
|
|
150
|
+
} else if (option === ActionElement.Server) {
|
|
151
|
+
// server only can enable once
|
|
152
|
+
const serverCases = getMWAServerCases();
|
|
153
|
+
cases.push({
|
|
154
|
+
...currentConfig,
|
|
155
|
+
...serverCases[Math.round(Math.random() * serverCases.length)],
|
|
156
|
+
});
|
|
157
|
+
} else if (option === ActionFunction.BFF) {
|
|
158
|
+
// bff only can enable once
|
|
159
|
+
const bffCases = getMWABFFCases();
|
|
160
|
+
cases.push({
|
|
161
|
+
...currentConfig,
|
|
162
|
+
...bffCases[Math.round(Math.random() * bffCases.length)],
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
cases.push(currentConfig);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
return cases;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export const getModuleNewCases = () => {
|
|
173
|
+
const cases: Array<Record<string, string>> = [];
|
|
174
|
+
ModuleActionTypes.forEach(action => {
|
|
175
|
+
const config: Record<string, any> = { actionType: action };
|
|
176
|
+
ModuleActionTypesMap[action].forEach(option => {
|
|
177
|
+
const currentConfig = { ...config, [action]: option };
|
|
178
|
+
cases.push(currentConfig);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
return cases;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const MWASubProjectValueMap: Record<string, string[]> = {
|
|
185
|
+
language: LanguageValues,
|
|
186
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
187
|
+
clientRoute: ClientRouteValues,
|
|
188
|
+
disableStateManagement: BooleanConfigValues,
|
|
189
|
+
enableLess: BooleanConfigValues,
|
|
190
|
+
enableSass: BooleanConfigValues,
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const ModuleSubProjectValueMap: Record<string, string[]> = {
|
|
194
|
+
language: LanguageValues,
|
|
195
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
196
|
+
enableLess: BooleanConfigValues,
|
|
197
|
+
enableSass: BooleanConfigValues,
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const getMWASubProjectCases = (isTest: boolean) => {
|
|
201
|
+
const cases = make(MWASubProjectValueMap, {
|
|
202
|
+
length: Object.keys(MWASubProjectValueMap).length,
|
|
203
|
+
postFilter: (row: Record<string, any>) => {
|
|
204
|
+
if (
|
|
205
|
+
row.needModifyMWAConfig === BooleanConfig.NO &&
|
|
206
|
+
(row.disableStateManagement !== BooleanConfig.NO ||
|
|
207
|
+
row.clientRoute !== ClientRoute.SelfControlRoute ||
|
|
208
|
+
row.enableLess !== BooleanConfig.NO ||
|
|
209
|
+
row.enableSass !== BooleanConfig.NO)
|
|
210
|
+
) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
return cases.map(item => ({
|
|
217
|
+
...item,
|
|
218
|
+
packageName: Object.values(item).join('-'),
|
|
219
|
+
packagePath: Object.values(item).join('-'),
|
|
220
|
+
solution: isTest ? SubSolution.MWATest : SubSolution.MWA,
|
|
221
|
+
}));
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const getModuleSubProjectCases = (isInner: boolean) => {
|
|
225
|
+
const cases = make(ModuleSubProjectValueMap, {
|
|
226
|
+
length: Object.keys(ModuleSubProjectValueMap).length,
|
|
227
|
+
postFilter: (row: Record<string, any>) => {
|
|
228
|
+
if (
|
|
229
|
+
row.needModifyModuleConfig === BooleanConfig.NO &&
|
|
230
|
+
(row.enableLess !== BooleanConfig.NO ||
|
|
231
|
+
row.enableSass !== BooleanConfig.NO)
|
|
232
|
+
) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
return true;
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
return cases.map(item => ({
|
|
239
|
+
...item,
|
|
240
|
+
packageName: Object.values(item).join('-'),
|
|
241
|
+
packagePath: Object.values(item).join('-'),
|
|
242
|
+
solution: isInner ? SubSolution.InnerModule : SubSolution.Module,
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export const getMonorepoNewCases = () => {
|
|
247
|
+
const cases: Array<Record<string, string>> = [
|
|
248
|
+
...getMWASubProjectCases(false),
|
|
249
|
+
...getMWASubProjectCases(true),
|
|
250
|
+
...getModuleSubProjectCases(false),
|
|
251
|
+
...getModuleSubProjectCases(true),
|
|
252
|
+
];
|
|
253
|
+
return cases;
|
|
254
|
+
};
|