@stacksjs/actions 0.46.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/package-json.mjs +1 -1
- package/dist/helpers/utils.d.ts +2 -1
- package/dist/helpers/utils.mjs +16 -2
- package/dist/key-generate.d.ts +1 -0
- package/dist/key-generate.mjs +8 -0
- 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 +14 -13
- package/dist/key.d.ts +0 -10
- package/dist/key.mjs +0 -31
|
@@ -2,7 +2,7 @@ import { log } from "@stacksjs/logging";
|
|
|
2
2
|
import { writeTextFile } from "@stacksjs/storage";
|
|
3
3
|
import { packageJsonPath } from "@stacksjs/path";
|
|
4
4
|
import { library } from "@stacksjs/config";
|
|
5
|
-
import { packageManager } from "../../package.json"
|
|
5
|
+
import { packageManager } from "../../package.json";
|
|
6
6
|
export async function generatePackageJson(type) {
|
|
7
7
|
let name, description, directory, keywords, config, prettyName;
|
|
8
8
|
if (type === "vue-components") {
|
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) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { runCommand } from "@stacksjs/cli";
|
|
2
|
+
import { isFile } from "@stacksjs/storage";
|
|
3
|
+
import { setEnvValue } from "@stacksjs/utils";
|
|
4
|
+
import { options } from "kolorist";
|
|
5
|
+
import { generateAppKey } from "@stacksjs/security";
|
|
6
|
+
if (!isFile(".env"))
|
|
7
|
+
await runCommand("cp .env.example .env", { ...options, cwd: projectPath() });
|
|
8
|
+
await setEnvValue("APP_KEY", await generateAppKey());
|
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,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"packageManager": "pnpm@7.
|
|
4
|
+
"version": "0.48.3",
|
|
5
|
+
"packageManager": "pnpm@7.21.0",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"license": "MIT",
|
|
@@ -37,27 +37,28 @@
|
|
|
37
37
|
],
|
|
38
38
|
"engines": {
|
|
39
39
|
"node": ">=v18.12.1",
|
|
40
|
-
"pnpm": ">=7.
|
|
40
|
+
"pnpm": ">=7.21.0"
|
|
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/
|
|
50
|
-
"@stacksjs/
|
|
51
|
-
"@stacksjs/
|
|
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"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"esno": "^0.16.3",
|
|
55
|
-
"@stacksjs/strings": "0.
|
|
56
|
+
"@stacksjs/strings": "0.48.3"
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"mkdist": "^1.0.0",
|
|
59
60
|
"typescript": "^4.9.4",
|
|
60
|
-
"@stacksjs/testing": "0.
|
|
61
|
+
"@stacksjs/testing": "0.48.3"
|
|
61
62
|
},
|
|
62
63
|
"scripts": {
|
|
63
64
|
"build": "mkdist -d",
|
package/dist/key.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CliOptions as KeyOptions } from '@stacksjs/types';
|
|
2
|
-
export declare function invoke(options: KeyOptions): Promise<void>;
|
|
3
|
-
/**
|
|
4
|
-
* An alias of the invoke method.
|
|
5
|
-
* @param options
|
|
6
|
-
* @returns
|
|
7
|
-
*/
|
|
8
|
-
export declare function key(options: KeyOptions): Promise<void>;
|
|
9
|
-
export declare function generate(options: KeyOptions): Promise<boolean>;
|
|
10
|
-
export declare function generateAppKey(): Promise<string>;
|
package/dist/key.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { getRandomValues } from "node:crypto";
|
|
2
|
-
import { log, runCommand } from "@stacksjs/cli";
|
|
3
|
-
import { setEnvValue } from "@stacksjs/utils";
|
|
4
|
-
import { isFile } from "@stacksjs/storage";
|
|
5
|
-
import utf8 from "crypto-js/enc-utf8";
|
|
6
|
-
import base64 from "crypto-js/enc-base64";
|
|
7
|
-
export async function invoke(options) {
|
|
8
|
-
await generate(options);
|
|
9
|
-
}
|
|
10
|
-
export async function key(options) {
|
|
11
|
-
return invoke(options);
|
|
12
|
-
}
|
|
13
|
-
export async function generate(options) {
|
|
14
|
-
try {
|
|
15
|
-
log.info("Setting random application key.");
|
|
16
|
-
if (!isFile(".env"))
|
|
17
|
-
await runCommand("cp .env.example .env", options);
|
|
18
|
-
await setEnvValue("APP_KEY", await generateAppKey());
|
|
19
|
-
log.success("Application key set");
|
|
20
|
-
return true;
|
|
21
|
-
} catch (error) {
|
|
22
|
-
log.error("There was an error generating your key.", error);
|
|
23
|
-
process.exit();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export async function generateAppKey() {
|
|
27
|
-
const random = getRandomValues(new Uint8Array(32));
|
|
28
|
-
const encodedWord = utf8.parse(random.toString());
|
|
29
|
-
const key2 = base64.stringify(encodedWord);
|
|
30
|
-
return `base64:${key2}`;
|
|
31
|
-
}
|