@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,158 @@
1
+ import * as fs from "node:fs";
2
+ import process from "node:process";
3
+ import { runCommand } from "@stacksjs/cli";
4
+ import { Action, NpmScript } from "@stacksjs/enums";
5
+ import { log } from "@stacksjs/logging";
6
+ import { frameworkPath, projectPath, storagePath } from "@stacksjs/path";
7
+ import { ExitCode } from "@stacksjs/types";
8
+ import { runNpmScript } from "@stacksjs/utils";
9
+ import { runAction } from "../helpers";
10
+ import { generateVsCodeCustomData as genVsCodeCustomData } from "../helpers/vscode-custom-data";
11
+ export async function invoke(options) {
12
+ if (options?.types)
13
+ await generateTypes(options);
14
+ else if (options?.entries)
15
+ await generateLibEntries(options);
16
+ else if (options?.webTypes)
17
+ await generateWebTypes(options);
18
+ else if (options?.customData)
19
+ await generateVsCodeCustomData();
20
+ else if (options?.ideHelpers)
21
+ await generateIdeHelpers(options);
22
+ else if (options?.componentMeta)
23
+ await generateComponentMeta();
24
+ else if (options?.coreSymlink)
25
+ await generateCoreSymlink();
26
+ else if (options?.openApiSpec)
27
+ await generateOpenApiSpec();
28
+ }
29
+ export function generate(options) {
30
+ return invoke(options);
31
+ }
32
+ export async function generateLibEntries(options) {
33
+ const result = await runAction(Action.GenerateLibraryEntries, {
34
+ ...options,
35
+ cwd: projectPath()
36
+ });
37
+ if (result.isErr) {
38
+ log.error("There was an error generating your library entry points", result.error);
39
+ process.exit(ExitCode.FatalError);
40
+ }
41
+ log.success("Library entry points generated successfully");
42
+ }
43
+ export async function generateWebTypes(options) {
44
+ const result = await runNpmScript(NpmScript.GenerateWebTypes, options);
45
+ if (result.isErr) {
46
+ log.error("There was an error generating the web-types.json file.", result.error);
47
+ process.exit(ExitCode.FatalError);
48
+ }
49
+ log.success("Successfully generated the web-types.json file");
50
+ }
51
+ export async function generateVsCodeCustomData() {
52
+ const result = await genVsCodeCustomData();
53
+ if (result.isErr) {
54
+ log.error("There was an error generating the custom-elements.json file.", result.error);
55
+ process.exit(ExitCode.FatalError);
56
+ }
57
+ await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
58
+ log.success("Successfully generated the custom-elements.json file");
59
+ }
60
+ export async function generateIdeHelpers(options) {
61
+ const result = await runNpmScript(NpmScript.GenerateIdeHelpers, options);
62
+ if (result.isErr) {
63
+ log.error("There was an error generating IDE helpers.", result.error);
64
+ process.exit(ExitCode.FatalError);
65
+ }
66
+ await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
67
+ log.success("Successfully generated IDE helpers");
68
+ }
69
+ export async function generateComponentMeta() {
70
+ const result = await genVsCodeCustomData();
71
+ if (result.isErr) {
72
+ log.error("There was an error generating your component meta information.", result.error);
73
+ process.exit(ExitCode.FatalError);
74
+ }
75
+ await runAction(Action.LintFix, { verbose: !0, cwd: projectPath() });
76
+ log.success("Successfully generated component meta information");
77
+ }
78
+ export async function generateTypes(options) {
79
+ const result = await runNpmScript(NpmScript.GenerateTypes, {
80
+ cwd: frameworkPath(),
81
+ ...options
82
+ });
83
+ if (result.isErr) {
84
+ log.error("There was an error generating your types.", result.error);
85
+ throw result.error instanceof Error ? result.error : Error(String(result.error));
86
+ }
87
+ log.success("Types were generated successfully");
88
+ }
89
+ export async function watchTypes(options) {
90
+ try {
91
+ const manifestPath = `${frameworkPath()}/package.json`, text = fs.existsSync(manifestPath) ? fs.readFileSync(manifestPath, "utf-8") : "";
92
+ if (!(text ? JSON.parse(text) : {})?.scripts?.["generate:types"]) {
93
+ log.warn("[generate:types --watch] no `generate:types` script in framework package.json \u2014 type regeneration disabled. dev:api will keep running, but type definitions won't auto-refresh on model/config changes.");
94
+ return;
95
+ }
96
+ } catch {}
97
+ const watched = [
98
+ projectPath("app/Models"),
99
+ storagePath("framework/defaults/app/Models"),
100
+ projectPath("config"),
101
+ projectPath("database/migrations")
102
+ ];
103
+ log.info(`[generate:types --watch] watching ${watched.length} directories`);
104
+ let pending = null, inflight = !1;
105
+ const trigger = () => {
106
+ if (pending)
107
+ clearTimeout(pending);
108
+ pending = setTimeout(async () => {
109
+ if (inflight)
110
+ return;
111
+ inflight = !0;
112
+ try {
113
+ log.info("[generate:types --watch] change detected, regenerating\u2026");
114
+ await generateTypes(options);
115
+ log.success("[generate:types --watch] types up to date");
116
+ } catch (err) {
117
+ log.error("[generate:types --watch] regeneration failed:", err);
118
+ } finally {
119
+ inflight = !1;
120
+ }
121
+ }, 200);
122
+ }, watchers = [];
123
+ for (const dir of watched)
124
+ try {
125
+ if (!fs.existsSync(dir))
126
+ continue;
127
+ const w = fs.watch(dir, { recursive: !0 }, () => trigger());
128
+ watchers.push(w);
129
+ } catch (err) {
130
+ log.warn(`[generate:types --watch] cannot watch ${dir}: ${err}`);
131
+ }
132
+ if (watchers.length === 0) {
133
+ log.warn("[generate:types --watch] no directories to watch \u2014 exiting");
134
+ return;
135
+ }
136
+ await new Promise((resolve) => {
137
+ process.once("SIGINT", () => {
138
+ log.info("[generate:types --watch] stopping");
139
+ for (const w of watchers)
140
+ try {
141
+ w.close();
142
+ } catch {}
143
+ resolve();
144
+ });
145
+ });
146
+ }
147
+ export function generatePantryConfig() {
148
+ log.success("Successfully generated `./pantry.yaml` based on your config");
149
+ }
150
+ export async function generateSeeder() {}
151
+ export async function generateCoreSymlink() {
152
+ await runCommand(`ln -s ${frameworkPath()} ${projectPath(".stacks")}`);
153
+ }
154
+ export async function generateOpenApiSpec() {
155
+ const { generateOpenApi } = await import("@stacksjs/api");
156
+ await generateOpenApi();
157
+ log.success("Successfully generated Open API Spec");
158
+ }
@@ -0,0 +1 @@
1
+ export declare function generateLibEntries(): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import { library } from "@stacksjs/config";
2
+ import { log } from "@stacksjs/logging";
3
+ import { hasComponents, hasFunctions } from "@stacksjs/storage";
4
+ import { generateLibEntry } from "../helpers/lib-entries";
5
+ export async function generateLibEntries() {
6
+ log.info("Generating library entry points...");
7
+ if (library.releaseable && hasComponents())
8
+ await generateLibEntry("web-components");
9
+ else
10
+ log.info("No components found. Skipping building component entry points.");
11
+ if (library.releaseable && hasFunctions())
12
+ await generateLibEntry("functions");
13
+ else
14
+ log.info("No functions found. Skipping building function entry point.");
15
+ }
16
+ await generateLibEntries();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ import { log, runCommand } from "@stacksjs/cli";
2
+ import { config } from "@stacksjs/config";
3
+ const pantryFile = Bun.file(new URL("../../../../../pantry.yaml", import.meta.url));
4
+ if (!await pantryFile.exists())
5
+ throw Error("pantry.yaml file not found");
6
+ const data = Bun.YAML.parse(await pantryFile.text());
7
+ if (data.dependencies["aws.amazon.com/cdk"] === void 0) {
8
+ log.info("aws.amazon.com/cdk dependency not found in pantry.yaml.");
9
+ if ((await runCommand("which cdk")).isErr)
10
+ throw Error("aws.amazon.com/cdk dependency not found in pantry.yaml. To confirm, run `which cdk`");
11
+ }
12
+ if (data.dependencies["aws.amazon.com/cli"] === void 0) {
13
+ log.info("aws.amazon.com/cli dependency not found in pantry.yaml.");
14
+ if ((await runCommand("which aws")).isErr)
15
+ throw Error("aws.amazon.com/cli dependency not found in pantry.yaml. To confirm, run `which aws`");
16
+ }
17
+ if (data.dependencies["bun.sh"] === void 0) {
18
+ log.info("bun.sh dependency not found in pantry.yaml.");
19
+ if ((await runCommand("which bun")).isErr)
20
+ throw Error("bun.sh dependency not found in pantry.yaml. To confirm, run `which bun`");
21
+ }
22
+ if (data.dependencies["info-zip.org/zip"] === void 0) {
23
+ log.info("info-zip.org/zip dependency not found in pantry.yaml.");
24
+ if ((await runCommand("which zip")).isErr)
25
+ throw Error("info-zip.org/zip dependency not found in pantry.yaml. To confirm, run `which zip`");
26
+ }
27
+ if (data.dependencies["info-zip.org/unzip"] === void 0) {
28
+ log.info("info-zip.org/unzip dependency not found in pantry.yaml.");
29
+ if ((await runCommand("which unzip")).isErr)
30
+ throw Error("info-zip.org/unzip dependency not found in pantry.yaml. To confirm, run `which unzip`");
31
+ }
32
+ if (data.dependencies["mailpit.axllent.org"] === void 0) {
33
+ log.info("mailpit.axllent.org dependency not found in pantry.yaml.");
34
+ if ((await runCommand("which mailpit")).isErr)
35
+ throw Error("mailpit.axllent.org dependency not found in pantry.yaml. To confirm, run `which mailpit`");
36
+ }
37
+ if (data.dependencies["redis.io"] === void 0) {
38
+ log.info("redis.io dependency not found in pantry.yaml.");
39
+ if ((await runCommand("which redis")).isErr)
40
+ throw Error("redis.io dependency not found in pantry.yaml. To confirm, run `which redis`");
41
+ }
42
+ if (config.database.default === "sqlite" && data.dependencies["sqlite.org"] === void 0) {
43
+ log.info("sqlite.org dependency not found in pantry.yaml.");
44
+ if ((await runCommand("which sqlite")).isErr)
45
+ throw Error("sqlite.org dependency not found in pantry.yaml. To confirm, run `which sqlite`");
46
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { generateCoreSymlink } from "@stacksjs/actions";
2
+ await generateCoreSymlink();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { log } from "@stacksjs/cli";
2
+ log.info("Generating types for ./resources/components & ./resources/function");
3
+ log.info("Generated types saved in ./storage/framework/types/*");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { log } from "@stacksjs/logging";
2
+ import { hasComponents } from "@stacksjs/storage";
3
+ import { generateVsCodeCustomData } from "../helpers/vscode-custom-data";
4
+ log.info("Generating VS Code custom data...");
5
+ if (hasComponents())
6
+ await generateVsCodeCustomData();
7
+ else
8
+ log.info("No components found. Skipping VS Code custom data generation.");
9
+ log.success("Generated VS Code custom data.");
@@ -0,0 +1 @@
1
+
File without changes
@@ -0,0 +1,26 @@
1
+ export declare function generateComponentMeta(): Promise<void>;
2
+ /**
3
+ * Read an `.stx` file and return its component API surface.
4
+ */
5
+ export declare function parseStxComponentMeta(componentPath: string): ComponentApi;
6
+ export declare interface ComponentApiProp {
7
+ name: string
8
+ description: string
9
+ type: string
10
+ default: string
11
+ required: boolean
12
+ }
13
+ export declare interface ComponentApiSlot {
14
+ name: string
15
+ description: string
16
+ }
17
+ export declare interface ComponentApiEvent {
18
+ name: string
19
+ type: string
20
+ description: string
21
+ }
22
+ export declare interface ComponentApi {
23
+ props: ComponentApiProp[]
24
+ events: ComponentApiEvent[]
25
+ slots: ComponentApiSlot[]
26
+ }
@@ -0,0 +1,295 @@
1
+ import { frameworkPath, join, path, projectPath } from "@stacksjs/path";
2
+ import { existsSync, globSync, mkdirSync, writeFileSync } from "@stacksjs/storage";
3
+ import { readFileSync } from "node:fs";
4
+ let parseMarkdownFn = null;
5
+ async function getMarkdownParser() {
6
+ if (parseMarkdownFn)
7
+ return parseMarkdownFn;
8
+ try {
9
+ parseMarkdownFn = (await import("@stacksjs/ts-md")).parseMarkdown;
10
+ } catch {
11
+ parseMarkdownFn = (s) => s;
12
+ }
13
+ return parseMarkdownFn;
14
+ }
15
+ function renderDescription(raw) {
16
+ if (!raw)
17
+ return "";
18
+ return parseMarkdownFn ? parseMarkdownFn(raw) : raw;
19
+ }
20
+ export async function generateComponentMeta() {
21
+ await getMarkdownParser();
22
+ const components = globSync([
23
+ "components/*.stx",
24
+ "components/**/*.stx",
25
+ "resources/components/**/*.stx",
26
+ "storage/framework/defaults/resources/components/**/*.stx"
27
+ ], { cwd: projectPath(), absolute: !0 }), metaDirPath = frameworkPath("component-meta");
28
+ if (!existsSync(metaDirPath))
29
+ mkdirSync(metaDirPath, { recursive: !0 });
30
+ for (const componentPath of components) {
31
+ const componentExportName = path.parse(componentPath).name, meta = parseStxComponentMeta(componentPath), metaJsonFilePath = join(metaDirPath, `${componentExportName}.json`);
32
+ writeFileSync(metaJsonFilePath, JSON.stringify(meta, null, 2));
33
+ }
34
+ }
35
+ export function parseStxComponentMeta(componentPath) {
36
+ const source = readFileSync(componentPath, "utf8"), scriptBlock = extractFirstScriptBlock(source), templateBlock = extractTemplate(source), props = scriptBlock ? extractProps(scriptBlock) : [], events = scriptBlock ? extractEvents(scriptBlock) : [], slots = extractSlots(templateBlock);
37
+ return { props, events, slots };
38
+ }
39
+ function extractFirstScriptBlock(source) {
40
+ const serverMatch = /<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i.exec(source);
41
+ if (serverMatch?.[1])
42
+ return serverMatch[1];
43
+ return /<script\b[^>]*>([\s\S]*?)<\/script>/i.exec(source)?.[1] ?? null;
44
+ }
45
+ function extractTemplate(source) {
46
+ const templateMatch = /<template\b[^>]*>([\s\S]*?)<\/template>/i.exec(source);
47
+ if (templateMatch?.[1])
48
+ return templateMatch[1];
49
+ return source.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "");
50
+ }
51
+ function extractProps(script) {
52
+ const interfaces = collectInterfaces(script), propsTypeBody = locatePropsType(script, interfaces);
53
+ if (!propsTypeBody)
54
+ return [];
55
+ const fields = parseTypeBody(propsTypeBody, interfaces), defaults = extractDefaults(script);
56
+ return fields.map((field) => {
57
+ return {
58
+ name: field.required ? field.name : `${field.name}?`,
59
+ description: renderDescription(field.description),
60
+ type: field.type,
61
+ default: defaults[field.name] ?? field.default ?? "unknown",
62
+ required: field.required
63
+ };
64
+ });
65
+ }
66
+ function collectInterfaces(script) {
67
+ const interfaces = new Map, ifaceRe = /(?:export\s+)?interface\s+([A-Z][\w$]*)\s*(?:extends\s+[\w$,\s]+)?\s*\{/g;
68
+ let m;
69
+ while ((m = ifaceRe.exec(script)) !== null) {
70
+ const name = m[1];
71
+ if (!name)
72
+ continue;
73
+ const start = m.index + m[0].length, body = sliceBalanced(script, start - 1, "{", "}");
74
+ if (body !== null)
75
+ interfaces.set(name, body);
76
+ }
77
+ const typeAliasRe = /(?:export\s+)?type\s+([A-Z][\w$]*)\s*=\s*\{/g;
78
+ while ((m = typeAliasRe.exec(script)) !== null) {
79
+ const name = m[1];
80
+ if (!name)
81
+ continue;
82
+ const start = m.index + m[0].length, body = sliceBalanced(script, start - 1, "{", "}");
83
+ if (body !== null)
84
+ interfaces.set(name, body);
85
+ }
86
+ return interfaces;
87
+ }
88
+ function locatePropsType(script, interfaces) {
89
+ const match = /defineProps\s*<\s*([\s\S]+?)\s*>\s*\(/.exec(script), generic = match?.[1]?.trim();
90
+ if (!match || !generic)
91
+ return null;
92
+ if (generic.startsWith("{")) {
93
+ const braceStart = script.indexOf("{", match.index);
94
+ return sliceBalanced(script, braceStart, "{", "}");
95
+ }
96
+ const ref = generic.replace(/[<>(].*$/, "").split("&")[0]?.trim();
97
+ if (!ref)
98
+ return null;
99
+ return interfaces.get(ref) ?? null;
100
+ }
101
+ function parseTypeBody(body, interfaces) {
102
+ const fields = [], statements = splitTopLevel(body, [";", `
103
+ `]);
104
+ let pendingDoc = "";
105
+ for (const raw of statements) {
106
+ const stmt = raw.trim();
107
+ if (!stmt)
108
+ continue;
109
+ const docMatch = /^\/\*\*([\s\S]*?)\*\/\s*([\s\S]*)$/.exec(stmt);
110
+ if (docMatch) {
111
+ pendingDoc = (docMatch[1] ?? "").split(`
112
+ `).map((l) => l.replace(/^\s*\*\s?/, "")).join(`
113
+ `).trim();
114
+ const remainder = (docMatch[2] ?? "").trim();
115
+ if (!remainder)
116
+ continue;
117
+ const field = parseFieldLine(remainder, pendingDoc, interfaces);
118
+ if (field)
119
+ fields.push(field);
120
+ pendingDoc = "";
121
+ continue;
122
+ }
123
+ if (stmt.startsWith("//")) {
124
+ pendingDoc = stmt.replace(/^\/\/\s?/, "");
125
+ continue;
126
+ }
127
+ const field = parseFieldLine(stmt, pendingDoc, interfaces);
128
+ if (field)
129
+ fields.push(field);
130
+ pendingDoc = "";
131
+ }
132
+ return fields;
133
+ }
134
+ function parseFieldLine(line, description, _interfaces) {
135
+ if (/^[a-zA-Z_$][\w$]*\s*\(/.test(line.trimStart()))
136
+ return null;
137
+ const m = /^([a-zA-Z_$][\w$]*)\s*(\??)\s*:\s*([\s\S]+?)\s*[;,]?\s*$/.exec(line);
138
+ if (!m)
139
+ return null;
140
+ const name = m[1], optional = m[2] ?? "", type = m[3];
141
+ if (!name || !type)
142
+ return null;
143
+ return {
144
+ name,
145
+ type: collapseWhitespace(type),
146
+ required: optional !== "?",
147
+ description
148
+ };
149
+ }
150
+ function extractDefaults(script) {
151
+ const defaults = {}, destructRe = /const\s*\{\s*([\s\S]*?)\s*\}\s*=\s*(?:withDefaults\s*\(\s*)?defineProps/g;
152
+ let m;
153
+ while ((m = destructRe.exec(script)) !== null)
154
+ if (m[1])
155
+ parseDestructDefaults(m[1], defaults);
156
+ const withDefaultsIdx = script.indexOf("withDefaults(");
157
+ if (withDefaultsIdx >= 0) {
158
+ const afterDefine = script.indexOf("defineProps", withDefaultsIdx);
159
+ if (afterDefine > 0) {
160
+ const generic = script.indexOf(">", afterDefine), closeParen = script.indexOf(")", generic >= 0 ? generic : afterDefine);
161
+ if (closeParen > 0) {
162
+ const commaIdx = script.indexOf(",", closeParen), objStart = commaIdx >= 0 ? script.indexOf("{", commaIdx) : -1;
163
+ if (objStart > 0) {
164
+ const body = sliceBalanced(script, objStart, "{", "}");
165
+ if (body)
166
+ parseObjectDefaults(body, defaults);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ return defaults;
172
+ }
173
+ function parseDestructDefaults(destructBody, out) {
174
+ for (const part of splitTopLevel(destructBody, [","])) {
175
+ const m = /^\s*([a-zA-Z_$][\w$]*)\s*=\s*([\s\S]+?)\s*$/.exec(part), key = m?.[1], value = m?.[2];
176
+ if (key && value)
177
+ out[key] = collapseWhitespace(value);
178
+ }
179
+ }
180
+ function parseObjectDefaults(objectBody, out) {
181
+ for (const part of splitTopLevel(objectBody, [","])) {
182
+ const m = /^\s*([a-zA-Z_$][\w$]*)\s*:\s*([\s\S]+?)\s*$/.exec(part.trim()), key = m?.[1], value = m?.[2];
183
+ if (key && value)
184
+ out[key] = collapseWhitespace(value);
185
+ }
186
+ }
187
+ function extractEvents(script) {
188
+ const m = /defineEmits\s*<\s*\{([\s\S]*?)\}\s*>\s*\(/.exec(script);
189
+ if (!m?.[1])
190
+ return [];
191
+ const events = [];
192
+ for (const part of splitTopLevel(m[1], [";", `
193
+ `])) {
194
+ const trimmed = part.trim();
195
+ if (!trimmed)
196
+ continue;
197
+ const tuple = /^['"]?([\w-]+)['"]?\s*:\s*\[(.*?)\]\s*$/.exec(trimmed);
198
+ if (tuple) {
199
+ const name = tuple[1];
200
+ if (!name)
201
+ continue;
202
+ events.push({ name, type: tuple[2]?.trim() || "void", description: "" });
203
+ continue;
204
+ }
205
+ const fn = /^([a-zA-Z_$][\w$]*)\s*\(([\s\S]*?)\)\s*:\s*([\s\S]+)$/.exec(trimmed);
206
+ if (fn) {
207
+ const name = fn[1];
208
+ if (!name)
209
+ continue;
210
+ events.push({ name, type: fn[2]?.trim() || "void", description: "" });
211
+ }
212
+ }
213
+ return events;
214
+ }
215
+ function extractSlots(template) {
216
+ const slots = [], seen = new Set, slotRe = /<slot\b([^>]*)>/g;
217
+ let m;
218
+ while ((m = slotRe.exec(template)) !== null) {
219
+ const attrs = m[1] ?? "", name = /\bname\s*=\s*["']([^"']+)["']/.exec(attrs)?.[1] ?? "default";
220
+ if (seen.has(name))
221
+ continue;
222
+ seen.add(name);
223
+ slots.push({ name, description: "" });
224
+ }
225
+ return slots;
226
+ }
227
+ function sliceBalanced(source, openIdx, open, close) {
228
+ if (source[openIdx] !== open)
229
+ return null;
230
+ let depth = 0, i = openIdx, inString = null;
231
+ while (i < source.length) {
232
+ const ch = source[i];
233
+ if (ch === void 0)
234
+ break;
235
+ if (inString) {
236
+ if (ch === "\\") {
237
+ i += 2;
238
+ continue;
239
+ }
240
+ if (ch === inString)
241
+ inString = null;
242
+ i++;
243
+ continue;
244
+ }
245
+ if (ch === '"' || ch === "'" || ch === "`") {
246
+ inString = ch;
247
+ i++;
248
+ continue;
249
+ }
250
+ if (ch === open)
251
+ depth++;
252
+ else if (ch === close) {
253
+ depth--;
254
+ if (depth === 0)
255
+ return source.slice(openIdx + 1, i);
256
+ }
257
+ i++;
258
+ }
259
+ return null;
260
+ }
261
+ function splitTopLevel(source, separators) {
262
+ const out = [], sepSet = new Set(separators);
263
+ let depth = 0, inString = null, start = 0;
264
+ for (let i = 0;i < source.length; i++) {
265
+ const ch = source[i];
266
+ if (ch === void 0)
267
+ break;
268
+ if (inString) {
269
+ if (ch === "\\") {
270
+ i++;
271
+ continue;
272
+ }
273
+ if (ch === inString)
274
+ inString = null;
275
+ continue;
276
+ }
277
+ if (ch === '"' || ch === "'" || ch === "`") {
278
+ inString = ch;
279
+ continue;
280
+ }
281
+ if (ch === "{" || ch === "[" || ch === "(" || ch === "<")
282
+ depth++;
283
+ else if (ch === "}" || ch === "]" || ch === ")" || ch === ">")
284
+ depth--;
285
+ else if (depth === 0 && sepSet.has(ch)) {
286
+ out.push(source.slice(start, i));
287
+ start = i + 1;
288
+ }
289
+ }
290
+ out.push(source.slice(start));
291
+ return out;
292
+ }
293
+ function collapseWhitespace(s) {
294
+ return s.replace(/\s+/g, " ").trim();
295
+ }
@@ -0,0 +1,4 @@
1
+ // export * from './component-meta'
2
+ // export * from './lib-entries'
3
+ // export * from './package-json'
4
+ export * from './utils';
@@ -0,0 +1 @@
1
+ export * from "./utils";
@@ -0,0 +1,12 @@
1
+ import type { LibraryType } from '@stacksjs/path';
2
+ /**
3
+ * Based on the config values, this method
4
+ * will generate the library entry points.
5
+ *
6
+ * @param type LibraryType
7
+ */
8
+ export declare function generateLibEntry(type: LibraryType): Promise<void>;
9
+ export declare function createLibraryEntryPoint(type: LibraryType): Promise<void>;
10
+ export declare function createWebComponentLibraryEntryPoint(type?: LibraryType): Promise<void>;
11
+ export declare function createFunctionLibraryEntryPoint(type?: LibraryType): Promise<void>;
12
+ export declare function generateEntryPointData(type: LibraryType): string;
@@ -0,0 +1,73 @@
1
+ import process from "node:process";
2
+ import { log } from "@stacksjs/logging";
3
+ import { componentsPath, functionsPath, libraryEntryPath } from "@stacksjs/path";
4
+ import { writeTextFile } from "@stacksjs/storage";
5
+ import { kebabCase } from "@stacksjs/strings";
6
+ import { ExitCode } from "@stacksjs/types";
7
+ import { determineResetPreset } from "@stacksjs/utils";
8
+ import library from "~/config/library";
9
+ export async function generateLibEntry(type) {
10
+ await createLibraryEntryPoint(type);
11
+ }
12
+ export async function createLibraryEntryPoint(type) {
13
+ if (type === "web-components")
14
+ await createWebComponentLibraryEntryPoint();
15
+ if (type === "functions")
16
+ await createFunctionLibraryEntryPoint();
17
+ }
18
+ export async function createWebComponentLibraryEntryPoint(type = "web-components") {
19
+ log.info("Ensuring Web Component Library Entry Point...");
20
+ await writeTextFile({
21
+ path: libraryEntryPath(type),
22
+ data: generateEntryPointData(type)
23
+ }).catch((err) => {
24
+ log.error("There was an error generating the Web Component library entry point", err);
25
+ process.exit(ExitCode.FatalError);
26
+ });
27
+ log.success("Created Web Component Library Entry Point");
28
+ }
29
+ export async function createFunctionLibraryEntryPoint(type = "functions") {
30
+ log.info("Ensuring Function Library Entry Point...");
31
+ await writeTextFile({
32
+ path: libraryEntryPath(type),
33
+ data: generateEntryPointData(type)
34
+ }).catch((err) => {
35
+ log.error("There was an error generating Function Library Entry Point", err);
36
+ process.exit(ExitCode.FatalError);
37
+ });
38
+ log.success("Created Functions Library Entry Point");
39
+ }
40
+ export function generateEntryPointData(type) {
41
+ let arr = [];
42
+ if (type === "functions") {
43
+ if (!library.functions?.files) {
44
+ log.error(Error("There are no functions defined to be built. Please check your config/library.ts file for potential adjustments"));
45
+ process.exit(ExitCode.FatalError);
46
+ }
47
+ for (const fx of library.functions.files)
48
+ if (Array.isArray(fx))
49
+ arr.push(`export * as ${fx[1]} from '${functionsPath(fx[0])}'`);
50
+ else
51
+ arr.push(`export * from '${functionsPath(fx)}'`);
52
+ return arr.join(`\r
53
+ `);
54
+ }
55
+ arr = determineResetPreset();
56
+ const imports = [...arr, "import { defineCustomElement } from 'vue'"], declarations = [], definitions = [];
57
+ if (!library.webComponents?.tags) {
58
+ log.error(Error("There are no components defined to be built. Please check your config/library.ts file for potential adjustments"));
59
+ process.exit(ExitCode.FatalError);
60
+ }
61
+ for (const component of library.webComponents.tags.map((tag) => tag.name))
62
+ if (Array.isArray(component)) {
63
+ imports.push(`import ${component[1]} from '${componentsPath(component[0])}.vue'`);
64
+ declarations.push(`const ${component[1]}CustomElement = defineCustomElement(${component[1]})`);
65
+ definitions.push(`customElements.define('${kebabCase(component[1])}', ${component[1]}CustomElement)`);
66
+ } else {
67
+ imports.push(`import ${component} from '${componentsPath(component)}.vue'`);
68
+ declarations.push(`const ${component}CustomElement = defineCustomElement(${component})`);
69
+ definitions.push(`customElements.define('${kebabCase(component)}', ${component}CustomElement)`);
70
+ }
71
+ return [...imports, ...declarations, ...definitions].join(`\r
72
+ `);
73
+ }