vite-plugin-deploy-ftp 1.0.1 → 1.1.1

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.d.mts CHANGED
@@ -8,6 +8,7 @@ type vitePluginDeployFtpOption = ({
8
8
  maxRetries?: number;
9
9
  retryDelay?: number;
10
10
  showBackFile?: boolean;
11
+ autoUpload?: boolean;
11
12
  } & {
12
13
  ftps: {
13
14
  name: string;
@@ -26,6 +27,7 @@ type vitePluginDeployFtpOption = ({
26
27
  maxRetries?: number;
27
28
  retryDelay?: number;
28
29
  showBackFile?: boolean;
30
+ autoUpload?: boolean;
29
31
  } & {
30
32
  name?: string;
31
33
  host?: string;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ type vitePluginDeployFtpOption = ({
8
8
  maxRetries?: number;
9
9
  retryDelay?: number;
10
10
  showBackFile?: boolean;
11
+ autoUpload?: boolean;
11
12
  } & {
12
13
  ftps: {
13
14
  name: string;
@@ -26,6 +27,7 @@ type vitePluginDeployFtpOption = ({
26
27
  maxRetries?: number;
27
28
  retryDelay?: number;
28
29
  showBackFile?: boolean;
30
+ autoUpload?: boolean;
29
31
  } & {
30
32
  name?: string;
31
33
  host?: string;
package/dist/index.js CHANGED
@@ -51,7 +51,8 @@ function vitePluginDeployFtp(option) {
51
51
  singleBackFiles = ["index.html"],
52
52
  showBackFile = false,
53
53
  maxRetries = 3,
54
- retryDelay = 1e3
54
+ retryDelay = 1e3,
55
+ autoUpload = false
55
56
  } = option || {};
56
57
  const isMultiFtp = "ftps" in option;
57
58
  const ftpConfigs = isMultiFtp ? option.ftps : [{ ...option, name: option.name || option.alias || option.host }];
@@ -94,12 +95,14 @@ function vitePluginDeployFtp(option) {
94
95
  }
95
96
  };
96
97
  async function deployToFtp() {
97
- const ftpUploadChoice = await (0, import_prompts.select)({
98
- message: "\u662F\u5426\u4E0A\u4F20FTP",
99
- choices: ["\u662F", "\u5426"],
100
- default: "\u662F"
101
- });
102
- if (ftpUploadChoice === "\u5426") return;
98
+ if (!autoUpload) {
99
+ const ftpUploadChoice = await (0, import_prompts.select)({
100
+ message: "\u662F\u5426\u4E0A\u4F20FTP",
101
+ choices: ["\u662F", "\u5426"],
102
+ default: "\u662F"
103
+ });
104
+ if (ftpUploadChoice === "\u5426") return;
105
+ }
103
106
  let selectedConfigs = [];
104
107
  if (isMultiFtp) {
105
108
  if (defaultFtp) {
package/dist/index.mjs CHANGED
@@ -17,7 +17,8 @@ function vitePluginDeployFtp(option) {
17
17
  singleBackFiles = ["index.html"],
18
18
  showBackFile = false,
19
19
  maxRetries = 3,
20
- retryDelay = 1e3
20
+ retryDelay = 1e3,
21
+ autoUpload = false
21
22
  } = option || {};
22
23
  const isMultiFtp = "ftps" in option;
23
24
  const ftpConfigs = isMultiFtp ? option.ftps : [{ ...option, name: option.name || option.alias || option.host }];
@@ -60,12 +61,14 @@ function vitePluginDeployFtp(option) {
60
61
  }
61
62
  };
62
63
  async function deployToFtp() {
63
- const ftpUploadChoice = await select({
64
- message: "\u662F\u5426\u4E0A\u4F20FTP",
65
- choices: ["\u662F", "\u5426"],
66
- default: "\u662F"
67
- });
68
- if (ftpUploadChoice === "\u5426") return;
64
+ if (!autoUpload) {
65
+ const ftpUploadChoice = await select({
66
+ message: "\u662F\u5426\u4E0A\u4F20FTP",
67
+ choices: ["\u662F", "\u5426"],
68
+ default: "\u662F"
69
+ });
70
+ if (ftpUploadChoice === "\u5426") return;
71
+ }
69
72
  let selectedConfigs = [];
70
73
  if (isMultiFtp) {
71
74
  if (defaultFtp) {
package/index.html ADDED
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>vite-plugin-deploy-ftp</title>
7
+ </head>
8
+ <body></body>
9
+
10
+ <script>
11
+ const time = new Date().toLocaleString()
12
+ document.body.innerHTML = `<h1>vite-plugin-deploy-ftp</h1><p>${time}</p>`
13
+ </script>
14
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-deploy-ftp",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "scripts": {
45
45
  "build": "tsup",
46
- "pack": "pnpm run build && pnpm pack"
46
+ "pack": "pnpm run build && pnpm pack",
47
+ "build:test": "vite build"
47
48
  }
48
49
  }
package/vite.config.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { defineConfig } from 'vite'
2
+ import vitePluginDeployFtp from './src'
3
+
4
+ export default defineConfig({
5
+ plugins: [
6
+ vitePluginDeployFtp({
7
+ open: true,
8
+ uploadPath: '__test/vite-plugin-deploy-ftp/',
9
+ singleBack: true,
10
+ defaultFtp: process.env.zH5FtpName,
11
+ autoUpload: true,
12
+ ftps: [
13
+ {
14
+ name: process.env.zH5FtpName || process.env.zH5FtpAlias || '',
15
+ host: process.env.zH5FtpHost,
16
+ port: +(process.env.zH5FtpPort || 21),
17
+ user: process.env.zH5FtpUser,
18
+ password: process.env.zH5FtpPassword,
19
+ alias: process.env.zH5FtpAlias,
20
+ },
21
+ {
22
+ name: process.env.zH5FtpName2 || process.env.zH5FtpAlias2 || '',
23
+ host: process.env.zH5FtpHost2,
24
+ port: +(process.env.zH5FtpPort2 || 21),
25
+ user: process.env.zH5FtpUser2,
26
+ password: process.env.zH5FtpPassword2,
27
+ alias: process.env.zH5FtpAlias2,
28
+ },
29
+ {
30
+ name: process.env.zQRFtpName || process.env.zQRFtpAlias || '',
31
+ host: process.env.zQRFtpHost,
32
+ port: +(process.env.zQRFtpPort || 21),
33
+ user: process.env.zQRFtpUser,
34
+ password: process.env.zQRFtpPassword,
35
+ alias: process.env.zQRFtpAlias,
36
+ },
37
+ ],
38
+ }),
39
+ ],
40
+ build: {
41
+ outDir: 'dist_test',
42
+ },
43
+ })