@eventra_dev/eventra-cli 0.0.10 → 0.0.12
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/commands/init.js +9 -2
- package/dist/commands/send.js +5 -4
- package/package.json +1 -1
- package/src/commands/init.ts +9 -2
- package/src/commands/send.ts +7 -8
- package/src/types.ts +1 -0
package/dist/commands/init.js
CHANGED
|
@@ -9,12 +9,18 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
9
9
|
const config_1 = require("../utils/config");
|
|
10
10
|
async function init() {
|
|
11
11
|
console.log(chalk_1.default.blue("Initializing Eventra..."));
|
|
12
|
-
// API KEY
|
|
13
|
-
const { apiKey } = await inquirer_1.default.prompt([
|
|
12
|
+
// API KEY ENDPOINT
|
|
13
|
+
const { apiKey, endpoint } = await inquirer_1.default.prompt([
|
|
14
14
|
{
|
|
15
15
|
type: "input",
|
|
16
16
|
name: "apiKey",
|
|
17
17
|
message: "API Key (optional):"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "input",
|
|
21
|
+
name: "endpoint",
|
|
22
|
+
message: "Custom endpoint (optional):",
|
|
23
|
+
default: "https://api.eventra.dev/api/v1/cli/events"
|
|
18
24
|
}
|
|
19
25
|
]);
|
|
20
26
|
console.log(chalk_1.default.gray("\nEventra automatically detects:"));
|
|
@@ -89,6 +95,7 @@ async function init() {
|
|
|
89
95
|
}
|
|
90
96
|
const config = {
|
|
91
97
|
apiKey,
|
|
98
|
+
endpoint,
|
|
92
99
|
events: [],
|
|
93
100
|
wrappers,
|
|
94
101
|
functionWrappers,
|
package/dist/commands/send.js
CHANGED
|
@@ -8,10 +8,11 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
9
9
|
const config_1 = require("../utils/config");
|
|
10
10
|
const package_json_1 = __importDefault(require("../../package.json"));
|
|
11
|
-
const EVENTRA_ENDPOINT = process.env.EVENTRA_ENDPOINT ?? "";
|
|
12
11
|
const CLI_VERSION = package_json_1.default.version;
|
|
13
12
|
async function send() {
|
|
14
13
|
const config = await (0, config_1.loadConfig)();
|
|
14
|
+
const endpoint = config?.endpoint ||
|
|
15
|
+
process.env.EVENTRA_ENDPOINT;
|
|
15
16
|
if (!config) {
|
|
16
17
|
console.log(chalk_1.default.red("eventra.json not found. Run 'eventra init'"));
|
|
17
18
|
return;
|
|
@@ -40,14 +41,14 @@ async function send() {
|
|
|
40
41
|
console.log(chalk_1.default.red("API key required"));
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
|
-
if (!
|
|
44
|
-
console.log(chalk_1.default.red("
|
|
44
|
+
if (!endpoint) {
|
|
45
|
+
console.log(chalk_1.default.red("Endpoint not configured"));
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
console.log("");
|
|
48
49
|
console.log(chalk_1.default.blue(`Sending ${config.events.length} events...`));
|
|
49
50
|
try {
|
|
50
|
-
const res = await fetch(
|
|
51
|
+
const res = await fetch(endpoint, {
|
|
51
52
|
method: "POST",
|
|
52
53
|
headers: {
|
|
53
54
|
"Content-Type": "application/json",
|
package/package.json
CHANGED
package/src/commands/init.ts
CHANGED
|
@@ -9,14 +9,20 @@ export async function init() {
|
|
|
9
9
|
chalk.blue("Initializing Eventra...")
|
|
10
10
|
);
|
|
11
11
|
|
|
12
|
-
// API KEY
|
|
13
|
-
const { apiKey } =
|
|
12
|
+
// API KEY ENDPOINT
|
|
13
|
+
const { apiKey, endpoint } =
|
|
14
14
|
await inquirer.prompt([
|
|
15
15
|
{
|
|
16
16
|
type: "input",
|
|
17
17
|
name: "apiKey",
|
|
18
18
|
message:
|
|
19
19
|
"API Key (optional):"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: "input",
|
|
23
|
+
name: "endpoint",
|
|
24
|
+
message: "Custom endpoint (optional):",
|
|
25
|
+
default: "https://api.eventra.dev/api/v1/cli/events"
|
|
20
26
|
}
|
|
21
27
|
]);
|
|
22
28
|
|
|
@@ -135,6 +141,7 @@ export async function init() {
|
|
|
135
141
|
|
|
136
142
|
const config = {
|
|
137
143
|
apiKey,
|
|
144
|
+
endpoint,
|
|
138
145
|
events: [],
|
|
139
146
|
wrappers,
|
|
140
147
|
functionWrappers,
|
package/src/commands/send.ts
CHANGED
|
@@ -7,14 +7,15 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import pkg from "../../package.json";
|
|
9
9
|
|
|
10
|
-
const EVENTRA_ENDPOINT =
|
|
11
|
-
process.env.EVENTRA_ENDPOINT ?? "";
|
|
12
|
-
|
|
13
10
|
const CLI_VERSION = pkg.version;
|
|
14
11
|
|
|
15
12
|
export async function send() {
|
|
16
13
|
const config = await loadConfig();
|
|
17
14
|
|
|
15
|
+
const endpoint =
|
|
16
|
+
config?.endpoint ||
|
|
17
|
+
process.env.EVENTRA_ENDPOINT;
|
|
18
|
+
|
|
18
19
|
if (!config) {
|
|
19
20
|
console.log(
|
|
20
21
|
chalk.red(
|
|
@@ -66,11 +67,9 @@ export async function send() {
|
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
if (!
|
|
70
|
+
if (!endpoint) {
|
|
70
71
|
console.log(
|
|
71
|
-
chalk.red(
|
|
72
|
-
"EVENTRA_ENDPOINT not configured"
|
|
73
|
-
)
|
|
72
|
+
chalk.red("Endpoint not configured")
|
|
74
73
|
);
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
@@ -84,7 +83,7 @@ export async function send() {
|
|
|
84
83
|
|
|
85
84
|
try {
|
|
86
85
|
const res = await fetch(
|
|
87
|
-
|
|
86
|
+
endpoint,
|
|
88
87
|
{
|
|
89
88
|
method: "POST",
|
|
90
89
|
headers: {
|