create-microact-app 1.0.1 → 1.0.2

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 (264) hide show
  1. package/package.json +1 -1
  2. package/templates/vanilla/package.json +1 -1
  3. package/templates/vanilla/src/components/App.js +22 -35
  4. package/templates/vanilla/src/components/Card.js +5 -12
  5. package/templates/vanilla/src/components/Hero.js +6 -8
  6. package/templates/vanilla/src/components/InteractiveDemo.js +34 -32
  7. package/templates/vanilla/src/main.js +2 -6
  8. package/templates/web3/contracts/.gitmodules +3 -0
  9. package/templates/web3/contracts/foundry.lock +8 -0
  10. package/templates/web3/contracts/lib/forge-std/.gitattributes +1 -0
  11. package/templates/web3/contracts/lib/forge-std/.github/CODEOWNERS +1 -0
  12. package/templates/web3/contracts/lib/forge-std/.github/dependabot.yml +6 -0
  13. package/templates/web3/contracts/lib/forge-std/.github/workflows/ci.yml +125 -0
  14. package/templates/web3/contracts/lib/forge-std/.github/workflows/sync.yml +36 -0
  15. package/templates/web3/contracts/lib/forge-std/CONTRIBUTING.md +193 -0
  16. package/templates/web3/contracts/lib/forge-std/LICENSE-APACHE +203 -0
  17. package/templates/web3/contracts/lib/forge-std/LICENSE-MIT +25 -0
  18. package/templates/web3/contracts/lib/forge-std/README.md +268 -0
  19. package/templates/web3/contracts/lib/forge-std/RELEASE_CHECKLIST.md +12 -0
  20. package/templates/web3/contracts/lib/forge-std/foundry.toml +18 -0
  21. package/templates/web3/contracts/lib/forge-std/package.json +16 -0
  22. package/templates/web3/contracts/lib/forge-std/scripts/vm.py +636 -0
  23. package/templates/web3/contracts/lib/forge-std/src/Base.sol +48 -0
  24. package/templates/web3/contracts/lib/forge-std/src/Config.sol +60 -0
  25. package/templates/web3/contracts/lib/forge-std/src/LibVariable.sol +477 -0
  26. package/templates/web3/contracts/lib/forge-std/src/Script.sol +28 -0
  27. package/templates/web3/contracts/lib/forge-std/src/StdAssertions.sol +779 -0
  28. package/templates/web3/contracts/lib/forge-std/src/StdChains.sol +295 -0
  29. package/templates/web3/contracts/lib/forge-std/src/StdCheats.sol +825 -0
  30. package/templates/web3/contracts/lib/forge-std/src/StdConfig.sol +632 -0
  31. package/templates/web3/contracts/lib/forge-std/src/StdConstants.sol +30 -0
  32. package/templates/web3/contracts/lib/forge-std/src/StdError.sol +15 -0
  33. package/templates/web3/contracts/lib/forge-std/src/StdInvariant.sol +120 -0
  34. package/templates/web3/contracts/lib/forge-std/src/StdJson.sol +275 -0
  35. package/templates/web3/contracts/lib/forge-std/src/StdMath.sol +47 -0
  36. package/templates/web3/contracts/lib/forge-std/src/StdStorage.sol +475 -0
  37. package/templates/web3/contracts/lib/forge-std/src/StdStyle.sol +333 -0
  38. package/templates/web3/contracts/lib/forge-std/src/StdToml.sol +275 -0
  39. package/templates/web3/contracts/lib/forge-std/src/StdUtils.sol +200 -0
  40. package/templates/web3/contracts/lib/forge-std/src/Test.sol +32 -0
  41. package/templates/web3/contracts/lib/forge-std/src/Vm.sol +2500 -0
  42. package/templates/web3/contracts/lib/forge-std/src/console.sol +1551 -0
  43. package/templates/web3/contracts/lib/forge-std/src/console2.sol +4 -0
  44. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC1155.sol +105 -0
  45. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC165.sol +12 -0
  46. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC20.sol +43 -0
  47. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC4626.sol +190 -0
  48. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC6909.sol +72 -0
  49. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC721.sol +164 -0
  50. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC7540.sol +144 -0
  51. package/templates/web3/contracts/lib/forge-std/src/interfaces/IERC7575.sol +241 -0
  52. package/templates/web3/contracts/lib/forge-std/src/interfaces/IMulticall3.sol +68 -0
  53. package/templates/web3/contracts/lib/forge-std/src/safeconsole.sol +13248 -0
  54. package/templates/web3/contracts/lib/forge-std/test/CommonBase.t.sol +44 -0
  55. package/templates/web3/contracts/lib/forge-std/test/Config.t.sol +381 -0
  56. package/templates/web3/contracts/lib/forge-std/test/LibVariable.t.sol +452 -0
  57. package/templates/web3/contracts/lib/forge-std/test/StdAssertions.t.sol +141 -0
  58. package/templates/web3/contracts/lib/forge-std/test/StdChains.t.sol +227 -0
  59. package/templates/web3/contracts/lib/forge-std/test/StdCheats.t.sol +638 -0
  60. package/templates/web3/contracts/lib/forge-std/test/StdConstants.t.sol +38 -0
  61. package/templates/web3/contracts/lib/forge-std/test/StdError.t.sol +119 -0
  62. package/templates/web3/contracts/lib/forge-std/test/StdJson.t.sol +49 -0
  63. package/templates/web3/contracts/lib/forge-std/test/StdMath.t.sol +202 -0
  64. package/templates/web3/contracts/lib/forge-std/test/StdStorage.t.sol +485 -0
  65. package/templates/web3/contracts/lib/forge-std/test/StdStyle.t.sol +110 -0
  66. package/templates/web3/contracts/lib/forge-std/test/StdToml.t.sol +49 -0
  67. package/templates/web3/contracts/lib/forge-std/test/StdUtils.t.sol +342 -0
  68. package/templates/web3/contracts/lib/forge-std/test/Vm.t.sol +18 -0
  69. package/templates/web3/contracts/lib/forge-std/test/compilation/CompilationScript.sol +8 -0
  70. package/templates/web3/contracts/lib/forge-std/test/compilation/CompilationScriptBase.sol +8 -0
  71. package/templates/web3/contracts/lib/forge-std/test/compilation/CompilationTest.sol +8 -0
  72. package/templates/web3/contracts/lib/forge-std/test/compilation/CompilationTestBase.sol +8 -0
  73. package/templates/web3/contracts/lib/forge-std/test/fixtures/broadcast.log.json +187 -0
  74. package/templates/web3/contracts/lib/forge-std/test/fixtures/config.toml +81 -0
  75. package/templates/web3/contracts/lib/forge-std/test/fixtures/test.json +8 -0
  76. package/templates/web3/contracts/lib/forge-std/test/fixtures/test.toml +6 -0
  77. package/templates/web3/package.json +1 -1
  78. package/templates/web3/src/components/App.js +23 -36
  79. package/templates/web3/src/components/CounterCard.js +45 -45
  80. package/templates/web3/src/main.js +5 -7
  81. package/templates/vanilla/node_modules/.package-lock.json +0 -207
  82. package/templates/vanilla/node_modules/@esbuild/darwin-x64/README.md +0 -3
  83. package/templates/vanilla/node_modules/@esbuild/darwin-x64/bin/esbuild +0 -0
  84. package/templates/vanilla/node_modules/@esbuild/darwin-x64/package.json +0 -17
  85. package/templates/vanilla/node_modules/@monygroupcorp/microact/README.md +0 -154
  86. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js +0 -1749
  87. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js.map +0 -1
  88. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js +0 -1743
  89. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js.map +0 -1
  90. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js +0 -2
  91. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js.map +0 -1
  92. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.html +0 -13
  93. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.js +0 -63
  94. package/templates/vanilla/node_modules/@monygroupcorp/microact/package.json +0 -38
  95. package/templates/vanilla/node_modules/@monygroupcorp/microact/rollup.config.cjs +0 -30
  96. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Component.js +0 -831
  97. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/DOMUpdater.js +0 -320
  98. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/EventBus.js +0 -123
  99. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Router.js +0 -253
  100. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/UpdateScheduler.js +0 -218
  101. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/index.js +0 -6
  102. package/templates/vanilla/node_modules/esbuild/LICENSE.md +0 -21
  103. package/templates/vanilla/node_modules/esbuild/README.md +0 -3
  104. package/templates/vanilla/node_modules/esbuild/bin/esbuild +0 -0
  105. package/templates/vanilla/node_modules/esbuild/install.js +0 -287
  106. package/templates/vanilla/node_modules/esbuild/lib/main.d.ts +0 -660
  107. package/templates/vanilla/node_modules/esbuild/lib/main.js +0 -2393
  108. package/templates/vanilla/node_modules/esbuild/package.json +0 -42
  109. package/templates/vanilla/node_modules/nanoid/LICENSE +0 -20
  110. package/templates/vanilla/node_modules/nanoid/README.md +0 -39
  111. package/templates/vanilla/node_modules/nanoid/async/index.browser.cjs +0 -69
  112. package/templates/vanilla/node_modules/nanoid/async/index.browser.js +0 -34
  113. package/templates/vanilla/node_modules/nanoid/async/index.cjs +0 -71
  114. package/templates/vanilla/node_modules/nanoid/async/index.d.ts +0 -56
  115. package/templates/vanilla/node_modules/nanoid/async/index.js +0 -35
  116. package/templates/vanilla/node_modules/nanoid/async/index.native.js +0 -26
  117. package/templates/vanilla/node_modules/nanoid/async/package.json +0 -12
  118. package/templates/vanilla/node_modules/nanoid/bin/nanoid.cjs +0 -55
  119. package/templates/vanilla/node_modules/nanoid/index.browser.cjs +0 -72
  120. package/templates/vanilla/node_modules/nanoid/index.browser.js +0 -34
  121. package/templates/vanilla/node_modules/nanoid/index.cjs +0 -85
  122. package/templates/vanilla/node_modules/nanoid/index.d.cts +0 -91
  123. package/templates/vanilla/node_modules/nanoid/index.d.ts +0 -91
  124. package/templates/vanilla/node_modules/nanoid/index.js +0 -45
  125. package/templates/vanilla/node_modules/nanoid/nanoid.js +0 -1
  126. package/templates/vanilla/node_modules/nanoid/non-secure/index.cjs +0 -34
  127. package/templates/vanilla/node_modules/nanoid/non-secure/index.d.ts +0 -33
  128. package/templates/vanilla/node_modules/nanoid/non-secure/index.js +0 -21
  129. package/templates/vanilla/node_modules/nanoid/non-secure/package.json +0 -6
  130. package/templates/vanilla/node_modules/nanoid/package.json +0 -89
  131. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  132. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.js +0 -3
  133. package/templates/vanilla/node_modules/nanoid/url-alphabet/package.json +0 -6
  134. package/templates/vanilla/node_modules/picocolors/LICENSE +0 -15
  135. package/templates/vanilla/node_modules/picocolors/README.md +0 -21
  136. package/templates/vanilla/node_modules/picocolors/package.json +0 -25
  137. package/templates/vanilla/node_modules/picocolors/picocolors.browser.js +0 -4
  138. package/templates/vanilla/node_modules/picocolors/picocolors.d.ts +0 -5
  139. package/templates/vanilla/node_modules/picocolors/picocolors.js +0 -75
  140. package/templates/vanilla/node_modules/picocolors/types.d.ts +0 -51
  141. package/templates/vanilla/node_modules/postcss/LICENSE +0 -20
  142. package/templates/vanilla/node_modules/postcss/README.md +0 -29
  143. package/templates/vanilla/node_modules/postcss/lib/at-rule.d.ts +0 -140
  144. package/templates/vanilla/node_modules/postcss/lib/at-rule.js +0 -25
  145. package/templates/vanilla/node_modules/postcss/lib/comment.d.ts +0 -68
  146. package/templates/vanilla/node_modules/postcss/lib/comment.js +0 -13
  147. package/templates/vanilla/node_modules/postcss/lib/container.d.ts +0 -483
  148. package/templates/vanilla/node_modules/postcss/lib/container.js +0 -447
  149. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.d.ts +0 -248
  150. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.js +0 -133
  151. package/templates/vanilla/node_modules/postcss/lib/declaration.d.ts +0 -151
  152. package/templates/vanilla/node_modules/postcss/lib/declaration.js +0 -24
  153. package/templates/vanilla/node_modules/postcss/lib/document.d.ts +0 -69
  154. package/templates/vanilla/node_modules/postcss/lib/document.js +0 -33
  155. package/templates/vanilla/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  156. package/templates/vanilla/node_modules/postcss/lib/fromJSON.js +0 -54
  157. package/templates/vanilla/node_modules/postcss/lib/input.d.ts +0 -227
  158. package/templates/vanilla/node_modules/postcss/lib/input.js +0 -265
  159. package/templates/vanilla/node_modules/postcss/lib/lazy-result.d.ts +0 -190
  160. package/templates/vanilla/node_modules/postcss/lib/lazy-result.js +0 -550
  161. package/templates/vanilla/node_modules/postcss/lib/list.d.ts +0 -60
  162. package/templates/vanilla/node_modules/postcss/lib/list.js +0 -58
  163. package/templates/vanilla/node_modules/postcss/lib/map-generator.js +0 -368
  164. package/templates/vanilla/node_modules/postcss/lib/no-work-result.d.ts +0 -46
  165. package/templates/vanilla/node_modules/postcss/lib/no-work-result.js +0 -138
  166. package/templates/vanilla/node_modules/postcss/lib/node.d.ts +0 -556
  167. package/templates/vanilla/node_modules/postcss/lib/node.js +0 -449
  168. package/templates/vanilla/node_modules/postcss/lib/parse.d.ts +0 -9
  169. package/templates/vanilla/node_modules/postcss/lib/parse.js +0 -42
  170. package/templates/vanilla/node_modules/postcss/lib/parser.js +0 -611
  171. package/templates/vanilla/node_modules/postcss/lib/postcss.d.mts +0 -69
  172. package/templates/vanilla/node_modules/postcss/lib/postcss.d.ts +0 -458
  173. package/templates/vanilla/node_modules/postcss/lib/postcss.js +0 -101
  174. package/templates/vanilla/node_modules/postcss/lib/postcss.mjs +0 -30
  175. package/templates/vanilla/node_modules/postcss/lib/previous-map.d.ts +0 -81
  176. package/templates/vanilla/node_modules/postcss/lib/previous-map.js +0 -144
  177. package/templates/vanilla/node_modules/postcss/lib/processor.d.ts +0 -115
  178. package/templates/vanilla/node_modules/postcss/lib/processor.js +0 -67
  179. package/templates/vanilla/node_modules/postcss/lib/result.d.ts +0 -205
  180. package/templates/vanilla/node_modules/postcss/lib/result.js +0 -42
  181. package/templates/vanilla/node_modules/postcss/lib/root.d.ts +0 -87
  182. package/templates/vanilla/node_modules/postcss/lib/root.js +0 -61
  183. package/templates/vanilla/node_modules/postcss/lib/rule.d.ts +0 -126
  184. package/templates/vanilla/node_modules/postcss/lib/rule.js +0 -27
  185. package/templates/vanilla/node_modules/postcss/lib/stringifier.d.ts +0 -46
  186. package/templates/vanilla/node_modules/postcss/lib/stringifier.js +0 -353
  187. package/templates/vanilla/node_modules/postcss/lib/stringify.d.ts +0 -9
  188. package/templates/vanilla/node_modules/postcss/lib/stringify.js +0 -11
  189. package/templates/vanilla/node_modules/postcss/lib/symbols.js +0 -5
  190. package/templates/vanilla/node_modules/postcss/lib/terminal-highlight.js +0 -70
  191. package/templates/vanilla/node_modules/postcss/lib/tokenize.js +0 -266
  192. package/templates/vanilla/node_modules/postcss/lib/warn-once.js +0 -13
  193. package/templates/vanilla/node_modules/postcss/lib/warning.d.ts +0 -147
  194. package/templates/vanilla/node_modules/postcss/lib/warning.js +0 -37
  195. package/templates/vanilla/node_modules/postcss/package.json +0 -88
  196. package/templates/vanilla/node_modules/rollup/LICENSE.md +0 -695
  197. package/templates/vanilla/node_modules/rollup/README.md +0 -125
  198. package/templates/vanilla/node_modules/rollup/dist/bin/rollup +0 -1715
  199. package/templates/vanilla/node_modules/rollup/dist/es/getLogFilter.js +0 -64
  200. package/templates/vanilla/node_modules/rollup/dist/es/package.json +0 -1
  201. package/templates/vanilla/node_modules/rollup/dist/es/rollup.js +0 -17
  202. package/templates/vanilla/node_modules/rollup/dist/es/shared/node-entry.js +0 -27273
  203. package/templates/vanilla/node_modules/rollup/dist/es/shared/watch.js +0 -4857
  204. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.d.ts +0 -5
  205. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.js +0 -69
  206. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.d.ts +0 -20
  207. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.js +0 -29
  208. package/templates/vanilla/node_modules/rollup/dist/rollup.d.ts +0 -1012
  209. package/templates/vanilla/node_modules/rollup/dist/rollup.js +0 -31
  210. package/templates/vanilla/node_modules/rollup/dist/shared/fsevents-importer.js +0 -37
  211. package/templates/vanilla/node_modules/rollup/dist/shared/index.js +0 -4571
  212. package/templates/vanilla/node_modules/rollup/dist/shared/loadConfigFile.js +0 -546
  213. package/templates/vanilla/node_modules/rollup/dist/shared/rollup.js +0 -27351
  214. package/templates/vanilla/node_modules/rollup/dist/shared/watch-cli.js +0 -561
  215. package/templates/vanilla/node_modules/rollup/dist/shared/watch-proxy.js +0 -87
  216. package/templates/vanilla/node_modules/rollup/dist/shared/watch.js +0 -316
  217. package/templates/vanilla/node_modules/rollup/package.json +0 -181
  218. package/templates/vanilla/node_modules/source-map-js/LICENSE +0 -28
  219. package/templates/vanilla/node_modules/source-map-js/README.md +0 -765
  220. package/templates/vanilla/node_modules/source-map-js/lib/array-set.js +0 -121
  221. package/templates/vanilla/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  222. package/templates/vanilla/node_modules/source-map-js/lib/base64.js +0 -67
  223. package/templates/vanilla/node_modules/source-map-js/lib/binary-search.js +0 -111
  224. package/templates/vanilla/node_modules/source-map-js/lib/mapping-list.js +0 -79
  225. package/templates/vanilla/node_modules/source-map-js/lib/quick-sort.js +0 -132
  226. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  227. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  228. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  229. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  230. package/templates/vanilla/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  231. package/templates/vanilla/node_modules/source-map-js/lib/source-node.js +0 -413
  232. package/templates/vanilla/node_modules/source-map-js/lib/util.js +0 -594
  233. package/templates/vanilla/node_modules/source-map-js/package.json +0 -71
  234. package/templates/vanilla/node_modules/source-map-js/source-map.d.ts +0 -104
  235. package/templates/vanilla/node_modules/source-map-js/source-map.js +0 -8
  236. package/templates/vanilla/node_modules/vite/LICENSE.md +0 -3396
  237. package/templates/vanilla/node_modules/vite/README.md +0 -20
  238. package/templates/vanilla/node_modules/vite/bin/openChrome.applescript +0 -95
  239. package/templates/vanilla/node_modules/vite/bin/vite.js +0 -61
  240. package/templates/vanilla/node_modules/vite/client.d.ts +0 -281
  241. package/templates/vanilla/node_modules/vite/dist/client/client.mjs +0 -725
  242. package/templates/vanilla/node_modules/vite/dist/client/client.mjs.map +0 -1
  243. package/templates/vanilla/node_modules/vite/dist/client/env.mjs +0 -30
  244. package/templates/vanilla/node_modules/vite/dist/client/env.mjs.map +0 -1
  245. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-7ec6f216.js +0 -914
  246. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-827b23df.js +0 -66713
  247. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-c423598f.js +0 -561
  248. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f0c7dae0.js +0 -7930
  249. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f1e8587f.js +0 -7646
  250. package/templates/vanilla/node_modules/vite/dist/node/cli.js +0 -929
  251. package/templates/vanilla/node_modules/vite/dist/node/constants.js +0 -130
  252. package/templates/vanilla/node_modules/vite/dist/node/index.d.ts +0 -3548
  253. package/templates/vanilla/node_modules/vite/dist/node/index.js +0 -158
  254. package/templates/vanilla/node_modules/vite/dist/node-cjs/publicUtils.cjs +0 -4555
  255. package/templates/vanilla/node_modules/vite/index.cjs +0 -34
  256. package/templates/vanilla/node_modules/vite/package.json +0 -173
  257. package/templates/vanilla/node_modules/vite/types/customEvent.d.ts +0 -35
  258. package/templates/vanilla/node_modules/vite/types/hmrPayload.d.ts +0 -61
  259. package/templates/vanilla/node_modules/vite/types/hot.d.ts +0 -32
  260. package/templates/vanilla/node_modules/vite/types/importGlob.d.ts +0 -97
  261. package/templates/vanilla/node_modules/vite/types/importMeta.d.ts +0 -26
  262. package/templates/vanilla/node_modules/vite/types/metadata.d.ts +0 -10
  263. package/templates/vanilla/node_modules/vite/types/package.json +0 -4
  264. package/templates/vanilla/package-lock.json +0 -589
@@ -1,929 +0,0 @@
1
- import path from 'node:path';
2
- import fs from 'node:fs';
3
- import { performance } from 'node:perf_hooks';
4
- import { EventEmitter } from 'events';
5
- import { D as colors, E as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-827b23df.js';
6
- import { VERSION } from './constants.js';
7
- import 'node:fs/promises';
8
- import 'node:url';
9
- import 'node:util';
10
- import 'node:module';
11
- import 'node:crypto';
12
- import 'tty';
13
- import 'esbuild';
14
- import 'path';
15
- import 'fs';
16
- import 'assert';
17
- import 'util';
18
- import 'net';
19
- import 'url';
20
- import 'http';
21
- import 'stream';
22
- import 'os';
23
- import 'child_process';
24
- import 'node:os';
25
- import 'node:child_process';
26
- import 'node:dns';
27
- import 'crypto';
28
- import 'node:buffer';
29
- import 'module';
30
- import 'node:assert';
31
- import 'node:process';
32
- import 'node:v8';
33
- import 'rollup';
34
- import 'worker_threads';
35
- import 'node:http';
36
- import 'node:https';
37
- import 'zlib';
38
- import 'buffer';
39
- import 'https';
40
- import 'tls';
41
- import 'node:net';
42
- import 'querystring';
43
- import 'node:readline';
44
- import 'node:zlib';
45
-
46
- function toArr(any) {
47
- return any == null ? [] : Array.isArray(any) ? any : [any];
48
- }
49
-
50
- function toVal(out, key, val, opts) {
51
- var x, old=out[key], nxt=(
52
- !!~opts.string.indexOf(key) ? (val == null || val === true ? '' : String(val))
53
- : typeof val === 'boolean' ? val
54
- : !!~opts.boolean.indexOf(key) ? (val === 'false' ? false : val === 'true' || (out._.push((x = +val,x * 0 === 0) ? x : val),!!val))
55
- : (x = +val,x * 0 === 0) ? x : val
56
- );
57
- out[key] = old == null ? nxt : (Array.isArray(old) ? old.concat(nxt) : [old, nxt]);
58
- }
59
-
60
- function mri2 (args, opts) {
61
- args = args || [];
62
- opts = opts || {};
63
-
64
- var k, arr, arg, name, val, out={ _:[] };
65
- var i=0, j=0, idx=0, len=args.length;
66
-
67
- const alibi = opts.alias !== void 0;
68
- const strict = opts.unknown !== void 0;
69
- const defaults = opts.default !== void 0;
70
-
71
- opts.alias = opts.alias || {};
72
- opts.string = toArr(opts.string);
73
- opts.boolean = toArr(opts.boolean);
74
-
75
- if (alibi) {
76
- for (k in opts.alias) {
77
- arr = opts.alias[k] = toArr(opts.alias[k]);
78
- for (i=0; i < arr.length; i++) {
79
- (opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
80
- }
81
- }
82
- }
83
-
84
- for (i=opts.boolean.length; i-- > 0;) {
85
- arr = opts.alias[opts.boolean[i]] || [];
86
- for (j=arr.length; j-- > 0;) opts.boolean.push(arr[j]);
87
- }
88
-
89
- for (i=opts.string.length; i-- > 0;) {
90
- arr = opts.alias[opts.string[i]] || [];
91
- for (j=arr.length; j-- > 0;) opts.string.push(arr[j]);
92
- }
93
-
94
- if (defaults) {
95
- for (k in opts.default) {
96
- name = typeof opts.default[k];
97
- arr = opts.alias[k] = opts.alias[k] || [];
98
- if (opts[name] !== void 0) {
99
- opts[name].push(k);
100
- for (i=0; i < arr.length; i++) {
101
- opts[name].push(arr[i]);
102
- }
103
- }
104
- }
105
- }
106
-
107
- const keys = strict ? Object.keys(opts.alias) : [];
108
-
109
- for (i=0; i < len; i++) {
110
- arg = args[i];
111
-
112
- if (arg === '--') {
113
- out._ = out._.concat(args.slice(++i));
114
- break;
115
- }
116
-
117
- for (j=0; j < arg.length; j++) {
118
- if (arg.charCodeAt(j) !== 45) break; // "-"
119
- }
120
-
121
- if (j === 0) {
122
- out._.push(arg);
123
- } else if (arg.substring(j, j + 3) === 'no-') {
124
- name = arg.substring(j + 3);
125
- if (strict && !~keys.indexOf(name)) {
126
- return opts.unknown(arg);
127
- }
128
- out[name] = false;
129
- } else {
130
- for (idx=j+1; idx < arg.length; idx++) {
131
- if (arg.charCodeAt(idx) === 61) break; // "="
132
- }
133
-
134
- name = arg.substring(j, idx);
135
- val = arg.substring(++idx) || (i+1 === len || (''+args[i+1]).charCodeAt(0) === 45 || args[++i]);
136
- arr = (j === 2 ? [name] : name);
137
-
138
- for (idx=0; idx < arr.length; idx++) {
139
- name = arr[idx];
140
- if (strict && !~keys.indexOf(name)) return opts.unknown('-'.repeat(j) + name);
141
- toVal(out, name, (idx + 1 < arr.length) || val, opts);
142
- }
143
- }
144
- }
145
-
146
- if (defaults) {
147
- for (k in opts.default) {
148
- if (out[k] === void 0) {
149
- out[k] = opts.default[k];
150
- }
151
- }
152
- }
153
-
154
- if (alibi) {
155
- for (k in out) {
156
- arr = opts.alias[k] || [];
157
- while (arr.length > 0) {
158
- out[arr.shift()] = out[k];
159
- }
160
- }
161
- }
162
-
163
- return out;
164
- }
165
-
166
- const removeBrackets = (v) => v.replace(/[<[].+/, "").trim();
167
- const findAllBrackets = (v) => {
168
- const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
169
- const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
170
- const res = [];
171
- const parse = (match) => {
172
- let variadic = false;
173
- let value = match[1];
174
- if (value.startsWith("...")) {
175
- value = value.slice(3);
176
- variadic = true;
177
- }
178
- return {
179
- required: match[0].startsWith("<"),
180
- value,
181
- variadic
182
- };
183
- };
184
- let angledMatch;
185
- while (angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v)) {
186
- res.push(parse(angledMatch));
187
- }
188
- let squareMatch;
189
- while (squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v)) {
190
- res.push(parse(squareMatch));
191
- }
192
- return res;
193
- };
194
- const getMriOptions = (options) => {
195
- const result = {alias: {}, boolean: []};
196
- for (const [index, option] of options.entries()) {
197
- if (option.names.length > 1) {
198
- result.alias[option.names[0]] = option.names.slice(1);
199
- }
200
- if (option.isBoolean) {
201
- if (option.negated) {
202
- const hasStringTypeOption = options.some((o, i) => {
203
- return i !== index && o.names.some((name) => option.names.includes(name)) && typeof o.required === "boolean";
204
- });
205
- if (!hasStringTypeOption) {
206
- result.boolean.push(option.names[0]);
207
- }
208
- } else {
209
- result.boolean.push(option.names[0]);
210
- }
211
- }
212
- }
213
- return result;
214
- };
215
- const findLongest = (arr) => {
216
- return arr.sort((a, b) => {
217
- return a.length > b.length ? -1 : 1;
218
- })[0];
219
- };
220
- const padRight = (str, length) => {
221
- return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
222
- };
223
- const camelcase = (input) => {
224
- return input.replace(/([a-z])-([a-z])/g, (_, p1, p2) => {
225
- return p1 + p2.toUpperCase();
226
- });
227
- };
228
- const setDotProp = (obj, keys, val) => {
229
- let i = 0;
230
- let length = keys.length;
231
- let t = obj;
232
- let x;
233
- for (; i < length; ++i) {
234
- x = t[keys[i]];
235
- t = t[keys[i]] = i === length - 1 ? val : x != null ? x : !!~keys[i + 1].indexOf(".") || !(+keys[i + 1] > -1) ? {} : [];
236
- }
237
- };
238
- const setByType = (obj, transforms) => {
239
- for (const key of Object.keys(transforms)) {
240
- const transform = transforms[key];
241
- if (transform.shouldTransform) {
242
- obj[key] = Array.prototype.concat.call([], obj[key]);
243
- if (typeof transform.transformFunction === "function") {
244
- obj[key] = obj[key].map(transform.transformFunction);
245
- }
246
- }
247
- }
248
- };
249
- const getFileName = (input) => {
250
- const m = /([^\\\/]+)$/.exec(input);
251
- return m ? m[1] : "";
252
- };
253
- const camelcaseOptionName = (name) => {
254
- return name.split(".").map((v, i) => {
255
- return i === 0 ? camelcase(v) : v;
256
- }).join(".");
257
- };
258
- class CACError extends Error {
259
- constructor(message) {
260
- super(message);
261
- this.name = this.constructor.name;
262
- if (typeof Error.captureStackTrace === "function") {
263
- Error.captureStackTrace(this, this.constructor);
264
- } else {
265
- this.stack = new Error(message).stack;
266
- }
267
- }
268
- }
269
-
270
- class Option {
271
- constructor(rawName, description, config) {
272
- this.rawName = rawName;
273
- this.description = description;
274
- this.config = Object.assign({}, config);
275
- rawName = rawName.replace(/\.\*/g, "");
276
- this.negated = false;
277
- this.names = removeBrackets(rawName).split(",").map((v) => {
278
- let name = v.trim().replace(/^-{1,2}/, "");
279
- if (name.startsWith("no-")) {
280
- this.negated = true;
281
- name = name.replace(/^no-/, "");
282
- }
283
- return camelcaseOptionName(name);
284
- }).sort((a, b) => a.length > b.length ? 1 : -1);
285
- this.name = this.names[this.names.length - 1];
286
- if (this.negated && this.config.default == null) {
287
- this.config.default = true;
288
- }
289
- if (rawName.includes("<")) {
290
- this.required = true;
291
- } else if (rawName.includes("[")) {
292
- this.required = false;
293
- } else {
294
- this.isBoolean = true;
295
- }
296
- }
297
- }
298
-
299
- const processArgs = process.argv;
300
- const platformInfo = `${process.platform}-${process.arch} node-${process.version}`;
301
-
302
- class Command {
303
- constructor(rawName, description, config = {}, cli) {
304
- this.rawName = rawName;
305
- this.description = description;
306
- this.config = config;
307
- this.cli = cli;
308
- this.options = [];
309
- this.aliasNames = [];
310
- this.name = removeBrackets(rawName);
311
- this.args = findAllBrackets(rawName);
312
- this.examples = [];
313
- }
314
- usage(text) {
315
- this.usageText = text;
316
- return this;
317
- }
318
- allowUnknownOptions() {
319
- this.config.allowUnknownOptions = true;
320
- return this;
321
- }
322
- ignoreOptionDefaultValue() {
323
- this.config.ignoreOptionDefaultValue = true;
324
- return this;
325
- }
326
- version(version, customFlags = "-v, --version") {
327
- this.versionNumber = version;
328
- this.option(customFlags, "Display version number");
329
- return this;
330
- }
331
- example(example) {
332
- this.examples.push(example);
333
- return this;
334
- }
335
- option(rawName, description, config) {
336
- const option = new Option(rawName, description, config);
337
- this.options.push(option);
338
- return this;
339
- }
340
- alias(name) {
341
- this.aliasNames.push(name);
342
- return this;
343
- }
344
- action(callback) {
345
- this.commandAction = callback;
346
- return this;
347
- }
348
- isMatched(name) {
349
- return this.name === name || this.aliasNames.includes(name);
350
- }
351
- get isDefaultCommand() {
352
- return this.name === "" || this.aliasNames.includes("!");
353
- }
354
- get isGlobalCommand() {
355
- return this instanceof GlobalCommand;
356
- }
357
- hasOption(name) {
358
- name = name.split(".")[0];
359
- return this.options.find((option) => {
360
- return option.names.includes(name);
361
- });
362
- }
363
- outputHelp() {
364
- const {name, commands} = this.cli;
365
- const {
366
- versionNumber,
367
- options: globalOptions,
368
- helpCallback
369
- } = this.cli.globalCommand;
370
- let sections = [
371
- {
372
- body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
373
- }
374
- ];
375
- sections.push({
376
- title: "Usage",
377
- body: ` $ ${name} ${this.usageText || this.rawName}`
378
- });
379
- const showCommands = (this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0;
380
- if (showCommands) {
381
- const longestCommandName = findLongest(commands.map((command) => command.rawName));
382
- sections.push({
383
- title: "Commands",
384
- body: commands.map((command) => {
385
- return ` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`;
386
- }).join("\n")
387
- });
388
- sections.push({
389
- title: `For more info, run any command with the \`--help\` flag`,
390
- body: commands.map((command) => ` $ ${name}${command.name === "" ? "" : ` ${command.name}`} --help`).join("\n")
391
- });
392
- }
393
- let options = this.isGlobalCommand ? globalOptions : [...this.options, ...globalOptions || []];
394
- if (!this.isGlobalCommand && !this.isDefaultCommand) {
395
- options = options.filter((option) => option.name !== "version");
396
- }
397
- if (options.length > 0) {
398
- const longestOptionName = findLongest(options.map((option) => option.rawName));
399
- sections.push({
400
- title: "Options",
401
- body: options.map((option) => {
402
- return ` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${option.config.default === void 0 ? "" : `(default: ${option.config.default})`}`;
403
- }).join("\n")
404
- });
405
- }
406
- if (this.examples.length > 0) {
407
- sections.push({
408
- title: "Examples",
409
- body: this.examples.map((example) => {
410
- if (typeof example === "function") {
411
- return example(name);
412
- }
413
- return example;
414
- }).join("\n")
415
- });
416
- }
417
- if (helpCallback) {
418
- sections = helpCallback(sections) || sections;
419
- }
420
- console.log(sections.map((section) => {
421
- return section.title ? `${section.title}:
422
- ${section.body}` : section.body;
423
- }).join("\n\n"));
424
- }
425
- outputVersion() {
426
- const {name} = this.cli;
427
- const {versionNumber} = this.cli.globalCommand;
428
- if (versionNumber) {
429
- console.log(`${name}/${versionNumber} ${platformInfo}`);
430
- }
431
- }
432
- checkRequiredArgs() {
433
- const minimalArgsCount = this.args.filter((arg) => arg.required).length;
434
- if (this.cli.args.length < minimalArgsCount) {
435
- throw new CACError(`missing required args for command \`${this.rawName}\``);
436
- }
437
- }
438
- checkUnknownOptions() {
439
- const {options, globalCommand} = this.cli;
440
- if (!this.config.allowUnknownOptions) {
441
- for (const name of Object.keys(options)) {
442
- if (name !== "--" && !this.hasOption(name) && !globalCommand.hasOption(name)) {
443
- throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
444
- }
445
- }
446
- }
447
- }
448
- checkOptionValue() {
449
- const {options: parsedOptions, globalCommand} = this.cli;
450
- const options = [...globalCommand.options, ...this.options];
451
- for (const option of options) {
452
- const value = parsedOptions[option.name.split(".")[0]];
453
- if (option.required) {
454
- const hasNegated = options.some((o) => o.negated && o.names.includes(option.name));
455
- if (value === true || value === false && !hasNegated) {
456
- throw new CACError(`option \`${option.rawName}\` value is missing`);
457
- }
458
- }
459
- }
460
- }
461
- }
462
- class GlobalCommand extends Command {
463
- constructor(cli) {
464
- super("@@global@@", "", {}, cli);
465
- }
466
- }
467
-
468
- var __assign = Object.assign;
469
- class CAC extends EventEmitter {
470
- constructor(name = "") {
471
- super();
472
- this.name = name;
473
- this.commands = [];
474
- this.rawArgs = [];
475
- this.args = [];
476
- this.options = {};
477
- this.globalCommand = new GlobalCommand(this);
478
- this.globalCommand.usage("<command> [options]");
479
- }
480
- usage(text) {
481
- this.globalCommand.usage(text);
482
- return this;
483
- }
484
- command(rawName, description, config) {
485
- const command = new Command(rawName, description || "", config, this);
486
- command.globalCommand = this.globalCommand;
487
- this.commands.push(command);
488
- return command;
489
- }
490
- option(rawName, description, config) {
491
- this.globalCommand.option(rawName, description, config);
492
- return this;
493
- }
494
- help(callback) {
495
- this.globalCommand.option("-h, --help", "Display this message");
496
- this.globalCommand.helpCallback = callback;
497
- this.showHelpOnExit = true;
498
- return this;
499
- }
500
- version(version, customFlags = "-v, --version") {
501
- this.globalCommand.version(version, customFlags);
502
- this.showVersionOnExit = true;
503
- return this;
504
- }
505
- example(example) {
506
- this.globalCommand.example(example);
507
- return this;
508
- }
509
- outputHelp() {
510
- if (this.matchedCommand) {
511
- this.matchedCommand.outputHelp();
512
- } else {
513
- this.globalCommand.outputHelp();
514
- }
515
- }
516
- outputVersion() {
517
- this.globalCommand.outputVersion();
518
- }
519
- setParsedInfo({args, options}, matchedCommand, matchedCommandName) {
520
- this.args = args;
521
- this.options = options;
522
- if (matchedCommand) {
523
- this.matchedCommand = matchedCommand;
524
- }
525
- if (matchedCommandName) {
526
- this.matchedCommandName = matchedCommandName;
527
- }
528
- return this;
529
- }
530
- unsetMatchedCommand() {
531
- this.matchedCommand = void 0;
532
- this.matchedCommandName = void 0;
533
- }
534
- parse(argv = processArgs, {
535
- run = true
536
- } = {}) {
537
- this.rawArgs = argv;
538
- if (!this.name) {
539
- this.name = argv[1] ? getFileName(argv[1]) : "cli";
540
- }
541
- let shouldParse = true;
542
- for (const command of this.commands) {
543
- const parsed = this.mri(argv.slice(2), command);
544
- const commandName = parsed.args[0];
545
- if (command.isMatched(commandName)) {
546
- shouldParse = false;
547
- const parsedInfo = __assign(__assign({}, parsed), {
548
- args: parsed.args.slice(1)
549
- });
550
- this.setParsedInfo(parsedInfo, command, commandName);
551
- this.emit(`command:${commandName}`, command);
552
- }
553
- }
554
- if (shouldParse) {
555
- for (const command of this.commands) {
556
- if (command.name === "") {
557
- shouldParse = false;
558
- const parsed = this.mri(argv.slice(2), command);
559
- this.setParsedInfo(parsed, command);
560
- this.emit(`command:!`, command);
561
- }
562
- }
563
- }
564
- if (shouldParse) {
565
- const parsed = this.mri(argv.slice(2));
566
- this.setParsedInfo(parsed);
567
- }
568
- if (this.options.help && this.showHelpOnExit) {
569
- this.outputHelp();
570
- run = false;
571
- this.unsetMatchedCommand();
572
- }
573
- if (this.options.version && this.showVersionOnExit && this.matchedCommandName == null) {
574
- this.outputVersion();
575
- run = false;
576
- this.unsetMatchedCommand();
577
- }
578
- const parsedArgv = {args: this.args, options: this.options};
579
- if (run) {
580
- this.runMatchedCommand();
581
- }
582
- if (!this.matchedCommand && this.args[0]) {
583
- this.emit("command:*");
584
- }
585
- return parsedArgv;
586
- }
587
- mri(argv, command) {
588
- const cliOptions = [
589
- ...this.globalCommand.options,
590
- ...command ? command.options : []
591
- ];
592
- const mriOptions = getMriOptions(cliOptions);
593
- let argsAfterDoubleDashes = [];
594
- const doubleDashesIndex = argv.indexOf("--");
595
- if (doubleDashesIndex > -1) {
596
- argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
597
- argv = argv.slice(0, doubleDashesIndex);
598
- }
599
- let parsed = mri2(argv, mriOptions);
600
- parsed = Object.keys(parsed).reduce((res, name) => {
601
- return __assign(__assign({}, res), {
602
- [camelcaseOptionName(name)]: parsed[name]
603
- });
604
- }, {_: []});
605
- const args = parsed._;
606
- const options = {
607
- "--": argsAfterDoubleDashes
608
- };
609
- const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
610
- let transforms = Object.create(null);
611
- for (const cliOption of cliOptions) {
612
- if (!ignoreDefault && cliOption.config.default !== void 0) {
613
- for (const name of cliOption.names) {
614
- options[name] = cliOption.config.default;
615
- }
616
- }
617
- if (Array.isArray(cliOption.config.type)) {
618
- if (transforms[cliOption.name] === void 0) {
619
- transforms[cliOption.name] = Object.create(null);
620
- transforms[cliOption.name]["shouldTransform"] = true;
621
- transforms[cliOption.name]["transformFunction"] = cliOption.config.type[0];
622
- }
623
- }
624
- }
625
- for (const key of Object.keys(parsed)) {
626
- if (key !== "_") {
627
- const keys = key.split(".");
628
- setDotProp(options, keys, parsed[key]);
629
- setByType(options, transforms);
630
- }
631
- }
632
- return {
633
- args,
634
- options
635
- };
636
- }
637
- runMatchedCommand() {
638
- const {args, options, matchedCommand: command} = this;
639
- if (!command || !command.commandAction)
640
- return;
641
- command.checkUnknownOptions();
642
- command.checkOptionValue();
643
- command.checkRequiredArgs();
644
- const actionArgs = [];
645
- command.args.forEach((arg, index) => {
646
- if (arg.variadic) {
647
- actionArgs.push(args.slice(index));
648
- } else {
649
- actionArgs.push(args[index]);
650
- }
651
- });
652
- actionArgs.push(options);
653
- return command.commandAction.apply(this, actionArgs);
654
- }
655
- }
656
-
657
- const cac = (name = "") => new CAC(name);
658
-
659
- const cli = cac('vite');
660
- let profileSession = global.__vite_profile_session;
661
- let profileCount = 0;
662
- const stopProfiler = (log) => {
663
- if (!profileSession)
664
- return;
665
- return new Promise((res, rej) => {
666
- profileSession.post('Profiler.stop', (err, { profile }) => {
667
- // Write profile to disk, upload, etc.
668
- if (!err) {
669
- const outPath = path.resolve(`./vite-profile-${profileCount++}.cpuprofile`);
670
- fs.writeFileSync(outPath, JSON.stringify(profile));
671
- log(colors.yellow(`CPU profile written to ${colors.white(colors.dim(outPath))}`));
672
- profileSession = undefined;
673
- res();
674
- }
675
- else {
676
- rej(err);
677
- }
678
- });
679
- });
680
- };
681
- const filterDuplicateOptions = (options) => {
682
- for (const [key, value] of Object.entries(options)) {
683
- if (Array.isArray(value)) {
684
- options[key] = value[value.length - 1];
685
- }
686
- }
687
- };
688
- /**
689
- * removing global flags before passing as command specific sub-configs
690
- */
691
- function cleanOptions(options) {
692
- const ret = { ...options };
693
- delete ret['--'];
694
- delete ret.c;
695
- delete ret.config;
696
- delete ret.base;
697
- delete ret.l;
698
- delete ret.logLevel;
699
- delete ret.clearScreen;
700
- delete ret.d;
701
- delete ret.debug;
702
- delete ret.f;
703
- delete ret.filter;
704
- delete ret.m;
705
- delete ret.mode;
706
- // convert the sourcemap option to a boolean if necessary
707
- if ('sourcemap' in ret) {
708
- const sourcemap = ret.sourcemap;
709
- ret.sourcemap =
710
- sourcemap === 'true'
711
- ? true
712
- : sourcemap === 'false'
713
- ? false
714
- : ret.sourcemap;
715
- }
716
- return ret;
717
- }
718
- /**
719
- * host may be a number (like 0), should convert to string
720
- */
721
- const convertHost = (v) => {
722
- if (typeof v === 'number') {
723
- return String(v);
724
- }
725
- return v;
726
- };
727
- /**
728
- * base may be a number (like 0), should convert to empty string
729
- */
730
- const convertBase = (v) => {
731
- if (v === 0) {
732
- return '';
733
- }
734
- return v;
735
- };
736
- cli
737
- .option('-c, --config <file>', `[string] use specified config file`)
738
- .option('--base <path>', `[string] public base path (default: /)`, {
739
- type: [convertBase],
740
- })
741
- .option('-l, --logLevel <level>', `[string] info | warn | error | silent`)
742
- .option('--clearScreen', `[boolean] allow/disable clear screen when logging`)
743
- .option('-d, --debug [feat]', `[string | boolean] show debug logs`)
744
- .option('-f, --filter <filter>', `[string] filter debug logs`)
745
- .option('-m, --mode <mode>', `[string] set env mode`);
746
- // dev
747
- cli
748
- .command('[root]', 'start dev server') // default command
749
- .alias('serve') // the command is called 'serve' in Vite's API
750
- .alias('dev') // alias to align with the script name
751
- .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
752
- .option('--port <port>', `[number] specify port`)
753
- .option('--https', `[boolean] use TLS + HTTP/2`)
754
- .option('--open [path]', `[boolean | string] open browser on startup`)
755
- .option('--cors', `[boolean] enable CORS`)
756
- .option('--strictPort', `[boolean] exit if specified port is already in use`)
757
- .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
758
- .action(async (root, options) => {
759
- filterDuplicateOptions(options);
760
- // output structure is preserved even after bundling so require()
761
- // is ok here
762
- const { createServer } = await import('./chunks/dep-827b23df.js').then(function (n) { return n.J; });
763
- try {
764
- const server = await createServer({
765
- root,
766
- base: options.base,
767
- mode: options.mode,
768
- configFile: options.config,
769
- logLevel: options.logLevel,
770
- clearScreen: options.clearScreen,
771
- optimizeDeps: { force: options.force },
772
- server: cleanOptions(options),
773
- });
774
- if (!server.httpServer) {
775
- throw new Error('HTTP server not available');
776
- }
777
- await server.listen();
778
- const info = server.config.logger.info;
779
- const viteStartTime = global.__vite_start_time ?? false;
780
- const startupDurationString = viteStartTime
781
- ? colors.dim(`ready in ${colors.reset(colors.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
782
- : '';
783
- info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
784
- server.printUrls();
785
- bindShortcuts(server, {
786
- print: true,
787
- customShortcuts: [
788
- profileSession && {
789
- key: 'p',
790
- description: 'start/stop the profiler',
791
- async action(server) {
792
- if (profileSession) {
793
- await stopProfiler(server.config.logger.info);
794
- }
795
- else {
796
- const inspector = await import('node:inspector').then((r) => r.default);
797
- await new Promise((res) => {
798
- profileSession = new inspector.Session();
799
- profileSession.connect();
800
- profileSession.post('Profiler.enable', () => {
801
- profileSession.post('Profiler.start', () => {
802
- server.config.logger.info('Profiler started');
803
- res();
804
- });
805
- });
806
- });
807
- }
808
- },
809
- },
810
- ],
811
- });
812
- }
813
- catch (e) {
814
- const logger = createLogger(options.logLevel);
815
- logger.error(colors.red(`error when starting dev server:\n${e.stack}`), {
816
- error: e,
817
- });
818
- stopProfiler(logger.info);
819
- process.exit(1);
820
- }
821
- });
822
- // build
823
- cli
824
- .command('build [root]', 'build for production')
825
- .option('--target <target>', `[string] transpile target (default: 'modules')`)
826
- .option('--outDir <dir>', `[string] output directory (default: dist)`)
827
- .option('--assetsDir <dir>', `[string] directory under outDir to place assets in (default: assets)`)
828
- .option('--assetsInlineLimit <number>', `[number] static asset base64 inline threshold in bytes (default: 4096)`)
829
- .option('--ssr [entry]', `[string] build specified entry for server-side rendering`)
830
- .option('--sourcemap [output]', `[boolean | "inline" | "hidden"] output source maps for build (default: false)`)
831
- .option('--minify [minifier]', `[boolean | "terser" | "esbuild"] enable/disable minification, ` +
832
- `or specify minifier to use (default: esbuild)`)
833
- .option('--manifest [name]', `[boolean | string] emit build manifest json`)
834
- .option('--ssrManifest [name]', `[boolean | string] emit ssr manifest json`)
835
- .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle (experimental)`)
836
- .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
837
- .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
838
- .action(async (root, options) => {
839
- filterDuplicateOptions(options);
840
- const { build } = await import('./chunks/dep-827b23df.js').then(function (n) { return n.I; });
841
- const buildOptions = cleanOptions(options);
842
- try {
843
- await build({
844
- root,
845
- base: options.base,
846
- mode: options.mode,
847
- configFile: options.config,
848
- logLevel: options.logLevel,
849
- clearScreen: options.clearScreen,
850
- optimizeDeps: { force: options.force },
851
- build: buildOptions,
852
- });
853
- }
854
- catch (e) {
855
- createLogger(options.logLevel).error(colors.red(`error during build:\n${e.stack}`), { error: e });
856
- process.exit(1);
857
- }
858
- finally {
859
- stopProfiler((message) => createLogger(options.logLevel).info(message));
860
- }
861
- });
862
- // optimize
863
- cli
864
- .command('optimize [root]', 'pre-bundle dependencies')
865
- .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
866
- .action(async (root, options) => {
867
- filterDuplicateOptions(options);
868
- const { optimizeDeps } = await import('./chunks/dep-827b23df.js').then(function (n) { return n.H; });
869
- try {
870
- const config = await resolveConfig({
871
- root,
872
- base: options.base,
873
- configFile: options.config,
874
- logLevel: options.logLevel,
875
- mode: options.mode,
876
- }, 'serve');
877
- await optimizeDeps(config, options.force, true);
878
- }
879
- catch (e) {
880
- createLogger(options.logLevel).error(colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
881
- process.exit(1);
882
- }
883
- });
884
- // preview
885
- cli
886
- .command('preview [root]', 'locally preview production build')
887
- .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
888
- .option('--port <port>', `[number] specify port`)
889
- .option('--strictPort', `[boolean] exit if specified port is already in use`)
890
- .option('--https', `[boolean] use TLS + HTTP/2`)
891
- .option('--open [path]', `[boolean | string] open browser on startup`)
892
- .option('--outDir <dir>', `[string] output directory (default: dist)`)
893
- .action(async (root, options) => {
894
- filterDuplicateOptions(options);
895
- const { preview } = await import('./chunks/dep-827b23df.js').then(function (n) { return n.K; });
896
- try {
897
- const server = await preview({
898
- root,
899
- base: options.base,
900
- configFile: options.config,
901
- logLevel: options.logLevel,
902
- mode: options.mode,
903
- build: {
904
- outDir: options.outDir,
905
- },
906
- preview: {
907
- port: options.port,
908
- strictPort: options.strictPort,
909
- host: options.host,
910
- https: options.https,
911
- open: options.open,
912
- },
913
- });
914
- server.printUrls();
915
- bindShortcuts(server, { print: true });
916
- }
917
- catch (e) {
918
- createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
919
- process.exit(1);
920
- }
921
- finally {
922
- stopProfiler((message) => createLogger(options.logLevel).info(message));
923
- }
924
- });
925
- cli.help();
926
- cli.version(VERSION);
927
- cli.parse();
928
-
929
- export { stopProfiler };