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`).
|
- `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).
|
- 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).
|
- 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
|
## 0.4.1 — 2025-12-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -67,6 +67,18 @@ bird followers --user 12345678 -n 10 # by user ID
|
|||||||
bird query-ids --fresh
|
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
|
## Commands
|
||||||
|
|
||||||
- `bird tweet "<text>"` — post a new tweet.
|
- `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",
|
"description": "CLI tool for tweeting and replying via Twitter/X GraphQL API",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"types": "dist/index.d.ts",
|
||||||
"bin": {
|
"bin": {
|
||||||
"bird": "dist/index.js"
|
"bird": "dist/cli.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm run build:dist && pnpm run build:binary",
|
"build": "pnpm run build:dist && pnpm run build:binary",
|
||||||
"build:dist": "tsc && node scripts/copy-dist-assets.js",
|
"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",
|
"dev": "tsx src/index.ts",
|
||||||
"bird": "pnpm run build:dist && node dist/index.js",
|
"bird": "pnpm run build:dist && node dist/index.js",
|
||||||
"test": "vitest run",
|
"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: {
|
timeline: {
|
||||||
instructions: [
|
instructions: [
|
||||||
{
|
{
|
||||||
entries: [
|
entries: [makeSearchEntry('1'), { content: { cursorType: 'Bottom', value: 'cursor-1' } }],
|
||||||
makeSearchEntry('1'),
|
|
||||||
{ content: { cursorType: 'Bottom', value: 'cursor-1' } },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ export default defineConfig({
|
|||||||
provider: 'v8',
|
provider: 'v8',
|
||||||
reporter: ['text', 'html'],
|
reporter: ['text', 'html'],
|
||||||
include: ['src/**/*.ts'],
|
include: ['src/**/*.ts'],
|
||||||
exclude: ['src/index.ts'],
|
exclude: ['src/cli.ts'],
|
||||||
thresholds: {
|
thresholds: {
|
||||||
statements: 90,
|
statements: 90,
|
||||||
branches: 80,
|
branches: 80,
|
||||||
|
|||||||
Reference in New Issue
Block a user