@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
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# @modern-js/generator-cases
|
|
2
|
+
|
|
3
|
+
## 1.0.0-rc.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 224f7fe: fix server route match
|
|
8
|
+
- 204c626: feat: initial
|
|
9
|
+
- Updated dependencies [224f7fe]
|
|
10
|
+
- Updated dependencies [204c626]
|
|
11
|
+
- @modern-js/generator-common@1.0.0-rc.11
|
|
12
|
+
|
|
13
|
+
## 1.0.0-rc.9
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 224f7fe: fix server route match
|
|
18
|
+
- 204c626: feat: initial
|
|
19
|
+
- Updated dependencies [224f7fe]
|
|
20
|
+
- Updated dependencies [204c626]
|
|
21
|
+
- @modern-js/generator-common@1.0.0-rc.10
|
|
22
|
+
|
|
23
|
+
## 1.0.0-rc.8
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- 224f7fe: fix server route match
|
|
28
|
+
- 204c626: feat: initial
|
|
29
|
+
- Updated dependencies [224f7fe]
|
|
30
|
+
- Updated dependencies [204c626]
|
|
31
|
+
- @modern-js/generator-common@1.0.0-rc.9
|
|
32
|
+
|
|
33
|
+
## 1.0.0-rc.7
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- 224f7fe: fix server route match
|
|
38
|
+
- 204c626: feat: initial
|
|
39
|
+
- Updated dependencies [224f7fe]
|
|
40
|
+
- Updated dependencies [204c626]
|
|
41
|
+
- @modern-js/generator-common@1.0.0-rc.8
|
|
42
|
+
|
|
43
|
+
## 1.0.0-rc.6
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- 224f7fe: fix server route match
|
|
48
|
+
- 204c626: feat: initial
|
|
49
|
+
- Updated dependencies [224f7fe]
|
|
50
|
+
- Updated dependencies [204c626]
|
|
51
|
+
- @modern-js/generator-common@1.0.0-rc.7
|
|
52
|
+
|
|
53
|
+
## 1.0.0-rc.5
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 224f7fe: fix server route match
|
|
58
|
+
- 204c626: feat: initial
|
|
59
|
+
- Updated dependencies [224f7fe]
|
|
60
|
+
- Updated dependencies [204c626]
|
|
61
|
+
- @modern-js/generator-common@1.0.0-rc.6
|
|
62
|
+
|
|
63
|
+
## 1.0.0-rc.4
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- fix server route match
|
|
68
|
+
- 204c626: feat: initial
|
|
69
|
+
- Updated dependencies [undefined]
|
|
70
|
+
- Updated dependencies [204c626]
|
|
71
|
+
- @modern-js/generator-common@1.0.0-rc.5
|
|
72
|
+
|
|
73
|
+
## 1.0.0-rc.3
|
|
74
|
+
|
|
75
|
+
### Patch Changes
|
|
76
|
+
|
|
77
|
+
- feat: initial
|
|
78
|
+
- Updated dependencies [undefined]
|
|
79
|
+
- @modern-js/generator-common@1.0.0-rc.4
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Modern.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
<p align="center">现代 Web 工程体系</p>
|
|
7
|
+
|
|
8
|
+
## 背景
|
|
9
|
+
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
|
10
|
+
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
|
11
|
+
|
|
12
|
+
## 计划
|
|
13
|
+
|
|
14
|
+
Modern.js 的 1.0.0.rc 版已经发到 npm,目前在做测试改进,README 文档之后统一提供(现阶段加入测试和开发,可以发 [issue](https://github.com/modern-js-dev/modern.js/issues) 留微信联系),完整的文档站计划在10月14日上线
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
|
|
3
|
+
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; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import make from 'covertable';
|
|
8
|
+
import { Solution, PackageManager, Language, RunWay, BooleanConfig, ClientRoute, MWAActionTypes, MWAActionTypesMap, Framework, BFFType, ActionElement, ActionFunction, ModuleActionTypes, ModuleActionTypesMap, SubSolution } from '@modern-js/generator-common';
|
|
9
|
+
export const LanguageValues = Object.values(Language);
|
|
10
|
+
export const PackageManagerValues = Object.values(PackageManager);
|
|
11
|
+
export const RunWayValues = Object.values(RunWay);
|
|
12
|
+
export const BooleanConfigValues = Object.values(BooleanConfig);
|
|
13
|
+
export const ClientRouteValues = Object.values(ClientRoute);
|
|
14
|
+
export const FrameworkValues = Object.values(Framework);
|
|
15
|
+
export const BFFTypeValues = Object.values(BFFType);
|
|
16
|
+
export const MWAValueMap = {
|
|
17
|
+
language: LanguageValues,
|
|
18
|
+
packageManager: PackageManagerValues,
|
|
19
|
+
runWay: RunWayValues,
|
|
20
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
21
|
+
clientRoute: ClientRouteValues,
|
|
22
|
+
disableStateManagement: BooleanConfigValues,
|
|
23
|
+
enableLess: BooleanConfigValues,
|
|
24
|
+
enableSass: BooleanConfigValues
|
|
25
|
+
};
|
|
26
|
+
export const ModuleValueMap = {
|
|
27
|
+
language: LanguageValues,
|
|
28
|
+
packageManager: PackageManagerValues,
|
|
29
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
30
|
+
enableLess: BooleanConfigValues,
|
|
31
|
+
enableSass: BooleanConfigValues
|
|
32
|
+
};
|
|
33
|
+
export const MonorepoValueMap = {
|
|
34
|
+
packageManager: PackageManagerValues
|
|
35
|
+
};
|
|
36
|
+
export const getMWACases = () => {
|
|
37
|
+
const cases = make(MWAValueMap, {
|
|
38
|
+
length: Object.keys(MWAValueMap).length,
|
|
39
|
+
postFilter: row => {
|
|
40
|
+
if (row.needModifyMWAConfig === BooleanConfig.NO && (row.disableStateManagement !== BooleanConfig.NO || row.clientRoute !== ClientRoute.SelfControlRoute || row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
48
|
+
solution: Solution.MWA
|
|
49
|
+
}));
|
|
50
|
+
};
|
|
51
|
+
export const getModuleCases = () => {
|
|
52
|
+
const cases = make(ModuleValueMap, {
|
|
53
|
+
length: Object.keys(ModuleValueMap).length,
|
|
54
|
+
postFilter: row => {
|
|
55
|
+
if (row.needModifyModuleConfig === BooleanConfig.NO && (row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
63
|
+
solution: Solution.Module
|
|
64
|
+
}));
|
|
65
|
+
};
|
|
66
|
+
export const getMonorepoCases = () => {
|
|
67
|
+
const cases = make(MonorepoValueMap, {
|
|
68
|
+
length: Object.keys(MonorepoValueMap).length
|
|
69
|
+
});
|
|
70
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
71
|
+
solution: Solution.Monorepo
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
export const MWAEntryValueMap = {
|
|
75
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
76
|
+
clientRoute: ClientRouteValues,
|
|
77
|
+
disableStateManagement: BooleanConfigValues
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const getMWAEntryCases = () => {
|
|
81
|
+
const cases = make(MWAEntryValueMap, {
|
|
82
|
+
length: Object.keys(MWAEntryValueMap).length
|
|
83
|
+
});
|
|
84
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
85
|
+
name: Object.values(item).join('-')
|
|
86
|
+
}));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const MWAServerValueMap = {
|
|
90
|
+
framework: FrameworkValues
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const getMWAServerCases = () => make(MWAServerValueMap, {
|
|
94
|
+
length: Object.keys(MWAServerValueMap).length
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const MWABFFValueMap = {
|
|
98
|
+
bffType: BFFTypeValues,
|
|
99
|
+
framework: FrameworkValues
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const getMWABFFCases = () => make(MWABFFValueMap, {
|
|
103
|
+
length: Object.keys(MWABFFValueMap).length
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export const getMWANewCases = () => {
|
|
107
|
+
const cases = [];
|
|
108
|
+
MWAActionTypes.forEach(action => {
|
|
109
|
+
const config = {
|
|
110
|
+
actionType: action
|
|
111
|
+
};
|
|
112
|
+
MWAActionTypesMap[action].forEach(option => {
|
|
113
|
+
config[action] = option;
|
|
114
|
+
|
|
115
|
+
const currentConfig = _objectSpread(_objectSpread({}, config), {}, {
|
|
116
|
+
[action]: option
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (option === ActionElement.Entry) {
|
|
120
|
+
const entryCases = getMWAEntryCases();
|
|
121
|
+
entryCases.forEach(c => {
|
|
122
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), c));
|
|
123
|
+
});
|
|
124
|
+
} else if (option === ActionElement.Server) {
|
|
125
|
+
// server only can enable once
|
|
126
|
+
const serverCases = getMWAServerCases();
|
|
127
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), serverCases[Math.round(Math.random() * serverCases.length)]));
|
|
128
|
+
} else if (option === ActionFunction.BFF) {
|
|
129
|
+
// bff only can enable once
|
|
130
|
+
const bffCases = getMWABFFCases();
|
|
131
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), bffCases[Math.round(Math.random() * bffCases.length)]));
|
|
132
|
+
} else {
|
|
133
|
+
cases.push(currentConfig);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return cases;
|
|
138
|
+
};
|
|
139
|
+
export const getModuleNewCases = () => {
|
|
140
|
+
const cases = [];
|
|
141
|
+
ModuleActionTypes.forEach(action => {
|
|
142
|
+
const config = {
|
|
143
|
+
actionType: action
|
|
144
|
+
};
|
|
145
|
+
ModuleActionTypesMap[action].forEach(option => {
|
|
146
|
+
const currentConfig = _objectSpread(_objectSpread({}, config), {}, {
|
|
147
|
+
[action]: option
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
cases.push(currentConfig);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
return cases;
|
|
154
|
+
};
|
|
155
|
+
export const MWASubProjectValueMap = {
|
|
156
|
+
language: LanguageValues,
|
|
157
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
158
|
+
clientRoute: ClientRouteValues,
|
|
159
|
+
disableStateManagement: BooleanConfigValues,
|
|
160
|
+
enableLess: BooleanConfigValues,
|
|
161
|
+
enableSass: BooleanConfigValues
|
|
162
|
+
};
|
|
163
|
+
export const ModuleSubProjectValueMap = {
|
|
164
|
+
language: LanguageValues,
|
|
165
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
166
|
+
enableLess: BooleanConfigValues,
|
|
167
|
+
enableSass: BooleanConfigValues
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const getMWASubProjectCases = isTest => {
|
|
171
|
+
const cases = make(MWASubProjectValueMap, {
|
|
172
|
+
length: Object.keys(MWASubProjectValueMap).length,
|
|
173
|
+
postFilter: row => {
|
|
174
|
+
if (row.needModifyMWAConfig === BooleanConfig.NO && (row.disableStateManagement !== BooleanConfig.NO || row.clientRoute !== ClientRoute.SelfControlRoute || row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
182
|
+
packageName: Object.values(item).join('-'),
|
|
183
|
+
packagePath: Object.values(item).join('-'),
|
|
184
|
+
solution: isTest ? SubSolution.MWATest : SubSolution.MWA
|
|
185
|
+
}));
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const getModuleSubProjectCases = isInner => {
|
|
189
|
+
const cases = make(ModuleSubProjectValueMap, {
|
|
190
|
+
length: Object.keys(ModuleSubProjectValueMap).length,
|
|
191
|
+
postFilter: row => {
|
|
192
|
+
if (row.needModifyModuleConfig === BooleanConfig.NO && (row.enableLess !== BooleanConfig.NO || row.enableSass !== BooleanConfig.NO)) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
200
|
+
packageName: Object.values(item).join('-'),
|
|
201
|
+
packagePath: Object.values(item).join('-'),
|
|
202
|
+
solution: isInner ? SubSolution.InnerModule : SubSolution.Module
|
|
203
|
+
}));
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export const getMonorepoNewCases = () => {
|
|
207
|
+
const cases = [...getMWASubProjectCases(false), ...getMWASubProjectCases(true), ...getModuleSubProjectCases(false), ...getModuleSubProjectCases(true)];
|
|
208
|
+
return cases;
|
|
209
|
+
};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMonorepoNewCases = exports.getMonorepoCases = exports.getModuleNewCases = exports.getModuleCases = exports.getMWANewCases = exports.getMWACases = exports.RunWayValues = exports.PackageManagerValues = exports.MonorepoValueMap = exports.ModuleValueMap = exports.ModuleSubProjectValueMap = exports.MWAValueMap = exports.MWASubProjectValueMap = exports.MWAServerValueMap = exports.MWAEntryValueMap = exports.MWABFFValueMap = exports.LanguageValues = exports.FrameworkValues = exports.ClientRouteValues = exports.BooleanConfigValues = exports.BFFTypeValues = void 0;
|
|
7
|
+
|
|
8
|
+
var _covertable = _interopRequireDefault(require("covertable"));
|
|
9
|
+
|
|
10
|
+
var _generatorCommon = require("@modern-js/generator-common");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
const LanguageValues = Object.values(_generatorCommon.Language);
|
|
21
|
+
exports.LanguageValues = LanguageValues;
|
|
22
|
+
const PackageManagerValues = Object.values(_generatorCommon.PackageManager);
|
|
23
|
+
exports.PackageManagerValues = PackageManagerValues;
|
|
24
|
+
const RunWayValues = Object.values(_generatorCommon.RunWay);
|
|
25
|
+
exports.RunWayValues = RunWayValues;
|
|
26
|
+
const BooleanConfigValues = Object.values(_generatorCommon.BooleanConfig);
|
|
27
|
+
exports.BooleanConfigValues = BooleanConfigValues;
|
|
28
|
+
const ClientRouteValues = Object.values(_generatorCommon.ClientRoute);
|
|
29
|
+
exports.ClientRouteValues = ClientRouteValues;
|
|
30
|
+
const FrameworkValues = Object.values(_generatorCommon.Framework);
|
|
31
|
+
exports.FrameworkValues = FrameworkValues;
|
|
32
|
+
const BFFTypeValues = Object.values(_generatorCommon.BFFType);
|
|
33
|
+
exports.BFFTypeValues = BFFTypeValues;
|
|
34
|
+
const MWAValueMap = {
|
|
35
|
+
language: LanguageValues,
|
|
36
|
+
packageManager: PackageManagerValues,
|
|
37
|
+
runWay: RunWayValues,
|
|
38
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
39
|
+
clientRoute: ClientRouteValues,
|
|
40
|
+
disableStateManagement: BooleanConfigValues,
|
|
41
|
+
enableLess: BooleanConfigValues,
|
|
42
|
+
enableSass: BooleanConfigValues
|
|
43
|
+
};
|
|
44
|
+
exports.MWAValueMap = MWAValueMap;
|
|
45
|
+
const ModuleValueMap = {
|
|
46
|
+
language: LanguageValues,
|
|
47
|
+
packageManager: PackageManagerValues,
|
|
48
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
49
|
+
enableLess: BooleanConfigValues,
|
|
50
|
+
enableSass: BooleanConfigValues
|
|
51
|
+
};
|
|
52
|
+
exports.ModuleValueMap = ModuleValueMap;
|
|
53
|
+
const MonorepoValueMap = {
|
|
54
|
+
packageManager: PackageManagerValues
|
|
55
|
+
};
|
|
56
|
+
exports.MonorepoValueMap = MonorepoValueMap;
|
|
57
|
+
|
|
58
|
+
const getMWACases = () => {
|
|
59
|
+
const cases = (0, _covertable.default)(MWAValueMap, {
|
|
60
|
+
length: Object.keys(MWAValueMap).length,
|
|
61
|
+
postFilter: row => {
|
|
62
|
+
if (row.needModifyMWAConfig === _generatorCommon.BooleanConfig.NO && (row.disableStateManagement !== _generatorCommon.BooleanConfig.NO || row.clientRoute !== _generatorCommon.ClientRoute.SelfControlRoute || row.enableLess !== _generatorCommon.BooleanConfig.NO || row.enableSass !== _generatorCommon.BooleanConfig.NO)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
70
|
+
solution: _generatorCommon.Solution.MWA
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
exports.getMWACases = getMWACases;
|
|
75
|
+
|
|
76
|
+
const getModuleCases = () => {
|
|
77
|
+
const cases = (0, _covertable.default)(ModuleValueMap, {
|
|
78
|
+
length: Object.keys(ModuleValueMap).length,
|
|
79
|
+
postFilter: row => {
|
|
80
|
+
if (row.needModifyModuleConfig === _generatorCommon.BooleanConfig.NO && (row.enableLess !== _generatorCommon.BooleanConfig.NO || row.enableSass !== _generatorCommon.BooleanConfig.NO)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
88
|
+
solution: _generatorCommon.Solution.Module
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.getModuleCases = getModuleCases;
|
|
93
|
+
|
|
94
|
+
const getMonorepoCases = () => {
|
|
95
|
+
const cases = (0, _covertable.default)(MonorepoValueMap, {
|
|
96
|
+
length: Object.keys(MonorepoValueMap).length
|
|
97
|
+
});
|
|
98
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
99
|
+
solution: _generatorCommon.Solution.Monorepo
|
|
100
|
+
}));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
exports.getMonorepoCases = getMonorepoCases;
|
|
104
|
+
const MWAEntryValueMap = {
|
|
105
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
106
|
+
clientRoute: ClientRouteValues,
|
|
107
|
+
disableStateManagement: BooleanConfigValues
|
|
108
|
+
};
|
|
109
|
+
exports.MWAEntryValueMap = MWAEntryValueMap;
|
|
110
|
+
|
|
111
|
+
const getMWAEntryCases = () => {
|
|
112
|
+
const cases = (0, _covertable.default)(MWAEntryValueMap, {
|
|
113
|
+
length: Object.keys(MWAEntryValueMap).length
|
|
114
|
+
});
|
|
115
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
116
|
+
name: Object.values(item).join('-')
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const MWAServerValueMap = {
|
|
121
|
+
framework: FrameworkValues
|
|
122
|
+
};
|
|
123
|
+
exports.MWAServerValueMap = MWAServerValueMap;
|
|
124
|
+
|
|
125
|
+
const getMWAServerCases = () => (0, _covertable.default)(MWAServerValueMap, {
|
|
126
|
+
length: Object.keys(MWAServerValueMap).length
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const MWABFFValueMap = {
|
|
130
|
+
bffType: BFFTypeValues,
|
|
131
|
+
framework: FrameworkValues
|
|
132
|
+
};
|
|
133
|
+
exports.MWABFFValueMap = MWABFFValueMap;
|
|
134
|
+
|
|
135
|
+
const getMWABFFCases = () => (0, _covertable.default)(MWABFFValueMap, {
|
|
136
|
+
length: Object.keys(MWABFFValueMap).length
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const getMWANewCases = () => {
|
|
140
|
+
const cases = [];
|
|
141
|
+
|
|
142
|
+
_generatorCommon.MWAActionTypes.forEach(action => {
|
|
143
|
+
const config = {
|
|
144
|
+
actionType: action
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
_generatorCommon.MWAActionTypesMap[action].forEach(option => {
|
|
148
|
+
config[action] = option;
|
|
149
|
+
|
|
150
|
+
const currentConfig = _objectSpread(_objectSpread({}, config), {}, {
|
|
151
|
+
[action]: option
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
if (option === _generatorCommon.ActionElement.Entry) {
|
|
155
|
+
const entryCases = getMWAEntryCases();
|
|
156
|
+
entryCases.forEach(c => {
|
|
157
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), c));
|
|
158
|
+
});
|
|
159
|
+
} else if (option === _generatorCommon.ActionElement.Server) {
|
|
160
|
+
// server only can enable once
|
|
161
|
+
const serverCases = getMWAServerCases();
|
|
162
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), serverCases[Math.round(Math.random() * serverCases.length)]));
|
|
163
|
+
} else if (option === _generatorCommon.ActionFunction.BFF) {
|
|
164
|
+
// bff only can enable once
|
|
165
|
+
const bffCases = getMWABFFCases();
|
|
166
|
+
cases.push(_objectSpread(_objectSpread({}, currentConfig), bffCases[Math.round(Math.random() * bffCases.length)]));
|
|
167
|
+
} else {
|
|
168
|
+
cases.push(currentConfig);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return cases;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
exports.getMWANewCases = getMWANewCases;
|
|
177
|
+
|
|
178
|
+
const getModuleNewCases = () => {
|
|
179
|
+
const cases = [];
|
|
180
|
+
|
|
181
|
+
_generatorCommon.ModuleActionTypes.forEach(action => {
|
|
182
|
+
const config = {
|
|
183
|
+
actionType: action
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
_generatorCommon.ModuleActionTypesMap[action].forEach(option => {
|
|
187
|
+
const currentConfig = _objectSpread(_objectSpread({}, config), {}, {
|
|
188
|
+
[action]: option
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
cases.push(currentConfig);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return cases;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
exports.getModuleNewCases = getModuleNewCases;
|
|
199
|
+
const MWASubProjectValueMap = {
|
|
200
|
+
language: LanguageValues,
|
|
201
|
+
needModifyMWAConfig: BooleanConfigValues,
|
|
202
|
+
clientRoute: ClientRouteValues,
|
|
203
|
+
disableStateManagement: BooleanConfigValues,
|
|
204
|
+
enableLess: BooleanConfigValues,
|
|
205
|
+
enableSass: BooleanConfigValues
|
|
206
|
+
};
|
|
207
|
+
exports.MWASubProjectValueMap = MWASubProjectValueMap;
|
|
208
|
+
const ModuleSubProjectValueMap = {
|
|
209
|
+
language: LanguageValues,
|
|
210
|
+
needModifyModuleConfig: BooleanConfigValues,
|
|
211
|
+
enableLess: BooleanConfigValues,
|
|
212
|
+
enableSass: BooleanConfigValues
|
|
213
|
+
};
|
|
214
|
+
exports.ModuleSubProjectValueMap = ModuleSubProjectValueMap;
|
|
215
|
+
|
|
216
|
+
const getMWASubProjectCases = isTest => {
|
|
217
|
+
const cases = (0, _covertable.default)(MWASubProjectValueMap, {
|
|
218
|
+
length: Object.keys(MWASubProjectValueMap).length,
|
|
219
|
+
postFilter: row => {
|
|
220
|
+
if (row.needModifyMWAConfig === _generatorCommon.BooleanConfig.NO && (row.disableStateManagement !== _generatorCommon.BooleanConfig.NO || row.clientRoute !== _generatorCommon.ClientRoute.SelfControlRoute || row.enableLess !== _generatorCommon.BooleanConfig.NO || row.enableSass !== _generatorCommon.BooleanConfig.NO)) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
228
|
+
packageName: Object.values(item).join('-'),
|
|
229
|
+
packagePath: Object.values(item).join('-'),
|
|
230
|
+
solution: isTest ? _generatorCommon.SubSolution.MWATest : _generatorCommon.SubSolution.MWA
|
|
231
|
+
}));
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const getModuleSubProjectCases = isInner => {
|
|
235
|
+
const cases = (0, _covertable.default)(ModuleSubProjectValueMap, {
|
|
236
|
+
length: Object.keys(ModuleSubProjectValueMap).length,
|
|
237
|
+
postFilter: row => {
|
|
238
|
+
if (row.needModifyModuleConfig === _generatorCommon.BooleanConfig.NO && (row.enableLess !== _generatorCommon.BooleanConfig.NO || row.enableSass !== _generatorCommon.BooleanConfig.NO)) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
return cases.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
246
|
+
packageName: Object.values(item).join('-'),
|
|
247
|
+
packagePath: Object.values(item).join('-'),
|
|
248
|
+
solution: isInner ? _generatorCommon.SubSolution.InnerModule : _generatorCommon.SubSolution.Module
|
|
249
|
+
}));
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
const getMonorepoNewCases = () => {
|
|
253
|
+
const cases = [...getMWASubProjectCases(false), ...getMWASubProjectCases(true), ...getModuleSubProjectCases(false), ...getModuleSubProjectCases(true)];
|
|
254
|
+
return cases;
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
exports.getMonorepoNewCases = getMonorepoNewCases;
|