vite-plugin-deploy-ftp 0.0.6 → 0.0.8
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/dist/index.js +13 -11
- package/dist/index.mjs +13 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -56,7 +56,8 @@ function vitePluginDeployFtp(option) {
|
|
|
56
56
|
sequential: true,
|
|
57
57
|
order: "post",
|
|
58
58
|
async handler() {
|
|
59
|
-
if (!
|
|
59
|
+
if (!open) return;
|
|
60
|
+
if (!host || !port || !user || !password || !uploadPath) {
|
|
60
61
|
console.log(import_chalk.default.yellow("\u8BF7\u914D\u7F6E\u6B63\u786E\u7684FTP\u4FE1\u606F"));
|
|
61
62
|
return;
|
|
62
63
|
}
|
|
@@ -84,17 +85,20 @@ function vitePluginDeployFtp(option) {
|
|
|
84
85
|
uploadSpinner.color = "blue";
|
|
85
86
|
uploadSpinner.text = "\u8FDE\u63A5\u6210\u529F";
|
|
86
87
|
const fileList = await client.list(uploadPath);
|
|
87
|
-
uploadSpinner.succeed(
|
|
88
|
-
`\u5DF2\u8FDE\u63A5 ${import_chalk.default.green(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`)}`
|
|
89
|
-
);
|
|
88
|
+
uploadSpinner.succeed(`\u5DF2\u8FDE\u63A5 ${import_chalk.default.green(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`)}`);
|
|
90
89
|
if (fileList.length) {
|
|
91
|
-
await
|
|
90
|
+
const isBackFiles = await (0, import_prompts.select)({
|
|
91
|
+
message: "\u662F\u5426\u5907\u4EFD\u8FDC\u7A0B\u6587\u4EF6",
|
|
92
|
+
choices: ["\u5426", "\u662F"],
|
|
93
|
+
default: "\u5426"
|
|
94
|
+
});
|
|
95
|
+
if (isBackFiles === "\u662F") {
|
|
96
|
+
await createBackupFile(client, uploadPath, protocol, other);
|
|
97
|
+
}
|
|
92
98
|
}
|
|
93
99
|
const uploadFileSpinner = (0, import_ora.default)("\u4E0A\u4F20\u4E2D...").start();
|
|
94
100
|
await client.uploadFromDir(outDir, uploadPath);
|
|
95
|
-
uploadFileSpinner.succeed(
|
|
96
|
-
"\u4E0A\u4F20\u6210\u529F url:" + import_chalk.default.green(`${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`)
|
|
97
|
-
);
|
|
101
|
+
uploadFileSpinner.succeed("\u4E0A\u4F20\u6210\u529F url:" + import_chalk.default.green(`${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`));
|
|
98
102
|
client.close();
|
|
99
103
|
}
|
|
100
104
|
}
|
|
@@ -111,9 +115,7 @@ async function createBackupFile(client, dir, protocol, other) {
|
|
|
111
115
|
import_node_fs.default.mkdirSync(localDir, { recursive: true });
|
|
112
116
|
}
|
|
113
117
|
await client.downloadToDir(localDir, dir);
|
|
114
|
-
backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${import_chalk.default.yellow(
|
|
115
|
-
`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + dir)}`
|
|
116
|
-
)}`;
|
|
118
|
+
backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${import_chalk.default.yellow(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + dir)}`)}`;
|
|
117
119
|
import_node_fs.default.readdirSync(localDir).forEach((i) => {
|
|
118
120
|
if (i.startsWith("backup_") && i.endsWith(".zip")) {
|
|
119
121
|
import_node_fs.default.rmSync(import_node_path.default.join(localDir, i));
|
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,8 @@ function vitePluginDeployFtp(option) {
|
|
|
22
22
|
sequential: true,
|
|
23
23
|
order: "post",
|
|
24
24
|
async handler() {
|
|
25
|
-
if (!
|
|
25
|
+
if (!open) return;
|
|
26
|
+
if (!host || !port || !user || !password || !uploadPath) {
|
|
26
27
|
console.log(chalk.yellow("\u8BF7\u914D\u7F6E\u6B63\u786E\u7684FTP\u4FE1\u606F"));
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
@@ -50,17 +51,20 @@ function vitePluginDeployFtp(option) {
|
|
|
50
51
|
uploadSpinner.color = "blue";
|
|
51
52
|
uploadSpinner.text = "\u8FDE\u63A5\u6210\u529F";
|
|
52
53
|
const fileList = await client.list(uploadPath);
|
|
53
|
-
uploadSpinner.succeed(
|
|
54
|
-
`\u5DF2\u8FDE\u63A5 ${chalk.green(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + uploadPath)}`)}`
|
|
55
|
-
);
|
|
54
|
+
uploadSpinner.succeed(`\u5DF2\u8FDE\u63A5 ${chalk.green(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + uploadPath)}`)}`);
|
|
56
55
|
if (fileList.length) {
|
|
57
|
-
|
|
56
|
+
const isBackFiles = await select({
|
|
57
|
+
message: "\u662F\u5426\u5907\u4EFD\u8FDC\u7A0B\u6587\u4EF6",
|
|
58
|
+
choices: ["\u5426", "\u662F"],
|
|
59
|
+
default: "\u5426"
|
|
60
|
+
});
|
|
61
|
+
if (isBackFiles === "\u662F") {
|
|
62
|
+
await createBackupFile(client, uploadPath, protocol, other);
|
|
63
|
+
}
|
|
58
64
|
}
|
|
59
65
|
const uploadFileSpinner = ora("\u4E0A\u4F20\u4E2D...").start();
|
|
60
66
|
await client.uploadFromDir(outDir, uploadPath);
|
|
61
|
-
uploadFileSpinner.succeed(
|
|
62
|
-
"\u4E0A\u4F20\u6210\u529F url:" + chalk.green(`${protocol + normalizePath(other + uploadPath)}`)
|
|
63
|
-
);
|
|
67
|
+
uploadFileSpinner.succeed("\u4E0A\u4F20\u6210\u529F url:" + chalk.green(`${protocol + normalizePath(other + uploadPath)}`));
|
|
64
68
|
client.close();
|
|
65
69
|
}
|
|
66
70
|
}
|
|
@@ -77,9 +81,7 @@ async function createBackupFile(client, dir, protocol, other) {
|
|
|
77
81
|
fs.mkdirSync(localDir, { recursive: true });
|
|
78
82
|
}
|
|
79
83
|
await client.downloadToDir(localDir, dir);
|
|
80
|
-
backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${chalk.yellow(
|
|
81
|
-
`\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir)}`
|
|
82
|
-
)}`;
|
|
84
|
+
backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${chalk.yellow(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir)}`)}`;
|
|
83
85
|
fs.readdirSync(localDir).forEach((i) => {
|
|
84
86
|
if (i.startsWith("backup_") && i.endsWith(".zip")) {
|
|
85
87
|
fs.rmSync(path.join(localDir, i));
|