@modern-js/utils 2.22.0 → 2.22.1-alpha.0
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/dist/FileSizeReporter.d.ts +16 -0
- package/dist/FileSizeReporter.js +162 -0
- package/dist/alias.d.ts +25 -0
- package/dist/alias.js +108 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeProject.js +71 -0
- package/dist/applyOptionsChain.d.ts +3 -0
- package/dist/applyOptionsChain.js +58 -0
- package/dist/babel.d.ts +3 -0
- package/dist/babel.js +136 -0
- package/dist/chainId.d.ts +244 -0
- package/dist/chainId.js +196 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +31 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +48 -0
- package/dist/compatRequire.d.ts +13 -0
- package/dist/compatRequire.js +82 -0
- package/dist/compiled.d.ts +43 -0
- package/dist/compiled.js +142 -0
- package/dist/constants.d.ts +244 -0
- package/dist/constants.js +320 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.js +28 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +52 -0
- package/dist/ensureAbsolutePath.d.ts +7 -0
- package/dist/ensureAbsolutePath.js +38 -0
- package/dist/ensureArray.d.ts +1 -0
- package/dist/ensureArray.js +32 -0
- package/dist/findExists.d.ts +6 -0
- package/dist/findExists.js +45 -0
- package/dist/generateMetaTags.d.ts +16 -0
- package/dist/generateMetaTags.js +61 -0
- package/dist/getBrowserslist.d.ts +2 -0
- package/dist/getBrowserslist.js +31 -0
- package/dist/getCoreJsVersion.d.ts +1 -0
- package/dist/getCoreJsVersion.js +46 -0
- package/dist/getEntryOptions.d.ts +1 -0
- package/dist/getEntryOptions.js +54 -0
- package/dist/getPackageManager.d.ts +1 -0
- package/dist/getPackageManager.js +87 -0
- package/dist/getPort.d.ts +14 -0
- package/dist/getPort.js +112 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +67 -0
- package/dist/getTargetDir.d.ts +1 -0
- package/dist/getTargetDir.js +41 -0
- package/dist/import.d.ts +5 -0
- package/dist/import.js +33 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +60 -0
- package/dist/is/index.d.ts +58 -0
- package/dist/is/index.js +114 -0
- package/dist/is/nodeEnv.d.ts +8 -0
- package/dist/is/nodeEnv.js +39 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +30 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +64 -0
- package/dist/logger.d.ts +65 -0
- package/dist/logger.js +145 -0
- package/dist/monorepo.d.ts +11 -0
- package/dist/monorepo.js +137 -0
- package/dist/nodeEnv.d.ts +3 -0
- package/dist/nodeEnv.js +81 -0
- package/dist/path.d.ts +18 -0
- package/dist/path.js +92 -0
- package/dist/pathSerializer.d.ts +16 -0
- package/dist/pathSerializer.js +76 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +46 -0
- package/dist/prettyInstructions.d.ts +9 -0
- package/dist/prettyInstructions.js +112 -0
- package/dist/printBuildError.d.ts +8 -0
- package/dist/printBuildError.js +57 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +64 -0
- package/dist/readTsConfig.d.ts +2 -0
- package/dist/readTsConfig.js +47 -0
- package/dist/removeSlash.d.ts +3 -0
- package/dist/removeSlash.js +33 -0
- package/dist/resolve.d.ts +13 -0
- package/dist/resolve.js +63 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +58 -0
- package/dist/runtimeExports.d.ts +4 -0
- package/dist/runtimeExports.js +73 -0
- package/dist/ssr.d.ts +8 -0
- package/dist/ssr.js +30 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +75 -0
- package/dist/testUtils.d.ts +5 -0
- package/dist/testUtils.js +38 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +15 -0
- package/dist/universal/constants.d.ts +9 -0
- package/dist/universal/constants.js +30 -0
- package/dist/universal/formatWebpack.d.ts +13 -0
- package/dist/universal/formatWebpack.js +100 -0
- package/dist/universal/nestedRoutes.d.ts +8 -0
- package/dist/universal/nestedRoutes.js +131 -0
- package/dist/universal/remixRouter.d.ts +1 -0
- package/dist/universal/remixRouter.js +17 -0
- package/dist/universal/serialize.d.ts +1 -0
- package/dist/universal/serialize.js +40 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +92 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +29 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +90 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getServerConfig: (appDirectory: string, configFile: string) => Promise<string | false>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
var getServerConfig_exports = {};
|
|
49
|
+
__export(getServerConfig_exports, {
|
|
50
|
+
getServerConfig: () => getServerConfig
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(getServerConfig_exports);
|
|
53
|
+
var path = __toESM(require("path"));
|
|
54
|
+
var import_constants = require("./constants");
|
|
55
|
+
var import_findExists = require("./findExists");
|
|
56
|
+
const getServerConfig = (appDirectory, configFile) => __async(void 0, null, function* () {
|
|
57
|
+
const configFilePath = (0, import_findExists.findExists)(
|
|
58
|
+
import_constants.CONFIG_FILE_EXTENSIONS.map(
|
|
59
|
+
(extension) => path.resolve(appDirectory, `${configFile}${extension}`)
|
|
60
|
+
)
|
|
61
|
+
);
|
|
62
|
+
return configFilePath;
|
|
63
|
+
});
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
getServerConfig
|
|
67
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTargetDir: (from: string, baseDir: string, targetBaseDir: string) => string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var getTargetDir_exports = {};
|
|
29
|
+
__export(getTargetDir_exports, {
|
|
30
|
+
getTargetDir: () => getTargetDir
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(getTargetDir_exports);
|
|
33
|
+
var path = __toESM(require("path"));
|
|
34
|
+
const getTargetDir = (from, baseDir, targetBaseDir) => {
|
|
35
|
+
const relativePath = path.relative(baseDir, from);
|
|
36
|
+
return path.resolve(targetBaseDir, relativePath);
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
getTargetDir
|
|
41
|
+
});
|
package/dist/import.d.ts
ADDED
package/dist/import.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var import_exports = {};
|
|
19
|
+
__export(import_exports, {
|
|
20
|
+
Import: () => Import,
|
|
21
|
+
lazyImport: () => lazy
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(import_exports);
|
|
24
|
+
const lazy = (moduleName, requireFn) => {
|
|
25
|
+
const importLazyLocal = require("../compiled/import-lazy")(requireFn);
|
|
26
|
+
return importLazyLocal(moduleName);
|
|
27
|
+
};
|
|
28
|
+
const Import = { lazy };
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
Import,
|
|
32
|
+
lazyImport
|
|
33
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export * from './compiled';
|
|
2
|
+
export * from './commands';
|
|
3
|
+
export * from './FileSizeReporter';
|
|
4
|
+
export * from './printBuildError';
|
|
5
|
+
export * from './debug';
|
|
6
|
+
export * from './findExists';
|
|
7
|
+
export * from './is';
|
|
8
|
+
export * from './compatRequire';
|
|
9
|
+
export * from './logger';
|
|
10
|
+
export * from './constants';
|
|
11
|
+
export * from './ensureArray';
|
|
12
|
+
export * from './ensureAbsolutePath';
|
|
13
|
+
export * from './clearConsole';
|
|
14
|
+
export * from './applyOptionsChain';
|
|
15
|
+
export * from './getBrowserslist';
|
|
16
|
+
export * from './removeSlash';
|
|
17
|
+
export * from './getEntryOptions';
|
|
18
|
+
export * from './getPort';
|
|
19
|
+
export * from './monorepo';
|
|
20
|
+
export * from './getPackageManager';
|
|
21
|
+
export * from './runtimeExports';
|
|
22
|
+
export * from './readTsConfig';
|
|
23
|
+
export * from './path';
|
|
24
|
+
export * from './pathSerializer';
|
|
25
|
+
export * from './generateMetaTags';
|
|
26
|
+
export * from './prettyInstructions';
|
|
27
|
+
export * from './alias';
|
|
28
|
+
export * from './import';
|
|
29
|
+
export * from './watch';
|
|
30
|
+
export * from './nodeEnv';
|
|
31
|
+
export * from './wait';
|
|
32
|
+
export * from './emptyDir';
|
|
33
|
+
export * from './getServerConfig';
|
|
34
|
+
export * from './resolve';
|
|
35
|
+
export * from './analyzeProject';
|
|
36
|
+
export * from './chainId';
|
|
37
|
+
export * from './version';
|
|
38
|
+
export * from './plugin';
|
|
39
|
+
export * from './routes';
|
|
40
|
+
export * from './testUtils';
|
|
41
|
+
export * from './getCoreJsVersion';
|
|
42
|
+
export * from './react';
|
|
43
|
+
export * from './getTargetDir';
|
|
44
|
+
export * from './babel';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var src_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(src_exports);
|
|
17
|
+
__reExport(src_exports, require("./compiled"), module.exports);
|
|
18
|
+
__reExport(src_exports, require("./commands"), module.exports);
|
|
19
|
+
__reExport(src_exports, require("./FileSizeReporter"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./printBuildError"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./debug"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./findExists"), module.exports);
|
|
23
|
+
__reExport(src_exports, require("./is"), module.exports);
|
|
24
|
+
__reExport(src_exports, require("./compatRequire"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./logger"), module.exports);
|
|
26
|
+
__reExport(src_exports, require("./constants"), module.exports);
|
|
27
|
+
__reExport(src_exports, require("./ensureArray"), module.exports);
|
|
28
|
+
__reExport(src_exports, require("./ensureAbsolutePath"), module.exports);
|
|
29
|
+
__reExport(src_exports, require("./clearConsole"), module.exports);
|
|
30
|
+
__reExport(src_exports, require("./applyOptionsChain"), module.exports);
|
|
31
|
+
__reExport(src_exports, require("./getBrowserslist"), module.exports);
|
|
32
|
+
__reExport(src_exports, require("./removeSlash"), module.exports);
|
|
33
|
+
__reExport(src_exports, require("./getEntryOptions"), module.exports);
|
|
34
|
+
__reExport(src_exports, require("./getPort"), module.exports);
|
|
35
|
+
__reExport(src_exports, require("./monorepo"), module.exports);
|
|
36
|
+
__reExport(src_exports, require("./getPackageManager"), module.exports);
|
|
37
|
+
__reExport(src_exports, require("./runtimeExports"), module.exports);
|
|
38
|
+
__reExport(src_exports, require("./readTsConfig"), module.exports);
|
|
39
|
+
__reExport(src_exports, require("./path"), module.exports);
|
|
40
|
+
__reExport(src_exports, require("./pathSerializer"), module.exports);
|
|
41
|
+
__reExport(src_exports, require("./generateMetaTags"), module.exports);
|
|
42
|
+
__reExport(src_exports, require("./prettyInstructions"), module.exports);
|
|
43
|
+
__reExport(src_exports, require("./alias"), module.exports);
|
|
44
|
+
__reExport(src_exports, require("./import"), module.exports);
|
|
45
|
+
__reExport(src_exports, require("./watch"), module.exports);
|
|
46
|
+
__reExport(src_exports, require("./nodeEnv"), module.exports);
|
|
47
|
+
__reExport(src_exports, require("./wait"), module.exports);
|
|
48
|
+
__reExport(src_exports, require("./emptyDir"), module.exports);
|
|
49
|
+
__reExport(src_exports, require("./getServerConfig"), module.exports);
|
|
50
|
+
__reExport(src_exports, require("./resolve"), module.exports);
|
|
51
|
+
__reExport(src_exports, require("./analyzeProject"), module.exports);
|
|
52
|
+
__reExport(src_exports, require("./chainId"), module.exports);
|
|
53
|
+
__reExport(src_exports, require("./version"), module.exports);
|
|
54
|
+
__reExport(src_exports, require("./plugin"), module.exports);
|
|
55
|
+
__reExport(src_exports, require("./routes"), module.exports);
|
|
56
|
+
__reExport(src_exports, require("./testUtils"), module.exports);
|
|
57
|
+
__reExport(src_exports, require("./getCoreJsVersion"), module.exports);
|
|
58
|
+
__reExport(src_exports, require("./react"), module.exports);
|
|
59
|
+
__reExport(src_exports, require("./getTargetDir"), module.exports);
|
|
60
|
+
__reExport(src_exports, require("./babel"), module.exports);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface EntryPoint {
|
|
2
|
+
entryName: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Check if the package name is in dependencies or devDependencies.
|
|
6
|
+
*
|
|
7
|
+
* @param appDirectory - Project root directory.
|
|
8
|
+
* @param name - Package name.
|
|
9
|
+
* @returns True if the name is in dependencies or devDependencies, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export declare const isDepExists: (appDirectory: string, name: string) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Is typescript project.
|
|
15
|
+
*
|
|
16
|
+
* @param root - App directory.
|
|
17
|
+
* @returns Whether to use typescript.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export declare const isTypescript: (root: string) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Is Empty object
|
|
23
|
+
*
|
|
24
|
+
* @param o - Any object.
|
|
25
|
+
* @returns Whether it is empty object.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export declare const isEmpty: (o: Record<string, unknown>) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Is SSR project
|
|
31
|
+
*
|
|
32
|
+
* @param config - User config.
|
|
33
|
+
* @returns Whether to use server side render.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export declare const isSSR: (config: any) => boolean;
|
|
37
|
+
export declare const isUseSSRBundle: (config: any) => boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Is Worker project
|
|
40
|
+
*
|
|
41
|
+
* @param config - User config.
|
|
42
|
+
* @returns Whether to use worker deploy.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
export declare const isServiceWorker: (config: any) => boolean;
|
|
46
|
+
export declare const isFastRefresh: () => boolean;
|
|
47
|
+
export declare const isRouterV5: (config: {
|
|
48
|
+
runtime?: {
|
|
49
|
+
router?: {
|
|
50
|
+
mode?: string;
|
|
51
|
+
} | boolean;
|
|
52
|
+
};
|
|
53
|
+
}) => boolean;
|
|
54
|
+
export declare const isSSGEntry: (config: any, entryName: string, entrypoints: EntryPoint[]) => boolean;
|
|
55
|
+
export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
|
|
56
|
+
export * from './nodeEnv';
|
|
57
|
+
export * from './platform';
|
|
58
|
+
export * from './type';
|
package/dist/is/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var is_exports = {};
|
|
30
|
+
__export(is_exports, {
|
|
31
|
+
isDepExists: () => isDepExists,
|
|
32
|
+
isEmpty: () => isEmpty,
|
|
33
|
+
isFastRefresh: () => isFastRefresh,
|
|
34
|
+
isRouterV5: () => isRouterV5,
|
|
35
|
+
isSSGEntry: () => isSSGEntry,
|
|
36
|
+
isSSR: () => isSSR,
|
|
37
|
+
isServiceWorker: () => isServiceWorker,
|
|
38
|
+
isSingleEntry: () => isSingleEntry,
|
|
39
|
+
isTypescript: () => isTypescript,
|
|
40
|
+
isUseSSRBundle: () => isUseSSRBundle
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(is_exports);
|
|
43
|
+
var import_fs = __toESM(require("fs"));
|
|
44
|
+
var import_path = __toESM(require("path"));
|
|
45
|
+
var import_debug = require("../debug");
|
|
46
|
+
var import_nodeEnv = require("./nodeEnv");
|
|
47
|
+
__reExport(is_exports, require("./nodeEnv"), module.exports);
|
|
48
|
+
__reExport(is_exports, require("./platform"), module.exports);
|
|
49
|
+
__reExport(is_exports, require("./type"), module.exports);
|
|
50
|
+
const debug = (0, import_debug.createDebugger)("judge-depExists");
|
|
51
|
+
const isDepExists = (appDirectory, name) => {
|
|
52
|
+
const pkgPath = import_path.default.resolve(appDirectory, "./package.json");
|
|
53
|
+
if (!import_fs.default.existsSync(pkgPath)) {
|
|
54
|
+
debug(`can't find package.json under: %s`, appDirectory);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const json = require(pkgPath);
|
|
58
|
+
const { dependencies = {}, devDependencies = {} } = json;
|
|
59
|
+
return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
|
|
60
|
+
};
|
|
61
|
+
const isTypescript = (root) => import_fs.default.existsSync(import_path.default.resolve(root, "./tsconfig.json"));
|
|
62
|
+
const isEmpty = (o) => Object.entries(o).length === 0 && o.constructor === Object;
|
|
63
|
+
const isSSR = (config) => {
|
|
64
|
+
const { server } = config;
|
|
65
|
+
if (server == null ? void 0 : server.ssr) {
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
if ((server == null ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
|
|
69
|
+
for (const name of Object.keys(server.ssrByEntries)) {
|
|
70
|
+
if (server.ssrByEntries[name]) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
};
|
|
77
|
+
const isUseSSRBundle = (config) => {
|
|
78
|
+
const { output } = config;
|
|
79
|
+
if (output == null ? void 0 : output.ssg) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return isSSR(config);
|
|
83
|
+
};
|
|
84
|
+
const isServiceWorker = (config) => {
|
|
85
|
+
const { output, server } = config;
|
|
86
|
+
if ((server == null ? void 0 : server.worker) && ((output == null ? void 0 : output.ssg) || isSSR(config))) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
};
|
|
91
|
+
const isFastRefresh = () => (0, import_nodeEnv.isDev)() && process.env.FAST_REFRESH !== "false";
|
|
92
|
+
const isRouterV5 = (config) => {
|
|
93
|
+
var _a, _b, _c;
|
|
94
|
+
return typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
|
|
95
|
+
};
|
|
96
|
+
const isSSGEntry = (config, entryName, entrypoints) => {
|
|
97
|
+
const ssgConfig = config.output.ssg;
|
|
98
|
+
const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig == null ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig == null ? void 0 : ssgConfig[entryName]);
|
|
99
|
+
return useSSG;
|
|
100
|
+
};
|
|
101
|
+
const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
isDepExists,
|
|
105
|
+
isEmpty,
|
|
106
|
+
isFastRefresh,
|
|
107
|
+
isRouterV5,
|
|
108
|
+
isSSGEntry,
|
|
109
|
+
isSSR,
|
|
110
|
+
isServiceWorker,
|
|
111
|
+
isSingleEntry,
|
|
112
|
+
isTypescript,
|
|
113
|
+
isUseSSRBundle
|
|
114
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the current NODE_ENV, or default to 'development' if not set.
|
|
3
|
+
*/
|
|
4
|
+
export declare const getNodeEnv: () => string;
|
|
5
|
+
export declare const isDev: () => boolean;
|
|
6
|
+
export declare const isProd: () => boolean;
|
|
7
|
+
export declare const isTest: () => boolean;
|
|
8
|
+
export declare const isProdProfile: () => boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var nodeEnv_exports = {};
|
|
19
|
+
__export(nodeEnv_exports, {
|
|
20
|
+
getNodeEnv: () => getNodeEnv,
|
|
21
|
+
isDev: () => isDev,
|
|
22
|
+
isProd: () => isProd,
|
|
23
|
+
isProdProfile: () => isProdProfile,
|
|
24
|
+
isTest: () => isTest
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(nodeEnv_exports);
|
|
27
|
+
const getNodeEnv = () => process.env.NODE_ENV || "development";
|
|
28
|
+
const isDev = () => getNodeEnv() === "development";
|
|
29
|
+
const isProd = () => getNodeEnv() === "production";
|
|
30
|
+
const isTest = () => getNodeEnv() === "test";
|
|
31
|
+
const isProdProfile = () => isProd() && process.argv.includes("--profile");
|
|
32
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
+
0 && (module.exports = {
|
|
34
|
+
getNodeEnv,
|
|
35
|
+
isDev,
|
|
36
|
+
isProd,
|
|
37
|
+
isProdProfile,
|
|
38
|
+
isTest
|
|
39
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var platform_exports = {};
|
|
19
|
+
__export(platform_exports, {
|
|
20
|
+
isBrowser: () => isBrowser,
|
|
21
|
+
isNodeJS: () => isNodeJS
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(platform_exports);
|
|
24
|
+
const isNodeJS = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
|
25
|
+
const isBrowser = () => typeof window !== "undefined";
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
isBrowser,
|
|
29
|
+
isNodeJS
|
|
30
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function isString(str: any): str is string;
|
|
2
|
+
export declare function isUndefined(obj: any): obj is undefined;
|
|
3
|
+
export declare function isArray(obj: unknown): obj is any[];
|
|
4
|
+
export declare function isFunction(func: any): func is Function;
|
|
5
|
+
export declare function isObject(obj: unknown): obj is Record<string, any>;
|
|
6
|
+
export declare function isPlainObject(obj: unknown): obj is Record<string, any>;
|
|
7
|
+
export declare function isPromise(obj: any): obj is Promise<any>;
|
|
8
|
+
export declare function isRegExp(obj: any): obj is RegExp;
|
package/dist/is/type.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var type_exports = {};
|
|
19
|
+
__export(type_exports, {
|
|
20
|
+
isArray: () => isArray,
|
|
21
|
+
isFunction: () => isFunction,
|
|
22
|
+
isObject: () => isObject,
|
|
23
|
+
isPlainObject: () => isPlainObject,
|
|
24
|
+
isPromise: () => isPromise,
|
|
25
|
+
isRegExp: () => isRegExp,
|
|
26
|
+
isString: () => isString,
|
|
27
|
+
isUndefined: () => isUndefined
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(type_exports);
|
|
30
|
+
function isString(str) {
|
|
31
|
+
return typeof str === "string";
|
|
32
|
+
}
|
|
33
|
+
function isUndefined(obj) {
|
|
34
|
+
return typeof obj === "undefined";
|
|
35
|
+
}
|
|
36
|
+
function isArray(obj) {
|
|
37
|
+
return Array.isArray(obj);
|
|
38
|
+
}
|
|
39
|
+
function isFunction(func) {
|
|
40
|
+
return typeof func === "function";
|
|
41
|
+
}
|
|
42
|
+
function isObject(obj) {
|
|
43
|
+
return obj !== null && typeof obj === "object";
|
|
44
|
+
}
|
|
45
|
+
function isPlainObject(obj) {
|
|
46
|
+
return isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]";
|
|
47
|
+
}
|
|
48
|
+
function isPromise(obj) {
|
|
49
|
+
return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
50
|
+
}
|
|
51
|
+
function isRegExp(obj) {
|
|
52
|
+
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
53
|
+
}
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
isArray,
|
|
57
|
+
isFunction,
|
|
58
|
+
isObject,
|
|
59
|
+
isPlainObject,
|
|
60
|
+
isPromise,
|
|
61
|
+
isRegExp,
|
|
62
|
+
isString,
|
|
63
|
+
isUndefined
|
|
64
|
+
});
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Color } from '../compiled/chalk';
|
|
2
|
+
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
3
|
+
type LogMsg = number | string | Error | null;
|
|
4
|
+
interface LoggerConfiguration {
|
|
5
|
+
color?: typeof Color;
|
|
6
|
+
label?: string;
|
|
7
|
+
level?: LogLevel;
|
|
8
|
+
}
|
|
9
|
+
interface InstanceConfiguration {
|
|
10
|
+
displayLabel?: boolean;
|
|
11
|
+
uppercaseLabel?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ConstructorOptions {
|
|
14
|
+
config?: InstanceConfiguration;
|
|
15
|
+
level?: string;
|
|
16
|
+
types?: Record<string, LoggerConfiguration>;
|
|
17
|
+
}
|
|
18
|
+
type LoggerFunction = (message?: LogMsg, ...args: any[]) => void;
|
|
19
|
+
declare const LOG_TYPES: {
|
|
20
|
+
error: {
|
|
21
|
+
color: string;
|
|
22
|
+
label: string;
|
|
23
|
+
level: string;
|
|
24
|
+
};
|
|
25
|
+
info: {
|
|
26
|
+
color: string;
|
|
27
|
+
label: string;
|
|
28
|
+
level: string;
|
|
29
|
+
};
|
|
30
|
+
success: {
|
|
31
|
+
color: string;
|
|
32
|
+
label: string;
|
|
33
|
+
level: string;
|
|
34
|
+
};
|
|
35
|
+
warn: {
|
|
36
|
+
color: string;
|
|
37
|
+
label: string;
|
|
38
|
+
level: string;
|
|
39
|
+
};
|
|
40
|
+
debug: {
|
|
41
|
+
color: string;
|
|
42
|
+
label: string;
|
|
43
|
+
level: string;
|
|
44
|
+
};
|
|
45
|
+
log: {
|
|
46
|
+
level: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
declare class Logger {
|
|
51
|
+
private readonly level;
|
|
52
|
+
private readonly config;
|
|
53
|
+
private readonly types;
|
|
54
|
+
private readonly longestLabel;
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
constructor(options?: ConstructorOptions);
|
|
57
|
+
private _log;
|
|
58
|
+
private getLongestLabel;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
type LoggerInterface = { [key in keyof typeof LOG_TYPES]: LoggerFunction };
|
|
62
|
+
declare const logger: Logger & LoggerInterface;
|
|
63
|
+
export { Logger };
|
|
64
|
+
export { logger };
|
|
65
|
+
export type { LoggerInterface };
|