-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated versionId into main version command, cleaned error handling,…
… fixed fork parseint
- Loading branch information
Showing
8 changed files
with
48 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,34 @@ | ||
const request = require('request-promise-native'); | ||
const config = require('config'); | ||
|
||
exports.desc = 'List versions available in your project'; | ||
exports.desc = 'List versions available in your project or get version by semver'; | ||
exports.category = 'services'; | ||
exports.weight = 3; | ||
exports.action = 'versions'; | ||
|
||
exports.run = function({ opts }) { | ||
const { key } = opts; | ||
const { key, version } = opts; | ||
|
||
if (!key) { | ||
return Promise.reject(new Error('No api key provided. Please use --key')); | ||
} | ||
|
||
const uri = version | ||
? `${config.host}/api/v1/version/${version}` | ||
: `${config.host}/api/v1/version`; | ||
|
||
return request | ||
.get(`${config.host}/api/v1/version`, { | ||
.get(uri, { | ||
json: true, | ||
auth: { user: key }, | ||
}) | ||
.catch(err => { | ||
let errorDesc; | ||
try { | ||
errorDesc = JSON.parse(err.error).description; | ||
} catch (e) { | ||
errorDesc = 'Failed to get versions attached to the provided key.'; | ||
} | ||
return Promise.reject(new Error(errorDesc)); | ||
return Promise.reject( | ||
new Error( | ||
err.error && err.error.description | ||
? err.error.description | ||
: 'Failed to get version(s) attached to the provided key.', | ||
), | ||
); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters