@donkeylabs/server 0.1.0

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/cli/donkeylabs ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * @donkeylabs/server CLI
4
+ *
5
+ * Commands:
6
+ * init Initialize a new project
7
+ * generate Generate types (registry, context, client)
8
+ * plugin Plugin management (create, list)
9
+ */
10
+
11
+ import { parseArgs } from "node:util";
12
+ import pc from "picocolors";
13
+
14
+ const { positionals, values } = parseArgs({
15
+ args: process.argv.slice(2),
16
+ options: {
17
+ help: { type: "boolean", short: "h" },
18
+ version: { type: "boolean", short: "v" },
19
+ },
20
+ allowPositionals: true,
21
+ });
22
+
23
+ const command = positionals[0];
24
+
25
+ function printHelp() {
26
+ console.log(`
27
+ ${pc.bold("@donkeylabs/server")} - Type-safe plugin system for Bun
28
+
29
+ ${pc.bold("Usage:")}
30
+ donkeylabs Interactive menu
31
+ donkeylabs <command> [options]
32
+
33
+ ${pc.bold("Commands:")}
34
+ ${pc.cyan("init")} Initialize a new project
35
+ ${pc.cyan("generate")} Generate types (registry, context, client)
36
+ ${pc.cyan("plugin")} Plugin management
37
+
38
+ ${pc.bold("Options:")}
39
+ -h, --help Show this help message
40
+ -v, --version Show version number
41
+
42
+ ${pc.bold("Examples:")}
43
+ donkeylabs # Interactive menu
44
+ donkeylabs init
45
+ donkeylabs generate
46
+ donkeylabs plugin create myPlugin
47
+ `);
48
+ }
49
+
50
+ function printVersion() {
51
+ // Read from package.json
52
+ console.log("0.1.0");
53
+ }
54
+
55
+ async function main() {
56
+ if (values.help) {
57
+ printHelp();
58
+ process.exit(0);
59
+ }
60
+
61
+ if (values.version) {
62
+ printVersion();
63
+ process.exit(0);
64
+ }
65
+
66
+ // No command provided - launch interactive mode
67
+ if (!command) {
68
+ const { interactiveCommand } = await import("./commands/interactive");
69
+ await interactiveCommand();
70
+ return;
71
+ }
72
+
73
+ switch (command) {
74
+ case "init":
75
+ const { initCommand } = await import("./commands/init");
76
+ await initCommand(positionals.slice(1));
77
+ break;
78
+
79
+ case "generate":
80
+ case "gen":
81
+ const { generateCommand } = await import("./commands/generate");
82
+ await generateCommand(positionals.slice(1));
83
+ break;
84
+
85
+ case "plugin":
86
+ const { pluginCommand } = await import("./commands/plugin");
87
+ await pluginCommand(positionals.slice(1));
88
+ break;
89
+
90
+ default:
91
+ console.error(pc.red(`Unknown command: ${command}`));
92
+ console.log(`Run ${pc.cyan("donkeylabs --help")} for available commands.`);
93
+ process.exit(1);
94
+ }
95
+ }
96
+
97
+ main().catch((error) => {
98
+ console.error(pc.red("Error:"), error.message);
99
+ process.exit(1);
100
+ });
package/cli/index.ts ADDED
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * @donkeylabs/server CLI
4
+ *
5
+ * Commands:
6
+ * init Initialize a new project
7
+ * generate Generate types (registry, context, client)
8
+ * plugin Plugin management (create, list)
9
+ */
10
+
11
+ import { parseArgs } from "node:util";
12
+ import pc from "picocolors";
13
+
14
+ const { positionals, values } = parseArgs({
15
+ args: process.argv.slice(2),
16
+ options: {
17
+ help: { type: "boolean", short: "h" },
18
+ version: { type: "boolean", short: "v" },
19
+ },
20
+ allowPositionals: true,
21
+ });
22
+
23
+ const command = positionals[0];
24
+
25
+ function printHelp() {
26
+ console.log(`
27
+ ${pc.bold("@donkeylabs/server")} - Type-safe plugin system for Bun
28
+
29
+ ${pc.bold("Usage:")}
30
+ donkeylabs Interactive menu
31
+ donkeylabs <command> [options]
32
+
33
+ ${pc.bold("Commands:")}
34
+ ${pc.cyan("init")} Initialize a new project
35
+ ${pc.cyan("generate")} Generate types (registry, context, client)
36
+ ${pc.cyan("plugin")} Plugin management
37
+
38
+ ${pc.bold("Options:")}
39
+ -h, --help Show this help message
40
+ -v, --version Show version number
41
+
42
+ ${pc.bold("Examples:")}
43
+ donkeylabs # Interactive menu
44
+ donkeylabs init
45
+ donkeylabs generate
46
+ donkeylabs plugin create myPlugin
47
+ `);
48
+ }
49
+
50
+ function printVersion() {
51
+ // Read from package.json
52
+ console.log("0.1.0");
53
+ }
54
+
55
+ async function main() {
56
+ if (values.help) {
57
+ printHelp();
58
+ process.exit(0);
59
+ }
60
+
61
+ if (values.version) {
62
+ printVersion();
63
+ process.exit(0);
64
+ }
65
+
66
+ // No command provided - launch interactive mode
67
+ if (!command) {
68
+ const { interactiveCommand } = await import("./commands/interactive");
69
+ await interactiveCommand();
70
+ return;
71
+ }
72
+
73
+ switch (command) {
74
+ case "init":
75
+ const { initCommand } = await import("./commands/init");
76
+ await initCommand(positionals.slice(1));
77
+ break;
78
+
79
+ case "generate":
80
+ case "gen":
81
+ const { generateCommand } = await import("./commands/generate");
82
+ await generateCommand(positionals.slice(1));
83
+ break;
84
+
85
+ case "plugin":
86
+ const { pluginCommand } = await import("./commands/plugin");
87
+ await pluginCommand(positionals.slice(1));
88
+ break;
89
+
90
+ default:
91
+ console.error(pc.red(`Unknown command: ${command}`));
92
+ console.log(`Run ${pc.cyan("donkeylabs --help")} for available commands.`);
93
+ process.exit(1);
94
+ }
95
+ }
96
+
97
+ main().catch((error) => {
98
+ console.error(pc.red("Error:"), error.message);
99
+ process.exit(1);
100
+ });