@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,2 @@
1
+ export declare function generatePackageJson(type: PackageJsonType): Promise<void>;
2
+ declare type PackageJsonType = 'web-components' | 'functions';
@@ -0,0 +1,74 @@
1
+ import { log } from "@stacksjs/logging";
2
+ import { packageJsonPath } from "@stacksjs/path";
3
+ import { writeTextFile } from "@stacksjs/storage";
4
+ import library from "~/config/library";
5
+ export async function generatePackageJson(type) {
6
+ let name, description, directory, keywords, config, prettyName;
7
+ if (type === "web-components") {
8
+ name = library.webComponents?.name;
9
+ description = library.webComponents?.description;
10
+ directory = "components";
11
+ keywords = library.webComponents?.keywords;
12
+ config = "web-components";
13
+ } else if (type === "functions") {
14
+ name = library.functions?.name;
15
+ description = library.functions?.description;
16
+ directory = "functions";
17
+ keywords = library.functions?.keywords;
18
+ config = "functions";
19
+ }
20
+ try {
21
+ await writeTextFile({
22
+ path: packageJsonPath(type),
23
+ data: `{
24
+ "name": "${name}",
25
+ "type": "module",
26
+ "version": "",
27
+ "packageManager": "bun",
28
+ "description": "${description}",
29
+ "author": "${library.author}",
30
+ "license": "MIT",
31
+ "homepage": "https://github.com/${library.repository}/tree/main/${directory}#readme",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/${library.repository}.git",
35
+ "directory": "${directory}"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/${library.repository}/issues"
39
+ },
40
+ "keywords": ${JSON.stringify(keywords)},
41
+ "contributors": ${JSON.stringify(library.contributors)},
42
+ "exports": {
43
+ ".": {
44
+ "types": "./dist/index.d.js",
45
+ "require": "./dist/index.cjs",
46
+ "import": "./dist/index.js"
47
+ }
48
+ },
49
+ "main": "dist/index.cjs",
50
+ "module": "dist/index.js",
51
+ "types": "dist/index.d.ts",
52
+ "files": [
53
+ "dist",
54
+ "README.md"
55
+ ],
56
+ "scripts": {
57
+ "build": "vite build -c ../build/${config}.ts",
58
+ "prepublishOnly": "bun run build"
59
+ },
60
+ "devDependencies": {
61
+ "stacks": "workspace:*"
62
+ }
63
+ }
64
+ `
65
+ });
66
+ if (type === "web-components")
67
+ prettyName = "Web Component library";
68
+ else if (type === "functions")
69
+ prettyName = "Function Library";
70
+ log.success(`Created ${prettyName} package.json file`);
71
+ } catch (err) {
72
+ log.error(`There was an error creating the ${prettyName} package.json`, err);
73
+ }
74
+ }
@@ -0,0 +1,23 @@
1
+ import type { ActionOptions, CommandError, Subprocess } from '@stacksjs/types';
2
+ import type { Result } from '@stacksjs/error-handling';
3
+ /**
4
+ * Run an Action the Stacks way.
5
+ *
6
+ * @param action The action to invoke.
7
+ * @param options The options to pass to the command.
8
+ * @returns The result of the command.
9
+ */
10
+ export declare function runAction(action: Action, options?: ActionOptions): Promise<Result<Subprocess, CommandError>>;
11
+ /**
12
+ * Run Actions the Stacks way.
13
+ *
14
+ * @param actions The actions to invoke.
15
+ * @param options The options to pass to the command.
16
+ * @returns The result of the command.
17
+ */
18
+ export declare function runActions(actions: Action[], options?: ActionOptions): Promise<any>;
19
+ // looks in most common locations
20
+ export declare function hasAction(action: Action): boolean;
21
+ declare type ActionPath = string // TODO: narrow this by automating its generation
22
+ type ActionName = string // TODO: narrow this by automating its generation
23
+ type Action = ActionPath | ActionName | string;
@@ -0,0 +1,105 @@
1
+ var {require}=import.meta;import { existsSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import process from "node:process";
5
+ import { buddyOptions, runCommand, runCommands } from "@stacksjs/cli";
6
+ import { err } from "@stacksjs/error-handling";
7
+ import { log } from "@stacksjs/logging";
8
+ import * as p from "@stacksjs/path";
9
+ async function resolveActionFile(action) {
10
+ const candidates = [];
11
+ candidates.push(p.actionsPath(`src/${action}.ts`));
12
+ try {
13
+ const pkgUrl = import.meta.resolve("@stacksjs/actions/package.json");
14
+ if (pkgUrl) {
15
+ const pkgPath = new URL(pkgUrl).pathname, pkgRoot = pkgPath.slice(0, pkgPath.lastIndexOf("/"));
16
+ candidates.push(`${pkgRoot}/dist/${action}.js`);
17
+ candidates.push(`${pkgRoot}/dist/src/${action}.js`);
18
+ candidates.push(`${pkgRoot}/src/${action}.ts`);
19
+ }
20
+ } catch {}
21
+ for (const candidate of candidates)
22
+ if (await Bun.file(candidate).exists())
23
+ return candidate;
24
+ return null;
25
+ }
26
+ export async function runAction(action, options) {
27
+ log.debug(`[action] Running: ${action}`);
28
+ if (action === "dev/views")
29
+ try {
30
+ const pantryPath = p.projectPath("pantry");
31
+ if (!process.env.NODE_PATH?.includes(pantryPath)) {
32
+ process.env.NODE_PATH = process.env.NODE_PATH ? `${pantryPath}:${process.env.NODE_PATH}` : pantryPath;
33
+ require("module").Module._initPaths?.();
34
+ }
35
+ const viewsEntries = [
36
+ p.projectPath("storage/framework/core/actions/src/dev/views.ts"),
37
+ p.frameworkPath("actions/src/dev/views.ts")
38
+ ];
39
+ for (const entry of viewsEntries)
40
+ if (existsSync(entry)) {
41
+ await import(entry);
42
+ return { ok: !0, value: {} };
43
+ }
44
+ return err("dev/views entry not found");
45
+ } catch (error) {
46
+ return err(`Failed to start dev server: ${error}`);
47
+ }
48
+ if (!(action.includes("/") || ["dev", "build", "install", "upgrade", "migrate"].some((prefix) => action.startsWith(prefix)))) {
49
+ const glob = new Bun.Glob("**/*.{ts,js}"), scanOptions = { cwd: p.userActionsPath(), onlyFiles: !0, absolute: !0 }, matchingFiles = [], basePath = p.userActionsPath();
50
+ for await (const file of glob.scan(scanOptions)) {
51
+ if (file.replace(`${basePath}/`, "").replace(/\.(ts|js)$/, "") === action || file.endsWith(`${action}.ts`) || file.endsWith(`${action}.js`)) {
52
+ log.debug(`[action] Resolved: ${action} \u2192 ${file}`);
53
+ return await (await import(file)).default.handle(void 0);
54
+ }
55
+ matchingFiles.push(file);
56
+ }
57
+ for (const file of matchingFiles)
58
+ try {
59
+ const a = await import(file);
60
+ if (a.name === action) {
61
+ log.debug(`[action] Resolved: ${action} \u2192 ${file}`);
62
+ return await a.handle();
63
+ }
64
+ } catch (error) {}
65
+ }
66
+ const path = await resolveActionFile(action);
67
+ if (!path)
68
+ return err(`Action '${action}' not found in storage/framework/core/actions/src or @stacksjs/actions`);
69
+ log.debug(`[action] Resolved: ${action} \u2192 ${path}`);
70
+ const isDevAction = action.startsWith("dev/"), watchFlag = isDevAction ? "--watch" : "", opts = isDevAction ? "" : buddyOptions(options) || "", cmd = `bun ${watchFlag} ${path} ${opts}`.trimEnd(), pantryNodePath = p.projectPath("pantry"), existingNodePath = process.env.NODE_PATH, nodePath = existingNodePath ? `${pantryNodePath}:${existingNodePath}` : pantryNodePath, shouldInherit = options?.verbose || isDevAction && !options?.quiet, optionsWithCwd = {
71
+ cwd: options?.cwd || p.projectPath(),
72
+ ...options,
73
+ stdout: shouldInherit ? "inherit" : void 0,
74
+ stderr: shouldInherit ? "inherit" : void 0,
75
+ env: { ...options?.env, NODE_PATH: nodePath, ...isDevAction ? { STACKS_DEV_SERVER: "1" } : {} }
76
+ }, result = await runCommand(cmd, optionsWithCwd);
77
+ log.debug(`[action] Completed: ${action}`);
78
+ return result;
79
+ }
80
+ export async function runActions(actions, options) {
81
+ if (!actions.length)
82
+ return err("No actions were specified");
83
+ for (const action of actions)
84
+ if (!hasAction(action))
85
+ return err(`The specified action "${action}" does not exist`);
86
+ const opts = buddyOptions(options) || "", o = {
87
+ cwd: options?.cwd || p.projectPath(),
88
+ ...options
89
+ }, commands = actions.map((action) => `bun ${p.relativeActionsPath(`src/${action}.ts`)} ${opts}`);
90
+ return await runCommands(commands, o);
91
+ }
92
+ export function hasAction(action) {
93
+ const userActionPatterns = [
94
+ `${action}.ts`,
95
+ `${action}`,
96
+ `Dashboard/${action}.ts`,
97
+ `Dashboard/${action}`,
98
+ `Buddy/${action}.ts`,
99
+ `Buddy/${action}`
100
+ ], actionPatterns = [`src/${action}.ts`, `src/${action}`, `${action}.ts`, `${action}`];
101
+ return [
102
+ ...userActionPatterns.map((pattern) => p.userActionsPath(pattern)),
103
+ ...actionPatterns.map((pattern) => p.actionsPath(pattern))
104
+ ].some((candidate) => existsSync(candidate));
105
+ }
@@ -0,0 +1,3 @@
1
+ import type { Result } from '@stacksjs/error-handling';
2
+ export declare function generateVsCodeCustomData(): Promise<Result<void, string>>;
3
+ export declare function generateWebTypes(): Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { err, ok } from "@stacksjs/error-handling";
2
+ import { log } from "@stacksjs/logging";
3
+ import { customElementsDataPath } from "@stacksjs/path";
4
+ import { writeTextFile } from "@stacksjs/storage";
5
+ import library from "~/config/library";
6
+ function generateComponentInfoData() {
7
+ return `{
8
+ "version": 1.1,
9
+ "tags": ${JSON.stringify(library.webComponents?.tags)}
10
+ }
11
+ `;
12
+ }
13
+ export async function generateVsCodeCustomData() {
14
+ try {
15
+ log.info("Generating custom-elements.json...");
16
+ await writeTextFile({
17
+ path: customElementsDataPath(),
18
+ data: generateComponentInfoData()
19
+ });
20
+ log.success("Generated custom-elements.json for IDEs.");
21
+ return ok(void 0);
22
+ } catch (e) {
23
+ log.error("There was an error generating the custom-elements.json file.", e);
24
+ return err("There was an error generating the custom-elements.json file.");
25
+ }
26
+ }
27
+ export async function generateWebTypes() {
28
+ log.info("Generating web-types.json...");
29
+ log.info("This feature is not yet implemented.");
30
+ }
@@ -0,0 +1,62 @@
1
+ export type { CrudField } from './scaffold-crud';
2
+ export type { DiscoveredPackagesManifest, PackageStacksMeta } from './discover-packages';
3
+ export * from './action';
4
+ export { add as runAdd } from './add';
5
+ // The write side of the markdown blog (content/blog/*.md), used by the
6
+ // dashboard's blog actions. The read/render side lives in ./blog and stays out
7
+ // of this barrel because it lazy-loads BunPress.
8
+ export {
9
+ type BlogPost,
10
+ BlogAdminError,
11
+ type BlogPostInput,
12
+ deleteBlogPost,
13
+ getBlogPost,
14
+ listBlogPosts,
15
+ saveBlogPost,
16
+ slugify as blogSlugify,
17
+ } from './blog-admin';
18
+ export { commit as runCommit } from './commit';
19
+ export * from './dev/index';
20
+ export * from './generate/index';
21
+ export * from './helpers/index';
22
+ // Code-style actions, exported so commands import + call them directly
23
+ // (`import { lintProject, lintFix } from '@stacksjs/actions'`) instead of
24
+ // spawning a deep dist path. Exported from ./lint/lint — the pure module — so
25
+ // importing the barrel never pulls the process-exiting ./lint/index script.
26
+ export { formatProject, lintFix, lintProject } from './lint/lint';
27
+ export * from './setup/index';
28
+ // makeFactory,
29
+ export {
30
+ createComponent,
31
+ createDatabase,
32
+ createFactory,
33
+ createFunction,
34
+ createLanguage,
35
+ createMiddleware,
36
+ createMigration,
37
+ createModel,
38
+ createMail,
39
+ createNotification,
40
+ createPage,
41
+ isDryRunActive,
42
+ makeAction,
43
+ makeCertificate,
44
+ makeComponent,
45
+ makeDatabase,
46
+ makeFunction,
47
+ makeLanguage,
48
+ makeMail,
49
+ makeNotification,
50
+ makePage,
51
+ makeQueueTable,
52
+ makeStack,
53
+ make as runMake,
54
+ setDryRun,
55
+ } from './make';
56
+ export { discoverPackages } from './discover-packages';
57
+ export { parseFields, scaffoldCrud } from './scaffold-crud';
58
+ export { installStack, uninstallStack, listStacks } from './stacks';
59
+ export { makeJob } from './make-job';
60
+ export { makeCommand } from './make-command';
61
+ export { makePolicy } from './make-policy';
62
+ export { makeResource } from './make-resource';
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ export * from "./action";
2
+ export { add as runAdd } from "./add";
3
+ export {
4
+ BlogAdminError,
5
+ deleteBlogPost,
6
+ getBlogPost,
7
+ listBlogPosts,
8
+ saveBlogPost,
9
+ slugify as blogSlugify
10
+ } from "./blog-admin";
11
+ export { commit as runCommit } from "./commit";
12
+ export * from "./dev";
13
+ export * from "./generate";
14
+ export * from "./helpers";
15
+ export { formatProject, lintFix, lintProject } from "./lint/lint";
16
+ export * from "./setup";
17
+ export {
18
+ createComponent,
19
+ createDatabase,
20
+ createFactory,
21
+ createFunction,
22
+ createLanguage,
23
+ createMiddleware,
24
+ createMigration,
25
+ createModel,
26
+ createMail,
27
+ createNotification,
28
+ createPage,
29
+ isDryRunActive,
30
+ makeAction,
31
+ makeCertificate,
32
+ makeComponent,
33
+ makeDatabase,
34
+ makeFunction,
35
+ makeLanguage,
36
+ makeMail,
37
+ makeNotification,
38
+ makePage,
39
+ makeQueueTable,
40
+ makeStack,
41
+ make as runMake,
42
+ setDryRun
43
+ } from "./make";
44
+ export { discoverPackages } from "./discover-packages";
45
+ export { parseFields, scaffoldCrud } from "./scaffold-crud";
46
+ export { installStack, uninstallStack, listStacks } from "./stacks";
47
+ export { makeJob } from "./make-job";
48
+ export { makeCommand } from "./make-command";
49
+ export { makePolicy } from "./make-policy";
50
+ export { makeResource } from "./make-resource";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { runCommand } from "@stacksjs/cli";
3
+ import { generateKeypair } from "@stacksjs/env";
4
+ import { projectPath } from "@stacksjs/path";
5
+ import { generateAppKey } from "@stacksjs/security";
6
+ import { existsSync } from "@stacksjs/storage";
7
+ import { setEnvValue } from "@stacksjs/utils";
8
+ if (!existsSync(".env"))
9
+ await runCommand("cp .env.example .env", { cwd: projectPath() });
10
+ await setEnvValue("APP_KEY", generateAppKey());
11
+ const envText = (() => {
12
+ try {
13
+ return readFileSync(projectPath(".env"), "utf-8");
14
+ } catch {
15
+ return "";
16
+ }
17
+ })(), hasPublic = /^DOTENV_PUBLIC_KEY=.+$/m.test(envText), hasPrivate = /^DOTENV_PRIVATE_KEY=.+$/m.test(envText);
18
+ if (!hasPublic || !hasPrivate) {
19
+ const { publicKey, privateKey } = generateKeypair();
20
+ if (!hasPublic)
21
+ await setEnvValue("DOTENV_PUBLIC_KEY", publicKey);
22
+ if (!hasPrivate)
23
+ await setEnvValue("DOTENV_PRIVATE_KEY", privateKey);
24
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import process from "node:process";
2
+ import { lintFix } from "./lint";
3
+ const { ok } = await lintFix();
4
+ process.exit(ok ? 0 : 1);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import process from "node:process";
2
+ import { lintProject } from "./lint";
3
+ const { ok } = await lintProject();
4
+ process.exit(ok ? 0 : 1);
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Lint (optionally auto-fix) the project's tracked source via pickier's SDK.
3
+ * Returns `{ ok }` rather than exiting, so callers keep control of the process.
4
+ * pickier auto-discovers its own config (pickier.config.ts, .config/pickier.ts,
5
+ * …), so we don't pass one.
6
+ */
7
+ export declare function lintProject(options?: { cwd?: string, fix?: boolean }): Promise<{ ok: boolean }>;
8
+ /** Auto-fix the project's code style — `lintProject` with fixing enabled. */
9
+ export declare function lintFix(options?: { cwd?: string }): Promise<{ ok: boolean }>;
10
+ /**
11
+ * Format the project via pickier's SDK. `write` applies changes; `check`
12
+ * verifies formatting without writing (fails if anything is unformatted).
13
+ */
14
+ export declare function formatProject(options?: { cwd?: string, write?: boolean, check?: boolean }): Promise<{ ok: boolean }>;
@@ -0,0 +1,34 @@
1
+ import process from "node:process";
2
+ import { log } from "@stacksjs/cli";
3
+ import { execSync } from "node:child_process";
4
+ import { runFormat, runLint } from "pickier";
5
+ const lintableFile = /\.(?:ts|js|json|md|yaml|yml)$/i, ignoredPath = /(?:^|\/)(?:node_modules|dist|pantry|storage\/framework\/cache|\.git|\.stx|\.stx-serve)(?:\/|$)/;
6
+ function trackedFiles(cwd) {
7
+ try {
8
+ return execSync("git ls-files -z", { cwd, encoding: "utf8" }).split("\x00").filter((file) => lintableFile.test(file) && !ignoredPath.test(file));
9
+ } catch {
10
+ return [];
11
+ }
12
+ }
13
+ export async function lintProject(options = {}) {
14
+ const cwd = options.cwd ?? process.cwd();
15
+ log.info(options.fix ? "Ensuring Code Style..." : "Checking Code Style...");
16
+ const files = trackedFiles(cwd);
17
+ if (!files.length) {
18
+ log.success("Linted");
19
+ return { ok: !0 };
20
+ }
21
+ const ok = await runLint(files, { maxWarnings: 9999, fix: options.fix }) === 0;
22
+ if (ok)
23
+ log.success("Linted");
24
+ return { ok };
25
+ }
26
+ export function lintFix(options = {}) {
27
+ return lintProject({ ...options, fix: !0 });
28
+ }
29
+ export async function formatProject(options = {}) {
30
+ const cwd = options.cwd ?? process.cwd(), files = trackedFiles(cwd);
31
+ if (!files.length)
32
+ return { ok: !0 };
33
+ return { ok: await runFormat(files, { write: options.write, check: options.check }) === 0 };
34
+ }
@@ -0,0 +1,10 @@
1
+ import type { MakeOptions } from '@stacksjs/types';
2
+ /**
3
+ * Create a new command file in app/Commands
4
+ */
5
+ export declare function makeCommand(options: MakeCommandOptions): Promise<boolean>;
6
+ export declare interface MakeCommandOptions extends MakeOptions {
7
+ register?: boolean
8
+ description?: string
9
+ signature?: string
10
+ }
@@ -0,0 +1,95 @@
1
+ import { log } from "@stacksjs/logging";
2
+ import * as p from "@stacksjs/path";
3
+ import { get, writeFile } from "@stacksjs/storage";
4
+ export async function makeCommand(options) {
5
+ const name = options.name;
6
+ if (!name) {
7
+ log.error("Command name is required");
8
+ return !1;
9
+ }
10
+ const commandName = toPascalCase(name), content = generateCommandContent(commandName, options), filePath = p.commandsPath(`${commandName}.ts`);
11
+ try {
12
+ await writeFile(filePath, content);
13
+ log.success(`Created command: ${filePath}`);
14
+ if (options.register !== !1)
15
+ await registerCommand(commandName, options.signature || toKebabCase(name));
16
+ return !0;
17
+ } catch (error) {
18
+ log.error(`Failed to create command: ${error.message}`);
19
+ return !1;
20
+ }
21
+ }
22
+ function generateCommandContent(name, options) {
23
+ const signature = options.signature || toKebabCase(name), description = options.description || `The ${signature} command`;
24
+ return `import type { CLI } from '@stacksjs/types'
25
+ import { log } from '@stacksjs/cli'
26
+
27
+ /**
28
+ * ${name} Command
29
+ *
30
+ * ${description}
31
+ */
32
+
33
+ interface ${name}Options {
34
+ verbose: boolean
35
+ // Add your command options here
36
+ }
37
+
38
+ export default function (cli: CLI) {
39
+ cli
40
+ .command('${signature}', '${description}')
41
+ .option('--verbose', 'Enable verbose output', { default: false })
42
+ // Add more options here
43
+ // .option('-n, --name <name>', 'Your name')
44
+ .action(async (options: ${name}Options) => {
45
+ try {
46
+ if (options.verbose) {
47
+ log.info('Running ${signature} command...')
48
+ }
49
+
50
+ log.info('No command logic implemented yet. Update this command action to add behavior.')
51
+
52
+ log.success('${signature} completed successfully!')
53
+ }
54
+ catch (error) {
55
+ log.error('${signature} failed:', error)
56
+ throw error
57
+ }
58
+ })
59
+
60
+ // Handle unknown subcommands
61
+ cli.on('${signature}:*', () => {
62
+ log.error('Invalid command: %s\\nSee --help for a list of available commands.', cli.args.join(' '))
63
+ })
64
+ }
65
+ `;
66
+ }
67
+ async function registerCommand(name, signature) {
68
+ const commandsPath = p.appPath("Commands.ts");
69
+ try {
70
+ let content = await get(commandsPath);
71
+ const exportMatch = content.match(/export default \{([\s\S]*)\} satisfies/);
72
+ if (exportMatch) {
73
+ const existingCommands = exportMatch[1] ?? "";
74
+ if (existingCommands.includes(`'${signature}'`)) {
75
+ log.info(`Command '${signature}' already registered in Commands.ts`);
76
+ return;
77
+ }
78
+ const newCommand = ` '${signature}': '${name}',
79
+ `, updatedCommands = `${existingCommands.trimEnd()}
80
+ ${newCommand}`;
81
+ content = content.replace(/export default \{[\s\S]*\} satisfies/, `export default {${updatedCommands}} satisfies`);
82
+ await writeFile(commandsPath, content);
83
+ log.success(`Registered command '${signature}' in Commands.ts`);
84
+ }
85
+ } catch (error) {
86
+ log.warn(`Could not register command in Commands.ts: ${error.message}`);
87
+ log.info("You may need to manually add it to app/Commands.ts");
88
+ }
89
+ }
90
+ function toPascalCase(str) {
91
+ return str.replace(/[-_](.)/g, (_, char) => char.toUpperCase()).replace(/^(.)/, (_, char) => char.toUpperCase());
92
+ }
93
+ function toKebabCase(str) {
94
+ return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]+/g, "-").toLowerCase();
95
+ }
@@ -0,0 +1,5 @@
1
+ import type { MakeOptions } from '@stacksjs/types';
2
+ /**
3
+ * Create a new job file in app/Jobs
4
+ */
5
+ export declare function makeJob(options: MakeOptions): Promise<boolean>;