@modern-js/generator-cases 1.2.0 → 1.2.3
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 +28 -0
- package/dist/js/modern/index.js +1 -1
- package/dist/js/node/index.js +1 -1
- package/dist/js/treeshaking/index.js +3 -1
- package/package.json +3 -5
- package/tests/__snapshots__/index.test.ts.snap +1923 -743
- package/tests/index.test.ts +1 -1
- package/src/index.ts +0 -277
package/tests/index.test.ts
CHANGED
|
@@ -22,7 +22,7 @@ describe('test generator cases', () => {
|
|
|
22
22
|
});
|
|
23
23
|
test('test getMWANewCases', async () => {
|
|
24
24
|
const mwaNewCases = getMWANewCases();
|
|
25
|
-
expect(mwaNewCases.length).toBe(
|
|
25
|
+
expect(mwaNewCases.length).toBe(26);
|
|
26
26
|
});
|
|
27
27
|
test('test getModuleNewCases', async () => {
|
|
28
28
|
const moduleNewCases = getModuleNewCases();
|
package/src/index.ts
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
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
|
-
CDNType,
|
|
19
|
-
LambdaType,
|
|
20
|
-
} from '@modern-js/generator-common';
|
|
21
|
-
|
|
22
|
-
export const LanguageValues = Object.values(Language);
|
|
23
|
-
export const PackageManagerValues = Object.values(PackageManager);
|
|
24
|
-
export const RunWayValues = Object.values(RunWay);
|
|
25
|
-
export const BooleanConfigValues = Object.values(BooleanConfig);
|
|
26
|
-
export const ClientRouteValues = Object.values(ClientRoute);
|
|
27
|
-
export const FrameworkValues = Object.values(Framework);
|
|
28
|
-
export const BFFTypeValues = Object.values(BFFType);
|
|
29
|
-
export const CDNTypeValues = Object.values(CDNType);
|
|
30
|
-
export const LambdaTypeValues = Object.values(LambdaType);
|
|
31
|
-
|
|
32
|
-
export const MWAValueMap: Record<string, string[]> = {
|
|
33
|
-
language: LanguageValues,
|
|
34
|
-
packageManager: PackageManagerValues,
|
|
35
|
-
runWay: RunWayValues,
|
|
36
|
-
needModifyMWAConfig: BooleanConfigValues,
|
|
37
|
-
clientRoute: ClientRouteValues,
|
|
38
|
-
disableStateManagement: BooleanConfigValues,
|
|
39
|
-
enableLess: BooleanConfigValues,
|
|
40
|
-
enableSass: BooleanConfigValues,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const ModuleValueMap: Record<string, string[]> = {
|
|
44
|
-
language: LanguageValues,
|
|
45
|
-
packageManager: PackageManagerValues,
|
|
46
|
-
needModifyModuleConfig: BooleanConfigValues,
|
|
47
|
-
enableLess: BooleanConfigValues,
|
|
48
|
-
enableSass: BooleanConfigValues,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const MonorepoValueMap: Record<string, string[]> = {
|
|
52
|
-
packageManager: PackageManagerValues,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const getMWACases = (length?: number) => {
|
|
56
|
-
const cases = make(MWAValueMap, {
|
|
57
|
-
length: length || Object.keys(MWAValueMap).length,
|
|
58
|
-
postFilter: (row: Record<string, any>) => {
|
|
59
|
-
if (
|
|
60
|
-
row.needModifyMWAConfig === BooleanConfig.NO &&
|
|
61
|
-
(row.disableStateManagement !== BooleanConfig.NO ||
|
|
62
|
-
row.clientRoute !== ClientRoute.SelfControlRoute ||
|
|
63
|
-
row.enableLess !== BooleanConfig.NO ||
|
|
64
|
-
row.enableSass !== BooleanConfig.NO)
|
|
65
|
-
) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return true;
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
return cases.map(item => ({
|
|
72
|
-
...item,
|
|
73
|
-
solution: Solution.MWA,
|
|
74
|
-
}));
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const getModuleCases = (length?: number) => {
|
|
78
|
-
const cases = make(ModuleValueMap, {
|
|
79
|
-
length: length || Object.keys(ModuleValueMap).length,
|
|
80
|
-
postFilter: (row: Record<string, any>) => {
|
|
81
|
-
if (
|
|
82
|
-
row.needModifyModuleConfig === BooleanConfig.NO &&
|
|
83
|
-
(row.enableLess !== BooleanConfig.NO ||
|
|
84
|
-
row.enableSass !== BooleanConfig.NO)
|
|
85
|
-
) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
return cases.map(item => ({
|
|
92
|
-
...item,
|
|
93
|
-
solution: Solution.Module,
|
|
94
|
-
}));
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const getMonorepoCases = () => {
|
|
98
|
-
const cases = make(MonorepoValueMap, {
|
|
99
|
-
length: Object.keys(MonorepoValueMap).length,
|
|
100
|
-
});
|
|
101
|
-
return cases.map(item => ({
|
|
102
|
-
...item,
|
|
103
|
-
solution: Solution.Monorepo,
|
|
104
|
-
}));
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const MWAEntryValueMap: Record<string, string[]> = {
|
|
108
|
-
needModifyMWAConfig: BooleanConfigValues,
|
|
109
|
-
clientRoute: ClientRouteValues,
|
|
110
|
-
disableStateManagement: BooleanConfigValues,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const getMWAEntryCases = (length?: number) => {
|
|
114
|
-
const cases = make(MWAEntryValueMap, {
|
|
115
|
-
length: length || Object.keys(MWAEntryValueMap).length,
|
|
116
|
-
});
|
|
117
|
-
return cases.map(item => ({
|
|
118
|
-
...item,
|
|
119
|
-
name: Object.values(item).join('-'),
|
|
120
|
-
}));
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const MWAServerValueMap: Record<string, string[]> = {
|
|
124
|
-
framework: FrameworkValues,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const getMWAServerCases = () =>
|
|
128
|
-
make(MWAServerValueMap, {
|
|
129
|
-
length: Object.keys(MWAServerValueMap).length,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
export const MWABFFValueMap: Record<string, string[]> = {
|
|
133
|
-
bffType: BFFTypeValues,
|
|
134
|
-
framework: FrameworkValues,
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const MWADeployValueMap: Record<string, string[]> = {
|
|
138
|
-
disableModernServer: BooleanConfigValues,
|
|
139
|
-
cdnType: CDNTypeValues,
|
|
140
|
-
lambdaType: LambdaTypeValues,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const getMWABFFCases = (length?: number) =>
|
|
144
|
-
make(MWABFFValueMap, {
|
|
145
|
-
length: length || Object.keys(MWABFFValueMap).length,
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
const getMWADeployCases = (length?: number) =>
|
|
149
|
-
make(MWADeployValueMap, {
|
|
150
|
-
length: length || Object.keys(MWADeployValueMap).length,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
export const getMWANewCases = (length?: number) => {
|
|
154
|
-
const cases: Array<Record<string, string>> = [];
|
|
155
|
-
MWAActionTypes.forEach(action => {
|
|
156
|
-
const config: Record<string, any> = { actionType: action };
|
|
157
|
-
MWAActionTypesMap[action].forEach(option => {
|
|
158
|
-
config[action] = option;
|
|
159
|
-
const currentConfig = { ...config, [action]: option };
|
|
160
|
-
if (option === ActionElement.Entry) {
|
|
161
|
-
const entryCases = getMWAEntryCases(length);
|
|
162
|
-
entryCases.forEach(c => {
|
|
163
|
-
cases.push({ ...currentConfig, ...c });
|
|
164
|
-
});
|
|
165
|
-
} else if (option === ActionElement.Server) {
|
|
166
|
-
// server only can enable once
|
|
167
|
-
const serverCases = getMWAServerCases();
|
|
168
|
-
cases.push({
|
|
169
|
-
...currentConfig,
|
|
170
|
-
...serverCases[Math.round(Math.random() * serverCases.length)],
|
|
171
|
-
});
|
|
172
|
-
} else if (option === ActionFunction.BFF) {
|
|
173
|
-
// bff only can enable once
|
|
174
|
-
const bffCases = getMWABFFCases(length);
|
|
175
|
-
cases.push({
|
|
176
|
-
...currentConfig,
|
|
177
|
-
...bffCases[Math.round(Math.random() * bffCases.length)],
|
|
178
|
-
});
|
|
179
|
-
} else if (option === ActionFunction.Deploy) {
|
|
180
|
-
// deploy only can enable once
|
|
181
|
-
const deployCases = getMWADeployCases(length);
|
|
182
|
-
cases.push({
|
|
183
|
-
...currentConfig,
|
|
184
|
-
...deployCases[Math.round(Math.random() * deployCases.length)],
|
|
185
|
-
});
|
|
186
|
-
} else {
|
|
187
|
-
cases.push(currentConfig);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
return cases;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export const getModuleNewCases = () => {
|
|
195
|
-
const cases: Array<Record<string, string>> = [];
|
|
196
|
-
ModuleActionTypes.forEach(action => {
|
|
197
|
-
const config: Record<string, any> = { actionType: action };
|
|
198
|
-
ModuleActionTypesMap[action].forEach(option => {
|
|
199
|
-
const currentConfig = { ...config, [action]: option };
|
|
200
|
-
cases.push(currentConfig);
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
return cases;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export const MWASubProjectValueMap: Record<string, string[]> = {
|
|
207
|
-
language: LanguageValues,
|
|
208
|
-
needModifyMWAConfig: BooleanConfigValues,
|
|
209
|
-
runWay: RunWayValues,
|
|
210
|
-
clientRoute: ClientRouteValues,
|
|
211
|
-
disableStateManagement: BooleanConfigValues,
|
|
212
|
-
enableLess: BooleanConfigValues,
|
|
213
|
-
enableSass: BooleanConfigValues,
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const ModuleSubProjectValueMap: Record<string, string[]> = {
|
|
217
|
-
language: LanguageValues,
|
|
218
|
-
needModifyModuleConfig: BooleanConfigValues,
|
|
219
|
-
enableLess: BooleanConfigValues,
|
|
220
|
-
enableSass: BooleanConfigValues,
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const getMWASubProjectCases = (isTest: boolean, length?: number) => {
|
|
224
|
-
const cases = make(MWASubProjectValueMap, {
|
|
225
|
-
length: length || Object.keys(MWASubProjectValueMap).length,
|
|
226
|
-
postFilter: (row: Record<string, any>) => {
|
|
227
|
-
if (
|
|
228
|
-
row.needModifyMWAConfig === BooleanConfig.NO &&
|
|
229
|
-
(row.disableStateManagement !== BooleanConfig.NO ||
|
|
230
|
-
row.clientRoute !== ClientRoute.SelfControlRoute ||
|
|
231
|
-
row.enableLess !== BooleanConfig.NO ||
|
|
232
|
-
row.enableSass !== BooleanConfig.NO)
|
|
233
|
-
) {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
return true;
|
|
237
|
-
},
|
|
238
|
-
});
|
|
239
|
-
return cases.map(item => ({
|
|
240
|
-
...item,
|
|
241
|
-
packageName: Object.values(item).join('-'),
|
|
242
|
-
packagePath: Object.values(item).join('-'),
|
|
243
|
-
solution: isTest ? SubSolution.MWATest : SubSolution.MWA,
|
|
244
|
-
}));
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
const getModuleSubProjectCases = (isInner: boolean, length?: number) => {
|
|
248
|
-
const cases = make(ModuleSubProjectValueMap, {
|
|
249
|
-
length: length || Object.keys(ModuleSubProjectValueMap).length,
|
|
250
|
-
postFilter: (row: Record<string, any>) => {
|
|
251
|
-
if (
|
|
252
|
-
row.needModifyModuleConfig === BooleanConfig.NO &&
|
|
253
|
-
(row.enableLess !== BooleanConfig.NO ||
|
|
254
|
-
row.enableSass !== BooleanConfig.NO)
|
|
255
|
-
) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
return true;
|
|
259
|
-
},
|
|
260
|
-
});
|
|
261
|
-
return cases.map(item => ({
|
|
262
|
-
...item,
|
|
263
|
-
packageName: Object.values(item).join('-'),
|
|
264
|
-
packagePath: Object.values(item).join('-'),
|
|
265
|
-
solution: isInner ? SubSolution.InnerModule : SubSolution.Module,
|
|
266
|
-
}));
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
export const getMonorepoNewCases = (length?: number) => {
|
|
270
|
-
const cases: Array<Record<string, string>> = [
|
|
271
|
-
...getMWASubProjectCases(false, length),
|
|
272
|
-
...getMWASubProjectCases(true, length),
|
|
273
|
-
...getModuleSubProjectCases(false, length),
|
|
274
|
-
...getModuleSubProjectCases(true, length),
|
|
275
|
-
];
|
|
276
|
-
return cases;
|
|
277
|
-
};
|