From adcc6dddefd3e203860776542a3ee7aef96c0965 Mon Sep 17 00:00:00 2001 From: lijiahang Date: Mon, 23 Dec 2024 10:52:49 +0800 Subject: [PATCH] =?UTF-8?q?:bookmark:=20=E5=8D=87=E7=BA=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-testing.yml | 6 +- docker-compose.yml | 8 +- docker/adminer/build.sh | 2 +- docker/mysql/build.sh | 2 +- docker/push.sh | 2 +- docker/redis/build.sh | 2 +- docker/service/build.sh | 2 +- orion-visor-dependencies/pom.xml | 2 +- .../framework/common/constant/AppConst.java | 2 +- .../dromara/visor/launch/ReplaceVersion.java | 141 ++++++++++++++++++ orion-visor-ui/.env.development | 2 +- orion-visor-ui/.env.production | 2 +- orion-visor-ui/package.json | 2 +- pom.xml | 2 +- 14 files changed, 159 insertions(+), 18 deletions(-) create mode 100644 orion-visor-launch/src/test/java/org/dromara/visor/launch/ReplaceVersion.java diff --git a/docker-compose-testing.yml b/docker-compose-testing.yml index e8d0ca86..5c03ad55 100644 --- a/docker-compose-testing.yml +++ b/docker-compose-testing.yml @@ -1,7 +1,7 @@ version: '3.3' services: service: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:2.2.2 privileged: true ports: - 1081:80 @@ -32,7 +32,7 @@ services: - mysql - redis mysql: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:2.2.2 privileged: true ports: - 3307:3306 @@ -52,7 +52,7 @@ services: retries: 10 start_period: 3s redis: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:2.2.2 privileged: true ports: - 6380:6379 diff --git a/docker-compose.yml b/docker-compose.yml index f5589b82..fe4f8f12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.3' services: service: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-service:2.2.2 privileged: true ports: - ${SERVICE_PORT:-1081}:80 @@ -32,7 +32,7 @@ services: - mysql - redis mysql: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:2.2.2 privileged: true ports: - 3307:3306 @@ -52,7 +52,7 @@ services: retries: 15 start_period: 3s redis: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:2.2.2 privileged: true ports: - 6380:6379 @@ -68,7 +68,7 @@ services: retries: 15 start_period: 3s adminer: - image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:2.2.1 + image: registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:2.2.2 ports: - 8081:8080 depends_on: diff --git a/docker/adminer/build.sh b/docker/adminer/build.sh index e3483ee7..d7d3d9ce 100644 --- a/docker/adminer/build.sh +++ b/docker/adminer/build.sh @@ -1,4 +1,4 @@ #/bin/bash -version=2.2.1 +version=2.2.2 docker build -t orion-visor-adminer:${version} . docker tag orion-visor-adminer:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:${version} diff --git a/docker/mysql/build.sh b/docker/mysql/build.sh index 97640ce5..7adbd875 100644 --- a/docker/mysql/build.sh +++ b/docker/mysql/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.2.1 +version=2.2.2 cp -r ../../sql ./sql docker build -t orion-visor-mysql:${version} . rm -rf ./sql diff --git a/docker/push.sh b/docker/push.sh index d1d35bee..b6adbfe4 100644 --- a/docker/push.sh +++ b/docker/push.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.2.1 +version=2.2.2 docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:${version} docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:${version} docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version} diff --git a/docker/redis/build.sh b/docker/redis/build.sh index f0dab071..d081b421 100644 --- a/docker/redis/build.sh +++ b/docker/redis/build.sh @@ -1,4 +1,4 @@ #/bin/bash -version=2.2.1 +version=2.2.2 docker build -t orion-visor-redis:${version} . docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version} diff --git a/docker/service/build.sh b/docker/service/build.sh index 72f20b61..d3cd1640 100644 --- a/docker/service/build.sh +++ b/docker/service/build.sh @@ -1,5 +1,5 @@ #/bin/bash -version=2.2.1 +version=2.2.2 mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar mv ../../orion-visor-ui/dist ./dist docker build --no-cache -t orion-visor-service:${version} . diff --git a/orion-visor-dependencies/pom.xml b/orion-visor-dependencies/pom.xml index 0d9308f5..b58050a5 100644 --- a/orion-visor-dependencies/pom.xml +++ b/orion-visor-dependencies/pom.xml @@ -14,7 +14,7 @@ https://github.com/dromara/orion-visor - 2.2.1 + 2.2.2 2.7.17 2.7.15 1.5.0 diff --git a/orion-visor-framework/orion-visor-framework-common/src/main/java/org/dromara/visor/framework/common/constant/AppConst.java b/orion-visor-framework/orion-visor-framework-common/src/main/java/org/dromara/visor/framework/common/constant/AppConst.java index 02c92cc0..afe34011 100644 --- a/orion-visor-framework/orion-visor-framework-common/src/main/java/org/dromara/visor/framework/common/constant/AppConst.java +++ b/orion-visor-framework/orion-visor-framework-common/src/main/java/org/dromara/visor/framework/common/constant/AppConst.java @@ -36,7 +36,7 @@ public interface AppConst extends OrionConst { /** * 同 ${orion.version} 迭代时候需要手动更改 */ - String VERSION = "2.2.1"; + String VERSION = "2.2.2"; /** * 同 ${spring.application.name} diff --git a/orion-visor-launch/src/test/java/org/dromara/visor/launch/ReplaceVersion.java b/orion-visor-launch/src/test/java/org/dromara/visor/launch/ReplaceVersion.java new file mode 100644 index 00000000..accab2ec --- /dev/null +++ b/orion-visor-launch/src/test/java/org/dromara/visor/launch/ReplaceVersion.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2023 - present Dromara, All rights reserved. + * + * https://visor.dromara.org + * https://visor.dromara.org.cn + * https://visor.orionsec.cn + * + * Members: + * lijiahangmax ljh1553488six@139.com - author + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.dromara.visor.launch; + +import cn.orionsec.kit.lang.utils.io.FileReaders; +import cn.orionsec.kit.lang.utils.io.FileWriters; +import cn.orionsec.kit.lang.utils.io.Files1; + +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.util.function.Function; + +/** + * 替换版本号 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/12/23 10:21 + */ +public class ReplaceVersion { + + private static final String TARGET_VERSION = "2.2.1"; + + private static final String REPLACE_VERSION = "2.2.2"; + + private static final String PATH = new File("").getAbsolutePath(); + + private static final String[] DOCKER_FILES = new String[]{ + "docker/push.sh", + "docker/adminer/build.sh", + "docker/adminer/build.sh", + "docker/mysql/build.sh", + "docker/redis/build.sh", + "docker/service/build.sh", + "docker-compose.yml", + "docker-compose-testing.yml" + }; + + private static final String[] POM_FILES = new String[]{ + "pom.xml", + "orion-visor-dependencies/pom.xml" + }; + + private static final String APP_CONST_FILE = "orion-visor-framework/orion-visor-framework-common/src/main/java/org/dromara/visor/framework/common/constant/AppConst.java"; + + private static final String PACKAGE_JSON_FILE = "orion-visor-ui/package.json"; + + private static final String[] VITE_ENV_FILES = new String[]{ + "orion-visor-ui/.env.development", + "orion-visor-ui/.env.production" + }; + + public static void main(String[] args) { + replaceDockerFiles(); + replacePomFiles(); + replaceAppConst(); + replacePackageJson(); + replaceViteEnvFiles(); + } + + /** + * 替换 docker 文件 + */ + private static void replaceDockerFiles() { + for (String file : DOCKER_FILES) { + readAndWrite(file, s -> s.replaceAll(TARGET_VERSION, REPLACE_VERSION)); + } + } + + /** + * 替换 pom 文件 + */ + private static void replacePomFiles() { + for (String file : POM_FILES) { + readAndWrite(file, s -> s.replaceAll("" + TARGET_VERSION + "", "" + REPLACE_VERSION + "")); + } + } + + /** + * 替换 AppConst 文件 + */ + private static void replaceAppConst() { + readAndWrite(APP_CONST_FILE, s -> s.replaceAll("String VERSION = \"" + TARGET_VERSION + "\"", "String VERSION = \"" + REPLACE_VERSION + "\"")); + } + + /** + * 替换 package.json 文件 + */ + private static void replacePackageJson() { + readAndWrite(PACKAGE_JSON_FILE, s -> s.replaceAll("\"version\": \"" + TARGET_VERSION + "\"", "\"version\": \"" + REPLACE_VERSION + "\"")); + } + + /** + * 替换 .env 文件 + */ + private static void replaceViteEnvFiles() { + for (String file : VITE_ENV_FILES) { + readAndWrite(file, s -> s.replaceAll("VITE_APP_VERSION= '" + TARGET_VERSION + "'", "VITE_APP_VERSION= '" + REPLACE_VERSION + "'")); + } + } + + /** + * 读取并且写入 + * + * @param path path + * @param mapping mapping + */ + private static void readAndWrite(String path, Function mapping) { + String filePath = Files1.getPath(PATH, path); + try { + // 读取文件内容 + byte[] bytes = FileReaders.readAllBytesFast(filePath); + // 写入文件内容 + FileWriters.writeFast(filePath, mapping.apply(new String(bytes)).getBytes(StandardCharsets.UTF_8)); + System.out.println("OK: " + path); + } catch (Exception e) { + System.err.println("ERR: " + path); + } + } + +} diff --git a/orion-visor-ui/.env.development b/orion-visor-ui/.env.development index 65c94ad9..d80f7e22 100644 --- a/orion-visor-ui/.env.development +++ b/orion-visor-ui/.env.development @@ -1,3 +1,3 @@ VITE_API_BASE_URL= 'http://127.0.0.1:9200/orion-visor/api' VITE_WS_BASE_URL= 'ws://127.0.0.1:9200/orion-visor/keep-alive' -VITE_APP_VERSION= '2.2.1' +VITE_APP_VERSION= '2.2.2' diff --git a/orion-visor-ui/.env.production b/orion-visor-ui/.env.production index 41aa34ed..9b71a198 100644 --- a/orion-visor-ui/.env.production +++ b/orion-visor-ui/.env.production @@ -1,3 +1,3 @@ VITE_API_BASE_URL= '/orion-visor/api' VITE_WS_BASE_URL= '/orion-visor/keep-alive' -VITE_APP_VERSION= '2.2.1' +VITE_APP_VERSION= '2.2.2' diff --git a/orion-visor-ui/package.json b/orion-visor-ui/package.json index 5efdcdbc..c2e33805 100644 --- a/orion-visor-ui/package.json +++ b/orion-visor-ui/package.json @@ -1,7 +1,7 @@ { "name": "orion-visor-ui", "description": "Orion Visor UI", - "version": "2.2.1", + "version": "2.2.2", "private": true, "author": "Jiahang Li", "license": "Apache 2.0", diff --git a/pom.xml b/pom.xml index 7f9d9d82..9bff4f88 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ - 2.2.1 + 2.2.2 8 8 3.0.0-M5