@stacksjs/actions 0.74.3 → 0.74.4

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.
@@ -31,6 +31,19 @@ export declare function runActions(actions: Action[], options?: ActionOptions):
31
31
  export declare function runActionSequence(actions: Action[], options: ActionOptions | undefined, runner?: typeof runAction): Promise<any>;
32
32
  // looks in most common locations
33
33
  export declare function hasAction(action: Action): boolean;
34
+ /**
35
+ * Generate an application key for a project that has not been initialised.
36
+ *
37
+ * This lived in `@stacksjs/utils`, and was the only reason that package
38
+ * depended on this one: a utility package importing the action runner, for a
39
+ * function whose whole body is a call to it. That single edge held `utils` -
40
+ * and `arrays`, `objects` and `slug` beneath it - inside the framework's
41
+ * dependency cycle.
42
+ *
43
+ * It belongs next to `runAction`, which is defined above it, so the
44
+ * dependency now runs the same direction as the layering.
45
+ */
46
+ export declare function initProject(): Promise<Result<Subprocess, Error>>;
34
47
  /**
35
48
  * Augmentation target: the actions this application can run.
36
49
  *
@@ -1 +1 @@
1
- var {require}=import.meta;import{existsSync}from"node:fs";import{delimiter,join}from"node:path";import process from"node:process";import{buddyOptions,runCommand}from"@stacksjs/cli";import{err,ok}from"@stacksjs/error-handling";import{log}from"@stacksjs/logging";import*as p from"@stacksjs/path";export function publishedActionCandidates(action,packageRoot){let root=packageRoot;if(!root)try{const pkgUrl=import.meta.resolve("@stacksjs/actions/package.json");if(pkgUrl){const pkgPath=new URL(pkgUrl).pathname;root=pkgPath.slice(0,pkgPath.lastIndexOf("/"))}}catch{return[]}if(!root)return[];return[`${root}/dist/${action}.js`,`${root}/dist/src/${action}.js`,`${root}/src/${action}.ts`]}export function developmentConditionForProject(projectRoot){return existsSync(join(projectRoot,"storage/framework/core"))&&existsSync(join(projectRoot,"node_modules/@stacksjs/env/src/index.ts"))?"--conditions development":""}export function actionNodePath(projectRoot,existingNodePath){const nodeModulesPath=join(projectRoot,"node_modules"),pantryPath=join(projectRoot,"pantry"),paths=[nodeModulesPath];for(const entry of existingNodePath?.split(delimiter)??[])if(entry&&entry!==nodeModulesPath&&entry!==pantryPath&&!paths.includes(entry))paths.push(entry);paths.push(pantryPath);return paths.join(delimiter)}async function resolveActionFile(action,projectRoot){const candidates=[];if(projectRoot)candidates.push(join(projectRoot,`storage/framework/core/actions/src/${action}.ts`));candidates.push(p.actionsPath(`src/${action}.ts`));candidates.push(...publishedActionCandidates(action));for(const candidate of candidates)if(await Bun.file(candidate).exists())return candidate;return null}export async function runAction(action,options){log.debug(`[action] Running: ${action}`);if(action==="dev/views")try{const nodePath=actionNodePath(p.projectPath(),process.env.NODE_PATH);if(process.env.NODE_PATH!==nodePath){process.env.NODE_PATH=nodePath;require("module").Module._initPaths?.()}const viewsEntries=[p.projectPath("storage/framework/core/actions/src/dev/views.ts"),p.frameworkPath("actions/src/dev/views.ts"),...publishedActionCandidates("dev/views")];for(const entry of viewsEntries)if(existsSync(entry)){await import(entry);return ok({})}return err(Error("dev/views entry not found"))}catch(error){return err(Error(`Failed to start dev server: ${error}`))}const isLikelyCoreAction=action.includes("/")||["dev","build","install","upgrade","migrate"].some((prefix)=>action.startsWith(prefix)),userActionsBase=options?.cwd?join(String(options.cwd),"app/Actions"):p.userActionsPath();if(!isLikelyCoreAction&&existsSync(userActionsBase)){const glob=new Bun.Glob("**/*.{ts,js}"),scanOptions={cwd:userActionsBase,onlyFiles:!0,absolute:!0},matchingFiles=[],basePath=userActionsBase;for await(const file of glob.scan(scanOptions)){if(file.replace(`${basePath}/`,"").replace(/\.(ts|js)$/,"")===action||file.endsWith(`${action}.ts`)||file.endsWith(`${action}.js`)){log.debug(`[action] Resolved: ${action} \u2192 ${file}`);return await(await import(file)).default.handle(void 0)}matchingFiles.push(file)}for(const file of matchingFiles)try{const a=await import(file);if(a.name===action){log.debug(`[action] Resolved: ${action} \u2192 ${file}`);return await a.handle()}}catch(error){}}const path=await resolveActionFile(action,options?.cwd?String(options.cwd):void 0);if(!path)return err(Error(`Action '${action}' not found in storage/framework/core/actions/src or @stacksjs/actions`));log.debug(`[action] Resolved: ${action} \u2192 ${path}`);const isDevAction=action.startsWith("dev/"),watchFlag=developmentWatchFlag(action),developmentCondition=developmentConditionForProject(p.projectPath()),opts=isDevAction?"":buddyOptions(options)||"",cmd=["bun",developmentCondition,watchFlag,path,opts].filter(Boolean).join(" "),nodePath=actionNodePath(p.projectPath(),process.env.NODE_PATH),shouldInherit=options?.verbose||isDevAction&&!options?.quiet,optionsWithCwd={cwd:options?.cwd||p.projectPath(),...options,stdout:shouldInherit?"inherit":void 0,stderr:shouldInherit?"inherit":void 0,env:{...options?.env,NODE_PATH:nodePath,...isDevAction?{STACKS_DEV_SERVER:"1"}:{}}},result=await runCommand(cmd,optionsWithCwd);log.debug(`[action] Completed: ${action}`);return result}export function developmentWatchFlag(action){if(!action.startsWith("dev/"))return"";return action==="dev/dashboard"||action==="dev/desktop"?"":"--watch"}export async function runActions(actions,options){if(!actions.length)return err("No actions were specified");for(const action of actions)if(!hasAction(action))return err(`The specified action "${action}" does not exist`);return await runActionSequence(actions,options)}export async function runActionSequence(actions,options,runner=runAction){let result;for(const action of actions){result=await runner(action,options);if(result?.isErr)return result}return result}export function hasAction(action){const userActionPatterns=[`${action}.ts`,`${action}`,`Dashboard/${action}.ts`,`Dashboard/${action}`,`Buddy/${action}.ts`,`Buddy/${action}`],actionPatterns=[`src/${action}.ts`,`src/${action}`,`${action}.ts`,`${action}`];return[...userActionPatterns.map((pattern)=>p.userActionsPath(pattern)),...actionPatterns.map((pattern)=>p.actionsPath(pattern)),...publishedActionCandidates(action)].some((candidate)=>existsSync(candidate))}
1
+ var {require}=import.meta;import{existsSync}from"node:fs";import{delimiter,join}from"node:path";import process from"node:process";import{buddyOptions,runCommand}from"@stacksjs/cli";import{app}from"@stacksjs/config";import{Action as ActionEnum}from"@stacksjs/enums";import{err,handleError,ok}from"@stacksjs/error-handling";import{log}from"@stacksjs/logging";import*as p from"@stacksjs/path";export function publishedActionCandidates(action,packageRoot){let root=packageRoot;if(!root)try{const pkgUrl=import.meta.resolve("@stacksjs/actions/package.json");if(pkgUrl){const pkgPath=new URL(pkgUrl).pathname;root=pkgPath.slice(0,pkgPath.lastIndexOf("/"))}}catch{return[]}if(!root)return[];return[`${root}/dist/${action}.js`,`${root}/dist/src/${action}.js`,`${root}/src/${action}.ts`]}export function developmentConditionForProject(projectRoot){return existsSync(join(projectRoot,"storage/framework/core"))&&existsSync(join(projectRoot,"node_modules/@stacksjs/env/src/index.ts"))?"--conditions development":""}export function actionNodePath(projectRoot,existingNodePath){const nodeModulesPath=join(projectRoot,"node_modules"),pantryPath=join(projectRoot,"pantry"),paths=[nodeModulesPath];for(const entry of existingNodePath?.split(delimiter)??[])if(entry&&entry!==nodeModulesPath&&entry!==pantryPath&&!paths.includes(entry))paths.push(entry);paths.push(pantryPath);return paths.join(delimiter)}async function resolveActionFile(action,projectRoot){const candidates=[];if(projectRoot)candidates.push(join(projectRoot,`storage/framework/core/actions/src/${action}.ts`));candidates.push(p.actionsPath(`src/${action}.ts`));candidates.push(...publishedActionCandidates(action));for(const candidate of candidates)if(await Bun.file(candidate).exists())return candidate;return null}export async function runAction(action,options){log.debug(`[action] Running: ${action}`);if(action==="dev/views")try{const nodePath=actionNodePath(p.projectPath(),process.env.NODE_PATH);if(process.env.NODE_PATH!==nodePath){process.env.NODE_PATH=nodePath;require("module").Module._initPaths?.()}const viewsEntries=[p.projectPath("storage/framework/core/actions/src/dev/views.ts"),p.frameworkPath("actions/src/dev/views.ts"),...publishedActionCandidates("dev/views")];for(const entry of viewsEntries)if(existsSync(entry)){await import(entry);return ok({})}return err(Error("dev/views entry not found"))}catch(error){return err(Error(`Failed to start dev server: ${error}`))}const isLikelyCoreAction=action.includes("/")||["dev","build","install","upgrade","migrate"].some((prefix)=>action.startsWith(prefix)),userActionsBase=options?.cwd?join(String(options.cwd),"app/Actions"):p.userActionsPath();if(!isLikelyCoreAction&&existsSync(userActionsBase)){const glob=new Bun.Glob("**/*.{ts,js}"),scanOptions={cwd:userActionsBase,onlyFiles:!0,absolute:!0},matchingFiles=[],basePath=userActionsBase;for await(const file of glob.scan(scanOptions)){if(file.replace(`${basePath}/`,"").replace(/\.(ts|js)$/,"")===action||file.endsWith(`${action}.ts`)||file.endsWith(`${action}.js`)){log.debug(`[action] Resolved: ${action} \u2192 ${file}`);return await(await import(file)).default.handle(void 0)}matchingFiles.push(file)}for(const file of matchingFiles)try{const a=await import(file);if(a.name===action){log.debug(`[action] Resolved: ${action} \u2192 ${file}`);return await a.handle()}}catch(error){}}const path=await resolveActionFile(action,options?.cwd?String(options.cwd):void 0);if(!path)return err(Error(`Action '${action}' not found in storage/framework/core/actions/src or @stacksjs/actions`));log.debug(`[action] Resolved: ${action} \u2192 ${path}`);const isDevAction=action.startsWith("dev/"),watchFlag=developmentWatchFlag(action),developmentCondition=developmentConditionForProject(p.projectPath()),opts=isDevAction?"":buddyOptions(options)||"",cmd=["bun",developmentCondition,watchFlag,path,opts].filter(Boolean).join(" "),nodePath=actionNodePath(p.projectPath(),process.env.NODE_PATH),shouldInherit=options?.verbose||isDevAction&&!options?.quiet,optionsWithCwd={cwd:options?.cwd||p.projectPath(),...options,stdout:shouldInherit?"inherit":void 0,stderr:shouldInherit?"inherit":void 0,env:{...options?.env,NODE_PATH:nodePath,...isDevAction?{STACKS_DEV_SERVER:"1"}:{}}},result=await runCommand(cmd,optionsWithCwd);log.debug(`[action] Completed: ${action}`);return result}export function developmentWatchFlag(action){if(!action.startsWith("dev/"))return"";return action==="dev/dashboard"||action==="dev/desktop"?"":"--watch"}export async function runActions(actions,options){if(!actions.length)return err("No actions were specified");for(const action of actions)if(!hasAction(action))return err(`The specified action "${action}" does not exist`);return await runActionSequence(actions,options)}export async function runActionSequence(actions,options,runner=runAction){let result;for(const action of actions){result=await runner(action,options);if(result?.isErr)return result}return result}export function hasAction(action){const userActionPatterns=[`${action}.ts`,`${action}`,`Dashboard/${action}.ts`,`Dashboard/${action}`,`Buddy/${action}.ts`,`Buddy/${action}`],actionPatterns=[`src/${action}.ts`,`src/${action}`,`${action}.ts`,`${action}`];return[...userActionPatterns.map((pattern)=>p.userActionsPath(pattern)),...actionPatterns.map((pattern)=>p.actionsPath(pattern)),...publishedActionCandidates(action)].some((candidate)=>existsSync(candidate))}export async function initProject(){if(app.env!=="production")log.info("Project not yet initialized, generating application key...");else handleError("Please run `buddy key:generate` to generate an application key");const result=await runAction(ActionEnum.KeyGenerate,{cwd:p.projectPath()});if(result.isErr)return err(handleError(result.error));log.info("Application key generated.");return ok(result.value)}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./action";export{add as runAdd}from"./add";export{BlogAdminError,deleteBlogPost,getBlogPost,listBlogPosts,saveBlogPost,slugify as blogSlugify}from"./blog-admin";export{commit as runCommit}from"./commit";export*from"./dev";export*from"./generate";export*from"./helpers";export*from"./library";export{formatProject,lintFix,lintProject}from"./lint/lint";export{DEFAULT_STX_LINT_CONFIG,loadStxLintConfig,runStxLint}from"./lint/stx-gate";export{measureDefaultsDrift,summarizeStructureChanges}from"./upgrade/package-project";export*from"./setup";export{createComponent,createDatabase,createFactory,createFunction,createLanguage,createMiddleware,createMigration,createModel,createMail,createNotification,createPage,isDryRunActive,makeAction,makeCertificate,makeComponent,makeDatabase,makeFunction,makeLanguage,makeMail,makeNotification,makePage,makeQueueTable,makeStack,make as runMake,setDryRun}from"./make";export{discoverPackages}from"./discover-packages";export{parseFields,scaffoldCrud}from"./scaffold-crud";export{installStack,uninstallStack,listStacks}from"./stacks";export{makeJob}from"./make-job";export{makeCommand}from"./make-command";export{makePolicy}from"./make-policy";export{makeResource}from"./make-resource";
1
+ import{setActionRunner}from"@stacksjs/action-runner";import{runAction}from"./helpers";setActionRunner((action,options)=>runAction(action,options));export*from"./action";export{add as runAdd}from"./add";export{BlogAdminError,deleteBlogPost,getBlogPost,listBlogPosts,saveBlogPost,slugify as blogSlugify}from"./blog-admin";export{commit as runCommit}from"./commit";export*from"./dev";export*from"./generate";export*from"./helpers";export*from"./library";export{formatProject,lintFix,lintProject}from"./lint/lint";export{DEFAULT_STX_LINT_CONFIG,loadStxLintConfig,runStxLint}from"./lint/stx-gate";export{measureDefaultsDrift,summarizeStructureChanges}from"./upgrade/package-project";export*from"./setup";export{createComponent,createDatabase,createFactory,createFunction,createLanguage,createMiddleware,createMigration,createModel,createMail,createNotification,createPage,isDryRunActive,makeAction,makeCertificate,makeComponent,makeDatabase,makeFunction,makeLanguage,makeMail,makeNotification,makePage,makeQueueTable,makeStack,make as runMake,setDryRun}from"./make";export{discoverPackages}from"./discover-packages";export{parseFields,scaffoldCrud}from"./scaffold-crud";export{installStack,uninstallStack,listStacks}from"./stacks";export{makeJob}from"./make-job";export{makeCommand}from"./make-command";export{makePolicy}from"./make-policy";export{makeResource}from"./make-resource";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/actions",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.74.3",
5
+ "version": "0.74.4",
6
6
  "description": "The Stacks actions.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -60,50 +60,51 @@
60
60
  "prepublishOnly": "bun run build"
61
61
  },
62
62
  "dependencies": {
63
- "@stacksjs/ai": "0.74.3",
64
- "@stacksjs/analytics": "0.74.3",
65
- "@stacksjs/api": "0.74.3",
66
- "@stacksjs/auth": "0.74.3",
67
- "@stacksjs/build": "0.74.3",
63
+ "@stacksjs/action-runner": "0.74.4",
64
+ "@stacksjs/ai": "0.74.4",
65
+ "@stacksjs/analytics": "0.74.4",
66
+ "@stacksjs/api": "0.74.4",
67
+ "@stacksjs/auth": "0.74.4",
68
+ "@stacksjs/build": "0.74.4",
68
69
  "@stacksjs/bumpx": "^0.2.6",
69
70
  "@stacksjs/bunpress": "^0.2.8",
70
- "@stacksjs/cli": "0.74.3",
71
- "@stacksjs/cloud": "0.74.3",
72
- "@stacksjs/cms": "0.74.3",
73
- "@stacksjs/config": "0.74.3",
74
- "@stacksjs/database": "0.74.3",
75
- "@stacksjs/desktop-build": "0.74.3",
76
- "@stacksjs/dns": "0.74.3",
77
- "@stacksjs/enums": "0.74.3",
78
- "@stacksjs/env": "0.74.3",
79
- "@stacksjs/error-handling": "0.74.3",
71
+ "@stacksjs/cli": "0.74.4",
72
+ "@stacksjs/cloud": "0.74.4",
73
+ "@stacksjs/cms": "0.74.4",
74
+ "@stacksjs/config": "0.74.4",
75
+ "@stacksjs/database": "0.74.4",
76
+ "@stacksjs/desktop-build": "0.74.4",
77
+ "@stacksjs/dns": "0.74.4",
78
+ "@stacksjs/enums": "0.74.4",
79
+ "@stacksjs/env": "0.74.4",
80
+ "@stacksjs/error-handling": "0.74.4",
80
81
  "@stacksjs/gitit": "^0.2.5",
81
- "@stacksjs/i18n": "0.74.3",
82
- "@stacksjs/image": "0.74.3",
83
- "@stacksjs/logging": "0.74.3",
82
+ "@stacksjs/i18n": "0.74.4",
83
+ "@stacksjs/image": "0.74.4",
84
+ "@stacksjs/logging": "0.74.4",
84
85
  "@stacksjs/logsmith": "^0.2.3",
85
- "@stacksjs/orm": "0.74.3",
86
- "@stacksjs/path": "0.74.3",
87
- "@stacksjs/payments": "0.74.3",
88
- "@stacksjs/queue": "0.74.3",
89
- "@stacksjs/registry": "0.74.3",
90
- "@stacksjs/router": "0.74.3",
86
+ "@stacksjs/orm": "0.74.4",
87
+ "@stacksjs/path": "0.74.4",
88
+ "@stacksjs/payments": "0.74.4",
89
+ "@stacksjs/queue": "0.74.4",
90
+ "@stacksjs/registry": "0.74.4",
91
+ "@stacksjs/router": "0.74.4",
91
92
  "@stacksjs/rpx": "^0.11.42",
92
- "@stacksjs/scheduler": "0.74.3",
93
- "@stacksjs/search-engine": "0.74.3",
94
- "@stacksjs/security": "0.74.3",
95
- "@stacksjs/server": "0.74.3",
96
- "@stacksjs/sites": "0.74.3",
97
- "@stacksjs/storage": "0.74.3",
98
- "@stacksjs/strings": "0.74.3",
93
+ "@stacksjs/scheduler": "0.74.4",
94
+ "@stacksjs/search-engine": "0.74.4",
95
+ "@stacksjs/security": "0.74.4",
96
+ "@stacksjs/server": "0.74.4",
97
+ "@stacksjs/sites": "0.74.4",
98
+ "@stacksjs/storage": "0.74.4",
99
+ "@stacksjs/strings": "0.74.4",
99
100
  "@stacksjs/stx": "^0.2.253",
100
- "@stacksjs/tlsx": "^0.13.2",
101
+ "@stacksjs/tlsx": "^0.13.19",
101
102
  "@stacksjs/ts-cloud": "^0.12.10",
102
103
  "@stacksjs/ts-md": "^0.1.1",
103
- "@stacksjs/tunnel": "0.74.3",
104
- "@stacksjs/types": "0.74.3",
105
- "@stacksjs/utils": "0.74.3",
106
- "@stacksjs/whois": "0.74.3",
104
+ "@stacksjs/tunnel": "0.74.4",
105
+ "@stacksjs/types": "0.74.4",
106
+ "@stacksjs/utils": "0.74.4",
107
+ "@stacksjs/whois": "0.74.4",
107
108
  "bun-plugin-stx": "^0.2.246"
108
109
  },
109
110
  "peerDependencies": {
@@ -119,7 +120,7 @@
119
120
  }
120
121
  },
121
122
  "devDependencies": {
122
- "@stacksjs/validation": "0.74.3",
123
+ "@stacksjs/validation": "0.74.4",
123
124
  "better-dx": "^0.2.24"
124
125
  }
125
126
  }