Skip to content

Commit 5c871dd

Browse files
authored
refactor(adapter): split browser command signatures (#1237)
1 parent b41ee2b commit 5c871dd

102 files changed

Lines changed: 420 additions & 186 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clis/36kr/news.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cli({
1212
{ name: 'limit', type: 'int', default: 20, help: 'Number of articles (max 50)' },
1313
],
1414
columns: ['rank', 'title', 'summary', 'date', 'url'],
15-
func: async (_page, kwargs) => {
15+
func: async (kwargs) => {
1616
const count = Math.min(kwargs.limit || 20, 50);
1717
const resp = await fetch('https://www.36kr.com/feed', {
1818
headers: { 'User-Agent': 'Mozilla/5.0 (compatible; opencli/1.0)' },

clis/apple-podcasts/commands.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('apple-podcasts search command', () => {
2424
}),
2525
});
2626
vi.stubGlobal('fetch', fetchMock);
27-
const result = await cmd.func(null, {
27+
const result = await cmd.func({
2828
query: 'machine learning',
2929
keyword: 'sports',
3030
limit: 5,
@@ -60,7 +60,7 @@ describe('apple-podcasts top command', () => {
6060
}),
6161
});
6262
vi.stubGlobal('fetch', fetchMock);
63-
await cmd.func(null, { country: 'US', limit: 1 });
63+
await cmd.func({ country: 'US', limit: 1 });
6464
const [, options] = fetchMock.mock.calls[0] ?? [];
6565
expect(options).toBeDefined();
6666
expect(options.signal).toBeDefined();
@@ -81,7 +81,7 @@ describe('apple-podcasts top command', () => {
8181
}),
8282
});
8383
vi.stubGlobal('fetch', fetchMock);
84-
const result = await cmd.func(null, { country: 'US', limit: 2 });
84+
const result = await cmd.func({ country: 'US', limit: 2 });
8585
expect(fetchMock).toHaveBeenCalledWith('https://rss.marketingtools.apple.com/api/v2/us/podcasts/top/2/podcasts.json', expect.objectContaining({
8686
signal: expect.any(Object),
8787
}));
@@ -94,6 +94,6 @@ describe('apple-podcasts top command', () => {
9494
const cmd = getRegistry().get('apple-podcasts/top');
9595
expect(cmd?.func).toBeTypeOf('function');
9696
vi.stubGlobal('fetch', vi.fn().mockRejectedValue(new Error('socket hang up')));
97-
await expect(cmd.func(null, { country: 'us', limit: 3 })).rejects.toThrow('Unable to reach Apple Podcasts charts for US');
97+
await expect(cmd.func({ country: 'us', limit: 3 })).rejects.toThrow('Unable to reach Apple Podcasts charts for US');
9898
});
9999
});

clis/apple-podcasts/episodes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cli({
1212
{ name: 'limit', type: 'int', default: 15, help: 'Max episodes to show' },
1313
],
1414
columns: ['title', 'duration', 'date'],
15-
func: async (_page, args) => {
15+
func: async (args) => {
1616
const limit = Math.max(1, Math.min(Number(args.limit), 200));
1717
// results[0] is the podcast itself; the rest are episodes
1818
const data = await itunesFetch(`/lookup?id=${args.id}&entity=podcastEpisode&limit=${limit + 1}`);

clis/apple-podcasts/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cli({
1212
{ name: 'limit', type: 'int', default: 10, help: 'Max results' },
1313
],
1414
columns: ['id', 'title', 'author', 'episodes', 'genre', 'url'],
15-
func: async (_page, args) => {
15+
func: async (args) => {
1616
const term = encodeURIComponent(args.query);
1717
const limit = Math.max(1, Math.min(Number(args.limit), 25));
1818
const data = await itunesFetch(`/search?term=${term}&media=podcast&limit=${limit}`);

clis/apple-podcasts/top.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ cli({
1414
{ name: 'country', default: 'us', help: 'Country code (e.g. us, cn, gb, jp)' },
1515
],
1616
columns: ['rank', 'title', 'author', 'id'],
17-
func: async (_page, args) => {
17+
func: async (args) => {
1818
const limit = Math.max(1, Math.min(Number(args.limit), 100));
1919
const country = String(args.country || 'us').trim().toLowerCase();
2020
const url = `${CHARTS_URL}/${country}/podcasts/top/${limit}/podcasts.json`;

clis/arxiv/paper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cli({
1111
{ name: 'id', positional: true, required: true, help: 'arXiv paper ID (e.g. 1706.03762)' },
1212
],
1313
columns: ['id', 'title', 'authors', 'published', 'abstract', 'url'],
14-
func: async (_page, args) => {
14+
func: async (args) => {
1515
const xml = await arxivFetch(`id_list=${encodeURIComponent(args.id)}`);
1616
const entries = parseEntries(xml);
1717
if (!entries.length)

clis/arxiv/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cli({
1212
{ name: 'limit', type: 'int', default: 10, help: 'Max results (max 25)' },
1313
],
1414
columns: ['id', 'title', 'authors', 'published', 'url'],
15-
func: async (_page, args) => {
15+
func: async (args) => {
1616
const limit = Math.max(1, Math.min(Number(args.limit), 25));
1717
const query = encodeURIComponent(`all:${args.query}`);
1818
const xml = await arxivFetch(`search_query=${query}&max_results=${limit}&sortBy=relevance`);

clis/bbc/news.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ cli({
1212
{ name: 'limit', type: 'int', default: 20, help: 'Number of headlines (max 50)' },
1313
],
1414
columns: ['rank', 'title', 'description', 'url'],
15-
func: async (page, kwargs) => {
15+
func: async (kwargs) => {
1616
const count = Math.min(kwargs.limit || 20, 50);
1717
const resp = await fetch('https://feeds.bbci.co.uk/news/rss.xml');
1818
if (!resp.ok)

clis/bloomberg/businessweek.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cli({
1111
{ name: 'limit', type: 'int', default: 1, help: 'Number of feed items to return (max 20)' },
1212
],
1313
columns: ['title', 'summary', 'link', 'mediaLinks'],
14-
func: async (_page, kwargs) => {
14+
func: async (kwargs) => {
1515
return fetchBloombergFeed('businessweek', kwargs.limit ?? 1);
1616
},
1717
});

clis/bloomberg/economics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cli({
1111
{ name: 'limit', type: 'int', default: 1, help: 'Number of feed items to return (max 20)' },
1212
],
1313
columns: ['title', 'summary', 'link', 'mediaLinks'],
14-
func: async (_page, kwargs) => {
14+
func: async (kwargs) => {
1515
return fetchBloombergFeed('economics', kwargs.limit ?? 1);
1616
},
1717
});

0 commit comments

Comments
 (0)