-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversionUpdate.py
57 lines (53 loc) · 1.43 KB
/
versionUpdate.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import json
fPack = open('package.json', 'r+')
pack = json.load(fPack)
fPackApp = open('app/package.json', 'r+')
packApp = json.load(fPackApp)
fAssetV = open('src/assets/version.json', 'r+')
assetV = json.load(fAssetV)
print('Current version: ')
print(' package.json:' + pack['version'])
print(' app/package.json:' + packApp['version'])
print(' version.json:' + assetV['version'])
print('')
print('Update')
print('1) Major version')
print('2) Minor version')
print('3) Patch version')
print('4) Input verison')
isValid = False
newV = pack['version']
while (not isValid):
up = input()
isValid = True
index = -1
if (up == '1'):
index = 0
elif (up == '2'):
index = 1
elif (up == '3'):
index = 2
elif (up == '4'):
newV = input('Set version: ')
else:
print('Invalid, try again')
isValid = False
if isValid and index >= 0:
nums = pack['version'].split('.')
nums[index] = str(int(nums[index])+1)
for i in range(index+1, len(nums)):
nums[i] = '0'
newV = '.'.join(nums)
print('Set new version: ' + newV)
pack['version'] = newV
packApp['version'] = newV
assetV['version'] = newV
fPack.seek(0)
fPackApp.seek(0)
fAssetV.seek(0)
json.dump(pack, fPack, indent=2)
json.dump(packApp, fPackApp, indent=2)
json.dump(assetV, fAssetV, indent=2)
fPack.close()
fPackApp.close()
fAssetV.close()