Skip to content

Commit f6db9bc

Browse files
committed
Merge pull request electron#1034 from atom/index-js
Update index.json when publishing
2 parents 7c0f414 + b8d0c5b commit f6db9bc

File tree

3 files changed

+98
-2
lines changed

3 files changed

+98
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
],
1111

1212
"devDependencies": {
13-
"atom-package-manager": "0.112.0",
13+
"atom-package-manager": "0.122.0",
1414
"coffee-script": "~1.7.1",
15-
"coffeelint": "~1.3.0"
15+
"coffeelint": "~1.3.0",
16+
"request": "*"
1617
},
1718

1819
"private": true,

script/dump-version-info.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var app = require('app');
2+
var fs = require('fs');
3+
var path = require('path');
4+
var request = require('request');
5+
6+
var TARGET_URL = 'http://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/index.json';
7+
8+
function getDate() {
9+
var today = new Date();
10+
var year = today.getFullYear();
11+
var month = today.getMonth() + 1;
12+
if (month <= 9)
13+
month = '0' + month;
14+
var day= today.getDate();
15+
if (day <= 9)
16+
day = '0' + day;
17+
return year + '-' + month + '-' + day;
18+
}
19+
20+
function getApmVersion() {
21+
var package = require(path.resolve(__dirname, '..', 'package.json'));
22+
return package.devDependencies['atom-package-manager'];
23+
}
24+
25+
function getInfoForCurrentVersion() {
26+
var json = {};
27+
json.version = process.versions['atom-shell'];
28+
json.date = getDate();
29+
json.apm = getApmVersion();
30+
31+
var names = ['node', 'v8', 'uv', 'zlib', 'openssl', 'modules', 'chrome']
32+
for (var i in names) {
33+
var name = names[i];
34+
json[name] = process.versions[name];
35+
}
36+
37+
json.files = [
38+
'darwin-x64',
39+
'darwin-x64-symbols',
40+
'linux-ia32',
41+
'linux-ia32-symbols',
42+
'linux-x64',
43+
'linux-x64-symbols',
44+
'win32-ia32',
45+
'win32-ia32-symbols',
46+
];
47+
48+
return json;
49+
}
50+
51+
function getIndexJsInServer(callback) {
52+
request(TARGET_URL, function(e, res, body) {
53+
if (e)
54+
callback(e);
55+
else if (res.statusCode != 200)
56+
callback(new Error('Server returned ' + res.statusCode));
57+
else
58+
callback(null, JSON.parse(body));
59+
});
60+
}
61+
62+
function findObjectByVersion(all, version) {
63+
for (var i in all)
64+
if (all[i].version == version)
65+
return i;
66+
return -1;
67+
}
68+
69+
app.on('ready', function() {
70+
getIndexJsInServer(function(e, all) {
71+
if (e) {
72+
console.error(e);
73+
process.exit(1);
74+
}
75+
76+
var current = getInfoForCurrentVersion();
77+
var found = findObjectByVersion(all, current.version);
78+
if (found == -1)
79+
all.unshift(current);
80+
else
81+
all[found] = current;
82+
83+
fs.writeFileSync(process.argv[2], JSON.stringify(all));
84+
process.exit(0);
85+
});
86+
});

script/upload.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ def upload_node(bucket, access_key, secret_key, version):
190190
s3put(bucket, access_key, secret_key, OUT_DIR,
191191
'atom-shell/dist/{0}'.format(version), [node_lib])
192192

193+
# Upload the index.json
194+
atom_shell = os.path.join(OUT_DIR, 'atom.exe')
195+
index_json = os.path.join(OUT_DIR, 'index.json')
196+
execute([atom_shell,
197+
os.path.join(SOURCE_ROOT, 'script', 'dump-version-info.js'),
198+
index_json])
199+
s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',
200+
[index_json])
201+
193202

194203
def auth_token():
195204
token = os.environ.get('ATOM_SHELL_GITHUB_TOKEN')

0 commit comments

Comments
 (0)