@eventra_dev/eventra-cli 0.0.1

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/src/index.ts ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Command } from "commander";
4
+
5
+ const program = new Command();
6
+
7
+ program
8
+ .name("eventra")
9
+ .description("Eventra CLI")
10
+ .version("0.0.1");
11
+
12
+ program
13
+ .command("init")
14
+ .description("Initialize Eventra")
15
+ .action(async () => {
16
+ const { init } = await import("./commands/init");
17
+ await init();
18
+ });
19
+
20
+ program
21
+ .command("sync")
22
+ .description("Sync events")
23
+ .action(async () => {
24
+ const { sync } = await import("./commands/sync");
25
+ await sync();
26
+ });
27
+
28
+ program
29
+ .command("send")
30
+ .description("Send events")
31
+ .action(async () => {
32
+ const { send } = await import("./commands/send");
33
+ await send();
34
+ });
35
+
36
+ program.parse();
@@ -0,0 +1,53 @@
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+
4
+ export const CONFIG_NAME = "eventra.json";
5
+
6
+ export function normalizeConfig(config: any) {
7
+ return {
8
+ apiKey: config.apiKey ?? "",
9
+ events: config.events ?? [],
10
+ wrappers: config.wrappers ?? [],
11
+ sync: config.sync ?? {
12
+ include: ["**/*.{ts,tsx,js,jsx}"],
13
+ exclude: [
14
+ "node_modules",
15
+ "dist",
16
+ ".next",
17
+ ".git"
18
+ ]
19
+ }
20
+ };
21
+ }
22
+
23
+ export async function loadConfig() {
24
+ const configPath = path.join(
25
+ process.cwd(),
26
+ CONFIG_NAME
27
+ );
28
+
29
+ if (!(await fs.pathExists(configPath))) {
30
+ return null;
31
+ }
32
+
33
+ const config = await fs.readJSON(configPath);
34
+
35
+ return normalizeConfig(config);
36
+ }
37
+
38
+ export async function saveConfig(config: any) {
39
+ const configPath = path.join(
40
+ process.cwd(),
41
+ CONFIG_NAME
42
+ );
43
+
44
+ const normalized = normalizeConfig(config);
45
+
46
+ await fs.writeJSON(
47
+ configPath,
48
+ normalized,
49
+ {
50
+ spaces: 2
51
+ }
52
+ );
53
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "CommonJS",
5
+ "outDir": "dist",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "types": ["node"]
10
+ },
11
+ "include": ["src"]
12
+ }