vite-plugin-deploy-ftp 0.0.4 → 0.0.6

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 CHANGED
@@ -60,6 +60,10 @@ function vitePluginDeployFtp(option) {
60
60
  console.log(import_chalk.default.yellow("\u8BF7\u914D\u7F6E\u6B63\u786E\u7684FTP\u4FE1\u606F"));
61
61
  return;
62
62
  }
63
+ let [protocol, other] = (alias || "://").split("://");
64
+ if (protocol) {
65
+ protocol = protocol + "://";
66
+ }
63
67
  const ftpUploadChoice = await (0, import_prompts.select)({
64
68
  message: "\u662F\u5426\u4E0A\u4F20FTP",
65
69
  choices: ["\u662F", "\u5426"],
@@ -80,20 +84,26 @@ function vitePluginDeployFtp(option) {
80
84
  uploadSpinner.color = "blue";
81
85
  uploadSpinner.text = "\u8FDE\u63A5\u6210\u529F";
82
86
  const fileList = await client.list(uploadPath);
83
- uploadSpinner.succeed(`\u5DF2\u8FDE\u63A5 ${import_chalk.default.green(`\u76EE\u5F55: ==> ${alias}${uploadPath}`)}`);
87
+ uploadSpinner.succeed(
88
+ `\u5DF2\u8FDE\u63A5 ${import_chalk.default.green(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`)}`
89
+ );
84
90
  if (fileList.length) {
85
- await createBackupFile(client, uploadPath, alias);
91
+ await createBackupFile(client, uploadPath, protocol, other);
86
92
  }
87
93
  const uploadFileSpinner = (0, import_ora.default)("\u4E0A\u4F20\u4E2D...").start();
88
94
  await client.uploadFromDir(outDir, uploadPath);
89
- uploadFileSpinner.succeed("\u4E0A\u4F20\u6210\u529F url:" + import_chalk.default.green(`${alias}${uploadPath}/`));
95
+ uploadFileSpinner.succeed(
96
+ "\u4E0A\u4F20\u6210\u529F url:" + import_chalk.default.green(`${protocol + (0, import_vite.normalizePath)(other + uploadPath)}`)
97
+ );
90
98
  client.close();
91
99
  }
92
100
  }
93
101
  };
94
102
  }
95
- async function createBackupFile(client, dir, alias) {
96
- const backupSpinner = (0, import_ora.default)(`\u521B\u5EFA\u5907\u4EFD\u6587\u4EF6\u4E2D ${import_chalk.default.yellow(`\u76EE\u5F55: ==> ${alias}${dir}`)}`).start();
103
+ async function createBackupFile(client, dir, protocol, other) {
104
+ const backupSpinner = (0, import_ora.default)(
105
+ `\u521B\u5EFA\u5907\u4EFD\u6587\u4EF6\u4E2D ${import_chalk.default.yellow(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + dir)}`)}`
106
+ ).start();
97
107
  const fileName = `backup_${(0, import_dayjs.default)().format("YYYYMMDD_HHmmss")}.zip`;
98
108
  const localDir = `./__temp/zip`;
99
109
  const zipFilePath = `./__temp/${fileName}`;
@@ -101,7 +111,9 @@ async function createBackupFile(client, dir, alias) {
101
111
  import_node_fs.default.mkdirSync(localDir, { recursive: true });
102
112
  }
103
113
  await client.downloadToDir(localDir, dir);
104
- backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${import_chalk.default.yellow(`\u76EE\u5F55: ==> ${alias}${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
+ )}`;
105
117
  import_node_fs.default.readdirSync(localDir).forEach((i) => {
106
118
  if (i.startsWith("backup_") && i.endsWith(".zip")) {
107
119
  import_node_fs.default.rmSync(import_node_path.default.join(localDir, i));
@@ -121,11 +133,11 @@ async function createBackupFile(client, dir, alias) {
121
133
  archive.directory(localDir, false);
122
134
  await archive.finalize();
123
135
  backupSpinner.text = `\u538B\u7F29\u5B8C\u6210, \u51C6\u5907\u4E0A\u4F20 ${import_chalk.default.yellow(
124
- `\u76EE\u5F55: ==> ${(0, import_vite.normalizePath)(`${alias}${dir}/${fileName}`)}`
136
+ `\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + dir + "/" + fileName)}`
125
137
  )}`;
126
138
  await client.uploadFrom(zipFilePath, (0, import_vite.normalizePath)(`${dir}/${fileName}`));
127
139
  backupSpinner.succeed(
128
- `\u5907\u4EFD\u6210\u529F ${import_chalk.default.green(`\u76EE\u5F55: ==> ${(0, import_vite.normalizePath)(`${alias}${dir}/${fileName}`)}`)}`
140
+ `\u5907\u4EFD\u6210\u529F ${import_chalk.default.green(`\u76EE\u5F55: ==> ${protocol + (0, import_vite.normalizePath)(other + dir + "/" + fileName)}`)}`
129
141
  );
130
142
  import_node_fs.default.rmSync(`./__temp`, { recursive: true });
131
143
  }
package/dist/index.mjs CHANGED
@@ -26,6 +26,10 @@ function vitePluginDeployFtp(option) {
26
26
  console.log(chalk.yellow("\u8BF7\u914D\u7F6E\u6B63\u786E\u7684FTP\u4FE1\u606F"));
27
27
  return;
28
28
  }
29
+ let [protocol, other] = (alias || "://").split("://");
30
+ if (protocol) {
31
+ protocol = protocol + "://";
32
+ }
29
33
  const ftpUploadChoice = await select({
30
34
  message: "\u662F\u5426\u4E0A\u4F20FTP",
31
35
  choices: ["\u662F", "\u5426"],
@@ -46,20 +50,26 @@ function vitePluginDeployFtp(option) {
46
50
  uploadSpinner.color = "blue";
47
51
  uploadSpinner.text = "\u8FDE\u63A5\u6210\u529F";
48
52
  const fileList = await client.list(uploadPath);
49
- uploadSpinner.succeed(`\u5DF2\u8FDE\u63A5 ${chalk.green(`\u76EE\u5F55: ==> ${alias}${uploadPath}`)}`);
53
+ uploadSpinner.succeed(
54
+ `\u5DF2\u8FDE\u63A5 ${chalk.green(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + uploadPath)}`)}`
55
+ );
50
56
  if (fileList.length) {
51
- await createBackupFile(client, uploadPath, alias);
57
+ await createBackupFile(client, uploadPath, protocol, other);
52
58
  }
53
59
  const uploadFileSpinner = ora("\u4E0A\u4F20\u4E2D...").start();
54
60
  await client.uploadFromDir(outDir, uploadPath);
55
- uploadFileSpinner.succeed("\u4E0A\u4F20\u6210\u529F url:" + chalk.green(`${alias}${uploadPath}/`));
61
+ uploadFileSpinner.succeed(
62
+ "\u4E0A\u4F20\u6210\u529F url:" + chalk.green(`${protocol + normalizePath(other + uploadPath)}`)
63
+ );
56
64
  client.close();
57
65
  }
58
66
  }
59
67
  };
60
68
  }
61
- async function createBackupFile(client, dir, alias) {
62
- const backupSpinner = ora(`\u521B\u5EFA\u5907\u4EFD\u6587\u4EF6\u4E2D ${chalk.yellow(`\u76EE\u5F55: ==> ${alias}${dir}`)}`).start();
69
+ async function createBackupFile(client, dir, protocol, other) {
70
+ const backupSpinner = ora(
71
+ `\u521B\u5EFA\u5907\u4EFD\u6587\u4EF6\u4E2D ${chalk.yellow(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir)}`)}`
72
+ ).start();
63
73
  const fileName = `backup_${dayjs().format("YYYYMMDD_HHmmss")}.zip`;
64
74
  const localDir = `./__temp/zip`;
65
75
  const zipFilePath = `./__temp/${fileName}`;
@@ -67,7 +77,9 @@ async function createBackupFile(client, dir, alias) {
67
77
  fs.mkdirSync(localDir, { recursive: true });
68
78
  }
69
79
  await client.downloadToDir(localDir, dir);
70
- backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${chalk.yellow(`\u76EE\u5F55: ==> ${alias}${dir}`)}`;
80
+ backupSpinner.text = `\u4E0B\u8F7D\u8FDC\u7A0B\u6587\u4EF6\u6210\u529F ${chalk.yellow(
81
+ `\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir)}`
82
+ )}`;
71
83
  fs.readdirSync(localDir).forEach((i) => {
72
84
  if (i.startsWith("backup_") && i.endsWith(".zip")) {
73
85
  fs.rmSync(path.join(localDir, i));
@@ -87,11 +99,11 @@ async function createBackupFile(client, dir, alias) {
87
99
  archive.directory(localDir, false);
88
100
  await archive.finalize();
89
101
  backupSpinner.text = `\u538B\u7F29\u5B8C\u6210, \u51C6\u5907\u4E0A\u4F20 ${chalk.yellow(
90
- `\u76EE\u5F55: ==> ${normalizePath(`${alias}${dir}/${fileName}`)}`
102
+ `\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir + "/" + fileName)}`
91
103
  )}`;
92
104
  await client.uploadFrom(zipFilePath, normalizePath(`${dir}/${fileName}`));
93
105
  backupSpinner.succeed(
94
- `\u5907\u4EFD\u6210\u529F ${chalk.green(`\u76EE\u5F55: ==> ${normalizePath(`${alias}${dir}/${fileName}`)}`)}`
106
+ `\u5907\u4EFD\u6210\u529F ${chalk.green(`\u76EE\u5F55: ==> ${protocol + normalizePath(other + dir + "/" + fileName)}`)}`
95
107
  );
96
108
  fs.rmSync(`./__temp`, { recursive: true });
97
109
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-deploy-ftp",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",