@stacksjs/actions 0.70.87 → 0.70.90

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 (159) hide show
  1. package/dist/action.js +78 -2
  2. package/dist/actions.js +2 -2
  3. package/dist/add.js +20 -2
  4. package/dist/ai/request-model-access.js +10 -2
  5. package/dist/auth/client.js +44 -3
  6. package/dist/auth/prune.js +35 -2
  7. package/dist/auth/setup.js +152 -36
  8. package/dist/auth/token.js +10 -2
  9. package/dist/blog-admin.d.ts +55 -0
  10. package/dist/blog-admin.js +156 -0
  11. package/dist/blog.d.ts +11 -0
  12. package/dist/blog.js +306 -56
  13. package/dist/build/cli.js +6 -2
  14. package/dist/build/component-libs.js +7 -2
  15. package/dist/build/core.js +55 -2
  16. package/dist/build/desktop.js +5 -2
  17. package/dist/build/docs.js +5 -2
  18. package/dist/build/frontend-static.js +123 -8
  19. package/dist/build/server.js +6 -2
  20. package/dist/build/stacks.js +8 -2
  21. package/dist/build/views.js +11 -2
  22. package/dist/build.js +64 -2
  23. package/dist/bump.js +162 -7
  24. package/dist/cdn/invalidate-cache.js +0 -1
  25. package/dist/changelog.js +27 -3
  26. package/dist/check/ports.js +16 -2
  27. package/dist/clean.js +4 -2
  28. package/dist/commit.js +12 -2
  29. package/dist/copy-types.js +10 -3
  30. package/dist/database/seed.js +26 -2
  31. package/dist/deploy/create-receipt-rule.js +36 -2
  32. package/dist/deploy/index.js +1318 -44
  33. package/dist/dev/api.js +94 -6
  34. package/dist/dev/components.js +7 -2
  35. package/dist/dev/dashboard-globals.js +89 -3
  36. package/dist/dev/dashboard-utils.js +380 -2
  37. package/dist/dev/dashboard.js +435 -8
  38. package/dist/dev/desktop.js +5 -2
  39. package/dist/dev/docs.js +24 -2
  40. package/dist/dev/index.js +29 -2
  41. package/dist/dev/migrate-watcher.js +74 -2
  42. package/dist/dev/system-tray.js +5 -2
  43. package/dist/dev/views.js +147 -2
  44. package/dist/discover-packages.js +32 -2
  45. package/dist/domains/add.js +61 -2
  46. package/dist/domains/purchase.js +66 -2
  47. package/dist/domains/remove.js +24 -2
  48. package/dist/examples.js +34 -2
  49. package/dist/find-projects.js +16 -2
  50. package/dist/fresh.js +17 -2
  51. package/dist/generate/action-types.js +9 -4
  52. package/dist/generate/component-meta.js +9 -3
  53. package/dist/generate/custom-cli-file.js +20 -3
  54. package/dist/generate/env-files.js +46 -6
  55. package/dist/generate/ide-helpers.js +8 -3
  56. package/dist/generate/index.js +158 -2
  57. package/dist/generate/lib-entries.js +16 -3
  58. package/dist/generate/pantry-file.js +46 -2
  59. package/dist/generate/symlink-core.js +2 -2
  60. package/dist/generate/types.js +3 -2
  61. package/dist/generate/vscode-custom-data.js +9 -3
  62. package/dist/generate/web-types.js +0 -1
  63. package/dist/helpers/component-meta.js +295 -2
  64. package/dist/helpers/index.js +1 -2
  65. package/dist/helpers/lib-entries.js +73 -2
  66. package/dist/helpers/package-json.js +45 -14
  67. package/dist/helpers/utils.js +105 -2
  68. package/dist/helpers/vscode-custom-data.js +30 -2
  69. package/dist/index.d.ts +13 -0
  70. package/dist/index.js +50 -2
  71. package/dist/key-generate.js +24 -2
  72. package/dist/lint/fix.js +4 -3
  73. package/dist/lint/index.js +4 -3
  74. package/dist/lint/lint.js +34 -2
  75. package/dist/make-command.js +64 -14
  76. package/dist/make-job.js +41 -16
  77. package/dist/make-policy.js +74 -26
  78. package/dist/make-resource.js +50 -21
  79. package/dist/make.js +328 -2
  80. package/dist/migrate/database.js +16 -2
  81. package/dist/migrate/fresh.js +31 -2
  82. package/dist/orm/base.js +0 -2
  83. package/dist/orm/test.js +0 -1
  84. package/dist/prepublish.js +16 -2
  85. package/dist/queue/clear.js +42 -2
  86. package/dist/queue/dlq-purge.js +28 -2
  87. package/dist/queue/dlq-retry.js +35 -2
  88. package/dist/queue/dlq.js +55 -5
  89. package/dist/queue/failed.js +69 -5
  90. package/dist/queue/flush.js +49 -3
  91. package/dist/queue/inspect.js +154 -8
  92. package/dist/queue/list.js +69 -5
  93. package/dist/queue/monitor.js +94 -6
  94. package/dist/queue/pause.js +28 -2
  95. package/dist/queue/quarantine.js +42 -3
  96. package/dist/queue/resume.js +27 -2
  97. package/dist/queue/retry.js +41 -2
  98. package/dist/queue/schedule-list.js +33 -5
  99. package/dist/queue/schedule.js +12 -2
  100. package/dist/queue/status.js +68 -5
  101. package/dist/queue/table.js +10 -2
  102. package/dist/queue/unquarantine.js +27 -2
  103. package/dist/queue/work.js +57 -2
  104. package/dist/release.js +21 -3
  105. package/dist/route/list.js +78 -3
  106. package/dist/run-action.js +1 -2
  107. package/dist/saas/setup.js +9 -2
  108. package/dist/scaffold-crud.js +164 -40
  109. package/dist/schedule/run.js +7 -2
  110. package/dist/search/flush.js +10 -2
  111. package/dist/search/import.js +10 -2
  112. package/dist/search/settings-list.js +10 -2
  113. package/dist/search/settings.js +9 -2
  114. package/dist/serve/api.js +35 -2
  115. package/dist/setup/index.js +1 -2
  116. package/dist/setup/ssl.js +271 -2
  117. package/dist/stacks.js +265 -2
  118. package/dist/templates.js +301 -2
  119. package/dist/test/feature.js +11 -2
  120. package/dist/test/index.js +11 -2
  121. package/dist/test/ui.js +4 -2
  122. package/dist/test/unit.js +11 -2
  123. package/dist/typecheck.js +4 -2
  124. package/dist/types.js +16 -2
  125. package/dist/upgrade/binary.js +29 -2
  126. package/dist/upgrade/bun.js +0 -1
  127. package/dist/upgrade/dependencies.js +0 -2
  128. package/dist/upgrade/framework-utils.js +193 -2
  129. package/dist/upgrade/framework.js +310 -7
  130. package/dist/upgrade/index.js +17 -2
  131. package/dist/upgrade/packages.js +99 -12
  132. package/dist/upgrade/shell.js +40 -4
  133. package/dist/upgrade.js +38 -2
  134. package/package.json +16 -16
  135. package/dist/chunk-0c8sd1t6.js +0 -2
  136. package/dist/chunk-0g2nzhx9.js +0 -240
  137. package/dist/chunk-0gadhvn7.js +0 -3
  138. package/dist/chunk-0h27aa4r.js +0 -93
  139. package/dist/chunk-3peh8kqs.js +0 -851
  140. package/dist/chunk-62gdfav8.js +0 -3
  141. package/dist/chunk-6bk53y02.js +0 -3
  142. package/dist/chunk-78c5n3s2.js +0 -3
  143. package/dist/chunk-c74qv38e.js +0 -17
  144. package/dist/chunk-cdk2r2jd.js +0 -1
  145. package/dist/chunk-dbz9dp2h.js +0 -3
  146. package/dist/chunk-e142dheq.js +0 -3
  147. package/dist/chunk-ec4gky40.js +0 -3
  148. package/dist/chunk-h3d81wrg.js +0 -3
  149. package/dist/chunk-m3q0x4h0.js +0 -688
  150. package/dist/chunk-mqgbyhph.js +0 -5
  151. package/dist/chunk-n24m8prb.js +0 -3
  152. package/dist/chunk-n5eqwhck.js +0 -7
  153. package/dist/chunk-nsvnqv8y.js +0 -5
  154. package/dist/chunk-nty6mmx4.js +0 -283
  155. package/dist/chunk-s735m9mg.js +0 -1
  156. package/dist/chunk-tpb8jgsk.js +0 -7
  157. package/dist/chunk-tsbk5vne.js +0 -3
  158. package/dist/chunk-xg9xscqz.js +0 -1
  159. package/dist/chunk-y6e448he.js +0 -7
@@ -1,26 +1,47 @@
1
- // @bun
2
- import{Gb as q}from"../chunk-tsbk5vne.js";import"../chunk-h3d81wrg.js";import{log as G}from"@stacksjs/logging";import{packageJsonPath as I}from"@stacksjs/path";import{writeTextFile as K}from"@stacksjs/storage";async function R(v){let B,C,z,D,E,A;if(v==="web-components")B=q.webComponents?.name,C=q.webComponents?.description,z="components",D=q.webComponents?.keywords,E="web-components";else if(v==="functions")B=q.functions?.name,C=q.functions?.description,z="functions",D=q.functions?.keywords,E="functions";try{if(await K({path:I(v),data:`{
3
- "name": "${B}",
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}",
4
25
  "type": "module",
5
26
  "version": "",
6
27
  "packageManager": "bun",
7
- "description": "${C}",
8
- "author": "${q.author}",
28
+ "description": "${description}",
29
+ "author": "${library.author}",
9
30
  "license": "MIT",
10
- "homepage": "https://github.com/${q.repository}/tree/main/${z}#readme",
31
+ "homepage": "https://github.com/${library.repository}/tree/main/${directory}#readme",
11
32
  "repository": {
12
33
  "type": "git",
13
- "url": "git+https://github.com/${q.repository}.git",
14
- "directory": "${z}"
34
+ "url": "git+https://github.com/${library.repository}.git",
35
+ "directory": "${directory}"
15
36
  },
16
37
  "bugs": {
17
- "url": "https://github.com/${q.repository}/issues"
38
+ "url": "https://github.com/${library.repository}/issues"
18
39
  },
19
- "keywords": ${JSON.stringify(D)},
20
- "contributors": ${JSON.stringify(q.contributors)},
40
+ "keywords": ${JSON.stringify(keywords)},
41
+ "contributors": ${JSON.stringify(library.contributors)},
21
42
  "exports": {
22
43
  ".": {
23
- "types": "./dist/index.d.ts",
44
+ "types": "./dist/index.d.js",
24
45
  "require": "./dist/index.cjs",
25
46
  "import": "./dist/index.js"
26
47
  }
@@ -33,11 +54,21 @@ import{Gb as q}from"../chunk-tsbk5vne.js";import"../chunk-h3d81wrg.js";import{lo
33
54
  "README.md"
34
55
  ],
35
56
  "scripts": {
36
- "build": "vite build -c ../build/${E}.ts",
57
+ "build": "vite build -c ../build/${config}.ts",
37
58
  "prepublishOnly": "bun run build"
38
59
  },
39
60
  "devDependencies": {
40
61
  "stacks": "workspace:*"
41
62
  }
42
63
  }
43
- `}),v==="web-components")A="Web Component library";else if(v==="functions")A="Function Library";G.success(`Created ${A} package.json file`)}catch(H){G.error(`There was an error creating the ${A} package.json`,H)}}export{R as generatePackageJson};
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
+ }
@@ -1,2 +1,105 @@
1
- // @bun
2
- import{Ib as a,Jb as b,Kb as c}from"../chunk-0gadhvn7.js";import"../chunk-h3d81wrg.js";export{b as runActions,a as runAction,c as hasAction};
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
+ }
@@ -1,2 +1,30 @@
1
- // @bun
2
- import{Eb as a,Fb as b}from"../chunk-tpb8jgsk.js";import"../chunk-tsbk5vne.js";import"../chunk-h3d81wrg.js";export{b as generateWebTypes,a as generateVsCodeCustomData};
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
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,19 @@ export type { CrudField } from './scaffold-crud';
2
2
  export type { DiscoveredPackagesManifest, PackageStacksMeta } from './discover-packages';
3
3
  export * from './action';
4
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';
5
18
  export { commit as runCommit } from './commit';
6
19
  export * from './dev/index';
7
20
  export * from './generate/index';
package/dist/index.js CHANGED
@@ -1,2 +1,50 @@
1
- // @bun
2
- import{$ as Q,Aa as pa,Ba as qa,Ca as ra,Da as sa,Ea as ta,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,_ as P,aa as R,ba as S,ca as T,da as U,ea as V,fa as W,ga as X,ha as Y,ia as Z,ja as _,ka as $,la as aa,ma as ba,na as ca,oa as da,pa as ea,qa as fa,ra as ga,sa as ha,ta as ia,ua as ja,va as ka,wa as la,xa as ma,ya as na,za as oa}from"./chunk-0c8sd1t6.js";import"./chunk-cdk2r2jd.js";import{Fa as A,Ga as B,Ha as C,Ia as D,Ja as E,Ka as F,La as G,Ma as H}from"./chunk-n5eqwhck.js";import{ib as r,jb as s,kb as t,lb as u,mb as v,nb as w,ob as x,pb as y,qb as z}from"./chunk-62gdfav8.js";import{Ab as n,Bb as o,Cb as p,Db as q,rb as e,sb as f,tb as g,ub as h,vb as i,wb as j,xb as k,yb as l,zb as m}from"./chunk-78c5n3s2.js";import"./chunk-tpb8jgsk.js";import"./chunk-tsbk5vne.js";import"./chunk-s735m9mg.js";import{Hb as a}from"./chunk-6bk53y02.js";import{Ib as b,Jb as c,Kb as d}from"./chunk-0gadhvn7.js";import"./chunk-h3d81wrg.js";export{m as watchTypes,oa as uninstallStack,E as trustCertificate,C as sslCertificatesExist,G as setupSSL,ja as setDryRun,ma as scaffoldCrud,x as runSystemTrayDevServer,ia as runMake,s as runFrontendDevServer,z as runDocsDevServer,r as runDevServer,y as runDesktopDevServer,w as runDashboardDevServer,v as runComponentsDevServer,J as runCommit,t as runBackendDevServer,u as runApiDevServer,I as runAdd,c as runActions,b as runAction,la as parseFields,ha as makeStack,ta as makeResource,ga as makeQueueTable,sa as makePolicy,fa as makePage,ea as makeNotification,da as makeMail,ca as makeLanguage,qa as makeJob,ba as makeFunction,aa as makeDatabase,$ as makeComponent,ra as makeCommand,_ as makeCertificate,Z as makeAction,pa as listStacks,M as lintProject,L as lintFix,H as isSSLSetupComplete,Y as isDryRunActive,A as isDomainInHosts,D as isCertificateTrusted,e as invoke,na as installStack,d as hasAction,h as generateWebTypes,i as generateVsCodeCustomData,l as generateTypes,o as generateSeeder,n as generatePantryConfig,q as generateOpenApiSpec,g as generateLibEntries,j as generateIdeHelpers,p as generateCoreSymlink,k as generateComponentMeta,F as generateCertificates,f as generate,K as formatProject,ka as discoverPackages,X as createPage,W as createNotification,U as createModel,T as createMigration,S as createMiddleware,V as createMail,R as createLanguage,Q as createFunction,P as createFactory,O as createDatabase,N as createComponent,B as addDomainToHosts,a as Action};
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";
@@ -1,2 +1,24 @@
1
- // @bun
2
- import{readFileSync as J}from"fs";import{runCommand as L}from"@stacksjs/cli";import{generateKeypair as M}from"@stacksjs/env";import{projectPath as D}from"@stacksjs/path";import{generateAppKey as N}from"@stacksjs/security";import{existsSync as O}from"@stacksjs/storage";import{setEnvValue as q}from"@stacksjs/utils";if(!O(".env"))await L("cp .env.example .env",{cwd:D()});await q("APP_KEY",N());var G=(()=>{try{return J(D(".env"),"utf-8")}catch{return""}})(),z=/^DOTENV_PUBLIC_KEY=.+$/m.test(G),B=/^DOTENV_PRIVATE_KEY=.+$/m.test(G);if(!z||!B){let{publicKey:H,privateKey:I}=M();if(!z)await q("DOTENV_PUBLIC_KEY",H);if(!B)await q("DOTENV_PRIVATE_KEY",I)}
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
+ }
package/dist/lint/fix.js CHANGED
@@ -1,3 +1,4 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
- import{Oa as b}from"../chunk-e142dheq.js";import"../chunk-h3d81wrg.js";import g from"process";var{ok:j}=await b();g.exit(j?0:1);
1
+ import process from "node:process";
2
+ import { lintFix } from "./lint";
3
+ const { ok } = await lintFix();
4
+ process.exit(ok ? 0 : 1);
@@ -1,3 +1,4 @@
1
- #!/usr/bin/env bun
2
- // @bun
3
- import{Na as f}from"../chunk-e142dheq.js";import"../chunk-h3d81wrg.js";import g from"process";var{ok:q}=await f();g.exit(q?0:1);
1
+ import process from "node:process";
2
+ import { lintProject } from "./lint";
3
+ const { ok } = await lintProject();
4
+ process.exit(ok ? 0 : 1);
package/dist/lint/lint.js CHANGED
@@ -1,2 +1,34 @@
1
- // @bun
2
- import{Na as a,Oa as b,Pa as c}from"../chunk-e142dheq.js";import"../chunk-h3d81wrg.js";export{a as lintProject,b as lintFix,c as formatProject};
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
+ }
@@ -1,45 +1,95 @@
1
- // @bun
2
- import"./chunk-h3d81wrg.js";import{log as B}from"@stacksjs/logging";import*as G from"@stacksjs/path";import{get as O,writeFile as H}from"@stacksjs/storage";async function V(y){let z=y.name;if(!z)return B.error("Command name is required"),!1;let q=S(z),A=Q(q,y),D=G.commandsPath(`${q}.ts`);try{if(await H(D,A),B.success(`Created command: ${D}`),y.register!==!1)await R(q,y.signature||I(z));return!0}catch(E){return B.error(`Failed to create command: ${E.message}`),!1}}function Q(y,z){let q=z.signature||I(y),A=z.description||`The ${q} command`;return`import type { CLI } from '@stacksjs/types'
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'
3
25
  import { log } from '@stacksjs/cli'
4
26
 
5
27
  /**
6
- * ${y} Command
28
+ * ${name} Command
7
29
  *
8
- * ${A}
30
+ * ${description}
9
31
  */
10
32
 
11
- interface ${y}Options {
33
+ interface ${name}Options {
12
34
  verbose: boolean
13
35
  // Add your command options here
14
36
  }
15
37
 
16
38
  export default function (cli: CLI) {
17
39
  cli
18
- .command('${q}', '${A}')
40
+ .command('${signature}', '${description}')
19
41
  .option('--verbose', 'Enable verbose output', { default: false })
20
42
  // Add more options here
21
43
  // .option('-n, --name <name>', 'Your name')
22
- .action(async (options: ${y}Options) => {
44
+ .action(async (options: ${name}Options) => {
23
45
  try {
24
46
  if (options.verbose) {
25
- log.info('Running ${q} command...')
47
+ log.info('Running ${signature} command...')
26
48
  }
27
49
 
28
50
  log.info('No command logic implemented yet. Update this command action to add behavior.')
29
51
 
30
- log.success('${q} completed successfully!')
52
+ log.success('${signature} completed successfully!')
31
53
  }
32
54
  catch (error) {
33
- log.error('${q} failed:', error)
55
+ log.error('${signature} failed:', error)
34
56
  throw error
35
57
  }
36
58
  })
37
59
 
38
60
  // Handle unknown subcommands
39
- cli.on('${q}:*', () => {
61
+ cli.on('${signature}:*', () => {
40
62
  log.error('Invalid command: %s\\nSee --help for a list of available commands.', cli.args.join(' '))
41
63
  })
42
64
  }
43
- `}async function R(y,z){let q=G.appPath("Commands.ts");try{let A=await O(q),D=A.match(/export default \{([\s\S]*)\} satisfies/);if(D){let E=D[1]??"";if(E.includes(`'${z}'`)){B.info(`Command '${z}' already registered in Commands.ts`);return}let J=` '${z}': '${y}',
44
- `,L=`${E.trimEnd()}
45
- ${J}`;A=A.replace(/export default \{[\s\S]*\} satisfies/,`export default {${L}} satisfies`),await H(q,A),B.success(`Registered command '${z}' in Commands.ts`)}}catch(A){B.warn(`Could not register command in Commands.ts: ${A.message}`),B.info("You may need to manually add it to app/Commands.ts")}}function S(y){return y.replace(/[-_](.)/g,(z,q)=>q.toUpperCase()).replace(/^(.)/,(z,q)=>q.toUpperCase())}function I(y){return y.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").toLowerCase()}export{V as makeCommand};
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
+ }
package/dist/make-job.js CHANGED
@@ -1,31 +1,51 @@
1
- // @bun
2
- import"./chunk-h3d81wrg.js";import{log as A}from"@stacksjs/logging";import*as H from"@stacksjs/path";import{writeFile as L}from"@stacksjs/storage";async function T(v){let x=v,y=v.name;if(!y)return A.error("Job name is required"),!1;let z=y.endsWith("Job")?y:`${y}Job`,I=x.class??!1?Q(z,x):M(z,x),E=H.userJobsPath(`${z}.ts`);try{return await L(E,I),A.success(`Created job: ${E}`),!0}catch(K){return A.error(`Failed to create job: ${K.message}`),!1}}function M(v,x){let y=x.queue??"default",z=x.tries??3,D=x.backoff??3;return`import { Job } from '@stacksjs/queue'
1
+ import { log } from "@stacksjs/logging";
2
+ import * as p from "@stacksjs/path";
3
+ import { writeFile } from "@stacksjs/storage";
4
+ export async function makeJob(options) {
5
+ const jobOptions = options, name = options.name;
6
+ if (!name) {
7
+ log.error("Job name is required");
8
+ return !1;
9
+ }
10
+ const jobName = name.endsWith("Job") ? name : `${name}Job`, content = jobOptions.class ?? !1 ? generateClassBasedJob(jobName, jobOptions) : generateFunctionBasedJob(jobName, jobOptions), filePath = p.userJobsPath(`${jobName}.ts`);
11
+ try {
12
+ await writeFile(filePath, content);
13
+ log.success(`Created job: ${filePath}`);
14
+ return !0;
15
+ } catch (error) {
16
+ log.error(`Failed to create job: ${error.message}`);
17
+ return !1;
18
+ }
19
+ }
20
+ function generateFunctionBasedJob(name, options) {
21
+ const queue = options.queue ?? "default", tries = options.tries ?? 3, backoff = options.backoff ?? 3;
22
+ return `import { Job } from '@stacksjs/queue'
3
23
 
4
24
  export default new Job({
5
25
  /**
6
26
  * The job name (optional, defaults to filename)
7
27
  */
8
- name: '${v}',
28
+ name: '${name}',
9
29
 
10
30
  /**
11
31
  * A description of what this job does (optional)
12
32
  */
13
- description: '${v} job',
33
+ description: '${name} job',
14
34
 
15
35
  /**
16
36
  * The queue this job should be dispatched to
17
37
  */
18
- queue: '${y}',
38
+ queue: '${queue}',
19
39
 
20
40
  /**
21
41
  * Number of times to retry if the job fails
22
42
  */
23
- tries: ${z},
43
+ tries: ${tries},
24
44
 
25
45
  /**
26
46
  * Seconds to wait between retry attempts
27
47
  */
28
- backoff: ${D},
48
+ backoff: ${backoff},
29
49
 
30
50
  /**
31
51
  * Cron expression for scheduled jobs (optional)
@@ -58,14 +78,18 @@ export default new Job({
58
78
  return { success: true }
59
79
  },
60
80
  })
61
- `}function Q(v,x){let y=x.queue??"default",z=x.tries??3;return`import { log } from '@stacksjs/logging'
81
+ `;
82
+ }
83
+ function generateClassBasedJob(name, options) {
84
+ const queue = options.queue ?? "default", tries = options.tries ?? 3;
85
+ return `import { log } from '@stacksjs/logging'
62
86
 
63
87
  /**
64
- * ${v}
88
+ * ${name}
65
89
  *
66
90
  * Generated job class.
67
91
  */
68
- export default class ${v} {
92
+ export default class ${name} {
69
93
  /**
70
94
  * Job configuration
71
95
  */
@@ -73,7 +97,7 @@ export default class ${v} {
73
97
  /**
74
98
  * The queue this job should be dispatched to
75
99
  */
76
- queue: '${y}',
100
+ queue: '${queue}',
77
101
 
78
102
  /**
79
103
  * Cron expression for scheduled jobs (optional)
@@ -97,7 +121,7 @@ export default class ${v} {
97
121
  /**
98
122
  * Number of retry attempts
99
123
  */
100
- retries: ${z},
124
+ retries: ${tries},
101
125
 
102
126
  /**
103
127
  * Delay between retries in seconds
@@ -111,19 +135,20 @@ export default class ${v} {
111
135
  */
112
136
  public static async handle(payload?: Record<string, unknown>): Promise<{ success: boolean }> {
113
137
  try {
114
- log.info('${v}: Starting job execution')
138
+ log.info('${name}: Starting job execution')
115
139
 
116
140
  // Add your job logic here.
117
141
  console.log('Processing with payload:', payload)
118
142
 
119
- log.info('${v}: Job completed successfully')
143
+ log.info('${name}: Job completed successfully')
120
144
 
121
145
  return { success: true }
122
146
  }
123
147
  catch (error) {
124
- log.error('${v}: Job failed:', error)
148
+ log.error('${name}: Job failed:', error)
125
149
  throw error
126
150
  }
127
151
  }
128
152
  }
129
- `}export{T as makeJob};
153
+ `;
154
+ }