refactor: split cli and library entry
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
- `following`/`followers` JSON user fields are now camelCase (`followersCount`, `followingCount`, `isBlueVerified`, `profileImageUrl`, `createdAt`).
|
||||
- Cookie extraction timeout is now configurable (default 30s on macOS) via `--cookie-timeout` / `BIRD_COOKIE_TIMEOUT_MS` (thanks @tylerseymour).
|
||||
- Search now paginates beyond 20 results when using `-n` (thanks @ryanh-ai).
|
||||
- Library exports are now separated from the CLI entrypoint for easier embedding.
|
||||
## 0.4.1 — 2025-12-31
|
||||
|
||||
### Added
|
||||
|
||||
@@ -67,6 +67,18 @@ bird followers --user 12345678 -n 10 # by user ID
|
||||
bird query-ids --fresh
|
||||
```
|
||||
|
||||
## Library
|
||||
|
||||
`bird` can be used as a library (same GraphQL client as the CLI):
|
||||
|
||||
```ts
|
||||
import { TwitterClient, resolveCredentials } from '@steipete/bird';
|
||||
|
||||
const { cookies } = await resolveCredentials({ cookieSource: 'safari' });
|
||||
const client = new TwitterClient({ cookies });
|
||||
const result = await client.search('from:steipete', 50);
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
- `bird tweet "<text>"` — post a new tweet.
|
||||
|
||||
+3
-2
@@ -4,8 +4,9 @@
|
||||
"description": "CLI tool for tweeting and replying via Twitter/X GraphQL API",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"bin": {
|
||||
"bird": "dist/index.js"
|
||||
"bird": "dist/cli.js"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
@@ -16,7 +17,7 @@
|
||||
"scripts": {
|
||||
"build": "pnpm run build:dist && pnpm run build:binary",
|
||||
"build:dist": "tsc && node scripts/copy-dist-assets.js",
|
||||
"build:binary": "BIRD_VERSION=$(node -p \"require('./package.json').version\") BIRD_GIT_SHA=$(git rev-parse --short=8 HEAD 2>/dev/null || true) bun build --compile --minify --env=BIRD_* src/index.ts --outfile bird",
|
||||
"build:binary": "BIRD_VERSION=$(node -p \"require('./package.json').version\") BIRD_GIT_SHA=$(git rev-parse --short=8 HEAD 2>/dev/null || true) bun build --compile --minify --env=BIRD_* src/cli.ts --outfile bird",
|
||||
"dev": "tsx src/index.ts",
|
||||
"bird": "pnpm run build:dist && node dist/index.js",
|
||||
"test": "vitest run",
|
||||
|
||||
+1049
File diff suppressed because it is too large
Load Diff
+1
-1049
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
export {
|
||||
type CookieExtractionResult,
|
||||
type CookieSource,
|
||||
extractCookiesFromChrome,
|
||||
extractCookiesFromFirefox,
|
||||
extractCookiesFromSafari,
|
||||
resolveCredentials,
|
||||
type TwitterCookies,
|
||||
} from './cookies.js';
|
||||
export { runtimeQueryIds } from './runtime-query-ids.js';
|
||||
export {
|
||||
type CurrentUserResult,
|
||||
type FollowingResult,
|
||||
type GetTweetResult,
|
||||
type SearchResult,
|
||||
type TweetData,
|
||||
TwitterClient,
|
||||
type TwitterClientOptions,
|
||||
type TwitterUser,
|
||||
} from './twitter-client.js';
|
||||
@@ -0,0 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { resolveCredentials, TwitterClient } from '../src/index.js';
|
||||
|
||||
describe('library exports', () => {
|
||||
it('exposes primary library surface', () => {
|
||||
expect(typeof TwitterClient).toBe('function');
|
||||
expect(typeof resolveCredentials).toBe('function');
|
||||
});
|
||||
});
|
||||
@@ -1345,10 +1345,7 @@ describe('TwitterClient', () => {
|
||||
timeline: {
|
||||
instructions: [
|
||||
{
|
||||
entries: [
|
||||
makeSearchEntry('1'),
|
||||
{ content: { cursorType: 'Bottom', value: 'cursor-1' } },
|
||||
],
|
||||
entries: [makeSearchEntry('1'), { content: { cursorType: 'Bottom', value: 'cursor-1' } }],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export default defineConfig({
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'html'],
|
||||
include: ['src/**/*.ts'],
|
||||
exclude: ['src/index.ts'],
|
||||
exclude: ['src/cli.ts'],
|
||||
thresholds: {
|
||||
statements: 90,
|
||||
branches: 80,
|
||||
|
||||
Reference in New Issue
Block a user