feat: remove global initialize
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
16ab108186
commit
a5cb084767
@ -1,14 +1,13 @@
|
|||||||
function upgradeModules(core) {
|
function exit() {
|
||||||
|
var http = require('@ccms/common/dist/http').default
|
||||||
|
function upgradeModules(core) {
|
||||||
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
||||||
var Paths = Java.type('java.nio.file.Paths')
|
var Paths = Java.type('java.nio.file.Paths')
|
||||||
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
||||||
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
|
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function exit() {
|
|
||||||
var http = require('@ccms/common/dist/http').default
|
|
||||||
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
|
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
|
||||||
|
|
||||||
console.debug('exit finish!')
|
console.debug('exit finish!')
|
||||||
}
|
}
|
||||||
exit()
|
exit()
|
||||||
|
@ -1,22 +1,34 @@
|
|||||||
var fs = require('@ccms/common/dist/fs')
|
global.initialize = function () {
|
||||||
function updateJar() {
|
var mspmc = 'https://ms.yumc.pw/api/plugin/download/name/'
|
||||||
if (!base.version) {
|
var artifact = 'https://ci.yumc.pw/job/Minecraft/job/MiaoScript/lastSuccessfulBuild/artifact'
|
||||||
|
|
||||||
|
var fs = require('@ccms/common/dist/fs')
|
||||||
|
var http = require('@ccms/common/dist/http').default
|
||||||
|
|
||||||
|
function updateJar() {
|
||||||
|
var DocumentBuilderFactory = Java.type('javax.xml.parsers.DocumentBuilderFactory')
|
||||||
|
var URLDecoder = Java.type('java.net.URLDecoder')
|
||||||
|
var pom = DocumentBuilderFactory.newInstance().newDocumentBuilder()
|
||||||
|
.parse(artifact + "/pom.xml")
|
||||||
|
var latestVersion = pom.getElementsByTagName("version").item(0).getTextContent()
|
||||||
|
if (base.version != latestVersion) {
|
||||||
var pluginFolder = fs.file(fs.concat(root, '..'))
|
var pluginFolder = fs.file(fs.concat(root, '..'))
|
||||||
var updateFolder = fs.concat(pluginFolder, 'update')
|
var updateFolder = fs.concat(pluginFolder, 'update')
|
||||||
|
fs.mkdirs(updateFolder)
|
||||||
|
var filePath = base.getInstance().class.classLoader.getURLs()[0]
|
||||||
|
var pluginFile = fs.file(URLDecoder.decode(filePath.getFile(), "UTF-8"))
|
||||||
|
var updateFile = fs.file(updateFolder, pluginFile.getName())
|
||||||
|
http.download(artifact + "/target/MiaoScript.jar", updateFile.getAbsolutePath())
|
||||||
|
console.info('MiaoScript found new version ' + latestVersion + ' will upgrade after reboot!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function upgradeModules(core) {
|
function upgradeModules(core) {
|
||||||
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
if (base.version && global.ScriptEngineVersion != core['dist-tags']['latest']) {
|
||||||
var Paths = Java.type('java.nio.file.Paths')
|
var Paths = Java.type('java.nio.file.Paths')
|
||||||
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
base.save(Paths.get(root, "upgrade"), core['dist-tags']['latest'])
|
||||||
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
|
console.info('@ccms/core found new version ' + core['dist-tags']['latest'] + ' will upgrade after reboot!')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function initialize() {
|
|
||||||
var mspmc = 'https://ms.yumc.pw/api/plugin/download/name/'
|
|
||||||
|
|
||||||
var http = require('@ccms/common/dist/http').default
|
|
||||||
|
|
||||||
var pluginFolder = fs.concat(root, 'plugins')
|
var pluginFolder = fs.concat(root, 'plugins')
|
||||||
var updateFolder = fs.concat(pluginFolder, 'update')
|
var updateFolder = fs.concat(pluginFolder, 'update')
|
||||||
var pluginFile = fs.concat(pluginFolder, 'MiaoScriptPackageManager.js')
|
var pluginFile = fs.concat(pluginFolder, 'MiaoScriptPackageManager.js')
|
||||||
@ -43,9 +55,14 @@ function initialize() {
|
|||||||
try {
|
try {
|
||||||
Java.type("org.bukkit.Bukkit")
|
Java.type("org.bukkit.Bukkit")
|
||||||
updateJar()
|
updateJar()
|
||||||
} catch (ignore) {
|
} catch (error) {
|
||||||
|
console.debug(error)
|
||||||
|
if (global.debug) {
|
||||||
|
console.ex(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
|
upgradeModules(http.get('https://registry.npmmirror.com/@ccms/core'))
|
||||||
console.debug('initialize finish!')
|
console.debug('initialize finish!')
|
||||||
}
|
}
|
||||||
initialize()
|
global.initialize()
|
||||||
|
delete global.initialize
|
||||||
|
Loading…
Reference in New Issue
Block a user