@modern-js/utils 2.69.5 → 3.0.0-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.
Files changed (233) hide show
  1. package/dist/cjs/cli/alias.js +76 -70
  2. package/dist/cjs/cli/applyOptionsChain.js +44 -45
  3. package/dist/cjs/cli/babel.js +100 -119
  4. package/dist/cjs/cli/commands.js +61 -59
  5. package/dist/cjs/cli/common.js +45 -37
  6. package/dist/cjs/cli/config.js +36 -30
  7. package/dist/cjs/cli/constants.js +124 -161
  8. package/dist/cjs/cli/ensure.js +52 -45
  9. package/dist/cjs/cli/fs.js +41 -38
  10. package/dist/cjs/cli/get/config.js +43 -38
  11. package/dist/cjs/cli/get/data.js +108 -125
  12. package/dist/cjs/cli/get/index.js +109 -58
  13. package/dist/cjs/cli/index.js +202 -63
  14. package/dist/cjs/cli/is/config.js +75 -71
  15. package/dist/cjs/cli/is/env.js +49 -37
  16. package/dist/cjs/cli/is/index.js +76 -25
  17. package/dist/cjs/cli/is/project.js +139 -135
  18. package/dist/cjs/cli/is/type.js +65 -49
  19. package/dist/cjs/cli/logger.js +36 -27
  20. package/dist/cjs/cli/monorepo.js +100 -96
  21. package/dist/cjs/cli/package.js +85 -82
  22. package/dist/cjs/cli/path.js +101 -82
  23. package/dist/cjs/cli/port.js +71 -74
  24. package/dist/cjs/cli/prettyInstructions.js +106 -116
  25. package/dist/cjs/cli/require.js +116 -136
  26. package/dist/cjs/cli/route.js +67 -77
  27. package/dist/cjs/cli/runtimeExports.js +16 -70
  28. package/dist/cjs/cli/version.js +53 -42
  29. package/dist/cjs/cli/watch.js +79 -72
  30. package/dist/cjs/compiled.js +199 -128
  31. package/dist/cjs/import.js +58 -33
  32. package/dist/cjs/index.js +69 -23
  33. package/dist/cjs/universal/constants.js +77 -67
  34. package/dist/cjs/universal/index.js +33 -25
  35. package/dist/cjs/universal/path.js +33 -27
  36. package/dist/cjs/universal/pluginDagSort.js +69 -68
  37. package/dist/compiled/address/index.js +171 -1
  38. package/dist/compiled/browserslist/index.js +1329 -1
  39. package/dist/compiled/chalk/index.js +2368 -1
  40. package/dist/compiled/chokidar/index.js +4138 -16
  41. package/dist/compiled/chokidar/index.js.LICENSE.txt +41 -0
  42. package/dist/compiled/commander/index.js +1540 -1
  43. package/dist/compiled/debug/index.js +621 -1
  44. package/dist/compiled/dotenv/index.js +101 -1
  45. package/dist/compiled/dotenv-expand/index.js +54 -1
  46. package/dist/compiled/execa/index.js +1738 -1
  47. package/dist/compiled/fast-glob/index.js +4645 -17
  48. package/dist/compiled/fast-glob/index.js.LICENSE.txt +38 -0
  49. package/dist/compiled/filesize/index.js +193 -4
  50. package/dist/compiled/filesize/index.js.LICENSE.txt +7 -0
  51. package/dist/compiled/fs-extra/index.js +2222 -1
  52. package/dist/compiled/glob/index.js +2011 -1
  53. package/dist/compiled/globby/index.js +690 -1
  54. package/dist/compiled/gzip-size/index.js +157 -1
  55. package/dist/compiled/import-lazy/index.js +45 -1
  56. package/dist/compiled/inquirer/index.js +20162 -4
  57. package/dist/compiled/inquirer/index.js.LICENSE.txt +7 -0
  58. package/dist/compiled/js-yaml/index.js +2188 -1
  59. package/dist/compiled/json5/index.js +983 -1
  60. package/dist/compiled/lodash/index.js +0 -4
  61. package/dist/compiled/mime-types/index.js +108 -6
  62. package/dist/compiled/mime-types/index.js.LICENSE.txt +13 -0
  63. package/dist/compiled/minimist/index.js +202 -1
  64. package/dist/compiled/nanoid/index.js +83 -1
  65. package/dist/compiled/ora/index.js +3936 -3
  66. package/dist/compiled/ora/index.js.LICENSE.txt +1 -0
  67. package/dist/compiled/pkg-up/index.js +177 -1
  68. package/dist/compiled/semver/index.js +1779 -1
  69. package/dist/compiled/signale/index.js +1704 -1
  70. package/dist/compiled/slash/index.js +32 -1
  71. package/dist/compiled/strip-ansi/index.js +34 -1
  72. package/dist/compiled/tsconfig-paths/index.js +629 -1
  73. package/dist/compiled/upath/index.js +135 -1
  74. package/dist/compiled/url-join/index.js +61 -1
  75. package/dist/compiled/webpack-chain/index.js +1475 -1
  76. package/dist/esm/cli/alias.mjs +31 -0
  77. package/dist/esm/cli/applyOptionsChain.mjs +16 -0
  78. package/dist/esm/cli/babel.mjs +76 -0
  79. package/dist/esm/cli/commands.mjs +23 -0
  80. package/dist/esm/cli/common.mjs +11 -0
  81. package/dist/esm/cli/config.mjs +5 -0
  82. package/dist/esm/cli/constants.mjs +29 -0
  83. package/dist/esm/cli/ensure.mjs +9 -0
  84. package/dist/esm/cli/fs.mjs +9 -0
  85. package/dist/esm/cli/get/config.mjs +14 -0
  86. package/dist/esm/cli/get/data.mjs +57 -0
  87. package/dist/esm/cli/get/index.mjs +18 -0
  88. package/dist/{esm-node/cli/index.js → esm/cli/index.mjs} +0 -1
  89. package/dist/esm/cli/is/config.mjs +34 -0
  90. package/dist/esm/cli/is/env.mjs +6 -0
  91. package/dist/esm/cli/is/project.mjs +104 -0
  92. package/dist/esm/cli/is/type.mjs +26 -0
  93. package/dist/esm/cli/logger.mjs +2 -0
  94. package/dist/esm/cli/monorepo.mjs +50 -0
  95. package/dist/esm/cli/package.mjs +51 -0
  96. package/dist/esm/cli/path.mjs +35 -0
  97. package/dist/esm/cli/port.mjs +35 -0
  98. package/dist/esm/cli/prettyInstructions.mjs +68 -0
  99. package/dist/esm/cli/require.mjs +79 -0
  100. package/dist/esm/cli/route.mjs +36 -0
  101. package/dist/esm/cli/runtimeExports.mjs +0 -0
  102. package/dist/esm/cli/version.mjs +21 -0
  103. package/dist/esm/cli/watch.mjs +40 -0
  104. package/dist/esm/compiled.mjs +115 -0
  105. package/dist/esm/import.mjs +25 -0
  106. package/dist/esm/universal/constants.mjs +13 -0
  107. package/dist/{esm-node/universal/index.js → esm/universal/index.mjs} +1 -3
  108. package/dist/esm/universal/path.mjs +2 -0
  109. package/dist/esm/universal/pluginDagSort.mjs +41 -0
  110. package/dist/esm-node/cli/alias.mjs +31 -0
  111. package/dist/esm-node/cli/applyOptionsChain.mjs +16 -0
  112. package/dist/esm-node/cli/babel.mjs +76 -0
  113. package/dist/esm-node/cli/commands.mjs +23 -0
  114. package/dist/esm-node/cli/common.mjs +11 -0
  115. package/dist/esm-node/cli/config.mjs +5 -0
  116. package/dist/esm-node/cli/constants.mjs +29 -0
  117. package/dist/esm-node/cli/ensure.mjs +9 -0
  118. package/dist/esm-node/cli/fs.mjs +9 -0
  119. package/dist/esm-node/cli/get/config.mjs +14 -0
  120. package/dist/esm-node/cli/get/data.mjs +57 -0
  121. package/dist/esm-node/cli/get/index.mjs +18 -0
  122. package/dist/esm-node/cli/index.mjs +22 -0
  123. package/dist/esm-node/cli/is/config.mjs +34 -0
  124. package/dist/esm-node/cli/is/env.mjs +6 -0
  125. package/dist/esm-node/cli/is/index.mjs +4 -0
  126. package/dist/esm-node/cli/is/project.mjs +104 -0
  127. package/dist/esm-node/cli/is/type.mjs +26 -0
  128. package/dist/esm-node/cli/logger.mjs +2 -0
  129. package/dist/esm-node/cli/monorepo.mjs +50 -0
  130. package/dist/esm-node/cli/package.mjs +51 -0
  131. package/dist/esm-node/cli/path.mjs +35 -0
  132. package/dist/esm-node/cli/port.mjs +35 -0
  133. package/dist/esm-node/cli/prettyInstructions.mjs +68 -0
  134. package/dist/esm-node/cli/require.mjs +79 -0
  135. package/dist/esm-node/cli/route.mjs +36 -0
  136. package/dist/esm-node/cli/runtimeExports.mjs +0 -0
  137. package/dist/esm-node/cli/version.mjs +21 -0
  138. package/dist/esm-node/cli/watch.mjs +40 -0
  139. package/dist/esm-node/compiled.mjs +115 -0
  140. package/dist/esm-node/import.mjs +25 -0
  141. package/dist/esm-node/index.mjs +3 -0
  142. package/dist/esm-node/universal/constants.mjs +13 -0
  143. package/dist/esm-node/universal/index.mjs +2 -0
  144. package/dist/esm-node/universal/path.mjs +2 -0
  145. package/dist/esm-node/universal/pluginDagSort.mjs +41 -0
  146. package/dist/types/cli/constants.d.ts +2 -26
  147. package/dist/types/cli/get/data.d.ts +0 -1
  148. package/dist/types/cli/index.d.ts +0 -1
  149. package/dist/types/cli/is/config.d.ts +1 -1
  150. package/dist/types/cli/runtimeExports.d.ts +1 -4
  151. package/dist/types/cli/watch.d.ts +1 -1
  152. package/dist/types/compiled.d.ts +0 -5
  153. package/dist/types/universal/constants.d.ts +4 -7
  154. package/package.json +27 -27
  155. package/rslib.config.mts +140 -0
  156. package/dist/cjs/cli/action.js +0 -55
  157. package/dist/cjs/universal/formatWebpack.js +0 -127
  158. package/dist/esm/cli/action.js +0 -68
  159. package/dist/esm/cli/alias.js +0 -43
  160. package/dist/esm/cli/applyOptionsChain.js +0 -29
  161. package/dist/esm/cli/babel.js +0 -122
  162. package/dist/esm/cli/commands.js +0 -39
  163. package/dist/esm/cli/common.js +0 -20
  164. package/dist/esm/cli/config.js +0 -11
  165. package/dist/esm/cli/constants.js +0 -114
  166. package/dist/esm/cli/ensure.js +0 -16
  167. package/dist/esm/cli/fs.js +0 -65
  168. package/dist/esm/cli/get/config.js +0 -19
  169. package/dist/esm/cli/get/data.js +0 -143
  170. package/dist/esm/cli/get/index.js +0 -38
  171. package/dist/esm/cli/index.js +0 -23
  172. package/dist/esm/cli/is/config.js +0 -70
  173. package/dist/esm/cli/is/env.js +0 -22
  174. package/dist/esm/cli/is/index.js +0 -4
  175. package/dist/esm/cli/is/project.js +0 -146
  176. package/dist/esm/cli/is/type.js +0 -39
  177. package/dist/esm/cli/logger.js +0 -5
  178. package/dist/esm/cli/monorepo.js +0 -82
  179. package/dist/esm/cli/package.js +0 -203
  180. package/dist/esm/cli/path.js +0 -66
  181. package/dist/esm/cli/port.js +0 -97
  182. package/dist/esm/cli/prettyInstructions.js +0 -102
  183. package/dist/esm/cli/require.js +0 -235
  184. package/dist/esm/cli/route.js +0 -64
  185. package/dist/esm/cli/runtimeExports.js +0 -44
  186. package/dist/esm/cli/version.js +0 -26
  187. package/dist/esm/cli/watch.js +0 -112
  188. package/dist/esm/compiled.js +0 -66
  189. package/dist/esm/import.js +0 -11
  190. package/dist/esm/index.js +0 -3
  191. package/dist/esm/universal/constants.js +0 -32
  192. package/dist/esm/universal/formatWebpack.js +0 -95
  193. package/dist/esm/universal/index.js +0 -4
  194. package/dist/esm/universal/path.js +0 -6
  195. package/dist/esm/universal/pluginDagSort.js +0 -73
  196. package/dist/esm-node/cli/action.js +0 -30
  197. package/dist/esm-node/cli/alias.js +0 -40
  198. package/dist/esm-node/cli/applyOptionsChain.js +0 -27
  199. package/dist/esm-node/cli/babel.js +0 -107
  200. package/dist/esm-node/cli/commands.js +0 -39
  201. package/dist/esm-node/cli/common.js +0 -15
  202. package/dist/esm-node/cli/config.js +0 -9
  203. package/dist/esm-node/cli/constants.js +0 -114
  204. package/dist/esm-node/cli/ensure.js +0 -14
  205. package/dist/esm-node/cli/fs.js +0 -18
  206. package/dist/esm-node/cli/get/config.js +0 -19
  207. package/dist/esm-node/cli/get/data.js +0 -96
  208. package/dist/esm-node/cli/get/index.js +0 -22
  209. package/dist/esm-node/cli/is/config.js +0 -50
  210. package/dist/esm-node/cli/is/env.js +0 -12
  211. package/dist/esm-node/cli/is/project.js +0 -105
  212. package/dist/esm-node/cli/is/type.js +0 -36
  213. package/dist/esm-node/cli/logger.js +0 -5
  214. package/dist/esm-node/cli/monorepo.js +0 -67
  215. package/dist/esm-node/cli/package.js +0 -66
  216. package/dist/esm-node/cli/path.js +0 -48
  217. package/dist/esm-node/cli/port.js +0 -48
  218. package/dist/esm-node/cli/prettyInstructions.js +0 -90
  219. package/dist/esm-node/cli/require.js +0 -111
  220. package/dist/esm-node/cli/route.js +0 -60
  221. package/dist/esm-node/cli/runtimeExports.js +0 -38
  222. package/dist/esm-node/cli/version.js +0 -26
  223. package/dist/esm-node/cli/watch.js +0 -45
  224. package/dist/esm-node/compiled.js +0 -66
  225. package/dist/esm-node/import.js +0 -11
  226. package/dist/esm-node/universal/constants.js +0 -32
  227. package/dist/esm-node/universal/formatWebpack.js +0 -102
  228. package/dist/esm-node/universal/path.js +0 -6
  229. package/dist/esm-node/universal/pluginDagSort.js +0 -50
  230. package/dist/types/cli/action.d.ts +0 -2
  231. package/dist/types/universal/formatWebpack.d.ts +0 -26
  232. /package/dist/{esm-node/cli/is/index.js → esm/cli/is/index.mjs} +0 -0
  233. /package/dist/{esm-node/index.js → esm/index.mjs} +0 -0
@@ -1,114 +0,0 @@
1
- import { NESTED_ROUTE_SPEC_FILE, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE, SERVER_BUNDLE_DIRECTORY, SERVER_RENDER_FUNCTION_NAME, SERVER_PLUGIN_BFF, SERVER_PLUGIN_EXPRESS, SERVER_PLUGIN_KOA, SERVER_PLUGIN_SERVER, SERVER_PLUGIN_POLYFILL } from "../universal/constants";
2
- var JS_EXTENSIONS = [
3
- ".js",
4
- ".ts",
5
- ".jsx",
6
- ".tsx"
7
- ];
8
- var SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
9
- var ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
10
- var LOADABLE_STATS_FILE = "loadable-stats.json";
11
- var API_DIR = "api";
12
- var DEFAULT_API_PREFIX = "/api";
13
- var SERVER_DIR = "server";
14
- var SHARED_DIR = "shared";
15
- var CONFIG_CACHE_DIR = "./node_modules/.cache/bundle-require";
16
- var CONFIG_FILE_EXTENSIONS = [
17
- ".js",
18
- ".ts",
19
- ".mjs"
20
- ];
21
- var OUTPUT_CONFIG_FILE = "modern.config.json";
22
- var DEFAULT_RUNTIME_CONFIG = "modern.runtime";
23
- var DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
24
- var ROUTE_MANIFEST_FILE = "routes-manifest.json";
25
- var LOADER_ROUTES_DIR = "loader-routes";
26
- var DEFAULT_DEV_HOST = "0.0.0.0";
27
- var INTERNAL_APP_TOOLS_PLUGINS = {
28
- "@modern-js/app-tools": "@modern-js/app-tools/cli",
29
- "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
30
- "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
31
- "@modern-js/plugin-bff": "@modern-js/plugin-bff/cli",
32
- "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
33
- "@modern-js/plugin-express": "@modern-js/plugin-express/cli",
34
- "@modern-js/plugin-koa": "@modern-js/plugin-koa/cli",
35
- "@modern-js/plugin-server": "@modern-js/plugin-server/cli",
36
- "@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
37
- "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
38
- "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
39
- // legacy router (inner react-router-dom v5)
40
- "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
41
- };
42
- var INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
43
- "@modern-js/runtime": "@modern-js/runtime/cli"
44
- };
45
- var INTERNAL_MODULE_TOOLS_PLUGINS = {
46
- "@modern-js/module-tools": "@modern-js/module-tools",
47
- "@modern-js/runtime": "@modern-js/runtime/cli",
48
- "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
49
- "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
50
- // legacy router (inner react-router-dom v5)
51
- "@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
52
- };
53
- var INTERNAL_MONOREPO_TOOLS_PLUGINS = {
54
- "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli"
55
- };
56
- var INTERNAL_DOC_TOOLS_PLUGINS = {
57
- "@modern-js/doc-tools": "@modern-js/doc-tools",
58
- "@modern-js/runtime": "@modern-js/runtime/cli"
59
- };
60
- var INTERNAL_CLI_PLUGINS = {
61
- "@modern-js/app-tools": "@modern-js/app-tools/cli",
62
- "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
63
- "@modern-js/module-tools": "@modern-js/module-tools",
64
- "@modern-js/doc-tools": "@modern-js/doc-tools",
65
- "@modern-js/runtime": "@modern-js/runtime/cli",
66
- "@modern-js/plugin-state": "@modern-js/plugin-state/cli",
67
- "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
68
- "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
69
- "@modern-js/plugin-bff": "@modern-js/plugin-bff/cli",
70
- "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
71
- "@modern-js/plugin-express": "@modern-js/plugin-express/cli",
72
- "@modern-js/plugin-koa": "@modern-js/plugin-koa/cli",
73
- "@modern-js/plugin-server": "@modern-js/plugin-server/cli",
74
- "@modern-js/plugin-swc": "@modern-js/plugin-swc",
75
- "@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
76
- "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
77
- "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
78
- // legacy router (inner react-router-dom v5)
79
- "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
80
- };
81
- export {
82
- API_DIR,
83
- CONFIG_CACHE_DIR,
84
- CONFIG_FILE_EXTENSIONS,
85
- DEFAULT_API_PREFIX,
86
- DEFAULT_DEV_HOST,
87
- DEFAULT_RUNTIME_CONFIG,
88
- DEFAULT_SERVER_CONFIG,
89
- ENTRY_NAME_PATTERN,
90
- INTERNAL_APP_TOOLS_PLUGINS,
91
- INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
92
- INTERNAL_CLI_PLUGINS,
93
- INTERNAL_DOC_TOOLS_PLUGINS,
94
- INTERNAL_MODULE_TOOLS_PLUGINS,
95
- INTERNAL_MONOREPO_TOOLS_PLUGINS,
96
- JS_EXTENSIONS,
97
- LOADABLE_STATS_FILE,
98
- LOADER_ROUTES_DIR,
99
- MAIN_ENTRY_NAME,
100
- NESTED_ROUTE_SPEC_FILE,
101
- OUTPUT_CONFIG_FILE,
102
- ROUTE_MANIFEST_FILE,
103
- ROUTE_SPEC_FILE,
104
- SERVER_BUNDLE_DIRECTORY,
105
- SERVER_DIR,
106
- SERVER_PLUGIN_BFF,
107
- SERVER_PLUGIN_EXPRESS,
108
- SERVER_PLUGIN_KOA,
109
- SERVER_PLUGIN_POLYFILL,
110
- SERVER_PLUGIN_SERVER,
111
- SERVER_RENDER_FUNCTION_NAME,
112
- SERVER_WORKER_BUNDLE_DIRECTORY,
113
- SHARED_DIR
114
- };
@@ -1,16 +0,0 @@
1
- import path from "path";
2
- var ensureAbsolutePath = function(base, filePath) {
3
- return path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
4
- };
5
- var ensureArray = function(params) {
6
- if (Array.isArray(params)) {
7
- return params;
8
- }
9
- return [
10
- params
11
- ];
12
- };
13
- export {
14
- ensureAbsolutePath,
15
- ensureArray
16
- };
@@ -1,65 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { fs } from "../compiled";
4
- var findExists = function(files) {
5
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
6
- try {
7
- for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
8
- var file = _step.value;
9
- if (fs.existsSync(file) && fs.statSync(file).isFile()) {
10
- return file;
11
- }
12
- }
13
- } catch (err) {
14
- _didIteratorError = true;
15
- _iteratorError = err;
16
- } finally {
17
- try {
18
- if (!_iteratorNormalCompletion && _iterator.return != null) {
19
- _iterator.return();
20
- }
21
- } finally {
22
- if (_didIteratorError) {
23
- throw _iteratorError;
24
- }
25
- }
26
- }
27
- return false;
28
- };
29
- var emptyDir = function() {
30
- var _ref = _async_to_generator(function(dir) {
31
- return _ts_generator(this, function(_state) {
32
- switch (_state.label) {
33
- case 0:
34
- return [
35
- 4,
36
- fs.pathExists(dir)
37
- ];
38
- case 1:
39
- if (!_state.sent())
40
- return [
41
- 3,
42
- 3
43
- ];
44
- return [
45
- 4,
46
- fs.emptyDir(dir)
47
- ];
48
- case 2:
49
- _state.sent();
50
- _state.label = 3;
51
- case 3:
52
- return [
53
- 2
54
- ];
55
- }
56
- });
57
- });
58
- return function emptyDir2(dir) {
59
- return _ref.apply(this, arguments);
60
- };
61
- }();
62
- export {
63
- emptyDir,
64
- findExists
65
- };
@@ -1,19 +0,0 @@
1
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
- import { isPlainObject } from "../is";
3
- var getEntryOptions = function(name, isMainEntry, baseOptions, optionsByEntries, packageName) {
4
- if (optionsByEntries) {
5
- var optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
6
- if (optionsByEntry === void 0 && isMainEntry && packageName) {
7
- optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
8
- }
9
- return optionsByEntry !== void 0 ? isPlainObject(optionsByEntry) && isPlainObject(baseOptions) ? _object_spread({}, baseOptions, optionsByEntry) : optionsByEntry : baseOptions;
10
- } else {
11
- return baseOptions;
12
- }
13
- };
14
- var getOptionsByEntryName = function(name, optionsByEntries) {
15
- return optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
16
- };
17
- export {
18
- getEntryOptions
19
- };
@@ -1,143 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
3
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
4
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
5
- import os from "os";
6
- import path from "path";
7
- import { fs, browserslist, json5 } from "../../compiled";
8
- import { INTERNAL_CLI_PLUGINS } from "../constants";
9
- import { isDepExists } from "../is";
10
- import { canUsePnpm, canUseYarn } from "../package";
11
- var MAX_TIMES = 5;
12
- function getPackageManager() {
13
- return _getPackageManager.apply(this, arguments);
14
- }
15
- function _getPackageManager() {
16
- _getPackageManager = _async_to_generator(function() {
17
- var cwd, appDirectory, times;
18
- var _arguments = arguments;
19
- return _ts_generator(this, function(_state) {
20
- switch (_state.label) {
21
- case 0:
22
- cwd = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : process.cwd();
23
- appDirectory = cwd;
24
- times = 0;
25
- while (os.homedir() !== appDirectory && times < MAX_TIMES) {
26
- times++;
27
- if (fs.existsSync(path.resolve(appDirectory, "pnpm-lock.yaml"))) {
28
- return [
29
- 2,
30
- "pnpm"
31
- ];
32
- }
33
- if (fs.existsSync(path.resolve(appDirectory, "yarn.lock"))) {
34
- return [
35
- 2,
36
- "yarn"
37
- ];
38
- }
39
- if (fs.existsSync(path.resolve(appDirectory, "package-lock.json"))) {
40
- return [
41
- 2,
42
- "npm"
43
- ];
44
- }
45
- appDirectory = path.join(appDirectory, "..");
46
- }
47
- return [
48
- 4,
49
- canUsePnpm()
50
- ];
51
- case 1:
52
- if (_state.sent()) {
53
- return [
54
- 2,
55
- "pnpm"
56
- ];
57
- }
58
- return [
59
- 4,
60
- canUseYarn()
61
- ];
62
- case 2:
63
- if (_state.sent()) {
64
- return [
65
- 2,
66
- "yarn"
67
- ];
68
- }
69
- return [
70
- 2,
71
- "npm"
72
- ];
73
- }
74
- });
75
- });
76
- return _getPackageManager.apply(this, arguments);
77
- }
78
- var getCoreJsVersion = function(corejsPkgPath) {
79
- try {
80
- var version = fs.readJSONSync(corejsPkgPath).version;
81
- var _version_split = _sliced_to_array(version.split("."), 2), major = _version_split[0], minor = _version_split[1];
82
- return "".concat(major, ".").concat(minor);
83
- } catch (err) {
84
- return "3";
85
- }
86
- };
87
- var getAntdMajorVersion = function(appDirectory) {
88
- try {
89
- var pkgJsonPath = require.resolve("antd/package.json", {
90
- paths: [
91
- appDirectory
92
- ]
93
- });
94
- var version = require(pkgJsonPath).version;
95
- return Number(version.split(".")[0]);
96
- } catch (err) {
97
- return null;
98
- }
99
- };
100
- var defaults = [
101
- "> 0.01%",
102
- "not dead",
103
- "not op_mini all"
104
- ];
105
- var getBrowserslist = function(appDirectory) {
106
- return browserslist.loadConfig({
107
- path: appDirectory
108
- }) || defaults;
109
- };
110
- function getInternalPlugins(appDirectory) {
111
- var internalPlugins = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : INTERNAL_CLI_PLUGINS;
112
- return _to_consumable_array(Object.keys(internalPlugins).filter(function(name) {
113
- var config = internalPlugins[name];
114
- if (typeof config !== "string" && config.forced === true) {
115
- return true;
116
- }
117
- return isDepExists(appDirectory, name);
118
- }).map(function(name) {
119
- var config = internalPlugins[name];
120
- if (typeof config !== "string") {
121
- return config.path;
122
- } else {
123
- return config;
124
- }
125
- }));
126
- }
127
- var readTsConfig = function(root) {
128
- return readTsConfigByFile(path.resolve(root, "./tsconfig.json"));
129
- };
130
- var readTsConfigByFile = function(filename) {
131
- var content = fs.readFileSync(path.resolve(filename), "utf-8");
132
- return json5.parse(content);
133
- };
134
- export {
135
- defaults,
136
- getAntdMajorVersion,
137
- getBrowserslist,
138
- getCoreJsVersion,
139
- getInternalPlugins,
140
- getPackageManager,
141
- readTsConfig,
142
- readTsConfigByFile
143
- };
@@ -1,38 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import path from "path";
4
- import { CONFIG_FILE_EXTENSIONS } from "../constants";
5
- import { findExists } from "../fs";
6
- var getServerConfig = function() {
7
- var _ref = _async_to_generator(function(appDirectory, configFile) {
8
- var configFilePath;
9
- return _ts_generator(this, function(_state) {
10
- configFilePath = findExists(CONFIG_FILE_EXTENSIONS.map(function(extension) {
11
- return path.resolve(appDirectory, "".concat(configFile).concat(extension));
12
- }));
13
- return [
14
- 2,
15
- configFilePath
16
- ];
17
- });
18
- });
19
- return function getServerConfig2(appDirectory, configFile) {
20
- return _ref.apply(this, arguments);
21
- };
22
- }();
23
- var getMeta = function() {
24
- var metaName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "modern-js";
25
- var meta = metaName.toLowerCase().split("-")[0];
26
- return meta;
27
- };
28
- var getTargetDir = function(from, baseDir, targetBaseDir) {
29
- var relativePath = path.relative(baseDir, from);
30
- return path.resolve(targetBaseDir, relativePath);
31
- };
32
- export * from "./data";
33
- export * from "./config";
34
- export {
35
- getMeta,
36
- getServerConfig,
37
- getTargetDir
38
- };
@@ -1,23 +0,0 @@
1
- export * from "./constants";
2
- export * from "./get";
3
- export * from "./is";
4
- export * from "./alias";
5
- export * from "./applyOptionsChain";
6
- export * from "./babel";
7
- export * from "./commands";
8
- export * from "./common";
9
- export * from "./ensure";
10
- export * from "./fs";
11
- export * from "./logger";
12
- export * from "./monorepo";
13
- export * from "./package";
14
- export * from "./path";
15
- export * from "./port";
16
- export * from "./prettyInstructions";
17
- export * from "./require";
18
- export * from "./runtimeExports";
19
- export * from "./watch";
20
- export * from "./config";
21
- export * from "./action";
22
- export * from "./version";
23
- export * from "./route";
@@ -1,70 +0,0 @@
1
- import { MAIN_ENTRY_NAME } from "../constants";
2
- import { isEmpty } from "./type";
3
- var isSSR = function(config) {
4
- var server = config.server;
5
- if (server === null || server === void 0 ? void 0 : server.ssr) {
6
- return true;
7
- }
8
- if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
9
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
10
- try {
11
- for (var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
12
- var name = _step.value;
13
- if (server.ssrByEntries[name]) {
14
- return true;
15
- }
16
- }
17
- } catch (err) {
18
- _didIteratorError = true;
19
- _iteratorError = err;
20
- } finally {
21
- try {
22
- if (!_iteratorNormalCompletion && _iterator.return != null) {
23
- _iterator.return();
24
- }
25
- } finally {
26
- if (_didIteratorError) {
27
- throw _iteratorError;
28
- }
29
- }
30
- }
31
- }
32
- return false;
33
- };
34
- var isUseSSRBundle = function(config) {
35
- var output = config.output;
36
- if (output === null || output === void 0 ? void 0 : output.ssg) {
37
- return true;
38
- }
39
- return isSSR(config);
40
- };
41
- var isUseRsc = function(config) {
42
- var _config_server;
43
- return config === null || config === void 0 ? void 0 : (_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.rsc;
44
- };
45
- var isServiceWorker = function(config) {
46
- var _deploy_worker;
47
- var output = config.output, deploy = config.deploy;
48
- 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))) {
49
- return true;
50
- }
51
- return false;
52
- };
53
- var isSSGEntry = function(config, entryName, entrypoints) {
54
- var _config_source;
55
- var ssgConfig = config.output.ssg;
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]);
57
- return useSSG;
58
- };
59
- var isSingleEntry = function(entrypoints) {
60
- var mainEntryName = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : MAIN_ENTRY_NAME;
61
- return entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
62
- };
63
- export {
64
- isSSGEntry,
65
- isSSR,
66
- isServiceWorker,
67
- isSingleEntry,
68
- isUseRsc,
69
- isUseSSRBundle
70
- };
@@ -1,22 +0,0 @@
1
- var getNodeEnv = function() {
2
- return process.env.NODE_ENV || "development";
3
- };
4
- var isDev = function() {
5
- return getNodeEnv() === "development";
6
- };
7
- var isProd = function() {
8
- return getNodeEnv() === "production";
9
- };
10
- var isTest = function() {
11
- return getNodeEnv() === "test";
12
- };
13
- var isBrowser = function() {
14
- return typeof window !== "undefined";
15
- };
16
- export {
17
- getNodeEnv,
18
- isBrowser,
19
- isDev,
20
- isProd,
21
- isTest
22
- };
@@ -1,4 +0,0 @@
1
- export * from "./env";
2
- export * from "./type";
3
- export * from "./config";
4
- export * from "./project";
@@ -1,146 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
- import path from "path";
5
- import pkgUp from "../../../compiled/pkg-up";
6
- import { fs, minimist, semver } from "../../compiled";
7
- import { getArgv } from "../commands";
8
- import { createDebugger } from "../common";
9
- import { ensureArray } from "../ensure";
10
- var debug = createDebugger("judge-depExists");
11
- var isDepExists = function(appDirectory, name) {
12
- var pkgPath = path.resolve(appDirectory, "./package.json");
13
- if (!fs.existsSync(pkgPath)) {
14
- debug("can't find package.json under: %s", appDirectory);
15
- return false;
16
- }
17
- var json = require(pkgPath);
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
- return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
20
- };
21
- var isPackageInstalled = function(name, resolvePaths) {
22
- try {
23
- require.resolve(name, {
24
- paths: ensureArray(resolvePaths)
25
- });
26
- return true;
27
- } catch (err) {
28
- return false;
29
- }
30
- };
31
- var isApiOnly = function() {
32
- var _ref = _async_to_generator(function(appDirectory, entryDir, apiDir) {
33
- var existApi, existSrc, options;
34
- return _ts_generator(this, function(_state) {
35
- switch (_state.label) {
36
- case 0:
37
- return [
38
- 4,
39
- fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : path.join(appDirectory, "api"))
40
- ];
41
- case 1:
42
- existApi = _state.sent();
43
- return [
44
- 4,
45
- fs.pathExists(path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"))
46
- ];
47
- case 2:
48
- existSrc = _state.sent();
49
- options = minimist(getArgv());
50
- if (options["api-only"]) {
51
- return [
52
- 2,
53
- true
54
- ];
55
- }
56
- return [
57
- 2,
58
- existApi && !existSrc
59
- ];
60
- }
61
- });
62
- });
63
- return function isApiOnly2(appDirectory, entryDir, apiDir) {
64
- return _ref.apply(this, arguments);
65
- };
66
- }();
67
- var isWebOnly = function() {
68
- var _ref = _async_to_generator(function() {
69
- var options;
70
- return _ts_generator(this, function(_state) {
71
- options = minimist(getArgv());
72
- return [
73
- 2,
74
- Boolean(options["web-only"])
75
- ];
76
- });
77
- });
78
- return function isWebOnly2() {
79
- return _ref.apply(this, arguments);
80
- };
81
- }();
82
- var isVersionBeyond17 = function(version) {
83
- return semver.gte(semver.minVersion(version), "17.0.0");
84
- };
85
- var getReactVersion = function(cwd) {
86
- var pkgPath = pkgUp.sync({
87
- cwd
88
- });
89
- if (!pkgPath) {
90
- return false;
91
- }
92
- var pkgInfo = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
93
- var deps = _object_spread({}, pkgInfo.devDependencies, pkgInfo.dependencies);
94
- if (typeof deps.react !== "string") {
95
- return false;
96
- }
97
- try {
98
- var reactPath = require.resolve("react/package.json", {
99
- paths: [
100
- cwd
101
- ]
102
- });
103
- var reactVersion = JSON.parse(fs.readFileSync(reactPath, "utf8")).version;
104
- return reactVersion;
105
- } catch (error) {
106
- console.error("Failed to resolve React version:", error);
107
- return false;
108
- }
109
- };
110
- var isBeyondReact17 = function(cwd) {
111
- var reactVersion = getReactVersion(cwd);
112
- if (!reactVersion) {
113
- return false;
114
- }
115
- return isVersionBeyond17(reactVersion);
116
- };
117
- var isSupportAutomaticJsx = function(cwd) {
118
- var reactVersion = getReactVersion(cwd);
119
- if (!reactVersion) {
120
- return false;
121
- }
122
- return semver.satisfies(semver.minVersion(reactVersion), ">=16.14.0");
123
- };
124
- var isReact18 = function() {
125
- var cwd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : process.cwd();
126
- var reactVersion = getReactVersion(cwd);
127
- if (!reactVersion) {
128
- return false;
129
- }
130
- return semver.gte(semver.minVersion(reactVersion), "18.0.0");
131
- };
132
- var isTypescript = function(root) {
133
- return fs.existsSync(path.resolve(root, "./tsconfig.json"));
134
- };
135
- export {
136
- getReactVersion,
137
- isApiOnly,
138
- isBeyondReact17,
139
- isDepExists,
140
- isPackageInstalled,
141
- isReact18,
142
- isSupportAutomaticJsx,
143
- isTypescript,
144
- isVersionBeyond17,
145
- isWebOnly
146
- };