6
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								pom.xml
									
									
									
									
									
								
							@@ -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>
 | 
					    <modelVersion>4.0.0</modelVersion>
 | 
				
			||||||
    <groupId>pw.yumc</groupId>
 | 
					    <groupId>pw.yumc</groupId>
 | 
				
			||||||
    <artifactId>MiaoScript</artifactId>
 | 
					    <artifactId>MiaoScript</artifactId>
 | 
				
			||||||
    <version>0.9.1</version>
 | 
					    <version>0.9.3</version>
 | 
				
			||||||
    <developers>
 | 
					    <developers>
 | 
				
			||||||
        <developer>
 | 
					        <developer>
 | 
				
			||||||
            <id>502647092</id>
 | 
					            <id>502647092</id>
 | 
				
			||||||
@@ -53,6 +54,7 @@
 | 
				
			|||||||
    <properties>
 | 
					    <properties>
 | 
				
			||||||
        <env.GIT_COMMIT>DEV</env.GIT_COMMIT>
 | 
					        <env.GIT_COMMIT>DEV</env.GIT_COMMIT>
 | 
				
			||||||
        <update.changes>
 | 
					        <update.changes>
 | 
				
			||||||
 | 
					            §620-09-21 §afeat: 完善 upgrade 逻辑;
 | 
				
			||||||
            §620-08-27 §afeat: 新增ProtocolLib依赖;
 | 
					            §620-08-27 §afeat: 新增ProtocolLib依赖;
 | 
				
			||||||
            §620-07-28 §afeat: 新增框架升级功能;
 | 
					            §620-07-28 §afeat: 新增框架升级功能;
 | 
				
			||||||
            §620-06-23 §afeat: 支持自定义参数;
 | 
					            §620-06-23 §afeat: 支持自定义参数;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,9 +2,9 @@ package pw.yumc.MiaoScript;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.io.File;
 | 
					import java.io.File;
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
 | 
					import java.nio.charset.StandardCharsets;
 | 
				
			||||||
import java.nio.file.Files;
 | 
					import java.nio.file.Files;
 | 
				
			||||||
import java.nio.file.Path;
 | 
					import java.nio.file.Path;
 | 
				
			||||||
import java.util.stream.Collectors;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Created with IntelliJ IDEA
 | 
					 * Created with IntelliJ IDEA
 | 
				
			||||||
@@ -32,27 +32,51 @@ public class Base {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String read(String path) throws IOException {
 | 
					    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 {
 | 
					    public void save(String path, String content) throws IOException {
 | 
				
			||||||
        File file = new File(path);
 | 
					        File file = new File(path);
 | 
				
			||||||
        file.getParentFile().mkdirs();
 | 
					        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 {
 | 
					    public boolean move(String source, String target) {
 | 
				
			||||||
        delete(new File(path).toPath());
 | 
					        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 {
 | 
					    public void delete(Path path) throws IOException {
 | 
				
			||||||
        File file = path.toFile();
 | 
					        delete(path.toFile());
 | 
				
			||||||
        if (!file.exists()) { return; }
 | 
					    }
 | 
				
			||||||
        if (file.isDirectory()) {
 | 
					
 | 
				
			||||||
            for (Path f : Files.list(file.toPath()).collect(Collectors.toList())) {
 | 
					    public boolean delete(File file) throws IOException {
 | 
				
			||||||
                delete(f);
 | 
					        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;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,18 @@ var global = this;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
(function () {
 | 
					(function () {
 | 
				
			||||||
    var loader;
 | 
					    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.boot = function (root, logger) {
 | 
				
			||||||
        global.scope = java.lang.System.getenv("MS_NODE_CORE_SCOPE") || "@ccms";
 | 
					        global.scope = java.lang.System.getenv("MS_NODE_CORE_SCOPE") || "@ccms";
 | 
				
			||||||
        global.log = logger;
 | 
					        global.log = logger;
 | 
				
			||||||
@@ -24,16 +36,22 @@ var global = this;
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "upgrade"))) {
 | 
					        if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "upgrade"))) {
 | 
				
			||||||
            logger.info('Found upgrade file starting 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"))
 | 
					            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
 | 
					        // Check Class Loader, Sometimes Server will can't found plugin.yml file
 | 
				
			||||||
        loader = checkClassLoader();
 | 
					        loader = checkClassLoader();
 | 
				
			||||||
        // Async Loading MiaoScript Engine
 | 
					        // Async Loading MiaoScript Engine
 | 
				
			||||||
        new java.lang.Thread(function () {
 | 
					        new java.lang.Thread(function () {
 | 
				
			||||||
            java.lang.Thread.currentThread().contextClassLoader = loader;
 | 
					            java.lang.Thread.currentThread().contextClassLoader = loader;
 | 
				
			||||||
            load(java.lang.System.getenv("MS_NODE_CORE_PLOYFILL") || 'classpath:core/ployfill.js')(root, logger);
 | 
					            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...')
 | 
					                logger.info('Error: abnormal Initialization MiaoScript Engine. Skip disable step...')
 | 
				
			||||||
            };
 | 
					            };
 | 
				
			||||||
        }, "MiaoScript thread").start()
 | 
					        }, "MiaoScript thread").start()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user