-
Notifications
You must be signed in to change notification settings - Fork 349
/
update_versions.py
executable file
·41 lines (31 loc) · 1.17 KB
/
update_versions.py
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
#!/usr/bin/env python2
'''What? A Python script in a JavaScript library? Well I never...
This script is just for updating versions of Horizon, it doesn't get
packaged or have any use for consumers of Horizon itself.
'''
import json
import sys
from contextlib import contextmanager
from collections import OrderedDict
@contextmanager
def rewrite(filename):
with open(filename, 'rb') as f:
package_json = json.load(f, object_pairs_hook=OrderedDict)
yield package_json
with open(filename, 'wb') as f:
json.dump(package_json, f, indent=2, separators=(',', ': '))
f.write('\n') # json dump gives no trailing newline
def main(version):
with rewrite('./client/package.json') as client_pkg:
client_pkg['version'] = version
with rewrite('./server/package.json') as server_pkg:
server_pkg['version'] = version
server_pkg['dependencies']['@horizon/client'] = version
with rewrite('./cli/package.json') as cli_pkg:
cli_pkg['version'] = version
cli_pkg['dependencies']['@horizon/server'] = version
if __name__ == '__main__':
try:
main(sys.argv[1])
except:
print 'Please provide a version'