Skip to content

Commit

Permalink
Merge pull request #436 from calibreapp/update-command-descriptions
Browse files Browse the repository at this point in the history
Update command descriptions (CAL-397)
  • Loading branch information
thefoxis authored May 13, 2022
2 parents 5810e92 + 1d2e555 commit 425cc74
Show file tree
Hide file tree
Showing 57 changed files with 528 additions and 334 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 5.01 (2022-05-13)
## 🚩 Commands and flags
* Adds a new command: `calibre team list` to list all Teams depending on API Token in use.

## 🛠 Core
* Updates all command and flag descriptions for clarity and accuracy.

## 📖 Documentation
* updates `README.md` to include link to Calibre’s documentation page for all CLI commands

# 5.0.0 (2022-04-29)

## 💥 Breaking changes
Expand Down
339 changes: 172 additions & 167 deletions CLI_COMMANDS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ $ calibre --help
$ calibre <command> --help
```

or [see all commands](CLI_COMMANDS.md) in this repository.
or [see all commands](CLI_COMMANDS.md) in this repository or [Calibre’s documentation](https://calibreapp.com/docs/automation/cli-commands).

In Node, you can use the either ES Modules or CommonJS versions accordingly:

Expand Down
26 changes: 17 additions & 9 deletions __tests__/cli/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ exports[`calibre --help 1`] = `
Commands:
calibre site <command> Site management commands
calibre test <command> Single page tests
calibre connection-list Print a list of connection speeds
calibre device-list Print a list of test devices
calibre location-list Print a list of test locations
calibre metric-list Print a list of metrics
calibre token <command> Store or revoke a Calibre API token (Use instead of C
ALIBRE_API_TOKEN environment variable)
calibre request Make a request to the Calibre GraphQL API
calibre site <command> Use the site command to manage your Sites, Pages, Tes
t Profiles, Deploys, Snapshots and download the monit
oring data.
calibre team <command> Use the team command to manage Teams.
calibre test <command> Use the test command to run Single Page Tests: public
or private tests for a single Page tested from a sin
gle device. This command also supports viewing all Si
ngle Page Tests and retrieving their artifacts.
calibre connection-list List all available network connection speeds.
calibre device-list List all available test devices.
calibre location-list List all available test locations.
calibre metric-list List all available web performance metrics.
calibre token <command> Use the token command to store or revoke a Calibre AP
I token. You can also save your token with the CALIBR
E_API_TOKEN environment variable.
calibre request Use the request command to make a request to the Cali
bre GraphQL API.
Options:
Expand Down
10 changes: 3 additions & 7 deletions __tests__/cli/__snapshots__/request.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,14 @@ exports[`request missing query argument 1`] = `
calibre request
Make a request to the Calibre GraphQL API
Use the request command to make a request to the Calibre GraphQL API.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--query GraphQL query to execute. e.g.:
calibre request --query='query G
etSite($slug: String!) {organisation{site(slug: $slug){slug}}}' -
-slug=calibre [string] [required]
--variables Pass query variables as named arguments"
--query Pass a GraphQL query to execute. [string] [required]
--variables Pass query variables as named arguments."
`;

exports[`request returns response 1`] = `
Expand Down
22 changes: 14 additions & 8 deletions __tests__/cli/__snapshots__/site.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ exports[`missing site argument 1`] = `
calibre site pages [options]
Print a list of pages for a given site
List Pages for a selected Site.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--site The identifying slug of a site [string] [required]
--count The number of records to return, maximum: 500 [default: 25]
--site A unique slug identifying each Site. You can find it in Site Settin
gs → General or by using the calibre site list command.
[string] [required]
--count The number of items to return (default: 25, maximum: 500).
[default: 25]
--cursor The cursor to fetch records after
--json Output in JSON format"
--json Outputs the results of the command in JSON format."
`;

exports[`missing site argument value 1`] = `
Expand All @@ -26,14 +29,17 @@ exports[`missing site argument value 1`] = `
calibre site pages [options]
Print a list of pages for a given site
List Pages for a selected Site.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--site The identifying slug of a site [string] [required]
--count The number of records to return, maximum: 500 [default: 25]
--site A unique slug identifying each Site. You can find it in Site Settin
gs → General or by using the calibre site list command.
[string] [required]
--count The number of items to return (default: 25, maximum: 500).
[default: 25]
--cursor The cursor to fetch records after
--json Output in JSON format"
--json Outputs the results of the command in JSON format."
`;
23 changes: 23 additions & 0 deletions __tests__/cli/__snapshots__/team.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`missing subcommand 1`] = `
"
Not enough non-option arguments: got 0, need at least 1
calibre team <command>
Use the team command to manage Teams.
Commands:
calibre team list List Teams based on API Token access. For Admin Tokens, thi
s will list all teams or as specified based on your setting
s. For Personal Access Tokens, this will list Teams that yo
u have access to.
Options:
--help Show help [boolean]
--version Show version number [boolean]"
`;
12 changes: 7 additions & 5 deletions __tests__/cli/site/__snapshots__/delete-deploy.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ exports[`site delete-deploy requires uuid 1`] = `
calibre site delete-deploy [options]
Deletes a deploy from a site
Delete a deploy from a selected Site.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--site The identifying slug of a site [string] [required]
--uuid The uuid of the deploy [required]
--confirm Confirm the deletion
--json Output in JSON format"
--site A unique slug identifying each Site. You can find it in Site Settin
gs → General or by using the calibre site list command.
[string] [required]
--uuid The UUID of the deploy. [required]
--confirm Use this flag to confirm the deletion of the selected deploy.
--json Outputs the results of the command in JSON format."
`;
12 changes: 7 additions & 5 deletions __tests__/cli/site/__snapshots__/delete-snapshot.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ exports[`site delete-snapshot requires id 1`] = `
calibre site delete-snapshot [options]
Deletes a snapshot from a site
Delete a Snapshot from a selected Site.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--site The identifying slug of a site [string] [required]
--id The id of the snapshot [required]
--confirm Confirm the deletion
--json Output in JSON format"
--site A unique slug identifying each Site. You can find it in Site Settin
gs → General or by using the calibre site list command.
[string] [required]
--id The id of the Snapshot. [required]
--confirm Use this flag to confirm the deletion of the selected Snapshot.
--json Outputs the results of the command in JSON format."
`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ exports[`snapshot metrics returns no snapshot error 1`] = `
calibre site get-snapshot-metrics [options]
Get the metrics of a given snapshot
Get all metrics of a given Snapshot.
Options:
--help Show help [boolean]
--version Show version number [boolean]
--site The identifying slug of a site [string] [required]
--snapshot The identifying id of a snapshot [required]
--json Output in JSON format
--csv Output in CSV format"
--site A unique slug identifying each Site. You can find it in Site Setti
ngs → General or by using the calibre site list command.
[string] [required]
--snapshot The id of a Snapshot. [required]
--json Outputs the results of the command in JSON format.
--csv Outputs the results of the command in CSV format."
`;
6 changes: 6 additions & 0 deletions __tests__/cli/team.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { runCLI } from '../utils'

test('missing subcommand', async () => {
const out = await runCLI({ args: 'team', testForError: true })
expect(out).toMatchSnapshot()
})
8 changes: 8 additions & 0 deletions __tests__/cli/team/__snapshots__/list.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`team list lists all teams 1`] = `
"2 sites
SLUG | NAME | DESCRIPTION
calibre | Calibre | Default team
engineering | Monitors | Engineering team"
`;
19 changes: 19 additions & 0 deletions __tests__/cli/team/list.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
runCLI,
setupIntegrationServer,
teardownIntegrationServer
} from '../../utils'

import listTeams from '../../fixtures/listTeams.json'

describe('team list', () => {
beforeAll(() => setupIntegrationServer(listTeams))
afterAll(() => teardownIntegrationServer())

test('lists all teams', async () => {
const out = await runCLI({
args: 'team list'
})
expect(out).toMatchSnapshot()
})
})
10 changes: 6 additions & 4 deletions __tests__/cli/token/__snapshots__/set.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ exports[`missing token argument 1`] = `
calibre token <command>
Store or revoke a Calibre API token (Use instead of CALIBRE_API_TOKEN environmen
t variable)
Use the token command to store or revoke a Calibre API token. You can also save
your token with the CALIBRE_API_TOKEN environment variable.
Commands:
calibre token set <key> Set the Calibre API token used for CLI commands
calibre token remove Remove the Calibre API token used for CLI commands
calibre token set <token> Store your API Token to use the CLI (saved in ~/.co
nfig/configstore/calibre.json).
calibre token remove Remove the saved API Token used for CLI commands (f
rom ~/.config/configstore/calibre.json).
Options:
Expand Down
18 changes: 18 additions & 0 deletions __tests__/fixtures/listTeams.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"data": {
"organisation": {
"teams": [
{
"name": "Calibre",
"description": "Default team",
"slug": "calibre"
},
{
"name": "Monitors",
"description": "Engineering team",
"slug": "engineering"
}
]
}
}
}
13 changes: 8 additions & 5 deletions generate-cli-md.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ ${describe || ''}
}

const formatOptions = options => {
return `Options:
${Object.keys(options).map(key => {
const optionKeys = Object.keys(options)
if (!optionKeys.length) {
return ''
} else {
return `Flags:
${optionKeys.map(key => {
const { describe, default: defaultValue, type } = options[key]
return `
* \`${key}\`: ${describe}${
* \`--${key}\`: ${describe}${
defaultValue ? ` (default: \`${defaultValue}\`)` : ''
}${type ? ` (${type})` : ''}`
})}`
}
}

const template = command => {
Expand All @@ -42,8 +47,6 @@ const template = command => {

const commands = getCommandMetaData()

// console.log(JSON.stringify(commands, null, 2))

let output = ''

commands.forEach(command => {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "calibre",
"version": "5.0.0",
"version": "5.0.1",
"engines": {
"node": ">= 14.18"
},
Expand Down
20 changes: 20 additions & 0 deletions src/api/team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { request } from './graphql.js'

const LIST_QUERY = `
query {
organisation {
teams {
name
description
slug
}
}
}
`

const list = async () => {
const response = await request({ query: LIST_QUERY })
return response.organisation.teams
}

export { list }
2 changes: 2 additions & 0 deletions src/cli-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import * as LocationList from './cli/location-list.js'
import * as MetricList from './cli/metric-list.js'
import * as Request from './cli/request.js'
import * as Site from './cli/site.js'
import * as Team from './cli/team.js'
import * as Test from './cli/test.js'
import * as Token from './cli/token.js'

const commands = [
Site,
Team,
Test,
ConnectionList,
DeviceList,
Expand Down
Loading

0 comments on commit 425cc74

Please sign in to comment.