chore: import upstream snapshot with attribution
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
// stackoverflow user — search Stack Overflow users by name and return profiles.
|
||||
import { cli, Strategy } from '@jackwener/opencli/registry';
|
||||
import {
|
||||
seFetch,
|
||||
normalizeLimit,
|
||||
requireString,
|
||||
epochToDate,
|
||||
ensureItems,
|
||||
decodeHtmlEntities,
|
||||
} from './utils.js';
|
||||
|
||||
cli({
|
||||
site: 'stackoverflow',
|
||||
name: 'user',
|
||||
access: 'read',
|
||||
description: 'Find Stack Overflow users by display name (highest reputation first).',
|
||||
domain: 'stackoverflow.com',
|
||||
strategy: Strategy.PUBLIC,
|
||||
browser: false,
|
||||
args: [
|
||||
{ name: 'name', positional: true, required: true, type: 'string', help: 'Display name (or substring) to search.' },
|
||||
{ name: 'limit', type: 'int', default: 10, help: 'Max users to return (max 100).' },
|
||||
],
|
||||
columns: ['userId', 'displayName', 'reputation', 'goldBadges', 'silverBadges', 'bronzeBadges', 'location', 'createdAt', 'lastAccessAt', 'url'],
|
||||
func: async (args) => {
|
||||
const name = requireString(args.name, 'name');
|
||||
const limit = normalizeLimit(args.limit, 10, 100, 'limit');
|
||||
const data = await seFetch('/users', {
|
||||
searchParams: {
|
||||
inname: name,
|
||||
order: 'desc',
|
||||
sort: 'reputation',
|
||||
pagesize: limit,
|
||||
},
|
||||
});
|
||||
const items = ensureItems(data, 'stackoverflow user');
|
||||
return items.slice(0, limit).map((u) => ({
|
||||
userId: u.user_id,
|
||||
displayName: decodeHtmlEntities(u.display_name || ''),
|
||||
reputation: u.reputation ?? 0,
|
||||
goldBadges: u.badge_counts?.gold ?? 0,
|
||||
silverBadges: u.badge_counts?.silver ?? 0,
|
||||
bronzeBadges: u.badge_counts?.bronze ?? 0,
|
||||
location: decodeHtmlEntities(u.location || ''),
|
||||
createdAt: epochToDate(u.creation_date),
|
||||
lastAccessAt: epochToDate(u.last_access_date),
|
||||
url: u.link || (u.user_id ? `https://stackoverflow.com/users/${u.user_id}` : ''),
|
||||
}));
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user