Skip to content

Commit 5aef393

Browse files
graydawncclaude
andauthored
fix(cli): drop twitter-bookmarks default from connector-sync (#87)
* fix(cli): drop twitter-bookmarks default from connector-sync The default dated from single-connector days. With multi-connector packages (github, xhs, reddit, hn), defaulting to twitter-bookmarks is misleading. Omitting the argument now lists installed connectors and prints usage instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(cli): derive __dirname in ESM for connector-sync The file uses `join(__dirname, ...)` to resolve bundled-connectors, but the package is ESM — __dirname is undefined and the subcommand crashed on invocation. Derive it from import.meta.url. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Chen <99816898+donteatfriedrice@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5efac9a commit 5aef393

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

packages/cli/src/commands/connector-sync.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { Command } from 'commander'
22
import { homedir } from 'node:os'
3-
import { join } from 'node:path'
3+
import { dirname, join } from 'node:path'
4+
import { fileURLToPath } from 'node:url'
5+
6+
const __dirname = dirname(fileURLToPath(import.meta.url))
47
import {
58
getDB,
69
ConnectorRegistry,
@@ -19,10 +22,10 @@ import type { SyncState } from '@spool/core'
1922

2023
export const connectorSyncCommand = new Command('connector-sync')
2124
.description('Sync a connector until fully complete')
22-
.argument('[connector-id]', 'Connector ID (default: twitter-bookmarks)', 'twitter-bookmarks')
25+
.argument('[connector-id]', 'Connector ID (omit to list available)')
2326
.option('--reset', 'Delete all data for this connector and sync from scratch')
2427
.option('--delay <ms>', 'Delay between page requests in ms', '600')
25-
.action(async (connectorId: string, opts: { reset?: boolean; delay?: string }) => {
28+
.action(async (connectorId: string | undefined, opts: { reset?: boolean; delay?: string }) => {
2629
const db = getDB()
2730
const registry = new ConnectorRegistry()
2831
const spoolDir = join(homedir(), '.spool')
@@ -42,9 +45,22 @@ export const connectorSyncCommand = new Command('connector-sync')
4245
trustStore: new TrustStore(spoolDir),
4346
})
4447

48+
const available = registry.list().map(c => c.id)
49+
50+
if (!connectorId) {
51+
if (available.length === 0) {
52+
console.error('No connectors installed.')
53+
process.exit(1)
54+
}
55+
console.log('Available connectors:')
56+
for (const id of available) console.log(` ${id}`)
57+
console.log('\nUsage: spool connector-sync <connector-id>')
58+
process.exit(0)
59+
}
60+
4561
if (!registry.has(connectorId)) {
4662
console.error(`Unknown connector: ${connectorId}`)
47-
console.error(`Available: ${registry.list().map(c => c.id).join(', ')}`)
63+
console.error(`Available: ${available.join(', ')}`)
4864
process.exit(1)
4965
}
5066

0 commit comments

Comments
 (0)