@modern-js/utils 2.35.0 → 2.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. package/dist/cjs/cli/alias.js +48 -49
  2. package/dist/cjs/cli/applyOptionsChain.js +30 -13
  3. package/dist/cjs/cli/babel.js +36 -26
  4. package/dist/cjs/cli/commands.js +29 -21
  5. package/dist/cjs/cli/common.js +29 -20
  6. package/dist/cjs/cli/config.js +24 -7
  7. package/dist/cjs/cli/constants/chainId.js +27 -10
  8. package/dist/cjs/cli/constants/index.js +86 -104
  9. package/dist/cjs/cli/ensure.js +37 -18
  10. package/dist/cjs/cli/fs.js +29 -19
  11. package/dist/cjs/cli/get/config.js +26 -9
  12. package/dist/cjs/cli/get/data.js +67 -54
  13. package/dist/cjs/cli/get/index.js +46 -25
  14. package/dist/cjs/cli/index.js +58 -23
  15. package/dist/cjs/cli/is/config.js +45 -41
  16. package/dist/cjs/cli/is/env.js +32 -29
  17. package/dist/cjs/cli/is/index.js +26 -8
  18. package/dist/cjs/cli/is/project.js +67 -53
  19. package/dist/cjs/cli/is/type.js +39 -36
  20. package/dist/cjs/cli/logger.js +25 -125
  21. package/dist/cjs/cli/monorepo.js +58 -58
  22. package/dist/cjs/cli/package.js +34 -26
  23. package/dist/cjs/cli/path.js +64 -54
  24. package/dist/cjs/cli/port.js +39 -13
  25. package/dist/cjs/cli/prettyInstructions.js +50 -34
  26. package/dist/cjs/cli/require.js +36 -31
  27. package/dist/cjs/cli/runtimeExports.js +42 -16
  28. package/dist/cjs/cli/watch.js +41 -22
  29. package/dist/cjs/compiled.js +127 -138
  30. package/dist/cjs/import.js +25 -15
  31. package/dist/cjs/index.js +24 -6
  32. package/dist/cjs/universal/constants.js +29 -21
  33. package/dist/cjs/universal/formatWebpack.js +28 -18
  34. package/dist/cjs/universal/pluginDagSort.js +25 -8
  35. package/dist/esm/cli/alias.js +13 -25
  36. package/dist/esm/cli/applyOptionsChain.js +4 -1
  37. package/dist/esm/cli/babel.js +6 -2
  38. package/dist/esm/cli/commands.js +10 -4
  39. package/dist/esm/cli/common.js +8 -3
  40. package/dist/esm/cli/config.js +4 -1
  41. package/dist/esm/cli/constants/chainId.js +7 -4
  42. package/dist/esm/cli/constants/index.js +64 -31
  43. package/dist/esm/cli/ensure.js +6 -2
  44. package/dist/esm/cli/fs.js +6 -2
  45. package/dist/esm/cli/get/config.js +4 -1
  46. package/dist/esm/cli/get/data.js +18 -8
  47. package/dist/esm/cli/get/index.js +6 -2
  48. package/dist/esm/cli/is/config.js +23 -17
  49. package/dist/esm/cli/is/env.js +12 -8
  50. package/dist/esm/cli/is/index.js +0 -1
  51. package/dist/esm/cli/is/project.js +17 -8
  52. package/dist/esm/cli/is/type.js +20 -9
  53. package/dist/esm/cli/logger.js +4 -123
  54. package/dist/esm/cli/monorepo.js +14 -16
  55. package/dist/esm/cli/package.js +10 -4
  56. package/dist/esm/cli/path.js +24 -11
  57. package/dist/esm/cli/port.js +6 -3
  58. package/dist/esm/cli/prettyInstructions.js +8 -5
  59. package/dist/esm/cli/require.js +15 -8
  60. package/dist/esm/cli/runtimeExports.js +6 -3
  61. package/dist/esm/cli/watch.js +10 -6
  62. package/dist/esm/compiled.js +65 -31
  63. package/dist/esm/import.js +6 -3
  64. package/dist/esm/universal/constants.js +10 -4
  65. package/dist/esm/universal/formatWebpack.js +8 -5
  66. package/dist/esm/universal/pluginDagSort.js +5 -2
  67. package/dist/esm-node/cli/alias.js +11 -22
  68. package/dist/esm-node/cli/applyOptionsChain.js +4 -1
  69. package/dist/esm-node/cli/babel.js +6 -2
  70. package/dist/esm-node/cli/commands.js +10 -4
  71. package/dist/esm-node/cli/common.js +8 -3
  72. package/dist/esm-node/cli/config.js +4 -1
  73. package/dist/esm-node/cli/constants/chainId.js +7 -4
  74. package/dist/esm-node/cli/constants/index.js +64 -31
  75. package/dist/esm-node/cli/ensure.js +6 -2
  76. package/dist/esm-node/cli/fs.js +6 -2
  77. package/dist/esm-node/cli/get/config.js +4 -1
  78. package/dist/esm-node/cli/get/data.js +18 -8
  79. package/dist/esm-node/cli/get/index.js +6 -2
  80. package/dist/esm-node/cli/is/config.js +23 -17
  81. package/dist/esm-node/cli/is/env.js +12 -6
  82. package/dist/esm-node/cli/is/index.js +0 -1
  83. package/dist/esm-node/cli/is/project.js +16 -7
  84. package/dist/esm-node/cli/is/type.js +20 -9
  85. package/dist/esm-node/cli/logger.js +4 -108
  86. package/dist/esm-node/cli/monorepo.js +14 -18
  87. package/dist/esm-node/cli/package.js +10 -4
  88. package/dist/esm-node/cli/path.js +24 -11
  89. package/dist/esm-node/cli/port.js +5 -2
  90. package/dist/esm-node/cli/prettyInstructions.js +8 -7
  91. package/dist/esm-node/cli/require.js +15 -8
  92. package/dist/esm-node/cli/runtimeExports.js +4 -1
  93. package/dist/esm-node/cli/watch.js +6 -2
  94. package/dist/esm-node/compiled.js +65 -31
  95. package/dist/esm-node/import.js +5 -2
  96. package/dist/esm-node/universal/constants.js +10 -4
  97. package/dist/esm-node/universal/formatWebpack.js +8 -5
  98. package/dist/esm-node/universal/pluginDagSort.js +5 -2
  99. package/dist/types/cli/alias.d.ts +0 -5
  100. package/dist/types/cli/constants/chainId.d.ts +2 -2
  101. package/dist/types/cli/is/env.d.ts +1 -2
  102. package/dist/types/cli/is/index.d.ts +0 -1
  103. package/dist/types/cli/logger.d.ts +1 -64
  104. package/dist/types/cli/monorepo.d.ts +0 -1
  105. package/package.json +6 -84
  106. package/dist/cjs/cli/is/platform.js +0 -21
  107. package/dist/cjs/runtime/nestedRoutes.js +0 -149
  108. package/dist/cjs/runtime/remixRouter.js +0 -6
  109. package/dist/cjs/runtime/router.js +0 -6
  110. package/dist/cjs/runtime-browser/index.js +0 -6
  111. package/dist/cjs/runtime-browser/parsed.js +0 -28
  112. package/dist/cjs/runtime-node/index.js +0 -28
  113. package/dist/cjs/runtime-node/loaderContext/createLoaderCtx.js +0 -34
  114. package/dist/cjs/runtime-node/loaderContext/createRequestCtx.js +0 -38
  115. package/dist/cjs/runtime-node/loaderContext/index.js +0 -22
  116. package/dist/cjs/runtime-node/nestedRoutes.js +0 -28
  117. package/dist/cjs/runtime-node/router.js +0 -6
  118. package/dist/cjs/runtime-node/serialize.js +0 -17
  119. package/dist/cjs/runtime-node/storage.js +0 -48
  120. package/dist/cjs/universal/time.js +0 -38
  121. package/dist/compiled/gradient-string/index.d.ts +0 -1
  122. package/dist/compiled/gradient-string/index.js +0 -1
  123. package/dist/compiled/gradient-string/license +0 -21
  124. package/dist/compiled/gradient-string/package.json +0 -1
  125. package/dist/compiled/webpack-dev-middleware/index.js +0 -7
  126. package/dist/compiled/webpack-dev-middleware/license +0 -20
  127. package/dist/compiled/webpack-dev-middleware/package.json +0 -1
  128. package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
  129. package/dist/esm/cli/is/platform.js +0 -6
  130. package/dist/esm/runtime/nestedRoutes.js +0 -163
  131. package/dist/esm/runtime/remixRouter.js +0 -1
  132. package/dist/esm/runtime/router.js +0 -1
  133. package/dist/esm/runtime-browser/index.js +0 -1
  134. package/dist/esm/runtime-browser/parsed.js +0 -18
  135. package/dist/esm/runtime-node/index.js +0 -6
  136. package/dist/esm/runtime-node/loaderContext/createLoaderCtx.js +0 -20
  137. package/dist/esm/runtime-node/loaderContext/createRequestCtx.js +0 -24
  138. package/dist/esm/runtime-node/loaderContext/index.js +0 -3
  139. package/dist/esm/runtime-node/nestedRoutes.js +0 -20
  140. package/dist/esm/runtime-node/router.js +0 -1
  141. package/dist/esm/runtime-node/serialize.js +0 -6
  142. package/dist/esm/runtime-node/storage.js +0 -36
  143. package/dist/esm/universal/time.js +0 -29
  144. package/dist/esm-node/cli/is/platform.js +0 -2
  145. package/dist/esm-node/runtime/nestedRoutes.js +0 -129
  146. package/dist/esm-node/runtime/remixRouter.js +0 -1
  147. package/dist/esm-node/runtime/router.js +0 -1
  148. package/dist/esm-node/runtime-browser/index.js +0 -1
  149. package/dist/esm-node/runtime-browser/parsed.js +0 -18
  150. package/dist/esm-node/runtime-node/index.js +0 -6
  151. package/dist/esm-node/runtime-node/loaderContext/createLoaderCtx.js +0 -15
  152. package/dist/esm-node/runtime-node/loaderContext/createRequestCtx.js +0 -19
  153. package/dist/esm-node/runtime-node/loaderContext/index.js +0 -3
  154. package/dist/esm-node/runtime-node/nestedRoutes.js +0 -18
  155. package/dist/esm-node/runtime-node/router.js +0 -1
  156. package/dist/esm-node/runtime-node/serialize.js +0 -6
  157. package/dist/esm-node/runtime-node/storage.js +0 -38
  158. package/dist/esm-node/universal/time.js +0 -28
  159. package/dist/types/cli/is/platform.d.ts +0 -2
  160. package/dist/types/runtime/nestedRoutes.d.ts +0 -13
  161. package/dist/types/runtime/remixRouter.d.ts +0 -1
  162. package/dist/types/runtime/router.d.ts +0 -1
  163. package/dist/types/runtime-browser/index.d.ts +0 -1
  164. package/dist/types/runtime-browser/parsed.d.ts +0 -1
  165. package/dist/types/runtime-node/index.d.ts +0 -10
  166. package/dist/types/runtime-node/loaderContext/createLoaderCtx.d.ts +0 -7
  167. package/dist/types/runtime-node/loaderContext/createRequestCtx.d.ts +0 -7
  168. package/dist/types/runtime-node/loaderContext/index.d.ts +0 -4
  169. package/dist/types/runtime-node/nestedRoutes.d.ts +0 -3
  170. package/dist/types/runtime-node/router.d.ts +0 -1
  171. package/dist/types/runtime-node/serialize.d.ts +0 -1
  172. package/dist/types/runtime-node/storage.d.ts +0 -5
  173. package/dist/types/universal/time.d.ts +0 -1
@@ -9,7 +9,7 @@ import { INTERNAL_CLI_PLUGINS } from "../constants";
9
9
  import { isDepExists } from "../is";
10
10
  import { canUsePnpm, canUseYarn } from "../package";
11
11
  var MAX_TIMES = 5;
12
- export function getPackageManager() {
12
+ function getPackageManager() {
13
13
  return _getPackageManager.apply(this, arguments);
14
14
  }
15
15
  function _getPackageManager() {
@@ -75,7 +75,7 @@ function _getPackageManager() {
75
75
  });
76
76
  return _getPackageManager.apply(this, arguments);
77
77
  }
78
- export var getCoreJsVersion = function(corejsPkgPath) {
78
+ var getCoreJsVersion = function(corejsPkgPath) {
79
79
  try {
80
80
  var version = fs.readJSONSync(corejsPkgPath).version;
81
81
  var _version_split = _sliced_to_array(version.split("."), 2), major = _version_split[0], minor = _version_split[1];
@@ -84,7 +84,7 @@ export var getCoreJsVersion = function(corejsPkgPath) {
84
84
  return "3";
85
85
  }
86
86
  };
87
- export var getAntdMajorVersion = function(appDirectory) {
87
+ var getAntdMajorVersion = function(appDirectory) {
88
88
  try {
89
89
  var pkgJsonPath = require.resolve("antd/package.json", {
90
90
  paths: [
@@ -97,17 +97,17 @@ export var getAntdMajorVersion = function(appDirectory) {
97
97
  return null;
98
98
  }
99
99
  };
100
- export var defaults = [
100
+ var defaults = [
101
101
  "> 0.01%",
102
102
  "not dead",
103
103
  "not op_mini all"
104
104
  ];
105
- export var getBrowserslist = function(appDirectory) {
105
+ var getBrowserslist = function(appDirectory) {
106
106
  return browserslist.loadConfig({
107
107
  path: appDirectory
108
108
  }) || defaults;
109
109
  };
110
- export function getInternalPlugins(appDirectory) {
110
+ function getInternalPlugins(appDirectory) {
111
111
  var internalPlugins = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : INTERNAL_CLI_PLUGINS;
112
112
  return _to_consumable_array(Object.keys(internalPlugins).filter(function(name) {
113
113
  var config = internalPlugins[name];
@@ -124,10 +124,20 @@ export function getInternalPlugins(appDirectory) {
124
124
  }
125
125
  }));
126
126
  }
127
- export var readTsConfig = function(root) {
127
+ var readTsConfig = function(root) {
128
128
  return readTsConfigByFile(path.resolve(root, "./tsconfig.json"));
129
129
  };
130
- export var readTsConfigByFile = function(filename) {
130
+ var readTsConfigByFile = function(filename) {
131
131
  var content = fs.readFileSync(path.resolve(filename), "utf-8");
132
132
  return json5.parse(content);
133
133
  };
134
+ export {
135
+ defaults,
136
+ getAntdMajorVersion,
137
+ getBrowserslist,
138
+ getCoreJsVersion,
139
+ getInternalPlugins,
140
+ getPackageManager,
141
+ readTsConfig,
142
+ readTsConfigByFile
143
+ };
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
4
  import { CONFIG_FILE_EXTENSIONS } from "../constants";
5
5
  import { findExists } from "../fs";
6
- export var getServerConfig = function() {
6
+ var getServerConfig = function() {
7
7
  var _ref = _async_to_generator(function(appDirectory, configFile) {
8
8
  var configFilePath;
9
9
  return _ts_generator(this, function(_state) {
@@ -20,9 +20,13 @@ export var getServerConfig = function() {
20
20
  return _ref.apply(this, arguments);
21
21
  };
22
22
  }();
23
- export var getTargetDir = function(from, baseDir, targetBaseDir) {
23
+ var getTargetDir = function(from, baseDir, targetBaseDir) {
24
24
  var relativePath = path.relative(baseDir, from);
25
25
  return path.resolve(targetBaseDir, relativePath);
26
26
  };
27
27
  export * from "./data";
28
28
  export * from "./config";
29
+ export {
30
+ getServerConfig,
31
+ getTargetDir
32
+ };
@@ -1,12 +1,11 @@
1
1
  import { MAIN_ENTRY_NAME } from "../constants";
2
2
  import { isEmpty } from "./type";
3
- export var isSSR = function(config) {
4
- var _server, _server1;
3
+ var isSSR = function(config) {
5
4
  var server = config.server;
6
- if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
5
+ if (server === null || server === void 0 ? void 0 : server.ssr) {
7
6
  return true;
8
7
  }
9
- if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
8
+ if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
10
9
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
11
10
  try {
12
11
  for (var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
@@ -32,33 +31,40 @@ export var isSSR = function(config) {
32
31
  }
33
32
  return false;
34
33
  };
35
- export var isUseSSRBundle = function(config) {
36
- var _output;
34
+ var isUseSSRBundle = function(config) {
37
35
  var output = config.output;
38
- if ((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) {
36
+ if (output === null || output === void 0 ? void 0 : output.ssg) {
39
37
  return true;
40
38
  }
41
39
  return isSSR(config);
42
40
  };
43
- export var isServiceWorker = function(config) {
44
- var _deploy_worker, _deploy, _output;
41
+ var isServiceWorker = function(config) {
42
+ var _deploy_worker;
45
43
  var output = config.output, deploy = config.deploy;
46
- if (((_deploy = deploy) === null || _deploy === void 0 ? void 0 : (_deploy_worker = _deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && (((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) || isSSR(config))) {
44
+ if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output === null || output === void 0 ? void 0 : output.ssg) || isSSR(config))) {
47
45
  return true;
48
46
  }
49
47
  return false;
50
48
  };
51
- export var isRouterV5 = function(config) {
52
- var _config_runtime, _config_runtime_router, _config_runtime1, _config;
53
- return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime1 = _config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
49
+ var isRouterV5 = function(config) {
50
+ var _config_runtime, _config_runtime_router, _config_runtime1;
51
+ return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
54
52
  };
55
- export var isSSGEntry = function(config, entryName, entrypoints) {
56
- var _config_source, _ssgConfig, _ssgConfig1;
53
+ var isSSGEntry = function(config, entryName, entrypoints) {
54
+ var _config_source;
57
55
  var ssgConfig = config.output.ssg;
58
- var useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof ((_ssgConfig = ssgConfig) === null || _ssgConfig === void 0 ? void 0 : _ssgConfig[0]) === "function" || Boolean((_ssgConfig1 = ssgConfig) === null || _ssgConfig1 === void 0 ? void 0 : _ssgConfig1[entryName]);
56
+ var 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]);
59
57
  return useSSG;
60
58
  };
61
- export var isSingleEntry = function(entrypoints) {
59
+ var isSingleEntry = function(entrypoints) {
62
60
  var mainEntryName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : MAIN_ENTRY_NAME;
63
61
  return entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
64
62
  };
63
+ export {
64
+ isRouterV5,
65
+ isSSGEntry,
66
+ isSSR,
67
+ isServiceWorker,
68
+ isSingleEntry,
69
+ isUseSSRBundle
70
+ };
@@ -1,18 +1,22 @@
1
- export var getNodeEnv = function() {
1
+ var getNodeEnv = function() {
2
2
  return process.env.NODE_ENV || "development";
3
3
  };
4
- export var isDev = function() {
4
+ var isDev = function() {
5
5
  return getNodeEnv() === "development";
6
6
  };
7
- export var isProd = function() {
7
+ var isProd = function() {
8
8
  return getNodeEnv() === "production";
9
9
  };
10
- export var isTest = function() {
10
+ var isTest = function() {
11
11
  return getNodeEnv() === "test";
12
12
  };
13
- export var isProdProfile = function() {
14
- return isProd() && process.argv.includes("--profile");
13
+ var isBrowser = function() {
14
+ return typeof window !== "undefined";
15
15
  };
16
- export var isFastRefresh = function() {
17
- return isDev() && process.env.FAST_REFRESH !== "false";
16
+ export {
17
+ getNodeEnv,
18
+ isBrowser,
19
+ isDev,
20
+ isProd,
21
+ isTest
18
22
  };
@@ -1,5 +1,4 @@
1
1
  export * from "./env";
2
- export * from "./platform";
3
2
  export * from "./type";
4
3
  export * from "./config";
5
4
  export * from "./project";
@@ -8,7 +8,7 @@ import { fs, minimist, semver } from "../../compiled";
8
8
  import { createDebugger } from "../common";
9
9
  import { ensureArray } from "../ensure";
10
10
  var debug = createDebugger("judge-depExists");
11
- export var isDepExists = function(appDirectory, name) {
11
+ var isDepExists = function(appDirectory, name) {
12
12
  var pkgPath = path.resolve(appDirectory, "./package.json");
13
13
  if (!fs.existsSync(pkgPath)) {
14
14
  debug("can't find package.json under: %s", appDirectory);
@@ -18,7 +18,7 @@ export var isDepExists = function(appDirectory, name) {
18
18
  var _json_dependencies = json.dependencies, dependencies = _json_dependencies === void 0 ? {} : _json_dependencies, _json_devDependencies = json.devDependencies, devDependencies = _json_devDependencies === void 0 ? {} : _json_devDependencies;
19
19
  return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
20
20
  };
21
- export var isPackageInstalled = function(name, resolvePaths) {
21
+ var isPackageInstalled = function(name, resolvePaths) {
22
22
  try {
23
23
  require.resolve(name, {
24
24
  paths: ensureArray(resolvePaths)
@@ -28,7 +28,7 @@ export var isPackageInstalled = function(name, resolvePaths) {
28
28
  return false;
29
29
  }
30
30
  };
31
- export var isApiOnly = function() {
31
+ var isApiOnly = function() {
32
32
  var _ref = _async_to_generator(function(appDirectory, entryDir, apiDir) {
33
33
  var existApi, existSrc, options;
34
34
  return _ts_generator(this, function(_state) {
@@ -64,7 +64,7 @@ export var isApiOnly = function() {
64
64
  return _ref.apply(this, arguments);
65
65
  };
66
66
  }();
67
- export var isWebOnly = function() {
67
+ var isWebOnly = function() {
68
68
  var _ref = _async_to_generator(function() {
69
69
  var options;
70
70
  return _ts_generator(this, function(_state) {
@@ -79,9 +79,9 @@ export var isWebOnly = function() {
79
79
  return _ref.apply(this, arguments);
80
80
  };
81
81
  }();
82
- export var isBeyondReact17 = function(cwd) {
82
+ var isBeyondReact17 = function(cwd) {
83
83
  var pkgPath = pkgUp.sync({
84
- cwd: cwd
84
+ cwd
85
85
  });
86
86
  if (!pkgPath) {
87
87
  return false;
@@ -93,7 +93,7 @@ export var isBeyondReact17 = function(cwd) {
93
93
  }
94
94
  return semver.satisfies(semver.minVersion(deps.react), ">=17.0.0");
95
95
  };
96
- export var isReact18 = function(cwd) {
96
+ var isReact18 = function(cwd) {
97
97
  var pkgPath = path.join(cwd, "package.json");
98
98
  if (!fs.existsSync(pkgPath)) {
99
99
  return false;
@@ -105,6 +105,15 @@ export var isReact18 = function(cwd) {
105
105
  }
106
106
  return semver.satisfies(semver.minVersion(deps.react), ">=18.0.0");
107
107
  };
108
- export var isTypescript = function(root) {
108
+ var isTypescript = function(root) {
109
109
  return fs.existsSync(path.resolve(root, "./tsconfig.json"));
110
110
  };
111
+ export {
112
+ isApiOnly,
113
+ isBeyondReact17,
114
+ isDepExists,
115
+ isPackageInstalled,
116
+ isReact18,
117
+ isTypescript,
118
+ isWebOnly
119
+ };
@@ -1,27 +1,38 @@
1
- export function isString(str) {
1
+ function isString(str) {
2
2
  return typeof str === "string";
3
3
  }
4
- export function isUndefined(obj) {
4
+ function isUndefined(obj) {
5
5
  return typeof obj === "undefined";
6
6
  }
7
- export function isArray(obj) {
7
+ function isArray(obj) {
8
8
  return Array.isArray(obj);
9
9
  }
10
- export function isFunction(func) {
10
+ function isFunction(func) {
11
11
  return typeof func === "function";
12
12
  }
13
- export function isObject(obj) {
13
+ function isObject(obj) {
14
14
  return obj !== null && typeof obj === "object";
15
15
  }
16
- export function isPlainObject(obj) {
16
+ function isPlainObject(obj) {
17
17
  return isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]";
18
18
  }
19
- export function isPromise(obj) {
19
+ function isPromise(obj) {
20
20
  return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
21
21
  }
22
- export function isRegExp(obj) {
22
+ function isRegExp(obj) {
23
23
  return Object.prototype.toString.call(obj) === "[object RegExp]";
24
24
  }
25
- export var isEmpty = function(o) {
25
+ var isEmpty = function(o) {
26
26
  return Object.entries(o).length === 0 && o.constructor === Object;
27
27
  };
28
+ export {
29
+ isArray,
30
+ isEmpty,
31
+ isFunction,
32
+ isObject,
33
+ isPlainObject,
34
+ isPromise,
35
+ isRegExp,
36
+ isString,
37
+ isUndefined
38
+ };
@@ -1,124 +1,5 @@
1
- import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
2
- import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
4
- import { _ as _to_array } from "@swc/helpers/_/_to_array";
5
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
6
- import chalk from "../../compiled/chalk";
7
- var LOG_LEVEL = {
8
- error: 0,
9
- warn: 1,
10
- info: 2,
11
- debug: 3,
12
- log: 4
1
+ import { logger, createLogger } from "rslog";
2
+ export {
3
+ createLogger,
4
+ logger
13
5
  };
14
- var LOG_TYPES = {
15
- error: {
16
- color: "red",
17
- label: "error",
18
- level: "error"
19
- },
20
- info: {
21
- color: "cyan",
22
- label: "info",
23
- level: "info"
24
- },
25
- success: {
26
- color: "green",
27
- label: "Success",
28
- level: "info"
29
- },
30
- warn: {
31
- color: "yellow",
32
- label: "warn",
33
- level: "warn"
34
- },
35
- debug: {
36
- color: "red",
37
- label: "debug",
38
- level: "debug"
39
- },
40
- log: {
41
- level: "log"
42
- }
43
- };
44
- var DEFAULT_CONFIG = {
45
- displayLabel: true,
46
- uppercaseLabel: false
47
- };
48
- var errorStackRegExp = /^\s*at\s.*:\d+:\d+[\s)]*$/;
49
- var anonymousErrorStackRegExp = /^\s*at\s.*\(<anonymous>\)$/;
50
- export var isErrorStackMessage = function(message) {
51
- return errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
52
- };
53
- var Logger = /* @__PURE__ */ function() {
54
- "use strict";
55
- function Logger2() {
56
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
57
- var _this = this;
58
- _class_call_check(this, Logger2);
59
- this.level = options.level || LOG_TYPES.log.level;
60
- this.config = _object_spread({}, DEFAULT_CONFIG, options.config || {});
61
- this.types = _object_spread({}, LOG_TYPES, options.types || {});
62
- this.longestLabel = this.getLongestLabel();
63
- Object.keys(this.types).forEach(function(type) {
64
- _this[type] = _this._log.bind(_this, type);
65
- });
66
- }
67
- var _proto = Logger2.prototype;
68
- _proto._log = function _log(type, message) {
69
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
70
- args[_key - 2] = arguments[_key];
71
- }
72
- var _console;
73
- if (message === void 0 || message === null) {
74
- console.log();
75
- return;
76
- }
77
- if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
78
- return;
79
- }
80
- var label = "";
81
- var text = "";
82
- var logType = this.types[type];
83
- if (this.config.displayLabel && logType.label) {
84
- label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
85
- label = label.padEnd(this.longestLabel.length);
86
- label = chalk.bold(logType.color ? chalk[logType.color](label) : label);
87
- }
88
- if (_instanceof(message, Error)) {
89
- if (message.stack) {
90
- var _message_stack_split = _to_array(message.stack.split("\n")), name = _message_stack_split[0], rest = _message_stack_split.slice(1);
91
- text = "".concat(name, "\n").concat(chalk.grey(rest.join("\n")));
92
- } else {
93
- text = message.message;
94
- }
95
- } else if (logType.level === "error" && typeof message === "string") {
96
- var lines = message.split("\n");
97
- text = lines.map(function(line) {
98
- return isErrorStackMessage(line) ? chalk.gray(line) : line;
99
- }).join("\n");
100
- } else {
101
- text = "".concat(message);
102
- }
103
- var log = label.length > 0 ? "".concat(label, " ").concat(text) : text;
104
- (_console = console).log.apply(_console, [
105
- log
106
- ].concat(_to_consumable_array(args)));
107
- };
108
- _proto.getLongestLabel = function getLongestLabel() {
109
- var _this = this;
110
- var longestLabel = "";
111
- Object.keys(this.types).forEach(function(type) {
112
- var _this_types_type = _this.types[type], _this_types_type_label = _this_types_type.label, label = _this_types_type_label === void 0 ? "" : _this_types_type_label;
113
- if (label.length > longestLabel.length) {
114
- longestLabel = label;
115
- }
116
- });
117
- return longestLabel;
118
- };
119
- return Logger2;
120
- }();
121
- var logger = new Logger();
122
- logger.Logger = Logger;
123
- export { Logger };
124
- export { logger };
@@ -1,4 +1,3 @@
1
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
1
  import fs from "fs";
3
2
  import path from "path";
4
3
  import { glob, yaml } from "../compiled";
@@ -8,10 +7,10 @@ var WORKSPACE_FILES = {
8
7
  PNPM: "pnpm-workspace.yaml",
9
8
  LERNA: "lerna.json"
10
9
  };
11
- export var isLerna = function(root) {
10
+ var isLerna = function(root) {
12
11
  return fs.existsSync(path.join(root, WORKSPACE_FILES.LERNA));
13
12
  };
14
- export var isYarnWorkspaces = function(root) {
13
+ var isYarnWorkspaces = function(root) {
15
14
  var _json_workspaces;
16
15
  var pkg = path.join(root, WORKSPACE_FILES.YARN);
17
16
  if (!fs.existsSync(pkg)) {
@@ -20,22 +19,13 @@ export var isYarnWorkspaces = function(root) {
20
19
  var json = JSON.parse(fs.readFileSync(pkg, "utf8"));
21
20
  return Boolean((_json_workspaces = json.workspaces) === null || _json_workspaces === void 0 ? void 0 : _json_workspaces.packages);
22
21
  };
23
- export var isPnpmWorkspaces = function(root) {
22
+ var isPnpmWorkspaces = function(root) {
24
23
  return fs.existsSync(path.join(root, WORKSPACE_FILES.PNPM));
25
24
  };
26
- export var isMonorepo = function(root) {
25
+ var isMonorepo = function(root) {
27
26
  return isLerna(root) || isYarnWorkspaces(root) || isPnpmWorkspaces(root);
28
27
  };
29
- export var isModernjsMonorepo = function(root) {
30
- var pkgJsonPath = path.join(root, "package.json");
31
- if (!fs.existsSync(pkgJsonPath)) {
32
- return false;
33
- }
34
- var json = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
35
- var deps = _object_spread({}, json.dependencies || {}, json.devDependencies || {});
36
- return Boolean(deps["@modern-js/monorepo-tools"]);
37
- };
38
- export var findMonorepoRoot = function(appDirectory) {
28
+ var findMonorepoRoot = function(appDirectory) {
39
29
  var maxDepth = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : PACKAGE_MAX_DEPTH;
40
30
  var inMonorepo = false;
41
31
  for (var depth = 0; depth < maxDepth; depth++) {
@@ -47,7 +37,7 @@ export var findMonorepoRoot = function(appDirectory) {
47
37
  }
48
38
  return inMonorepo ? appDirectory : void 0;
49
39
  };
50
- export var getMonorepoPackages = function(root) {
40
+ var getMonorepoPackages = function(root) {
51
41
  var packages = [];
52
42
  if (isYarnWorkspaces(root)) {
53
43
  var json = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
@@ -81,3 +71,11 @@ export var getMonorepoPackages = function(root) {
81
71
  }
82
72
  return [];
83
73
  };
74
+ export {
75
+ findMonorepoRoot,
76
+ getMonorepoPackages,
77
+ isLerna,
78
+ isMonorepo,
79
+ isPnpmWorkspaces,
80
+ isYarnWorkspaces
81
+ };
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import { execa } from "../compiled";
4
- export function getPnpmVersion() {
4
+ function getPnpmVersion() {
5
5
  return _getPnpmVersion.apply(this, arguments);
6
6
  }
7
7
  function _getPnpmVersion() {
@@ -27,7 +27,7 @@ function _getPnpmVersion() {
27
27
  });
28
28
  return _getPnpmVersion.apply(this, arguments);
29
29
  }
30
- export function canUseNpm() {
30
+ function canUseNpm() {
31
31
  return _canUseNpm.apply(this, arguments);
32
32
  }
33
33
  function _canUseNpm() {
@@ -71,7 +71,7 @@ function _canUseNpm() {
71
71
  });
72
72
  return _canUseNpm.apply(this, arguments);
73
73
  }
74
- export function canUseYarn() {
74
+ function canUseYarn() {
75
75
  return _canUseYarn.apply(this, arguments);
76
76
  }
77
77
  function _canUseYarn() {
@@ -115,7 +115,7 @@ function _canUseYarn() {
115
115
  });
116
116
  return _canUseYarn.apply(this, arguments);
117
117
  }
118
- export function canUsePnpm() {
118
+ function canUsePnpm() {
119
119
  return _canUsePnpm.apply(this, arguments);
120
120
  }
121
121
  function _canUsePnpm() {
@@ -159,3 +159,9 @@ function _canUsePnpm() {
159
159
  });
160
160
  return _canUsePnpm.apply(this, arguments);
161
161
  }
162
+ export {
163
+ canUseNpm,
164
+ canUsePnpm,
165
+ canUseYarn,
166
+ getPnpmVersion
167
+ };
@@ -3,21 +3,21 @@ import path from "path";
3
3
  import os from "os";
4
4
  import fs from "fs";
5
5
  import { nanoid, upath } from "../compiled";
6
- export var isPathString = function(test) {
6
+ var isPathString = function(test) {
7
7
  return path.posix.basename(test) !== test || path.win32.basename(test) !== test;
8
8
  };
9
- export var isRelativePath = function(test) {
9
+ var isRelativePath = function(test) {
10
10
  return /^\.\.?($|[\\/])/.test(test);
11
11
  };
12
- export var normalizeOutputPath = function(s) {
12
+ var normalizeOutputPath = function(s) {
13
13
  return s.replace(/\\/g, "\\\\");
14
14
  };
15
- export var normalizeToPosixPath = function(p) {
15
+ var normalizeToPosixPath = function(p) {
16
16
  return upath.normalizeSafe(path.normalize(p || "")).replace(/^([a-zA-Z]+):/, function(_, m) {
17
17
  return "/".concat(m.toLowerCase());
18
18
  });
19
19
  };
20
- export var getTemplatePath = function(prefix) {
20
+ var getTemplatePath = function(prefix) {
21
21
  var _path;
22
22
  var tmpRoot = fs.realpathSync(os.tmpdir());
23
23
  var parts = [
@@ -27,7 +27,7 @@ export var getTemplatePath = function(prefix) {
27
27
  parts.push(nanoid());
28
28
  return (_path = path).resolve.apply(_path, _to_consumable_array(parts));
29
29
  };
30
- export function getRealTemporaryDirectory() {
30
+ function getRealTemporaryDirectory() {
31
31
  var ret = null;
32
32
  try {
33
33
  ret = os.tmpdir();
@@ -36,18 +36,31 @@ export function getRealTemporaryDirectory() {
36
36
  }
37
37
  return ret;
38
38
  }
39
- export function splitPathString(str) {
39
+ function splitPathString(str) {
40
40
  return str.split(/[\\/]/);
41
41
  }
42
- export var removeLeadingSlash = function(s) {
42
+ var removeLeadingSlash = function(s) {
43
43
  return s.replace(/^\/+/, "");
44
44
  };
45
- export var removeTailSlash = function(s) {
45
+ var removeTailSlash = function(s) {
46
46
  return s.replace(/\/+$/, "");
47
47
  };
48
- export var removeSlash = function(s) {
48
+ var removeSlash = function(s) {
49
49
  return removeLeadingSlash(removeTailSlash(s));
50
50
  };
51
- export var cutNameByHyphen = function(s) {
51
+ var cutNameByHyphen = function(s) {
52
52
  return s.split(/[-_]/)[0];
53
53
  };
54
+ export {
55
+ cutNameByHyphen,
56
+ getRealTemporaryDirectory,
57
+ getTemplatePath,
58
+ isPathString,
59
+ isRelativePath,
60
+ normalizeOutputPath,
61
+ normalizeToPosixPath,
62
+ removeLeadingSlash,
63
+ removeSlash,
64
+ removeTailSlash,
65
+ splitPathString
66
+ };
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import net from "net";
4
4
  import { chalk } from "../compiled";
5
5
  import { logger } from "./logger";
6
- export var getPort = function() {
6
+ var getPort = function() {
7
7
  var _ref = _async_to_generator(function(port) {
8
8
  var _ref2, _ref_tryLimits, tryLimits, _ref_strictPort, strictPort, _ref_slient, slient, original, found, attempts, e;
9
9
  var _arguments = arguments;
@@ -42,7 +42,7 @@ export var getPort = function() {
42
42
  server.unref();
43
43
  server.on("error", reject);
44
44
  server.listen({
45
- port: port,
45
+ port,
46
46
  host: "0.0.0.0"
47
47
  }, function() {
48
48
  found = true;
@@ -77,7 +77,7 @@ export var getPort = function() {
77
77
  if (strictPort) {
78
78
  throw new Error('Port "'.concat(original, '" is occupied, please choose another one.'));
79
79
  } else if (!slient) {
80
- logger.info("Something is already running on port ".concat(original, ". ").concat(chalk.yellow("Use port ".concat(port, " instead."))));
80
+ logger.info("Port ".concat(original, " is in use. ").concat(chalk.yellow("using port ".concat(port, "."))));
81
81
  }
82
82
  }
83
83
  return [
@@ -91,3 +91,6 @@ export var getPort = function() {
91
91
  return _ref.apply(this, arguments);
92
92
  };
93
93
  }();
94
+ export {
95
+ getPort
96
+ };