30 Star 207 Fork 28

快编程 / axe.store

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
update.gua 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
dudu_axe 提交于 2022-06-22 20:10 . axe.store 2.0.0
con importUtil = import("util")
con importPath = import("path")
con importConfig = import("config")
con isJson = importConfig.config.isJson
con wirteLogFile = importUtil.wirteLogFile
con versionLocal = function() {
con metaBin = importPath.pathMetaBin()
con versionFile = '{}/{}'.format(metaBin, 'version')
if (importUtil.guaFileExist(versionFile)) {
con c = 'cat {}'.format(versionFile)
con r = importUtil.call(c)
return importUtil.guaStringToInt(r)
} else {
return 0
}
}
con versionRemote = function() {
con c = 'curl -sL https://gitee.com/kuaibiancheng/store/raw/master/version'
con r = os.exec(c)
if (r.exitCode == 0) {
con output = r.output
var version = int(output)
return version
} else {
if (isJson) {
con m = "由于网络问题未检查更新"
wirteLogFile(m)
} else {
log('由于网络问题未检查更新')
}
return -1
}
}
con checkVersion = function() {
con l = versionLocal()
con r = versionRemote()
con isOldVersion = r > l
return isOldVersion
}
con replaceMeta = function() {
con pathTmp = '{}/tmp_repo'.format(importPath.pathHome())
con repoUrl = 'https://gitee.com/kuaibiancheng/store'
con commandGit = 'git clone --depth=1 {} {}'.format(repoUrl, pathTmp)
importUtil.call(commandGit)
con pathMetaBin = importPath.pathMetaBin()
con commandCp = 'cp -r {}/* {}'.format(pathTmp, pathMetaBin)
importUtil.call(commandCp)
updateGualang(pathTmp)
importUtil.guaFileRm(pathTmp)
}
con updateGualang = function(repoPath) {
con c1 = 'cp {}/gualang/* /usr/local/axe/meta'.format(repoPath)
con c2 = "chmod +x /usr/local/axe/meta/gualang"
importUtil.callWithoutOutput(c1)
importUtil.callWithoutOutput(c2)
}
con clear = function() {
con pathOutput = importPath.pathAsyncOutput()
importUtil.guaFileRm(pathOutput)
}
con updateStore = function() {
clear()
con isOldVersion = checkVersion()
if (isOldVersion) {
replaceMeta()
return true
} else {
return false
}
}
1
https://gitee.com/kuaibiancheng/store.git
git@gitee.com:kuaibiancheng/store.git
kuaibiancheng
store
axe.store
master

搜索帮助