@stacksjs/actions 0.70.88 → 0.70.91

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 (261) hide show
  1. package/dist/action.d.ts +149 -0
  2. package/dist/action.js +78 -0
  3. package/dist/actions.d.ts +2 -0
  4. package/dist/actions.js +2 -0
  5. package/dist/add.d.ts +6 -0
  6. package/dist/add.js +20 -0
  7. package/dist/ai/request-model-access.d.ts +1 -0
  8. package/dist/ai/request-model-access.js +10 -0
  9. package/dist/auth/client.d.ts +1 -0
  10. package/dist/auth/client.js +44 -0
  11. package/dist/auth/prune.d.ts +1 -0
  12. package/dist/auth/prune.js +35 -0
  13. package/dist/auth/setup.d.ts +1 -0
  14. package/dist/auth/setup.js +322 -0
  15. package/dist/auth/token.d.ts +1 -0
  16. package/dist/auth/token.js +10 -0
  17. package/dist/blog-admin.d.ts +55 -0
  18. package/dist/blog-admin.js +156 -0
  19. package/dist/blog.d.ts +30 -0
  20. package/dist/blog.js +398 -0
  21. package/dist/build/cli.d.ts +1 -0
  22. package/dist/build/cli.js +6 -0
  23. package/dist/build/component-libs.d.ts +1 -0
  24. package/dist/build/component-libs.js +7 -0
  25. package/dist/build/core.d.ts +1 -0
  26. package/dist/build/core.js +55 -0
  27. package/dist/build/desktop.d.ts +1 -0
  28. package/dist/build/desktop.js +5 -0
  29. package/dist/build/docs.d.ts +1 -0
  30. package/dist/build/docs.js +5 -0
  31. package/dist/build/frontend-static.d.ts +16 -0
  32. package/dist/build/frontend-static.js +124 -0
  33. package/dist/build/server.d.ts +1 -0
  34. package/dist/build/server.js +6 -0
  35. package/dist/build/stacks.d.ts +1 -0
  36. package/dist/build/stacks.js +8 -0
  37. package/dist/build/views.d.ts +1 -0
  38. package/dist/build/views.js +11 -0
  39. package/dist/build.d.ts +9 -0
  40. package/dist/build.js +64 -0
  41. package/dist/bump.d.ts +1 -0
  42. package/dist/bump.js +163 -0
  43. package/dist/cdn/invalidate-cache.d.ts +1 -0
  44. package/dist/cdn/invalidate-cache.js +0 -0
  45. package/dist/changelog.d.ts +9 -0
  46. package/dist/changelog.js +27 -0
  47. package/dist/check/ports.d.ts +1 -0
  48. package/dist/check/ports.js +16 -0
  49. package/dist/clean.d.ts +1 -0
  50. package/dist/clean.js +4 -0
  51. package/dist/commit.d.ts +3 -0
  52. package/dist/commit.js +12 -0
  53. package/dist/copy-types.d.ts +1 -0
  54. package/dist/copy-types.js +10 -0
  55. package/dist/database/seed.d.ts +1 -0
  56. package/dist/database/seed.js +26 -0
  57. package/dist/deploy/create-receipt-rule.d.ts +1 -0
  58. package/dist/deploy/create-receipt-rule.js +36 -0
  59. package/dist/deploy/index.d.ts +1 -0
  60. package/dist/deploy/index.js +1574 -0
  61. package/dist/dev/api.d.ts +1 -0
  62. package/dist/dev/api.js +94 -0
  63. package/dist/dev/components.d.ts +1 -0
  64. package/dist/dev/components.js +7 -0
  65. package/dist/dev/dashboard-globals.d.ts +4 -0
  66. package/dist/dev/dashboard-globals.js +89 -0
  67. package/dist/dev/dashboard-utils.d.ts +150 -0
  68. package/dist/dev/dashboard-utils.js +380 -0
  69. package/dist/dev/dashboard.d.ts +22 -0
  70. package/dist/dev/dashboard.js +435 -0
  71. package/dist/dev/desktop.d.ts +1 -0
  72. package/dist/dev/desktop.js +5 -0
  73. package/dist/dev/docs.d.ts +1 -0
  74. package/dist/dev/docs.js +24 -0
  75. package/dist/dev/index.d.ts +10 -0
  76. package/dist/dev/index.js +29 -0
  77. package/dist/dev/migrate-watcher.d.ts +1 -0
  78. package/dist/dev/migrate-watcher.js +74 -0
  79. package/dist/dev/system-tray.d.ts +1 -0
  80. package/dist/dev/system-tray.js +5 -0
  81. package/dist/dev/views.d.ts +1 -0
  82. package/dist/dev/views.js +147 -0
  83. package/dist/discover-packages.d.ts +18 -0
  84. package/dist/discover-packages.js +32 -0
  85. package/dist/domains/add.d.ts +1 -0
  86. package/dist/domains/add.js +61 -0
  87. package/dist/domains/purchase.d.ts +1 -0
  88. package/dist/domains/purchase.js +66 -0
  89. package/dist/domains/remove.d.ts +1 -0
  90. package/dist/domains/remove.js +24 -0
  91. package/dist/examples.d.ts +5 -0
  92. package/dist/examples.js +34 -0
  93. package/dist/find-projects.d.ts +1 -0
  94. package/dist/find-projects.js +16 -0
  95. package/dist/fresh.d.ts +1 -0
  96. package/dist/fresh.js +17 -0
  97. package/dist/generate/action-types.d.ts +1 -0
  98. package/dist/generate/action-types.js +13 -0
  99. package/dist/generate/component-meta.d.ts +1 -0
  100. package/dist/generate/component-meta.js +9 -0
  101. package/dist/generate/custom-cli-file.d.ts +1 -0
  102. package/dist/generate/custom-cli-file.js +21 -0
  103. package/dist/generate/env-files.d.ts +1 -0
  104. package/dist/generate/env-files.js +66 -0
  105. package/dist/generate/ide-helpers.d.ts +1 -0
  106. package/dist/generate/ide-helpers.js +8 -0
  107. package/dist/generate/index.d.ts +36 -0
  108. package/dist/generate/index.js +158 -0
  109. package/dist/generate/lib-entries.d.ts +1 -0
  110. package/dist/generate/lib-entries.js +16 -0
  111. package/dist/generate/pantry-file.d.ts +1 -0
  112. package/dist/generate/pantry-file.js +46 -0
  113. package/dist/generate/symlink-core.d.ts +1 -0
  114. package/dist/generate/symlink-core.js +2 -0
  115. package/dist/generate/types.d.ts +1 -0
  116. package/dist/generate/types.js +3 -0
  117. package/dist/generate/vscode-custom-data.d.ts +1 -0
  118. package/dist/generate/vscode-custom-data.js +9 -0
  119. package/dist/generate/web-types.d.ts +1 -0
  120. package/dist/generate/web-types.js +0 -0
  121. package/dist/helpers/component-meta.d.ts +26 -0
  122. package/dist/helpers/component-meta.js +295 -0
  123. package/dist/helpers/index.d.ts +4 -0
  124. package/dist/helpers/index.js +1 -0
  125. package/dist/helpers/lib-entries.d.ts +12 -0
  126. package/dist/helpers/lib-entries.js +73 -0
  127. package/dist/helpers/package-json.d.ts +2 -0
  128. package/dist/helpers/package-json.js +74 -0
  129. package/dist/helpers/utils.d.ts +23 -0
  130. package/dist/helpers/utils.js +105 -0
  131. package/dist/helpers/vscode-custom-data.d.ts +3 -0
  132. package/dist/helpers/vscode-custom-data.js +30 -0
  133. package/dist/index.d.ts +62 -0
  134. package/dist/index.js +50 -0
  135. package/dist/key-generate.d.ts +1 -0
  136. package/dist/key-generate.js +24 -0
  137. package/dist/lint/fix.d.ts +1 -0
  138. package/dist/lint/fix.js +4 -0
  139. package/dist/lint/index.d.ts +1 -0
  140. package/dist/lint/index.js +4 -0
  141. package/dist/lint/lint.d.ts +14 -0
  142. package/dist/lint/lint.js +34 -0
  143. package/dist/make-command.d.ts +10 -0
  144. package/dist/make-command.js +95 -0
  145. package/dist/make-job.d.ts +5 -0
  146. package/dist/make-job.js +154 -0
  147. package/dist/make-policy.d.ts +10 -0
  148. package/dist/make-policy.js +142 -0
  149. package/dist/make-resource.d.ts +10 -0
  150. package/dist/make-resource.js +142 -0
  151. package/dist/make.d.ts +52 -0
  152. package/dist/make.js +328 -0
  153. package/dist/migrate/database.d.ts +1 -0
  154. package/dist/migrate/database.js +16 -0
  155. package/dist/migrate/fresh.d.ts +1 -0
  156. package/dist/migrate/fresh.js +31 -0
  157. package/dist/orm/base.d.ts +1 -0
  158. package/dist/orm/base.js +0 -0
  159. package/dist/orm/test.d.ts +1 -0
  160. package/dist/orm/test.js +0 -0
  161. package/dist/prepublish.d.ts +1 -0
  162. package/dist/prepublish.js +16 -0
  163. package/dist/queue/clear.d.ts +1 -0
  164. package/dist/queue/clear.js +42 -0
  165. package/dist/queue/dlq-purge.d.ts +1 -0
  166. package/dist/queue/dlq-purge.js +28 -0
  167. package/dist/queue/dlq-retry.d.ts +1 -0
  168. package/dist/queue/dlq-retry.js +35 -0
  169. package/dist/queue/dlq.d.ts +1 -0
  170. package/dist/queue/dlq.js +55 -0
  171. package/dist/queue/failed.d.ts +1 -0
  172. package/dist/queue/failed.js +69 -0
  173. package/dist/queue/flush.d.ts +1 -0
  174. package/dist/queue/flush.js +49 -0
  175. package/dist/queue/inspect.d.ts +1 -0
  176. package/dist/queue/inspect.js +154 -0
  177. package/dist/queue/list.d.ts +1 -0
  178. package/dist/queue/list.js +69 -0
  179. package/dist/queue/monitor.d.ts +1 -0
  180. package/dist/queue/monitor.js +95 -0
  181. package/dist/queue/pause.d.ts +1 -0
  182. package/dist/queue/pause.js +28 -0
  183. package/dist/queue/quarantine.d.ts +1 -0
  184. package/dist/queue/quarantine.js +42 -0
  185. package/dist/queue/resume.d.ts +1 -0
  186. package/dist/queue/resume.js +27 -0
  187. package/dist/queue/retry.d.ts +1 -0
  188. package/dist/queue/retry.js +41 -0
  189. package/dist/queue/schedule-list.d.ts +1 -0
  190. package/dist/queue/schedule-list.js +33 -0
  191. package/dist/queue/schedule.d.ts +1 -0
  192. package/dist/queue/schedule.js +12 -0
  193. package/dist/queue/status.d.ts +1 -0
  194. package/dist/queue/status.js +68 -0
  195. package/dist/queue/table.d.ts +1 -0
  196. package/dist/queue/table.js +10 -0
  197. package/dist/queue/unquarantine.d.ts +1 -0
  198. package/dist/queue/unquarantine.js +27 -0
  199. package/dist/queue/work.d.ts +1 -0
  200. package/dist/queue/work.js +57 -0
  201. package/dist/release.d.ts +1 -0
  202. package/dist/release.js +21 -0
  203. package/dist/route/list.d.ts +1 -0
  204. package/dist/route/list.js +78 -0
  205. package/dist/run-action.d.ts +2 -0
  206. package/dist/run-action.js +1 -0
  207. package/dist/saas/setup.d.ts +1 -0
  208. package/dist/saas/setup.js +9 -0
  209. package/dist/scaffold-crud.d.ts +25 -0
  210. package/dist/scaffold-crud.js +211 -0
  211. package/dist/schedule/run.d.ts +1 -0
  212. package/dist/schedule/run.js +7 -0
  213. package/dist/search/flush.d.ts +1 -0
  214. package/dist/search/flush.js +10 -0
  215. package/dist/search/import.d.ts +1 -0
  216. package/dist/search/import.js +10 -0
  217. package/dist/search/settings-list.d.ts +1 -0
  218. package/dist/search/settings-list.js +10 -0
  219. package/dist/search/settings.d.ts +1 -0
  220. package/dist/search/settings.js +9 -0
  221. package/dist/serve/api.d.ts +1 -0
  222. package/dist/serve/api.js +35 -0
  223. package/dist/setup/index.d.ts +1 -0
  224. package/dist/setup/index.js +1 -0
  225. package/dist/setup/ssl.d.ts +38 -0
  226. package/dist/setup/ssl.js +271 -0
  227. package/dist/stacks.d.ts +4 -0
  228. package/dist/stacks.js +265 -0
  229. package/dist/templates.d.ts +28 -0
  230. package/dist/templates.js +301 -0
  231. package/dist/test/feature.d.ts +1 -0
  232. package/dist/test/feature.js +11 -0
  233. package/dist/test/index.d.ts +1 -0
  234. package/dist/test/index.js +11 -0
  235. package/dist/test/ui.d.ts +1 -0
  236. package/dist/test/ui.js +4 -0
  237. package/dist/test/unit.d.ts +1 -0
  238. package/dist/test/unit.js +11 -0
  239. package/dist/typecheck.d.ts +1 -0
  240. package/dist/typecheck.js +4 -0
  241. package/dist/types.d.ts +3 -0
  242. package/dist/types.js +16 -0
  243. package/dist/upgrade/binary.d.ts +1 -0
  244. package/dist/upgrade/binary.js +29 -0
  245. package/dist/upgrade/bun.d.ts +1 -0
  246. package/dist/upgrade/bun.js +0 -0
  247. package/dist/upgrade/dependencies.d.ts +1 -0
  248. package/dist/upgrade/dependencies.js +0 -0
  249. package/dist/upgrade/framework-utils.d.ts +150 -0
  250. package/dist/upgrade/framework-utils.js +193 -0
  251. package/dist/upgrade/framework.d.ts +1 -0
  252. package/dist/upgrade/framework.js +310 -0
  253. package/dist/upgrade/index.d.ts +1 -0
  254. package/dist/upgrade/index.js +17 -0
  255. package/dist/upgrade/packages.d.ts +14 -0
  256. package/dist/upgrade/packages.js +99 -0
  257. package/dist/upgrade/shell.d.ts +1 -0
  258. package/dist/upgrade/shell.js +41 -0
  259. package/dist/upgrade.d.ts +7 -0
  260. package/dist/upgrade.js +38 -0
  261. package/package.json +16 -16
@@ -0,0 +1,147 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { existsSync } from "node:fs";
3
+ import { config, overridesReady } from "@stacksjs/config";
4
+ import { projectPath } from "@stacksjs/path";
5
+ const requestStore = new AsyncLocalStorage;
6
+ function currentRequestContext() {
7
+ return requestStore.getStore() ?? globalThis.__stxServeContext;
8
+ }
9
+ globalThis.requestContext = {
10
+ cookie(name) {
11
+ return currentRequestContext()?.cookies?.[name] ?? null;
12
+ },
13
+ url() {
14
+ return currentRequestContext()?.url ?? "";
15
+ },
16
+ locale() {
17
+ return currentRequestContext()?.locale ?? "de";
18
+ }
19
+ };
20
+ const projectServe = projectPath("serve.ts");
21
+ try {
22
+ if (await Bun.file(projectServe).exists())
23
+ await import(projectServe);
24
+ else
25
+ await startDefaultServer();
26
+ } catch {
27
+ await startDefaultServer();
28
+ }
29
+ function parseCookies(req) {
30
+ const out = {}, header = req.headers.get("cookie") || "";
31
+ if (!header)
32
+ return out;
33
+ for (const part of header.split(";")) {
34
+ const trimmed = part.trim(), eq = trimmed.indexOf("=");
35
+ if (eq === -1)
36
+ continue;
37
+ const k = trimmed.slice(0, eq).trim(), v = trimmed.slice(eq + 1).trim();
38
+ if (!k)
39
+ continue;
40
+ try {
41
+ out[k] = decodeURIComponent(v);
42
+ } catch {
43
+ out[k] = v;
44
+ }
45
+ }
46
+ return out;
47
+ }
48
+ async function startDefaultServer() {
49
+ await overridesReady;
50
+ const { injectGlobalAutoImports, isApiBoundRequest, proxyToBackend } = await import("@stacksjs/server"), { applyRequestLocale } = await import("@stacksjs/i18n");
51
+ await injectGlobalAutoImports();
52
+ const { serve } = await import("bun-plugin-stx/serve"), { site: siteConfig, i18n: i18nConfig } = await loadStxSiteConfig(), userViewsPath = "resources/views", defaultViewsPath = "storage/framework/defaults/resources/views", userLayoutsPath = await firstExistingPath([
53
+ "resources/views/layouts",
54
+ "resources/layouts"
55
+ ]) ?? "resources/views/layouts", defaultLayoutsPath = "storage/framework/defaults/resources/layouts", userComponentsPath = await firstExistingPath([
56
+ "resources/views/components",
57
+ "resources/components"
58
+ ]) ?? "resources/views/components", preferredPort = Number(process.env.PORT) || 3000, apiPort = Number(process.env.PORT_API) || 3008, docsPort = Number(process.env.PORT_DOCS) || config.ports?.docs || 3006, apiBase = `http://127.0.0.1:${apiPort}`, docsBase = `http://127.0.0.1:${docsPort}`, authCookie = config?.auth?.defaultTokenName ?? "auth-token";
59
+ await serve({
60
+ patterns: [userViewsPath, defaultViewsPath],
61
+ port: preferredPort,
62
+ componentsDir: "storage/framework/defaults/resources/components",
63
+ layoutsDir: userLayoutsPath,
64
+ partialsDir: userComponentsPath,
65
+ fallbackLayoutsDir: defaultLayoutsPath,
66
+ fallbackPartialsDir: defaultViewsPath,
67
+ quiet: !0,
68
+ ...i18nConfig && { i18n: i18nConfig },
69
+ ...siteConfig?.url && { site: siteConfig },
70
+ auth: {
71
+ cookieName: authCookie,
72
+ redirectTo: "/login"
73
+ },
74
+ onRequest: async (req) => {
75
+ const url = new URL(req.url), { maintenanceGate } = await import("@stacksjs/server"), gated = await maintenanceGate(req);
76
+ if (gated)
77
+ return gated;
78
+ if (existsSync(projectPath("resources/views/blog.stx"))) {
79
+ const { renderBlogFeed } = await import("../blog"), feed = await renderBlogFeed(req);
80
+ if (feed)
81
+ return feed;
82
+ } else {
83
+ const { renderBlog } = await import("../blog"), blogResponse = await renderBlog(req);
84
+ if (blogResponse)
85
+ return blogResponse;
86
+ }
87
+ if (url.pathname === "/docs" || url.pathname.startsWith("/docs/"))
88
+ return proxyToBackend(req, docsBase, "/docs");
89
+ if (isApiBoundRequest(req, url.pathname))
90
+ return proxyToBackend(req, apiBase);
91
+ if (i18nConfig && req.method === "GET") {
92
+ const localeSwitch = url.pathname.match(/^\/locale\/([a-z]{2}(?:-[a-z]{2})?)\/?$/i);
93
+ if (localeSwitch) {
94
+ const { createLocaleSwitchResponse } = await import("@stacksjs/i18n");
95
+ return createLocaleSwitchResponse(req, localeSwitch[1], i18nConfig);
96
+ }
97
+ }
98
+ const locale = await applyRequestLocale(req), ctx = { cookies: parseCookies(req), url: req.url, locale };
99
+ globalThis.__stxServeSearch = url.search;
100
+ globalThis.__stxServeContext = ctx;
101
+ requestStore.enterWith(ctx);
102
+ return null;
103
+ }
104
+ });
105
+ }
106
+ async function firstExistingPath(candidates) {
107
+ for (const candidate of candidates)
108
+ if (existsSync(projectPath(candidate)))
109
+ return candidate;
110
+ return null;
111
+ }
112
+ function fallbackI18nFromSite(site) {
113
+ const locales = site.i18n.locales, defaultLocale = site.i18n.defaultLocale ?? locales[0];
114
+ return {
115
+ locales,
116
+ defaultLocale,
117
+ labels: site.i18n.labels ?? Object.fromEntries(locales.map((c) => [c, c.toUpperCase()])),
118
+ translations: {},
119
+ pickerSelector: site.i18n.pickerSelector ?? "#lang-picker"
120
+ };
121
+ }
122
+ async function resolveSiteI18n(site) {
123
+ try {
124
+ const { resolveI18n } = await import("@stacksjs/stx");
125
+ if (typeof resolveI18n === "function") {
126
+ const i18n = resolveI18n(site, projectPath());
127
+ if (i18n)
128
+ return i18n;
129
+ }
130
+ } catch {}
131
+ return fallbackI18nFromSite(site);
132
+ }
133
+ async function loadStxSiteConfig() {
134
+ const sitePath = projectPath("site.config.ts");
135
+ if (!existsSync(sitePath))
136
+ return {};
137
+ try {
138
+ const site = (await import(sitePath)).default;
139
+ if (!site)
140
+ return {};
141
+ if (!site.i18n)
142
+ return { site };
143
+ const i18n = await resolveSiteI18n(site);
144
+ return { site, i18n };
145
+ } catch {}
146
+ return {};
147
+ }
@@ -0,0 +1,18 @@
1
+ import type { StackDirectory } from '@stacksjs/types';
2
+ export declare function discoverPackages(): Promise<DiscoveredPackagesManifest>;
3
+ export declare interface PackageStacksMeta {
4
+ providers?: string[]
5
+ routes?: string[]
6
+ views?: string[]
7
+ components?: string[]
8
+ commands?: string[]
9
+ middleware?: string[]
10
+ migrations?: string[]
11
+ name?: string
12
+ description?: string
13
+ directories?: StackDirectory[]
14
+ }
15
+ export declare interface DiscoveredPackagesManifest {
16
+ generated_at: string
17
+ packages: Record<string, PackageStacksMeta>
18
+ }
@@ -0,0 +1,32 @@
1
+ import { projectPath, storagePath } from "@stacksjs/path";
2
+ export async function discoverPackages() {
3
+ const manifest = {
4
+ generated_at: new Date().toISOString(),
5
+ packages: {}
6
+ }, dontDiscover = new Set;
7
+ try {
8
+ const list = (await Bun.file(projectPath("package.json")).json())?.stacks?.["dont-discover"];
9
+ if (Array.isArray(list))
10
+ for (const name of list)
11
+ dontDiscover.add(name);
12
+ } catch {}
13
+ const pantryDir = projectPath("pantry"), patterns = ["*/package.json", "@*/*/package.json"];
14
+ for (const pattern of patterns) {
15
+ const glob = new Bun.Glob(pattern);
16
+ for await (const file of glob.scan({ cwd: pantryDir, absolute: !0, onlyFiles: !0 }))
17
+ try {
18
+ const pkg = await Bun.file(file).json(), name = pkg?.name;
19
+ if (!name || !pkg.stacks || dontDiscover.has(name))
20
+ continue;
21
+ manifest.packages[name] = pkg.stacks;
22
+ } catch {}
23
+ }
24
+ const manifestPath = storagePath("framework/discovered-packages.json");
25
+ try {
26
+ const current = await Bun.file(manifestPath).json();
27
+ if (JSON.stringify(current.packages ?? {}) === JSON.stringify(manifest.packages))
28
+ return current;
29
+ } catch {}
30
+ await Bun.write(manifestPath, JSON.stringify(manifest, null, 2));
31
+ return manifest;
32
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ import process from "node:process";
2
+ import { italic, log, parseOptions, runCommand } from "@stacksjs/cli";
3
+ import { createHostedZone, getHostedZoneNameservers, updateNameservers } from "@stacksjs/dns";
4
+ import { loadEnv } from "@stacksjs/env";
5
+ import { handleError } from "@stacksjs/error-handling";
6
+ import { projectConfigPath } from "@stacksjs/path";
7
+ import { whois } from "@stacksjs/whois";
8
+ loadEnv({
9
+ path: [".env", ".env.production"],
10
+ overload: !0
11
+ });
12
+ const options = parseOptions();
13
+ function normalizeDomain(url) {
14
+ if (!url)
15
+ return;
16
+ return url.replace(/^https?:\/\//, "").replace(/\/$/, "");
17
+ }
18
+ const domain = normalizeDomain(options.domain ?? process.env.APP_URL);
19
+ if (!domain) {
20
+ log.error("There was no Domain or App URL provided. Please provide a domain using the --domain flag or add a url to your app config.");
21
+ process.exit(1);
22
+ }
23
+ const result = await createHostedZone(domain);
24
+ if (result.isErr) {
25
+ handleError(result.error);
26
+ process.exit(1);
27
+ }
28
+ const nameServers = await getHostedZoneNameservers(domain);
29
+ if (!nameServers || nameServers.length === 0) {
30
+ handleError(`No nameservers found for domain: ${domain}. Please ensure the Hosted Zone exists in Route53.`);
31
+ process.exit(1);
32
+ }
33
+ await updateNameservers(nameServers);
34
+ const registrar = (await whois(domain, !0)).parsedData.Registrar;
35
+ if (registrar.includes("Amazon")) {
36
+ if (options.deploy)
37
+ await runCommand("buddy deploy");
38
+ else {
39
+ log.info("");
40
+ log.info("You can now continue your deployment process by re-running:");
41
+ log.info("");
42
+ log.info(` \u27A1\uFE0F ${italic("buddy deploy")}`);
43
+ log.info("");
44
+ }
45
+ process.exit(0);
46
+ }
47
+ log.info("");
48
+ log.info("\u2139\uFE0F Please note, before continuing your deployment process,");
49
+ log.info(` update your ${registrar} nameservers to the following:`);
50
+ const emojis = ["1\uFE0F\u20E3", "2\uFE0F\u20E3", "3\uFE0F\u20E3", "4\uFE0F\u20E3"];
51
+ log.info("");
52
+ nameServers.forEach((nameserver, index) => {
53
+ log.info(` ${emojis[index]} Nameserver: ${nameserver}`);
54
+ });
55
+ log.info("");
56
+ log.info(italic(`stored in ${projectConfigPath("dns.ts")}`));
57
+ log.info("");
58
+ log.info("Once the nameservers have been updated, re-run the following command:");
59
+ log.info("");
60
+ log.info(` \u27A1\uFE0F ${italic("buddy deploy")}`);
61
+ log.info("");
@@ -0,0 +1 @@
1
+ declare type CountryCode = string;
@@ -0,0 +1,66 @@
1
+ import process from "node:process";
2
+ import { log, parseOptions } from "@stacksjs/cli";
3
+ import { purchaseDomain } from "@stacksjs/cloud";
4
+ import { config } from "@stacksjs/config";
5
+ import { handleError } from "@stacksjs/error-handling";
6
+ import { ExitCode } from "@stacksjs/types";
7
+ const c = config.dns.contactInfo;
8
+ if (!c) {
9
+ handleError("You must provide contact info in your config file.");
10
+ process.exit(ExitCode.FatalError);
11
+ }
12
+ const defaultOptions = {
13
+ domain: "",
14
+ years: 1,
15
+ privacy: !0,
16
+ autoRenew: !0,
17
+ registrantFirstName: c.firstName,
18
+ registrantLastName: c.lastName,
19
+ registrantOrganization: c.organizationName,
20
+ registrantAddressLine1: c.addressLine1,
21
+ registrantAddressLine2: c.addressLine2,
22
+ registrantCity: c.city,
23
+ registrantState: c.state,
24
+ registrantCountry: c.countryCode,
25
+ registrantZip: c.zip,
26
+ registrantPhone: c.phoneNumber,
27
+ registrantEmail: c.email,
28
+ adminFirstName: c.admin?.firstName || c.firstName,
29
+ adminLastName: c.admin?.lastName || c.lastName,
30
+ adminOrganization: c.admin?.organizationName || c.organizationName,
31
+ adminAddressLine1: c.admin?.addressLine1 || c.addressLine1,
32
+ adminAddressLine2: c.admin?.addressLine2 || c.addressLine2,
33
+ adminCity: c.admin?.city || c.city,
34
+ adminState: c.admin?.state || c.state,
35
+ adminCountry: c.admin?.countryCode || c.countryCode,
36
+ adminZip: c.admin?.zip || c.zip,
37
+ adminPhone: c.admin?.phoneNumber || c.phoneNumber,
38
+ adminEmail: c.admin?.email || c.email,
39
+ techFirstName: c.tech?.firstName || c.firstName,
40
+ techLastName: c.tech?.lastName || c.lastName,
41
+ techOrganization: c.tech?.organizationName || c.organizationName,
42
+ techAddressLine1: c.tech?.addressLine1 || c.addressLine1,
43
+ techAddressLine2: c.tech?.addressLine2 || c.addressLine2,
44
+ techCity: c.tech?.city || c.city,
45
+ techState: c.tech?.state || c.state,
46
+ techCountry: c.tech?.countryCode || c.countryCode,
47
+ techZip: c.tech?.zip || c.zip,
48
+ techPhone: c.tech?.phoneNumber || c.phoneNumber,
49
+ techEmail: c.tech?.email || c.email,
50
+ privacyAdmin: c.privacyAdmin || c.privacy || !0,
51
+ privacyTech: c.privacyTech || c.privacy || !0,
52
+ privacyRegistrant: c.privacyRegistrant || c.privacy || !0,
53
+ contactType: "PERSON",
54
+ verbose: !1
55
+ }, options = { ...defaultOptions, ...parseOptions() };
56
+ if (!options.domain) {
57
+ handleError("You must provide a domain name to purchase.");
58
+ process.exit(ExitCode.FatalError);
59
+ }
60
+ const result = purchaseDomain(options.domain, options);
61
+ if (result.isErr) {
62
+ handleError(result.error);
63
+ process.exit(ExitCode.FatalError);
64
+ }
65
+ log.info("Domain purchased successfully.");
66
+ process.exit(ExitCode.Success);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import process from "node:process";
2
+ import { parseOptions } from "@stacksjs/cli";
3
+ import { app } from "@stacksjs/config";
4
+ import { deleteHostedZoneRecords } from "@stacksjs/dns";
5
+ import { handleError } from "@stacksjs/error-handling";
6
+ import { log } from "@stacksjs/logging";
7
+ const parsedOptions = parseOptions(), options = {
8
+ domain: parsedOptions.domain,
9
+ verbose: parsedOptions.verbose
10
+ };
11
+ if (!options.domain)
12
+ if (app.url)
13
+ options.domain = app.url;
14
+ else {
15
+ handleError("there was no domain provided when");
16
+ process.exit(1);
17
+ }
18
+ if (options.verbose)
19
+ log.info(`Removing domain: ${options.domain}`);
20
+ const result = await deleteHostedZoneRecords(options.domain);
21
+ if (result.isErr) {
22
+ handleError(result.error);
23
+ process.exit(1);
24
+ }
@@ -0,0 +1,5 @@
1
+ import type { ExamplesOptions } from '@stacksjs/types';
2
+ export declare function invoke(options: ExamplesOptions): Promise<void>;
3
+ export declare function examples(options: ExamplesOptions): Promise<void>;
4
+ export declare function componentExample(options: ExamplesOptions): Promise<void>;
5
+ export declare function webComponentExample(options: ExamplesOptions): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import process from "node:process";
2
+ import { NpmScript } from "@stacksjs/enums";
3
+ import { log } from "@stacksjs/logging";
4
+ import { hasComponents } from "@stacksjs/storage";
5
+ import { ExitCode } from "@stacksjs/types";
6
+ import { runNpmScript } from "@stacksjs/utils";
7
+ export async function invoke(options) {
8
+ if (options.components || options.vue)
9
+ await componentExample(options);
10
+ else if (options.webComponents || options.elements)
11
+ await webComponentExample(options);
12
+ else
13
+ log.error("An unsupported option was used. Please try again, check the documentation & report the issue, if needed.");
14
+ }
15
+ export async function examples(options) {
16
+ return await invoke(options);
17
+ }
18
+ export async function componentExample(options) {
19
+ if (hasComponents()) {
20
+ await runNpmScript(NpmScript.ExampleVue, options);
21
+ log.success("Your component library was built successfully");
22
+ } else
23
+ log.info("No components found.");
24
+ }
25
+ export async function webComponentExample(options) {
26
+ if (hasComponents()) {
27
+ log.info("Building your Web Component library...");
28
+ await runNpmScript(NpmScript.BuildWebComponents, options);
29
+ log.success("Your Web Component library was built successfully");
30
+ } else {
31
+ log.info("No components found.");
32
+ process.exit(ExitCode.FatalError);
33
+ }
34
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import process from "node:process";
2
+ import { parseOptions } from "@stacksjs/cli";
3
+ import { log } from "@stacksjs/logging";
4
+ import { ExitCode } from "@stacksjs/types";
5
+ import { findStacksProjects } from "@stacksjs/utils";
6
+ try {
7
+ const options = parseOptions(), projects = await findStacksProjects(void 0, options);
8
+ if (projects.length > 0) {
9
+ log.info("Found Projects:");
10
+ projects.forEach((project) => console.log(` - ${project}`));
11
+ process.exit(ExitCode.Success);
12
+ }
13
+ log.info("No Stacks Projects found.");
14
+ } catch (error) {
15
+ log.error("Error searching for Stacks projects:", error);
16
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/fresh.js ADDED
@@ -0,0 +1,17 @@
1
+ import process from "node:process";
2
+ import { runCommand } from "@stacksjs/cli";
3
+ import { handleError } from "@stacksjs/error-handling";
4
+ import { log } from "@stacksjs/logging";
5
+ import { projectPath } from "@stacksjs/path";
6
+ import { ExitCode } from "@stacksjs/types";
7
+ import { cleanProject } from "@stacksjs/utils";
8
+ log.info("Cleaning project...");
9
+ await cleanProject();
10
+ log.info("Installing dependencies...");
11
+ const result = await runCommand("bun install", {
12
+ cwd: projectPath()
13
+ });
14
+ if (result.isErr) {
15
+ handleError(result.error);
16
+ process.exit(ExitCode.FatalError);
17
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import { readdir } from "node:fs/promises";
2
+ import { log } from "@stacksjs/logging";
3
+ import { path as p } from "@stacksjs/path";
4
+ import { storage } from "@stacksjs/storage";
5
+ log.info("Generating action types...");
6
+ const domain = "Actions", files = await readdir(p.appPath(domain), { recursive: !0 }), validActions = `// This file is auto-generated by Stacks. Do not edit this file manually.
7
+ // If you wish to rename an action, please do so by editing the file name.
8
+ //
9
+ // For more information, please visit: https://stacksjs.com/docs
10
+
11
+ export type ActionPath = ${files.filter((file) => file.endsWith(".ts")).map((value) => `'${domain}/${value.replace(".ts", "")}'`).join(" | ")}
12
+ `;
13
+ await storage.writeFile(p.frameworkPath("types/actions.d.ts"), validActions);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { log } from "@stacksjs/logging";
2
+ import { hasComponents } from "@stacksjs/storage";
3
+ import { generateComponentMeta } from "../helpers/component-meta";
4
+ log.info("Generating component meta...");
5
+ if (hasComponents())
6
+ generateComponentMeta();
7
+ else
8
+ log.info("No components found. Skipping component meta generation.");
9
+ log.success("Generated component meta.");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ import process from "node:process";
2
+ import { cli } from "@stacksjs/config";
3
+ import { log } from "@stacksjs/logging";
4
+ import { projectPath } from "@stacksjs/path";
5
+ import { writeTextFile } from "@stacksjs/storage";
6
+ import { ExitCode } from "@stacksjs/types";
7
+ log.info("Ensuring Component Library Entry Point...");
8
+ if (!cli.command) {
9
+ log.error("No command defined in the CLI configuration");
10
+ process.exit(ExitCode.FatalError);
11
+ }
12
+ await writeTextFile({
13
+ path: projectPath(cli.command),
14
+ data: `#!/usr/bin/env bun
15
+ import('./storage/framework/core/buddy/src/custom-cli')
16
+ `
17
+ }).catch((err) => {
18
+ log.error("There was an error generating your custom CLI file.", err);
19
+ process.exit(ExitCode.FatalError);
20
+ });
21
+ log.success("Generated custom CLI file");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,66 @@
1
+ import { env as e, envEnum } from "@stacksjs/env";
2
+ import { log } from "@stacksjs/logging";
3
+ import { path as p } from "@stacksjs/path";
4
+ import { storage } from "@stacksjs/storage";
5
+ import { envKeys } from "../../../../env";
6
+ log.info("Generating type env files...");
7
+ const envTypes = `
8
+ // This file is auto-generated by Stacks. Do not edit this file manually.
9
+ // If you want to change the environment variables, please edit the .env file.
10
+ //
11
+ // For more information, please visit: https://stacksjs.com/docs
12
+
13
+ declare module 'bun' {
14
+ namespace env {
15
+ ${envKeys.map((key) => {
16
+ let type = typeof e[key], value = e[key];
17
+ if (!value)
18
+ if (envEnum[key]) {
19
+ type = envEnum[key]?.map((item) => `'${item}'`).join(" | ");
20
+ value = envEnum[key]?.[0];
21
+ } else
22
+ switch (type) {
23
+ case "number":
24
+ value = "0";
25
+ break;
26
+ case "boolean":
27
+ value = !1;
28
+ break;
29
+ default:
30
+ value = "";
31
+ }
32
+ type = "string";
33
+ if (typeof value === "string") {
34
+ if (value.toLowerCase() === "true" || value.toLowerCase() === "false")
35
+ type = "boolean";
36
+ else if (!Number.isNaN(Number.parseFloat(value)) && Number.isFinite(Number(value)))
37
+ type = "number";
38
+ else if (envEnum[key])
39
+ type = envEnum[key].map((item) => `'${item}'`).join(" | ");
40
+ } else if (typeof value === "number")
41
+ type = "number";
42
+ else if (typeof value === "boolean")
43
+ type = "boolean";
44
+ return `const ${key}: ${type}`;
45
+ }).join(`
46
+ `)}
47
+ }
48
+ }
49
+ `;
50
+ await storage.writeFile(p.frameworkPath("types/env.d.ts"), envTypes);
51
+ log.info(" - ./storage/framework/env.ts");
52
+ const env = `
53
+ // This file is auto-generated by Stacks. Do not edit this file manually.
54
+ // If you want to change the environment variables, please edit the .env file.
55
+ //
56
+ // For more information, please visit: https://stacksjs.com/docs
57
+
58
+ export const envKeys = [
59
+ ${envKeys.map((key) => `'${key}'`).join(`,
60
+ `)}
61
+ ] as const
62
+
63
+ export type EnvKey = typeof envKeys[number]
64
+ `;
65
+ await storage.writeFile(p.frameworkPath("env.ts"), env);
66
+ log.info(" - ./storage/framework/env.d.ts");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { log } from "@stacksjs/logging";
2
+ import { hasComponents } from "@stacksjs/storage";
3
+ import { generateVsCodeCustomData, generateWebTypes } from "../helpers/vscode-custom-data";
4
+ if (hasComponents()) {
5
+ await generateWebTypes();
6
+ await generateVsCodeCustomData();
7
+ } else
8
+ log.info("No components found. Skipping IDE helper generation.");
@@ -0,0 +1,36 @@
1
+ import type { GeneratorOptions } from '@stacksjs/types';
2
+ // import { files } from '@stacksjs/storage'
3
+ export declare function invoke(options?: GeneratorOptions): Promise<void>;
4
+ export declare function generate(options: GeneratorOptions): Promise<void>;
5
+ export declare function generateLibEntries(options: GeneratorOptions): Promise<void>;
6
+ export declare function generateWebTypes(options?: GeneratorOptions): Promise<void>;
7
+ export declare function generateVsCodeCustomData(): Promise<void>;
8
+ export declare function generateIdeHelpers(options?: GeneratorOptions): Promise<void>;
9
+ export declare function generateComponentMeta(): Promise<void>;
10
+ export declare function generateTypes(options?: GeneratorOptions): Promise<void>;
11
+ /**
12
+ * Watch model + config + migration source for changes and re-run
13
+ * `generateTypes()` whenever any of them change. Debounced at 200ms so
14
+ * a refactor that touches a dozen files in one save coalesces into a
15
+ * single regen pass.
16
+ *
17
+ * Watched roots:
18
+ * - `app/Models/` — userland models
19
+ * - `storage/framework/defaults/app/Models/` — framework defaults
20
+ * (Stacks' equivalent of Laravel's vendor/. When you're working on
21
+ * the framework itself you edit here and need fresh types just as
22
+ * much as a userland edit.)
23
+ * - `config/`
24
+ * - `database/migrations/`
25
+ *
26
+ * `inflight` guards against re-entry: a slow regen shouldn't queue up
27
+ * three more behind it. `pending` debounces a burst of saves into one
28
+ * fire. The returned promise only resolves on SIGINT, so the caller
29
+ * either awaits (blocking, like `generate:types --watch`) or fires it
30
+ * non-blocking (sidecar use, like `dev:api`).
31
+ */
32
+ export declare function watchTypes(options?: GeneratorOptions): Promise<void>;
33
+ export declare function generatePantryConfig(): void;
34
+ export declare function generateSeeder(): Promise<void>;
35
+ export declare function generateCoreSymlink(): Promise<void>;
36
+ export declare function generateOpenApiSpec(): Promise<void>;