-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e836543
commit ad58830
Showing
5 changed files
with
58 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const Chalk = require('chalk'); | ||
const log = console.log; | ||
const Constants = require('../utils/constants'); | ||
const fs = require('fs-extra'); | ||
const Hive = require('../handlers/Hive'); | ||
const xml2js = require('xml2js'); | ||
|
||
// Main code // | ||
const self = module.exports = { | ||
getLatestVersion: (info) => { | ||
return new Promise((resolve, reject) => { | ||
const substitute = info.dependency.replace(/\./g, '/').replace(/:/g, '/') | ||
let url = `https://jcenter.bintray.com/${substitute}/maven-metadata.xml` | ||
|
||
require('node-read-url') | ||
.promise(url) | ||
.then(response => { | ||
xml2js.parseString(response, (err, result) => { | ||
if (result.metadata.version.length === 1) { | ||
resolve(result.metadata.version[0]) | ||
} else { | ||
resolve('+') | ||
} | ||
}); | ||
}).catch(err => resolve('+')); | ||
}).catch(err => resolve('+')); | ||
}, | ||
getLatestVersionByPair: (pair) => { | ||
return Hive.get(pair) | ||
.then(info => { | ||
return self.getLatestVersion(info); | ||
}).catch(err => { | ||
log(`Cant find the pair: ${pair}`) | ||
}); | ||
} | ||
}; | ||
|
||
|
||
// self.getLatestVersionByPair('square/picasso2') | ||
// .then(version => { | ||
// log(`version: ${version}`) | ||
// }) |
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