-
Notifications
You must be signed in to change notification settings - Fork 1
/
v-release.js
57 lines (45 loc) · 1.29 KB
/
v-release.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Altera a versão para RELEASE antes do build
*/
const fs = require('fs');
const http = require('http');
const semver = require('semver');
var options = {
hostname: 'registry.npmjs.org',
port: 80,
path: '/react-native-ui-blueprint',
method: 'GET',
headers: {
'Accept': 'application/json'
}
};
var req = http.request(options, function (res) {
var json = '';
res.setEncoding('utf8');
res.on('data', function (data) {
json += data;
});
res.on('end', function () {
let info = JSON.parse(json);
// No formato '0.1.0', '0.2.0'
var release = '0.0.0';
var version = '';
for (var v in info.versions) {
if (semver.prerelease(v)) {
continue;
} else if (semver.gt(v, release)) {
release = v;
}
}
// Numero da nova versão SNAPHSOT (pre)
var version = semver.inc(release, 'minor');
console.log('Incrementing react-native-ui-blueprint version to: "' + version + '"');
var packageJson = require('./package.json');
packageJson.version = version;
fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 4));
});
});
req.on('error', function (e) {
throw e;
});
req.end();