@stacksjs/actions 0.70.280 → 0.70.282
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.
- package/dist/helpers/utils.d.ts +9 -0
- package/dist/helpers/utils.js +1 -1
- package/package.json +18 -18
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import type { ActionOptions, CommandError, Subprocess } from '@stacksjs/types';
|
|
|
2
2
|
import type { Result } from '@stacksjs/error-handling';
|
|
3
3
|
export declare function publishedActionCandidates(action: string, packageRoot?: string): string[];
|
|
4
4
|
export declare function developmentConditionForProject(projectRoot: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Build the lookup path for action subprocesses.
|
|
7
|
+
*
|
|
8
|
+
* Installed application dependencies are authoritative. Pantry is a fallback
|
|
9
|
+
* for compiled tools that need packages which are not installed in the app;
|
|
10
|
+
* putting it first lets an old local Pantry snapshot silently shadow the
|
|
11
|
+
* versions locked in node_modules during migrations and production deploys.
|
|
12
|
+
*/
|
|
13
|
+
export declare function actionNodePath(projectRoot: string, existingNodePath?: string): string;
|
|
5
14
|
/**
|
|
6
15
|
* Run an Action the Stacks way.
|
|
7
16
|
*
|
package/dist/helpers/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var {require}=import.meta;import{existsSync}from"node:fs";import{homedir}from"node:os";import{join}from"node:path";import process from"node:process";import{buddyOptions,runCommand}from"@stacksjs/cli";import{err}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":""}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
|
|
1
|
+
var {require}=import.meta;import{existsSync}from"node:fs";import{homedir}from"node:os";import{delimiter,join}from"node:path";import process from"node:process";import{buddyOptions,runCommand}from"@stacksjs/cli";import{err}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:!0,value:{}}}return err("dev/views entry not found")}catch(error){return err(`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(`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=isDevAction?"--watch":"",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 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))}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.70.
|
|
5
|
+
"version": "0.70.282",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -59,33 +59,33 @@
|
|
|
59
59
|
"prepublishOnly": "bun run build"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@stacksjs/config": "0.70.
|
|
62
|
+
"@stacksjs/config": "0.70.282",
|
|
63
63
|
"@stacksjs/bumpx": "^0.2.6",
|
|
64
64
|
"@stacksjs/bunpress": "^0.1.18",
|
|
65
65
|
"@stacksjs/logsmith": "^0.2.3",
|
|
66
|
-
"@stacksjs/registry": "0.70.
|
|
66
|
+
"@stacksjs/registry": "0.70.282",
|
|
67
67
|
"@stacksjs/stx": "^0.2.148",
|
|
68
68
|
"@stacksjs/ts-cloud": "^0.7.103",
|
|
69
69
|
"@stacksjs/ts-md": "^0.1.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@stacksjs/api": "0.70.
|
|
73
|
-
"@stacksjs/cli": "0.70.
|
|
74
|
-
"@stacksjs/database": "0.70.
|
|
72
|
+
"@stacksjs/api": "0.70.282",
|
|
73
|
+
"@stacksjs/cli": "0.70.282",
|
|
74
|
+
"@stacksjs/database": "0.70.282",
|
|
75
75
|
"@stacksjs/tlsx": "^0.13.2",
|
|
76
76
|
"better-dx": "^0.2.17",
|
|
77
|
-
"@stacksjs/dns": "0.70.
|
|
78
|
-
"@stacksjs/enums": "0.70.
|
|
79
|
-
"@stacksjs/env": "0.70.
|
|
80
|
-
"@stacksjs/error-handling": "0.70.
|
|
81
|
-
"@stacksjs/image": "0.70.
|
|
82
|
-
"@stacksjs/logging": "0.70.
|
|
83
|
-
"@stacksjs/path": "0.70.
|
|
84
|
-
"@stacksjs/security": "0.70.
|
|
85
|
-
"@stacksjs/storage": "0.70.
|
|
86
|
-
"@stacksjs/strings": "0.70.
|
|
87
|
-
"@stacksjs/utils": "0.70.
|
|
88
|
-
"@stacksjs/validation": "0.70.
|
|
77
|
+
"@stacksjs/dns": "0.70.282",
|
|
78
|
+
"@stacksjs/enums": "0.70.282",
|
|
79
|
+
"@stacksjs/env": "0.70.282",
|
|
80
|
+
"@stacksjs/error-handling": "0.70.282",
|
|
81
|
+
"@stacksjs/image": "0.70.282",
|
|
82
|
+
"@stacksjs/logging": "0.70.282",
|
|
83
|
+
"@stacksjs/path": "0.70.282",
|
|
84
|
+
"@stacksjs/security": "0.70.282",
|
|
85
|
+
"@stacksjs/storage": "0.70.282",
|
|
86
|
+
"@stacksjs/strings": "0.70.282",
|
|
87
|
+
"@stacksjs/utils": "0.70.282",
|
|
88
|
+
"@stacksjs/validation": "0.70.282"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"pickier": "^0.1.35"
|