@modern-js/utils 1.3.7 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +9 -0
- package/CHANGELOG.md +31 -0
- package/compiled/browserslist/index.d.ts +178 -0
- package/compiled/browserslist/index.js +1 -0
- package/compiled/browserslist/license +20 -0
- package/compiled/browserslist/package.json +1 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/license +9 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/chokidar/anymatch/index.d.ts +19 -0
- package/compiled/chokidar/fsevents.node +0 -0
- package/compiled/chokidar/index.js +40 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/chokidar/types/index.d.ts +188 -0
- package/compiled/commander/index.js +1 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/commander/typings/index.d.ts +774 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/license +20 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/license +9 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/filesize/filesize.d.ts +131 -0
- package/compiled/filesize/index.js +9 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/compiled/fs-extra/index.d.ts +563 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/license +15 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/index.d.ts +91 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/license +21 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/gzip-size/index.d.ts +96 -0
- package/compiled/gzip-size/index.js +1 -0
- package/compiled/gzip-size/license +9 -0
- package/compiled/gzip-size/package.json +1 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/license +9 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/js-yaml/index.d.ts +154 -0
- package/compiled/js-yaml/index.js +1 -0
- package/compiled/js-yaml/license +21 -0
- package/compiled/js-yaml/package.json +1 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1446 -0
- package/compiled/lodash/common/lang.d.ts +1693 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1220 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/license +47 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/license +9 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/recursive-readdir/index.d.ts +21 -0
- package/compiled/recursive-readdir/index.js +1 -0
- package/compiled/recursive-readdir/license +21 -0
- package/compiled/recursive-readdir/package.json +1 -0
- package/compiled/signale/index.d.ts +162 -0
- package/compiled/signale/index.js +1 -0
- package/compiled/signale/package.json +1 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/license +9 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/upath/index.js +1 -0
- package/compiled/upath/license +22 -0
- package/compiled/upath/package.json +1 -0
- package/compiled/upath/upath.d.ts +241 -0
- package/dist/{types/FileSizeReporter.d.ts → FileSizeReporter.d.ts} +5 -5
- package/dist/FileSizeReporter.js +151 -0
- package/dist/{types/alias.d.ts → alias.d.ts} +12 -14
- package/dist/alias.js +62 -0
- package/dist/analyzeProject.d.ts +1 -0
- package/dist/analyzeProject.js +44 -0
- package/dist/applyOptionsChain.d.ts +6 -0
- package/dist/applyOptionsChain.js +30 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +9 -0
- package/dist/{types/compatRequire.d.ts → compatRequire.d.ts} +1 -1
- package/dist/compatRequire.js +28 -0
- package/dist/compiled.d.ts +21 -0
- package/dist/compiled.js +33 -0
- package/dist/constants.d.ts +222 -0
- package/dist/constants.js +277 -0
- package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
- package/dist/debug.js +11 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +19 -0
- package/dist/{types/ensureAbsolutePath.d.ts → ensureAbsolutePath.d.ts} +1 -1
- package/dist/ensureAbsolutePath.js +15 -0
- package/dist/{types/findExists.d.ts → findExists.d.ts} +1 -1
- package/dist/findExists.js +21 -0
- package/dist/{types/format.d.ts → format.d.ts} +3 -3
- package/dist/format.js +113 -0
- package/dist/{types/generateMetaTags.d.ts → generateMetaTags.d.ts} +3 -3
- package/dist/generateMetaTags.js +48 -0
- package/dist/{types/getBrowserslist.d.ts → getBrowserslist.d.ts} +1 -1
- package/dist/getBrowserslist.js +7 -0
- package/dist/{types/getCacheIdentifier.d.ts → getCacheIdentifier.d.ts} +3 -3
- package/dist/getCacheIdentifier.js +24 -0
- package/dist/{types/getEntryOptions.d.ts → getEntryOptions.d.ts} +1 -1
- package/dist/getEntryOptions.js +26 -0
- package/dist/{types/getPackageManager.d.ts → getPackageManager.d.ts} +1 -1
- package/dist/getPackageManager.js +47 -0
- package/dist/{types/getPort.d.ts → getPort.d.ts} +1 -1
- package/dist/getPort.js +62 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +39 -0
- package/dist/{types/import.d.ts → import.d.ts} +2 -2
- package/dist/import.js +10 -0
- package/dist/{types/index.d.ts → index.d.ts} +5 -4
- package/dist/index.js +46 -0
- package/dist/{types/is → is}/index.d.ts +1 -4
- package/dist/is/index.js +82 -0
- package/dist/{types/is → is}/node-env.d.ts +1 -1
- package/dist/is/node-env.js +12 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +10 -0
- package/dist/{types/is → is}/type.d.ts +1 -1
- package/dist/is/type.js +38 -0
- package/dist/logger.d.ts +63 -0
- package/dist/logger.js +128 -0
- package/dist/{types/monorepo.d.ts → monorepo.d.ts} +3 -3
- package/dist/monorepo.js +80 -0
- package/dist/{types/nodeEnv.d.ts → nodeEnv.d.ts} +1 -1
- package/dist/nodeEnv.js +49 -0
- package/dist/{types/path.d.ts → path.d.ts} +1 -1
- package/dist/path.js +14 -0
- package/dist/{types/prettyInstructions.d.ts → prettyInstructions.d.ts} +2 -2
- package/dist/prettyInstructions.js +64 -0
- package/dist/{types/printBuildError.d.ts → printBuildError.d.ts} +1 -1
- package/dist/printBuildError.js +43 -0
- package/dist/{types/readTsConfig.d.ts → readTsConfig.d.ts} +1 -1
- package/dist/readTsConfig.js +19 -0
- package/dist/{types/removeSlash.d.ts → removeSlash.d.ts} +1 -1
- package/dist/removeSlash.js +9 -0
- package/dist/{types/runtimeExports.d.ts → runtimeExports.d.ts} +3 -3
- package/dist/runtimeExports.js +53 -0
- package/dist/ssrHelpers.d.ts +4 -0
- package/dist/ssrHelpers.js +7 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +61 -0
- package/dist/{types/wait.d.ts → wait.d.ts} +1 -1
- package/dist/wait.js +7 -0
- package/dist/{types/watch.d.ts → watch.d.ts} +4 -4
- package/dist/watch.js +64 -0
- package/package.json +55 -37
- package/tsconfig.json +3 -5
- package/dist/js/modern/FileSizeReporter.js +0 -156
- package/dist/js/modern/alias.js +0 -74
- package/dist/js/modern/applyOptionsChain.js +0 -27
- package/dist/js/modern/chalk.js +0 -2
- package/dist/js/modern/clearConsole.js +0 -5
- package/dist/js/modern/compatRequire.js +0 -26
- package/dist/js/modern/constants.js +0 -333
- package/dist/js/modern/emptyDir.js +0 -6
- package/dist/js/modern/ensureAbsolutePath.js +0 -9
- package/dist/js/modern/findExists.js +0 -16
- package/dist/js/modern/format.js +0 -137
- package/dist/js/modern/generateMetaTags.js +0 -49
- package/dist/js/modern/getBrowserslist.js +0 -5
- package/dist/js/modern/getCacheIdentifier.js +0 -20
- package/dist/js/modern/getEntryOptions.js +0 -24
- package/dist/js/modern/getPackageManager.js +0 -37
- package/dist/js/modern/getPort.js +0 -52
- package/dist/js/modern/import.js +0 -11
- package/dist/js/modern/index.js +0 -34
- package/dist/js/modern/is/index.js +0 -77
- package/dist/js/modern/is/node-env.js +0 -5
- package/dist/js/modern/is/platform.js +0 -2
- package/dist/js/modern/is/type.js +0 -25
- package/dist/js/modern/logger.js +0 -152
- package/dist/js/modern/monorepo.js +0 -84
- package/dist/js/modern/nodeEnv.js +0 -31
- package/dist/js/modern/path.js +0 -5
- package/dist/js/modern/pkgUp.js +0 -2
- package/dist/js/modern/prettyInstructions.js +0 -79
- package/dist/js/modern/printBuildError.js +0 -40
- package/dist/js/modern/readTsConfig.js +0 -13
- package/dist/js/modern/removeSlash.js +0 -3
- package/dist/js/modern/runtimeExports.js +0 -52
- package/dist/js/modern/wait.js +0 -5
- package/dist/js/modern/watch.js +0 -43
- package/dist/js/node/FileSizeReporter.js +0 -175
- package/dist/js/node/alias.js +0 -97
- package/dist/js/node/applyOptionsChain.js +0 -37
- package/dist/js/node/chalk.js +0 -15
- package/dist/js/node/clearConsole.js +0 -14
- package/dist/js/node/compatRequire.js +0 -41
- package/dist/js/node/constants.js +0 -353
- package/dist/js/node/debug.js +0 -19
- package/dist/js/node/emptyDir.js +0 -18
- package/dist/js/node/ensureAbsolutePath.js +0 -20
- package/dist/js/node/findExists.js +0 -27
- package/dist/js/node/format.js +0 -141
- package/dist/js/node/generateMetaTags.js +0 -58
- package/dist/js/node/getBrowserslist.js +0 -17
- package/dist/js/node/getCacheIdentifier.js +0 -27
- package/dist/js/node/getEntryOptions.js +0 -35
- package/dist/js/node/getPackageManager.js +0 -51
- package/dist/js/node/getPort.js +0 -67
- package/dist/js/node/import.js +0 -19
- package/dist/js/node/index.js +0 -465
- package/dist/js/node/is/index.js +0 -150
- package/dist/js/node/is/node-env.js +0 -23
- package/dist/js/node/is/platform.js +0 -14
- package/dist/js/node/is/type.js +0 -46
- package/dist/js/node/logger.js +0 -162
- package/dist/js/node/monorepo.js +0 -118
- package/dist/js/node/nodeEnv.js +0 -45
- package/dist/js/node/path.js +0 -24
- package/dist/js/node/pkgUp.js +0 -15
- package/dist/js/node/prettyInstructions.js +0 -95
- package/dist/js/node/printBuildError.js +0 -52
- package/dist/js/node/readTsConfig.js +0 -28
- package/dist/js/node/removeSlash.js +0 -18
- package/dist/js/node/runtimeExports.js +0 -68
- package/dist/js/node/wait.js +0 -12
- package/dist/js/node/watch.js +0 -61
- package/dist/js/treeshaking/FileSizeReporter.js +0 -185
- package/dist/js/treeshaking/alias.js +0 -72
- package/dist/js/treeshaking/applyOptionsChain.js +0 -31
- package/dist/js/treeshaking/chalk.js +0 -2
- package/dist/js/treeshaking/clearConsole.js +0 -5
- package/dist/js/treeshaking/compatRequire.js +0 -29
- package/dist/js/treeshaking/constants.js +0 -333
- package/dist/js/treeshaking/debug.js +0 -10
- package/dist/js/treeshaking/emptyDir.js +0 -37
- package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
- package/dist/js/treeshaking/findExists.js +0 -33
- package/dist/js/treeshaking/format.js +0 -167
- package/dist/js/treeshaking/generateMetaTags.js +0 -55
- package/dist/js/treeshaking/getBrowserslist.js +0 -7
- package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
- package/dist/js/treeshaking/getEntryOptions.js +0 -26
- package/dist/js/treeshaking/getPackageManager.js +0 -101
- package/dist/js/treeshaking/getPort.js +0 -103
- package/dist/js/treeshaking/import.js +0 -11
- package/dist/js/treeshaking/index.js +0 -34
- package/dist/js/treeshaking/is/index.js +0 -81
- package/dist/js/treeshaking/is/node-env.js +0 -13
- package/dist/js/treeshaking/is/platform.js +0 -6
- package/dist/js/treeshaking/is/type.js +0 -27
- package/dist/js/treeshaking/logger.js +0 -188
- package/dist/js/treeshaking/monorepo.js +0 -95
- package/dist/js/treeshaking/nodeEnv.js +0 -108
- package/dist/js/treeshaking/path.js +0 -11
- package/dist/js/treeshaking/pkgUp.js +0 -2
- package/dist/js/treeshaking/prettyInstructions.js +0 -100
- package/dist/js/treeshaking/printBuildError.js +0 -40
- package/dist/js/treeshaking/readTsConfig.js +0 -13
- package/dist/js/treeshaking/removeSlash.js +0 -9
- package/dist/js/treeshaking/runtimeExports.js +0 -61
- package/dist/js/treeshaking/wait.js +0 -8
- package/dist/js/treeshaking/watch.js +0 -112
- package/dist/types/applyOptionsChain.d.ts +0 -6
- package/dist/types/chalk.d.ts +0 -2
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/constants.d.ts +0 -219
- package/dist/types/debug.d.ts +0 -8
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/is/platform.d.ts +0 -2
- package/dist/types/logger.d.ts +0 -63
- package/dist/types/pkgUp.d.ts +0 -2
- package/tests/.eslintrc.js +0 -6
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
- package/tests/applyOptionsChain.test.ts +0 -100
- package/tests/compatRequire.test.ts +0 -32
- package/tests/debug.test.ts +0 -25
- package/tests/ensureAbsolutePath.test.ts +0 -16
- package/tests/findExists.test.ts +0 -22
- package/tests/fixtures/browserlist/develop/package.json +0 -11
- package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
- package/tests/fixtures/browserlist/pkg/package.json +0 -7
- package/tests/fixtures/compat-require/cjs.js +0 -1
- package/tests/fixtures/compat-require/empty.js +0 -1
- package/tests/fixtures/compat-require/esm.js +0 -5
- package/tests/fixtures/compat-require/foo.js +0 -3
- package/tests/fixtures/file-exists/a.ejs +0 -0
- package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
- package/tests/fixtures/file-exists/a.mjs +0 -0
- package/tests/fixtures/file-exists/a.ts +0 -0
- package/tests/format.test.ts +0 -60
- package/tests/generateMetaTags.test.ts +0 -19
- package/tests/getBrowserslist.test.ts +0 -32
- package/tests/getCacheIdentifier.test.ts +0 -37
- package/tests/getEntryOptions.test.ts +0 -53
- package/tests/index.test.ts +0 -18
- package/tests/is.test.ts +0 -27
- package/tests/isPlatform.test.ts +0 -19
- package/tests/isType.test.ts +0 -85
- package/tests/logger.test.ts +0 -53
- package/tests/prettyInstructions.test.ts +0 -139
- package/tests/removeSlash.test.ts +0 -19
- package/tests/tsconfig.json +0 -11
- package/tests/wait.ts +0 -38
package/dist/js/node/is/index.js
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
var _exportNames = {
|
7
|
-
isDepExists: true,
|
8
|
-
isTypescript: true,
|
9
|
-
isEmpty: true,
|
10
|
-
isSSR: true,
|
11
|
-
isUseSSRBundle: true,
|
12
|
-
isFastRefresh: true
|
13
|
-
};
|
14
|
-
exports.isUseSSRBundle = exports.isTypescript = exports.isSSR = exports.isFastRefresh = exports.isEmpty = exports.isDepExists = void 0;
|
15
|
-
|
16
|
-
var _fs = _interopRequireDefault(require("fs"));
|
17
|
-
|
18
|
-
var _path = _interopRequireDefault(require("path"));
|
19
|
-
|
20
|
-
var _nodeEnv = require("./node-env");
|
21
|
-
|
22
|
-
Object.keys(_nodeEnv).forEach(function (key) {
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
24
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
25
|
-
if (key in exports && exports[key] === _nodeEnv[key]) return;
|
26
|
-
Object.defineProperty(exports, key, {
|
27
|
-
enumerable: true,
|
28
|
-
get: function () {
|
29
|
-
return _nodeEnv[key];
|
30
|
-
}
|
31
|
-
});
|
32
|
-
});
|
33
|
-
|
34
|
-
var _platform = require("./platform");
|
35
|
-
|
36
|
-
Object.keys(_platform).forEach(function (key) {
|
37
|
-
if (key === "default" || key === "__esModule") return;
|
38
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
39
|
-
if (key in exports && exports[key] === _platform[key]) return;
|
40
|
-
Object.defineProperty(exports, key, {
|
41
|
-
enumerable: true,
|
42
|
-
get: function () {
|
43
|
-
return _platform[key];
|
44
|
-
}
|
45
|
-
});
|
46
|
-
});
|
47
|
-
|
48
|
-
var _type = require("./type");
|
49
|
-
|
50
|
-
Object.keys(_type).forEach(function (key) {
|
51
|
-
if (key === "default" || key === "__esModule") return;
|
52
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
53
|
-
if (key in exports && exports[key] === _type[key]) return;
|
54
|
-
Object.defineProperty(exports, key, {
|
55
|
-
enumerable: true,
|
56
|
-
get: function () {
|
57
|
-
return _type[key];
|
58
|
-
}
|
59
|
-
});
|
60
|
-
});
|
61
|
-
|
62
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Check if the package name is in dependencies or devDependencies.
|
66
|
-
*
|
67
|
-
* @param appDirectory - Project root directory.
|
68
|
-
* @param name - Package name.
|
69
|
-
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
70
|
-
*/
|
71
|
-
const isDepExists = (appDirectory, name) => {
|
72
|
-
const json = require(_path.default.resolve(appDirectory, './package.json'));
|
73
|
-
|
74
|
-
const {
|
75
|
-
dependencies = {},
|
76
|
-
devDependencies = {}
|
77
|
-
} = json;
|
78
|
-
return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
|
79
|
-
};
|
80
|
-
/**
|
81
|
-
* Is typescript project.
|
82
|
-
*
|
83
|
-
* @param root - App directory.
|
84
|
-
* @returns Whether to use typescript.
|
85
|
-
*/
|
86
|
-
|
87
|
-
|
88
|
-
exports.isDepExists = isDepExists;
|
89
|
-
|
90
|
-
const isTypescript = root => _fs.default.existsSync(_path.default.resolve(root, './tsconfig.json'));
|
91
|
-
/**
|
92
|
-
* Is Empty object
|
93
|
-
*
|
94
|
-
* @param o - Any object.
|
95
|
-
* @returns Whether it is empty object.
|
96
|
-
*/
|
97
|
-
|
98
|
-
|
99
|
-
exports.isTypescript = isTypescript;
|
100
|
-
|
101
|
-
const isEmpty = o => Object.entries(o).length === 0 && o.constructor === Object;
|
102
|
-
/**
|
103
|
-
* Is SSR project
|
104
|
-
*
|
105
|
-
* @param config - User config.
|
106
|
-
* @returns Whether to use server side render.
|
107
|
-
*/
|
108
|
-
|
109
|
-
|
110
|
-
exports.isEmpty = isEmpty;
|
111
|
-
|
112
|
-
const isSSR = config => {
|
113
|
-
const {
|
114
|
-
server
|
115
|
-
} = config;
|
116
|
-
|
117
|
-
if (server !== null && server !== void 0 && server.ssr) {
|
118
|
-
return true;
|
119
|
-
}
|
120
|
-
|
121
|
-
if (server !== null && server !== void 0 && server.ssrByEntries && !isEmpty(server.ssrByEntries)) {
|
122
|
-
for (const name of Object.keys(server.ssrByEntries)) {
|
123
|
-
if (server.ssrByEntries[name]) {
|
124
|
-
return true;
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
return false;
|
130
|
-
};
|
131
|
-
|
132
|
-
exports.isSSR = isSSR;
|
133
|
-
|
134
|
-
const isUseSSRBundle = config => {
|
135
|
-
const {
|
136
|
-
output
|
137
|
-
} = config;
|
138
|
-
|
139
|
-
if (output !== null && output !== void 0 && output.ssg) {
|
140
|
-
return true;
|
141
|
-
}
|
142
|
-
|
143
|
-
return isSSR(config);
|
144
|
-
};
|
145
|
-
|
146
|
-
exports.isUseSSRBundle = isUseSSRBundle;
|
147
|
-
|
148
|
-
const isFastRefresh = () => (0, _nodeEnv.isDev)() && process.env.FAST_REFRESH !== 'false';
|
149
|
-
|
150
|
-
exports.isFastRefresh = isFastRefresh;
|
@@ -1,23 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isTest = exports.isProdProfile = exports.isProd = exports.isDev = void 0;
|
7
|
-
|
8
|
-
const isDev = () => process.env.NODE_ENV === 'development';
|
9
|
-
|
10
|
-
exports.isDev = isDev;
|
11
|
-
|
12
|
-
const isProd = () => process.env.NODE_ENV === 'production';
|
13
|
-
|
14
|
-
exports.isProd = isProd;
|
15
|
-
|
16
|
-
const isTest = () => process.env.NODE_ENV === 'test'; // Variable used for enabling profiling in Production.
|
17
|
-
|
18
|
-
|
19
|
-
exports.isTest = isTest;
|
20
|
-
|
21
|
-
const isProdProfile = () => isProd() && process.argv.includes('--profile');
|
22
|
-
|
23
|
-
exports.isProdProfile = isProdProfile;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isNodeJS = exports.isBrowser = void 0;
|
7
|
-
|
8
|
-
const isNodeJS = () => typeof process !== 'undefined' && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
9
|
-
|
10
|
-
exports.isNodeJS = isNodeJS;
|
11
|
-
|
12
|
-
const isBrowser = () => typeof window !== 'undefined';
|
13
|
-
|
14
|
-
exports.isBrowser = isBrowser;
|
package/dist/js/node/is/type.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isArray = isArray;
|
7
|
-
exports.isFunction = isFunction;
|
8
|
-
exports.isObject = isObject;
|
9
|
-
exports.isPlainObject = isPlainObject;
|
10
|
-
exports.isPromise = isPromise;
|
11
|
-
exports.isRegExp = isRegExp;
|
12
|
-
exports.isString = isString;
|
13
|
-
exports.isUndefined = isUndefined;
|
14
|
-
|
15
|
-
function isString(str) {
|
16
|
-
return typeof str === 'string';
|
17
|
-
}
|
18
|
-
|
19
|
-
function isUndefined(obj) {
|
20
|
-
return typeof obj === 'undefined';
|
21
|
-
}
|
22
|
-
|
23
|
-
function isArray(obj) {
|
24
|
-
return Array.isArray(obj);
|
25
|
-
} // eslint-disable-next-line @typescript-eslint/ban-types
|
26
|
-
|
27
|
-
|
28
|
-
function isFunction(func) {
|
29
|
-
return typeof func === 'function';
|
30
|
-
}
|
31
|
-
|
32
|
-
function isObject(obj) {
|
33
|
-
return obj !== null && typeof obj === 'object';
|
34
|
-
}
|
35
|
-
|
36
|
-
function isPlainObject(obj) {
|
37
|
-
return isObject(obj) && Object.prototype.toString.call(obj) === '[object Object]';
|
38
|
-
}
|
39
|
-
|
40
|
-
function isPromise(obj) {
|
41
|
-
return Boolean(obj) && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
|
42
|
-
}
|
43
|
-
|
44
|
-
function isRegExp(obj) {
|
45
|
-
return Object.prototype.toString.call(obj) === '[object RegExp]';
|
46
|
-
}
|
package/dist/js/node/logger.js
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.logger = void 0;
|
7
|
-
|
8
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
|
12
|
-
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; }
|
13
|
-
|
14
|
-
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; }
|
15
|
-
|
16
|
-
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; }
|
17
|
-
|
18
|
-
const {
|
19
|
-
grey,
|
20
|
-
underline
|
21
|
-
} = _chalk.default;
|
22
|
-
const LOG_TYPES = {
|
23
|
-
error: {
|
24
|
-
color: 'red',
|
25
|
-
label: 'error',
|
26
|
-
level: 'error'
|
27
|
-
},
|
28
|
-
info: {
|
29
|
-
color: 'blue',
|
30
|
-
label: 'info',
|
31
|
-
level: 'info'
|
32
|
-
},
|
33
|
-
warn: {
|
34
|
-
color: 'yellow',
|
35
|
-
label: 'warning',
|
36
|
-
level: 'warn'
|
37
|
-
},
|
38
|
-
debug: {
|
39
|
-
color: 'red',
|
40
|
-
label: 'debug',
|
41
|
-
level: 'debug'
|
42
|
-
},
|
43
|
-
log: {
|
44
|
-
level: 'info'
|
45
|
-
}
|
46
|
-
};
|
47
|
-
const DEFAULT_CONFIG = {
|
48
|
-
displayLabel: true,
|
49
|
-
underlineLabel: true,
|
50
|
-
uppercaseLabel: false
|
51
|
-
};
|
52
|
-
|
53
|
-
class Logger {
|
54
|
-
constructor(options = {}) {
|
55
|
-
this.logCount = 200;
|
56
|
-
this.history = {};
|
57
|
-
this.config = void 0;
|
58
|
-
this.types = void 0;
|
59
|
-
this.longestLabel = void 0;
|
60
|
-
this.config = _objectSpread(_objectSpread({}, DEFAULT_CONFIG), options.config || {});
|
61
|
-
this.types = _objectSpread(_objectSpread({}, LOG_TYPES), options.types || {});
|
62
|
-
this.longestLabel = this.getLongestLabel();
|
63
|
-
Object.keys(this.types).forEach(type => {
|
64
|
-
this[type] = this._log.bind(this, type);
|
65
|
-
});
|
66
|
-
}
|
67
|
-
|
68
|
-
retainLog(type, message) {
|
69
|
-
if (!this.history[type]) {
|
70
|
-
this.history[type] = [];
|
71
|
-
}
|
72
|
-
|
73
|
-
this.history[type].push(message);
|
74
|
-
|
75
|
-
while (this.history[type].length > this.logCount) {
|
76
|
-
this.history[type].shift();
|
77
|
-
}
|
78
|
-
} // eslint-disable-next-line max-statements
|
79
|
-
|
80
|
-
|
81
|
-
_log(type, message) {
|
82
|
-
if (message === undefined) {
|
83
|
-
// eslint-disable-next-line no-console
|
84
|
-
console.log();
|
85
|
-
return;
|
86
|
-
}
|
87
|
-
|
88
|
-
let label = '';
|
89
|
-
let text = '';
|
90
|
-
const logType = this.types[type];
|
91
|
-
|
92
|
-
if (this.config.displayLabel && logType.label) {
|
93
|
-
label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
|
94
|
-
|
95
|
-
if (this.config.underlineLabel) {
|
96
|
-
label = underline(label).padEnd(this.longestUnderlinedLabel.length + 1);
|
97
|
-
} else {
|
98
|
-
label = label.padEnd(this.longestLabel.length + 1);
|
99
|
-
}
|
100
|
-
|
101
|
-
label = logType.color ? _chalk.default[logType.color](label) : label;
|
102
|
-
}
|
103
|
-
|
104
|
-
if (message instanceof Error) {
|
105
|
-
if (message.stack) {
|
106
|
-
const [name, ...rest] = message.stack.split('\n');
|
107
|
-
text = `${name}\n${grey(rest.join('\n'))}`;
|
108
|
-
} else {
|
109
|
-
text = message.message;
|
110
|
-
}
|
111
|
-
} else {
|
112
|
-
text = `${message}`;
|
113
|
-
} // only retain logs of warn/error level
|
114
|
-
|
115
|
-
|
116
|
-
if (logType.level === 'warn' || logType.level === 'error') {
|
117
|
-
// retain log text without label
|
118
|
-
this.retainLog(type, text);
|
119
|
-
}
|
120
|
-
|
121
|
-
const log = label.length > 0 ? `${label} ${text}` : text; // eslint-disable-next-line no-console
|
122
|
-
|
123
|
-
console.log(log);
|
124
|
-
}
|
125
|
-
|
126
|
-
getLongestLabel() {
|
127
|
-
let longestLabel = '';
|
128
|
-
Object.keys(this.types).forEach(type => {
|
129
|
-
const {
|
130
|
-
label = ''
|
131
|
-
} = this.types[type];
|
132
|
-
|
133
|
-
if (label.length > longestLabel.length) {
|
134
|
-
longestLabel = label;
|
135
|
-
}
|
136
|
-
});
|
137
|
-
return longestLabel;
|
138
|
-
}
|
139
|
-
|
140
|
-
get longestUnderlinedLabel() {
|
141
|
-
return underline(this.longestLabel);
|
142
|
-
}
|
143
|
-
|
144
|
-
getRetainedLogs(type) {
|
145
|
-
return this.history[type] || [];
|
146
|
-
}
|
147
|
-
|
148
|
-
clearRetainedLogs(type) {
|
149
|
-
if (type) {
|
150
|
-
if (this.history[type]) {
|
151
|
-
this.history[type] = [];
|
152
|
-
}
|
153
|
-
} else {
|
154
|
-
this.history = {};
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
}
|
159
|
-
|
160
|
-
const logger = new Logger();
|
161
|
-
exports.logger = logger;
|
162
|
-
logger.Logger = Logger;
|
package/dist/js/node/monorepo.js
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.isYarnWorkspaces = exports.isPnpmWorkspaces = exports.isMonorepo = exports.isModernjsMonorepo = exports.isLerna = exports.getMonorepoPackages = exports.findMonorepoRoot = void 0;
|
7
|
-
|
8
|
-
var _fs = _interopRequireDefault(require("fs"));
|
9
|
-
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
11
|
-
|
12
|
-
var _glob = _interopRequireDefault(require("glob"));
|
13
|
-
|
14
|
-
var _yaml = _interopRequireDefault(require("yaml"));
|
15
|
-
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
|
-
|
18
|
-
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; }
|
19
|
-
|
20
|
-
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; }
|
21
|
-
|
22
|
-
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; }
|
23
|
-
|
24
|
-
const PACKAGE_MAX_DEPTH = 5;
|
25
|
-
const WOKRSPACES_FILES = {
|
26
|
-
YARN: 'package.json',
|
27
|
-
PNPM: 'pnpm-workspaces.yaml',
|
28
|
-
LERNA: 'lerna.json'
|
29
|
-
};
|
30
|
-
|
31
|
-
const isLerna = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.LERNA));
|
32
|
-
|
33
|
-
exports.isLerna = isLerna;
|
34
|
-
|
35
|
-
const isYarnWorkspaces = root => {
|
36
|
-
var _json$workspaces;
|
37
|
-
|
38
|
-
const pkg = _path.default.join(root, WOKRSPACES_FILES.YARN);
|
39
|
-
|
40
|
-
if (!_fs.default.existsSync(pkg)) {
|
41
|
-
return false;
|
42
|
-
}
|
43
|
-
|
44
|
-
const json = JSON.parse(_fs.default.readFileSync(pkg, 'utf8'));
|
45
|
-
return Boolean((_json$workspaces = json.workspaces) === null || _json$workspaces === void 0 ? void 0 : _json$workspaces.packages);
|
46
|
-
};
|
47
|
-
|
48
|
-
exports.isYarnWorkspaces = isYarnWorkspaces;
|
49
|
-
|
50
|
-
const isPnpmWorkspaces = root => _fs.default.existsSync(_path.default.join(root, WOKRSPACES_FILES.PNPM));
|
51
|
-
|
52
|
-
exports.isPnpmWorkspaces = isPnpmWorkspaces;
|
53
|
-
|
54
|
-
const isMonorepo = root => isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
|
55
|
-
|
56
|
-
exports.isMonorepo = isMonorepo;
|
57
|
-
|
58
|
-
const isModernjsMonorepo = root => {
|
59
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
|
60
|
-
|
61
|
-
const deps = _objectSpread(_objectSpread({}, json.dependencies || {}), json.devDependencies || {});
|
62
|
-
|
63
|
-
return Boolean(deps['@modern-js/monorepo-tools']);
|
64
|
-
};
|
65
|
-
|
66
|
-
exports.isModernjsMonorepo = isModernjsMonorepo;
|
67
|
-
|
68
|
-
const findMonorepoRoot = (appDirectory, maxDepth = PACKAGE_MAX_DEPTH) => {
|
69
|
-
let inMonorepo = false;
|
70
|
-
|
71
|
-
for (let depth = 0; depth < maxDepth; depth++) {
|
72
|
-
if (isMonorepo(appDirectory)) {
|
73
|
-
inMonorepo = true;
|
74
|
-
break;
|
75
|
-
} // eslint-disable-next-line no-param-reassign
|
76
|
-
|
77
|
-
|
78
|
-
appDirectory = _path.default.dirname(appDirectory);
|
79
|
-
}
|
80
|
-
|
81
|
-
return inMonorepo ? appDirectory : undefined;
|
82
|
-
};
|
83
|
-
|
84
|
-
exports.findMonorepoRoot = findMonorepoRoot;
|
85
|
-
|
86
|
-
const getMonorepoPackages = root => {
|
87
|
-
let packages = [];
|
88
|
-
|
89
|
-
if (isYarnWorkspaces(root)) {
|
90
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.join(root, 'package.json'), 'utf8'));
|
91
|
-
({
|
92
|
-
packages
|
93
|
-
} = json.workspaces);
|
94
|
-
} else if (isLerna(root)) {
|
95
|
-
const json = JSON.parse(_fs.default.readFileSync(_path.default.resolve(root, 'lerna.json'), 'utf8'));
|
96
|
-
({
|
97
|
-
packages
|
98
|
-
} = json);
|
99
|
-
} else {
|
100
|
-
({
|
101
|
-
packages
|
102
|
-
} = _yaml.default.parse(_fs.default.readFileSync(_path.default.join(root, WOKRSPACES_FILES.PNPM), 'utf8')));
|
103
|
-
}
|
104
|
-
|
105
|
-
if (packages) {
|
106
|
-
return packages.map(name => // The trailing / ensures only dirs are picked up
|
107
|
-
_glob.default.sync(_path.default.join(root, `${name}/`), {
|
108
|
-
ignore: ['**/node_modules/**']
|
109
|
-
})).flat().filter(filepath => _fs.default.existsSync(_path.default.resolve(filepath, 'package.json'))).map(filepath => ({
|
110
|
-
path: filepath,
|
111
|
-
name: JSON.parse(_fs.default.readFileSync(_path.default.resolve(filepath, 'package.json'), 'utf8')).name
|
112
|
-
}));
|
113
|
-
}
|
114
|
-
|
115
|
-
return [];
|
116
|
-
};
|
117
|
-
|
118
|
-
exports.getMonorepoPackages = getMonorepoPackages;
|
package/dist/js/node/nodeEnv.js
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.canUseNpm = canUseNpm;
|
7
|
-
exports.canUsePnpm = canUsePnpm;
|
8
|
-
exports.canUseYarn = canUseYarn;
|
9
|
-
|
10
|
-
var _execa = _interopRequireDefault(require("execa"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
async function canUseNpm() {
|
15
|
-
try {
|
16
|
-
await (0, _execa.default)('npm', ['--version'], {
|
17
|
-
env: process.env
|
18
|
-
});
|
19
|
-
return true;
|
20
|
-
} catch (e) {
|
21
|
-
return false;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
async function canUseYarn() {
|
26
|
-
try {
|
27
|
-
await (0, _execa.default)('yarn', ['--version'], {
|
28
|
-
env: process.env
|
29
|
-
});
|
30
|
-
return true;
|
31
|
-
} catch (e) {
|
32
|
-
return false;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
async function canUsePnpm() {
|
37
|
-
try {
|
38
|
-
await (0, _execa.default)('pnpm', ['--version'], {
|
39
|
-
env: process.env
|
40
|
-
});
|
41
|
-
return true;
|
42
|
-
} catch (e) {
|
43
|
-
return false;
|
44
|
-
}
|
45
|
-
}
|
package/dist/js/node/path.js
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.normalizeToPosixPath = exports.normalizeOutputPath = exports.isRelativePath = void 0;
|
7
|
-
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
9
|
-
|
10
|
-
var _upath = _interopRequireDefault(require("upath"));
|
11
|
-
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
-
|
14
|
-
const isRelativePath = test => /^\.\.?($|[\\/])/.test(test);
|
15
|
-
|
16
|
-
exports.isRelativePath = isRelativePath;
|
17
|
-
|
18
|
-
const normalizeOutputPath = s => s.replace(/\\/g, '\\\\');
|
19
|
-
|
20
|
-
exports.normalizeOutputPath = normalizeOutputPath;
|
21
|
-
|
22
|
-
const normalizeToPosixPath = p => _upath.default.normalizeSafe(_path.default.normalize(p));
|
23
|
-
|
24
|
-
exports.normalizeToPosixPath = normalizeToPosixPath;
|
package/dist/js/node/pkgUp.js
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
Object.defineProperty(exports, "pkgUp", {
|
7
|
-
enumerable: true,
|
8
|
-
get: function () {
|
9
|
-
return _pkgUp.default;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
|
13
|
-
var _pkgUp = _interopRequireDefault(require("pkg-up"));
|
14
|
-
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -1,95 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.prettyInstructions = exports.isSingleEntry = void 0;
|
7
|
-
|
8
|
-
var _os = _interopRequireDefault(require("os"));
|
9
|
-
|
10
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
11
|
-
|
12
|
-
var _is = require("./is");
|
13
|
-
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
-
|
16
|
-
// TODO: remove hard code 'main'
|
17
|
-
const isSingleEntry = entrypoints => entrypoints.length === 1 && entrypoints[0].entryName === 'main';
|
18
|
-
|
19
|
-
exports.isSingleEntry = isSingleEntry;
|
20
|
-
|
21
|
-
const normalizeUrl = url => url.replace(/([^:]\/)\/+/g, '$1');
|
22
|
-
|
23
|
-
const getAddressUrls = (protocol = 'http', port) => {
|
24
|
-
const interfaces = _os.default.networkInterfaces();
|
25
|
-
|
26
|
-
const ipv4Interfaces = [];
|
27
|
-
Object.keys(interfaces).forEach(key => {
|
28
|
-
interfaces[key].forEach(detail => {
|
29
|
-
if (detail.family === 'IPv4') {
|
30
|
-
ipv4Interfaces.push(detail);
|
31
|
-
}
|
32
|
-
});
|
33
|
-
});
|
34
|
-
return ipv4Interfaces.reduce((memo, detail) => {
|
35
|
-
let type = 'Network: ';
|
36
|
-
let url = `${protocol}://${detail.address}:${port}`;
|
37
|
-
|
38
|
-
if (detail.address.includes(`localhost`)) {
|
39
|
-
type = 'Local: ';
|
40
|
-
url = `${protocol}://localhost:${port}`;
|
41
|
-
}
|
42
|
-
|
43
|
-
memo.push({
|
44
|
-
type,
|
45
|
-
url
|
46
|
-
});
|
47
|
-
return memo;
|
48
|
-
}, []);
|
49
|
-
};
|
50
|
-
|
51
|
-
const prettyInstructions = (appContext, config) => {
|
52
|
-
const {
|
53
|
-
entrypoints,
|
54
|
-
serverRoutes,
|
55
|
-
port,
|
56
|
-
existSrc,
|
57
|
-
checkedEntries
|
58
|
-
} = appContext;
|
59
|
-
const urls = getAddressUrls(config.dev.https && (0, _is.isDev)() ? 'https' : 'http', port);
|
60
|
-
const routes = existSrc ? serverRoutes.filter(route => route.entryName) : serverRoutes;
|
61
|
-
let message = 'App running at:\n\n';
|
62
|
-
|
63
|
-
if (isSingleEntry(entrypoints) || !existSrc) {
|
64
|
-
message += urls.map(({
|
65
|
-
type,
|
66
|
-
url
|
67
|
-
}) => ` ${_chalk.default.bold(`> ${type.padEnd(10)}`)}${_chalk.default.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}\n`).join('');
|
68
|
-
} else {
|
69
|
-
const maxNameLength = Math.max(...routes.map(r => r.entryName.length));
|
70
|
-
urls.forEach(({
|
71
|
-
type,
|
72
|
-
url
|
73
|
-
}) => {
|
74
|
-
message += ` ${_chalk.default.bold(`> ${type}`)}\n`;
|
75
|
-
routes.forEach(({
|
76
|
-
entryName,
|
77
|
-
urlPath,
|
78
|
-
isSSR
|
79
|
-
}) => {
|
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`;
|
85
|
-
});
|
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');
|
90
|
-
}
|
91
|
-
|
92
|
-
return message;
|
93
|
-
};
|
94
|
-
|
95
|
-
exports.prettyInstructions = prettyInstructions;
|