@eventra_dev/eventra-cli 0.0.9 → 0.0.11

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.
@@ -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/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,
@@ -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 (!EVENTRA_ENDPOINT) {
44
- console.log(chalk_1.default.red("EVENTRA_ENDPOINT not configured"));
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(EVENTRA_ENDPOINT, {
51
+ const res = await fetch(endpoint, {
51
52
  method: "POST",
52
53
  headers: {
53
54
  "Content-Type": "application/json",
@@ -27,6 +27,7 @@ async function sync() {
27
27
  const project = new ts_morph_1.Project();
28
28
  const events = new Set();
29
29
  const aliases = config.aliases ?? {};
30
+ const asked = new Set();
30
31
  const files = await (0, fast_glob_1.default)(config.sync.include, {
31
32
  ignore: config.sync.exclude
32
33
  });
@@ -56,19 +57,20 @@ async function sync() {
56
57
  continue;
57
58
  }
58
59
  // dynamic event
59
- if (dynamic) {
60
+ if (dynamic && !asked.has(value)) {
60
61
  console.log(chalk_1.default.yellow("\nDynamic event detected:"));
61
62
  console.log(chalk_1.default.gray(value));
62
63
  const { name } = await inquirer_1.default.prompt([
63
64
  {
64
65
  type: "input",
65
66
  name: "name",
66
- message: "Enter event name:",
67
- validate: (v) => v
68
- ? true
69
- : "Required"
67
+ message: "Enter event name (or type 'skip'):"
70
68
  }
71
69
  ]);
70
+ asked.add(value);
71
+ if (!name || name === "skip") {
72
+ continue;
73
+ }
72
74
  aliases[value] = name;
73
75
  events.add(name);
74
76
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventra_dev/eventra-cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Eventra CLI",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -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/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,
@@ -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 (!EVENTRA_ENDPOINT) {
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
- EVENTRA_ENDPOINT,
86
+ endpoint,
88
87
  {
89
88
  method: "POST",
90
89
  headers: {
@@ -40,6 +40,8 @@ export async function sync() {
40
40
  const aliases =
41
41
  config.aliases ?? {};
42
42
 
43
+ const asked = new Set<string>()
44
+
43
45
  const files = await fg(
44
46
  config.sync.include,
45
47
  {
@@ -102,7 +104,7 @@ export async function sync() {
102
104
  }
103
105
 
104
106
  // dynamic event
105
- if (dynamic) {
107
+ if (dynamic && !asked.has(value)) {
106
108
  console.log(
107
109
  chalk.yellow(
108
110
  "\nDynamic event detected:"
@@ -119,14 +121,16 @@ export async function sync() {
119
121
  type: "input",
120
122
  name: "name",
121
123
  message:
122
- "Enter event name:",
123
- validate: (v) =>
124
- v
125
- ? true
126
- : "Required"
124
+ "Enter event name (or type 'skip'):"
127
125
  }
128
126
  ]);
129
127
 
128
+ asked.add(value);
129
+
130
+ if (!name || name === "skip") {
131
+ continue;
132
+ }
133
+
130
134
  aliases[value] = name;
131
135
 
132
136
  events.add(name);
package/src/types.ts CHANGED
@@ -10,6 +10,7 @@ export type FunctionWrapper = {
10
10
 
11
11
  export type EventraConfig = {
12
12
  apiKey?: string;
13
+ endpoint?: string;
13
14
  events: string[];
14
15
  wrappers: ComponentWrapper[];
15
16
  functionWrappers: FunctionWrapper[];