@editframe/cli 0.8.0-beta.4 → 0.8.0-beta.5
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/VERSION.d.ts +1 -1
- package/dist/VERSION.js +1 -1
- package/dist/commands/webhook.d.ts +7 -0
- package/dist/commands/webhook.js +62 -0
- package/dist/index.js +1 -0
- package/package.json +5 -5
- package/src/commands/webhook.ts +77 -0
package/dist/VERSION.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.8.0-beta.
|
|
1
|
+
export declare const VERSION = "0.8.0-beta.5";
|
package/dist/VERSION.js
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import debug from "debug";
|
|
5
|
+
import { input, select } from "@inquirer/prompts";
|
|
6
|
+
import { getClient } from "../utils/index.js";
|
|
7
|
+
const log = debug("ef:cli:auth");
|
|
8
|
+
const topics = [
|
|
9
|
+
"render.created",
|
|
10
|
+
"render.rendering",
|
|
11
|
+
"render.pending",
|
|
12
|
+
"render.failed",
|
|
13
|
+
"render.completed"
|
|
14
|
+
];
|
|
15
|
+
const testWebhookURL = async ({
|
|
16
|
+
webhookURL,
|
|
17
|
+
topic
|
|
18
|
+
}) => {
|
|
19
|
+
const response = await getClient().authenticatedFetch(
|
|
20
|
+
"/api/v1/test_webhook",
|
|
21
|
+
{
|
|
22
|
+
method: "POST",
|
|
23
|
+
body: JSON.stringify({
|
|
24
|
+
webhookURL,
|
|
25
|
+
topic
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
console.log(response);
|
|
30
|
+
return response.json();
|
|
31
|
+
};
|
|
32
|
+
const webhookCommand = program.command("webhook").description("Test webhook URL with a topic").option("-u, --webhookURL <webhookURL>", "Webhook URL").addOption(new Option("-t, --topic <topic>", "Topic").choices(topics)).action(async () => {
|
|
33
|
+
const options = webhookCommand.opts();
|
|
34
|
+
log("Options:", options);
|
|
35
|
+
let { webhookURL, topic } = options;
|
|
36
|
+
if (!webhookURL) {
|
|
37
|
+
const answer = await input({ message: "Enter a webhook URL:" });
|
|
38
|
+
webhookURL = answer;
|
|
39
|
+
}
|
|
40
|
+
if (!topic) {
|
|
41
|
+
const answer = await select({
|
|
42
|
+
message: "Select a topic:",
|
|
43
|
+
choices: [...topics.map((topic2) => ({ title: topic2, value: topic2 }))]
|
|
44
|
+
});
|
|
45
|
+
topic = answer;
|
|
46
|
+
}
|
|
47
|
+
const spinner = ora("Testing...").start();
|
|
48
|
+
try {
|
|
49
|
+
const apiData = await testWebhookURL({ webhookURL, topic });
|
|
50
|
+
spinner.succeed("Webhook URL is working! 🎉");
|
|
51
|
+
process.stderr.write(chalk.green(`${apiData.message}
|
|
52
|
+
`));
|
|
53
|
+
} catch (error) {
|
|
54
|
+
spinner.fail("Webhook URL is not working!");
|
|
55
|
+
process.stderr.write(error?.message);
|
|
56
|
+
process.stderr.write("\n");
|
|
57
|
+
log("Error:", error);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
export {
|
|
61
|
+
testWebhookURL
|
|
62
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import "./commands/preview.js";
|
|
|
9
9
|
import "./commands/process.js";
|
|
10
10
|
import "./commands/process-file.js";
|
|
11
11
|
import "./commands/check.js";
|
|
12
|
+
import "./commands/webhook.js";
|
|
12
13
|
program.name("editframe").addOption(new Option("-t, --token <token>", "API Token").env("EF_TOKEN")).addOption(
|
|
13
14
|
new Option("--ef-host <host>", "Editframe Host").env("EF_HOST").default("https://editframe.dev")
|
|
14
15
|
).addOption(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/cli",
|
|
3
|
-
"version": "0.8.0-beta.
|
|
3
|
+
"version": "0.8.0-beta.5",
|
|
4
4
|
"description": "Command line interface for EditFrame",
|
|
5
5
|
"bin": {
|
|
6
6
|
"editframe": "./dist/index.js"
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"vite-tsconfig-paths": "^4.3.2"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@editframe/api": "0.8.0-beta.
|
|
27
|
-
"@editframe/assets": "0.8.0-beta.
|
|
28
|
-
"@editframe/elements": "0.8.0-beta.
|
|
29
|
-
"@editframe/vite-plugin": "0.8.0-beta.
|
|
26
|
+
"@editframe/api": "0.8.0-beta.5",
|
|
27
|
+
"@editframe/assets": "0.8.0-beta.5",
|
|
28
|
+
"@editframe/elements": "0.8.0-beta.5",
|
|
29
|
+
"@editframe/vite-plugin": "0.8.0-beta.5",
|
|
30
30
|
"axios": "^1.6.8",
|
|
31
31
|
"chalk": "^5.3.0",
|
|
32
32
|
"commander": "^12.0.0",
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { program, Option } from "commander";
|
|
2
|
+
import ora from "ora";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import debug from "debug";
|
|
5
|
+
import { input, select } from "@inquirer/prompts";
|
|
6
|
+
|
|
7
|
+
import { getClient } from "../utils/index.ts";
|
|
8
|
+
|
|
9
|
+
const log = debug("ef:cli:auth");
|
|
10
|
+
|
|
11
|
+
export interface APITestWebhhokResult {
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
const topics = [
|
|
15
|
+
"render.created",
|
|
16
|
+
"render.rendering",
|
|
17
|
+
"render.pending",
|
|
18
|
+
"render.failed",
|
|
19
|
+
"render.completed",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const testWebhookURL = async ({
|
|
23
|
+
webhookURL,
|
|
24
|
+
topic,
|
|
25
|
+
}: {
|
|
26
|
+
webhookURL: string;
|
|
27
|
+
topic: string;
|
|
28
|
+
}) => {
|
|
29
|
+
const response = await getClient().authenticatedFetch(
|
|
30
|
+
"/api/v1/test_webhook",
|
|
31
|
+
{
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
webhookURL,
|
|
35
|
+
topic,
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
console.log(response);
|
|
40
|
+
return response.json() as Promise<APITestWebhhokResult>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const webhookCommand = program
|
|
44
|
+
.command("webhook")
|
|
45
|
+
.description("Test webhook URL with a topic")
|
|
46
|
+
.option("-u, --webhookURL <webhookURL>", "Webhook URL")
|
|
47
|
+
.addOption(new Option("-t, --topic <topic>", "Topic").choices(topics))
|
|
48
|
+
.action(async () => {
|
|
49
|
+
const options = webhookCommand.opts();
|
|
50
|
+
log("Options:", options);
|
|
51
|
+
let { webhookURL, topic } = options;
|
|
52
|
+
|
|
53
|
+
if (!webhookURL) {
|
|
54
|
+
const answer = await input({ message: "Enter a webhook URL:" });
|
|
55
|
+
webhookURL = answer;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!topic) {
|
|
59
|
+
const answer = await select({
|
|
60
|
+
message: "Select a topic:",
|
|
61
|
+
choices: [...topics.map((topic) => ({ title: topic, value: topic }))],
|
|
62
|
+
});
|
|
63
|
+
topic = answer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const spinner = ora("Testing...").start();
|
|
67
|
+
try {
|
|
68
|
+
const apiData = await testWebhookURL({ webhookURL, topic });
|
|
69
|
+
spinner.succeed("Webhook URL is working! 🎉");
|
|
70
|
+
process.stderr.write(chalk.green(`${apiData.message}\n`));
|
|
71
|
+
} catch (error: any) {
|
|
72
|
+
spinner.fail("Webhook URL is not working!");
|
|
73
|
+
process.stderr.write(error?.message);
|
|
74
|
+
process.stderr.write("\n");
|
|
75
|
+
log("Error:", error);
|
|
76
|
+
}
|
|
77
|
+
});
|