mirror of https://github.com/openspug/spug
improve update
parent
38beefba78
commit
9cc939222d
|
@ -12,16 +12,17 @@ class Command(BaseCommand):
|
|||
help = '升级Spug版本'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
res = requests.get('https://gitee.com/api/v5/repos/openspug/spug/releases/latest').json()
|
||||
version, is_repair = res.get('tag_name'), False
|
||||
if not version:
|
||||
return self.stderr.write(self.style.ERROR('获取新版本失败,排除网络问题后请附带输出内容至官方论坛反馈'))
|
||||
if version == settings.SPUG_VERSION:
|
||||
version, is_repair = settings.SPUG_VERSION, False
|
||||
res = requests.get(f'https://api.spug.cc/apis/release/latest/?version={version}').json()
|
||||
if res['error']:
|
||||
return self.stderr.write(self.style.ERROR(f'获取新版本失败:{res["error"]}'))
|
||||
if not res['data']['has_new']:
|
||||
self.stdout.write(self.style.SUCCESS(''))
|
||||
is_repair = True
|
||||
answer = input(f'当前已是最新版本,是否要进行修复性更新[y|n]?')
|
||||
else:
|
||||
self.stdout.write(f'{version} 更新日志:\r\n' + res.get('body', ''))
|
||||
version = res['data']['version']
|
||||
self.stdout.write(res['data']['content'])
|
||||
answer = input(f'发现新版本 {version} 是否更新[y|n]?')
|
||||
if answer.lower() != 'y':
|
||||
return
|
||||
|
@ -29,7 +30,7 @@ class Command(BaseCommand):
|
|||
# update web
|
||||
web_dir = os.path.join(settings.BASE_DIR, '../spug_web')
|
||||
commands = [
|
||||
f'curl -o /tmp/spug_web.tar.gz https://cdn.spug.cc/spug/web_{version}.tar.gz',
|
||||
f'curl -o /tmp/spug_web.tar.gz http://cdn.spug.cc/spug/web_{version}.tar.gz',
|
||||
f'rm -rf {web_dir}/build',
|
||||
f'tar xf /tmp/spug_web.tar.gz -C {web_dir}'
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue