|
@@ -1,5 +1,5 @@
|
|
|
-const client = require("ssh2-sftp-client");
|
|
|
-const path = require("path");
|
|
|
+// const client = require("ssh2-sftp-client");
|
|
|
+// const path = require("path");
|
|
|
// const fs = require("fs");
|
|
|
|
|
|
const { execSync } = require("child_process");
|
|
@@ -22,47 +22,47 @@ const { execSync } = require("child_process");
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- async function upServer() {
|
|
|
- const config = {
|
|
|
- path: {
|
|
|
- // 远程地址
|
|
|
- romotePath: "/data2/zyx/static/",
|
|
|
- // 本地地址
|
|
|
- localPath: path.resolve(__dirname, "./dist"),
|
|
|
- },
|
|
|
- romote: {
|
|
|
- // 服务器 ip 地址
|
|
|
- host: "123.57.195.226",
|
|
|
- // 端口号,默认是 22
|
|
|
- port: 22,
|
|
|
- // 登录的用户名
|
|
|
- username: "root",
|
|
|
- // 登录密码
|
|
|
- password: "581100Li.",
|
|
|
- },
|
|
|
- };
|
|
|
- const sftp = new client();
|
|
|
- try {
|
|
|
- await sftp.connect(config.romote);
|
|
|
- const romotePath = config.path.romotePath;
|
|
|
- const isCss = await sftp.exists(romotePath + "css");
|
|
|
- const isFonts = await sftp.exists(romotePath + "fonts");
|
|
|
- const isJs = await sftp.exists(romotePath + "js");
|
|
|
- const isIndexHtml = await sftp.exists(romotePath + "index.html");
|
|
|
- isCss && await sftp.rmdir(romotePath + "css", true);
|
|
|
- isFonts && await sftp.rmdir(romotePath + "fonts", true);
|
|
|
- isJs && await sftp.rmdir(romotePath + "js", true);
|
|
|
- isIndexHtml && await sftp.delete(romotePath + "index.html", true);
|
|
|
- console.log("已清空原有文件");
|
|
|
- await sftp.uploadDir(config.path.localPath, romotePath);
|
|
|
- console.log("上传完成");
|
|
|
- // 断开连接
|
|
|
- sftp.end();
|
|
|
- console.log("断开链接");
|
|
|
- } catch (err) {
|
|
|
- console.log("更新失败", err);
|
|
|
- }
|
|
|
- }
|
|
|
+// async function upServer() {
|
|
|
+// const config = {
|
|
|
+// path: {
|
|
|
+// // 远程地址
|
|
|
+// romotePath: "/data2/zyx/static/",
|
|
|
+// // 本地地址
|
|
|
+// localPath: path.resolve(__dirname, "./dist"),
|
|
|
+// },
|
|
|
+// romote: {
|
|
|
+// // 服务器 ip 地址
|
|
|
+// host: "123.57.195.226",
|
|
|
+// // 端口号,默认是 22
|
|
|
+// port: 22,
|
|
|
+// // 登录的用户名
|
|
|
+// username: "root",
|
|
|
+// // 登录密码
|
|
|
+// password: "581100Li.",
|
|
|
+// },
|
|
|
+// };
|
|
|
+// const sftp = new client();
|
|
|
+// try {
|
|
|
+// await sftp.connect(config.romote);
|
|
|
+// const romotePath = config.path.romotePath;
|
|
|
+// const isCss = await sftp.exists(romotePath + "css");
|
|
|
+// const isFonts = await sftp.exists(romotePath + "fonts");
|
|
|
+// const isJs = await sftp.exists(romotePath + "js");
|
|
|
+// const isIndexHtml = await sftp.exists(romotePath + "index.html");
|
|
|
+// isCss && await sftp.rmdir(romotePath + "css", true);
|
|
|
+// isFonts && await sftp.rmdir(romotePath + "fonts", true);
|
|
|
+// isJs && await sftp.rmdir(romotePath + "js", true);
|
|
|
+// isIndexHtml && await sftp.delete(romotePath + "index.html", true);
|
|
|
+// console.log("已清空原有文件");
|
|
|
+// await sftp.uploadDir(config.path.localPath, romotePath);
|
|
|
+// console.log("上传完成");
|
|
|
+// // 断开连接
|
|
|
+// sftp.end();
|
|
|
+// console.log("断开链接");
|
|
|
+// } catch (err) {
|
|
|
+// console.log("更新失败", err);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
/**
|
|
|
* 上传git
|
|
@@ -83,7 +83,7 @@ const { execSync } = require("child_process");
|
|
|
execFun();
|
|
|
// await getFiles();
|
|
|
// console.log("获取文件路径---完成");
|
|
|
- await upServer();
|
|
|
+ // await upServer();
|
|
|
} catch (err) {
|
|
|
console.log("失败", err);
|
|
|
}
|