@modern-js/utils 1.3.0 → 1.3.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 +22 -0
- package/dist/js/modern/constants.js +34 -6
- package/dist/js/modern/emptyDir.js +6 -0
- package/dist/js/modern/{formatWebpackMessages.js → format.js} +35 -1
- package/dist/js/modern/index.js +3 -2
- package/dist/js/modern/prettyInstructions.js +12 -3
- package/dist/js/modern/printBuildError.js +0 -1
- package/dist/js/node/constants.js +34 -6
- package/dist/js/node/emptyDir.js +18 -0
- package/dist/js/node/{formatWebpackMessages.js → format.js} +34 -1
- package/dist/js/node/index.js +18 -4
- package/dist/js/node/prettyInstructions.js +12 -3
- package/dist/js/node/printBuildError.js +0 -2
- package/dist/js/treeshaking/constants.js +34 -6
- package/dist/js/treeshaking/emptyDir.js +37 -0
- package/dist/js/treeshaking/{formatWebpackMessages.js → format.js} +43 -1
- package/dist/js/treeshaking/index.js +3 -2
- package/dist/js/treeshaking/prettyInstructions.js +13 -3
- package/dist/js/treeshaking/printBuildError.js +0 -1
- package/dist/types/constants.d.ts +29 -2
- package/dist/types/emptyDir.d.ts +1 -0
- package/dist/types/{formatWebpackMessages.d.ts → format.d.ts} +4 -1
- package/dist/types/index.d.ts +3 -2
- package/jest.config.js +4 -0
- package/package.json +9 -9
- package/tests/format.test.ts +60 -0
- package/tests/generateMetaTags.test.ts +19 -0
- package/tests/index.test.ts +2 -0
- package/tests/isType.test.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @modern-js/utils
|
|
2
2
|
|
|
3
|
+
## 1.3.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4c792f68: feat(plugin-garfish): Sub-applications automatically increment basename
|
|
8
|
+
feat(plugin-garfish): export common generate code function
|
|
9
|
+
fix(plugin-garfish): modify plugin-garfish schema config
|
|
10
|
+
- a7f42f48: new user config for plugin-unbundle
|
|
11
|
+
|
|
12
|
+
## 1.3.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- deeaa602: support svg/proxy/multi-version in unbundled
|
|
17
|
+
|
|
18
|
+
## 1.3.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 78279953: compiler entry bug fix and dev build console
|
|
23
|
+
- 4d72edea: support dev compiler by entry
|
|
24
|
+
|
|
3
25
|
## 1.3.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -151,6 +151,9 @@ export const INTERNAL_PLUGINS = {
|
|
|
151
151
|
},
|
|
152
152
|
'@modern-js/plugin-nocode': {
|
|
153
153
|
cli: '@modern-js/plugin-nocode/cli'
|
|
154
|
+
},
|
|
155
|
+
'@modern-js/plugin-design-token': {
|
|
156
|
+
cli: '@modern-js/plugin-design-token/cli'
|
|
154
157
|
}
|
|
155
158
|
};
|
|
156
159
|
/**
|
|
@@ -222,11 +225,6 @@ export const PLUGIN_SCHEMAS = {
|
|
|
222
225
|
schema: {
|
|
223
226
|
typeof: ['object', 'function']
|
|
224
227
|
}
|
|
225
|
-
}, {
|
|
226
|
-
target: 'source.designSystem',
|
|
227
|
-
schema: {
|
|
228
|
-
typeof: ['object']
|
|
229
|
-
}
|
|
230
228
|
}],
|
|
231
229
|
'@modern-js/plugin-proxy': [{
|
|
232
230
|
target: 'dev.proxy',
|
|
@@ -244,6 +242,19 @@ export const PLUGIN_SCHEMAS = {
|
|
|
244
242
|
schema: {
|
|
245
243
|
type: 'boolean'
|
|
246
244
|
}
|
|
245
|
+
}, {
|
|
246
|
+
target: 'dev.unbundle',
|
|
247
|
+
schema: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
ignore: {
|
|
251
|
+
type: ['string', 'array'],
|
|
252
|
+
items: {
|
|
253
|
+
type: 'string'
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
247
258
|
}],
|
|
248
259
|
'@modern-js/plugin-ssg': [{
|
|
249
260
|
target: 'output.ssg',
|
|
@@ -269,6 +280,18 @@ export const PLUGIN_SCHEMAS = {
|
|
|
269
280
|
type: ['boolean', 'object']
|
|
270
281
|
}
|
|
271
282
|
}],
|
|
283
|
+
'@modern-js/plugin-design-token': [// Legacy Features
|
|
284
|
+
{
|
|
285
|
+
target: 'source.designSystem',
|
|
286
|
+
schema: {
|
|
287
|
+
typeof: ['object']
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
target: 'source.designSystem.supportStyledComponents',
|
|
291
|
+
schema: {
|
|
292
|
+
type: ['boolean']
|
|
293
|
+
}
|
|
294
|
+
}],
|
|
272
295
|
'@modern-js/plugin-router': [{
|
|
273
296
|
target: 'runtime.router',
|
|
274
297
|
schema: {
|
|
@@ -289,13 +312,18 @@ export const PLUGIN_SCHEMAS = {
|
|
|
289
312
|
'@modern-js/plugin-garfish': [{
|
|
290
313
|
target: 'runtime.masterApp',
|
|
291
314
|
schema: {
|
|
292
|
-
type: ['object']
|
|
315
|
+
type: ['boolean', 'object']
|
|
293
316
|
}
|
|
294
317
|
}, {
|
|
295
318
|
target: 'dev.withMasterApp',
|
|
296
319
|
schema: {
|
|
297
320
|
type: ['object']
|
|
298
321
|
}
|
|
322
|
+
}, {
|
|
323
|
+
target: 'deploy.microFrontend',
|
|
324
|
+
schema: {
|
|
325
|
+
type: ['boolean', 'object']
|
|
326
|
+
}
|
|
299
327
|
}],
|
|
300
328
|
'@modern-js/plugin-nocode': []
|
|
301
329
|
};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : 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
|
+
|
|
1
7
|
/* eslint-disable no-param-reassign */
|
|
2
8
|
|
|
3
9
|
/* eslint-disable max-statements */
|
|
@@ -100,4 +106,32 @@ function formatWebpackMessages(json) {
|
|
|
100
106
|
export { formatWebpackMessages };
|
|
101
107
|
/* eslint-enable max-statements */
|
|
102
108
|
|
|
103
|
-
/* eslint-enable no-param-reassign */
|
|
109
|
+
/* eslint-enable no-param-reassign */
|
|
110
|
+
|
|
111
|
+
function formatProxyOptions(proxyOptions) {
|
|
112
|
+
const formatedProxy = [];
|
|
113
|
+
|
|
114
|
+
if (!Array.isArray(proxyOptions)) {
|
|
115
|
+
if ('target' in proxyOptions) {
|
|
116
|
+
formatedProxy.push(proxyOptions);
|
|
117
|
+
} else {
|
|
118
|
+
Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
|
119
|
+
const option = proxyOptions[source];
|
|
120
|
+
total.push(_objectSpread({
|
|
121
|
+
context: source,
|
|
122
|
+
changeOrigin: true,
|
|
123
|
+
logLevel: 'warn'
|
|
124
|
+
}, typeof option === 'string' ? {
|
|
125
|
+
target: option
|
|
126
|
+
} : option));
|
|
127
|
+
return total;
|
|
128
|
+
}, []));
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
formatedProxy.push(...proxyOptions);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return formatedProxy;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { formatProxyOptions };
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _fs from 'fs-extra';
|
|
2
2
|
export { _fs as fs };
|
|
3
3
|
export * from "./chalk";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./format";
|
|
5
5
|
export * from "./FileSizeReporter";
|
|
6
6
|
export * from "./printBuildError";
|
|
7
7
|
export * from "./debug";
|
|
@@ -30,4 +30,5 @@ export * from "./alias";
|
|
|
30
30
|
export * from "./import";
|
|
31
31
|
export * from "./watch";
|
|
32
32
|
export * from "./nodeEnv";
|
|
33
|
-
export * from "./wait";
|
|
33
|
+
export * from "./wait";
|
|
34
|
+
export * from "./emptyDir";
|
|
@@ -39,7 +39,8 @@ export const prettyInstructions = (appContext, config) => {
|
|
|
39
39
|
entrypoints,
|
|
40
40
|
serverRoutes,
|
|
41
41
|
port,
|
|
42
|
-
existSrc
|
|
42
|
+
existSrc,
|
|
43
|
+
checkedEntries
|
|
43
44
|
} = appContext;
|
|
44
45
|
const urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
|
45
46
|
const routes = existSrc ? serverRoutes.filter(route => route.entryName) : serverRoutes;
|
|
@@ -59,11 +60,19 @@ export const prettyInstructions = (appContext, config) => {
|
|
|
59
60
|
message += ` ${chalk.bold(`> ${type}`)}\n`;
|
|
60
61
|
routes.forEach(({
|
|
61
62
|
entryName,
|
|
62
|
-
urlPath
|
|
63
|
+
urlPath,
|
|
64
|
+
isSSR
|
|
63
65
|
}) => {
|
|
64
|
-
|
|
66
|
+
if (!checkedEntries.includes(entryName)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
message += ` ${chalk.yellowBright(isSSR ? 'λ' : '○')} ${chalk.yellowBright(entryName.padEnd(maxNameLength + 8))}${chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
|
|
65
71
|
});
|
|
66
72
|
});
|
|
73
|
+
message += '\n';
|
|
74
|
+
message += chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
|
|
75
|
+
message += chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
return message;
|
|
@@ -169,6 +169,9 @@ const INTERNAL_PLUGINS = {
|
|
|
169
169
|
},
|
|
170
170
|
'@modern-js/plugin-nocode': {
|
|
171
171
|
cli: '@modern-js/plugin-nocode/cli'
|
|
172
|
+
},
|
|
173
|
+
'@modern-js/plugin-design-token': {
|
|
174
|
+
cli: '@modern-js/plugin-design-token/cli'
|
|
172
175
|
}
|
|
173
176
|
};
|
|
174
177
|
/**
|
|
@@ -241,11 +244,6 @@ const PLUGIN_SCHEMAS = {
|
|
|
241
244
|
schema: {
|
|
242
245
|
typeof: ['object', 'function']
|
|
243
246
|
}
|
|
244
|
-
}, {
|
|
245
|
-
target: 'source.designSystem',
|
|
246
|
-
schema: {
|
|
247
|
-
typeof: ['object']
|
|
248
|
-
}
|
|
249
247
|
}],
|
|
250
248
|
'@modern-js/plugin-proxy': [{
|
|
251
249
|
target: 'dev.proxy',
|
|
@@ -263,6 +261,19 @@ const PLUGIN_SCHEMAS = {
|
|
|
263
261
|
schema: {
|
|
264
262
|
type: 'boolean'
|
|
265
263
|
}
|
|
264
|
+
}, {
|
|
265
|
+
target: 'dev.unbundle',
|
|
266
|
+
schema: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
ignore: {
|
|
270
|
+
type: ['string', 'array'],
|
|
271
|
+
items: {
|
|
272
|
+
type: 'string'
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
266
277
|
}],
|
|
267
278
|
'@modern-js/plugin-ssg': [{
|
|
268
279
|
target: 'output.ssg',
|
|
@@ -288,6 +299,18 @@ const PLUGIN_SCHEMAS = {
|
|
|
288
299
|
type: ['boolean', 'object']
|
|
289
300
|
}
|
|
290
301
|
}],
|
|
302
|
+
'@modern-js/plugin-design-token': [// Legacy Features
|
|
303
|
+
{
|
|
304
|
+
target: 'source.designSystem',
|
|
305
|
+
schema: {
|
|
306
|
+
typeof: ['object']
|
|
307
|
+
}
|
|
308
|
+
}, {
|
|
309
|
+
target: 'source.designSystem.supportStyledComponents',
|
|
310
|
+
schema: {
|
|
311
|
+
type: ['boolean']
|
|
312
|
+
}
|
|
313
|
+
}],
|
|
291
314
|
'@modern-js/plugin-router': [{
|
|
292
315
|
target: 'runtime.router',
|
|
293
316
|
schema: {
|
|
@@ -308,13 +331,18 @@ const PLUGIN_SCHEMAS = {
|
|
|
308
331
|
'@modern-js/plugin-garfish': [{
|
|
309
332
|
target: 'runtime.masterApp',
|
|
310
333
|
schema: {
|
|
311
|
-
type: ['object']
|
|
334
|
+
type: ['boolean', 'object']
|
|
312
335
|
}
|
|
313
336
|
}, {
|
|
314
337
|
target: 'dev.withMasterApp',
|
|
315
338
|
schema: {
|
|
316
339
|
type: ['object']
|
|
317
340
|
}
|
|
341
|
+
}, {
|
|
342
|
+
target: 'deploy.microFrontend',
|
|
343
|
+
schema: {
|
|
344
|
+
type: ['boolean', 'object']
|
|
345
|
+
}
|
|
318
346
|
}],
|
|
319
347
|
'@modern-js/plugin-nocode': []
|
|
320
348
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.emptyDir = void 0;
|
|
7
|
+
|
|
8
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const emptyDir = async dir => {
|
|
13
|
+
if (await _fsExtra.default.pathExists(dir)) {
|
|
14
|
+
await _fsExtra.default.emptyDir(dir);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.emptyDir = emptyDir;
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.formatProxyOptions = formatProxyOptions;
|
|
6
7
|
exports.formatWebpackMessages = formatWebpackMessages;
|
|
7
8
|
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
8
15
|
/* eslint-disable no-param-reassign */
|
|
9
16
|
|
|
10
17
|
/* eslint-disable max-statements */
|
|
@@ -103,6 +110,32 @@ function formatWebpackMessages(json) {
|
|
|
103
110
|
|
|
104
111
|
return result;
|
|
105
112
|
}
|
|
113
|
+
|
|
106
114
|
/* eslint-enable max-statements */
|
|
107
115
|
|
|
108
|
-
/* eslint-enable no-param-reassign */
|
|
116
|
+
/* eslint-enable no-param-reassign */
|
|
117
|
+
function formatProxyOptions(proxyOptions) {
|
|
118
|
+
const formatedProxy = [];
|
|
119
|
+
|
|
120
|
+
if (!Array.isArray(proxyOptions)) {
|
|
121
|
+
if ('target' in proxyOptions) {
|
|
122
|
+
formatedProxy.push(proxyOptions);
|
|
123
|
+
} else {
|
|
124
|
+
Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce((total, source) => {
|
|
125
|
+
const option = proxyOptions[source];
|
|
126
|
+
total.push(_objectSpread({
|
|
127
|
+
context: source,
|
|
128
|
+
changeOrigin: true,
|
|
129
|
+
logLevel: 'warn'
|
|
130
|
+
}, typeof option === 'string' ? {
|
|
131
|
+
target: option
|
|
132
|
+
} : option));
|
|
133
|
+
return total;
|
|
134
|
+
}, []));
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
formatedProxy.push(...proxyOptions);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return formatedProxy;
|
|
141
|
+
}
|
package/dist/js/node/index.js
CHANGED
|
@@ -26,16 +26,16 @@ Object.keys(_chalk).forEach(function (key) {
|
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _format = require("./format");
|
|
30
30
|
|
|
31
|
-
Object.keys(
|
|
31
|
+
Object.keys(_format).forEach(function (key) {
|
|
32
32
|
if (key === "default" || key === "__esModule") return;
|
|
33
33
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
34
|
-
if (key in exports && exports[key] ===
|
|
34
|
+
if (key in exports && exports[key] === _format[key]) return;
|
|
35
35
|
Object.defineProperty(exports, key, {
|
|
36
36
|
enumerable: true,
|
|
37
37
|
get: function () {
|
|
38
|
-
return
|
|
38
|
+
return _format[key];
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
});
|
|
@@ -446,6 +446,20 @@ Object.keys(_wait).forEach(function (key) {
|
|
|
446
446
|
});
|
|
447
447
|
});
|
|
448
448
|
|
|
449
|
+
var _emptyDir = require("./emptyDir");
|
|
450
|
+
|
|
451
|
+
Object.keys(_emptyDir).forEach(function (key) {
|
|
452
|
+
if (key === "default" || key === "__esModule") return;
|
|
453
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
454
|
+
if (key in exports && exports[key] === _emptyDir[key]) return;
|
|
455
|
+
Object.defineProperty(exports, key, {
|
|
456
|
+
enumerable: true,
|
|
457
|
+
get: function () {
|
|
458
|
+
return _emptyDir[key];
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
});
|
|
462
|
+
|
|
449
463
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
450
464
|
|
|
451
465
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -53,7 +53,8 @@ const prettyInstructions = (appContext, config) => {
|
|
|
53
53
|
entrypoints,
|
|
54
54
|
serverRoutes,
|
|
55
55
|
port,
|
|
56
|
-
existSrc
|
|
56
|
+
existSrc,
|
|
57
|
+
checkedEntries
|
|
57
58
|
} = appContext;
|
|
58
59
|
const urls = getAddressUrls(config.dev.https && (0, _is.isDev)() ? 'https' : 'http', port);
|
|
59
60
|
const routes = existSrc ? serverRoutes.filter(route => route.entryName) : serverRoutes;
|
|
@@ -73,11 +74,19 @@ const prettyInstructions = (appContext, config) => {
|
|
|
73
74
|
message += ` ${_chalk.default.bold(`> ${type}`)}\n`;
|
|
74
75
|
routes.forEach(({
|
|
75
76
|
entryName,
|
|
76
|
-
urlPath
|
|
77
|
+
urlPath,
|
|
78
|
+
isSSR
|
|
77
79
|
}) => {
|
|
78
|
-
|
|
80
|
+
if (!checkedEntries.includes(entryName)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
message += ` ${_chalk.default.yellowBright(isSSR ? 'λ' : '○')} ${_chalk.default.yellowBright(entryName.padEnd(maxNameLength + 8))}${_chalk.default.cyanBright(normalizeUrl(`${url}/${urlPath}`))}\n`;
|
|
79
85
|
});
|
|
80
86
|
});
|
|
87
|
+
message += '\n';
|
|
88
|
+
message += _chalk.default.cyanBright(' λ (Server) server-side renders at runtime\n');
|
|
89
|
+
message += _chalk.default.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
|
81
90
|
}
|
|
82
91
|
|
|
83
92
|
return message;
|
|
@@ -153,6 +153,9 @@ export var INTERNAL_PLUGINS = {
|
|
|
153
153
|
},
|
|
154
154
|
'@modern-js/plugin-nocode': {
|
|
155
155
|
cli: '@modern-js/plugin-nocode/cli'
|
|
156
|
+
},
|
|
157
|
+
'@modern-js/plugin-design-token': {
|
|
158
|
+
cli: '@modern-js/plugin-design-token/cli'
|
|
156
159
|
}
|
|
157
160
|
};
|
|
158
161
|
/**
|
|
@@ -222,11 +225,6 @@ export var PLUGIN_SCHEMAS = {
|
|
|
222
225
|
schema: {
|
|
223
226
|
"typeof": ['object', 'function']
|
|
224
227
|
}
|
|
225
|
-
}, {
|
|
226
|
-
target: 'source.designSystem',
|
|
227
|
-
schema: {
|
|
228
|
-
"typeof": ['object']
|
|
229
|
-
}
|
|
230
228
|
}],
|
|
231
229
|
'@modern-js/plugin-proxy': [{
|
|
232
230
|
target: 'dev.proxy',
|
|
@@ -244,6 +242,19 @@ export var PLUGIN_SCHEMAS = {
|
|
|
244
242
|
schema: {
|
|
245
243
|
type: 'boolean'
|
|
246
244
|
}
|
|
245
|
+
}, {
|
|
246
|
+
target: 'dev.unbundle',
|
|
247
|
+
schema: {
|
|
248
|
+
type: 'object',
|
|
249
|
+
properties: {
|
|
250
|
+
ignore: {
|
|
251
|
+
type: ['string', 'array'],
|
|
252
|
+
items: {
|
|
253
|
+
type: 'string'
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
247
258
|
}],
|
|
248
259
|
'@modern-js/plugin-ssg': [{
|
|
249
260
|
target: 'output.ssg',
|
|
@@ -269,6 +280,18 @@ export var PLUGIN_SCHEMAS = {
|
|
|
269
280
|
type: ['boolean', 'object']
|
|
270
281
|
}
|
|
271
282
|
}],
|
|
283
|
+
'@modern-js/plugin-design-token': [// Legacy Features
|
|
284
|
+
{
|
|
285
|
+
target: 'source.designSystem',
|
|
286
|
+
schema: {
|
|
287
|
+
"typeof": ['object']
|
|
288
|
+
}
|
|
289
|
+
}, {
|
|
290
|
+
target: 'source.designSystem.supportStyledComponents',
|
|
291
|
+
schema: {
|
|
292
|
+
type: ['boolean']
|
|
293
|
+
}
|
|
294
|
+
}],
|
|
272
295
|
'@modern-js/plugin-router': [{
|
|
273
296
|
target: 'runtime.router',
|
|
274
297
|
schema: {
|
|
@@ -289,13 +312,18 @@ export var PLUGIN_SCHEMAS = {
|
|
|
289
312
|
'@modern-js/plugin-garfish': [{
|
|
290
313
|
target: 'runtime.masterApp',
|
|
291
314
|
schema: {
|
|
292
|
-
type: ['object']
|
|
315
|
+
type: ['boolean', 'object']
|
|
293
316
|
}
|
|
294
317
|
}, {
|
|
295
318
|
target: 'dev.withMasterApp',
|
|
296
319
|
schema: {
|
|
297
320
|
type: ['object']
|
|
298
321
|
}
|
|
322
|
+
}, {
|
|
323
|
+
target: 'deploy.microFrontend',
|
|
324
|
+
schema: {
|
|
325
|
+
type: ['boolean', 'object']
|
|
326
|
+
}
|
|
299
327
|
}],
|
|
300
328
|
'@modern-js/plugin-nocode': []
|
|
301
329
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
export var emptyDir = /*#__PURE__*/function () {
|
|
9
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(dir) {
|
|
10
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
11
|
+
while (1) {
|
|
12
|
+
switch (_context.prev = _context.next) {
|
|
13
|
+
case 0:
|
|
14
|
+
_context.next = 2;
|
|
15
|
+
return fs.pathExists(dir);
|
|
16
|
+
|
|
17
|
+
case 2:
|
|
18
|
+
if (!_context.sent) {
|
|
19
|
+
_context.next = 5;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_context.next = 5;
|
|
24
|
+
return fs.emptyDir(dir);
|
|
25
|
+
|
|
26
|
+
case 5:
|
|
27
|
+
case "end":
|
|
28
|
+
return _context.stop();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, _callee);
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
return function emptyDir(_x) {
|
|
35
|
+
return _ref.apply(this, arguments);
|
|
36
|
+
};
|
|
37
|
+
}();
|
|
@@ -1,3 +1,17 @@
|
|
|
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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
+
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
|
|
13
|
+
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; }
|
|
14
|
+
|
|
1
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
16
|
|
|
3
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -122,4 +136,32 @@ function formatWebpackMessages(json) {
|
|
|
122
136
|
export { formatWebpackMessages };
|
|
123
137
|
/* eslint-enable max-statements */
|
|
124
138
|
|
|
125
|
-
/* eslint-enable no-param-reassign */
|
|
139
|
+
/* eslint-enable no-param-reassign */
|
|
140
|
+
|
|
141
|
+
function formatProxyOptions(proxyOptions) {
|
|
142
|
+
var formatedProxy = [];
|
|
143
|
+
|
|
144
|
+
if (!Array.isArray(proxyOptions)) {
|
|
145
|
+
if ('target' in proxyOptions) {
|
|
146
|
+
formatedProxy.push(proxyOptions);
|
|
147
|
+
} else {
|
|
148
|
+
Array.prototype.push.apply(formatedProxy, Object.keys(proxyOptions).reduce(function (total, source) {
|
|
149
|
+
var option = proxyOptions[source];
|
|
150
|
+
total.push(_objectSpread({
|
|
151
|
+
context: source,
|
|
152
|
+
changeOrigin: true,
|
|
153
|
+
logLevel: 'warn'
|
|
154
|
+
}, typeof option === 'string' ? {
|
|
155
|
+
target: option
|
|
156
|
+
} : option));
|
|
157
|
+
return total;
|
|
158
|
+
}, []));
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
formatedProxy.push.apply(formatedProxy, _toConsumableArray(proxyOptions));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return formatedProxy;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { formatProxyOptions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _fs from 'fs-extra';
|
|
2
2
|
export { _fs as fs };
|
|
3
3
|
export * from "./chalk";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./format";
|
|
5
5
|
export * from "./FileSizeReporter";
|
|
6
6
|
export * from "./printBuildError";
|
|
7
7
|
export * from "./debug";
|
|
@@ -30,4 +30,5 @@ export * from "./alias";
|
|
|
30
30
|
export * from "./import";
|
|
31
31
|
export * from "./watch";
|
|
32
32
|
export * from "./nodeEnv";
|
|
33
|
-
export * from "./wait";
|
|
33
|
+
export * from "./wait";
|
|
34
|
+
export * from "./emptyDir";
|
|
@@ -57,7 +57,8 @@ export var prettyInstructions = function prettyInstructions(appContext, config)
|
|
|
57
57
|
entrypoints = _ref.entrypoints,
|
|
58
58
|
serverRoutes = _ref.serverRoutes,
|
|
59
59
|
port = _ref.port,
|
|
60
|
-
existSrc = _ref.existSrc
|
|
60
|
+
existSrc = _ref.existSrc,
|
|
61
|
+
checkedEntries = _ref.checkedEntries;
|
|
61
62
|
var urls = getAddressUrls(config.dev.https && isDev() ? 'https' : 'http', port);
|
|
62
63
|
var routes = existSrc ? serverRoutes.filter(function (route) {
|
|
63
64
|
return route.entryName;
|
|
@@ -80,10 +81,19 @@ export var prettyInstructions = function prettyInstructions(appContext, config)
|
|
|
80
81
|
message += " ".concat(chalk.bold("> ".concat(type)), "\n");
|
|
81
82
|
routes.forEach(function (_ref4) {
|
|
82
83
|
var entryName = _ref4.entryName,
|
|
83
|
-
urlPath = _ref4.urlPath
|
|
84
|
-
|
|
84
|
+
urlPath = _ref4.urlPath,
|
|
85
|
+
isSSR = _ref4.isSSR;
|
|
86
|
+
|
|
87
|
+
if (!checkedEntries.includes(entryName)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
message += " ".concat(chalk.yellowBright(isSSR ? 'λ' : '○'), " ").concat(chalk.yellowBright(entryName.padEnd(maxNameLength + 8))).concat(chalk.cyanBright(normalizeUrl("".concat(url, "/").concat(urlPath))), "\n");
|
|
85
92
|
});
|
|
86
93
|
});
|
|
94
|
+
message += '\n';
|
|
95
|
+
message += chalk.cyanBright(' λ (Server) server-side renders at runtime\n');
|
|
96
|
+
message += chalk.cyanBright(' ○ (Static) client-side rendered as static HTML\n');
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
return message;
|
|
@@ -131,12 +131,26 @@ export declare const PLUGIN_SCHEMAS: {
|
|
|
131
131
|
typeof: string[];
|
|
132
132
|
};
|
|
133
133
|
}[];
|
|
134
|
-
'@modern-js/plugin-unbundle': {
|
|
134
|
+
'@modern-js/plugin-unbundle': ({
|
|
135
135
|
target: string;
|
|
136
136
|
schema: {
|
|
137
137
|
type: string;
|
|
138
|
+
properties?: undefined;
|
|
138
139
|
};
|
|
139
|
-
}
|
|
140
|
+
} | {
|
|
141
|
+
target: string;
|
|
142
|
+
schema: {
|
|
143
|
+
type: string;
|
|
144
|
+
properties: {
|
|
145
|
+
ignore: {
|
|
146
|
+
type: string[];
|
|
147
|
+
items: {
|
|
148
|
+
type: string;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
})[];
|
|
140
154
|
'@modern-js/plugin-ssg': {
|
|
141
155
|
target: string;
|
|
142
156
|
schema: {
|
|
@@ -161,6 +175,19 @@ export declare const PLUGIN_SCHEMAS: {
|
|
|
161
175
|
type: string[];
|
|
162
176
|
};
|
|
163
177
|
}[];
|
|
178
|
+
'@modern-js/plugin-design-token': ({
|
|
179
|
+
target: string;
|
|
180
|
+
schema: {
|
|
181
|
+
typeof: string[];
|
|
182
|
+
type?: undefined;
|
|
183
|
+
};
|
|
184
|
+
} | {
|
|
185
|
+
target: string;
|
|
186
|
+
schema: {
|
|
187
|
+
type: string[];
|
|
188
|
+
typeof?: undefined;
|
|
189
|
+
};
|
|
190
|
+
})[];
|
|
164
191
|
'@modern-js/plugin-router': {
|
|
165
192
|
target: string;
|
|
166
193
|
schema: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const emptyDir: (dir: string) => Promise<void>;
|
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
|
7
7
|
*/
|
|
8
8
|
import { StatsCompilation } from 'webpack';
|
|
9
|
+
import { ProxyDetail, ProxyOptions } from '@modern-js/types';
|
|
9
10
|
declare function formatWebpackMessages(json: StatsCompilation): {
|
|
10
11
|
errors: string[];
|
|
11
12
|
warnings: string[];
|
|
12
13
|
};
|
|
13
|
-
export { formatWebpackMessages };
|
|
14
|
+
export { formatWebpackMessages };
|
|
15
|
+
declare function formatProxyOptions(proxyOptions: ProxyOptions): ProxyDetail[];
|
|
16
|
+
export { formatProxyOptions };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * as fs from 'fs-extra';
|
|
2
2
|
export * from './chalk';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './format';
|
|
4
4
|
export * from './FileSizeReporter';
|
|
5
5
|
export * from './printBuildError';
|
|
6
6
|
export * from './debug';
|
|
@@ -29,4 +29,5 @@ export * from './alias';
|
|
|
29
29
|
export * from './import';
|
|
30
30
|
export * from './watch';
|
|
31
31
|
export * from './nodeEnv';
|
|
32
|
-
export * from './wait';
|
|
32
|
+
export * from './wait';
|
|
33
|
+
export * from './emptyDir';
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.3.
|
|
14
|
+
"version": "1.3.3",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
},
|
|
27
27
|
"default": "./dist/js/treeshaking/index.js"
|
|
28
28
|
},
|
|
29
|
-
"./
|
|
30
|
-
"jsnext:source": "./src/
|
|
31
|
-
"default": "./dist/js/treeshaking/
|
|
29
|
+
"./format": {
|
|
30
|
+
"jsnext:source": "./src/format.ts",
|
|
31
|
+
"default": "./dist/js/treeshaking/format.js"
|
|
32
32
|
},
|
|
33
33
|
"./constants": {
|
|
34
34
|
"jsnext:source": "./src/constants.ts",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
},
|
|
38
38
|
"typesVersions": {
|
|
39
39
|
"*": {
|
|
40
|
-
"
|
|
41
|
-
"./dist/types/
|
|
40
|
+
"format": [
|
|
41
|
+
"./dist/types/format.d.ts"
|
|
42
42
|
],
|
|
43
43
|
"constants": [
|
|
44
44
|
"./dist/types/constants.d.ts"
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"webpack": "^5.54.0",
|
|
76
76
|
"@scripts/build": "0.0.0",
|
|
77
77
|
"jest": "^27",
|
|
78
|
-
"@scripts/jest-config": "0.0.0"
|
|
78
|
+
"@scripts/jest-config": "0.0.0",
|
|
79
|
+
"@modern-js/types": "^1.3.4"
|
|
79
80
|
},
|
|
80
81
|
"sideEffects": false,
|
|
81
82
|
"publishConfig": {
|
|
82
83
|
"registry": "https://registry.npmjs.org/",
|
|
83
|
-
"access": "public"
|
|
84
|
-
"types": "./dist/types/index.d.ts"
|
|
84
|
+
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"new": "modern new",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { formatProxyOptions } from '../src/format';
|
|
2
|
+
|
|
3
|
+
describe('test format', () => {
|
|
4
|
+
it('should format correctly use simply options', async () => {
|
|
5
|
+
const proxy = {
|
|
6
|
+
'/simple': `http://localhost`,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const options = formatProxyOptions(proxy);
|
|
10
|
+
expect(options).toEqual([
|
|
11
|
+
{
|
|
12
|
+
context: '/simple',
|
|
13
|
+
changeOrigin: true,
|
|
14
|
+
logLevel: 'warn',
|
|
15
|
+
target: 'http://localhost',
|
|
16
|
+
},
|
|
17
|
+
]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should format correctly use simply options', async () => {
|
|
21
|
+
const proxy = {
|
|
22
|
+
'/simple-obj': {
|
|
23
|
+
target: `http://localhost`,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const options = formatProxyOptions(proxy);
|
|
27
|
+
expect(options).toEqual([
|
|
28
|
+
{
|
|
29
|
+
context: '/simple-obj',
|
|
30
|
+
changeOrigin: true,
|
|
31
|
+
logLevel: 'warn',
|
|
32
|
+
target: 'http://localhost',
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should format correctly use simply options', async () => {
|
|
38
|
+
const proxy = {
|
|
39
|
+
context: '/context',
|
|
40
|
+
target: `http://localhost`,
|
|
41
|
+
};
|
|
42
|
+
const options = formatProxyOptions(proxy);
|
|
43
|
+
expect(options).toEqual([
|
|
44
|
+
{ context: '/context', target: 'http://localhost' },
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should format correctly use simply options', async () => {
|
|
49
|
+
const proxy = [
|
|
50
|
+
{
|
|
51
|
+
context: '/array',
|
|
52
|
+
target: `http://localhost`,
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
const options = formatProxyOptions(proxy);
|
|
56
|
+
expect(options).toEqual([
|
|
57
|
+
{ context: '/array', target: 'http://localhost' },
|
|
58
|
+
]);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { generateMetaTags } from '../src/generateMetaTags';
|
|
2
|
+
|
|
3
|
+
describe('generateMetaTags', () => {
|
|
4
|
+
it('should return empty string when params is empty', () => {
|
|
5
|
+
expect(generateMetaTags()).toEqual('');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('should generate meta tag correctly', () => {
|
|
9
|
+
const options = {
|
|
10
|
+
foo: {
|
|
11
|
+
name: 'viewport',
|
|
12
|
+
content: 'width=500, initial-scale=1',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
expect(generateMetaTags(options).trim()).toEqual(
|
|
16
|
+
'<meta name="viewport" content="width=500, initial-scale=1">',
|
|
17
|
+
);
|
|
18
|
+
});
|
|
19
|
+
});
|
package/tests/index.test.ts
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { isString, isUndefined } from '../src/is/type';
|
|
2
|
+
|
|
3
|
+
describe('validate type', () => {
|
|
4
|
+
it('should validate string correctly', () => {
|
|
5
|
+
expect(isString('')).toBeTruthy();
|
|
6
|
+
expect(isString('foo')).toBeTruthy();
|
|
7
|
+
expect(isString(null)).toBeFalsy();
|
|
8
|
+
expect(isString(123)).toBeFalsy();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should validate undeinfed correctly', () => {
|
|
12
|
+
expect(isUndefined(undefined)).toBeTruthy();
|
|
13
|
+
expect(isUndefined(null)).toBeFalsy();
|
|
14
|
+
expect(isUndefined('')).toBeFalsy();
|
|
15
|
+
expect(isUndefined(123)).toBeFalsy();
|
|
16
|
+
});
|
|
17
|
+
});
|