mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 21:07:48 +00:00
[cli] Allow ls to specify a limit up to 100 (#8735)
### Related Issues Allow the `ls` commands to have a `--limit` option that allows a user to fetch up to 100 records per page. Currently the default is 20, but the API allows up to 100. This keeps the default, if unspecified at 20. Fixes: https://linear.app/vercel/issue/VCCLI-244/add-limit-option-all-the-ls-subcommands This adds in `ls --limit` into: - [x] `alias ls` - [x] `certs ls` - [x] `dns ls` - [x] `domains ls` I note that `env` has an `ls` command, but it doesn't have a pagination command and [looking at the API](https://vercel.com/docs/rest-api#endpoints/projects/retrieve-the-environment-variables-of-a-project-by-id-or-name) it doesn't support pagination or limit. Wasn't sure if I should add in `-L` as a short cut to `--limit`, seems like a good idea. ~Couldn't find any tests that cover this API, but I could be looking in the wrong place, this is the first pull request, so my apologies if I've missed it. But I'll take another look tomorrow and leave it in the draft state for now.~ Added in unit tests for each of the commands and mocks for those unit tests, which is has caused this PR to get quite a bit larger, sorry about that. Of note for reviewers, there were a few places where I changed `console.log` to `output.log` to get the output passed to the tests - as far as I can tell everything works on the command line and in tests. ### 📋 Checklist #### Tests - [x] The code changed/added as part of this PR has been covered with tests - [x] All tests pass locally with `yarn test-unit` #### Code Review - [x] This PR has a concise title and thorough description useful to a reviewer - [x] Issue from task tracker has a link to this PR
This commit is contained in:
24
packages/cli/test/unit/commands/certs.test.ts
Normal file
24
packages/cli/test/unit/commands/certs.test.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { client } from '../../mocks/client';
|
||||
import certs from '../../../src/commands/certs';
|
||||
import { useUser } from '../../mocks/user';
|
||||
import { useCert } from '../../mocks/certs';
|
||||
|
||||
describe('certs', () => {
|
||||
it('should list up to 20 certs by default', async () => {
|
||||
useUser();
|
||||
useCert();
|
||||
client.setArgv('certs', 'ls');
|
||||
const exitCodePromise = certs(client);
|
||||
await expect(client.stderr).toOutput('dummy-19.cert');
|
||||
await expect(exitCodePromise).resolves.toEqual(0);
|
||||
});
|
||||
|
||||
it('should list up to 2 certs if limit set to 2', async () => {
|
||||
useUser();
|
||||
useCert();
|
||||
client.setArgv('certs', 'ls', '--limit', '2');
|
||||
const exitCodePromise = certs(client);
|
||||
await expect(client.stderr).toOutput('dummy-1.cert');
|
||||
await expect(exitCodePromise).resolves.toEqual(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user