create-microact-app 1.0.1

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 (213) hide show
  1. package/index.js +95 -0
  2. package/package.json +21 -0
  3. package/templates/vanilla/.github/workflows/deploy.yml +38 -0
  4. package/templates/vanilla/index.html +13 -0
  5. package/templates/vanilla/node_modules/.package-lock.json +207 -0
  6. package/templates/vanilla/node_modules/@esbuild/darwin-x64/README.md +3 -0
  7. package/templates/vanilla/node_modules/@esbuild/darwin-x64/bin/esbuild +0 -0
  8. package/templates/vanilla/node_modules/@esbuild/darwin-x64/package.json +17 -0
  9. package/templates/vanilla/node_modules/@monygroupcorp/microact/README.md +154 -0
  10. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js +1749 -0
  11. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.cjs.js.map +1 -0
  12. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js +1743 -0
  13. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.esm.js.map +1 -0
  14. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js +2 -0
  15. package/templates/vanilla/node_modules/@monygroupcorp/microact/dist/microact.umd.js.map +1 -0
  16. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.html +13 -0
  17. package/templates/vanilla/node_modules/@monygroupcorp/microact/example/index.js +63 -0
  18. package/templates/vanilla/node_modules/@monygroupcorp/microact/package.json +38 -0
  19. package/templates/vanilla/node_modules/@monygroupcorp/microact/rollup.config.cjs +30 -0
  20. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Component.js +831 -0
  21. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/DOMUpdater.js +320 -0
  22. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/EventBus.js +123 -0
  23. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/Router.js +253 -0
  24. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/UpdateScheduler.js +218 -0
  25. package/templates/vanilla/node_modules/@monygroupcorp/microact/src/index.js +6 -0
  26. package/templates/vanilla/node_modules/esbuild/LICENSE.md +21 -0
  27. package/templates/vanilla/node_modules/esbuild/README.md +3 -0
  28. package/templates/vanilla/node_modules/esbuild/bin/esbuild +0 -0
  29. package/templates/vanilla/node_modules/esbuild/install.js +287 -0
  30. package/templates/vanilla/node_modules/esbuild/lib/main.d.ts +660 -0
  31. package/templates/vanilla/node_modules/esbuild/lib/main.js +2393 -0
  32. package/templates/vanilla/node_modules/esbuild/package.json +42 -0
  33. package/templates/vanilla/node_modules/nanoid/LICENSE +20 -0
  34. package/templates/vanilla/node_modules/nanoid/README.md +39 -0
  35. package/templates/vanilla/node_modules/nanoid/async/index.browser.cjs +69 -0
  36. package/templates/vanilla/node_modules/nanoid/async/index.browser.js +34 -0
  37. package/templates/vanilla/node_modules/nanoid/async/index.cjs +71 -0
  38. package/templates/vanilla/node_modules/nanoid/async/index.d.ts +56 -0
  39. package/templates/vanilla/node_modules/nanoid/async/index.js +35 -0
  40. package/templates/vanilla/node_modules/nanoid/async/index.native.js +26 -0
  41. package/templates/vanilla/node_modules/nanoid/async/package.json +12 -0
  42. package/templates/vanilla/node_modules/nanoid/bin/nanoid.cjs +55 -0
  43. package/templates/vanilla/node_modules/nanoid/index.browser.cjs +72 -0
  44. package/templates/vanilla/node_modules/nanoid/index.browser.js +34 -0
  45. package/templates/vanilla/node_modules/nanoid/index.cjs +85 -0
  46. package/templates/vanilla/node_modules/nanoid/index.d.cts +91 -0
  47. package/templates/vanilla/node_modules/nanoid/index.d.ts +91 -0
  48. package/templates/vanilla/node_modules/nanoid/index.js +45 -0
  49. package/templates/vanilla/node_modules/nanoid/nanoid.js +1 -0
  50. package/templates/vanilla/node_modules/nanoid/non-secure/index.cjs +34 -0
  51. package/templates/vanilla/node_modules/nanoid/non-secure/index.d.ts +33 -0
  52. package/templates/vanilla/node_modules/nanoid/non-secure/index.js +21 -0
  53. package/templates/vanilla/node_modules/nanoid/non-secure/package.json +6 -0
  54. package/templates/vanilla/node_modules/nanoid/package.json +89 -0
  55. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.cjs +7 -0
  56. package/templates/vanilla/node_modules/nanoid/url-alphabet/index.js +3 -0
  57. package/templates/vanilla/node_modules/nanoid/url-alphabet/package.json +6 -0
  58. package/templates/vanilla/node_modules/picocolors/LICENSE +15 -0
  59. package/templates/vanilla/node_modules/picocolors/README.md +21 -0
  60. package/templates/vanilla/node_modules/picocolors/package.json +25 -0
  61. package/templates/vanilla/node_modules/picocolors/picocolors.browser.js +4 -0
  62. package/templates/vanilla/node_modules/picocolors/picocolors.d.ts +5 -0
  63. package/templates/vanilla/node_modules/picocolors/picocolors.js +75 -0
  64. package/templates/vanilla/node_modules/picocolors/types.d.ts +51 -0
  65. package/templates/vanilla/node_modules/postcss/LICENSE +20 -0
  66. package/templates/vanilla/node_modules/postcss/README.md +29 -0
  67. package/templates/vanilla/node_modules/postcss/lib/at-rule.d.ts +140 -0
  68. package/templates/vanilla/node_modules/postcss/lib/at-rule.js +25 -0
  69. package/templates/vanilla/node_modules/postcss/lib/comment.d.ts +68 -0
  70. package/templates/vanilla/node_modules/postcss/lib/comment.js +13 -0
  71. package/templates/vanilla/node_modules/postcss/lib/container.d.ts +483 -0
  72. package/templates/vanilla/node_modules/postcss/lib/container.js +447 -0
  73. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.d.ts +248 -0
  74. package/templates/vanilla/node_modules/postcss/lib/css-syntax-error.js +133 -0
  75. package/templates/vanilla/node_modules/postcss/lib/declaration.d.ts +151 -0
  76. package/templates/vanilla/node_modules/postcss/lib/declaration.js +24 -0
  77. package/templates/vanilla/node_modules/postcss/lib/document.d.ts +69 -0
  78. package/templates/vanilla/node_modules/postcss/lib/document.js +33 -0
  79. package/templates/vanilla/node_modules/postcss/lib/fromJSON.d.ts +9 -0
  80. package/templates/vanilla/node_modules/postcss/lib/fromJSON.js +54 -0
  81. package/templates/vanilla/node_modules/postcss/lib/input.d.ts +227 -0
  82. package/templates/vanilla/node_modules/postcss/lib/input.js +265 -0
  83. package/templates/vanilla/node_modules/postcss/lib/lazy-result.d.ts +190 -0
  84. package/templates/vanilla/node_modules/postcss/lib/lazy-result.js +550 -0
  85. package/templates/vanilla/node_modules/postcss/lib/list.d.ts +60 -0
  86. package/templates/vanilla/node_modules/postcss/lib/list.js +58 -0
  87. package/templates/vanilla/node_modules/postcss/lib/map-generator.js +368 -0
  88. package/templates/vanilla/node_modules/postcss/lib/no-work-result.d.ts +46 -0
  89. package/templates/vanilla/node_modules/postcss/lib/no-work-result.js +138 -0
  90. package/templates/vanilla/node_modules/postcss/lib/node.d.ts +556 -0
  91. package/templates/vanilla/node_modules/postcss/lib/node.js +449 -0
  92. package/templates/vanilla/node_modules/postcss/lib/parse.d.ts +9 -0
  93. package/templates/vanilla/node_modules/postcss/lib/parse.js +42 -0
  94. package/templates/vanilla/node_modules/postcss/lib/parser.js +611 -0
  95. package/templates/vanilla/node_modules/postcss/lib/postcss.d.mts +69 -0
  96. package/templates/vanilla/node_modules/postcss/lib/postcss.d.ts +458 -0
  97. package/templates/vanilla/node_modules/postcss/lib/postcss.js +101 -0
  98. package/templates/vanilla/node_modules/postcss/lib/postcss.mjs +30 -0
  99. package/templates/vanilla/node_modules/postcss/lib/previous-map.d.ts +81 -0
  100. package/templates/vanilla/node_modules/postcss/lib/previous-map.js +144 -0
  101. package/templates/vanilla/node_modules/postcss/lib/processor.d.ts +115 -0
  102. package/templates/vanilla/node_modules/postcss/lib/processor.js +67 -0
  103. package/templates/vanilla/node_modules/postcss/lib/result.d.ts +205 -0
  104. package/templates/vanilla/node_modules/postcss/lib/result.js +42 -0
  105. package/templates/vanilla/node_modules/postcss/lib/root.d.ts +87 -0
  106. package/templates/vanilla/node_modules/postcss/lib/root.js +61 -0
  107. package/templates/vanilla/node_modules/postcss/lib/rule.d.ts +126 -0
  108. package/templates/vanilla/node_modules/postcss/lib/rule.js +27 -0
  109. package/templates/vanilla/node_modules/postcss/lib/stringifier.d.ts +46 -0
  110. package/templates/vanilla/node_modules/postcss/lib/stringifier.js +353 -0
  111. package/templates/vanilla/node_modules/postcss/lib/stringify.d.ts +9 -0
  112. package/templates/vanilla/node_modules/postcss/lib/stringify.js +11 -0
  113. package/templates/vanilla/node_modules/postcss/lib/symbols.js +5 -0
  114. package/templates/vanilla/node_modules/postcss/lib/terminal-highlight.js +70 -0
  115. package/templates/vanilla/node_modules/postcss/lib/tokenize.js +266 -0
  116. package/templates/vanilla/node_modules/postcss/lib/warn-once.js +13 -0
  117. package/templates/vanilla/node_modules/postcss/lib/warning.d.ts +147 -0
  118. package/templates/vanilla/node_modules/postcss/lib/warning.js +37 -0
  119. package/templates/vanilla/node_modules/postcss/package.json +88 -0
  120. package/templates/vanilla/node_modules/rollup/LICENSE.md +695 -0
  121. package/templates/vanilla/node_modules/rollup/README.md +125 -0
  122. package/templates/vanilla/node_modules/rollup/dist/bin/rollup +1715 -0
  123. package/templates/vanilla/node_modules/rollup/dist/es/getLogFilter.js +64 -0
  124. package/templates/vanilla/node_modules/rollup/dist/es/package.json +1 -0
  125. package/templates/vanilla/node_modules/rollup/dist/es/rollup.js +17 -0
  126. package/templates/vanilla/node_modules/rollup/dist/es/shared/node-entry.js +27273 -0
  127. package/templates/vanilla/node_modules/rollup/dist/es/shared/watch.js +4857 -0
  128. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.d.ts +5 -0
  129. package/templates/vanilla/node_modules/rollup/dist/getLogFilter.js +69 -0
  130. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.d.ts +20 -0
  131. package/templates/vanilla/node_modules/rollup/dist/loadConfigFile.js +29 -0
  132. package/templates/vanilla/node_modules/rollup/dist/rollup.d.ts +1012 -0
  133. package/templates/vanilla/node_modules/rollup/dist/rollup.js +31 -0
  134. package/templates/vanilla/node_modules/rollup/dist/shared/fsevents-importer.js +37 -0
  135. package/templates/vanilla/node_modules/rollup/dist/shared/index.js +4571 -0
  136. package/templates/vanilla/node_modules/rollup/dist/shared/loadConfigFile.js +546 -0
  137. package/templates/vanilla/node_modules/rollup/dist/shared/rollup.js +27351 -0
  138. package/templates/vanilla/node_modules/rollup/dist/shared/watch-cli.js +561 -0
  139. package/templates/vanilla/node_modules/rollup/dist/shared/watch-proxy.js +87 -0
  140. package/templates/vanilla/node_modules/rollup/dist/shared/watch.js +316 -0
  141. package/templates/vanilla/node_modules/rollup/package.json +181 -0
  142. package/templates/vanilla/node_modules/source-map-js/LICENSE +28 -0
  143. package/templates/vanilla/node_modules/source-map-js/README.md +765 -0
  144. package/templates/vanilla/node_modules/source-map-js/lib/array-set.js +121 -0
  145. package/templates/vanilla/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  146. package/templates/vanilla/node_modules/source-map-js/lib/base64.js +67 -0
  147. package/templates/vanilla/node_modules/source-map-js/lib/binary-search.js +111 -0
  148. package/templates/vanilla/node_modules/source-map-js/lib/mapping-list.js +79 -0
  149. package/templates/vanilla/node_modules/source-map-js/lib/quick-sort.js +132 -0
  150. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.d.ts +1 -0
  151. package/templates/vanilla/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  152. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.d.ts +1 -0
  153. package/templates/vanilla/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  154. package/templates/vanilla/node_modules/source-map-js/lib/source-node.d.ts +1 -0
  155. package/templates/vanilla/node_modules/source-map-js/lib/source-node.js +413 -0
  156. package/templates/vanilla/node_modules/source-map-js/lib/util.js +594 -0
  157. package/templates/vanilla/node_modules/source-map-js/package.json +71 -0
  158. package/templates/vanilla/node_modules/source-map-js/source-map.d.ts +104 -0
  159. package/templates/vanilla/node_modules/source-map-js/source-map.js +8 -0
  160. package/templates/vanilla/node_modules/vite/LICENSE.md +3396 -0
  161. package/templates/vanilla/node_modules/vite/README.md +20 -0
  162. package/templates/vanilla/node_modules/vite/bin/openChrome.applescript +95 -0
  163. package/templates/vanilla/node_modules/vite/bin/vite.js +61 -0
  164. package/templates/vanilla/node_modules/vite/client.d.ts +281 -0
  165. package/templates/vanilla/node_modules/vite/dist/client/client.mjs +725 -0
  166. package/templates/vanilla/node_modules/vite/dist/client/client.mjs.map +1 -0
  167. package/templates/vanilla/node_modules/vite/dist/client/env.mjs +30 -0
  168. package/templates/vanilla/node_modules/vite/dist/client/env.mjs.map +1 -0
  169. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-7ec6f216.js +914 -0
  170. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-827b23df.js +66713 -0
  171. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-c423598f.js +561 -0
  172. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f0c7dae0.js +7930 -0
  173. package/templates/vanilla/node_modules/vite/dist/node/chunks/dep-f1e8587f.js +7646 -0
  174. package/templates/vanilla/node_modules/vite/dist/node/cli.js +929 -0
  175. package/templates/vanilla/node_modules/vite/dist/node/constants.js +130 -0
  176. package/templates/vanilla/node_modules/vite/dist/node/index.d.ts +3548 -0
  177. package/templates/vanilla/node_modules/vite/dist/node/index.js +158 -0
  178. package/templates/vanilla/node_modules/vite/dist/node-cjs/publicUtils.cjs +4555 -0
  179. package/templates/vanilla/node_modules/vite/index.cjs +34 -0
  180. package/templates/vanilla/node_modules/vite/package.json +173 -0
  181. package/templates/vanilla/node_modules/vite/types/customEvent.d.ts +35 -0
  182. package/templates/vanilla/node_modules/vite/types/hmrPayload.d.ts +61 -0
  183. package/templates/vanilla/node_modules/vite/types/hot.d.ts +32 -0
  184. package/templates/vanilla/node_modules/vite/types/importGlob.d.ts +97 -0
  185. package/templates/vanilla/node_modules/vite/types/importMeta.d.ts +26 -0
  186. package/templates/vanilla/node_modules/vite/types/metadata.d.ts +10 -0
  187. package/templates/vanilla/node_modules/vite/types/package.json +4 -0
  188. package/templates/vanilla/package-lock.json +589 -0
  189. package/templates/vanilla/package.json +17 -0
  190. package/templates/vanilla/src/components/App.js +60 -0
  191. package/templates/vanilla/src/components/Card.js +21 -0
  192. package/templates/vanilla/src/components/Hero.js +15 -0
  193. package/templates/vanilla/src/components/InteractiveDemo.js +59 -0
  194. package/templates/vanilla/src/main.js +9 -0
  195. package/templates/vanilla/src/style/main.css +172 -0
  196. package/templates/vanilla/vite.config.js +8 -0
  197. package/templates/web3/.env.example +15 -0
  198. package/templates/web3/.github/workflows/deploy.yml +38 -0
  199. package/templates/web3/README.md +33 -0
  200. package/templates/web3/contracts/foundry.toml +11 -0
  201. package/templates/web3/contracts/script/Deploy.s.sol +13 -0
  202. package/templates/web3/contracts/src/Counter.sol +21 -0
  203. package/templates/web3/index.html +13 -0
  204. package/templates/web3/package.json +25 -0
  205. package/templates/web3/scripts/chain-start.mjs +305 -0
  206. package/templates/web3/scripts/chain-stop.mjs +34 -0
  207. package/templates/web3/scripts/deploy.mjs +155 -0
  208. package/templates/web3/scripts/setup.mjs +42 -0
  209. package/templates/web3/src/components/App.js +49 -0
  210. package/templates/web3/src/components/CounterCard.js +111 -0
  211. package/templates/web3/src/main.js +54 -0
  212. package/templates/web3/src/style/main.css +345 -0
  213. package/templates/web3/vite.config.js +29 -0
@@ -0,0 +1,929 @@
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 };