sequoia-cli 0.3.1 → 0.3.3

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 +103 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -99758,8 +99758,7 @@ async function tryLoadOAuthCredentials(profile) {
99758
99758
  return {
99759
99759
  type: "oauth",
99760
99760
  did: profile,
99761
- handle: handle || profile,
99762
- pdsUrl: "https://bsky.social"
99761
+ handle: handle || profile
99763
99762
  };
99764
99763
  }
99765
99764
  }
@@ -99769,8 +99768,7 @@ async function tryLoadOAuthCredentials(profile) {
99769
99768
  return {
99770
99769
  type: "oauth",
99771
99770
  did: match2.did,
99772
- handle: match2.handle || match2.did,
99773
- pdsUrl: "https://bsky.social"
99771
+ handle: match2.handle || match2.did
99774
99772
  };
99775
99773
  }
99776
99774
  return null;
@@ -99821,8 +99819,7 @@ async function loadCredentials(projectIdentity) {
99821
99819
  return {
99822
99820
  type: "oauth",
99823
99821
  did: oauthDids[0],
99824
- handle: handle || oauthDids[0],
99825
- pdsUrl: "https://bsky.social"
99822
+ handle: handle || oauthDids[0]
99826
99823
  };
99827
99824
  }
99828
99825
  }
@@ -100125,6 +100122,42 @@ async function saveState(configDir, state) {
100125
100122
  await fs5.writeFile(statePath, JSON.stringify(state, null, 2));
100126
100123
  }
100127
100124
 
100125
+ // src/lib/credential-select.ts
100126
+ async function selectCredential(allCredentials) {
100127
+ const options = await Promise.all(allCredentials.map(async ({ id, type }) => {
100128
+ let label = id;
100129
+ if (type === "oauth") {
100130
+ const handle = await getOAuthHandle(id);
100131
+ label = handle ? `${handle} (${id})` : id;
100132
+ }
100133
+ return {
100134
+ value: { id, type },
100135
+ label: `${label} [${type}]`
100136
+ };
100137
+ }));
100138
+ const selected = exitOnCancel(await qt({
100139
+ message: "Multiple identities found. Select one:",
100140
+ options
100141
+ }));
100142
+ if (selected.type === "oauth") {
100143
+ const session = await getOAuthSession(selected.id);
100144
+ if (session) {
100145
+ const handle = await getOAuthHandle(selected.id);
100146
+ return {
100147
+ type: "oauth",
100148
+ did: selected.id,
100149
+ handle: handle || selected.id
100150
+ };
100151
+ }
100152
+ } else {
100153
+ const creds = await getCredentials(selected.id);
100154
+ if (creds) {
100155
+ return creds;
100156
+ }
100157
+ }
100158
+ return null;
100159
+ }
100160
+
100128
100161
  // src/commands/init.ts
100129
100162
  async function fileExists5(filePath) {
100130
100163
  try {
@@ -100253,10 +100286,21 @@ var initCommand = import_cmd_ts2.command({
100253
100286
  onCancel();
100254
100287
  }
100255
100288
  let publicationUri;
100256
- const credentials = await loadCredentials();
100289
+ let credentials = await loadCredentials();
100257
100290
  if (publicationChoice === "create") {
100258
100291
  if (!credentials) {
100259
- R2.error("You must authenticate first. Run 'sequoia auth' before creating a publication.");
100292
+ const allCredentials = await listAllCredentials();
100293
+ if (allCredentials.length > 1) {
100294
+ credentials = await selectCredential(allCredentials);
100295
+ } else if (allCredentials.length === 1) {
100296
+ credentials = await selectCredential(allCredentials);
100297
+ } else {
100298
+ R2.error("You must authenticate first. Run 'sequoia login' (recommended) or 'sequoia auth' before creating a publication.");
100299
+ process.exit(1);
100300
+ }
100301
+ }
100302
+ if (!credentials) {
100303
+ R2.error("Could not load credentials. Try running 'sequoia login' again to re-authenticate.");
100260
100304
  process.exit(1);
100261
100305
  }
100262
100306
  const s = Ie();
@@ -100267,7 +100311,7 @@ var initCommand = import_cmd_ts2.command({
100267
100311
  s.stop("Connected!");
100268
100312
  } catch (_error) {
100269
100313
  s.stop("Failed to connect");
100270
- R2.error("Failed to connect. Check your credentials with 'sequoia auth'.");
100314
+ R2.error("Failed to connect. Try re-authenticating with 'sequoia login' or 'sequoia auth'.");
100271
100315
  process.exit(1);
100272
100316
  }
100273
100317
  const publicationConfig = await Rt({
@@ -100353,7 +100397,7 @@ var initCommand = import_cmd_ts2.command({
100353
100397
  ...maxAgeDays !== 7 && { maxAgeDays }
100354
100398
  };
100355
100399
  }
100356
- const pdsUrl = credentials?.pdsUrl;
100400
+ const pdsUrl = credentials?.type === "app-password" ? credentials.pdsUrl : undefined;
100357
100401
  const configContent = generateConfigTemplate({
100358
100402
  siteUrl: siteConfig.siteUrl,
100359
100403
  contentDir: siteConfig.contentDir || "./content",
@@ -100809,8 +100853,7 @@ var publishCommand = import_cmd_ts5.command({
100809
100853
  credentials = {
100810
100854
  type: "oauth",
100811
100855
  did: selected,
100812
- handle: handle || selected,
100813
- pdsUrl: "https://bsky.social"
100856
+ handle: handle || selected
100814
100857
  };
100815
100858
  }
100816
100859
  } else {
@@ -100908,7 +100951,8 @@ Bluesky posting: enabled (max age: ${maxAgeDays} days)`);
100908
100951
  Dry run complete. No changes made.`);
100909
100952
  return;
100910
100953
  }
100911
- s.start(`Connecting to ${credentials.pdsUrl}...`);
100954
+ const connectingTo = credentials.type === "oauth" ? credentials.handle : credentials.pdsUrl;
100955
+ s.start(`Connecting as ${connectingTo}...`);
100912
100956
  let agent;
100913
100957
  try {
100914
100958
  agent = await createAgent(credentials);
@@ -101078,8 +101122,7 @@ var syncCommand = import_cmd_ts6.command({
101078
101122
  credentials = {
101079
101123
  type: "oauth",
101080
101124
  did: selected,
101081
- handle: handle || selected,
101082
- pdsUrl: "https://bsky.social"
101125
+ handle: handle || selected
101083
101126
  };
101084
101127
  }
101085
101128
  } else {
@@ -101091,7 +101134,8 @@ var syncCommand = import_cmd_ts6.command({
101091
101134
  }
101092
101135
  }
101093
101136
  const s = Ie();
101094
- s.start(`Connecting to ${credentials.pdsUrl}...`);
101137
+ const connectingTo = credentials.type === "oauth" ? credentials.handle : credentials.pdsUrl;
101138
+ s.start(`Connecting as ${connectingTo}...`);
101095
101139
  let agent;
101096
101140
  try {
101097
101141
  agent = await createAgent(credentials);
@@ -101486,10 +101530,49 @@ async function editBluesky(config) {
101486
101530
  };
101487
101531
  }
101488
101532
  async function updatePublicationFlow(config) {
101489
- const credentials = await loadCredentials(config.identity);
101533
+ let credentials = await loadCredentials(config.identity);
101490
101534
  if (!credentials) {
101491
- R2.error("No credentials found. Run 'sequoia auth' or 'sequoia login' first.");
101492
- process.exit(1);
101535
+ const identities = await listAllCredentials();
101536
+ if (identities.length === 0) {
101537
+ R2.error("No credentials found. Run 'sequoia login' or 'sequoia auth' first.");
101538
+ process.exit(1);
101539
+ }
101540
+ const options = await Promise.all(identities.map(async (cred) => {
101541
+ if (cred.type === "oauth") {
101542
+ const handle = await getOAuthHandle(cred.id);
101543
+ return {
101544
+ value: cred.id,
101545
+ label: `${handle || cred.id} (OAuth)`
101546
+ };
101547
+ }
101548
+ return {
101549
+ value: cred.id,
101550
+ label: `${cred.id} (App Password)`
101551
+ };
101552
+ }));
101553
+ R2.info("Multiple identities found. Select one to use:");
101554
+ const selected = exitOnCancel(await qt({
101555
+ message: "Identity:",
101556
+ options
101557
+ }));
101558
+ const selectedCred = identities.find((c) => c.id === selected);
101559
+ if (selectedCred?.type === "oauth") {
101560
+ const session = await getOAuthSession(selected);
101561
+ if (session) {
101562
+ const handle = await getOAuthHandle(selected);
101563
+ credentials = {
101564
+ type: "oauth",
101565
+ did: selected,
101566
+ handle: handle || selected
101567
+ };
101568
+ }
101569
+ } else {
101570
+ credentials = await getCredentials(selected);
101571
+ }
101572
+ if (!credentials) {
101573
+ R2.error("Failed to load selected credentials.");
101574
+ process.exit(1);
101575
+ }
101493
101576
  }
101494
101577
  const s = Ie();
101495
101578
  s.start("Connecting to ATProto...");
@@ -101606,7 +101689,7 @@ Publish evergreen content to the ATmosphere
101606
101689
 
101607
101690
  > https://tangled.org/stevedylan.dev/sequoia
101608
101691
  `,
101609
- version: "0.3.1",
101692
+ version: "0.3.3",
101610
101693
  cmds: {
101611
101694
  auth: authCommand,
101612
101695
  init: initCommand,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sequoia-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "sequoia": "dist/index.js"