@wix/cli 1.1.76 → 1.1.78

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 (130) hide show
  1. package/build/{DevCommand-3HAKKJ3K.js → DevCommand-V5WDZS4B.js} +12 -12
  2. package/build/{DevCommand-LVRRQ4AL.js → DevCommand-WWEO6WT4.js} +43 -26
  3. package/build/{DevCommand-LVRRQ4AL.js.map → DevCommand-WWEO6WT4.js.map} +1 -1
  4. package/build/{InstallCommand-RNVO3BKP.js → InstallCommand-K5I3IQTL.js} +14 -14
  5. package/build/{LoginCommand-3XRBIMCL.js → LoginCommand-U4KJ4GD4.js} +9 -9
  6. package/build/{LogoutCommand-KF54IFPX.js → LogoutCommand-VHQCOUCO.js} +6 -6
  7. package/build/{PreviewCommand-5X7EXDSC.js → PreviewCommand-2ZQNXDBP.js} +16 -16
  8. package/build/{PreviewCommand-LHCJPJA2.js → PreviewCommand-MBNS3U3U.js} +16 -16
  9. package/build/{PublishCommand-FZQ6WHAV.js → PublishCommand-CQ4UEHTX.js} +16 -16
  10. package/build/{UninstallCommand-QDE7UX2I.js → UninstallCommand-AMWFTPZ5.js} +14 -14
  11. package/build/{WhoamiCommand-U3FOJU24.js → WhoamiCommand-QEGMSHQ2.js} +3 -3
  12. package/build/{chunk-OOS26XL7.js → chunk-37SSXHXJ.js} +7 -7
  13. package/build/{chunk-DO62B7KA.js → chunk-6CQXTPSU.js} +3 -3
  14. package/build/{chunk-7F67FQ34.js → chunk-75THOFWQ.js} +3 -3
  15. package/build/{chunk-GCNYWJU6.js → chunk-7CXKIQNA.js} +7 -4
  16. package/build/{chunk-GCNYWJU6.js.map → chunk-7CXKIQNA.js.map} +1 -1
  17. package/build/{chunk-B4CPCNOD.js → chunk-B5KXKZY5.js} +2 -2
  18. package/build/{chunk-BJ7Z6NAJ.js → chunk-BOCVEA2O.js} +2 -2
  19. package/build/{chunk-MNJL22KV.js → chunk-BRO65NMB.js} +4 -4
  20. package/build/{chunk-SLWJ5VS2.js → chunk-BYHAPURJ.js} +3 -3
  21. package/build/{chunk-DKVRKMVW.js → chunk-F63GAI4F.js} +2 -1
  22. package/build/{chunk-DKVRKMVW.js.map → chunk-F63GAI4F.js.map} +1 -1
  23. package/build/{chunk-LFTBHG6D.js → chunk-FQB5WA6K.js} +2 -2
  24. package/build/{chunk-ZOKVZQ4A.js → chunk-GZZLN27Q.js} +2 -2
  25. package/build/{chunk-4QSZX64K.js → chunk-IMBJZ3UI.js} +2 -2
  26. package/build/{chunk-RG3BUZIC.js → chunk-JHX6EZIO.js} +3 -3
  27. package/build/{chunk-4ZYZEEHX.js → chunk-JSLUM7TU.js} +10 -8
  28. package/build/{chunk-4ZYZEEHX.js.map → chunk-JSLUM7TU.js.map} +1 -1
  29. package/build/{chunk-CFDP3M2N.js → chunk-KI3KRWT4.js} +2 -2
  30. package/build/{chunk-KBDI4S6W.js → chunk-KRDDGNES.js} +2 -2
  31. package/build/{chunk-IU5SPMBI.js → chunk-LYL4JUHA.js} +2 -2
  32. package/build/{chunk-MEDEBLXN.js → chunk-M4KFHLVR.js} +10 -27
  33. package/build/chunk-M4KFHLVR.js.map +1 -0
  34. package/build/{chunk-EQY46BAC.js → chunk-MHIV5HR5.js} +3 -3
  35. package/build/{chunk-UQJZNC6L.js → chunk-NQ6XAGAF.js} +3 -3
  36. package/build/{chunk-3FFVU4JP.js → chunk-PR73JPSE.js} +2 -2
  37. package/build/{chunk-GJ6S5EFI.js → chunk-RH2ZHUFP.js} +5 -5
  38. package/build/chunk-RH2ZHUFP.js.map +1 -0
  39. package/build/{chunk-NGJC2725.js → chunk-RILMLOX5.js} +3 -3
  40. package/build/{chunk-NUEDXJIR.js → chunk-RTDQOZ3U.js} +5 -5
  41. package/build/{chunk-WAI23YOI.js → chunk-T2TARSVP.js} +3 -3
  42. package/build/{chunk-B4YQPDSJ.js → chunk-UDTYL6OI.js} +27 -4
  43. package/build/chunk-UDTYL6OI.js.map +1 -0
  44. package/build/{chunk-QPOVSKWU.js → chunk-V7C6EZG4.js} +7 -7
  45. package/build/{chunk-P7C5YAYN.js → chunk-VGH2WOQG.js} +4 -4
  46. package/build/{chunk-P7C5YAYN.js.map → chunk-VGH2WOQG.js.map} +1 -1
  47. package/build/{chunk-QK5N6ZMB.js → chunk-VTOZLUQR.js} +5 -5
  48. package/build/{chunk-B4DDDAJU.js → chunk-WC2H22NZ.js} +5 -5
  49. package/build/{chunk-OTIWV2FH.js → chunk-XHUQFWXB.js} +1002 -102
  50. package/build/chunk-XHUQFWXB.js.map +1 -0
  51. package/build/{chunk-DBBN5OWA.js → chunk-YQHKS7GJ.js} +3 -3
  52. package/build/{chunk-TKOWKMEX.js → chunk-YUGTQQID.js} +3 -3
  53. package/build/{chunk-AYNJ4R5B.js → chunk-Z3BKHPN5.js} +2 -1
  54. package/build/chunk-Z3BKHPN5.js.map +1 -0
  55. package/build/dev-GMC75OLH.js +809 -0
  56. package/build/dev-GMC75OLH.js.map +1 -0
  57. package/build/index.js +22 -22
  58. package/build/{install-NUZR5YUA.js → install-5WCR4UVH.js} +15 -15
  59. package/build/{publish-VUCQH454.js → publish-QZQC4D5V.js} +16 -16
  60. package/build/{render-command-YXYFVRLE.js → render-command-2WCIXKOR.js} +10 -10
  61. package/build/{render-command-OW3EPBXD.js → render-command-4Z5GYACI.js} +8 -8
  62. package/build/{render-command-MKQQF3K6.js → render-command-5BX6P437.js} +9 -9
  63. package/build/{render-command-WS2QIYHX.js → render-command-U3MODL5F.js} +10 -10
  64. package/build/{run-command-IAOE7U2C.js → run-command-M4SJR3M3.js} +7 -7
  65. package/build/{src-O72D2TES.js → src-45KK47A7.js} +5 -5
  66. package/build/{src-AERLLIWO.js → src-CQCCIQ37.js} +4 -4
  67. package/build/{src-YEOI453Q.js → src-FUP5ZJ7V.js} +2 -2
  68. package/build/{src-I4DBGYZE.js → src-PEZ7FCVG.js} +6 -6
  69. package/build/{src-6U7EOYQR.js → src-QKJMBEHM.js} +16 -16
  70. package/build/{src-LHCBB23V.js → src-WY6KW6NB.js} +22 -16
  71. package/build/src-WY6KW6NB.js.map +1 -0
  72. package/build/{sync-types-SK5JNAOE.js → sync-types-HPZP6SB5.js} +11 -11
  73. package/build/{uninstall-RC5EPW5R.js → uninstall-CJGYAE4U.js} +15 -15
  74. package/package.json +2 -2
  75. package/build/chunk-AYNJ4R5B.js.map +0 -1
  76. package/build/chunk-B4YQPDSJ.js.map +0 -1
  77. package/build/chunk-GJ6S5EFI.js.map +0 -1
  78. package/build/chunk-MEDEBLXN.js.map +0 -1
  79. package/build/chunk-OTIWV2FH.js.map +0 -1
  80. package/build/dev-SRKAKGMG.js +0 -1613
  81. package/build/dev-SRKAKGMG.js.map +0 -1
  82. package/build/src-LHCBB23V.js.map +0 -1
  83. /package/build/{DevCommand-3HAKKJ3K.js.map → DevCommand-V5WDZS4B.js.map} +0 -0
  84. /package/build/{InstallCommand-RNVO3BKP.js.map → InstallCommand-K5I3IQTL.js.map} +0 -0
  85. /package/build/{LoginCommand-3XRBIMCL.js.map → LoginCommand-U4KJ4GD4.js.map} +0 -0
  86. /package/build/{LogoutCommand-KF54IFPX.js.map → LogoutCommand-VHQCOUCO.js.map} +0 -0
  87. /package/build/{PreviewCommand-5X7EXDSC.js.map → PreviewCommand-2ZQNXDBP.js.map} +0 -0
  88. /package/build/{PreviewCommand-LHCJPJA2.js.map → PreviewCommand-MBNS3U3U.js.map} +0 -0
  89. /package/build/{PublishCommand-FZQ6WHAV.js.map → PublishCommand-CQ4UEHTX.js.map} +0 -0
  90. /package/build/{UninstallCommand-QDE7UX2I.js.map → UninstallCommand-AMWFTPZ5.js.map} +0 -0
  91. /package/build/{WhoamiCommand-U3FOJU24.js.map → WhoamiCommand-QEGMSHQ2.js.map} +0 -0
  92. /package/build/{chunk-OOS26XL7.js.map → chunk-37SSXHXJ.js.map} +0 -0
  93. /package/build/{chunk-DO62B7KA.js.map → chunk-6CQXTPSU.js.map} +0 -0
  94. /package/build/{chunk-7F67FQ34.js.map → chunk-75THOFWQ.js.map} +0 -0
  95. /package/build/{chunk-B4CPCNOD.js.map → chunk-B5KXKZY5.js.map} +0 -0
  96. /package/build/{chunk-BJ7Z6NAJ.js.map → chunk-BOCVEA2O.js.map} +0 -0
  97. /package/build/{chunk-MNJL22KV.js.map → chunk-BRO65NMB.js.map} +0 -0
  98. /package/build/{chunk-SLWJ5VS2.js.map → chunk-BYHAPURJ.js.map} +0 -0
  99. /package/build/{chunk-LFTBHG6D.js.map → chunk-FQB5WA6K.js.map} +0 -0
  100. /package/build/{chunk-ZOKVZQ4A.js.map → chunk-GZZLN27Q.js.map} +0 -0
  101. /package/build/{chunk-4QSZX64K.js.map → chunk-IMBJZ3UI.js.map} +0 -0
  102. /package/build/{chunk-RG3BUZIC.js.map → chunk-JHX6EZIO.js.map} +0 -0
  103. /package/build/{chunk-CFDP3M2N.js.map → chunk-KI3KRWT4.js.map} +0 -0
  104. /package/build/{chunk-KBDI4S6W.js.map → chunk-KRDDGNES.js.map} +0 -0
  105. /package/build/{chunk-IU5SPMBI.js.map → chunk-LYL4JUHA.js.map} +0 -0
  106. /package/build/{chunk-EQY46BAC.js.map → chunk-MHIV5HR5.js.map} +0 -0
  107. /package/build/{chunk-UQJZNC6L.js.map → chunk-NQ6XAGAF.js.map} +0 -0
  108. /package/build/{chunk-3FFVU4JP.js.map → chunk-PR73JPSE.js.map} +0 -0
  109. /package/build/{chunk-NGJC2725.js.map → chunk-RILMLOX5.js.map} +0 -0
  110. /package/build/{chunk-NUEDXJIR.js.map → chunk-RTDQOZ3U.js.map} +0 -0
  111. /package/build/{chunk-WAI23YOI.js.map → chunk-T2TARSVP.js.map} +0 -0
  112. /package/build/{chunk-QPOVSKWU.js.map → chunk-V7C6EZG4.js.map} +0 -0
  113. /package/build/{chunk-QK5N6ZMB.js.map → chunk-VTOZLUQR.js.map} +0 -0
  114. /package/build/{chunk-B4DDDAJU.js.map → chunk-WC2H22NZ.js.map} +0 -0
  115. /package/build/{chunk-DBBN5OWA.js.map → chunk-YQHKS7GJ.js.map} +0 -0
  116. /package/build/{chunk-TKOWKMEX.js.map → chunk-YUGTQQID.js.map} +0 -0
  117. /package/build/{install-NUZR5YUA.js.map → install-5WCR4UVH.js.map} +0 -0
  118. /package/build/{publish-VUCQH454.js.map → publish-QZQC4D5V.js.map} +0 -0
  119. /package/build/{render-command-YXYFVRLE.js.map → render-command-2WCIXKOR.js.map} +0 -0
  120. /package/build/{render-command-OW3EPBXD.js.map → render-command-4Z5GYACI.js.map} +0 -0
  121. /package/build/{render-command-MKQQF3K6.js.map → render-command-5BX6P437.js.map} +0 -0
  122. /package/build/{render-command-WS2QIYHX.js.map → render-command-U3MODL5F.js.map} +0 -0
  123. /package/build/{run-command-IAOE7U2C.js.map → run-command-M4SJR3M3.js.map} +0 -0
  124. /package/build/{src-O72D2TES.js.map → src-45KK47A7.js.map} +0 -0
  125. /package/build/{src-AERLLIWO.js.map → src-CQCCIQ37.js.map} +0 -0
  126. /package/build/{src-I4DBGYZE.js.map → src-FUP5ZJ7V.js.map} +0 -0
  127. /package/build/{src-YEOI453Q.js.map → src-PEZ7FCVG.js.map} +0 -0
  128. /package/build/{src-6U7EOYQR.js.map → src-QKJMBEHM.js.map} +0 -0
  129. /package/build/{sync-types-SK5JNAOE.js.map → sync-types-HPZP6SB5.js.map} +0 -0
  130. /package/build/{uninstall-RC5EPW5R.js.map → uninstall-CJGYAE4U.js.map} +0 -0
@@ -0,0 +1,809 @@
1
+ import { createRequire as _createRequire } from 'node:module';
2
+ const require = _createRequire(import.meta.url);
3
+ import {
4
+ syncTypesWithAuth
5
+ } from "./chunk-VTOZLUQR.js";
6
+ import {
7
+ createLogger
8
+ } from "./chunk-BOCVEA2O.js";
9
+ import {
10
+ createI18nT
11
+ } from "./chunk-IMBJZ3UI.js";
12
+ import "./chunk-CNXKF7E3.js";
13
+ import {
14
+ authenticate
15
+ } from "./chunk-75THOFWQ.js";
16
+ import "./chunk-HCJQQACZ.js";
17
+ import {
18
+ loadProjectGridAppContent
19
+ } from "./chunk-WC2H22NZ.js";
20
+ import {
21
+ httpRequest
22
+ } from "./chunk-JHX6EZIO.js";
23
+ import {
24
+ saveProjectModel
25
+ } from "./chunk-YQHKS7GJ.js";
26
+ import "./chunk-OELBJVRN.js";
27
+ import {
28
+ TunnelClient,
29
+ createVeloCLIServer,
30
+ debounceQueue,
31
+ launchTunnel,
32
+ require_chokidar
33
+ } from "./chunk-XHUQFWXB.js";
34
+ import {
35
+ require_normalize_path
36
+ } from "./chunk-EDFOB3LN.js";
37
+ import "./chunk-BRO65NMB.js";
38
+ import "./chunk-E2POOOG2.js";
39
+ import "./chunk-OJHDGJWP.js";
40
+ import {
41
+ updateFiles
42
+ } from "./chunk-UDTYL6OI.js";
43
+ import {
44
+ AppType,
45
+ GridAppLayout as GridAppLayout2,
46
+ createApp,
47
+ pagesDiff
48
+ } from "./chunk-PR73JPSE.js";
49
+ import {
50
+ GridAppLayout
51
+ } from "./chunk-6LI4WGAW.js";
52
+ import "./chunk-T2TARSVP.js";
53
+ import {
54
+ createHttpClient,
55
+ isHttpError,
56
+ openBrowser,
57
+ pLimit
58
+ } from "./chunk-RH2ZHUFP.js";
59
+ import {
60
+ ErrorViewer,
61
+ extractHttpError,
62
+ writeCrashReport
63
+ } from "./chunk-7CXKIQNA.js";
64
+ import {
65
+ wixCliCliMessageDisplayed,
66
+ wixCliCodeHasBeenChanged,
67
+ wixCliFileFolderCreatedRenamedDeleted,
68
+ wixCliReadyForReloadAfterCodeChange,
69
+ wixCliUserResponseToCliMessage
70
+ } from "./chunk-KUAMU72Z.js";
71
+ import {
72
+ renderSync
73
+ } from "./chunk-GZZLN27Q.js";
74
+ import {
75
+ require_react
76
+ } from "./chunk-LXW2RB2I.js";
77
+ import "./chunk-2K5KKUL3.js";
78
+ import "./chunk-YU54OBFT.js";
79
+ import "./chunk-XMTHMR2B.js";
80
+ import "./chunk-FQB5WA6K.js";
81
+ import {
82
+ getDebugLogFilePath,
83
+ getPagesFolder,
84
+ getSourceFolder,
85
+ getTypesDir
86
+ } from "./chunk-YLK75XXM.js";
87
+ import {
88
+ outputFile,
89
+ pathExists
90
+ } from "./chunk-KI3KRWT4.js";
91
+ import {
92
+ getTestOverrides
93
+ } from "./chunk-GO2GZJCK.js";
94
+ import {
95
+ CliError,
96
+ CliErrorCode
97
+ } from "./chunk-F63GAI4F.js";
98
+ import {
99
+ __toESM,
100
+ init_esm_shims
101
+ } from "./chunk-PYIAC2GK.js";
102
+
103
+ // ../cli-site-old/src/dev/index.ts
104
+ init_esm_shims();
105
+
106
+ // ../cli-site-old/src/dev/dev.ts
107
+ init_esm_shims();
108
+
109
+ // ../../node_modules/exit-hook/index.js
110
+ init_esm_shims();
111
+ import process from "node:process";
112
+ var asyncCallbacks = /* @__PURE__ */ new Set();
113
+ var callbacks = /* @__PURE__ */ new Set();
114
+ var isCalled = false;
115
+ var isRegistered = false;
116
+ async function exit(shouldManuallyExit, isSynchronous, signal) {
117
+ if (isCalled) {
118
+ return;
119
+ }
120
+ isCalled = true;
121
+ if (asyncCallbacks.size > 0 && isSynchronous) {
122
+ console.error([
123
+ "SYNCHRONOUS TERMINATION NOTICE:",
124
+ "When explicitly exiting the process via process.exit or via a parent process,",
125
+ "asynchronous tasks in your exitHooks will not run. Either remove these tasks,",
126
+ "use gracefulExit() instead of process.exit(), or ensure your parent process",
127
+ "sends a SIGINT to the process running this code."
128
+ ].join(" "));
129
+ }
130
+ const exitCode = 128 + signal;
131
+ const done = (force = false) => {
132
+ if (force === true || shouldManuallyExit === true) {
133
+ process.exit(exitCode);
134
+ }
135
+ };
136
+ for (const callback of callbacks) {
137
+ callback(exitCode);
138
+ }
139
+ if (isSynchronous) {
140
+ done();
141
+ return;
142
+ }
143
+ const promises = [];
144
+ let forceAfter = 0;
145
+ for (const [callback, wait] of asyncCallbacks) {
146
+ forceAfter = Math.max(forceAfter, wait);
147
+ promises.push(Promise.resolve(callback(exitCode)));
148
+ }
149
+ const asyncTimer = setTimeout(() => {
150
+ done(true);
151
+ }, forceAfter);
152
+ await Promise.all(promises);
153
+ clearTimeout(asyncTimer);
154
+ done();
155
+ }
156
+ function addHook(options) {
157
+ const { onExit, wait, isSynchronous } = options;
158
+ const asyncCallbackConfig = [onExit, wait];
159
+ if (isSynchronous) {
160
+ callbacks.add(onExit);
161
+ } else {
162
+ asyncCallbacks.add(asyncCallbackConfig);
163
+ }
164
+ if (!isRegistered) {
165
+ isRegistered = true;
166
+ process.once("beforeExit", exit.bind(void 0, true, false, -128));
167
+ process.once("SIGINT", exit.bind(void 0, true, false, 2));
168
+ process.once("SIGTERM", exit.bind(void 0, true, false, 15));
169
+ process.once("exit", exit.bind(void 0, false, true, 0));
170
+ process.on("message", (message) => {
171
+ if (message === "shutdown") {
172
+ exit(true, true, -128);
173
+ }
174
+ });
175
+ }
176
+ return () => {
177
+ if (isSynchronous) {
178
+ callbacks.delete(onExit);
179
+ } else {
180
+ asyncCallbacks.delete(asyncCallbackConfig);
181
+ }
182
+ };
183
+ }
184
+ function asyncExitHook(onExit, options = {}) {
185
+ if (typeof onExit !== "function") {
186
+ throw new TypeError("onExit must be a function");
187
+ }
188
+ if (!(typeof options.wait === "number" && options.wait > 0)) {
189
+ throw new TypeError("wait must be set to a positive numeric value");
190
+ }
191
+ return addHook({
192
+ onExit,
193
+ wait: options.wait,
194
+ isSynchronous: false
195
+ });
196
+ }
197
+
198
+ // ../cli-site-old/src/dev/dev.ts
199
+ var import_react = __toESM(require_react(), 1);
200
+
201
+ // ../cli-site-old/src/environment.ts
202
+ init_esm_shims();
203
+ var DEV_EDITOR_BASE_URL = "https://wix.com/editor/";
204
+ function getDevEditorBaseUrl() {
205
+ return getTestOverrides().devEditorBaseUrl ?? DEV_EDITOR_BASE_URL;
206
+ }
207
+
208
+ // ../cli-site-old/src/gridapp/createGridApp.ts
209
+ init_esm_shims();
210
+
211
+ // ../cli-site-old/src/gridapp/error-handlers/maxFileSizeErrorHandler.ts
212
+ init_esm_shims();
213
+ function catchFilesMaxSizeError(err, files = []) {
214
+ if (!files.length) {
215
+ return;
216
+ }
217
+ const httpError = extractHttpError(err);
218
+ if (!httpError) {
219
+ return;
220
+ }
221
+ const filesMaxSizeRawViolations = httpError.response?.data?.details?.validationError?.fieldViolations?.filter(
222
+ (v) => v.violatedRule === "MAX_LENGTH"
223
+ );
224
+ if (!filesMaxSizeRawViolations?.length) {
225
+ return;
226
+ }
227
+ const maxSizeViolationsData = tryExtractMaxSizeViolationMetadata(
228
+ filesMaxSizeRawViolations
229
+ );
230
+ throw new CliError({
231
+ code: CliErrorCode.GridAppFilesMaxLengthExceeded({
232
+ maxSizeViolationsData,
233
+ filePaths: files.map((f) => f.path ?? "[unknown file path]")
234
+ }),
235
+ cause: httpError
236
+ });
237
+ }
238
+ function tryExtractMaxSizeViolationMetadata(filesMaxSizeViolations) {
239
+ const fileIndexRegex = /\[(?<fileIndex>\d+)\].content/;
240
+ const expectedAndReceivedSizeRegex = /has size (?<receivedSize>\d+), expected (?<expectedSize>\d+) or less/;
241
+ const violationsData = {
242
+ expectedSize: void 0,
243
+ files: []
244
+ };
245
+ for (const filesMaxSizeViolation of filesMaxSizeViolations) {
246
+ const fileIndexMatchResult = fileIndexRegex.exec(
247
+ filesMaxSizeViolation.field
248
+ );
249
+ const expectedAndReceivedSizeMatchResult = expectedAndReceivedSizeRegex.exec(filesMaxSizeViolation.description);
250
+ if (!(fileIndexMatchResult?.groups?.fileIndex && expectedAndReceivedSizeMatchResult?.groups?.receivedSize && expectedAndReceivedSizeMatchResult.groups.expectedSize)) {
251
+ return null;
252
+ }
253
+ violationsData.expectedSize ??= Math.trunc(
254
+ parseInt(expectedAndReceivedSizeMatchResult.groups.expectedSize, 10) / 1e3
255
+ );
256
+ violationsData.files.push({
257
+ receivedSize: Math.trunc(
258
+ parseInt(expectedAndReceivedSizeMatchResult.groups.receivedSize, 10) / 1e3
259
+ ),
260
+ fileIndex: parseInt(fileIndexMatchResult.groups.fileIndex, 10)
261
+ });
262
+ }
263
+ return violationsData;
264
+ }
265
+
266
+ // ../cli-site-old/src/gridapp/createGridApp.ts
267
+ async function createAppWithParams(params, opts) {
268
+ let app;
269
+ try {
270
+ const response = await httpRequest(
271
+ { type: "code", authState: opts.authState },
272
+ createApp(params)
273
+ );
274
+ app = response.data.app;
275
+ } catch (err) {
276
+ catchFilesMaxSizeError(err, params.content?.files);
277
+ throw err;
278
+ }
279
+ if (!app?.id) {
280
+ throw new CliError({
281
+ code: CliErrorCode.InvalidCreateAppResponse(),
282
+ info: { app },
283
+ cause: null
284
+ });
285
+ }
286
+ return app.id;
287
+ }
288
+ async function createMutableGridApp(projectFolder, opts) {
289
+ const content = await loadProjectGridAppContent(projectFolder);
290
+ return createAppWithParams(
291
+ {
292
+ app: {
293
+ mutable: true,
294
+ appType: AppType.VELO_ISOLATED
295
+ },
296
+ content
297
+ },
298
+ opts
299
+ );
300
+ }
301
+
302
+ // ../cli-site-old/src/gridapp/startGridAppUpdater.ts
303
+ init_esm_shims();
304
+ import { readFile } from "node:fs/promises";
305
+ import { join } from "node:path";
306
+ var import_chokidar = __toESM(require_chokidar(), 1);
307
+ var import_normalize_path = __toESM(require_normalize_path(), 1);
308
+ var WATCH_FS_EVENTS_DEBOUNCE_TIME = 1e3;
309
+ var getSectionName = (path) => {
310
+ if (path.startsWith("src/pages")) {
311
+ return "public";
312
+ }
313
+ if (path.startsWith("src/backend")) {
314
+ return "backend";
315
+ }
316
+ return "other";
317
+ };
318
+ function startGridAppUpdater(model, gridAppId, opts, logger, biEvents) {
319
+ const { projectFolder } = model;
320
+ const limit = pLimit(1);
321
+ const watcher = (0, import_chokidar.watch)(getSourceFolder(projectFolder), {
322
+ disableGlobbing: true,
323
+ cwd: projectFolder,
324
+ ignoreInitial: true
325
+ }).on(
326
+ "all",
327
+ debounceQueue(async (events) => {
328
+ await limit(async () => {
329
+ const logSynced = logger.logSyncingLocalCode();
330
+ const { added, changed, removed } = normalizeChokidarBatchedEvents(events);
331
+ const addedArray = Array.from(added.values()).map((path) => ({
332
+ path,
333
+ type: "create"
334
+ }));
335
+ const changedArray = Array.from(changed.values()).map((path) => ({
336
+ path,
337
+ type: "update"
338
+ }));
339
+ const removedArray = Array.from(removed.values()).map((path) => ({
340
+ path,
341
+ type: "delete"
342
+ }));
343
+ for (const val of [...addedArray, ...changedArray, ...removedArray]) {
344
+ biEvents.file({
345
+ model,
346
+ action: val.type,
347
+ path: val.path,
348
+ oldPath: "",
349
+ sectionName: getSectionName(val.path)
350
+ });
351
+ if (val.type === "update") {
352
+ biEvents.codeChanged(model, val.path);
353
+ }
354
+ }
355
+ try {
356
+ await writeFiles({
357
+ filesToUpdate: await Promise.all(
358
+ addedArray.concat(changedArray).map(async (val) => ({
359
+ path: (0, import_normalize_path.default)(val.path),
360
+ content: await readFile(
361
+ join(projectFolder, val.path),
362
+ "utf8"
363
+ )
364
+ }))
365
+ ),
366
+ removedArray,
367
+ gridAppId,
368
+ authState: opts.authState
369
+ });
370
+ const message = logSynced.success();
371
+ biEvents.messageDisplayed({ message, model });
372
+ biEvents.readyForReloadAfterCodeChanged(model);
373
+ } catch (e) {
374
+ logSynced.fail();
375
+ const error = new CliError({
376
+ code: CliErrorCode.GridAppFailedToUpdateFiles(),
377
+ cause: e,
378
+ info: {
379
+ added,
380
+ changed,
381
+ removed
382
+ }
383
+ });
384
+ opts.onError(error);
385
+ }
386
+ });
387
+ }, WATCH_FS_EVENTS_DEBOUNCE_TIME)
388
+ ).on("error", (e) => {
389
+ const error = new CliError({
390
+ code: CliErrorCode.FailedToWatchFiles(),
391
+ cause: e
392
+ });
393
+ opts.onError(error);
394
+ });
395
+ return { close: () => watcher.close() };
396
+ }
397
+ function normalizeChokidarBatchedEvents(events) {
398
+ return events.reduce(
399
+ (result, [eventType, filePath]) => {
400
+ switch (eventType) {
401
+ case "add": {
402
+ result.added.add(filePath);
403
+ break;
404
+ }
405
+ case "change": {
406
+ result.changed.add(filePath);
407
+ break;
408
+ }
409
+ case "unlink": {
410
+ result.added.delete(filePath);
411
+ result.changed.delete(filePath);
412
+ result.removed.add(filePath);
413
+ break;
414
+ }
415
+ case "unlinkDir": {
416
+ const filePathAsDir = filePath.endsWith("/") ? filePath : `${filePath}/`;
417
+ for (const filePath2 of result.added) {
418
+ if (filePath2.startsWith(filePathAsDir)) {
419
+ result.added.delete(filePath2);
420
+ }
421
+ }
422
+ for (const filePath2 of result.changed) {
423
+ if (filePath2.startsWith(filePathAsDir)) {
424
+ result.changed.delete(filePath2);
425
+ }
426
+ }
427
+ result.removed.add(filePath);
428
+ break;
429
+ }
430
+ case "addDir": {
431
+ break;
432
+ }
433
+ }
434
+ return result;
435
+ },
436
+ {
437
+ added: /* @__PURE__ */ new Set(),
438
+ changed: /* @__PURE__ */ new Set(),
439
+ removed: /* @__PURE__ */ new Set()
440
+ }
441
+ );
442
+ }
443
+ async function writeFiles({
444
+ filesToUpdate,
445
+ removedArray,
446
+ gridAppId,
447
+ authState
448
+ }) {
449
+ try {
450
+ await httpRequest(
451
+ {
452
+ type: "code",
453
+ authState
454
+ },
455
+ updateFiles({
456
+ gridAppId,
457
+ layout: GridAppLayout.GITHUB,
458
+ filesToUpdate,
459
+ ignoreForbiddenPaths: true,
460
+ pathsToDelete: removedArray.map((val) => val.path)
461
+ })
462
+ );
463
+ } catch (err) {
464
+ catchFilesMaxSizeError(err, filesToUpdate);
465
+ throw err;
466
+ }
467
+ }
468
+
469
+ // ../cli-site-old/src/key-watcher.ts
470
+ init_esm_shims();
471
+ import readline from "node:readline";
472
+ import { stdin } from "node:process";
473
+ var KeyWatcher = class {
474
+ actions = /* @__PURE__ */ new Map();
475
+ watchExitProcess() {
476
+ return new Promise((resolve) => {
477
+ this.on("c", (key) => {
478
+ if (key.ctrl) {
479
+ resolve();
480
+ }
481
+ });
482
+ });
483
+ }
484
+ on(key, callback) {
485
+ this.actions.set(key, callback);
486
+ }
487
+ watch() {
488
+ const rl = readline.createInterface(stdin);
489
+ readline.emitKeypressEvents(stdin, rl);
490
+ if (stdin.isTTY) {
491
+ stdin.setRawMode(true);
492
+ stdin.setEncoding("utf8");
493
+ }
494
+ stdin.on("keypress", this.handleKeyPress);
495
+ return {
496
+ ctrlCPromise: this.watchExitProcess()
497
+ };
498
+ }
499
+ unwatch() {
500
+ if (stdin.isTTY) {
501
+ stdin.setRawMode(false);
502
+ }
503
+ stdin.off("keypress", this.handleKeyPress);
504
+ stdin.pause();
505
+ this.actions.clear();
506
+ }
507
+ handleKeyPress = (_, key) => {
508
+ this.actions.get(key.name)?.(key);
509
+ };
510
+ };
511
+
512
+ // ../cli-site-old/src/bi.ts
513
+ init_esm_shims();
514
+ import { randomUUID } from "node:crypto";
515
+ var sitesBiEvents = (biLogger) => ({
516
+ file: ({
517
+ model,
518
+ action,
519
+ path,
520
+ sectionName,
521
+ oldPath
522
+ }) => {
523
+ void biLogger.report(
524
+ wixCliFileFolderCreatedRenamedDeleted({
525
+ action,
526
+ path,
527
+ sectionName,
528
+ oldPath,
529
+ siteRevision: Number(model.revision)
530
+ })
531
+ );
532
+ },
533
+ codeChanged: (model, fileName) => {
534
+ void biLogger.report(
535
+ wixCliCodeHasBeenChanged({
536
+ fileName,
537
+ siteRevision: Number(model.revision)
538
+ })
539
+ );
540
+ },
541
+ readyForReloadAfterCodeChanged: (model) => {
542
+ void biLogger.report(
543
+ wixCliReadyForReloadAfterCodeChange({
544
+ siteRevision: Number(model.revision)
545
+ })
546
+ );
547
+ },
548
+ messageDisplayed: ({
549
+ message,
550
+ model
551
+ }) => {
552
+ void biLogger.report(
553
+ wixCliCliMessageDisplayed({
554
+ message,
555
+ messageId: randomUUID(),
556
+ siteRevision: Number(model.revision)
557
+ })
558
+ );
559
+ },
560
+ userResponse: ({
561
+ model,
562
+ action,
563
+ message
564
+ }) => {
565
+ void biLogger.report(
566
+ wixCliUserResponseToCliMessage({
567
+ action,
568
+ message,
569
+ messageId: randomUUID(),
570
+ siteRevision: Number(model.revision)
571
+ })
572
+ );
573
+ }
574
+ });
575
+
576
+ // ../cli-site-old/src/dev/sync-all-to-revision.ts
577
+ init_esm_shims();
578
+ import { rm as rm2 } from "node:fs/promises";
579
+
580
+ // ../cli-site-old/src/sources/index.ts
581
+ init_esm_shims();
582
+ import { readdir } from "node:fs/promises";
583
+
584
+ // ../cli-site-old/src/sources/pages-diff.ts
585
+ init_esm_shims();
586
+ import { join as join2 } from "node:path";
587
+ import { rm, rename } from "node:fs/promises";
588
+ async function createPages(projectFolder, pages) {
589
+ await Promise.all(
590
+ pages.map((page) => {
591
+ if (!page.pageId?.path || !page.content) {
592
+ return Promise.resolve();
593
+ }
594
+ return outputFile(join2(projectFolder, page.pageId.path), page.content);
595
+ })
596
+ );
597
+ }
598
+ async function renamePages(projectFolder, pages) {
599
+ await Promise.all(
600
+ pages.map(async (page) => {
601
+ if (!page.sourcePath?.path || !page.targetPath?.path) {
602
+ return;
603
+ }
604
+ const sourcePath = join2(projectFolder, page.sourcePath.path);
605
+ const targetPath = join2(projectFolder, page.targetPath.path);
606
+ if (await pathExists(targetPath)) {
607
+ return rm(sourcePath, { force: true });
608
+ }
609
+ return rename(sourcePath, targetPath);
610
+ })
611
+ );
612
+ }
613
+ async function deletePages(projectFolder, pages) {
614
+ await Promise.all(
615
+ pages.map((page) => {
616
+ if (!page.path) {
617
+ return Promise.resolve();
618
+ }
619
+ return rm(join2(projectFolder, page.path), { force: true });
620
+ })
621
+ );
622
+ }
623
+
624
+ // ../cli-site-old/src/sources/index.ts
625
+ async function syncPages(model, opts) {
626
+ const pagesFolder = getPagesFolder(model.projectFolder);
627
+ if (!await pathExists(pagesFolder)) {
628
+ throw new CliError({
629
+ code: CliErrorCode.NoPagesDirectoryFound({
630
+ srcDir: getSourceFolder(model.projectFolder)
631
+ }),
632
+ cause: null
633
+ });
634
+ }
635
+ const params = {
636
+ layout: GridAppLayout2.GITHUB,
637
+ sourcePagesPaths: await readdir(pagesFolder),
638
+ targetRevision: model.revision
639
+ };
640
+ const { data } = await httpRequest(
641
+ {
642
+ authState: opts.authState,
643
+ type: "code"
644
+ },
645
+ pagesDiff(params)
646
+ ).catch((e) => {
647
+ throw new CliError({
648
+ code: CliErrorCode.FailedToGetPagesDiff(),
649
+ cause: e,
650
+ info: { ...params }
651
+ });
652
+ });
653
+ await Promise.all([
654
+ createPages(model.projectFolder, data.pagesDiff?.created ?? []),
655
+ renamePages(model.projectFolder, data.pagesDiff?.renamed ?? []),
656
+ deletePages(model.projectFolder, data.pagesDiff?.deleted ?? [])
657
+ ]);
658
+ }
659
+
660
+ // ../cli-site-old/src/dev/sync-all-to-revision.ts
661
+ async function syncAllToRevision(model, opts, logger) {
662
+ const logTypesSynced = logger.logSyncingTypesToRevision(model.revision);
663
+ try {
664
+ await syncTypesWithAuth(model, { authState: opts.authState });
665
+ logTypesSynced.success();
666
+ } catch (error) {
667
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), error);
668
+ logTypesSynced.fail();
669
+ await rm2(getTypesDir(model.projectFolder), {
670
+ recursive: true,
671
+ force: true
672
+ }).catch((e) => {
673
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), e);
674
+ logger.logRecoverableFailureToRemoveTypesDir(e);
675
+ });
676
+ }
677
+ const logPagesSynced = logger.logSyncingPagesToRevision(model.revision);
678
+ try {
679
+ await syncPages(model, { authState: opts.authState });
680
+ logPagesSynced.success();
681
+ } catch (error) {
682
+ logPagesSynced.fail();
683
+ throw error;
684
+ }
685
+ }
686
+
687
+ // ../cli-site-old/src/dev/dev.ts
688
+ async function dev(initialModel, { biLogger, errorReporter }, {
689
+ https = false,
690
+ tunnel: useTunnel = false
691
+ }) {
692
+ let model = initialModel;
693
+ const authState = await authenticate({
694
+ metaSiteId: model.metaSiteId,
695
+ biLogger,
696
+ errorReporter
697
+ });
698
+ const t = createI18nT();
699
+ const logger = createLogger({ t });
700
+ const biEvents = sitesBiEvents(biLogger);
701
+ const server = createVeloCLIServer({ https });
702
+ let gridAppId;
703
+ try {
704
+ gridAppId = await createMutableGridApp(model.projectFolder, {
705
+ authState
706
+ });
707
+ } catch (error) {
708
+ const message = isHttpError(error) ? error.response?.data?.message : void 0;
709
+ throw new CliError({
710
+ code: CliErrorCode.FailedToCreateGridApp({
711
+ error: message
712
+ }),
713
+ cause: error
714
+ });
715
+ }
716
+ await syncAllToRevision(model, { authState }, logger);
717
+ const { close } = startGridAppUpdater(
718
+ model,
719
+ gridAppId,
720
+ {
721
+ authState,
722
+ onError(error) {
723
+ logger.logNewLine();
724
+ errorReporter.reportError(error);
725
+ writeCrashReport(getDebugLogFilePath(model.projectFolder), error);
726
+ renderSync((0, import_react.createElement)(ErrorViewer, { error }));
727
+ }
728
+ },
729
+ logger,
730
+ biEvents
731
+ );
732
+ const onServerDisconnected = (devEditorUrl) => {
733
+ const message = logger.logNoOpenedTab(devEditorUrl);
734
+ biEvents.messageDisplayed({ model, message });
735
+ };
736
+ const onSyncDevEditorChanges = async (revision) => {
737
+ if (revision !== model.revision) {
738
+ const newModel = { ...model, revision };
739
+ await saveProjectModel(newModel);
740
+ const message = logger.logUpdatedLocalCodeToRevision({
741
+ revision: newModel.revision
742
+ });
743
+ biEvents.messageDisplayed({ message, model });
744
+ await syncAllToRevision(newModel, { authState }, logger);
745
+ model = newModel;
746
+ }
747
+ };
748
+ const openLocalEditor = async (serverPort) => {
749
+ biEvents.userResponse({
750
+ action: "Browser opened",
751
+ message: "Opening the Local Editor",
752
+ model
753
+ });
754
+ const devEditorUrl = getDevEditorUrl(serverPort);
755
+ if (https) {
756
+ await openBrowser(new URL(`https://localhost:${serverPort}`).href);
757
+ } else {
758
+ await openBrowser(devEditorUrl);
759
+ }
760
+ };
761
+ let keyWatcher;
762
+ let tunnel;
763
+ const getDevEditorUrl = (serverPort) => {
764
+ const url = new URL(model.metaSiteId, getDevEditorBaseUrl());
765
+ if (tunnel) {
766
+ url.searchParams.append("localEditorDestination", tunnel.domain);
767
+ } else {
768
+ url.searchParams.append("localPort", serverPort.toString());
769
+ }
770
+ url.searchParams.append("secureSocket", https.toString());
771
+ return url.toString();
772
+ };
773
+ try {
774
+ const { port: serverPort } = await server.serve(gridAppId, {
775
+ getDevEditorUrl
776
+ });
777
+ if (useTunnel) {
778
+ const httpClient = createHttpClient({
779
+ type: "backoffice",
780
+ getAppToken: authState.getAccessToken
781
+ });
782
+ const tunnelClient = new TunnelClient(httpClient);
783
+ tunnel = await launchTunnel(serverPort, tunnelClient);
784
+ }
785
+ const devEditorUrl = getDevEditorUrl(serverPort);
786
+ server.on("disconnected", () => onServerDisconnected(devEditorUrl));
787
+ server.on("syncDevEditorChanges", onSyncDevEditorChanges);
788
+ keyWatcher = new KeyWatcher();
789
+ logger.logOpeningBrowser(https);
790
+ await openLocalEditor(serverPort);
791
+ const { ctrlCPromise } = keyWatcher.watch();
792
+ keyWatcher.on("e", () => openLocalEditor(serverPort));
793
+ asyncExitHook(
794
+ async () => {
795
+ await server.close();
796
+ tunnel?.close();
797
+ },
798
+ { wait: 500 }
799
+ );
800
+ await ctrlCPromise;
801
+ } finally {
802
+ keyWatcher?.unwatch();
803
+ await Promise.all([server.close(), close(), tunnel?.close()]);
804
+ }
805
+ }
806
+ export {
807
+ dev
808
+ };
809
+ //# sourceMappingURL=dev-GMC75OLH.js.map