@stacksjs/actions 0.70.137 → 0.70.139
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 +2 -0
- package/dist/helpers/utils.js +34 -16
- package/package.json +17 -17
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ActionOptions, CommandError, Subprocess } from '@stacksjs/types';
|
|
2
2
|
import type { Result } from '@stacksjs/error-handling';
|
|
3
|
+
export declare function publishedActionCandidates(action: string, packageRoot?: string): string[];
|
|
3
4
|
export declare function developmentConditionForProject(projectRoot: string): string;
|
|
4
5
|
/**
|
|
5
6
|
* Run an Action the Stacks way.
|
|
@@ -17,6 +18,7 @@ export declare function runAction(action: Action, options?: ActionOptions): Prom
|
|
|
17
18
|
* @returns The result of the command.
|
|
18
19
|
*/
|
|
19
20
|
export declare function runActions(actions: Action[], options?: ActionOptions): Promise<any>;
|
|
21
|
+
export declare function runActionSequence(actions: Action[], options: ActionOptions | undefined, runner?: typeof runAction): Promise<any>;
|
|
20
22
|
// looks in most common locations
|
|
21
23
|
export declare function hasAction(action: Action): boolean;
|
|
22
24
|
declare type ActionPath = string // TODO: narrow this by automating its generation
|
package/dist/helpers/utils.js
CHANGED
|
@@ -2,25 +2,37 @@ var {require}=import.meta;import { existsSync } from "node:fs";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
|
-
import { buddyOptions, runCommand
|
|
5
|
+
import { buddyOptions, runCommand } from "@stacksjs/cli";
|
|
6
6
|
import { err } from "@stacksjs/error-handling";
|
|
7
7
|
import { log } from "@stacksjs/logging";
|
|
8
8
|
import * as p from "@stacksjs/path";
|
|
9
|
+
export function publishedActionCandidates(action, packageRoot) {
|
|
10
|
+
let root = packageRoot;
|
|
11
|
+
if (!root)
|
|
12
|
+
try {
|
|
13
|
+
const pkgUrl = import.meta.resolve("@stacksjs/actions/package.json");
|
|
14
|
+
if (pkgUrl) {
|
|
15
|
+
const pkgPath = new URL(pkgUrl).pathname;
|
|
16
|
+
root = pkgPath.slice(0, pkgPath.lastIndexOf("/"));
|
|
17
|
+
}
|
|
18
|
+
} catch {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
if (!root)
|
|
22
|
+
return [];
|
|
23
|
+
return [
|
|
24
|
+
`${root}/dist/${action}.js`,
|
|
25
|
+
`${root}/dist/src/${action}.js`,
|
|
26
|
+
`${root}/src/${action}.ts`
|
|
27
|
+
];
|
|
28
|
+
}
|
|
9
29
|
export function developmentConditionForProject(projectRoot) {
|
|
10
30
|
return existsSync(join(projectRoot, "storage/framework/core")) && existsSync(join(projectRoot, "node_modules/@stacksjs/env/src/index.ts")) ? "--conditions development" : "";
|
|
11
31
|
}
|
|
12
32
|
async function resolveActionFile(action) {
|
|
13
33
|
const candidates = [];
|
|
14
34
|
candidates.push(p.actionsPath(`src/${action}.ts`));
|
|
15
|
-
|
|
16
|
-
const pkgUrl = import.meta.resolve("@stacksjs/actions/package.json");
|
|
17
|
-
if (pkgUrl) {
|
|
18
|
-
const pkgPath = new URL(pkgUrl).pathname, pkgRoot = pkgPath.slice(0, pkgPath.lastIndexOf("/"));
|
|
19
|
-
candidates.push(`${pkgRoot}/dist/${action}.js`);
|
|
20
|
-
candidates.push(`${pkgRoot}/dist/src/${action}.js`);
|
|
21
|
-
candidates.push(`${pkgRoot}/src/${action}.ts`);
|
|
22
|
-
}
|
|
23
|
-
} catch {}
|
|
35
|
+
candidates.push(...publishedActionCandidates(action));
|
|
24
36
|
for (const candidate of candidates)
|
|
25
37
|
if (await Bun.file(candidate).exists())
|
|
26
38
|
return candidate;
|
|
@@ -86,11 +98,16 @@ export async function runActions(actions, options) {
|
|
|
86
98
|
for (const action of actions)
|
|
87
99
|
if (!hasAction(action))
|
|
88
100
|
return err(`The specified action "${action}" does not exist`);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
return await runActionSequence(actions, options);
|
|
102
|
+
}
|
|
103
|
+
export async function runActionSequence(actions, options, runner = runAction) {
|
|
104
|
+
let result;
|
|
105
|
+
for (const action of actions) {
|
|
106
|
+
result = await runner(action, options);
|
|
107
|
+
if (result?.isErr)
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
94
111
|
}
|
|
95
112
|
export function hasAction(action) {
|
|
96
113
|
const userActionPatterns = [
|
|
@@ -103,6 +120,7 @@ export function hasAction(action) {
|
|
|
103
120
|
], actionPatterns = [`src/${action}.ts`, `src/${action}`, `${action}.ts`, `${action}`];
|
|
104
121
|
return [
|
|
105
122
|
...userActionPatterns.map((pattern) => p.userActionsPath(pattern)),
|
|
106
|
-
...actionPatterns.map((pattern) => p.actionsPath(pattern))
|
|
123
|
+
...actionPatterns.map((pattern) => p.actionsPath(pattern)),
|
|
124
|
+
...publishedActionCandidates(action)
|
|
107
125
|
].some((candidate) => existsSync(candidate));
|
|
108
126
|
}
|
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.139",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"prepublishOnly": "bun run build"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@stacksjs/config": "0.70.
|
|
65
|
+
"@stacksjs/config": "0.70.139",
|
|
66
66
|
"@stacksjs/bumpx": "^0.2.6",
|
|
67
67
|
"@stacksjs/bunpress": "^0.1.12",
|
|
68
68
|
"@stacksjs/logsmith": "^0.2.3",
|
|
@@ -70,23 +70,23 @@
|
|
|
70
70
|
"@stacksjs/ts-md": "^0.1.1"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@stacksjs/api": "0.70.
|
|
74
|
-
"@stacksjs/cli": "0.70.
|
|
75
|
-
"@stacksjs/config": "0.70.
|
|
76
|
-
"@stacksjs/database": "0.70.
|
|
73
|
+
"@stacksjs/api": "0.70.139",
|
|
74
|
+
"@stacksjs/cli": "0.70.139",
|
|
75
|
+
"@stacksjs/config": "0.70.139",
|
|
76
|
+
"@stacksjs/database": "0.70.139",
|
|
77
77
|
"@stacksjs/tlsx": "^0.13.2",
|
|
78
78
|
"better-dx": "^0.2.17",
|
|
79
|
-
"@stacksjs/dns": "0.70.
|
|
80
|
-
"@stacksjs/enums": "0.70.
|
|
81
|
-
"@stacksjs/env": "0.70.
|
|
82
|
-
"@stacksjs/error-handling": "0.70.
|
|
83
|
-
"@stacksjs/logging": "0.70.
|
|
84
|
-
"@stacksjs/path": "0.70.
|
|
85
|
-
"@stacksjs/security": "0.70.
|
|
86
|
-
"@stacksjs/storage": "0.70.
|
|
87
|
-
"@stacksjs/strings": "0.70.
|
|
88
|
-
"@stacksjs/utils": "0.70.
|
|
89
|
-
"@stacksjs/validation": "0.70.
|
|
79
|
+
"@stacksjs/dns": "0.70.139",
|
|
80
|
+
"@stacksjs/enums": "0.70.139",
|
|
81
|
+
"@stacksjs/env": "0.70.139",
|
|
82
|
+
"@stacksjs/error-handling": "0.70.139",
|
|
83
|
+
"@stacksjs/logging": "0.70.139",
|
|
84
|
+
"@stacksjs/path": "0.70.139",
|
|
85
|
+
"@stacksjs/security": "0.70.139",
|
|
86
|
+
"@stacksjs/storage": "0.70.139",
|
|
87
|
+
"@stacksjs/strings": "0.70.139",
|
|
88
|
+
"@stacksjs/utils": "0.70.139",
|
|
89
|
+
"@stacksjs/validation": "0.70.139"
|
|
90
90
|
},
|
|
91
91
|
"peerDependencies": {
|
|
92
92
|
"pickier": "^0.1.35"
|