release: update to 0.9.3

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-09-21 16:06:37 +08:00
parent 427aa262f0
commit 7f85295eb1
3 changed files with 59 additions and 15 deletions

View File

@ -1,8 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pw.yumc</groupId>
<artifactId>MiaoScript</artifactId>
<version>0.9.1</version>
<version>0.9.3</version>
<developers>
<developer>
<id>502647092</id>
@ -53,6 +54,7 @@
<properties>
<env.GIT_COMMIT>DEV</env.GIT_COMMIT>
<update.changes>
§620-09-21 §afeat: 完善 upgrade 逻辑;
§620-08-27 §afeat: 新增ProtocolLib依赖;
§620-07-28 §afeat: 新增框架升级功能;
§620-06-23 §afeat: 支持自定义参数;

View File

@ -2,9 +2,9 @@ package pw.yumc.MiaoScript;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Collectors;
/**
* Created with IntelliJ IDEA
@ -32,27 +32,51 @@ public class Base {
}
public String read(String path) throws IOException {
return new String(Files.readAllBytes(new File(path).toPath()), "UTF-8");
return new String(Files.readAllBytes(new File(path).toPath()), StandardCharsets.UTF_8);
}
public void save(String path, String content) throws IOException {
File file = new File(path);
file.getParentFile().mkdirs();
Files.write(file.toPath(), content.getBytes("UTF-8"));
Files.write(file.toPath(), content.getBytes(StandardCharsets.UTF_8));
}
public void delete(String path) throws IOException {
delete(new File(path).toPath());
public boolean move(String source, String target) {
File file = new File(source);
return file.renameTo(new File(target));
}
public boolean delete(String path) throws IOException {
return delete(new File(path));
}
public void delete(Path path) throws IOException {
File file = path.toFile();
if (!file.exists()) { return; }
if (file.isDirectory()) {
for (Path f : Files.list(file.toPath()).collect(Collectors.toList())) {
delete(f);
delete(path.toFile());
}
public boolean delete(File file) throws IOException {
if (!file.exists()) {
return false;
}
if (file.isFile()) {
return file.delete();
}
File[] files = file.listFiles();
if (files != null) {
for (File f : files) {
if (f.isFile()) {
if (!f.delete()) {
f.deleteOnExit();
}
} else {
this.delete(f.getAbsolutePath());
}
}
}
Files.delete(path);
boolean result = file.delete();
if (!result) {
file.deleteOnExit();
}
return result;
}
}

View File

@ -5,6 +5,18 @@ var global = this;
*/
(function () {
var loader;
global.engineDisable = function () {
global.engineDisableImpl && global.engineDisableImpl()
if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "old_node_modules"))) {
logger.info('Found old_node_modules folder delete...');
base.delete(java.nio.file.Paths.get(root, "old_node_modules"))
}
if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "upgrade"))) {
logger.info('Found upgrade file delete node_modules...');
base.delete(java.nio.file.Paths.get(root, "node_modules"))
base.delete(java.nio.file.Paths.get(root, "upgrade"))
}
};
global.boot = function (root, logger) {
global.scope = java.lang.System.getenv("MS_NODE_CORE_SCOPE") || "@ccms";
global.log = logger;
@ -24,16 +36,22 @@ var global = this;
}
if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "upgrade"))) {
logger.info('Found upgrade file starting upgrade...');
base.delete(java.nio.file.Paths.get(root, "node_modules"))
base.move(java.nio.file.Paths.get(root, "node_modules"), java.nio.file.Paths.get(root, "old_node_modules"))
base.delete(java.nio.file.Paths.get(root, "upgrade"))
}
new java.lang.Thread(function () {
try {
base.delete(java.nio.file.Paths.get(root, "old_node_modules"))
} catch (ex) {
}
}, "MiaoScript node_modules clean thread").start()
// Check Class Loader, Sometimes Server will can't found plugin.yml file
loader = checkClassLoader();
// Async Loading MiaoScript Engine
new java.lang.Thread(function () {
java.lang.Thread.currentThread().contextClassLoader = loader;
load(java.lang.System.getenv("MS_NODE_CORE_PLOYFILL") || 'classpath:core/ployfill.js')(root, logger);
global.engineDisable = require(java.lang.System.getenv("MS_NODE_CORE_MODULE") || global.scope + '/core').default || function () {
global.engineDisableImpl = require(java.lang.System.getenv("MS_NODE_CORE_MODULE") || global.scope + '/core').default || function () {
logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
};
}, "MiaoScript thread").start()