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