@mcpak/cli 0.1.1 → 0.2.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.
Files changed (2) hide show
  1. package/dist/index.js +61 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { Command as Command12 } from "commander";
4
+ import { Command as Command14 } from "commander";
5
5
 
6
6
  // src/commands/health.ts
7
7
  import { Command } from "commander";
@@ -79,6 +79,33 @@ var RegistryClient = class {
79
79
  }
80
80
  return res.json();
81
81
  }
82
+ async register(username) {
83
+ const res = await fetch(`${this.baseUrl}/auth/register`, {
84
+ method: "POST",
85
+ headers: { "Content-Type": "application/json" },
86
+ body: JSON.stringify({ username })
87
+ });
88
+ if (!res.ok) {
89
+ const body = await res.json().catch(() => ({}));
90
+ throw new Error(
91
+ body.error ?? `Register failed: ${res.status}`
92
+ );
93
+ }
94
+ return res.json();
95
+ }
96
+ async whoami() {
97
+ const res = await fetch(`${this.baseUrl}/auth/whoami`, {
98
+ method: "POST",
99
+ headers: this.headers()
100
+ });
101
+ if (!res.ok) {
102
+ const body = await res.json().catch(() => ({}));
103
+ throw new Error(
104
+ body.error ?? `Whoami failed: ${res.status}`
105
+ );
106
+ }
107
+ return res.json();
108
+ }
82
109
  async checkUpdate(name, currentVersion) {
83
110
  const res = await fetch(
84
111
  `${this.baseUrl}/packages/${name}/check-update`,
@@ -688,8 +715,38 @@ Versions:`);
688
715
  }
689
716
  });
690
717
 
718
+ // src/commands/register.ts
719
+ import { Command as Command12 } from "commander";
720
+ var registerCommand = new Command12("register").description("Register a new account on the registry").argument("<username>", "Username to register").option("-r, --registry <url>", "Registry URL", DEFAULT_REGISTRY).action(async (username, opts) => {
721
+ if (!username || username.length < 2) {
722
+ throw new CliError("Username must be at least 2 characters.");
723
+ }
724
+ const client = new RegistryClient(opts.registry);
725
+ const result = await withSpinner(
726
+ "Registering\u2026",
727
+ () => client.register(username)
728
+ );
729
+ setToken(opts.registry, result.token);
730
+ success(`Registered as ${result.username}`);
731
+ info(`Token saved to ~/.mcpak/auth.json`);
732
+ });
733
+
734
+ // src/commands/whoami.ts
735
+ import { Command as Command13 } from "commander";
736
+ var whoamiCommand = new Command13("whoami").description("Show the currently logged-in user").option("-r, --registry <url>", "Registry URL", DEFAULT_REGISTRY).action(async (opts) => {
737
+ const token = getToken(opts.registry);
738
+ if (!token) {
739
+ throw new CliError(
740
+ "Not logged in. Run `mcpak register <username>` or `mcpak login --token <token>` first."
741
+ );
742
+ }
743
+ const client = new RegistryClient(opts.registry, token);
744
+ const result = await withSpinner("Checking\u2026", () => client.whoami());
745
+ success(`Logged in as ${result.username}`);
746
+ });
747
+
691
748
  // src/index.ts
692
- var program = new Command12();
749
+ var program = new Command14();
693
750
  program.name("mcpak").description("Package manager for MCP servers").version("0.0.1");
694
751
  program.addCommand(healthCommand);
695
752
  program.addCommand(installCommand);
@@ -702,4 +759,6 @@ program.addCommand(searchCommand);
702
759
  program.addCommand(loginCommand);
703
760
  program.addCommand(logoutCommand);
704
761
  program.addCommand(infoCommand);
762
+ program.addCommand(registerCommand);
763
+ program.addCommand(whoamiCommand);
705
764
  program.parseAsync().catch(handleError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpak/cli",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mcpak": "dist/index.js"