@clawcard/cli 1.0.2 → 1.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawcard/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "The ClawCard CLI — manage your agent keys, billing, and setup from the terminal",
5
5
  "bin": {
6
6
  "clawcard": "./bin/clawcard.mjs"
package/src/api.js CHANGED
@@ -17,7 +17,7 @@ async function request(path, options = {}) {
17
17
  const url = `${BASE_URL}${path}`;
18
18
  const headers = {
19
19
  "Content-Type": "application/json",
20
- Cookie: `better-auth.session_token=${token}`,
20
+ Authorization: `Bearer ${token}`,
21
21
  ...options.headers,
22
22
  };
23
23
 
@@ -30,6 +30,7 @@ const COMMANDS = [
30
30
  ["", ""],
31
31
  [orange.bold("Other"), ""],
32
32
  [" referral", "Show referral code"],
33
+ [" update", "Check for updates"],
33
34
  [" help", "Show this help"],
34
35
  [" --version", "Show version"],
35
36
  ];
package/src/index.js CHANGED
@@ -1,13 +1,19 @@
1
1
  import { Command } from "commander";
2
2
  import * as p from "@clack/prompts";
3
- import { showSplash } from "./splash.js";
3
+ import chalk from "chalk";
4
+ import { showSplash, checkForUpdate, VERSION } from "./splash.js";
4
5
  import { isLoggedIn } from "./config.js";
5
6
 
7
+ const orange = chalk.hex("#FF6B35");
8
+
6
9
  // Show splash on every invocation
7
10
  showSplash();
8
11
 
12
+ // Check for updates in background (non-blocking)
13
+ const updatePromise = checkForUpdate();
14
+
9
15
  const program = new Command();
10
- program.name("clawcard").description("The ClawCard CLI").version("1.0.2");
16
+ program.name("clawcard").description("The ClawCard CLI").version(VERSION);
11
17
 
12
18
  // Auth commands
13
19
  program
@@ -142,6 +148,22 @@ program
142
148
  await referralCommand();
143
149
  });
144
150
 
151
+ // Update
152
+ program
153
+ .command("update")
154
+ .description("Update to the latest version")
155
+ .action(async () => {
156
+ const s = p.spinner();
157
+ s.start("Checking for updates...");
158
+ const latest = await checkForUpdate();
159
+ if (latest) {
160
+ s.stop(`Update available: ${chalk.dim(VERSION)} → ${orange.bold(latest)}`);
161
+ p.log.info(`Run: ${orange("npm i -g @clawcard/cli@latest")}`);
162
+ } else {
163
+ s.stop("You're on the latest version!");
164
+ }
165
+ });
166
+
145
167
  // Help
146
168
  program
147
169
  .command("help")
@@ -155,6 +177,14 @@ program
155
177
  if (process.argv.length <= 2) {
156
178
  const loggedIn = isLoggedIn();
157
179
 
180
+ // Show update notice if available (non-blocking, already fetched)
181
+ const latest = await updatePromise;
182
+ if (latest) {
183
+ p.log.warn(
184
+ `Update available: ${chalk.dim(VERSION)} → ${orange.bold(latest)} Run ${orange("npm i -g @clawcard/cli@latest")}`
185
+ );
186
+ }
187
+
158
188
  const options = loggedIn
159
189
  ? [
160
190
  {
package/src/splash.js CHANGED
@@ -1,11 +1,33 @@
1
1
  import chalk from "chalk";
2
+ import { readFileSync } from "fs";
3
+ import { join, dirname } from "path";
4
+ import { fileURLToPath } from "url";
2
5
 
3
6
  const o = chalk.hex("#FF6B35");
4
7
  const d = chalk.dim;
5
8
 
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
11
+ export const VERSION = pkg.version;
12
+
13
+ export async function checkForUpdate() {
14
+ try {
15
+ const res = await fetch("https://registry.npmjs.org/@clawcard/cli/latest", {
16
+ signal: AbortSignal.timeout(3000),
17
+ });
18
+ const data = await res.json();
19
+ if (data.version && data.version !== VERSION) {
20
+ return data.version;
21
+ }
22
+ } catch {
23
+ // offline or timeout — skip silently
24
+ }
25
+ return null;
26
+ }
27
+
6
28
  export function showSplash() {
7
29
  console.log();
8
- console.log(` 🦞 ${o.bold("clawcard.sh")}`);
30
+ console.log(` 🦞 ${o.bold("clawcard.sh")} ${d("v" + VERSION)}`);
9
31
  console.log(` ${o("on-demand credit cards, email and phone for your agents")}`);
10
32
  console.log();
11
33
  }