Skip to content

Commit dbb8977

Browse files
committed
added getbyid
1 parent c786949 commit dbb8977

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/versions/list.js renamed to lib/versions/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const config = require('config');
33

44
exports.desc = 'List versions available in your project';
55
exports.category = 'services';
6-
exports.weight = 4;
7-
exports.action = 'versions:list';
6+
exports.weight = 3;
87

98
exports.run = function({ opts }) {
109
let { key } = opts;

lib/versions/versionId.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const request = require('request-promise-native');
2+
const config = require('config');
3+
4+
exports.desc = 'List versions available in your project';
5+
exports.category = 'services';
6+
exports.weight = 4;
7+
exports.action = 'versions:versionId';
8+
9+
exports.run = function({ opts }) {
10+
let { key } = opts;
11+
const { version } = opts;
12+
13+
if (!key && opts.token) {
14+
console.warn(
15+
'Using `rdme` with --token has been deprecated. Please use --key and --id instead',
16+
);
17+
[key] = opts.token.split('-');
18+
}
19+
20+
if (!key) {
21+
return Promise.reject(new Error('No api key provided. Please use --key'));
22+
}
23+
24+
if (!version) {
25+
return Promise.reject(
26+
new Error('No version provided. Please specify a semantic version using --version'),
27+
);
28+
}
29+
30+
return request
31+
.get(`${config.host}/api/v1/version/${version}`, {
32+
json: true,
33+
auth: { user: key },
34+
})
35+
.catch(err => Promise.reject(new Error(err)));
36+
};

0 commit comments

Comments
 (0)