|
|
|
@ -2,6 +2,7 @@ import { chmodSync } from 'fs'
|
|
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
import { Writer } from 'clitastic'
|
|
|
|
|
import semver from 'semver'
|
|
|
|
|
|
|
|
|
|
import { INSTALL_DIR, VERSION } from '..'
|
|
|
|
|
import { checkIfResticIsAvailable, downloadFile, exec } from '../utils'
|
|
|
|
@ -18,6 +19,11 @@ export async function upgrade() {
|
|
|
|
|
responseType: 'json',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const latest = semver.coerce(json.tag_name)
|
|
|
|
|
const current = semver.coerce(VERSION)
|
|
|
|
|
if (!latest || !current) throw new Error('Could not parse versions numbers.')
|
|
|
|
|
if (semver.gt(latest, current) && semver.major(latest) === semver.major(current)) {
|
|
|
|
|
// Update to compatible
|
|
|
|
|
if (json.tag_name != VERSION) {
|
|
|
|
|
const platformMap: { [key: string]: string } = {
|
|
|
|
|
darwin: 'macos',
|
|
|
|
@ -32,6 +38,7 @@ export async function upgrade() {
|
|
|
|
|
|
|
|
|
|
chmodSync(to, 0o755)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
w.done('All up to date! 🚀')
|
|
|
|
|
}
|
|
|
|
|