2015-01-20 22:39:14 +00:00
|
|
|
var app = require('app');
|
2015-01-21 05:53:53 +00:00
|
|
|
var fs = require('fs');
|
2015-01-21 06:01:37 +00:00
|
|
|
var path = require('path');
|
2015-01-21 05:53:53 +00:00
|
|
|
var request = require('request');
|
|
|
|
|
2015-01-23 20:16:49 +00:00
|
|
|
var TARGET_URL = 'https://atom.io/download/atom-shell/index.json';
|
2015-01-20 22:39:14 +00:00
|
|
|
|
|
|
|
function getDate() {
|
|
|
|
var today = new Date();
|
|
|
|
var year = today.getFullYear();
|
|
|
|
var month = today.getMonth() + 1;
|
|
|
|
if (month <= 9)
|
|
|
|
month = '0' + month;
|
|
|
|
var day= today.getDate();
|
|
|
|
if (day <= 9)
|
|
|
|
day = '0' + day;
|
|
|
|
return year + '-' + month + '-' + day;
|
|
|
|
}
|
|
|
|
|
2015-01-21 06:01:37 +00:00
|
|
|
function getApmVersion() {
|
|
|
|
var package = require(path.resolve(__dirname, '..', 'package.json'));
|
|
|
|
return package.devDependencies['atom-package-manager'];
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:53:53 +00:00
|
|
|
function getInfoForCurrentVersion() {
|
2015-01-20 22:39:14 +00:00
|
|
|
var json = {};
|
|
|
|
json.version = process.versions['atom-shell'];
|
|
|
|
json.date = getDate();
|
2015-01-21 06:01:37 +00:00
|
|
|
json.apm = getApmVersion();
|
2015-01-20 22:39:14 +00:00
|
|
|
|
2015-01-21 21:37:52 +00:00
|
|
|
var names = ['node', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'chrome']
|
2015-01-20 22:39:14 +00:00
|
|
|
for (var i in names) {
|
|
|
|
var name = names[i];
|
|
|
|
json[name] = process.versions[name];
|
|
|
|
}
|
|
|
|
|
|
|
|
json.files = [
|
|
|
|
'darwin-x64',
|
|
|
|
'darwin-x64-symbols',
|
|
|
|
'linux-ia32',
|
|
|
|
'linux-ia32-symbols',
|
|
|
|
'linux-x64',
|
|
|
|
'linux-x64-symbols',
|
|
|
|
'win32-ia32',
|
|
|
|
'win32-ia32-symbols',
|
|
|
|
];
|
|
|
|
|
2015-01-21 05:53:53 +00:00
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getIndexJsInServer(callback) {
|
|
|
|
request(TARGET_URL, function(e, res, body) {
|
|
|
|
if (e)
|
|
|
|
callback(e);
|
|
|
|
else if (res.statusCode != 200)
|
|
|
|
callback(new Error('Server returned ' + res.statusCode));
|
|
|
|
else
|
|
|
|
callback(null, JSON.parse(body));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function findObjectByVersion(all, version) {
|
|
|
|
for (var i in all)
|
|
|
|
if (all[i].version == version)
|
|
|
|
return i;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
app.on('ready', function() {
|
|
|
|
getIndexJsInServer(function(e, all) {
|
|
|
|
if (e) {
|
|
|
|
console.error(e);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
var current = getInfoForCurrentVersion();
|
|
|
|
var found = findObjectByVersion(all, current.version);
|
|
|
|
if (found == -1)
|
|
|
|
all.unshift(current);
|
|
|
|
else
|
|
|
|
all[found] = current;
|
|
|
|
|
|
|
|
fs.writeFileSync(process.argv[2], JSON.stringify(all));
|
|
|
|
process.exit(0);
|
|
|
|
});
|
2015-01-20 22:39:14 +00:00
|
|
|
});
|