devflare 1.0.0-next.39 → 1.0.0-next.40

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 (277) hide show
  1. package/dist/_chunks/account-BtWcv3X9.js +462 -0
  2. package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
  3. package/dist/_chunks/ai-CBEuLdoP.js +322 -0
  4. package/dist/_chunks/api-TzdliH-6.js +568 -0
  5. package/dist/_chunks/build-3T6O4uIg.js +24 -0
  6. package/dist/_chunks/build-artifacts-8TqBSQkG.js +483 -0
  7. package/dist/_chunks/cli-BTF1X4SG.js +1128 -0
  8. package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
  9. package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
  10. package/dist/_chunks/command-utils-BsfkmTqh.js +45 -0
  11. package/dist/_chunks/compiler-uoyAQ8zW.js +424 -0
  12. package/dist/_chunks/config-D5u-bEkn.js +78 -0
  13. package/dist/_chunks/config-path-DCPto4XB.js +42 -0
  14. package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
  15. package/dist/_chunks/decorators-QmV57ixr.js +19 -0
  16. package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
  17. package/dist/_chunks/deploy-DMTr6JeR.js +915 -0
  18. package/dist/_chunks/dev-CvRHmRFZ.js +3456 -0
  19. package/dist/_chunks/doctor-DIG8DoFU.js +219 -0
  20. package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
  21. package/dist/_chunks/env-S0_nMVz1.js +125 -0
  22. package/dist/_chunks/family-DXC5SdFK.js +143 -0
  23. package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
  24. package/dist/_chunks/glob-CmQOvunB.js +56 -0
  25. package/dist/_chunks/init-3moXTgpb.js +165 -0
  26. package/dist/_chunks/loader-DLXO60RO.js +1153 -0
  27. package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
  28. package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
  29. package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
  30. package/dist/_chunks/local-secrets-DMmEOygL.js +123 -0
  31. package/dist/_chunks/local-workflow-entrypoints-Wip3o1u8.js +90 -0
  32. package/dist/_chunks/login-BmnDzDlH.js +51 -0
  33. package/dist/_chunks/package-metadata-DAuCkyvK.js +39 -0
  34. package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
  35. package/dist/_chunks/preview-BhqDmq8I.js +456 -0
  36. package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
  37. package/dist/_chunks/preview-resources-DdXj8LMM.js +358 -0
  38. package/dist/_chunks/previews-Dlr13x5M.js +1134 -0
  39. package/dist/_chunks/productions-D3AnOHac.js +411 -0
  40. package/dist/_chunks/ref-CYJNAAe_.js +178 -0
  41. package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
  42. package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
  43. package/dist/_chunks/resolve-package-Y84HB3Nt.js +133 -0
  44. package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
  45. package/dist/_chunks/routes-C3FqES2W.js +796 -0
  46. package/dist/_chunks/runtime-FvXvfuZ2.js +550 -0
  47. package/dist/_chunks/schema-normalization-DWVleVxo.js +477 -0
  48. package/dist/_chunks/secrets-70eN0Q6C.js +95 -0
  49. package/dist/_chunks/token-kguIDmej.js +333 -0
  50. package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
  51. package/dist/_chunks/types-OrLbzv4I.js +476 -0
  52. package/dist/_chunks/ui-BUoZApvE.js +103 -0
  53. package/dist/_chunks/usage-BBTGzjon.js +272 -0
  54. package/dist/_chunks/vite-CsI0E-uV.js +1235 -0
  55. package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
  56. package/dist/_chunks/worker-CS1jgNFE.js +410 -0
  57. package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
  58. package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
  59. package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
  60. package/dist/bridge/index.d.ts +6 -6
  61. package/dist/bridge/miniflare.d.ts +2 -2
  62. package/dist/bridge/proxy.d.ts +1 -1
  63. package/dist/bridge/v2/body-streams.d.ts +1 -1
  64. package/dist/bridge/v2/codec.d.ts +4 -4
  65. package/dist/bridge/v2/index.d.ts +10 -10
  66. package/dist/bridge/v2/serialization.d.ts +1 -1
  67. package/dist/bridge/v2/value-codec.d.ts +1 -1
  68. package/dist/bridge/v2/value-serialization.d.ts.map +1 -1
  69. package/dist/bridge/v2/ws-relay.d.ts +3 -3
  70. package/dist/browser-shim/index.d.ts +2 -2
  71. package/dist/browser.d.ts +70 -70
  72. package/dist/browser.js +74 -2462
  73. package/dist/bundler/do-bundler.d.ts +1 -1
  74. package/dist/bundler/index.d.ts +3 -3
  75. package/dist/bundler/rolldown-shared.d.ts +1 -1
  76. package/dist/bundler/worker-bundler.d.ts +1 -1
  77. package/dist/cli/build-manifest.d.ts +1 -1
  78. package/dist/cli/command-utils.d.ts +1 -1
  79. package/dist/cli/commands/account.d.ts +1 -1
  80. package/dist/cli/commands/ai.d.ts +1 -1
  81. package/dist/cli/commands/build-artifacts.d.ts +5 -5
  82. package/dist/cli/commands/build.d.ts +1 -1
  83. package/dist/cli/commands/config.d.ts +1 -1
  84. package/dist/cli/commands/deploy/prepare.d.ts +2 -2
  85. package/dist/cli/commands/deploy/runtime.d.ts +1 -1
  86. package/dist/cli/commands/deploy/verification.d.ts +1 -1
  87. package/dist/cli/commands/deploy.d.ts +1 -1
  88. package/dist/cli/commands/dev.d.ts +1 -1
  89. package/dist/cli/commands/doctor.d.ts +1 -1
  90. package/dist/cli/commands/init.d.ts +1 -1
  91. package/dist/cli/commands/login.d.ts +1 -1
  92. package/dist/cli/commands/previews-support/cleanup.d.ts +1 -1
  93. package/dist/cli/commands/previews-support/family.d.ts +3 -3
  94. package/dist/cli/commands/previews-support/render.d.ts +3 -3
  95. package/dist/cli/commands/previews-support/theme.d.ts +2 -2
  96. package/dist/cli/commands/previews-support/types.d.ts +2 -2
  97. package/dist/cli/commands/previews.d.ts +1 -1
  98. package/dist/cli/commands/productions.d.ts +1 -1
  99. package/dist/cli/commands/remote.d.ts +1 -1
  100. package/dist/cli/commands/secrets.d.ts +1 -1
  101. package/dist/cli/commands/token.d.ts +1 -1
  102. package/dist/cli/commands/type-generation/discovery.d.ts +2 -2
  103. package/dist/cli/commands/type-generation/generator.d.ts +3 -3
  104. package/dist/cli/commands/type-generation/models.d.ts +1 -1
  105. package/dist/cli/commands/types.d.ts +1 -1
  106. package/dist/cli/commands/worker.d.ts +1 -1
  107. package/dist/cli/deploy-strategy.d.ts +1 -1
  108. package/dist/cli/deploy-target.d.ts +1 -1
  109. package/dist/cli/help-pages/pages/account.d.ts +1 -1
  110. package/dist/cli/help-pages/pages/core.d.ts +1 -1
  111. package/dist/cli/help-pages/pages/index.d.ts +1 -1
  112. package/dist/cli/help-pages/pages/misc.d.ts +1 -1
  113. package/dist/cli/help-pages/pages/previews.d.ts +1 -1
  114. package/dist/cli/help-pages/pages/productions.d.ts +1 -1
  115. package/dist/cli/help-pages/render.d.ts +2 -2
  116. package/dist/cli/help-pages/shared.d.ts +1 -1
  117. package/dist/cli/help.d.ts +2 -2
  118. package/dist/cli/index.js +2 -1383
  119. package/dist/cli/preview-bindings.d.ts +3 -3
  120. package/dist/cli/preview.d.ts +1 -1
  121. package/dist/cli/wrangler-auth.d.ts +1 -1
  122. package/dist/cloudflare/account-core.d.ts +2 -2
  123. package/dist/cloudflare/account-resources.d.ts +2 -2
  124. package/dist/cloudflare/account-status.d.ts +1 -1
  125. package/dist/cloudflare/account-workers.d.ts +2 -2
  126. package/dist/cloudflare/account.d.ts +7 -7
  127. package/dist/cloudflare/auth.d.ts +1 -1
  128. package/dist/cloudflare/index.d.ts +13 -13
  129. package/dist/cloudflare/index.js +4 -59
  130. package/dist/cloudflare/kv-namespace.d.ts +1 -1
  131. package/dist/cloudflare/preview-registry-cache.d.ts +1 -1
  132. package/dist/cloudflare/preview-registry-inference.d.ts +2 -2
  133. package/dist/cloudflare/preview-registry-records.d.ts +3 -3
  134. package/dist/cloudflare/preview-registry-shape.d.ts +2 -2
  135. package/dist/cloudflare/preview-registry-store.d.ts +3 -3
  136. package/dist/cloudflare/preview-registry-transport.d.ts +2 -2
  137. package/dist/cloudflare/preview-registry-types.d.ts +2 -2
  138. package/dist/cloudflare/preview-registry.d.ts +5 -5
  139. package/dist/cloudflare/tokens.d.ts +2 -2
  140. package/dist/cloudflare/usage.d.ts +2 -2
  141. package/dist/config/binding-resolution-helpers.d.ts +1 -1
  142. package/dist/config/compiler/bindings.d.ts +2 -2
  143. package/dist/config/compiler/core-helpers.d.ts +2 -2
  144. package/dist/config/compiler/do-workers.d.ts +2 -2
  145. package/dist/config/compiler/paths.d.ts +1 -1
  146. package/dist/config/compiler.d.ts +6 -6
  147. package/dist/config/define.d.ts +2 -2
  148. package/dist/config/deploy-resources.d.ts +5 -5
  149. package/dist/config/env-vars.d.ts +1 -1
  150. package/dist/config/framework-providers.d.ts +1 -1
  151. package/dist/config/index.d.ts +12 -12
  152. package/dist/config/loader.d.ts +2 -2
  153. package/dist/config/local-dev-vars.d.ts +1 -1
  154. package/dist/config/preview-resources.d.ts +4 -4
  155. package/dist/config/preview.d.ts +1 -1
  156. package/dist/config/ref.d.ts +2 -2
  157. package/dist/config/resolve-phased.d.ts +4 -4
  158. package/dist/config/resolve.d.ts +1 -1
  159. package/dist/config/resource-resolution.d.ts +6 -6
  160. package/dist/config/schema-env.d.ts +20 -20
  161. package/dist/config/schema-normalization.d.ts +1 -1
  162. package/dist/config/schema-types-bindings.d.ts +4 -4
  163. package/dist/config/schema-types-build.d.ts +1 -1
  164. package/dist/config/schema-types.d.ts +7 -7
  165. package/dist/config/schema.d.ts +46 -46
  166. package/dist/config/service-bindings-validation.d.ts +1 -1
  167. package/dist/config-entry.d.ts +6 -6
  168. package/dist/config-entry.js +3 -8
  169. package/dist/decorators/index.d.ts +2 -2
  170. package/dist/decorators/index.js +2 -9
  171. package/dist/dev-server/d1-migrations.d.ts +1 -1
  172. package/dist/dev-server/dev-server-state.d.ts +6 -6
  173. package/dist/dev-server/gateway-script.d.ts +1 -1
  174. package/dist/dev-server/index.d.ts +1 -1
  175. package/dist/dev-server/miniflare-bindings.d.ts +1 -1
  176. package/dist/dev-server/miniflare-dev-config.d.ts +5 -5
  177. package/dist/dev-server/miniflare-worker-config.d.ts +3 -3
  178. package/dist/dev-server/server-startup-helpers.d.ts +6 -6
  179. package/dist/dev-server/worker-surface-paths.d.ts +2 -2
  180. package/dist/index.d.ts +8 -8
  181. package/dist/index.js +9 -22
  182. package/dist/runtime/context-events.d.ts +1 -1
  183. package/dist/runtime/context.d.ts +3 -3
  184. package/dist/runtime/exports.d.ts +2 -2
  185. package/dist/runtime/index.d.ts +10 -10
  186. package/dist/runtime/index.js +5 -57
  187. package/dist/runtime/middleware.d.ts +1 -1
  188. package/dist/runtime/router/index.d.ts +3 -3
  189. package/dist/runtime/validation.d.ts +1 -1
  190. package/dist/secrets/local-secrets.d.ts +1 -1
  191. package/dist/shims/local-media-bindings.d.ts +1 -1
  192. package/dist/sveltekit/index.d.ts +1 -1
  193. package/dist/sveltekit/index.js +327 -9
  194. package/dist/sveltekit/local-bindings.d.ts +1 -1
  195. package/dist/sveltekit/platform.d.ts +1 -1
  196. package/dist/test/binding-hints.d.ts +2 -2
  197. package/dist/test/cf.d.ts +19 -19
  198. package/dist/test/index.d.ts +18 -18
  199. package/dist/test/index.js +4495 -46
  200. package/dist/test/offline-bindings.d.ts +3 -3
  201. package/dist/test/resolve-service-bindings.d.ts +1 -1
  202. package/dist/test/simple-context-bindings.d.ts +1 -1
  203. package/dist/test/simple-context-durable-objects.d.ts +1 -1
  204. package/dist/test/simple-context-env.d.ts +2 -2
  205. package/dist/test/simple-context-handlers.d.ts +2 -2
  206. package/dist/test/simple-context-lifecycle.d.ts +2 -2
  207. package/dist/test/simple-context-mfconfig.d.ts +1 -1
  208. package/dist/test/simple-context-multi-worker.d.ts +2 -2
  209. package/dist/test/simple-context-runtime.d.ts +1 -1
  210. package/dist/test/simple-context-startup.d.ts +1 -1
  211. package/dist/test/simple-context.d.ts +1 -1
  212. package/dist/test/utilities/env.d.ts +3 -3
  213. package/dist/test/utilities.d.ts +10 -10
  214. package/dist/test/worker.d.ts +1 -1
  215. package/dist/transform/index.d.ts +2 -2
  216. package/dist/utils/send-email.js +163 -19
  217. package/dist/vite/config-file.d.ts +2 -2
  218. package/dist/vite/index.d.ts +3 -3
  219. package/dist/vite/index.js +2 -31
  220. package/dist/vite/plugin-config-hook.d.ts +1 -1
  221. package/dist/vite/plugin-context.d.ts +3 -3
  222. package/dist/vite/plugin-durable-objects.d.ts +2 -2
  223. package/dist/vite/plugin-programmatic.d.ts +1 -1
  224. package/dist/vite/plugin-service-bindings.d.ts +2 -2
  225. package/dist/vite/plugin.d.ts +3 -3
  226. package/dist/worker-entry/composed-worker.d.ts +1 -1
  227. package/dist/worker-entry/routes.d.ts +2 -2
  228. package/dist/worker-entry/surface-paths.d.ts +1 -1
  229. package/dist/workflows/local-workflow-entrypoints.d.ts +1 -1
  230. package/package.json +5 -3
  231. package/dist/account-4tgh03a8.js +0 -484
  232. package/dist/ai-r3zqmxan.js +0 -261
  233. package/dist/api-6z01z734.js +0 -33
  234. package/dist/build-kw625v84.js +0 -51
  235. package/dist/config-ghk2bxj3.js +0 -102
  236. package/dist/deploy-9kee65n9.js +0 -1062
  237. package/dist/dev-x8zr249a.js +0 -3569
  238. package/dist/doctor-0ng5qrr1.js +0 -258
  239. package/dist/durable-object-0ybmg08a.js +0 -13
  240. package/dist/index-04wh9bxx.js +0 -514
  241. package/dist/index-0cc05hzv.js +0 -74
  242. package/dist/index-2yv7w548.js +0 -185
  243. package/dist/index-37x76zdn.js +0 -4
  244. package/dist/index-3cpzsr47.js +0 -125
  245. package/dist/index-3t6rypgc.js +0 -13
  246. package/dist/index-4mmpccrb.js +0 -309
  247. package/dist/index-5dkjffqz.js +0 -25
  248. package/dist/index-5hy7jmv3.js +0 -890
  249. package/dist/index-627srx16.js +0 -45
  250. package/dist/index-7m557715.js +0 -283
  251. package/dist/index-a8pnvg3r.js +0 -52
  252. package/dist/index-aabgympv.js +0 -39
  253. package/dist/index-atwc3csp.js +0 -256
  254. package/dist/index-cv4cvrxe.js +0 -2046
  255. package/dist/index-h7r11y4a.js +0 -539
  256. package/dist/index-hvtd936d.js +0 -1229
  257. package/dist/index-kcp7y951.js +0 -136
  258. package/dist/index-maw0jjnn.js +0 -147
  259. package/dist/index-mek9msfv.js +0 -705
  260. package/dist/index-n4xkaymm.js +0 -236
  261. package/dist/index-nkk59p3y.js +0 -579
  262. package/dist/index-phcrvs6d.js +0 -342
  263. package/dist/index-se4kw8tm.js +0 -460
  264. package/dist/index-x8s9rwfh.js +0 -2020
  265. package/dist/index-y7w3x9p1.js +0 -18
  266. package/dist/index-z9gy8w6b.js +0 -57
  267. package/dist/index-zdd0d9qa.js +0 -199
  268. package/dist/init-tb8jqgvr.js +0 -180
  269. package/dist/login-4h1sfsed.js +0 -75
  270. package/dist/previews-qr7c5j8h.js +0 -1336
  271. package/dist/productions-xpmd6bw8.js +0 -505
  272. package/dist/remote-kqcvhnfx.js +0 -192
  273. package/dist/secrets-6wbdsdek.js +0 -89
  274. package/dist/token-yp1qa70y.js +0 -419
  275. package/dist/types-15yv4cj3.js +0 -701
  276. package/dist/worker-1yg72jxg.js +0 -510
  277. package/dist/worker-entrypoint-y8s9kdcx.js +0 -15
@@ -1,18 +0,0 @@
1
- // src/decorators/durable-object.ts
2
- function durableObject(options = {}) {
3
- return (target) => {
4
- Object.defineProperty(target, "__durableObjectOptions", {
5
- value: options,
6
- enumerable: false,
7
- writable: false
8
- });
9
- return target;
10
- };
11
- }
12
- function getDurableObjectOptions(target) {
13
- if (typeof target === "function") {
14
- return target.__durableObjectOptions;
15
- }
16
- return;
17
- }
18
- export { durableObject, getDurableObjectOptions };
@@ -1,57 +0,0 @@
1
- import {
2
- __require
3
- } from "./index-37x76zdn.js";
4
-
5
- // src/cli/dependencies.ts
6
- async function createRealDependencies() {
7
- const fs = await import("node:fs/promises");
8
- const { execa, execaCommand } = await import("execa");
9
- const { spawn } = await import("node:child_process");
10
- return {
11
- fs,
12
- exec: {
13
- exec: async (command, args = [], options = {}) => {
14
- const result = await execa(command, args, options);
15
- return {
16
- exitCode: result.exitCode ?? 0,
17
- stdout: String(result.stdout ?? ""),
18
- stderr: String(result.stderr ?? ""),
19
- failed: result.failed,
20
- killed: false,
21
- signal: result.signal
22
- };
23
- },
24
- spawn: (command, args = [], options = {}) => {
25
- const child = spawn(command, args, {
26
- cwd: options.cwd,
27
- stdio: options.stdio ?? "pipe",
28
- env: options.env,
29
- shell: options.shell ?? false
30
- });
31
- const wrapper = {
32
- pid: child.pid,
33
- stdout: child.stdout,
34
- stderr: child.stderr,
35
- get killed() {
36
- return child.killed;
37
- },
38
- kill: (signal) => child.kill(signal),
39
- on: (event, handler) => {
40
- child.on(event, handler);
41
- return wrapper;
42
- }
43
- };
44
- return wrapper;
45
- }
46
- }
47
- };
48
- }
49
- var _deps = null;
50
- async function getDependencies() {
51
- if (!_deps) {
52
- _deps = await createRealDependencies();
53
- }
54
- return _deps;
55
- }
56
-
57
- export { getDependencies };
@@ -1,199 +0,0 @@
1
- import {
2
- __require
3
- } from "./index-37x76zdn.js";
4
-
5
- // src/dev-server/vite-utils.ts
6
- import { spawn } from "node:child_process";
7
- import { resolve } from "pathe";
8
- var VITE_CONFIG_FILES = [
9
- "vite.config.ts",
10
- "vite.config.js",
11
- "vite.config.mts",
12
- "vite.config.mjs",
13
- "vite.config.cts",
14
- "vite.config.cjs"
15
- ];
16
- var ANSI_REGEX = /\x1b\[[0-9;]*m/g;
17
- var LOCAL_VITE_URL_REGEX = /https?:\/\/(?:localhost|127\.0\.0\.1|\[::1\])(?::\d+)?\/?/i;
18
- async function getNodeFs() {
19
- return await import("node:fs/promises");
20
- }
21
- function safeParsePackageJson(content) {
22
- try {
23
- return JSON.parse(content);
24
- } catch {
25
- return {};
26
- }
27
- }
28
- function readDependencyFlag(pkg, name) {
29
- const dependencies = pkg.dependencies;
30
- const devDependencies = pkg.devDependencies;
31
- return Boolean(dependencies?.[name] ?? devDependencies?.[name]);
32
- }
33
- async function detectViteProject(cwd, fs) {
34
- const fileSystem = fs ?? await getNodeFs();
35
- let viteConfigPath = null;
36
- for (const configName of VITE_CONFIG_FILES) {
37
- const absolutePath = resolve(cwd, configName);
38
- try {
39
- await fileSystem.access(absolutePath);
40
- viteConfigPath = absolutePath;
41
- break;
42
- } catch {}
43
- }
44
- let pkg = {};
45
- try {
46
- const packageJson = await fileSystem.readFile(resolve(cwd, "package.json"), "utf-8");
47
- pkg = safeParsePackageJson(packageJson);
48
- } catch {
49
- pkg = {};
50
- }
51
- const hasLocalViteDependency = readDependencyFlag(pkg, "vite");
52
- const hasLocalCloudflareVitePluginDependency = readDependencyFlag(pkg, "@cloudflare/vite-plugin");
53
- const wantsViteIntegration = Boolean(viteConfigPath || hasLocalViteDependency || hasLocalCloudflareVitePluginDependency);
54
- return {
55
- viteConfigPath,
56
- hasLocalViteDependency,
57
- hasLocalCloudflareVitePluginDependency,
58
- shouldStartVite: Boolean(viteConfigPath),
59
- wantsViteIntegration
60
- };
61
- }
62
- async function resolveViteMode(cwd, options = {}) {
63
- const detection = await detectViteProject(cwd, options.fs);
64
- const requested = options.requested ?? true;
65
- return {
66
- enableVite: requested && detection.shouldStartVite,
67
- viteConfigPath: detection.viteConfigPath,
68
- detection
69
- };
70
- }
71
- function stripAnsi(value) {
72
- return value.replace(ANSI_REGEX, "");
73
- }
74
- function extractViteReadyUrl(output) {
75
- const cleaned = stripAnsi(output);
76
- const lines = cleaned.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
77
- for (const line of lines) {
78
- if (!line.toLowerCase().includes("local:")) {
79
- continue;
80
- }
81
- const match = line.match(LOCAL_VITE_URL_REGEX);
82
- if (match) {
83
- return match[0];
84
- }
85
- }
86
- const fallbackMatch = cleaned.match(LOCAL_VITE_URL_REGEX);
87
- return fallbackMatch?.[0] ?? null;
88
- }
89
- async function waitForViteReady(process, options = {}) {
90
- const { timeoutMs = 15000, onStdout, onStderr } = options;
91
- let combinedOutput = "";
92
- return await new Promise((resolvePromise, rejectPromise) => {
93
- let settled = false;
94
- let timeout;
95
- const settle = (resolver) => {
96
- if (settled) {
97
- return;
98
- }
99
- settled = true;
100
- clearTimeout(timeout);
101
- resolver();
102
- };
103
- const inspectChunk = (chunk) => {
104
- combinedOutput += typeof chunk === "string" ? chunk : chunk.toString("utf-8");
105
- const readyUrl = extractViteReadyUrl(combinedOutput);
106
- if (readyUrl) {
107
- settle(() => resolvePromise(readyUrl));
108
- }
109
- };
110
- process.stdout?.on("data", (chunk) => {
111
- onStdout?.(chunk);
112
- inspectChunk(chunk);
113
- });
114
- process.stderr?.on("data", (chunk) => {
115
- onStderr?.(chunk);
116
- inspectChunk(chunk);
117
- });
118
- process.on("error", (error) => {
119
- settle(() => rejectPromise(error));
120
- });
121
- process.on("exit", (code, signal) => {
122
- settle(() => {
123
- const reason = signal ? `signal ${signal}` : `exit code ${code ?? "unknown"}`;
124
- rejectPromise(new Error(`Vite exited before reporting a ready URL (${reason})`));
125
- });
126
- });
127
- timeout = setTimeout(() => {
128
- settle(() => resolvePromise(null));
129
- }, timeoutMs);
130
- });
131
- }
132
- async function defaultRunCommand(command, args) {
133
- await new Promise((resolvePromise, rejectPromise) => {
134
- const child = spawn(command, args, {
135
- stdio: "ignore",
136
- windowsHide: true
137
- });
138
- child.on("error", rejectPromise);
139
- child.on("exit", () => resolvePromise());
140
- });
141
- }
142
- function waitForProcessExit(process, timeoutMs) {
143
- if (process.killed) {
144
- return Promise.resolve(true);
145
- }
146
- return new Promise((resolvePromise) => {
147
- let settled = false;
148
- let timeout;
149
- const settle = (value) => {
150
- if (settled) {
151
- return;
152
- }
153
- settled = true;
154
- clearTimeout(timeout);
155
- resolvePromise(value);
156
- };
157
- process.on("exit", () => settle(true));
158
- timeout = setTimeout(() => {
159
- settle(false);
160
- }, timeoutMs);
161
- });
162
- }
163
- async function stopSpawnedProcessTree(process, options = {}) {
164
- const {
165
- platform = globalThis.process?.platform ?? "linux",
166
- timeoutMs = 3000,
167
- runCommand = defaultRunCommand
168
- } = options;
169
- if (platform === "win32" && process.pid) {
170
- try {
171
- await runCommand("taskkill", ["/pid", String(process.pid), "/t", "/f"]);
172
- } catch {
173
- try {
174
- process.kill("SIGTERM");
175
- } catch {
176
- return;
177
- }
178
- }
179
- await waitForProcessExit(process, timeoutMs);
180
- return;
181
- }
182
- try {
183
- process.kill("SIGTERM");
184
- } catch {
185
- return;
186
- }
187
- const exited = await waitForProcessExit(process, timeoutMs);
188
- if (exited) {
189
- return;
190
- }
191
- try {
192
- process.kill("SIGKILL");
193
- } catch {
194
- return;
195
- }
196
- await waitForProcessExit(process, timeoutMs);
197
- }
198
-
199
- export { detectViteProject, resolveViteMode, waitForViteReady, stopSpawnedProcessTree };
@@ -1,180 +0,0 @@
1
- import {
2
- getDependencies
3
- } from "./index-z9gy8w6b.js";
4
- import {
5
- getInitDependencyVersions
6
- } from "./index-627srx16.js";
7
- import {
8
- createCliTheme,
9
- cyanBold,
10
- dim,
11
- green,
12
- logLine
13
- } from "./index-maw0jjnn.js";
14
- import"./index-3t6rypgc.js";
15
- import"./index-37x76zdn.js";
16
-
17
- // src/cli/commands/init.ts
18
- import { join, resolve } from "pathe";
19
- var MINIMAL_TEMPLATE = {
20
- name: "minimal",
21
- description: "Minimal starter with single handler",
22
- files: {
23
- "devflare.config.ts": `import { defineConfig } from 'devflare/config'
24
-
25
- export default defineConfig({
26
- name: '{{PROJECT_NAME}}',
27
- compatibilityDate: '${new Date().toISOString().split("T")[0]}',
28
- files: {
29
- fetch: 'src/fetch.ts'
30
- }
31
- })
32
- `,
33
- "src/fetch.ts": `import type { FetchEvent } from 'devflare/runtime'
34
-
35
- export async function fetch({ url }: FetchEvent): Promise<Response> {
36
- return new Response(
37
- url.pathname === '/'
38
- ? 'Hello from Devflare'
39
- : \`Hello from Devflare: \${url.pathname}\`
40
- )
41
- }
42
- `,
43
- "package.json": `{
44
- "name": "{{PROJECT_NAME}}",
45
- "version": "0.0.1",
46
- "private": true,
47
- "type": "module",
48
- "scripts": {
49
- "dev": "devflare dev",
50
- "build": "devflare build",
51
- "deploy": "devflare deploy",
52
- "types": "devflare types"
53
- },
54
- "devDependencies": {
55
- "@cloudflare/workers-types": "{{WORKERS_TYPES_VERSION}}",
56
- "devflare": "{{DEVFLARE_VERSION}}",
57
- "typescript": "{{TYPESCRIPT_VERSION}}",
58
- "wrangler": "{{WRANGLER_VERSION}}"
59
- }
60
- }
61
- `,
62
- "tsconfig.json": `{
63
- "compilerOptions": {
64
- "target": "ESNext",
65
- "module": "ESNext",
66
- "moduleResolution": "bundler",
67
- "strict": true,
68
- "skipLibCheck": true,
69
- "types": ["@cloudflare/workers-types"]
70
- },
71
- "include": ["src/**/*", "env.d.ts", "devflare.config.ts"]
72
- }
73
- `
74
- }
75
- };
76
- var API_TEMPLATE = {
77
- name: "api",
78
- description: "API starter with request-wide middleware",
79
- files: {
80
- "devflare.config.ts": `import { defineConfig } from 'devflare/config'
81
-
82
- export default defineConfig({
83
- name: '{{PROJECT_NAME}}',
84
- compatibilityDate: '${new Date().toISOString().split("T")[0]}',
85
- files: {
86
- fetch: 'src/fetch.ts'
87
- }
88
- })
89
- `,
90
- "src/fetch.ts": `import { sequence } from 'devflare/runtime'
91
- import { corsHandle } from './middleware/cors'
92
- import { appFetch } from './app'
93
-
94
- export const handle = sequence(corsHandle, appFetch)
95
- `,
96
- "src/middleware/cors.ts": `import type { FetchEvent, ResolveFetch } from 'devflare/runtime'
97
-
98
- export async function corsHandle(event: FetchEvent, resolve: ResolveFetch): Promise<Response> {
99
- // Handle preflight
100
- if (event.request.method === 'OPTIONS') {
101
- return new Response(null, {
102
- headers: {
103
- 'Access-Control-Allow-Origin': '*',
104
- 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
105
- 'Access-Control-Allow-Headers': 'Content-Type, Authorization'
106
- }
107
- })
108
- }
109
-
110
- const response = await resolve(event)
111
- const next = new Response(response.body, response)
112
- next.headers.set('Access-Control-Allow-Origin', '*')
113
- return next
114
- }
115
- `,
116
- "src/app.ts": `import type { FetchEvent } from 'devflare/runtime'
117
-
118
- export async function appFetch({ url }: FetchEvent): Promise<Response> {
119
- if (url.pathname === '/api/health') {
120
- return Response.json({ status: 'ok' })
121
- }
122
-
123
- if (url.pathname.startsWith('/api/')) {
124
- return Response.json({ error: 'Not found' }, { status: 404 })
125
- }
126
-
127
- return new Response('Not Found', { status: 404 })
128
- }
129
- `,
130
- "package.json": MINIMAL_TEMPLATE.files["package.json"],
131
- "tsconfig.json": MINIMAL_TEMPLATE.files["tsconfig.json"]
132
- }
133
- };
134
- var TEMPLATES = {
135
- minimal: MINIMAL_TEMPLATE,
136
- api: API_TEMPLATE
137
- };
138
- async function runInitCommand(parsed, logger, options) {
139
- const projectName = parsed.args[0] || "my-devflare-app";
140
- const templateName = parsed.options.template || "minimal";
141
- const cwd = options.cwd || process.cwd();
142
- const theme = createCliTheme(parsed.options);
143
- logLine(logger);
144
- logLine(logger, `${cyanBold("init", theme)} ${dim("Creating a new Devflare project", theme)}`);
145
- logLine(logger, `${dim("project", theme)} ${green(projectName, theme)}`);
146
- const template = TEMPLATES[templateName];
147
- if (!template) {
148
- logger.error(`Unknown template: ${templateName}`);
149
- logger.info(`Available templates: ${Object.keys(TEMPLATES).join(", ")}`);
150
- return { exitCode: 1 };
151
- }
152
- const projectDir = resolve(cwd, projectName);
153
- const dependencyVersions = await getInitDependencyVersions();
154
- const { fs } = await getDependencies();
155
- try {
156
- await fs.access(projectDir);
157
- logger.error(`Directory already exists: ${projectDir}`);
158
- return { exitCode: 1 };
159
- } catch {}
160
- await fs.mkdir(projectDir, { recursive: true });
161
- for (const [filePath, content] of Object.entries(template.files)) {
162
- const fullPath = join(projectDir, filePath);
163
- const dir = fullPath.substring(0, fullPath.lastIndexOf("/"));
164
- await fs.mkdir(dir, { recursive: true }).catch(() => {});
165
- const processedContent = content.replace(/\{\{PROJECT_NAME\}\}/g, projectName).replace(/\{\{DEVFLARE_VERSION\}\}/g, dependencyVersions.devflare).replace(/\{\{TYPESCRIPT_VERSION\}\}/g, dependencyVersions.typescript).replace(/\{\{WRANGLER_VERSION\}\}/g, dependencyVersions.wrangler).replace(/\{\{WORKERS_TYPES_VERSION\}\}/g, dependencyVersions.workersTypes);
166
- await fs.writeFile(fullPath, processedContent, "utf-8");
167
- logLine(logger, ` ${dim("created", theme)} ${filePath}`);
168
- }
169
- logger.success("Project created successfully!");
170
- logLine(logger);
171
- logLine(logger, dim("next steps", theme));
172
- logLine(logger, ` cd ${projectName}`);
173
- logLine(logger, " bun install");
174
- logLine(logger, " bun run types");
175
- logLine(logger, " bun run dev");
176
- return { exitCode: 0 };
177
- }
178
- export {
179
- runInitCommand
180
- };
@@ -1,75 +0,0 @@
1
- import {
2
- getConfiguredAccountId
3
- } from "./index-0cc05hzv.js";
4
- import {
5
- account
6
- } from "./index-phcrvs6d.js";
7
- import"./index-atwc3csp.js";
8
- import"./index-hvtd936d.js";
9
- import {
10
- getDependencies
11
- } from "./index-z9gy8w6b.js";
12
- import {
13
- createCliTheme,
14
- dim,
15
- green,
16
- logLine,
17
- whiteDim,
18
- yellow
19
- } from "./index-maw0jjnn.js";
20
- import"./index-3t6rypgc.js";
21
- import"./index-x8s9rwfh.js";
22
- import"./index-h7r11y4a.js";
23
- import"./index-04wh9bxx.js";
24
- import"./index-37x76zdn.js";
25
-
26
- // src/cli/commands/login.ts
27
- async function logResolvedAccount(cwd, logger, theme) {
28
- try {
29
- const primaryAccount = await account.getPrimaryAccount();
30
- if (primaryAccount) {
31
- logLine(logger, `${dim("Primary account:", theme)} ${green(primaryAccount.name, theme)} ${whiteDim(`(${primaryAccount.id})`, theme)}`);
32
- return;
33
- }
34
- } catch {}
35
- const configuredAccountId = await getConfiguredAccountId(cwd);
36
- if (!configuredAccountId) {
37
- logLine(logger, dim("Run `devflare account` to inspect available accounts.", theme));
38
- return;
39
- }
40
- const configuredAccount = await account.getAccountById(configuredAccountId);
41
- if (configuredAccount) {
42
- logLine(logger, `${dim("Configured account:", theme)} ${green(configuredAccount.name, theme)} ${whiteDim(`(${configuredAccount.id})`, theme)}`);
43
- return;
44
- }
45
- logLine(logger, `${dim("Configured account ID:", theme)} ${whiteDim(configuredAccountId, theme)}`);
46
- logLine(logger, dim("Run `devflare account --account <id>` to inspect the configured account.", theme));
47
- }
48
- async function runLoginCommand(parsed, logger, options) {
49
- const force = parsed.options.force === true;
50
- const cwd = options.cwd ?? process.cwd();
51
- const theme = createCliTheme(parsed.options);
52
- if (!force && await account.isAuthenticated()) {
53
- logger.success("Already authenticated with Cloudflare");
54
- await logResolvedAccount(cwd, logger, theme);
55
- logLine(logger, dim("Use `devflare login --force` to open Wrangler login again.", theme));
56
- return { exitCode: 0 };
57
- }
58
- logLine(logger);
59
- logLine(logger, `${yellow("login", theme)} ${dim("Opening Wrangler login…", theme)}`);
60
- const deps = await getDependencies();
61
- const result = await deps.exec.exec("bunx", ["wrangler", "login"], {
62
- cwd,
63
- stdio: "inherit"
64
- });
65
- if (result.exitCode !== 0) {
66
- logger.error("Wrangler login failed");
67
- return { exitCode: 1 };
68
- }
69
- logger.success("Authenticated with Cloudflare");
70
- await logResolvedAccount(cwd, logger, theme);
71
- return { exitCode: 0 };
72
- }
73
- export {
74
- runLoginCommand
75
- };