Skip to content

Commit

Permalink
Merge pull request #2855 from balena-io/releases-to-release-list
Browse files Browse the repository at this point in the history
Add `release list` alias for `releases` command
  • Loading branch information
flowzone-app[bot] authored Oct 16, 2024
2 parents 019af9e + 8d1394a commit 65b278e
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 44 deletions.
4 changes: 2 additions & 2 deletions completion/_balena
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _balena() {
local context state line curcontext="$curcontext"

# Valid top-level completions
main_commands=( api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release releases scan settings ssh support tag tags tunnel util version whoami )
main_commands=( api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami )
# Sub-completions
api_key_cmds=( generate list revoke )
app_cmds=( create )
Expand All @@ -22,7 +22,7 @@ _balena() {
key_cmds=( add rm )
local_cmds=( configure flash )
os_cmds=( build-config configure download initialize versions )
release_cmds=( finalize invalidate validate )
release_cmds=( finalize invalidate list validate )
tag_cmds=( rm set )


Expand Down
4 changes: 2 additions & 2 deletions completion/balena-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _balena_complete()
local cur prev

# Valid top-level completions
main_commands="api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release releases scan settings ssh support tag tags tunnel util version whoami"
main_commands="api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami"
# Sub-completions
api_key_cmds="generate list revoke"
app_cmds="create"
Expand All @@ -21,7 +21,7 @@ _balena_complete()
key_cmds="add rm"
local_cmds="configure flash"
os_cmds="build-config configure download initialize versions"
release_cmds="finalize invalidate validate"
release_cmds="finalize invalidate list validate"
tag_cmds="rm set"


Expand Down
51 changes: 29 additions & 22 deletions docs/balena-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ are encouraged to regularly update the balena CLI to the latest version.
- [release finalize](#release-finalize)
- [release](#release)
- [release invalidate](#release-invalidate)
- [release list](#release-list)
- [release validate](#release-validate)
- [releases](#releases)

- Settings

Expand Down Expand Up @@ -3581,29 +3581,14 @@ the commit or ID of the release to invalidate

### Options

## release validate

### Description
## release list

Validate a release.

Valid releases are automatically deployed to devices tracking the latest
release if they are finalized.

Examples:

$ balena release validate a777f7345fe3d655c1c981aa642e5555
$ balena release validate 1234567

### Arguments

#### COMMITORID
### Aliases

the commit or ID of the release to validate
- `releases`

### Options

## releases
To use one of the aliases, replace `release list` with the alias.

### Description

Expand All @@ -3626,8 +3611,8 @@ The 'jq' utility may be helpful for querying JSON fields in shell scripts

Examples:

$ balena releases myorg/myfleet
$ balena releases myorg/myfleet --json
$ balena release list myorg/myfleet
$ balena release list myorg/myfleet --json

### Arguments

Expand All @@ -3641,6 +3626,28 @@ fleet name or slug (preferred)

produce JSON output instead of tabular output

## release validate

### Description

Validate a release.

Valid releases are automatically deployed to devices tracking the latest
release if they are finalized.

Examples:

$ balena release validate a777f7345fe3d655c1c981aa642e5555
$ balena release validate 1234567

### Arguments

#### COMMITORID

the commit or ID of the release to validate

### Options

# Settings

## settings
Expand Down
2 changes: 1 addition & 1 deletion src/commands/device/pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class DevicePinCmd extends Command {
pinnedRelease
? `This device is currently pinned to ${pinnedRelease}.`
: 'This device is not currently pinned to any release.'
} \n\nTo see a list of all releases this device can be pinned to, run \`balena releases ${appSlug}\`.`,
} \n\nTo see a list of all releases this device can be pinned to, run \`balena release list ${appSlug}\`.`,
);
} else {
await balena.models.device.pinToRelease(params.uuid, releaseToPinTo);
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fleet/pin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class FleetPinCmd extends Command {
pinnedRelease
? `This fleet is currently pinned to ${pinnedRelease}.`
: 'This fleet is not currently pinned to any release.'
} \n\nTo see a list of all releases this fleet can be pinned to, run \`balena releases ${slug}\`.`,
} \n\nTo see a list of all releases this fleet can be pinned to, run \`balena release list ${slug}\`.`,
);
} else {
await balena.models.application.pinToRelease(slug, releaseToPinTo);
Expand Down
10 changes: 6 additions & 4 deletions src/commands/releases/index.ts → src/commands/release/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import { applicationNameNote } from '../../utils/messages';
import type * as BalenaSdk from 'balena-sdk';
import { jsonInfo } from '../../utils/messages';

export default class ReleasesCmd extends Command {
export default class ReleaseListCmd extends Command {
public static aliases = ['releases'];

public static description = stripIndent`
List all releases of a fleet.
Expand All @@ -33,8 +35,8 @@ export default class ReleasesCmd extends Command {
${jsonInfo.split('\n').join('\n\t\t')}
`;
public static examples = [
'$ balena releases myorg/myfleet',
'$ balena releases myorg/myfleet --json',
'$ balena release list myorg/myfleet',
'$ balena release list myorg/myfleet --json',
];

public static flags = {
Expand All @@ -52,7 +54,7 @@ export default class ReleasesCmd extends Command {
public static authenticated = true;

public async run() {
const { args: params, flags: options } = await this.parse(ReleasesCmd);
const { args: params, flags: options } = await this.parse(ReleaseListCmd);

const fields: Array<keyof BalenaSdk.Release> = [
'id',
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/release.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('balena release', function () {
it('should list releases', async () => {
api.expectGetRelease();
api.expectGetApplication();
const { out } = await runCommand('releases someapp');
const { out } = await runCommand('release list someapp');
const lines = cleanOutput(out);
expect(lines.length).to.be.equal(2);
expect(lines[1]).to.contain('142334');
Expand All @@ -78,7 +78,7 @@ describe('balena release', function () {
it('should list releases as JSON with the -j/--json flag', async () => {
api.expectGetRelease();
api.expectGetApplication();
const { err, out } = await runCommand('releases someapp --json');
const { err, out } = await runCommand('release list someapp --json');
expect(err).to.be.empty;
const json = JSON.parse(out.join(''));
expect(json[0].commit).to.equal('90247b54de4fa7a0a3cbc85e73c68039');
Expand Down
4 changes: 2 additions & 2 deletions tests/test-data/pkg/expected-warnings-darwin-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
%2: build/commands/release/invalidate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js
%2: build/commands/release/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/releases/index.js
%2: build/commands/release/validate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/scan/index.js
Expand Down
4 changes: 2 additions & 2 deletions tests/test-data/pkg/expected-warnings-darwin-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
%2: build/commands/release/invalidate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js
%2: build/commands/release/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/releases/index.js
%2: build/commands/release/validate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/scan/index.js
Expand Down
4 changes: 2 additions & 2 deletions tests/test-data/pkg/expected-warnings-linux-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
%2: build/commands/release/invalidate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js
%2: build/commands/release/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/releases/index.js
%2: build/commands/release/validate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/scan/index.js
Expand Down
4 changes: 2 additions & 2 deletions tests/test-data/pkg/expected-warnings-linux-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
%2: build/commands/release/invalidate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js
%2: build/commands/release/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/releases/index.js
%2: build/commands/release/validate.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/scan/index.js
Expand Down
4 changes: 2 additions & 2 deletions tests/test-data/pkg/expected-warnings-win32-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@
%2: build\commands\release\invalidate.js
> Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json
%2: build\commands\release\validate.js
%2: build\commands\release\list.js
> Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json
%2: build\commands\releases\index.js
%2: build\commands\release\validate.js
> Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json
%2: build\commands\scan\index.js
Expand Down

0 comments on commit 65b278e

Please sign in to comment.