ares-ssh-deploy 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +471 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/types/index.d.ts +67 -0
- package/dist/utils/childProcess.cjs +1 -0
- package/dist/utils/childProcess.d.cts +103 -0
- package/dist/utils/childProcess.d.mts +103 -0
- package/dist/utils/childProcess.d.ts +103 -0
- package/dist/utils/childProcess.mjs +1 -0
- package/dist/utils/common.cjs +1 -0
- package/dist/utils/common.d.cts +45 -0
- package/dist/utils/common.d.mts +45 -0
- package/dist/utils/common.d.ts +45 -0
- package/dist/utils/common.mjs +1 -0
- package/dist/utils/deploy-linux-bastion.cjs +1 -0
- package/dist/utils/deploy-linux-bastion.d.cts +120 -0
- package/dist/utils/deploy-linux-bastion.d.mts +120 -0
- package/dist/utils/deploy-linux-bastion.d.ts +120 -0
- package/dist/utils/deploy-linux-bastion.mjs +1 -0
- package/dist/utils/deploy-windows-server.cjs +1 -0
- package/dist/utils/deploy-windows-server.d.cts +66 -0
- package/dist/utils/deploy-windows-server.d.mts +66 -0
- package/dist/utils/deploy-windows-server.d.ts +66 -0
- package/dist/utils/deploy-windows-server.mjs +1 -0
- package/dist/utils/logger.cjs +1 -0
- package/dist/utils/logger.d.cts +5 -0
- package/dist/utils/logger.d.mts +5 -0
- package/dist/utils/logger.d.ts +5 -0
- package/dist/utils/logger.mjs +1 -0
- package/dist/utils/ssh.cjs +1 -0
- package/dist/utils/ssh.d.cts +226 -0
- package/dist/utils/ssh.d.mts +226 -0
- package/dist/utils/ssh.d.ts +226 -0
- package/dist/utils/ssh.mjs +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ExecOptions, SpawnOptions } from 'child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 下午4:10
|
|
6
|
+
* @description: 使用fs.rename重命名文件夹
|
|
7
|
+
* @param oldPath 原文件夹路径
|
|
8
|
+
* @param newPath 新文件夹路径
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
declare function renameDirectory(oldPath: string, newPath: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* @author: ares
|
|
14
|
+
* @date: 2025/8/28 下午1:34
|
|
15
|
+
* @description: 用exec执行命令
|
|
16
|
+
* @param command
|
|
17
|
+
* @param config
|
|
18
|
+
* @returns {Promise<*>}
|
|
19
|
+
*/
|
|
20
|
+
declare function execCommand(command: string, config?: ExecOptions): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* @author: ares
|
|
23
|
+
* @date: 2025/8/28 下午1:27
|
|
24
|
+
* @description: 用exec执行CD命令
|
|
25
|
+
* @param path
|
|
26
|
+
* @returns {Promise<*>}
|
|
27
|
+
*/
|
|
28
|
+
declare function execCDCommand(path: string): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* @author: ares
|
|
31
|
+
* @date: 2025/8/28 下午1:27
|
|
32
|
+
* @description: 用exec执行PNPM命令
|
|
33
|
+
* @param script
|
|
34
|
+
* @param projectDir
|
|
35
|
+
* @returns {Promise<*>}
|
|
36
|
+
*/
|
|
37
|
+
declare function execPNPMCommand(script: string, projectDir: string): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* @author: ares
|
|
40
|
+
* @date: 2025/8/28 下午1:27
|
|
41
|
+
* @description: 用exec执行项目的PNPM命令
|
|
42
|
+
* @param projectDir
|
|
43
|
+
* @param script
|
|
44
|
+
* @returns {Promise<*>}
|
|
45
|
+
*/
|
|
46
|
+
declare function execProjectPNPMCommand(projectDir: string, script: string): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* @author: ares
|
|
49
|
+
* @date: 2025/8/28 下午1:42
|
|
50
|
+
* @description: 在指定目录下用exec执行命令
|
|
51
|
+
* @param dir
|
|
52
|
+
* @param command
|
|
53
|
+
* @returns {Promise<*>}
|
|
54
|
+
*/
|
|
55
|
+
declare function execCommandUnderDirectory(dir: string, command: string): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* @author: ares
|
|
58
|
+
* @date: 2025/8/28 下午2:49
|
|
59
|
+
* @description: 用spawn执行命令
|
|
60
|
+
* @param command
|
|
61
|
+
* @param args
|
|
62
|
+
* @param config
|
|
63
|
+
* @returns {Promise<*>}
|
|
64
|
+
*/
|
|
65
|
+
declare function spawnCommand(command: any, args?: string[], config?: SpawnOptions): Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* @author: ares
|
|
68
|
+
* @date: 2025/8/28 下午1:27
|
|
69
|
+
* @description: 用spawn执行CD命令
|
|
70
|
+
* @param path
|
|
71
|
+
* @returns {Promise<*>}
|
|
72
|
+
*/
|
|
73
|
+
declare function spawnCDCommand(path: string): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* @author: ares
|
|
76
|
+
* @date: 2025/8/28 下午1:27
|
|
77
|
+
* @description: 执行PNPM命令
|
|
78
|
+
* @param script
|
|
79
|
+
* @param projectDir
|
|
80
|
+
* @returns {Promise<*>}
|
|
81
|
+
*/
|
|
82
|
+
declare function spawnPNPMCommand(script: string, projectDir: string): Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* @author: ares
|
|
85
|
+
* @date: 2025/8/28 下午1:27
|
|
86
|
+
* @description: 用spawn执行项目的PNPM命令
|
|
87
|
+
* @param projectDir
|
|
88
|
+
* @param script
|
|
89
|
+
* @returns {Promise<*>}
|
|
90
|
+
*/
|
|
91
|
+
declare function spawnProjectPNPMCommand(projectDir: string, script: string): Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
* @author: ares
|
|
94
|
+
* @date: 2025/8/28 下午1:42
|
|
95
|
+
* @description: 在指定目录下用spawn执行命令
|
|
96
|
+
* @param dir
|
|
97
|
+
* @param command
|
|
98
|
+
* @param args
|
|
99
|
+
* @returns {Promise<*>}
|
|
100
|
+
*/
|
|
101
|
+
declare function spawnCommandUnderDirectory(dir: string, command: string, args?: string[]): Promise<any>;
|
|
102
|
+
|
|
103
|
+
export { execCDCommand, execCommand, execCommandUnderDirectory, execPNPMCommand, execProjectPNPMCommand, renameDirectory, spawnCDCommand, spawnCommand, spawnCommandUnderDirectory, spawnPNPMCommand, spawnProjectPNPMCommand };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ExecOptions, SpawnOptions } from 'child_process';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 下午4:10
|
|
6
|
+
* @description: 使用fs.rename重命名文件夹
|
|
7
|
+
* @param oldPath 原文件夹路径
|
|
8
|
+
* @param newPath 新文件夹路径
|
|
9
|
+
* @returns {Promise<void>}
|
|
10
|
+
*/
|
|
11
|
+
declare function renameDirectory(oldPath: string, newPath: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* @author: ares
|
|
14
|
+
* @date: 2025/8/28 下午1:34
|
|
15
|
+
* @description: 用exec执行命令
|
|
16
|
+
* @param command
|
|
17
|
+
* @param config
|
|
18
|
+
* @returns {Promise<*>}
|
|
19
|
+
*/
|
|
20
|
+
declare function execCommand(command: string, config?: ExecOptions): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* @author: ares
|
|
23
|
+
* @date: 2025/8/28 下午1:27
|
|
24
|
+
* @description: 用exec执行CD命令
|
|
25
|
+
* @param path
|
|
26
|
+
* @returns {Promise<*>}
|
|
27
|
+
*/
|
|
28
|
+
declare function execCDCommand(path: string): Promise<any>;
|
|
29
|
+
/**
|
|
30
|
+
* @author: ares
|
|
31
|
+
* @date: 2025/8/28 下午1:27
|
|
32
|
+
* @description: 用exec执行PNPM命令
|
|
33
|
+
* @param script
|
|
34
|
+
* @param projectDir
|
|
35
|
+
* @returns {Promise<*>}
|
|
36
|
+
*/
|
|
37
|
+
declare function execPNPMCommand(script: string, projectDir: string): Promise<any>;
|
|
38
|
+
/**
|
|
39
|
+
* @author: ares
|
|
40
|
+
* @date: 2025/8/28 下午1:27
|
|
41
|
+
* @description: 用exec执行项目的PNPM命令
|
|
42
|
+
* @param projectDir
|
|
43
|
+
* @param script
|
|
44
|
+
* @returns {Promise<*>}
|
|
45
|
+
*/
|
|
46
|
+
declare function execProjectPNPMCommand(projectDir: string, script: string): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* @author: ares
|
|
49
|
+
* @date: 2025/8/28 下午1:42
|
|
50
|
+
* @description: 在指定目录下用exec执行命令
|
|
51
|
+
* @param dir
|
|
52
|
+
* @param command
|
|
53
|
+
* @returns {Promise<*>}
|
|
54
|
+
*/
|
|
55
|
+
declare function execCommandUnderDirectory(dir: string, command: string): Promise<any>;
|
|
56
|
+
/**
|
|
57
|
+
* @author: ares
|
|
58
|
+
* @date: 2025/8/28 下午2:49
|
|
59
|
+
* @description: 用spawn执行命令
|
|
60
|
+
* @param command
|
|
61
|
+
* @param args
|
|
62
|
+
* @param config
|
|
63
|
+
* @returns {Promise<*>}
|
|
64
|
+
*/
|
|
65
|
+
declare function spawnCommand(command: any, args?: string[], config?: SpawnOptions): Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* @author: ares
|
|
68
|
+
* @date: 2025/8/28 下午1:27
|
|
69
|
+
* @description: 用spawn执行CD命令
|
|
70
|
+
* @param path
|
|
71
|
+
* @returns {Promise<*>}
|
|
72
|
+
*/
|
|
73
|
+
declare function spawnCDCommand(path: string): Promise<any>;
|
|
74
|
+
/**
|
|
75
|
+
* @author: ares
|
|
76
|
+
* @date: 2025/8/28 下午1:27
|
|
77
|
+
* @description: 执行PNPM命令
|
|
78
|
+
* @param script
|
|
79
|
+
* @param projectDir
|
|
80
|
+
* @returns {Promise<*>}
|
|
81
|
+
*/
|
|
82
|
+
declare function spawnPNPMCommand(script: string, projectDir: string): Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* @author: ares
|
|
85
|
+
* @date: 2025/8/28 下午1:27
|
|
86
|
+
* @description: 用spawn执行项目的PNPM命令
|
|
87
|
+
* @param projectDir
|
|
88
|
+
* @param script
|
|
89
|
+
* @returns {Promise<*>}
|
|
90
|
+
*/
|
|
91
|
+
declare function spawnProjectPNPMCommand(projectDir: string, script: string): Promise<any>;
|
|
92
|
+
/**
|
|
93
|
+
* @author: ares
|
|
94
|
+
* @date: 2025/8/28 下午1:42
|
|
95
|
+
* @description: 在指定目录下用spawn执行命令
|
|
96
|
+
* @param dir
|
|
97
|
+
* @param command
|
|
98
|
+
* @param args
|
|
99
|
+
* @returns {Promise<*>}
|
|
100
|
+
*/
|
|
101
|
+
declare function spawnCommandUnderDirectory(dir: string, command: string, args?: string[]): Promise<any>;
|
|
102
|
+
|
|
103
|
+
export { execCDCommand, execCommand, execCommandUnderDirectory, execPNPMCommand, execProjectPNPMCommand, renameDirectory, spawnCDCommand, spawnCommand, spawnCommandUnderDirectory, spawnPNPMCommand, spawnProjectPNPMCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import p from"fs/promises";import C from"os";import i from"iconv-lite";import{exec as D,spawn as y}from"child_process";import{logger as t}from"./logger.mjs";async function $(n,o){try{t.info(`\u5F00\u59CB\u91CD\u547D\u540D\u6587\u4EF6\u5939: ${n} -> ${o}`),await p.rename(n,o),t.info(`\u6587\u4EF6\u5939\u91CD\u547D\u540D\u5B8C\u6210: ${n} -> ${o}`)}catch(e){throw t.error(`\u91CD\u547D\u540D\u6587\u4EF6\u5939\u5931\u8D25: ${n} -> ${o}`,e),e}}async function a(n,o={}){return new Promise((e,f)=>{const r=C.platform()==="win32",s={cwd:process.cwd(),encoding:r?"buffer":"utf8",...o};try{t.info(`\u6267\u884C\u547D\u4EE4 ${n}`),D(n,s,function(d,c,u){r&&(Buffer.isBuffer(c)?c=i.decode(c,"GBK"):c=c.toString(),Buffer.isBuffer(u)?u=i.decode(u,"GBK"):u=u.toString()),t.info(`\u6267\u884C\u547D\u4EE4 ${n} \u5B8C\u6210`),u&&t.error(`\u6267\u884C\u547D\u4EE4 ${n} \u53D1\u751F\u5F02\u5E38`,u),e({stdout:c,stderr:u})})}catch(d){f(d)}})}async function E(n){const o=`cd ${n}`;return a(o)}async function w(n,o){const e=`pnpm ${n}`;return a(e,{cwd:o})}async function P(n,o){return w(o,n)}async function l(n,o){return a(o,{cwd:n})}async function m(n,o=[],e={}){return new Promise((f,r)=>{const s=C.platform()==="win32",d={cwd:process.cwd(),shell:!0,...e};try{t.info(`\u6267\u884C\u547D\u4EE4 ${n}`);const c=y(n,[...o],d);c.stdout.on("data",u=>{s&&(u=i.decode(u,"GBK")),console.info("stdout: ",u)}),c.stderr.on("data",u=>{s&&(u=i.decode(u,"GBK")),console.error("stderr: ",u),r(u)}),c.on("close",u=>{console.info(`child process exited with code ${u}`),f(`close with code ${u}`)})}catch(c){r(c)}})}async function B(n){return m("cd",[n])}async function h(n,o){return m("pnpm",[n],{cwd:o})}async function x(n,o){return w(o,n)}async function F(n,o,e=[]){return m(o,[...e],{cwd:n})}export{E as execCDCommand,a as execCommand,l as execCommandUnderDirectory,w as execPNPMCommand,P as execProjectPNPMCommand,$ as renameDirectory,B as spawnCDCommand,m as spawnCommand,F as spawnCommandUnderDirectory,h as spawnPNPMCommand,x as spawnProjectPNPMCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const lodashEs=require("lodash-es"),utils_logger=require("./logger.cjs"),utils_childProcess=require("./childProcess.cjs"),{BUILD_PROJECT:g,BUILD_MODE:p,PROJECT_DIR:u,LOCAL_DEPLOY_DIR:i,LOCAL_DOWNLOAD_DIR:n,BASTION_SSH_HOST:A,BASTION_SSH_USER:d,BASTION_SSH_PASSWORD:f,BASTION_SSH_PORT:I,BASTION_SSH_PRIVATE_KEY:c,TARGET_SSH_HOST:T,TARGET_SSH_USER:S,TARGET_SSH_PASSWORD:_,TARGET_SSH_PORT:a,TARGET_SSH_PRIVATE_KEY:l,TARGET_BK_DIR:D,TARGET_DIR:H,TARGET_DIR_TEMP:s,TARGET_HEALTH_DIR:B,TARGET_HIDE_HEALTH_FILE_DIR:O,TARGET_HEALTH_FILE:P,TARGET_HEALTH_HIDDEN_FILE:L}=process.env;function getBastionConfig(e={}){return lodashEs.merge({host:A,port:I,username:d,password:f,privateKey:c},e)}function getBastionTargetConfig(e={}){return lodashEs.merge({host:T,port:a,username:S,password:_,privateKey:l,localDeployDir:i,localDownloadDir:n,remoteBackupDir:D,remoteDir:H,remoteDirTemp:s,remoteHealthDir:B,remoteHideHealthFileDir:O,remoteHealthFile:P,remoteHealthHiddenFile:L},e)}function getBastionChannelConfig(e={}){const o=getBastionTargetConfig(e);return lodashEs.merge({dstIP:o.host,dstPort:o.port},e)}function getWindowsServerTargetConfig(e={}){return lodashEs.merge({host:T,port:a,username:S,password:_,privateKey:l,localDeployDir:i,localDownloadDir:n,remoteBackupDir:D,remoteDir:H,remoteDirTemp:s},e)}function getBuildConfig(e){return lodashEs.merge({build:e.build||g==="true",mode:e.mode||p,projectDir:e.projectDir||u},e)}async function buildProject(e){const{mode:o,projectDir:r}=getBuildConfig(e),t=o?`build:${o}`:"build";utils_logger.logger.info("\u5F00\u59CB\u6253\u5305\u9879\u76EE...");const E=await utils_childProcess.execProjectPNPMCommand(r,t);return utils_logger.logger.info("\u6253\u5305\u9879\u76EE\u5B8C\u6210"),E}exports.buildProject=buildProject,exports.getBastionChannelConfig=getBastionChannelConfig,exports.getBastionConfig=getBastionConfig,exports.getBastionTargetConfig=getBastionTargetConfig,exports.getBuildConfig=getBuildConfig,exports.getWindowsServerTargetConfig=getWindowsServerTargetConfig;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: ares
|
|
3
|
+
* @date: 2026/1/26 上午9:38
|
|
4
|
+
* @description: 获取堡垒机配置
|
|
5
|
+
* @param config
|
|
6
|
+
*/
|
|
7
|
+
declare function getBastionConfig(config?: BastionSSHClientConfig): BastionSSHClientConfig;
|
|
8
|
+
/**
|
|
9
|
+
* @author: ares
|
|
10
|
+
* @date: 2026/1/26 上午9:42
|
|
11
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
12
|
+
* @param config
|
|
13
|
+
*/
|
|
14
|
+
declare function getBastionTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
15
|
+
/**
|
|
16
|
+
* @author: ares
|
|
17
|
+
* @date: 2026/1/26 上午9:43
|
|
18
|
+
* @description: 获取堡垒机连接内部服务器通道配置
|
|
19
|
+
* @param config
|
|
20
|
+
*/
|
|
21
|
+
declare function getBastionChannelConfig(config?: TargetSSHClientConfig): BastionChannelConfig;
|
|
22
|
+
/**
|
|
23
|
+
* @author: ares
|
|
24
|
+
* @date: 2026/1/26 上午9:42
|
|
25
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
26
|
+
* @param config
|
|
27
|
+
*/
|
|
28
|
+
declare function getWindowsServerTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
29
|
+
/**
|
|
30
|
+
* @author: ares
|
|
31
|
+
* @date: 2026/1/26 上午10:13
|
|
32
|
+
* @description: 获取打包项目配置
|
|
33
|
+
* @param config
|
|
34
|
+
*/
|
|
35
|
+
declare function getBuildConfig(config: BuildConfig): BuildConfig;
|
|
36
|
+
/**
|
|
37
|
+
* @author: ares
|
|
38
|
+
* @date: 2025/8/29 上午10:55
|
|
39
|
+
* @description: 打包项目
|
|
40
|
+
* @param bConfig
|
|
41
|
+
* @returns {Promise<*>}
|
|
42
|
+
*/
|
|
43
|
+
declare function buildProject(bConfig: BuildConfig): Promise<any>;
|
|
44
|
+
|
|
45
|
+
export { buildProject, getBastionChannelConfig, getBastionConfig, getBastionTargetConfig, getBuildConfig, getWindowsServerTargetConfig };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: ares
|
|
3
|
+
* @date: 2026/1/26 上午9:38
|
|
4
|
+
* @description: 获取堡垒机配置
|
|
5
|
+
* @param config
|
|
6
|
+
*/
|
|
7
|
+
declare function getBastionConfig(config?: BastionSSHClientConfig): BastionSSHClientConfig;
|
|
8
|
+
/**
|
|
9
|
+
* @author: ares
|
|
10
|
+
* @date: 2026/1/26 上午9:42
|
|
11
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
12
|
+
* @param config
|
|
13
|
+
*/
|
|
14
|
+
declare function getBastionTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
15
|
+
/**
|
|
16
|
+
* @author: ares
|
|
17
|
+
* @date: 2026/1/26 上午9:43
|
|
18
|
+
* @description: 获取堡垒机连接内部服务器通道配置
|
|
19
|
+
* @param config
|
|
20
|
+
*/
|
|
21
|
+
declare function getBastionChannelConfig(config?: TargetSSHClientConfig): BastionChannelConfig;
|
|
22
|
+
/**
|
|
23
|
+
* @author: ares
|
|
24
|
+
* @date: 2026/1/26 上午9:42
|
|
25
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
26
|
+
* @param config
|
|
27
|
+
*/
|
|
28
|
+
declare function getWindowsServerTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
29
|
+
/**
|
|
30
|
+
* @author: ares
|
|
31
|
+
* @date: 2026/1/26 上午10:13
|
|
32
|
+
* @description: 获取打包项目配置
|
|
33
|
+
* @param config
|
|
34
|
+
*/
|
|
35
|
+
declare function getBuildConfig(config: BuildConfig): BuildConfig;
|
|
36
|
+
/**
|
|
37
|
+
* @author: ares
|
|
38
|
+
* @date: 2025/8/29 上午10:55
|
|
39
|
+
* @description: 打包项目
|
|
40
|
+
* @param bConfig
|
|
41
|
+
* @returns {Promise<*>}
|
|
42
|
+
*/
|
|
43
|
+
declare function buildProject(bConfig: BuildConfig): Promise<any>;
|
|
44
|
+
|
|
45
|
+
export { buildProject, getBastionChannelConfig, getBastionConfig, getBastionTargetConfig, getBuildConfig, getWindowsServerTargetConfig };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: ares
|
|
3
|
+
* @date: 2026/1/26 上午9:38
|
|
4
|
+
* @description: 获取堡垒机配置
|
|
5
|
+
* @param config
|
|
6
|
+
*/
|
|
7
|
+
declare function getBastionConfig(config?: BastionSSHClientConfig): BastionSSHClientConfig;
|
|
8
|
+
/**
|
|
9
|
+
* @author: ares
|
|
10
|
+
* @date: 2026/1/26 上午9:42
|
|
11
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
12
|
+
* @param config
|
|
13
|
+
*/
|
|
14
|
+
declare function getBastionTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
15
|
+
/**
|
|
16
|
+
* @author: ares
|
|
17
|
+
* @date: 2026/1/26 上午9:43
|
|
18
|
+
* @description: 获取堡垒机连接内部服务器通道配置
|
|
19
|
+
* @param config
|
|
20
|
+
*/
|
|
21
|
+
declare function getBastionChannelConfig(config?: TargetSSHClientConfig): BastionChannelConfig;
|
|
22
|
+
/**
|
|
23
|
+
* @author: ares
|
|
24
|
+
* @date: 2026/1/26 上午9:42
|
|
25
|
+
* @description: 获取堡垒机内部linux服务器配置
|
|
26
|
+
* @param config
|
|
27
|
+
*/
|
|
28
|
+
declare function getWindowsServerTargetConfig(config?: TargetSSHClientConfig): TargetSSHClientConfig;
|
|
29
|
+
/**
|
|
30
|
+
* @author: ares
|
|
31
|
+
* @date: 2026/1/26 上午10:13
|
|
32
|
+
* @description: 获取打包项目配置
|
|
33
|
+
* @param config
|
|
34
|
+
*/
|
|
35
|
+
declare function getBuildConfig(config: BuildConfig): BuildConfig;
|
|
36
|
+
/**
|
|
37
|
+
* @author: ares
|
|
38
|
+
* @date: 2025/8/29 上午10:55
|
|
39
|
+
* @description: 打包项目
|
|
40
|
+
* @param bConfig
|
|
41
|
+
* @returns {Promise<*>}
|
|
42
|
+
*/
|
|
43
|
+
declare function buildProject(bConfig: BuildConfig): Promise<any>;
|
|
44
|
+
|
|
45
|
+
export { buildProject, getBastionChannelConfig, getBastionConfig, getBastionTargetConfig, getBuildConfig, getWindowsServerTargetConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{merge as r}from"lodash-es";import{logger as t}from"./logger.mjs";import{execProjectPNPMCommand as c}from"./childProcess.mjs";const{BUILD_PROJECT:p,BUILD_MODE:I,PROJECT_DIR:d,LOCAL_DEPLOY_DIR:i,LOCAL_DOWNLOAD_DIR:T,BASTION_SSH_HOST:O,BASTION_SSH_USER:f,BASTION_SSH_PASSWORD:B,BASTION_SSH_PORT:P,BASTION_SSH_PRIVATE_KEY:g,TARGET_SSH_HOST:_,TARGET_SSH_USER:n,TARGET_SSH_PASSWORD:D,TARGET_SSH_PORT:u,TARGET_SSH_PRIVATE_KEY:E,TARGET_BK_DIR:S,TARGET_DIR:a,TARGET_DIR_TEMP:R,TARGET_HEALTH_DIR:L,TARGET_HIDE_HEALTH_FILE_DIR:C,TARGET_HEALTH_FILE:G,TARGET_HEALTH_HIDDEN_FILE:h}=process.env;function N(e={}){return r({host:O,port:P,username:f,password:B,privateKey:g},e)}function A(e={}){return r({host:_,port:u,username:n,password:D,privateKey:E,localDeployDir:i,localDownloadDir:T,remoteBackupDir:S,remoteDir:a,remoteDirTemp:R,remoteHealthDir:L,remoteHideHealthFileDir:C,remoteHealthFile:G,remoteHealthHiddenFile:h},e)}function w(e={}){const o=A(e);return r({dstIP:o.host,dstPort:o.port},e)}function F(e={}){return r({host:_,port:u,username:n,password:D,privateKey:E,localDeployDir:i,localDownloadDir:T,remoteBackupDir:S,remoteDir:a,remoteDirTemp:R},e)}function H(e){return r({build:e.build||p==="true",mode:e.mode||I,projectDir:e.projectDir||d},e)}async function y(e){const{mode:o,projectDir:l}=H(e),m=o?`build:${o}`:"build";t.info("\u5F00\u59CB\u6253\u5305\u9879\u76EE...");const s=await c(l,m);return t.info("\u6253\u5305\u9879\u76EE\u5B8C\u6210"),s}export{y as buildProject,w as getBastionChannelConfig,N as getBastionConfig,A as getBastionTargetConfig,H as getBuildConfig,F as getWindowsServerTargetConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("fs"),u=require("dayjs"),utils_logger=require("./logger.cjs"),utils_common=require("./common.cjs"),utils_ssh=require("./ssh.cjs"),utils_childProcess=require("./childProcess.cjs");function _interopDefaultCompat(r){return r&&typeof r=="object"&&"default"in r?r.default:r}const d__default=_interopDefaultCompat(d),u__default=_interopDefaultCompat(u);async function backupLocal(r,e,t){const{localDownloadDir:o,remoteDir:i}=e;utils_logger.logger.info("\u5F00\u59CB\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5230\u672C\u5730...");const n=u__default().format("YYYY-MM-DD_HHmmss");await utils_childProcess.execCommandUnderDirectory(o,`mkdir ${n}`);const a=await utils_ssh.getDirectoryFromIntraServer(r,t,e,{localDir:`${o}${n}`,remoteDir:i});return utils_logger.logger.info("\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5230\u672C\u5730\u5B8C\u6210"),a}async function backupRemote(r,e,t){const{remoteBackupDir:o,remoteDir:i}=e;utils_logger.logger.info("\u5F00\u59CB\u5728\u670D\u52A1\u5668\u7AEF\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE...");const n=u__default().format("YYYY-MM-DD_HHmmss"),a=`${o}${n}`;await utils_ssh.makeDirectoryOnIntraServer(r,t,e,{path:a});const E=await utils_ssh.execIntraServerCommand(r,t,e,`cp -ra ${i}. ${a}`);return utils_logger.logger.info("\u5728\u670D\u52A1\u5668\u7AEF\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5B8C\u6210"),E}async function checkRemoteDirExist(r,e,t){const{remoteDir:o,remoteDirTemp:i,remoteBackupDir:n}=e;if(utils_logger.logger.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),(await utils_ssh.execIntraServerCommand(r,t,e,`test -d ${o}`)).code!==0)try{utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u76EE\u6807\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u76EE\u6807\u76EE\u5F55..."),await utils_ssh.makeDirectoryOnIntraServer(r,t,e,{path:o}),utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u6210\u529F")}catch(E){throw E}utils_logger.logger.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const a=await utils_ssh.execIntraServerCommand(r,t,e,`test -d ${i}`);if(a.code!==0)try{utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u4E34\u65F6\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55..."),await utils_ssh.makeDirectoryOnIntraServer(r,t,e,{path:i}),utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55\u6210\u529F")}catch(E){throw E}if(utils_logger.logger.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u5907\u4EFD\u76EE\u5F55..."),await utils_ssh.execIntraServerCommand(r,t,e,`test -d ${n}`),a.code!==0)try{utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u5907\u4EFD\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u5907\u4EFD\u76EE\u5F55..."),await utils_ssh.makeDirectoryOnIntraServer(r,t,e,{path:n}),utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u5907\u4EFD\u76EE\u5F55\u6210\u529F")}catch(E){throw E}}async function hideHealthFile(r,e,t){const{remoteHealthFile:o,remoteHideHealthFileDir:i}=e;utils_logger.logger.info("\u5F00\u59CB\u9690\u85CF\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6...");const n=await utils_ssh.execIntraServerCommand(r,t,e,`mv ${o} ${i}`);return utils_logger.logger.info("\u9690\u85CF\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6\u5B8C\u6210"),n}async function displayHealthFile(r,e,t){const{remoteHealthHiddenFile:o,remoteHealthDir:i}=e;utils_logger.logger.info("\u5F00\u59CB\u8FD8\u539F\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6...");const n=await utils_ssh.execIntraServerCommand(r,t,e,`mv ${o} ${i}`);return utils_logger.logger.info("\u8FD8\u539F\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6\u5B8C\u6210"),n}async function clearRemoteTempDir(r,e,t){const{remoteDirTemp:o}=e;utils_logger.logger.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const i=await utils_ssh.execIntraServerCommand(r,t,e,`rm -rf ${o}*`);return utils_logger.logger.info("\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210"),i}async function uploadToRemoteTempDir(r,e,t){const{localDeployDir:o,remoteDirTemp:i}=e;utils_logger.logger.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const n=await utils_ssh.putDirectoryToIntraServer(r,t,e,{localDir:o,remoteDir:i});return utils_logger.logger.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210"),n}async function clearRemoteTargetDir(r,e,t){const{remoteDir:o}=e;utils_logger.logger.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55...");const i=await utils_ssh.execIntraServerCommand(r,t,e,`rm -rf ${o}*`);return utils_logger.logger.info("\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55\u5B8C\u6210"),i}async function moveRemoteTempDirToTargetDir(r,e,t){const{remoteDir:o,remoteDirTemp:i}=e;utils_logger.logger.info("\u5F00\u59CB\u79FB\u52A8\u4E34\u65F6\u76EE\u5F55\u6587\u4EF6\u5230\u76EE\u6807\u76EE\u5F55...");const n=await utils_ssh.execIntraServerCommand(r,t,e,`mv ${i}* ${o}`);return utils_logger.logger.info("\u6587\u4EF6\u79FB\u52A8\u5B8C\u6210"),n}async function deployToLinuxBastionInternalServer(r={},e={},t={}){let o;const i=utils_common.getBuildConfig(r),n=utils_common.getBastionConfig(e),a=utils_common.getBastionTargetConfig(t),E=utils_common.getBastionChannelConfig(a);try{const{localDeployDir:c}=a;if(!d__default.existsSync(c))throw new Error(`\u672C\u5730\u76EE\u5F55 ${c} \u4E0D\u5B58\u5728`);return i.build&&await utils_common.buildProject(i),o=await utils_ssh.getBastionSSHClient(n),await checkRemoteDirExist(o,a,E),await backupRemote(o,a,E),await clearRemoteTempDir(o,a,E),await uploadToRemoteTempDir(o,a,E),await clearRemoteTargetDir(o,a,E),await moveRemoteTempDirToTargetDir(o,a,E),utils_logger.logger.info("\u90E8\u7F72\u5B8C\u6210!"),!0}catch(c){return utils_logger.logger.error("\u90E8\u7F72\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF:",c),!1}finally{utils_logger.logger.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),o?.dispose()}}async function enableLinuxBastionHealthCheck(r={},e={}){let t;const o=utils_common.getBastionConfig(r),i=utils_common.getBastionTargetConfig(e),n=utils_common.getBastionChannelConfig(i);try{t=await utils_ssh.getBastionSSHClient(o),await displayHealthFile(t,i,n),utils_logger.logger.info("\u5F00\u542F\u5065\u5EB7\u68C0\u67E5\u6210\u529F!")}catch(a){utils_logger.logger.error("\u5F00\u542F\u5065\u5EB7\u68C0\u67E5\u65F6\u51FA\u73B0\u9519\u8BEF:",a)}finally{utils_logger.logger.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),t?.dispose()}}async function disableLinuxBastionHealthCheck(r={},e={}){let t;const o=utils_common.getBastionConfig(r),i=utils_common.getBastionTargetConfig(e),n=utils_common.getBastionChannelConfig(i);try{t=await utils_ssh.getBastionSSHClient(o),await hideHealthFile(t,i,n),utils_logger.logger.info("\u5173\u95ED\u5065\u5EB7\u68C0\u67E5\u6210\u529F!")}catch(a){utils_logger.logger.error("\u5173\u95ED\u5065\u5EB7\u68C0\u67E5\u65F6\u51FA\u73B0\u9519\u8BEF:",a)}finally{utils_logger.logger.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),t?.dispose()}}process.on("uncaughtException",r=>{utils_logger.logger.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u6355\u83B7\u7684\u5F02\u5E38: ${r}`)}),process.on("unhandledRejection",(r,e)=>{utils_logger.logger.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u5904\u7406\u7684\u62D2\u7EDD: ${e} \u539F\u56E0\u662F: ${r}`)}),exports.backupLocal=backupLocal,exports.backupRemote=backupRemote,exports.checkRemoteDirExist=checkRemoteDirExist,exports.clearRemoteTargetDir=clearRemoteTargetDir,exports.clearRemoteTempDir=clearRemoteTempDir,exports.deployToLinuxBastionInternalServer=deployToLinuxBastionInternalServer,exports.disableLinuxBastionHealthCheck=disableLinuxBastionHealthCheck,exports.displayHealthFile=displayHealthFile,exports.enableLinuxBastionHealthCheck=enableLinuxBastionHealthCheck,exports.hideHealthFile=hideHealthFile,exports.moveRemoteTempDirToTargetDir=moveRemoteTempDirToTargetDir,exports.uploadToRemoteTempDir=uploadToRemoteTempDir;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { NodeSSH, SSHExecCommandResponse } from 'node-ssh';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 上午10:23
|
|
6
|
+
* @description: 备份远程项目文件到本地
|
|
7
|
+
* @param bastionSSH
|
|
8
|
+
* @param targetConfig
|
|
9
|
+
* @param channelConfig
|
|
10
|
+
* @returns {Promise<*>}
|
|
11
|
+
*/
|
|
12
|
+
declare function backupLocal(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* @author: ares
|
|
15
|
+
* @date: 2025/8/29 上午10:23
|
|
16
|
+
* @description: 在服务器端备份远程项目文件
|
|
17
|
+
* @param bastionSSH
|
|
18
|
+
* @param targetConfig
|
|
19
|
+
* @param channelConfig
|
|
20
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
21
|
+
*/
|
|
22
|
+
declare function backupRemote(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* @author: ares
|
|
25
|
+
* @date: 2025/8/29 上午10:26
|
|
26
|
+
* @description: 检查服务器上的相关目录是否存在
|
|
27
|
+
* @param bastionSSH
|
|
28
|
+
* @param targetConfig
|
|
29
|
+
* @param channelConfig
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
declare function checkRemoteDirExist(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @author: ares
|
|
35
|
+
* @date: 2025/8/29 上午10:32
|
|
36
|
+
* @description: 把被健康检查的文件移动至其它目录, 使健康检查失效
|
|
37
|
+
* @param bastionSSH
|
|
38
|
+
* @param targetConfig
|
|
39
|
+
* @param channelConfig
|
|
40
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
41
|
+
*/
|
|
42
|
+
declare function hideHealthFile(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* @author: ares
|
|
45
|
+
* @date: 2025/8/29 上午10:32
|
|
46
|
+
* @description: 把被移动至其它目录的被健康检查的文件移动回原来的目录, 使健康检查生效效
|
|
47
|
+
* @param bastionSSH
|
|
48
|
+
* @param targetConfig
|
|
49
|
+
* @param channelConfig
|
|
50
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
51
|
+
*/
|
|
52
|
+
declare function displayHealthFile(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* @author: ares
|
|
55
|
+
* @date: 2025/8/29 上午10:28
|
|
56
|
+
* @description: 删除远程临时目录
|
|
57
|
+
* @param bastionSSH
|
|
58
|
+
* @param targetConfig
|
|
59
|
+
* @param channelConfig
|
|
60
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
61
|
+
*/
|
|
62
|
+
declare function clearRemoteTempDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* @author: ares
|
|
65
|
+
* @date: 2025/8/29 上午10:30
|
|
66
|
+
* @description: 上传到远程临时目录
|
|
67
|
+
* @param bastionSSH
|
|
68
|
+
* @param targetConfig
|
|
69
|
+
* @param channelConfig
|
|
70
|
+
* @returns {Promise<*>}
|
|
71
|
+
*/
|
|
72
|
+
declare function uploadToRemoteTempDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* @author: ares
|
|
75
|
+
* @date: 2025/8/29 上午10:31
|
|
76
|
+
* @description: 清空远程目标目录
|
|
77
|
+
* @param bastionSSH
|
|
78
|
+
* @param targetConfig
|
|
79
|
+
* @param channelConfig
|
|
80
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
81
|
+
*/
|
|
82
|
+
declare function clearRemoteTargetDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* @author: ares
|
|
85
|
+
* @date: 2025/8/29 上午10:32
|
|
86
|
+
* @description: 移动远程临时目录内容到目标目录
|
|
87
|
+
* @param bastionSSH
|
|
88
|
+
* @param targetConfig
|
|
89
|
+
* @param channelConfig
|
|
90
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
91
|
+
*/
|
|
92
|
+
declare function moveRemoteTempDirToTargetDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* @author: ares
|
|
95
|
+
* @date: 2025/8/28 下午1:37
|
|
96
|
+
* @description: 通过堡垒机部署项目到linux服务器
|
|
97
|
+
* @param bConfig 打包前端项目配置
|
|
98
|
+
* @param btConfig 堡垒机配置
|
|
99
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
101
|
+
*/
|
|
102
|
+
declare function deployToLinuxBastionInternalServer(bConfig?: BuildConfig, btConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* @author: ares
|
|
105
|
+
* @date: 2025/9/11 下午1:00
|
|
106
|
+
* @description: 使健康检查生效
|
|
107
|
+
* @param bConfig 堡垒机配置
|
|
108
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
109
|
+
*/
|
|
110
|
+
declare function enableLinuxBastionHealthCheck(bConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* @author: ares
|
|
113
|
+
* @date: 2025/9/11 下午1:00
|
|
114
|
+
* @description: 使健康检查失效
|
|
115
|
+
* @param bConfig 堡垒机配置
|
|
116
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
117
|
+
*/
|
|
118
|
+
declare function disableLinuxBastionHealthCheck(bConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<void>;
|
|
119
|
+
|
|
120
|
+
export { backupLocal, backupRemote, checkRemoteDirExist, clearRemoteTargetDir, clearRemoteTempDir, deployToLinuxBastionInternalServer, disableLinuxBastionHealthCheck, displayHealthFile, enableLinuxBastionHealthCheck, hideHealthFile, moveRemoteTempDirToTargetDir, uploadToRemoteTempDir };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { NodeSSH, SSHExecCommandResponse } from 'node-ssh';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 上午10:23
|
|
6
|
+
* @description: 备份远程项目文件到本地
|
|
7
|
+
* @param bastionSSH
|
|
8
|
+
* @param targetConfig
|
|
9
|
+
* @param channelConfig
|
|
10
|
+
* @returns {Promise<*>}
|
|
11
|
+
*/
|
|
12
|
+
declare function backupLocal(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* @author: ares
|
|
15
|
+
* @date: 2025/8/29 上午10:23
|
|
16
|
+
* @description: 在服务器端备份远程项目文件
|
|
17
|
+
* @param bastionSSH
|
|
18
|
+
* @param targetConfig
|
|
19
|
+
* @param channelConfig
|
|
20
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
21
|
+
*/
|
|
22
|
+
declare function backupRemote(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
23
|
+
/**
|
|
24
|
+
* @author: ares
|
|
25
|
+
* @date: 2025/8/29 上午10:26
|
|
26
|
+
* @description: 检查服务器上的相关目录是否存在
|
|
27
|
+
* @param bastionSSH
|
|
28
|
+
* @param targetConfig
|
|
29
|
+
* @param channelConfig
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
declare function checkRemoteDirExist(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* @author: ares
|
|
35
|
+
* @date: 2025/8/29 上午10:32
|
|
36
|
+
* @description: 把被健康检查的文件移动至其它目录, 使健康检查失效
|
|
37
|
+
* @param bastionSSH
|
|
38
|
+
* @param targetConfig
|
|
39
|
+
* @param channelConfig
|
|
40
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
41
|
+
*/
|
|
42
|
+
declare function hideHealthFile(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* @author: ares
|
|
45
|
+
* @date: 2025/8/29 上午10:32
|
|
46
|
+
* @description: 把被移动至其它目录的被健康检查的文件移动回原来的目录, 使健康检查生效效
|
|
47
|
+
* @param bastionSSH
|
|
48
|
+
* @param targetConfig
|
|
49
|
+
* @param channelConfig
|
|
50
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
51
|
+
*/
|
|
52
|
+
declare function displayHealthFile(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* @author: ares
|
|
55
|
+
* @date: 2025/8/29 上午10:28
|
|
56
|
+
* @description: 删除远程临时目录
|
|
57
|
+
* @param bastionSSH
|
|
58
|
+
* @param targetConfig
|
|
59
|
+
* @param channelConfig
|
|
60
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
61
|
+
*/
|
|
62
|
+
declare function clearRemoteTempDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* @author: ares
|
|
65
|
+
* @date: 2025/8/29 上午10:30
|
|
66
|
+
* @description: 上传到远程临时目录
|
|
67
|
+
* @param bastionSSH
|
|
68
|
+
* @param targetConfig
|
|
69
|
+
* @param channelConfig
|
|
70
|
+
* @returns {Promise<*>}
|
|
71
|
+
*/
|
|
72
|
+
declare function uploadToRemoteTempDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<any>;
|
|
73
|
+
/**
|
|
74
|
+
* @author: ares
|
|
75
|
+
* @date: 2025/8/29 上午10:31
|
|
76
|
+
* @description: 清空远程目标目录
|
|
77
|
+
* @param bastionSSH
|
|
78
|
+
* @param targetConfig
|
|
79
|
+
* @param channelConfig
|
|
80
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
81
|
+
*/
|
|
82
|
+
declare function clearRemoteTargetDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* @author: ares
|
|
85
|
+
* @date: 2025/8/29 上午10:32
|
|
86
|
+
* @description: 移动远程临时目录内容到目标目录
|
|
87
|
+
* @param bastionSSH
|
|
88
|
+
* @param targetConfig
|
|
89
|
+
* @param channelConfig
|
|
90
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
91
|
+
*/
|
|
92
|
+
declare function moveRemoteTempDirToTargetDir(bastionSSH: NodeSSH, targetConfig: TargetSSHClientConfig, channelConfig: BastionChannelConfig): Promise<SSHExecCommandResponse>;
|
|
93
|
+
/**
|
|
94
|
+
* @author: ares
|
|
95
|
+
* @date: 2025/8/28 下午1:37
|
|
96
|
+
* @description: 通过堡垒机部署项目到linux服务器
|
|
97
|
+
* @param bConfig 打包前端项目配置
|
|
98
|
+
* @param btConfig 堡垒机配置
|
|
99
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
101
|
+
*/
|
|
102
|
+
declare function deployToLinuxBastionInternalServer(bConfig?: BuildConfig, btConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* @author: ares
|
|
105
|
+
* @date: 2025/9/11 下午1:00
|
|
106
|
+
* @description: 使健康检查生效
|
|
107
|
+
* @param bConfig 堡垒机配置
|
|
108
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
109
|
+
*/
|
|
110
|
+
declare function enableLinuxBastionHealthCheck(bConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* @author: ares
|
|
113
|
+
* @date: 2025/9/11 下午1:00
|
|
114
|
+
* @description: 使健康检查失效
|
|
115
|
+
* @param bConfig 堡垒机配置
|
|
116
|
+
* @param tConfig 堡垒机内部linux服务器配置
|
|
117
|
+
*/
|
|
118
|
+
declare function disableLinuxBastionHealthCheck(bConfig?: BastionSSHClientConfig, tConfig?: TargetSSHClientConfig): Promise<void>;
|
|
119
|
+
|
|
120
|
+
export { backupLocal, backupRemote, checkRemoteDirExist, clearRemoteTargetDir, clearRemoteTempDir, deployToLinuxBastionInternalServer, disableLinuxBastionHealthCheck, displayHealthFile, enableLinuxBastionHealthCheck, hideHealthFile, moveRemoteTempDirToTargetDir, uploadToRemoteTempDir };
|