chirpie 1.0.13 → 1.0.15

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 +74 -2
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -27,6 +27,14 @@ function success(msg) {
27
27
  function error(msg) {
28
28
  console.error(`\x1B[31m\u2717\x1B[0m ${msg}`);
29
29
  }
30
+ function apiError(err, fallback) {
31
+ const maybe = err;
32
+ if (typeof maybe?.code === "string" && typeof maybe?.message === "string") {
33
+ error(`${maybe.code}: ${maybe.message}`);
34
+ return;
35
+ }
36
+ error(err instanceof Error ? err.message : fallback);
37
+ }
30
38
  function info(msg) {
31
39
  console.log(`\x1B[36m\u2139\x1B[0m ${msg}`);
32
40
  }
@@ -181,7 +189,7 @@ var postCommand = new Command3("post").description("Create a post").argument("<t
181
189
  success(`Post created (${post.id})`);
182
190
  }
183
191
  } catch (err) {
184
- error(err instanceof Error ? err.message : "Failed to create post");
192
+ apiError(err, "Failed to create post");
185
193
  process.exit(1);
186
194
  }
187
195
  });
@@ -264,7 +272,7 @@ var threadCommand = new Command4("thread").description("Create a thread").argume
264
272
  success(`Thread created with ${thread.posts.length} posts (${thread.id})`);
265
273
  }
266
274
  } catch (err) {
267
- error(err instanceof Error ? err.message : "Failed to create thread");
275
+ apiError(err, "Failed to create thread");
268
276
  process.exit(1);
269
277
  }
270
278
  });
@@ -540,6 +548,70 @@ accountsCommand.command("connect-telegram").description("Connect a Telegram bot
540
548
  process.exit(1);
541
549
  }
542
550
  });
551
+ var xKeysCommand = accountsCommand.command("x-keys").description("Manage your own X developer app used to connect X accounts");
552
+ xKeysCommand.command("set").description("Set or replace your own X developer app credentials").requiredOption("--client-id <id>", "OAuth 2.0 Client ID from developer.x.com").option("--client-secret <secret>", "OAuth 2.0 Client Secret (omit to enter securely via prompt)").option("--label <label>", "Optional name for the app").option("--json", "Output raw JSON").action(async (opts) => {
553
+ const client = getClient();
554
+ try {
555
+ let clientSecret = opts.clientSecret;
556
+ if (!clientSecret) {
557
+ clientSecret = await readSecretFromStdin("Client Secret: ");
558
+ if (!clientSecret) {
559
+ error("Client secret is required");
560
+ process.exit(1);
561
+ }
562
+ }
563
+ const result = await client.setXKeys({
564
+ client_id: opts.clientId,
565
+ client_secret: clientSecret,
566
+ ...opts.label ? { label: opts.label } : {}
567
+ });
568
+ if (opts.json) {
569
+ json(result);
570
+ } else {
571
+ success("X developer keys saved.");
572
+ info(`Add this callback URI to your X app: ${result.redirect_uri}`);
573
+ info(`Required scopes: ${result.required_scopes.join(" ")}`);
574
+ info("Then run `chirpie accounts connect-x` to move an account onto your app.");
575
+ }
576
+ } catch (err) {
577
+ error(err instanceof Error ? err.message : "Failed to save X developer keys");
578
+ process.exit(1);
579
+ }
580
+ });
581
+ xKeysCommand.command("status").description("Show whether your own X developer app is configured").option("--json", "Output raw JSON").action(async (opts) => {
582
+ const client = getClient();
583
+ try {
584
+ const status = await client.getXKeysStatus();
585
+ if (opts.json) {
586
+ json(status);
587
+ } else if (!status.configured) {
588
+ info("No X developer app configured \u2014 X accounts connect through Chirpie's app.");
589
+ info(`Callback URI to register when you add one: ${status.redirect_uri}`);
590
+ } else {
591
+ success(
592
+ `Using your own X developer app${status.label ? ` (${status.label})` : ""}${status.client_id_last4 ? `, client ID ending \u2026${status.client_id_last4}` : ""}.`
593
+ );
594
+ info(`Callback URI: ${status.redirect_uri}`);
595
+ }
596
+ } catch (err) {
597
+ error(err instanceof Error ? err.message : "Failed to read X developer keys status");
598
+ process.exit(1);
599
+ }
600
+ });
601
+ xKeysCommand.command("remove").description("Remove your own X developer app credentials").option("--json", "Output raw JSON").action(async (opts) => {
602
+ const client = getClient();
603
+ try {
604
+ const result = await client.removeXKeys();
605
+ if (opts.json) {
606
+ json(result);
607
+ } else {
608
+ success(result.message);
609
+ }
610
+ } catch (err) {
611
+ error(err instanceof Error ? err.message : "Failed to remove X developer keys");
612
+ process.exit(1);
613
+ }
614
+ });
543
615
  var comingSoonCli = [
544
616
  { cmd: "connect-reddit", label: "Reddit" },
545
617
  { cmd: "connect-pinterest", label: "Pinterest" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chirpie",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Chirpie CLI — post to social media from the command line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,7 +45,7 @@
45
45
  ],
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@chirpie/sdk": "^1.0.11",
48
+ "@chirpie/sdk": "^1.0.13",
49
49
  "commander": "^13"
50
50
  },
51
51
  "devDependencies": {