@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/.github/workflows/release.yml +40 -0
- package/LICENSE +9 -0
- package/README.md +310 -0
- package/dist/commands/init.js +42 -0
- package/dist/commands/send.js +67 -0
- package/dist/commands/sync.js +216 -0
- package/dist/index.js +64 -0
- package/dist/utils/config.js +43 -0
- package/package.json +30 -0
- package/src/commands/init.ts +60 -0
- package/src/commands/send.ts +124 -0
- package/src/commands/sync.ts +397 -0
- package/src/index.ts +36 -0
- package/src/utils/config.ts +53 -0
- package/tsconfig.json +12 -0
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
|
+
}
|