Skip to content

Commit 8ccc61d

Browse files
author
Oleg Sucharevich
authored
add get step versions (#359)
1 parent 372bb59 commit 8ccc61d

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lib/interface/cli/commands/step/get.cmd.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const { prepareKeyValueFromCLIEnvOption } = require('../../helpers/general');
77
const Output = require('../../../../output/Output');
88
const { sdk } = require('../../../../logic');
99
const StepType = require('../../../../logic/entities/StepType');
10+
const StepTypeVersion = require('../../../../logic/entities/StepTypeVersion');
1011

1112
const getRoot = require('../root/get.cmd');
1213

@@ -58,6 +59,11 @@ const command = new Command({
5859
describe: 'Limit amount of returned results',
5960
default: DEFAULTS.GET_LIMIT_RESULTS,
6061
})
62+
.option('versions', {
63+
describe: 'Get only typed-step versions',
64+
default: false,
65+
boolean: true,
66+
})
6167
.option('page', {
6268
describe: 'Paginated page',
6369
default: DEFAULTS.GET_PAGINATED_PAGE,
@@ -73,8 +79,12 @@ const command = new Command({
7379
const stage = argv.stage;
7480
const official = argv.official;
7581
const tag = argv.tag;
82+
const onlyVersions = argv.versions;
7683

77-
if (!_.isEmpty(ids)) {
84+
if (onlyVersions) {
85+
const res = await sdk.steps.getStepVersions({ name: ids[0] });
86+
Output.print(_.map(res, StepTypeVersion.fromResponse));
87+
} else if (!_.isEmpty(ids)) {
7888
const steps = [];
7989
for (const id of ids) {
8090
try {

lib/logic/entities/StepTypeVersion.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Entity = require('./Entity');
2+
const _ = require('lodash');
3+
4+
class StepTypeVersion extends Entity {
5+
constructor(data) {
6+
super();
7+
this.entityType = 'step-type-version';
8+
this.info = data;
9+
this.version = this.info;
10+
this.defaultColumns = ['version'];
11+
this.wideColumns = this.defaultColumns;
12+
}
13+
14+
static fromResponse(response) {
15+
return new StepTypeVersion(response);
16+
}
17+
}
18+
19+
module.exports = StepTypeVersion;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.32.1",
3+
"version": "0.33.0",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)