@modern-js/utils 2.35.1 → 2.36.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +45 -46
- package/dist/cjs/cli/applyOptionsChain.js +30 -13
- package/dist/cjs/cli/babel.js +36 -26
- package/dist/cjs/cli/commands.js +29 -21
- package/dist/cjs/cli/common.js +29 -20
- package/dist/cjs/cli/config.js +24 -7
- package/dist/cjs/cli/constants/chainId.js +24 -7
- package/dist/cjs/cli/constants/index.js +86 -104
- package/dist/cjs/cli/ensure.js +37 -18
- package/dist/cjs/cli/fs.js +29 -19
- package/dist/cjs/cli/get/config.js +26 -9
- package/dist/cjs/cli/get/data.js +67 -54
- package/dist/cjs/cli/get/index.js +46 -25
- package/dist/cjs/cli/index.js +58 -23
- package/dist/cjs/cli/is/config.js +37 -31
- package/dist/cjs/cli/is/env.js +32 -29
- package/dist/cjs/cli/is/index.js +26 -8
- package/dist/cjs/cli/is/project.js +67 -53
- package/dist/cjs/cli/is/type.js +39 -36
- package/dist/cjs/cli/logger.js +25 -130
- package/dist/cjs/cli/monorepo.js +58 -58
- package/dist/cjs/cli/package.js +34 -26
- package/dist/cjs/cli/path.js +64 -54
- package/dist/cjs/cli/port.js +39 -13
- package/dist/cjs/cli/prettyInstructions.js +48 -29
- package/dist/cjs/cli/require.js +35 -29
- package/dist/cjs/cli/runtimeExports.js +42 -16
- package/dist/cjs/cli/watch.js +41 -22
- package/dist/cjs/compiled.js +127 -138
- package/dist/cjs/import.js +25 -15
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/universal/constants.js +29 -21
- package/dist/cjs/universal/formatWebpack.js +25 -15
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +10 -22
- package/dist/esm/cli/applyOptionsChain.js +4 -1
- package/dist/esm/cli/babel.js +6 -2
- package/dist/esm/cli/commands.js +10 -4
- package/dist/esm/cli/common.js +8 -3
- package/dist/esm/cli/config.js +4 -1
- package/dist/esm/cli/constants/chainId.js +4 -1
- package/dist/esm/cli/constants/index.js +64 -31
- package/dist/esm/cli/ensure.js +6 -2
- package/dist/esm/cli/fs.js +6 -2
- package/dist/esm/cli/get/config.js +4 -1
- package/dist/esm/cli/get/data.js +18 -8
- package/dist/esm/cli/get/index.js +6 -2
- package/dist/esm/cli/is/config.js +14 -6
- package/dist/esm/cli/is/env.js +12 -8
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/is/project.js +17 -8
- package/dist/esm/cli/is/type.js +20 -9
- package/dist/esm/cli/logger.js +4 -128
- package/dist/esm/cli/monorepo.js +14 -16
- package/dist/esm/cli/package.js +10 -4
- package/dist/esm/cli/path.js +24 -11
- package/dist/esm/cli/port.js +5 -2
- package/dist/esm/cli/prettyInstructions.js +6 -2
- package/dist/esm/cli/require.js +14 -6
- package/dist/esm/cli/runtimeExports.js +6 -3
- package/dist/esm/cli/watch.js +10 -6
- package/dist/esm/compiled.js +65 -31
- package/dist/esm/import.js +6 -3
- package/dist/esm/universal/constants.js +10 -4
- package/dist/esm/universal/formatWebpack.js +5 -2
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +8 -19
- package/dist/esm-node/cli/applyOptionsChain.js +4 -1
- package/dist/esm-node/cli/babel.js +6 -2
- package/dist/esm-node/cli/commands.js +10 -4
- package/dist/esm-node/cli/common.js +8 -3
- package/dist/esm-node/cli/config.js +4 -1
- package/dist/esm-node/cli/constants/chainId.js +4 -1
- package/dist/esm-node/cli/constants/index.js +64 -31
- package/dist/esm-node/cli/ensure.js +6 -2
- package/dist/esm-node/cli/fs.js +6 -2
- package/dist/esm-node/cli/get/config.js +4 -1
- package/dist/esm-node/cli/get/data.js +18 -8
- package/dist/esm-node/cli/get/index.js +6 -2
- package/dist/esm-node/cli/is/config.js +14 -6
- package/dist/esm-node/cli/is/env.js +12 -6
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/is/project.js +16 -7
- package/dist/esm-node/cli/is/type.js +20 -9
- package/dist/esm-node/cli/logger.js +4 -113
- package/dist/esm-node/cli/monorepo.js +14 -18
- package/dist/esm-node/cli/package.js +10 -4
- package/dist/esm-node/cli/path.js +24 -11
- package/dist/esm-node/cli/port.js +4 -1
- package/dist/esm-node/cli/prettyInstructions.js +6 -2
- package/dist/esm-node/cli/require.js +14 -6
- package/dist/esm-node/cli/runtimeExports.js +4 -1
- package/dist/esm-node/cli/watch.js +6 -2
- package/dist/esm-node/compiled.js +65 -31
- package/dist/esm-node/import.js +5 -2
- package/dist/esm-node/universal/constants.js +10 -4
- package/dist/esm-node/universal/formatWebpack.js +5 -2
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/is/env.d.ts +1 -2
- package/dist/types/cli/is/index.d.ts +0 -1
- package/dist/types/cli/logger.d.ts +1 -69
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/package.json +6 -13
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/compiled/gradient-string/index.d.ts +0 -1
- package/dist/compiled/gradient-string/index.js +0 -1
- package/dist/compiled/gradient-string/license +0 -21
- package/dist/compiled/gradient-string/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/index.js +0 -7
- package/dist/compiled/webpack-dev-middleware/license +0 -20
- package/dist/compiled/webpack-dev-middleware/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
- package/dist/esm/cli/is/platform.js +0 -6
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/types/cli/is/platform.d.ts +0 -2
package/dist/cjs/cli/index.js
CHANGED
@@ -1,25 +1,60 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
16
|
+
var cli_exports = {};
|
17
|
+
module.exports = __toCommonJS(cli_exports);
|
18
|
+
__reExport(cli_exports, require("./constants"), module.exports);
|
19
|
+
__reExport(cli_exports, require("./get"), module.exports);
|
20
|
+
__reExport(cli_exports, require("./is"), module.exports);
|
21
|
+
__reExport(cli_exports, require("./alias"), module.exports);
|
22
|
+
__reExport(cli_exports, require("./applyOptionsChain"), module.exports);
|
23
|
+
__reExport(cli_exports, require("./babel"), module.exports);
|
24
|
+
__reExport(cli_exports, require("./commands"), module.exports);
|
25
|
+
__reExport(cli_exports, require("./common"), module.exports);
|
26
|
+
__reExport(cli_exports, require("./ensure"), module.exports);
|
27
|
+
__reExport(cli_exports, require("./fs"), module.exports);
|
28
|
+
__reExport(cli_exports, require("./logger"), module.exports);
|
29
|
+
__reExport(cli_exports, require("./monorepo"), module.exports);
|
30
|
+
__reExport(cli_exports, require("./package"), module.exports);
|
31
|
+
__reExport(cli_exports, require("./path"), module.exports);
|
32
|
+
__reExport(cli_exports, require("./port"), module.exports);
|
33
|
+
__reExport(cli_exports, require("./prettyInstructions"), module.exports);
|
34
|
+
__reExport(cli_exports, require("./require"), module.exports);
|
35
|
+
__reExport(cli_exports, require("./runtimeExports"), module.exports);
|
36
|
+
__reExport(cli_exports, require("./watch"), module.exports);
|
37
|
+
__reExport(cli_exports, require("./config"), module.exports);
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
39
|
+
0 && (module.exports = {
|
40
|
+
...require("./constants"),
|
41
|
+
...require("./get"),
|
42
|
+
...require("./is"),
|
43
|
+
...require("./alias"),
|
44
|
+
...require("./applyOptionsChain"),
|
45
|
+
...require("./babel"),
|
46
|
+
...require("./commands"),
|
47
|
+
...require("./common"),
|
48
|
+
...require("./ensure"),
|
49
|
+
...require("./fs"),
|
50
|
+
...require("./logger"),
|
51
|
+
...require("./monorepo"),
|
52
|
+
...require("./package"),
|
53
|
+
...require("./path"),
|
54
|
+
...require("./port"),
|
55
|
+
...require("./prettyInstructions"),
|
56
|
+
...require("./require"),
|
57
|
+
...require("./runtimeExports"),
|
58
|
+
...require("./watch"),
|
59
|
+
...require("./config")
|
4
60
|
});
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
-
_export_star._(require("./constants"), exports);
|
7
|
-
_export_star._(require("./get"), exports);
|
8
|
-
_export_star._(require("./is"), exports);
|
9
|
-
_export_star._(require("./alias"), exports);
|
10
|
-
_export_star._(require("./applyOptionsChain"), exports);
|
11
|
-
_export_star._(require("./babel"), exports);
|
12
|
-
_export_star._(require("./commands"), exports);
|
13
|
-
_export_star._(require("./common"), exports);
|
14
|
-
_export_star._(require("./ensure"), exports);
|
15
|
-
_export_star._(require("./fs"), exports);
|
16
|
-
_export_star._(require("./logger"), exports);
|
17
|
-
_export_star._(require("./monorepo"), exports);
|
18
|
-
_export_star._(require("./package"), exports);
|
19
|
-
_export_star._(require("./path"), exports);
|
20
|
-
_export_star._(require("./port"), exports);
|
21
|
-
_export_star._(require("./prettyInstructions"), exports);
|
22
|
-
_export_star._(require("./require"), exports);
|
23
|
-
_export_star._(require("./runtimeExports"), exports);
|
24
|
-
_export_star._(require("./watch"), exports);
|
25
|
-
_export_star._(require("./config"), exports);
|
@@ -1,42 +1,39 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return isSSR;
|
15
|
-
},
|
16
|
-
isUseSSRBundle: function() {
|
17
|
-
return isUseSSRBundle;
|
18
|
-
},
|
19
|
-
isServiceWorker: function() {
|
20
|
-
return isServiceWorker;
|
21
|
-
},
|
22
|
-
isRouterV5: function() {
|
23
|
-
return isRouterV5;
|
24
|
-
},
|
25
|
-
isSSGEntry: function() {
|
26
|
-
return isSSGEntry;
|
27
|
-
},
|
28
|
-
isSingleEntry: function() {
|
29
|
-
return isSingleEntry;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
30
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var config_exports = {};
|
20
|
+
__export(config_exports, {
|
21
|
+
isRouterV5: () => isRouterV5,
|
22
|
+
isSSGEntry: () => isSSGEntry,
|
23
|
+
isSSR: () => isSSR,
|
24
|
+
isServiceWorker: () => isServiceWorker,
|
25
|
+
isSingleEntry: () => isSingleEntry,
|
26
|
+
isUseSSRBundle: () => isUseSSRBundle
|
31
27
|
});
|
32
|
-
|
33
|
-
|
28
|
+
module.exports = __toCommonJS(config_exports);
|
29
|
+
var import_constants = require("../constants");
|
30
|
+
var import_type = require("./type");
|
34
31
|
const isSSR = (config) => {
|
35
32
|
const { server } = config;
|
36
33
|
if (server === null || server === void 0 ? void 0 : server.ssr) {
|
37
34
|
return true;
|
38
35
|
}
|
39
|
-
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0,
|
36
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, import_type.isEmpty)(server.ssrByEntries)) {
|
40
37
|
for (const name of Object.keys(server.ssrByEntries)) {
|
41
38
|
if (server.ssrByEntries[name]) {
|
42
39
|
return true;
|
@@ -70,4 +67,13 @@ const isSSGEntry = (config, entryName, entrypoints) => {
|
|
70
67
|
const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
|
71
68
|
return useSSG;
|
72
69
|
};
|
73
|
-
const isSingleEntry = (entrypoints, mainEntryName =
|
70
|
+
const isSingleEntry = (entrypoints, mainEntryName = import_constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
72
|
+
0 && (module.exports = {
|
73
|
+
isRouterV5,
|
74
|
+
isSSGEntry,
|
75
|
+
isSSR,
|
76
|
+
isServiceWorker,
|
77
|
+
isSingleEntry,
|
78
|
+
isUseSSRBundle
|
79
|
+
});
|
package/dist/cjs/cli/is/env.js
CHANGED
@@ -1,37 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return getNodeEnv;
|
15
|
-
},
|
16
|
-
isDev: function() {
|
17
|
-
return isDev;
|
18
|
-
},
|
19
|
-
isProd: function() {
|
20
|
-
return isProd;
|
21
|
-
},
|
22
|
-
isTest: function() {
|
23
|
-
return isTest;
|
24
|
-
},
|
25
|
-
isProdProfile: function() {
|
26
|
-
return isProdProfile;
|
27
|
-
},
|
28
|
-
isFastRefresh: function() {
|
29
|
-
return isFastRefresh;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
30
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var env_exports = {};
|
20
|
+
__export(env_exports, {
|
21
|
+
getNodeEnv: () => getNodeEnv,
|
22
|
+
isBrowser: () => isBrowser,
|
23
|
+
isDev: () => isDev,
|
24
|
+
isProd: () => isProd,
|
25
|
+
isTest: () => isTest
|
31
26
|
});
|
27
|
+
module.exports = __toCommonJS(env_exports);
|
32
28
|
const getNodeEnv = () => process.env.NODE_ENV || "development";
|
33
29
|
const isDev = () => getNodeEnv() === "development";
|
34
30
|
const isProd = () => getNodeEnv() === "production";
|
35
31
|
const isTest = () => getNodeEnv() === "test";
|
36
|
-
const
|
37
|
-
|
32
|
+
const isBrowser = () => typeof window !== "undefined";
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
34
|
+
0 && (module.exports = {
|
35
|
+
getNodeEnv,
|
36
|
+
isBrowser,
|
37
|
+
isDev,
|
38
|
+
isProd,
|
39
|
+
isTest
|
40
|
+
});
|
package/dist/cjs/cli/is/index.js
CHANGED
@@ -1,10 +1,28 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
8
|
+
for (let key of __getOwnPropNames(from))
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
11
|
+
}
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
16
|
+
var is_exports = {};
|
17
|
+
module.exports = __toCommonJS(is_exports);
|
18
|
+
__reExport(is_exports, require("./env"), module.exports);
|
19
|
+
__reExport(is_exports, require("./type"), module.exports);
|
20
|
+
__reExport(is_exports, require("./config"), module.exports);
|
21
|
+
__reExport(is_exports, require("./project"), module.exports);
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
23
|
+
0 && (module.exports = {
|
24
|
+
...require("./env"),
|
25
|
+
...require("./type"),
|
26
|
+
...require("./config"),
|
27
|
+
...require("./project")
|
4
28
|
});
|
5
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
6
|
-
_export_star._(require("./env"), exports);
|
7
|
-
_export_star._(require("./platform"), exports);
|
8
|
-
_export_star._(require("./type"), exports);
|
9
|
-
_export_star._(require("./config"), exports);
|
10
|
-
_export_star._(require("./project"), exports);
|
@@ -1,48 +1,52 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
6
9
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return isDepExists;
|
15
|
-
},
|
16
|
-
isPackageInstalled: function() {
|
17
|
-
return isPackageInstalled;
|
18
|
-
},
|
19
|
-
isApiOnly: function() {
|
20
|
-
return isApiOnly;
|
21
|
-
},
|
22
|
-
isWebOnly: function() {
|
23
|
-
return isWebOnly;
|
24
|
-
},
|
25
|
-
isBeyondReact17: function() {
|
26
|
-
return isBeyondReact17;
|
27
|
-
},
|
28
|
-
isReact18: function() {
|
29
|
-
return isReact18;
|
30
|
-
},
|
31
|
-
isTypescript: function() {
|
32
|
-
return isTypescript;
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
33
17
|
}
|
18
|
+
return to;
|
19
|
+
};
|
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 project_exports = {};
|
30
|
+
__export(project_exports, {
|
31
|
+
isApiOnly: () => isApiOnly,
|
32
|
+
isBeyondReact17: () => isBeyondReact17,
|
33
|
+
isDepExists: () => isDepExists,
|
34
|
+
isPackageInstalled: () => isPackageInstalled,
|
35
|
+
isReact18: () => isReact18,
|
36
|
+
isTypescript: () => isTypescript,
|
37
|
+
isWebOnly: () => isWebOnly
|
34
38
|
});
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
const debug = (0,
|
39
|
+
module.exports = __toCommonJS(project_exports);
|
40
|
+
var import_path = __toESM(require("path"));
|
41
|
+
var import_pkg_up = __toESM(require("../../../compiled/pkg-up"));
|
42
|
+
var import_commands = require("../commands");
|
43
|
+
var import_compiled = require("../../compiled");
|
44
|
+
var import_common = require("../common");
|
45
|
+
var import_ensure = require("../ensure");
|
46
|
+
const debug = (0, import_common.createDebugger)("judge-depExists");
|
43
47
|
const isDepExists = (appDirectory, name) => {
|
44
|
-
const pkgPath =
|
45
|
-
if (!
|
48
|
+
const pkgPath = import_path.default.resolve(appDirectory, "./package.json");
|
49
|
+
if (!import_compiled.fs.existsSync(pkgPath)) {
|
46
50
|
debug(`can't find package.json under: %s`, appDirectory);
|
47
51
|
return false;
|
48
52
|
}
|
@@ -53,7 +57,7 @@ const isDepExists = (appDirectory, name) => {
|
|
53
57
|
const isPackageInstalled = (name, resolvePaths) => {
|
54
58
|
try {
|
55
59
|
require.resolve(name, {
|
56
|
-
paths: (0,
|
60
|
+
paths: (0, import_ensure.ensureArray)(resolvePaths)
|
57
61
|
});
|
58
62
|
return true;
|
59
63
|
} catch (err) {
|
@@ -61,26 +65,26 @@ const isPackageInstalled = (name, resolvePaths) => {
|
|
61
65
|
}
|
62
66
|
};
|
63
67
|
const isApiOnly = async (appDirectory, entryDir, apiDir) => {
|
64
|
-
const existApi = await
|
65
|
-
const existSrc = await
|
66
|
-
const options = (0,
|
68
|
+
const existApi = await import_compiled.fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : import_path.default.join(appDirectory, "api"));
|
69
|
+
const existSrc = await import_compiled.fs.pathExists(import_path.default.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"));
|
70
|
+
const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
|
67
71
|
if (options["api-only"]) {
|
68
72
|
return true;
|
69
73
|
}
|
70
74
|
return existApi && !existSrc;
|
71
75
|
};
|
72
76
|
const isWebOnly = async () => {
|
73
|
-
const options = (0,
|
77
|
+
const options = (0, import_compiled.minimist)((0, import_commands.getArgv)());
|
74
78
|
return Boolean(options["web-only"]);
|
75
79
|
};
|
76
80
|
const isBeyondReact17 = (cwd) => {
|
77
|
-
const pkgPath =
|
81
|
+
const pkgPath = import_pkg_up.default.sync({
|
78
82
|
cwd
|
79
83
|
});
|
80
84
|
if (!pkgPath) {
|
81
85
|
return false;
|
82
86
|
}
|
83
|
-
const pkgInfo = JSON.parse(
|
87
|
+
const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
|
84
88
|
const deps = {
|
85
89
|
...pkgInfo.devDependencies,
|
86
90
|
...pkgInfo.dependencies
|
@@ -88,14 +92,14 @@ const isBeyondReact17 = (cwd) => {
|
|
88
92
|
if (typeof deps.react !== "string") {
|
89
93
|
return false;
|
90
94
|
}
|
91
|
-
return
|
95
|
+
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=17.0.0");
|
92
96
|
};
|
93
97
|
const isReact18 = (cwd) => {
|
94
|
-
const pkgPath =
|
95
|
-
if (!
|
98
|
+
const pkgPath = import_path.default.join(cwd, "package.json");
|
99
|
+
if (!import_compiled.fs.existsSync(pkgPath)) {
|
96
100
|
return false;
|
97
101
|
}
|
98
|
-
const pkgInfo = JSON.parse(
|
102
|
+
const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
|
99
103
|
const deps = {
|
100
104
|
...pkgInfo.devDependencies,
|
101
105
|
...pkgInfo.dependencies
|
@@ -103,6 +107,16 @@ const isReact18 = (cwd) => {
|
|
103
107
|
if (typeof deps.react !== "string") {
|
104
108
|
return false;
|
105
109
|
}
|
106
|
-
return
|
110
|
+
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
|
107
111
|
};
|
108
|
-
const isTypescript = (root) =>
|
112
|
+
const isTypescript = (root) => import_compiled.fs.existsSync(import_path.default.resolve(root, "./tsconfig.json"));
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
114
|
+
0 && (module.exports = {
|
115
|
+
isApiOnly,
|
116
|
+
isBeyondReact17,
|
117
|
+
isDepExists,
|
118
|
+
isPackageInstalled,
|
119
|
+
isReact18,
|
120
|
+
isTypescript,
|
121
|
+
isWebOnly
|
122
|
+
});
|
package/dist/cjs/cli/is/type.js
CHANGED
@@ -1,43 +1,34 @@
|
|
1
1
|
"use strict";
|
2
|
-
Object.defineProperty
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
6
7
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
return isString;
|
15
|
-
},
|
16
|
-
isUndefined: function() {
|
17
|
-
return isUndefined;
|
18
|
-
},
|
19
|
-
isArray: function() {
|
20
|
-
return isArray;
|
21
|
-
},
|
22
|
-
isFunction: function() {
|
23
|
-
return isFunction;
|
24
|
-
},
|
25
|
-
isObject: function() {
|
26
|
-
return isObject;
|
27
|
-
},
|
28
|
-
isPlainObject: function() {
|
29
|
-
return isPlainObject;
|
30
|
-
},
|
31
|
-
isPromise: function() {
|
32
|
-
return isPromise;
|
33
|
-
},
|
34
|
-
isRegExp: function() {
|
35
|
-
return isRegExp;
|
36
|
-
},
|
37
|
-
isEmpty: function() {
|
38
|
-
return isEmpty;
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
39
15
|
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var type_exports = {};
|
20
|
+
__export(type_exports, {
|
21
|
+
isArray: () => isArray,
|
22
|
+
isEmpty: () => isEmpty,
|
23
|
+
isFunction: () => isFunction,
|
24
|
+
isObject: () => isObject,
|
25
|
+
isPlainObject: () => isPlainObject,
|
26
|
+
isPromise: () => isPromise,
|
27
|
+
isRegExp: () => isRegExp,
|
28
|
+
isString: () => isString,
|
29
|
+
isUndefined: () => isUndefined
|
40
30
|
});
|
31
|
+
module.exports = __toCommonJS(type_exports);
|
41
32
|
function isString(str) {
|
42
33
|
return typeof str === "string";
|
43
34
|
}
|
@@ -63,3 +54,15 @@ function isRegExp(obj) {
|
|
63
54
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
64
55
|
}
|
65
56
|
const isEmpty = (o) => Object.entries(o).length === 0 && o.constructor === Object;
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
58
|
+
0 && (module.exports = {
|
59
|
+
isArray,
|
60
|
+
isEmpty,
|
61
|
+
isFunction,
|
62
|
+
isObject,
|
63
|
+
isPlainObject,
|
64
|
+
isPromise,
|
65
|
+
isRegExp,
|
66
|
+
isString,
|
67
|
+
isUndefined
|
68
|
+
});
|