@stacksjs/actions 0.47.4 → 0.48.3
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 -1
- package/dist/helpers/utils.mjs +16 -2
- package/dist/make.d.ts +1 -1
- package/dist/make.mjs +30 -4
- package/dist/test-coverage.mjs +1 -1
- package/dist/test-feature.d.ts +1 -0
- package/dist/test-feature.mjs +4 -0
- package/dist/test-unit.d.ts +1 -0
- package/dist/test-unit.mjs +4 -0
- package/package.json +12 -12
package/dist/helpers/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CliOptions, CommandResult } from '@stacksjs/types';
|
|
2
2
|
import type { Err, Result } from '@stacksjs/error-handling';
|
|
3
|
+
export type ActionResult = Promise<Result<CommandResult<string>, Error> | Result<CommandResult<string>, Error>[] | Err<CommandResult<string>, string>>;
|
|
3
4
|
/**
|
|
4
5
|
* Run an Action the Stacks way.
|
|
5
6
|
*
|
|
@@ -7,7 +8,7 @@ import type { Err, Result } from '@stacksjs/error-handling';
|
|
|
7
8
|
* @param options The options to pass to the command.
|
|
8
9
|
* @returns The result of the command.
|
|
9
10
|
*/
|
|
10
|
-
export declare function runAction(action: string, options?: CliOptions):
|
|
11
|
+
export declare function runAction(action: string, options?: CliOptions): ActionResult;
|
|
11
12
|
/**
|
|
12
13
|
* Run Actions the Stacks way.
|
|
13
14
|
*
|
package/dist/helpers/utils.mjs
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import storage from "@stacksjs/storage";
|
|
2
|
-
import { runCommand, runCommands } from "@stacksjs/cli";
|
|
2
|
+
import { log, runCommand, runCommands } from "@stacksjs/cli";
|
|
3
3
|
import { actionsPath, functionsPath } from "@stacksjs/path";
|
|
4
4
|
import { err } from "@stacksjs/error-handling";
|
|
5
|
+
const parseOptions = (options) => {
|
|
6
|
+
if (!options)
|
|
7
|
+
return "";
|
|
8
|
+
const parsedOptions = Object.entries(options).map(([key, value]) => {
|
|
9
|
+
if (typeof value === "boolean")
|
|
10
|
+
return `--${key}`;
|
|
11
|
+
else
|
|
12
|
+
return `--${key}=${value}`;
|
|
13
|
+
});
|
|
14
|
+
return parsedOptions.join(" ").replace("----=", "");
|
|
15
|
+
};
|
|
5
16
|
export async function runAction(action, options) {
|
|
6
17
|
if (!hasAction(action))
|
|
7
18
|
return err(`The specified action "${action}" does not exist.`);
|
|
8
|
-
const
|
|
19
|
+
const opts = parseOptions(options);
|
|
20
|
+
const cmd = `npx esno ${actionsPath(`${action}.ts ${opts}`)}`;
|
|
21
|
+
if (options?.debug)
|
|
22
|
+
log.info("Running command:", cmd, options);
|
|
9
23
|
return options?.shouldShowSpinner ? await runCommands([cmd], options) : await runCommand(cmd, options);
|
|
10
24
|
}
|
|
11
25
|
export async function runActions(actions, options) {
|
package/dist/make.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare function createFactory(options: MakeOptions): Promise<void>;
|
|
|
15
15
|
export declare function migration(options: MakeOptions): Promise<void>;
|
|
16
16
|
export declare function createMigration(options: MakeOptions): Promise<void>;
|
|
17
17
|
export declare function notification(options: MakeOptions): Promise<void>;
|
|
18
|
-
export declare function createNotification(options: MakeOptions): Promise<void>;
|
|
19
18
|
export declare function page(options: MakeOptions): Promise<void>;
|
|
20
19
|
export declare function createPage(options: MakeOptions): Promise<void>;
|
|
21
20
|
export declare function fx(options: MakeOptions): Promise<void>;
|
|
@@ -23,3 +22,4 @@ export declare function createFunction(options: MakeOptions): Promise<void>;
|
|
|
23
22
|
export declare function language(options: MakeOptions): Promise<void>;
|
|
24
23
|
export declare function createLanguage(options: MakeOptions): Promise<void>;
|
|
25
24
|
export declare function stack(options: MakeOptions): Promise<void>;
|
|
25
|
+
export declare function createNotification(options: MakeOptions): Promise<boolean>;
|
package/dist/make.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { italic, log, spawn } from "@stacksjs/cli";
|
|
2
|
-
import { writeTextFile } from "@stacksjs/storage";
|
|
2
|
+
import { createFolder, doesFolderExist, writeTextFile } from "@stacksjs/storage";
|
|
3
3
|
import { resolve } from "@stacksjs/path";
|
|
4
4
|
export async function invoke(options) {
|
|
5
5
|
if (options.component)
|
|
@@ -105,9 +105,6 @@ export async function notification(options) {
|
|
|
105
105
|
process.exit();
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
export async function createNotification(options) {
|
|
109
|
-
console.log("options", options);
|
|
110
|
-
}
|
|
111
108
|
export async function page(options) {
|
|
112
109
|
try {
|
|
113
110
|
const name = options.name;
|
|
@@ -199,3 +196,32 @@ export async function stack(options) {
|
|
|
199
196
|
process.exit();
|
|
200
197
|
}
|
|
201
198
|
}
|
|
199
|
+
export async function createNotification(options) {
|
|
200
|
+
const name = options.name;
|
|
201
|
+
try {
|
|
202
|
+
let importOption = "EmailOptions";
|
|
203
|
+
if (!doesFolderExist("notifications"))
|
|
204
|
+
await createFolder("./notifications");
|
|
205
|
+
if (options.chat)
|
|
206
|
+
importOption = "ChatOptions";
|
|
207
|
+
if (options.sms)
|
|
208
|
+
importOption = "SMSOptions";
|
|
209
|
+
await writeTextFile({
|
|
210
|
+
path: `./notifications/${name}.ts`,
|
|
211
|
+
data: `import type { ${importOption} } from '@stacksjs/types'
|
|
212
|
+
|
|
213
|
+
function content(): string {
|
|
214
|
+
return 'example'
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function send(): ${importOption} {
|
|
218
|
+
return {
|
|
219
|
+
content: content(),
|
|
220
|
+
}
|
|
221
|
+
}`
|
|
222
|
+
});
|
|
223
|
+
return true;
|
|
224
|
+
} catch (error) {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
package/dist/test-coverage.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NpmScript } from "@stacksjs/types";
|
|
2
2
|
import { runCommand } from "@stacksjs/cli";
|
|
3
3
|
import { frameworkPath } from "@stacksjs/path";
|
|
4
|
-
await runCommand(NpmScript.TestCoverage, {
|
|
4
|
+
await runCommand(NpmScript.TestCoverage, { cwd: frameworkPath(), debug: true });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.3",
|
|
5
5
|
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"markdown-it": "^13.0.1",
|
|
44
|
-
"vue-component-meta": "^1.0.
|
|
45
|
-
"@stacksjs/cli": "0.
|
|
46
|
-
"@stacksjs/config": "0.
|
|
47
|
-
"@stacksjs/logging": "0.
|
|
48
|
-
"@stacksjs/path": "0.
|
|
49
|
-
"@stacksjs/security": "0.
|
|
50
|
-
"@stacksjs/storage": "0.
|
|
51
|
-
"@stacksjs/types": "0.
|
|
52
|
-
"@stacksjs/utils": "0.
|
|
44
|
+
"vue-component-meta": "^1.0.19",
|
|
45
|
+
"@stacksjs/cli": "0.48.3",
|
|
46
|
+
"@stacksjs/config": "0.48.3",
|
|
47
|
+
"@stacksjs/logging": "0.48.3",
|
|
48
|
+
"@stacksjs/path": "0.48.3",
|
|
49
|
+
"@stacksjs/security": "0.48.3",
|
|
50
|
+
"@stacksjs/storage": "0.48.3",
|
|
51
|
+
"@stacksjs/types": "0.48.3",
|
|
52
|
+
"@stacksjs/utils": "0.48.3"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"esno": "^0.16.3",
|
|
56
|
-
"@stacksjs/strings": "0.
|
|
56
|
+
"@stacksjs/strings": "0.48.3"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"mkdist": "^1.0.0",
|
|
60
60
|
"typescript": "^4.9.4",
|
|
61
|
-
"@stacksjs/testing": "0.
|
|
61
|
+
"@stacksjs/testing": "0.48.3"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "mkdist -d",
|