fix: adapt upstream commands to relay client
CI / test (push) Failing after 5m19s
Publish npm package / publish (push) Successful in 9m52s

This commit is contained in:
2026-06-24 18:51:33 +09:00
parent 55fd5c3d81
commit eedf9b1644
8 changed files with 17 additions and 104 deletions
+6 -26
View File
@@ -42,19 +42,9 @@ export function registerFollowCommands(program: Command, ctx: CliContext): void
.action(async (usernameOrId: string) => {
const opts = program.opts();
const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
for (const warning of warnings) {
console.error(`${ctx.p('warn')}${warning}`);
}
if (!cookies.authToken || !cookies.ct0) {
console.error(`${ctx.p('err')}Missing required credentials`);
process.exit(1);
}
const client = new TwitterClient({ cookies, timeoutMs });
const relayBaseUrl = ctx.resolveRelayBaseUrlFromOptions(opts);
const profileName = ctx.resolveProfileNameFromOptions(opts);
const client = new TwitterClient({ relayBaseUrl, profileName, timeoutMs });
const resolved = await resolveUserId(client, usernameOrId, ctx);
if (!resolved) {
@@ -81,19 +71,9 @@ export function registerFollowCommands(program: Command, ctx: CliContext): void
.action(async (usernameOrId: string) => {
const opts = program.opts();
const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
for (const warning of warnings) {
console.error(`${ctx.p('warn')}${warning}`);
}
if (!cookies.authToken || !cookies.ct0) {
console.error(`${ctx.p('err')}Missing required credentials`);
process.exit(1);
}
const client = new TwitterClient({ cookies, timeoutMs });
const relayBaseUrl = ctx.resolveRelayBaseUrlFromOptions(opts);
const profileName = ctx.resolveProfileNameFromOptions(opts);
const client = new TwitterClient({ relayBaseUrl, profileName, timeoutMs });
const resolved = await resolveUserId(client, usernameOrId, ctx);
if (!resolved) {
+3 -63
View File
@@ -317,18 +317,9 @@ export function registerUserCommands(program: Command, ctx: CliContext): void {
process.exit(1);
}
const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
for (const warning of warnings) {
console.error(`${ctx.p('warn')}${warning}`);
}
if (!cookies.authToken || !cookies.ct0) {
console.error(`${ctx.p('err')}Missing required credentials`);
process.exit(1);
}
const client = new TwitterClient({ cookies, timeoutMs });
const relayBaseUrl = ctx.resolveRelayBaseUrlFromOptions(opts);
const profileName = ctx.resolveProfileNameFromOptions(opts);
const client = new TwitterClient({ relayBaseUrl, profileName, timeoutMs });
const result = await client.getUserAboutAccount(normalizedHandle);
if (result.success && result.aboutProfile) {
@@ -344,55 +335,4 @@ export function registerUserCommands(program: Command, ctx: CliContext): void {
process.exit(1);
}
});
program
.command('about')
.description('Get account origin and location information for a user')
.argument('<username>', 'Twitter username (with or without @)')
.option('--json', 'Output as JSON')
.action(async (username: string, cmdOpts: { json?: boolean }) => {
const opts = program.opts();
const timeoutMs = ctx.resolveTimeoutFromOptions(opts);
const { cookies, warnings } = await ctx.resolveCredentialsFromOptions(opts);
for (const warning of warnings) {
console.error(`${ctx.p('warn')}${warning}`);
}
if (!cookies.authToken || !cookies.ct0) {
console.error(`${ctx.p('err')}Missing required credentials`);
process.exit(1);
}
const client = new TwitterClient({ cookies, timeoutMs });
const result = await client.getUserAboutAccount(username);
if (result.success && result.aboutProfile) {
if (cmdOpts.json) {
console.log(JSON.stringify(result.aboutProfile, null, 2));
} else {
const profile = result.aboutProfile;
console.log(`${ctx.p('info')}Account information for @${username}:`);
if (profile.accountBasedIn) {
console.log(` Account based in: ${profile.accountBasedIn}`);
}
if (profile.createdCountryAccurate !== undefined) {
console.log(` Creation country accurate: ${profile.createdCountryAccurate ? 'Yes' : 'No'}`);
}
if (profile.locationAccurate !== undefined) {
console.log(` Location accurate: ${profile.locationAccurate ? 'Yes' : 'No'}`);
}
if (profile.source) {
console.log(`${ctx.l('source')}${profile.source}`);
}
if (profile.learnMoreUrl) {
console.log(` Learn more: ${profile.learnMoreUrl}`);
}
}
} else {
console.error(`${ctx.p('err')}Failed to fetch account information: ${result.error ?? 'Unknown error'}`);
process.exit(1);
}
});
}
+1 -1
View File
@@ -66,7 +66,7 @@ export function withFollow<TBase extends AbstractConstructor<TwitterClientBase>>
const response = await this.fetchWithTimeout(url, {
method: 'POST',
headers: {
...this.getBaseHeaders(),
...this.getHeaders(),
'content-type': 'application/x-www-form-urlencoded',
},
body: params.toString(),