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,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 @@
|
|
|
1
|
+
import H from"fs";import m from"dayjs";import{logger as t}from"./logger.mjs";import{getBuildConfig as S,getBastionConfig as B,getBastionTargetConfig as s,getBastionChannelConfig as C,buildProject as g}from"./common.mjs";import{getBastionSSHClient as A,getDirectoryFromIntraServer as T,makeDirectoryOnIntraServer as D,execIntraServerCommand as F,putDirectoryToIntraServer as b}from"./ssh.mjs";import{execCommandUnderDirectory as k}from"./childProcess.mjs";async function v(i,u,E){const{localDownloadDir:r,remoteDir:e}=u;t.info("\u5F00\u59CB\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5230\u672C\u5730...");const o=m().format("YYYY-MM-DD_HHmmss");await k(r,`mkdir ${o}`);const a=await T(i,E,u,{localDir:`${r}${o}`,remoteDir:e});return t.info("\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5230\u672C\u5730\u5B8C\u6210"),a}async function f(i,u,E){const{remoteBackupDir:r,remoteDir:e}=u;t.info("\u5F00\u59CB\u5728\u670D\u52A1\u5668\u7AEF\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE...");const o=m().format("YYYY-MM-DD_HHmmss"),a=`${r}${o}`;await D(i,E,u,{path:a});const n=await F(i,E,u,`cp -ra ${e}. ${a}`);return t.info("\u5728\u670D\u52A1\u5668\u7AEF\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5B8C\u6210"),n}async function l(i,u,E){const{remoteDir:r,remoteDirTemp:e,remoteBackupDir:o}=u;if(t.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),(await F(i,E,u,`test -d ${r}`)).code!==0)try{t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u76EE\u6807\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u76EE\u6807\u76EE\u5F55..."),await D(i,E,u,{path:r}),t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u6210\u529F")}catch(n){throw n}t.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const a=await F(i,E,u,`test -d ${e}`);if(a.code!==0)try{t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u4E34\u65F6\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55..."),await D(i,E,u,{path:e}),t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55\u6210\u529F")}catch(n){throw n}if(t.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u5907\u4EFD\u76EE\u5F55..."),await F(i,E,u,`test -d ${o}`),a.code!==0)try{t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u5907\u4EFD\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u5907\u4EFD\u76EE\u5F55..."),await D(i,E,u,{path:o}),t.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u5907\u4EFD\u76EE\u5F55\u6210\u529F")}catch(n){throw n}}async function p(i,u,E){const{remoteHealthFile:r,remoteHideHealthFileDir:e}=u;t.info("\u5F00\u59CB\u9690\u85CF\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6...");const o=await F(i,E,u,`mv ${r} ${e}`);return t.info("\u9690\u85CF\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6\u5B8C\u6210"),o}async function w(i,u,E){const{remoteHealthHiddenFile:r,remoteHealthDir:e}=u;t.info("\u5F00\u59CB\u8FD8\u539F\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6...");const o=await F(i,E,u,`mv ${r} ${e}`);return t.info("\u8FD8\u539F\u88AB\u5065\u5EB7\u68C0\u67E5\u7684\u6587\u4EF6\u5B8C\u6210"),o}async function y(i,u,E){const{remoteDirTemp:r}=u;t.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const e=await F(i,E,u,`rm -rf ${r}*`);return t.info("\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210"),e}async function h(i,u,E){const{localDeployDir:r,remoteDirTemp:e}=u;t.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55...");const o=await b(i,E,u,{localDir:r,remoteDir:e});return t.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210"),o}async function d(i,u,E){const{remoteDir:r}=u;t.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55...");const e=await F(i,E,u,`rm -rf ${r}*`);return t.info("\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55\u5B8C\u6210"),e}async function $(i,u,E){const{remoteDir:r,remoteDirTemp:e}=u;t.info("\u5F00\u59CB\u79FB\u52A8\u4E34\u65F6\u76EE\u5F55\u6587\u4EF6\u5230\u76EE\u6807\u76EE\u5F55...");const o=await F(i,E,u,`mv ${e}* ${r}`);return t.info("\u6587\u4EF6\u79FB\u52A8\u5B8C\u6210"),o}async function x(i={},u={},E={}){let r;const e=S(i),o=B(u),a=s(E),n=C(a);try{const{localDeployDir:c}=a;if(!H.existsSync(c))throw new Error(`\u672C\u5730\u76EE\u5F55 ${c} \u4E0D\u5B58\u5728`);return e.build&&await g(e),r=await A(o),await l(r,a,n),await f(r,a,n),await y(r,a,n),await h(r,a,n),await d(r,a,n),await $(r,a,n),t.info("\u90E8\u7F72\u5B8C\u6210!"),!0}catch(c){return t.error("\u90E8\u7F72\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF:",c),!1}finally{t.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),r?.dispose()}}async function Y(i={},u={}){let E;const r=B(i),e=s(u),o=C(e);try{E=await A(r),await w(E,e,o),t.info("\u5F00\u542F\u5065\u5EB7\u68C0\u67E5\u6210\u529F!")}catch(a){t.error("\u5F00\u542F\u5065\u5EB7\u68C0\u67E5\u65F6\u51FA\u73B0\u9519\u8BEF:",a)}finally{t.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),E?.dispose()}}async function R(i={},u={}){let E;const r=B(i),e=s(u),o=C(e);try{E=await A(r),await p(E,e,o),t.info("\u5173\u95ED\u5065\u5EB7\u68C0\u67E5\u6210\u529F!")}catch(a){t.error("\u5173\u95ED\u5065\u5EB7\u68C0\u67E5\u65F6\u51FA\u73B0\u9519\u8BEF:",a)}finally{t.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),E?.dispose()}}process.on("uncaughtException",i=>{t.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u6355\u83B7\u7684\u5F02\u5E38: ${i}`)}),process.on("unhandledRejection",(i,u)=>{t.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u5904\u7406\u7684\u62D2\u7EDD: ${u} \u539F\u56E0\u662F: ${i}`)});export{v as backupLocal,f as backupRemote,l as checkRemoteDirExist,d as clearRemoteTargetDir,y as clearRemoteTempDir,x as deployToLinuxBastionInternalServer,R as disableLinuxBastionHealthCheck,w as displayHealthFile,Y as enableLinuxBastionHealthCheck,p as hideHealthFile,$ as moveRemoteTempDirToTargetDir,h as uploadToRemoteTempDir};
|
|
@@ -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(e){return e&&typeof e=="object"&&"default"in e?e.default:e}const d__default=_interopDefaultCompat(d),u__default=_interopDefaultCompat(u);async function backup(e,r){const{localDownloadDir:o,remoteDir:i}=r;utils_logger.logger.info("\u5F00\u59CB\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE...");const t=u__default().format("YYYY-MM-DD_HHmmss");await utils_childProcess.execCommandUnderDirectory(o,`mkdir ${t}`);const E=await utils_ssh.getDirectoryFromRemoteWindowServer(e,{localDir:`${o}${t}`,remoteDir:i});return utils_logger.logger.info("\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5B8C\u6210"),E}async function checkRemoteDirExist(e,r){const{remoteDir:o,remoteDirTemp:i}=r;if(utils_logger.logger.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),(await utils_ssh.execRemoteWindowServerCommand(e,`dir /ad /b /on ${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.makeDirectoryOnRemoteWindowServer(e,{path:o}),utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u6210\u529F")}catch(t){throw t}if(utils_logger.logger.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),(await utils_ssh.execRemoteWindowServerCommand(e,`dir /ad /b /on ${i}`)).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.makeDirectoryOnRemoteWindowServer(e,{path:i}),utils_logger.logger.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55\u6210\u529F")}catch(t){throw t}}async function clearRemoteTempDir(e,r){const{remoteDirTemp:o}=r;utils_logger.logger.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),await utils_ssh.clearRemoteWindowServerDir(e,o),utils_logger.logger.info("\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210")}async function uploadToRemoteTempDir(e,r){const{localDeployDir:o,remoteDirTemp:i}=r;utils_logger.logger.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),await utils_ssh.putDirectoryToRemoteWindowServer(e,{localDir:o,remoteDir:i}),utils_logger.logger.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210")}async function clearRemoteTargetDir(e,r){const{remoteDir:o}=r;utils_logger.logger.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),await utils_ssh.clearRemoteWindowServerDir(e,o),utils_logger.logger.info("\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55\u5B8C\u6210")}async function moveRemoteTempDirToTargetDir(e,r){const{remoteDir:o,remoteDirTemp:i}=r;utils_logger.logger.info("\u5F00\u59CB\u79FB\u52A8\u4E34\u65F6\u76EE\u5F55\u6587\u4EF6\u5230\u76EE\u6807\u76EE\u5F55..."),await utils_ssh.execRemoteWindowServerCommand(e,`robocopy ${i} ${o} /E /MOVE`),utils_logger.logger.info("\u6587\u4EF6\u79FB\u52A8\u5B8C\u6210")}async function deployToWindowsServer(e={},r={}){let o;const i=utils_common.getBuildConfig(e),t=utils_common.getWindowsServerTargetConfig(r);try{if(!d__default.existsSync(t.localDeployDir))throw new Error(`\u672C\u5730\u76EE\u5F55 ${t.localDeployDir} \u4E0D\u5B58\u5728`);return i.build&&await utils_common.buildProject(i),o=await utils_ssh.getSSHClient(t),await checkRemoteDirExist(o,t),await clearRemoteTempDir(o,t),await uploadToRemoteTempDir(o,t),await clearRemoteTargetDir(o,t),await moveRemoteTempDirToTargetDir(o,t),utils_logger.logger.info("\u90E8\u7F72\u5B8C\u6210!"),!0}catch(E){return utils_logger.logger.error("\u90E8\u7F72\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF:",E),!1}finally{utils_logger.logger.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),o?.dispose()}}process.on("uncaughtException",e=>{utils_logger.logger.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u6355\u83B7\u7684\u5F02\u5E38: ${e}`)}),process.on("unhandledRejection",(e,r)=>{utils_logger.logger.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u5904\u7406\u7684\u62D2\u7EDD: ${r} \u539F\u56E0\u662F: ${e}`)}),exports.backup=backup,exports.checkRemoteDirExist=checkRemoteDirExist,exports.clearRemoteTargetDir=clearRemoteTargetDir,exports.clearRemoteTempDir=clearRemoteTempDir,exports.deployToWindowsServer=deployToWindowsServer,exports.moveRemoteTempDirToTargetDir=moveRemoteTempDirToTargetDir,exports.uploadToRemoteTempDir=uploadToRemoteTempDir;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { NodeSSH } from 'node-ssh';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 上午10:23
|
|
6
|
+
* @description: 备份远程项目文件
|
|
7
|
+
* @param targetSSH
|
|
8
|
+
* @param targetConfig
|
|
9
|
+
* @returns {Promise<*>}
|
|
10
|
+
*/
|
|
11
|
+
declare function backup(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* @author: ares
|
|
14
|
+
* @date: 2025/8/29 上午10:26
|
|
15
|
+
* @description: 检查服务器上的相关目录是否存在
|
|
16
|
+
* @param targetSSH
|
|
17
|
+
* @param targetConfig
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
declare function checkRemoteDirExist(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @author: ares
|
|
23
|
+
* @date: 2025/8/29 上午10:28
|
|
24
|
+
* @description: 删除远程临时目录
|
|
25
|
+
* @param targetSSH
|
|
26
|
+
* @param targetConfig
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
declare function clearRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* @author: ares
|
|
32
|
+
* @date: 2025/8/29 上午10:30
|
|
33
|
+
* @description: 上传到远程临时目录
|
|
34
|
+
* @param targetSSH
|
|
35
|
+
* @param targetConfig
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
declare function uploadToRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @author: ares
|
|
41
|
+
* @date: 2025/8/29 上午10:31
|
|
42
|
+
* @description: 清空远程目标目录
|
|
43
|
+
* @param targetSSH
|
|
44
|
+
* @param targetConfig
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
declare function clearRemoteTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @author: ares
|
|
50
|
+
* @date: 2025/8/29 上午10:32
|
|
51
|
+
* @description: 移动远程临时目录内容到目标目录
|
|
52
|
+
* @param targetSSH
|
|
53
|
+
* @param targetConfig
|
|
54
|
+
* @returns {Promise<void>}
|
|
55
|
+
*/
|
|
56
|
+
declare function moveRemoteTempDirToTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @author: ares
|
|
59
|
+
* @date: 2025/8/28 下午1:37
|
|
60
|
+
* @description: 部署项目到window-server
|
|
61
|
+
* @param bConfig 打包前端项目配置
|
|
62
|
+
* @param tConfig 服务器配置
|
|
63
|
+
*/
|
|
64
|
+
declare function deployToWindowsServer(bConfig?: BuildConfig, tConfig?: TargetSSHClientConfig): Promise<boolean>;
|
|
65
|
+
|
|
66
|
+
export { backup, checkRemoteDirExist, clearRemoteTargetDir, clearRemoteTempDir, deployToWindowsServer, moveRemoteTempDirToTargetDir, uploadToRemoteTempDir };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { NodeSSH } from 'node-ssh';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 上午10:23
|
|
6
|
+
* @description: 备份远程项目文件
|
|
7
|
+
* @param targetSSH
|
|
8
|
+
* @param targetConfig
|
|
9
|
+
* @returns {Promise<*>}
|
|
10
|
+
*/
|
|
11
|
+
declare function backup(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* @author: ares
|
|
14
|
+
* @date: 2025/8/29 上午10:26
|
|
15
|
+
* @description: 检查服务器上的相关目录是否存在
|
|
16
|
+
* @param targetSSH
|
|
17
|
+
* @param targetConfig
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
declare function checkRemoteDirExist(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @author: ares
|
|
23
|
+
* @date: 2025/8/29 上午10:28
|
|
24
|
+
* @description: 删除远程临时目录
|
|
25
|
+
* @param targetSSH
|
|
26
|
+
* @param targetConfig
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
declare function clearRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* @author: ares
|
|
32
|
+
* @date: 2025/8/29 上午10:30
|
|
33
|
+
* @description: 上传到远程临时目录
|
|
34
|
+
* @param targetSSH
|
|
35
|
+
* @param targetConfig
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
declare function uploadToRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @author: ares
|
|
41
|
+
* @date: 2025/8/29 上午10:31
|
|
42
|
+
* @description: 清空远程目标目录
|
|
43
|
+
* @param targetSSH
|
|
44
|
+
* @param targetConfig
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
declare function clearRemoteTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @author: ares
|
|
50
|
+
* @date: 2025/8/29 上午10:32
|
|
51
|
+
* @description: 移动远程临时目录内容到目标目录
|
|
52
|
+
* @param targetSSH
|
|
53
|
+
* @param targetConfig
|
|
54
|
+
* @returns {Promise<void>}
|
|
55
|
+
*/
|
|
56
|
+
declare function moveRemoteTempDirToTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @author: ares
|
|
59
|
+
* @date: 2025/8/28 下午1:37
|
|
60
|
+
* @description: 部署项目到window-server
|
|
61
|
+
* @param bConfig 打包前端项目配置
|
|
62
|
+
* @param tConfig 服务器配置
|
|
63
|
+
*/
|
|
64
|
+
declare function deployToWindowsServer(bConfig?: BuildConfig, tConfig?: TargetSSHClientConfig): Promise<boolean>;
|
|
65
|
+
|
|
66
|
+
export { backup, checkRemoteDirExist, clearRemoteTargetDir, clearRemoteTempDir, deployToWindowsServer, moveRemoteTempDirToTargetDir, uploadToRemoteTempDir };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { NodeSSH } from 'node-ssh';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @author: ares
|
|
5
|
+
* @date: 2025/8/29 上午10:23
|
|
6
|
+
* @description: 备份远程项目文件
|
|
7
|
+
* @param targetSSH
|
|
8
|
+
* @param targetConfig
|
|
9
|
+
* @returns {Promise<*>}
|
|
10
|
+
*/
|
|
11
|
+
declare function backup(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<any>;
|
|
12
|
+
/**
|
|
13
|
+
* @author: ares
|
|
14
|
+
* @date: 2025/8/29 上午10:26
|
|
15
|
+
* @description: 检查服务器上的相关目录是否存在
|
|
16
|
+
* @param targetSSH
|
|
17
|
+
* @param targetConfig
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
declare function checkRemoteDirExist(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @author: ares
|
|
23
|
+
* @date: 2025/8/29 上午10:28
|
|
24
|
+
* @description: 删除远程临时目录
|
|
25
|
+
* @param targetSSH
|
|
26
|
+
* @param targetConfig
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*/
|
|
29
|
+
declare function clearRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* @author: ares
|
|
32
|
+
* @date: 2025/8/29 上午10:30
|
|
33
|
+
* @description: 上传到远程临时目录
|
|
34
|
+
* @param targetSSH
|
|
35
|
+
* @param targetConfig
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
*/
|
|
38
|
+
declare function uploadToRemoteTempDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* @author: ares
|
|
41
|
+
* @date: 2025/8/29 上午10:31
|
|
42
|
+
* @description: 清空远程目标目录
|
|
43
|
+
* @param targetSSH
|
|
44
|
+
* @param targetConfig
|
|
45
|
+
* @returns {Promise<void>}
|
|
46
|
+
*/
|
|
47
|
+
declare function clearRemoteTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* @author: ares
|
|
50
|
+
* @date: 2025/8/29 上午10:32
|
|
51
|
+
* @description: 移动远程临时目录内容到目标目录
|
|
52
|
+
* @param targetSSH
|
|
53
|
+
* @param targetConfig
|
|
54
|
+
* @returns {Promise<void>}
|
|
55
|
+
*/
|
|
56
|
+
declare function moveRemoteTempDirToTargetDir(targetSSH: NodeSSH, targetConfig: TargetSSHClientConfig): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @author: ares
|
|
59
|
+
* @date: 2025/8/28 下午1:37
|
|
60
|
+
* @description: 部署项目到window-server
|
|
61
|
+
* @param bConfig 打包前端项目配置
|
|
62
|
+
* @param tConfig 服务器配置
|
|
63
|
+
*/
|
|
64
|
+
declare function deployToWindowsServer(bConfig?: BuildConfig, tConfig?: TargetSSHClientConfig): Promise<boolean>;
|
|
65
|
+
|
|
66
|
+
export { backup, checkRemoteDirExist, clearRemoteTargetDir, clearRemoteTempDir, deployToWindowsServer, moveRemoteTempDirToTargetDir, uploadToRemoteTempDir };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import C from"fs";import B from"dayjs";import{logger as o}from"./logger.mjs";import{getBuildConfig as l,getWindowsServerTargetConfig as s,buildProject as w}from"./common.mjs";import{getSSHClient as p,getDirectoryFromRemoteWindowServer as d,execRemoteWindowServerCommand as n,makeDirectoryOnRemoteWindowServer as a,clearRemoteWindowServerDir as F,putDirectoryToRemoteWindowServer as y}from"./ssh.mjs";import{execCommandUnderDirectory as S}from"./childProcess.mjs";async function T(e,E){const{localDownloadDir:u,remoteDir:i}=E;o.info("\u5F00\u59CB\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE...");const r=B().format("YYYY-MM-DD_HHmmss");await S(u,`mkdir ${r}`);const t=await d(e,{localDir:`${u}${r}`,remoteDir:i});return o.info("\u5907\u4EFD\u8FDC\u7A0B\u9879\u76EE\u5B8C\u6210"),t}async function D(e,E){const{remoteDir:u,remoteDirTemp:i}=E;if(o.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),(await n(e,`dir /ad /b /on ${u}`)).code!==0)try{o.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u76EE\u6807\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u76EE\u6807\u76EE\u5F55..."),await a(e,{path:u}),o.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u6807\u76EE\u5F55\u6210\u529F")}catch(r){throw r}if(o.info("\u5F00\u59CB\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),(await n(e,`dir /ad /b /on ${i}`)).code!==0)try{o.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u6CA1\u6709\u4E34\u65F6\u76EE\u5F55, \u5F00\u59CB\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55..."),await a(e,{path:i}),o.info("\u76EE\u6807\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u4E34\u65F6\u76EE\u5F55\u6210\u529F")}catch(r){throw r}}async function c(e,E){const{remoteDirTemp:u}=E;o.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),await F(e,u),o.info("\u6E05\u7A7A\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210")}async function m(e,E){const{localDeployDir:u,remoteDirTemp:i}=E;o.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55..."),await y(e,{localDir:u,remoteDir:i}),o.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u4E34\u65F6\u76EE\u5F55\u5B8C\u6210")}async function A(e,E){const{remoteDir:u}=E;o.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55..."),await F(e,u),o.info("\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55\u5B8C\u6210")}async function f(e,E){const{remoteDir:u,remoteDirTemp:i}=E;o.info("\u5F00\u59CB\u79FB\u52A8\u4E34\u65F6\u76EE\u5F55\u6587\u4EF6\u5230\u76EE\u6807\u76EE\u5F55..."),await n(e,`robocopy ${i} ${u} /E /MOVE`),o.info("\u6587\u4EF6\u79FB\u52A8\u5B8C\u6210")}async function g(e={},E={}){let u;const i=l(e),r=s(E);try{if(!C.existsSync(r.localDeployDir))throw new Error(`\u672C\u5730\u76EE\u5F55 ${r.localDeployDir} \u4E0D\u5B58\u5728`);return i.build&&await w(i),u=await p(r),await D(u,r),await c(u,r),await m(u,r),await A(u,r),await f(u,r),o.info("\u90E8\u7F72\u5B8C\u6210!"),!0}catch(t){return o.error("\u90E8\u7F72\u8FC7\u7A0B\u4E2D\u51FA\u73B0\u9519\u8BEF:",t),!1}finally{o.info("\u9500\u6BC1bastionSSH\u548CtargetSSH\u8FDE\u63A5"),u?.dispose()}}process.on("uncaughtException",e=>{o.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u6355\u83B7\u7684\u5F02\u5E38: ${e}`)}),process.on("unhandledRejection",(e,E)=>{o.error(`\u7CFB\u7EDF\u53D1\u751F\u672A\u5904\u7406\u7684\u62D2\u7EDD: ${E} \u539F\u56E0\u662F: ${e}`)});export{T as backup,D as checkRemoteDirExist,A as clearRemoteTargetDir,c as clearRemoteTempDir,g as deployToWindowsServer,f as moveRemoteTempDirToTargetDir,m as uploadToRemoteTempDir};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("log4js");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const e__default=_interopDefaultCompat(e),{LOG_LEVEL:o="info"}=process.env;e__default.configure({appenders:{datafile:{type:"dateFile",filename:"./logs/deploy.log",pattern:".yyyy-MM-dd"},console:{type:"console"}},categories:{default:{appenders:["datafile","console"],level:o}}});const logger=e__default.getLogger("default");exports.logger=logger;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"log4js";const{LOG_LEVEL:o="info"}=process.env;e.configure({appenders:{datafile:{type:"dateFile",filename:"./logs/deploy.log",pattern:".yyyy-MM-dd"},console:{type:"console"}},categories:{default:{appenders:["datafile","console"],level:o}}});const l=e.getLogger("default");export{l as logger};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const d=require("path"),nodeSsh=require("node-ssh"),f=require("iconv-lite"),utils_logger=require("./logger.cjs");function _interopDefaultCompat(o){return o&&typeof o=="object"&&"default"in o?o.default:o}const d__default=_interopDefaultCompat(d),f__default=_interopDefaultCompat(f);async function getSSHClient(o){const{host:e,port:r,username:t,password:u,privateKey:i}=o,n=await new nodeSsh.NodeSSH().connect({host:e,port:Number(r),username:t,password:u,privateKey:i});return n.connection.on("error",E=>{E.code==="ECONNRESET"?utils_logger.logger.info("SSH\u8FDE\u63A5\u88AB\u91CD\u7F6E"):utils_logger.logger.error("SSH\u53D1\u751F\u5F02\u5E38:",E)}),n.connection.on("end",()=>{utils_logger.logger.info("SSH\u8FDE\u63A5\u7ED3\u675F")}),n.connection.on("close",()=>{utils_logger.logger.info("SSH\u8FDE\u63A5\u5173\u95ED")}),n}async function getBastionSSHClient(o){utils_logger.logger.info("\u5F00\u59CB\u8FDE\u63A5\u5230\u8FDC\u7A0B\u5821\u5792\u673A...");const e=await getSSHClient(o);return utils_logger.logger.info("\u8FDE\u63A5\u5230\u8FDC\u7A0B\u5821\u5792\u673A\u6210\u529F"),e}async function getBastionChannel(o,e){const{srcIP:r="127.0.0.1",srcPort:t=0,dstIP:u,dstPort:i}=e;utils_logger.logger.info("\u5F00\u59CB\u901A\u8FC7\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u96A7\u9053...");const n=await o.forwardOut(r,Number(t),u,Number(i));return utils_logger.logger.info("\u901A\u8FC7\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u96A7\u9053\u6210\u529F"),n}async function getIntraServerSSHClient(o,e){const{username:r,password:t}=e,u=new nodeSsh.NodeSSH;return utils_logger.logger.info("\u5F00\u59CB\u8FDE\u63A5\u5230\u5185\u90E8\u76EE\u6807\u670D\u52A1\u5668..."),await u.connect({sock:o,username:r,password:t}),utils_logger.logger.info("\u8FDE\u63A5\u5230\u5185\u90E8\u76EE\u6807\u670D\u52A1\u5668\u6210\u529F"),u}async function execIntraServerCommand(o,e,r,t,u){const i=await getBastionChannel(o,e),n=await getIntraServerSSHClient(i,r);utils_logger.logger.info(`\u6267\u884C\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u547D\u4EE4\u3010 ${t} \u3011`);const E=await n.execCommand(t),{stderr:c}=E,a=/\r?\n/,s=E.stdout.split(a);return utils_logger.logger.info(`\u6267\u884C\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u547D\u4EE4\u3010 ${t} \u3011\u5B8C\u6210`),c&&utils_logger.logger.error("\u6267\u884C\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u547D\u4EE4\u3010 ${command} \u3011\u53D1\u751F\u5F02\u5E38:",c),typeof u=="function"&&await u(s),n.dispose(),utils_logger.logger.info("dispose\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u7684SSH"),i.close(),utils_logger.logger.info("close\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u7684CHANNEL"),E}async function putDirectoryToIntraServer(o,e,r,t){const u=await getBastionChannel(o,e),i=await getIntraServerSSHClient(u,r);utils_logger.logger.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668...");const{localDir:n,remoteDir:E}=t;await i.putDirectory(n,E,{recursive:!0,concurrency:10,validate:function(c){return d__default.basename(c).substr(0,1)!=="."},tick:function(c,a,s){s?utils_logger.logger.error("\u4E0A\u4F20\u5230\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u5931\u8D25:",`\u672C\u5730\u6587\u4EF6${c}`):utils_logger.logger.log(`\u4E0A\u4F20\u5230\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u6210\u529F: \u672C\u5730\u6587\u4EF6${c}`)}}),utils_logger.logger.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u5B8C\u6210"),i.dispose(),utils_logger.logger.info("dispose\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u7684SSH"),u.close(),utils_logger.logger.info("close\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u7684CHANNEL")}async function getDirectoryFromIntraServer(o,e,r,t){const u=await getBastionChannel(o,e),i=await getIntraServerSSHClient(u,r);utils_logger.logger.info("\u5F00\u59CB\u4ECE\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730...");const{localDir:n,remoteDir:E}=t;await i.getDirectory(n,E,{recursive:!0,concurrency:10,validate:function(c){return d__default.basename(c).substr(0,1)!=="."},tick:function(c,a,s){s?utils_logger.logger.error("\u4ECE\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0B\u8F7D\u5931\u8D25:",`\u8FDC\u7A0B\u6587\u4EF6${a}`):utils_logger.logger.log(`\u4ECE\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0B\u8F7D\u6210\u529F: \u8FDC\u7A0B\u6587\u4EF6${a}`)}}),utils_logger.logger.info("\u4ECE\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730\u5B8C\u6210"),i.dispose(),utils_logger.logger.info("dispose\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u7684SSH"),u.close(),utils_logger.logger.info("close\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u7684CHANNEL")}async function makeDirectoryOnIntraServer(o,e,r,t){const u=await getBastionChannel(o,e),i=await getIntraServerSSHClient(u,r);utils_logger.logger.info("\u5F00\u59CB\u5728\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55...");const{path:n,method:E,givenSftp:c}=t;await i.mkdir(n,E,c),utils_logger.logger.info("\u5728\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55\u5B8C\u6210"),i.dispose(),utils_logger.logger.info("dispose\u5821\u5792\u673A\u5185\u90E8\u670D\u52A1\u5668\u7684SSH"),u.close(),utils_logger.logger.info("close\u5821\u5792\u673A\u4E0E\u5185\u90E8\u670D\u52A1\u5668\u5EFA\u7ACB\u7684CHANNEL")}async function execRemoteServerCommand(o,e,r={},t){utils_logger.logger.info(`\u6267\u884C\u547D\u4EE4\u3010 ${e} \u3011`);const u=await o.execCommand(e,{encoding:"utf8",...r}),{stderr:i}=u,n=/\r?\n/,E=u.stdout.split(n);utils_logger.logger.info(`\u6267\u884C\u547D\u4EE4\u3010 ${e} \u3011\u5B8C\u6210`),i&&utils_logger.logger.error(`\u6267\u884C\u547D\u4EE4 ${e} \u53D1\u751F\u5F02\u5E38`,i),typeof t=="function"&&await t(E)}async function putDirectoryToRemoteServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668...");const{localDir:r,remoteDir:t}=e;await o.putDirectory(r,t,{recursive:!0,concurrency:10,validate:function(u){return d__default.basename(u).substr(0,1)!=="."},tick:function(u,i,n){n?utils_logger.logger.error("\u4E0A\u4F20\u5931\u8D25:",`\u672C\u5730\u6587\u4EF6${u}`):utils_logger.logger.log(`\u4E0A\u4F20\u6210\u529F: \u672C\u5730\u6587\u4EF6${u}`)}}),utils_logger.logger.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u5B8C\u6210")}async function getDirectoryFromRemoteServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u4ECE\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730...");const{localDir:r,remoteDir:t}=e;await o.getDirectory(r,t,{recursive:!0,concurrency:10,validate:function(u){return d__default.basename(u).substr(0,1)!=="."},tick:function(u,i,n){n?utils_logger.logger.error("\u4E0B\u8F7D\u5931\u8D25:",`\u8FDC\u7A0B\u6587\u4EF6${i}`):utils_logger.logger.log(`\u4E0B\u8F7D\u6210\u529F: \u8FDC\u7A0B\u6587\u4EF6${i}`)}}),utils_logger.logger.info("\u4ECE\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730\u5B8C\u6210")}async function makeDirectoryOnRemoteServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u5728\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55...");const{path:r,method:t,givenSftp:u}=e;await o.mkdir(r,t,u),utils_logger.logger.info("\u5728\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55\u5B8C\u6210")}async function execRemoteWindowServerCommand(o,e,r={},t){utils_logger.logger.info(`\u6267\u884C\u547D\u4EE4\u3010 ${e} \u3011`);const u=await o.execCommand(e,{encoding:"binary",...r}),i=Buffer.isBuffer(u.stdout)?f__default.decode(u.stdout,"GBK"):u.stdout.toString(),n=Buffer.isBuffer(u.stderr)?f__default.decode(u.stderr,"GBK"):u.stderr.toString(),E=/\r?\n/,c=i.split(E);return utils_logger.logger.info(`\u6267\u884C\u547D\u4EE4\u3010 ${e} \u3011\u5B8C\u6210`),n&&utils_logger.logger.error(`\u6267\u884C\u547D\u4EE4 ${e} \u53D1\u751F\u5F02\u5E38`,n),typeof t=="function"&&await t(c),u}async function putDirectoryToRemoteWindowServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668...");const{localDir:r,remoteDir:t}=e;await o.putDirectory(r,t,{recursive:!0,concurrency:10,validate:function(u){return d__default.basename(u).substr(0,1)!=="."},tick:function(u,i,n){n?utils_logger.logger.error("\u4E0A\u4F20\u5931\u8D25:",`\u672C\u5730\u6587\u4EF6${u}`):utils_logger.logger.log(`\u4E0A\u4F20\u6210\u529F: ${u}`)}}),utils_logger.logger.info("\u4E0A\u4F20\u672C\u5730\u76EE\u5F55\u5230\u8FDC\u7A0B\u670D\u52A1\u5668\u5B8C\u6210")}async function getDirectoryFromRemoteWindowServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u4ECE\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730...");const{localDir:r,remoteDir:t}=e;await o.getDirectory(r,t,{recursive:!0,concurrency:10,validate:function(u){return d__default.basename(u).substr(0,1)!=="."},tick:function(u,i,n){n?utils_logger.logger.error("\u4E0B\u8F7D\u5931\u8D25:",`\u8FDC\u7A0B\u6587\u4EF6${u}`):utils_logger.logger.log(`\u4E0B\u8F7D\u6210\u529F: ${u}`)}}),utils_logger.logger.info("\u4ECE\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0B\u8F7D\u76EE\u5F55\u5230\u672C\u5730\u5B8C\u6210")}async function makeDirectoryOnRemoteWindowServer(o,e){utils_logger.logger.info("\u5F00\u59CB\u5728\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55...");const{path:r,method:t,givenSftp:u}=e;await o.mkdir(r,t,u),utils_logger.logger.info("\u5728\u8FDC\u7A0B\u670D\u52A1\u5668\u4E0A\u521B\u5EFA\u76EE\u5F55\u5B8C\u6210")}async function clearRemoteWindowServerDir(o,e){utils_logger.logger.info("\u5F00\u59CB\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55...");const r=`tem${new Date().getTime()}`;await execRemoteWindowServerCommand(o,`mkdir ${e}${r}`),await execRemoteWindowServerCommand(o,`robocopy ${e}${r} ${e} /mir`),await execRemoteWindowServerCommand(o,`rmdir ${e}${r}`),utils_logger.logger.info("\u6E05\u7A7A\u670D\u52A1\u5668\u76EE\u6807\u76EE\u5F55\u5B8C\u6210")}exports.clearRemoteWindowServerDir=clearRemoteWindowServerDir,exports.execIntraServerCommand=execIntraServerCommand,exports.execRemoteServerCommand=execRemoteServerCommand,exports.execRemoteWindowServerCommand=execRemoteWindowServerCommand,exports.getBastionChannel=getBastionChannel,exports.getBastionSSHClient=getBastionSSHClient,exports.getDirectoryFromIntraServer=getDirectoryFromIntraServer,exports.getDirectoryFromRemoteServer=getDirectoryFromRemoteServer,exports.getDirectoryFromRemoteWindowServer=getDirectoryFromRemoteWindowServer,exports.getIntraServerSSHClient=getIntraServerSSHClient,exports.getSSHClient=getSSHClient,exports.makeDirectoryOnIntraServer=makeDirectoryOnIntraServer,exports.makeDirectoryOnRemoteServer=makeDirectoryOnRemoteServer,exports.makeDirectoryOnRemoteWindowServer=makeDirectoryOnRemoteWindowServer,exports.putDirectoryToIntraServer=putDirectoryToIntraServer,exports.putDirectoryToRemoteServer=putDirectoryToRemoteServer,exports.putDirectoryToRemoteWindowServer=putDirectoryToRemoteWindowServer;
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { NodeSSH, SSHExecCommandResponse, SSHExecCommandOptions } from 'node-ssh';
|
|
3
|
+
import { Duplex, Writable, Readable } from 'stream';
|
|
4
|
+
|
|
5
|
+
type ChannelType = "session" | "sftp" | "direct-tcpip" | "direct-streamlocal@openssh.com";
|
|
6
|
+
|
|
7
|
+
type ChannelSubType = "exec" | "shell";
|
|
8
|
+
|
|
9
|
+
interface Channel extends Duplex {
|
|
10
|
+
/** Standard input for the Channel. */
|
|
11
|
+
stdin: this;
|
|
12
|
+
/** Standard output for the Channel. */
|
|
13
|
+
stdout: this;
|
|
14
|
+
/** Standard error for the Channel. */
|
|
15
|
+
stderr: Writable | Readable;
|
|
16
|
+
/** Indicates whether this is a server or client channel. */
|
|
17
|
+
server: boolean;
|
|
18
|
+
/** The channel type, usually "session". */
|
|
19
|
+
type: ChannelType;
|
|
20
|
+
/** The channel subtype, usually "exec", "shell", or undefined. */
|
|
21
|
+
subtype?: ChannelSubType;
|
|
22
|
+
incoming: unknown;
|
|
23
|
+
outgoing: unknown;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sends EOF to the remote side.
|
|
27
|
+
*/
|
|
28
|
+
eof(): void;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Closes the channel on both sides.
|
|
32
|
+
*/
|
|
33
|
+
close(...args: any[]): void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Shuts down the channel on this side.
|
|
37
|
+
*/
|
|
38
|
+
destroy(): this;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Session type-specific methods
|
|
42
|
+
*/
|
|
43
|
+
setWindow(rows: number, cols: number, height: number, width: number): void;
|
|
44
|
+
signal(signalName: string): void;
|
|
45
|
+
exit(status: number): void;
|
|
46
|
+
exit(signalName: string, coreDumped?: boolean, msg?: string): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Emitted once the channel is completely closed on both the client and the server.
|
|
50
|
+
*/
|
|
51
|
+
on(event: "close", listener: () => void): this;
|
|
52
|
+
on(event: "eof", listener: () => void): this;
|
|
53
|
+
on(event: "end", listener: () => void): this;
|
|
54
|
+
on(event: string | symbol, listener: Function): this;
|
|
55
|
+
once(event: "close", listener: () => void): this;
|
|
56
|
+
once(event: "eof", listener: () => void): this;
|
|
57
|
+
once(event: "end", listener: () => void): this;
|
|
58
|
+
once(event: string | symbol, listener: Function): this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @author: ares
|
|
63
|
+
* @date: 2025/8/28 上午9:15
|
|
64
|
+
* @description: SSH连接远程服务器
|
|
65
|
+
* @param config
|
|
66
|
+
* @returns {Promise<NodeSSH>}
|
|
67
|
+
*/
|
|
68
|
+
declare function getSSHClient(config: SSHClientConfig): Promise<NodeSSH>;
|
|
69
|
+
/**
|
|
70
|
+
* @author: ares
|
|
71
|
+
* @date: 2025/8/28 上午9:16
|
|
72
|
+
* @description: SSH连接堡垒机
|
|
73
|
+
* @param config
|
|
74
|
+
* @returns {Promise<NodeSSH>}
|
|
75
|
+
*/
|
|
76
|
+
declare function getBastionSSHClient(config: SSHClientConfig): Promise<NodeSSH>;
|
|
77
|
+
/**
|
|
78
|
+
* @author: ares
|
|
79
|
+
* @date: 2025/8/28 上午9:21
|
|
80
|
+
* @description: 通过堡垒机与内部服务器建立隧道
|
|
81
|
+
* @param bastionSSHClient
|
|
82
|
+
* @param config
|
|
83
|
+
* @returns {Promise<Channel>}
|
|
84
|
+
*/
|
|
85
|
+
declare function getBastionChannel(bastionSSHClient: NodeSSH, config: BastionChannelConfig): Promise<Channel>;
|
|
86
|
+
/**
|
|
87
|
+
* @author: ares
|
|
88
|
+
* @date: 2025/8/28 上午9:25
|
|
89
|
+
* @description: 通过堡垒机隧道与内部服务器建立SSH连接
|
|
90
|
+
* @param channel
|
|
91
|
+
* @param config
|
|
92
|
+
* @returns {Promise<NodeSSH>}
|
|
93
|
+
*/
|
|
94
|
+
declare function getIntraServerSSHClient(channel: Channel, config: IntraServerSSHClientConfig): Promise<NodeSSH>;
|
|
95
|
+
/**
|
|
96
|
+
* @author: ares
|
|
97
|
+
* @date: 2025/8/28 上午9:29
|
|
98
|
+
* @description: 在堡垒机内部服务器上执行命令
|
|
99
|
+
* @param bastionSSHClient
|
|
100
|
+
* @param channelConfig
|
|
101
|
+
* @param intraServerConfig
|
|
102
|
+
* @param command
|
|
103
|
+
* @param callback
|
|
104
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
105
|
+
*/
|
|
106
|
+
declare function execIntraServerCommand(bastionSSHClient: NodeSSH, channelConfig: BastionChannelConfig, intraServerConfig: IntraServerSSHClientConfig, command: string, callback?: any): Promise<SSHExecCommandResponse>;
|
|
107
|
+
/**
|
|
108
|
+
* @author: ares
|
|
109
|
+
* @date: 2025/8/28 上午9:35
|
|
110
|
+
* @description: 上传本地目录到堡垒机内部服务器
|
|
111
|
+
* @param bastionSSHClient
|
|
112
|
+
* @param channelConfig
|
|
113
|
+
* @param intraServerConfig
|
|
114
|
+
* @param config
|
|
115
|
+
* @returns {Promise<void>}
|
|
116
|
+
*/
|
|
117
|
+
declare function putDirectoryToIntraServer(bastionSSHClient: NodeSSH, channelConfig: BastionChannelConfig, intraServerConfig: IntraServerSSHClientConfig, config: UploadDownloadConfig): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* @author: ares
|
|
120
|
+
* @date: 2025/8/29 上午9:45
|
|
121
|
+
* @description: 从堡垒机内部服务器下载目录到本地目录
|
|
122
|
+
* @param bastionSSHClient
|
|
123
|
+
* @param channelConfig
|
|
124
|
+
* @param intraServerConfig
|
|
125
|
+
* @param config
|
|
126
|
+
* @returns {Promise<void>}
|
|
127
|
+
*/
|
|
128
|
+
declare function getDirectoryFromIntraServer(bastionSSHClient: NodeSSH, channelConfig: BastionChannelConfig, intraServerConfig: IntraServerSSHClientConfig, config: UploadDownloadConfig): Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* @author: ares
|
|
131
|
+
* @date: 2025/8/28 上午10:50
|
|
132
|
+
* @description: 在堡垒机内部服务器上创建目录
|
|
133
|
+
* @param bastionSSHClient
|
|
134
|
+
* @param channelConfig
|
|
135
|
+
* @param intraServerConfig
|
|
136
|
+
* @param config
|
|
137
|
+
* @returns {Promise<void>}
|
|
138
|
+
*/
|
|
139
|
+
declare function makeDirectoryOnIntraServer(bastionSSHClient: NodeSSH, channelConfig: BastionChannelConfig, intraServerConfig: IntraServerSSHClientConfig, config: MakeDirectoryConfig): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* @author: ares
|
|
142
|
+
* @date: 2025/8/28 上午9:29
|
|
143
|
+
* @description: 在远程服务器上执行命令
|
|
144
|
+
* @param ssh
|
|
145
|
+
* @param command
|
|
146
|
+
* @param commandOptions
|
|
147
|
+
* @param callback
|
|
148
|
+
* @returns {Promise<void>}
|
|
149
|
+
*/
|
|
150
|
+
declare function execRemoteServerCommand(ssh: NodeSSH, command: string, commandOptions?: SSHExecCommandOptions, callback?: any): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* @author: ares
|
|
153
|
+
* @date: 2025/8/28 上午9:35
|
|
154
|
+
* @description: 上传本地目录到远程服务器
|
|
155
|
+
* @param ssh
|
|
156
|
+
* @param config
|
|
157
|
+
* @returns {Promise<void>}
|
|
158
|
+
*/
|
|
159
|
+
declare function putDirectoryToRemoteServer(ssh: NodeSSH, config: UploadDownloadConfig): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* @author: ares
|
|
162
|
+
* @date: 2025/8/29 上午9:45
|
|
163
|
+
* @description: 从远程服务器下载目录到本地目录
|
|
164
|
+
* @param ssh
|
|
165
|
+
* @param config
|
|
166
|
+
* @returns {Promise<void>}
|
|
167
|
+
*/
|
|
168
|
+
declare function getDirectoryFromRemoteServer(ssh: NodeSSH, config: UploadDownloadConfig): Promise<void>;
|
|
169
|
+
/**
|
|
170
|
+
* @author: ares
|
|
171
|
+
* @date: 2025/8/28 上午10:50
|
|
172
|
+
* @description: 在远程服务器上创建目录
|
|
173
|
+
* @param ssh
|
|
174
|
+
* @param config
|
|
175
|
+
* @returns {Promise<void>}
|
|
176
|
+
*/
|
|
177
|
+
declare function makeDirectoryOnRemoteServer(ssh: NodeSSH, config: MakeDirectoryConfig): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* @author: ares
|
|
180
|
+
* @date: 2025/8/28 上午9:29
|
|
181
|
+
* @description: 在远程windowServer上执行命令
|
|
182
|
+
* @param ssh
|
|
183
|
+
* @param command
|
|
184
|
+
* @param commandOptions
|
|
185
|
+
* @param callback
|
|
186
|
+
* @returns {Promise<SSHExecCommandResponse>}
|
|
187
|
+
*/
|
|
188
|
+
declare function execRemoteWindowServerCommand(ssh: NodeSSH, command: string, commandOptions?: SSHExecCommandOptions, callback?: any): Promise<SSHExecCommandResponse>;
|
|
189
|
+
/**
|
|
190
|
+
* @author: ares
|
|
191
|
+
* @date: 2025/8/28 上午9:35
|
|
192
|
+
* @description: 上传本地目录到远程windowServer
|
|
193
|
+
* @param ssh
|
|
194
|
+
* @param config
|
|
195
|
+
* @returns {Promise<void>}
|
|
196
|
+
*/
|
|
197
|
+
declare function putDirectoryToRemoteWindowServer(ssh: NodeSSH, config: UploadDownloadConfig): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* @author: ares
|
|
200
|
+
* @date: 2025/8/29 上午9:45
|
|
201
|
+
* @description: 从远程windowServer下载目录到本地目录
|
|
202
|
+
* @param ssh
|
|
203
|
+
* @param config
|
|
204
|
+
* @returns {Promise<void>}
|
|
205
|
+
*/
|
|
206
|
+
declare function getDirectoryFromRemoteWindowServer(ssh: NodeSSH, config: UploadDownloadConfig): Promise<void>;
|
|
207
|
+
/**
|
|
208
|
+
* @author: ares
|
|
209
|
+
* @date: 2025/8/28 上午10:50
|
|
210
|
+
* @description: 在远程windowServer上创建目录
|
|
211
|
+
* @param ssh
|
|
212
|
+
* @param config
|
|
213
|
+
* @returns {Promise<void>}
|
|
214
|
+
*/
|
|
215
|
+
declare function makeDirectoryOnRemoteWindowServer(ssh: NodeSSH, config: MakeDirectoryConfig): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* @author: ares
|
|
218
|
+
* @date: 2025/9/1 下午2:25
|
|
219
|
+
* @description: 在远程windowServer上清空目录
|
|
220
|
+
* @param targetSSH
|
|
221
|
+
* @param path
|
|
222
|
+
* @returns {Promise<void>}
|
|
223
|
+
*/
|
|
224
|
+
declare function clearRemoteWindowServerDir(targetSSH: NodeSSH, path: string): Promise<void>;
|
|
225
|
+
|
|
226
|
+
export { clearRemoteWindowServerDir, execIntraServerCommand, execRemoteServerCommand, execRemoteWindowServerCommand, getBastionChannel, getBastionSSHClient, getDirectoryFromIntraServer, getDirectoryFromRemoteServer, getDirectoryFromRemoteWindowServer, getIntraServerSSHClient, getSSHClient, makeDirectoryOnIntraServer, makeDirectoryOnRemoteServer, makeDirectoryOnRemoteWindowServer, putDirectoryToIntraServer, putDirectoryToRemoteServer, putDirectoryToRemoteWindowServer };
|