w-ftp 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.
Files changed (50) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +54 -0
  4. package/.jsdoc +25 -0
  5. package/LICENSE +21 -0
  6. package/README.md +163 -0
  7. package/SECURITY.md +5 -0
  8. package/babel.config.js +14 -0
  9. package/docs/WFtp.mjs.html +665 -0
  10. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  11. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  12. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  13. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  14. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  15. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  16. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  17. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  20. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  21. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  22. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  23. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  24. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  28. package/docs/global.html +439 -0
  29. package/docs/index.html +81 -0
  30. package/docs/jsftp.js.html +925 -0
  31. package/docs/scripts/collapse.js +20 -0
  32. package/docs/scripts/linenumber.js +25 -0
  33. package/docs/scripts/nav.js +12 -0
  34. package/docs/scripts/polyfill.js +4 -0
  35. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  36. package/docs/scripts/prettify/lang-css.js +2 -0
  37. package/docs/scripts/prettify/prettify.js +28 -0
  38. package/docs/scripts/search.js +83 -0
  39. package/docs/styles/jsdoc.css +765 -0
  40. package/docs/styles/prettify.css +79 -0
  41. package/g-download.mjs +84 -0
  42. package/g-upload.mjs +65 -0
  43. package/package.json +30 -0
  44. package/src/WFtp.mjs +596 -0
  45. package/src/jsftp.js +856 -0
  46. package/test/all.test.mjs +10 -0
  47. package/toolg/addVersion.mjs +4 -0
  48. package/toolg/cleanFolder.mjs +4 -0
  49. package/toolg/gDistRollup.mjs +27 -0
  50. package/toolg/modifyReadme.mjs +4 -0
package/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 4
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ /build/
2
+ /config/
3
+ /dist/
package/.eslintrc.js ADDED
@@ -0,0 +1,54 @@
1
+ module.exports = {
2
+ "env": {
3
+ "browser": true,
4
+ "es6": true,
5
+ "mocha": true
6
+ },
7
+ "extends": ["plugin:vue/base", "plugin:vue/essential", "standard"],
8
+ "plugins": [
9
+ "vue"
10
+ ],
11
+ "globals": {
12
+ "Atomics": "readonly",
13
+ "SharedArrayBuffer": "readonly"
14
+ },
15
+ "parser": "vue-eslint-parser",
16
+ "parserOptions": {
17
+ "parser": "babel-eslint",
18
+ "ecmaVersion": 2019,
19
+ "sourceType": "module",
20
+ },
21
+ rules: {
22
+ 'generator-star-spacing': 'off',
23
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
24
+ 'indent': ['error', 4],
25
+ 'no-console': 'off',
26
+ 'comma-dangle': ['error', {
27
+ 'arrays': 'ignore',
28
+ 'objects': 'ignore',
29
+ 'imports': 'never',
30
+ 'exports': 'never',
31
+ 'functions': 'ignore'
32
+ }],
33
+ 'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 2 }],
34
+ //'space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never' }],
35
+ 'space-before-function-paren': 'off',
36
+ 'spaced-comment': 'off',
37
+ 'brace-style': ['error', 'stroustrup'],
38
+ 'padded-blocks': 'off',
39
+ 'no-constant-condition': 'off',
40
+ 'camelcase': 'off',
41
+ 'no-new': 'off',
42
+ 'prefer-const': 'off',
43
+ 'quote-props': ['error', 'consistent'],
44
+ 'dot-notation': 'off',
45
+ 'standard/no-callback-literal': 'off',
46
+ 'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
47
+ 'prefer-promise-reject-errors': 'off',
48
+ 'no-unused-vars': ['error', { 'args': 'none', 'ignoreRestSiblings': true, 'argsIgnorePattern': '^_' }],
49
+ 'node/no-callback-literal': 'off',
50
+ 'prefer-regex-literals': 'off',
51
+ 'array-callback-return': 'off',
52
+ 'no-unreachable-loop': 'off',
53
+ }
54
+ };
package/.jsdoc ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "tags": {
3
+ "allowUnknownTags": false
4
+ },
5
+ "source": {
6
+ "include": ["src/", "server/"],
7
+ "includePattern": ".+\\.(js(doc|x)?|mjs|vue)$",
8
+ "excludePattern": "(node_modules/|docs)"
9
+ },
10
+ "plugins": [
11
+ "plugins/markdown",
12
+ "node_modules/jsdoc-vuejs"
13
+ ],
14
+ "opts": {
15
+ "template": "node_modules/docdash",
16
+ "encoding": "utf8",
17
+ "destination": "docs/",
18
+ "recurse": true,
19
+ "verbose": true
20
+ },
21
+ "templates": {
22
+ "cleverLinks": false,
23
+ "monospaceLinks": false
24
+ }
25
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 semisphere(yu-da, lyu 呂昱達)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # w-ftp
2
+ A tool for ftp.
3
+
4
+ ![language](https://img.shields.io/badge/language-JavaScript-orange.svg)
5
+ [![npm version](http://img.shields.io/npm/v/w-ftp.svg?style=flat)](https://npmjs.org/package/w-ftp)
6
+ [![license](https://img.shields.io/npm/l/w-ftp.svg?style=flat)](https://npmjs.org/package/w-ftp)
7
+ [![gzip file size](http://img.badgesize.io/yuda-lyu/w-ftp/master/dist/w-ftp.umd.js.svg?compression=gzip)](https://github.com/yuda-lyu/w-ftp)
8
+ [![npm download](https://img.shields.io/npm/dt/w-ftp.svg)](https://npmjs.org/package/w-ftp)
9
+ [![jsdelivr download](https://img.shields.io/jsdelivr/npm/hm/w-ftp.svg)](https://www.jsdelivr.com/package/npm/w-ftp)
10
+
11
+ ## Documentation
12
+ To view documentation or get support, visit [docs](https://yuda-lyu.github.io/w-ftp/global.htm).
13
+
14
+ ## Installation
15
+ ### Using npm(ES6 module):
16
+ > **Note:** `w-ftp` is mainly dependent on the fork of `jsftp`, `lodash` and `wsemi`.
17
+
18
+ ```alias
19
+ npm i w-ftp
20
+ ```
21
+
22
+ #### Example for download:
23
+ > **Link:** [[dev source code](https://github.com/yuda-lyu/w-ftp/blob/master/g-download.mjs)]
24
+ ```alias
25
+ import path from 'path'
26
+ import fs from 'fs'
27
+ import WFtp from './src/WFtp.mjs'
28
+
29
+
30
+ async function test_up() {
31
+ let r
32
+
33
+ let ftp = WFtp()
34
+ // console.log('ftp', ftp)
35
+
36
+ await ftp.conn({
37
+ hostname: `hostname`,
38
+ port: `port`,
39
+ username: `username`,
40
+ password: `password`,
41
+ })
42
+
43
+ let fps = await ftp.ls('.')
44
+ console.log('ftp.ls', fps[0], fps.length)
45
+
46
+ r = await ftp.upload('./_test_upload_client/DECL_20210805055044.csv', './DECL_20210805055044.csv', (p) => {
47
+ console.log('ftp.upload p', p.name, p.progress)
48
+ })
49
+ console.log('ftp.upload', r)
50
+
51
+ r = await ftp.syncToRemote('./_test_upload_client', '.', (p) => {
52
+ console.log('ftp.syncToRemote p', p.name, p.progress)
53
+ })
54
+ console.log('ftp.syncToRemote', r)
55
+
56
+ r = await ftp.quit()
57
+ console.log('ftp.quit', r)
58
+
59
+ }
60
+ test_up()
61
+ .catch((err) => {
62
+ console.log(err)
63
+ })
64
+ // ftp.ls {
65
+ // name: 'DECL_202108.csv',
66
+ // type: 0,
67
+ // time: 1658366760000,
68
+ // size: '218690',
69
+ // owner: 'ftp',
70
+ // group: 'ftp',
71
+ // userPermissions: { read: true, write: true, exec: false },
72
+ // groupPermissions: { read: true, write: true, exec: false },
73
+ // otherPermissions: { read: true, write: true, exec: false }
74
+ // } 73
75
+ // ftp.upload p DECL_20210805055044.csv 75.71339448693362
76
+ // drain
77
+ // ftp.upload p DECL_20210805055044.csv 100
78
+ // ftp.upload ok
79
+ // ftp.syncToRemote { num: 0, files: [] }
80
+ // ftp.quit { code: 221, text: '221 Goodbye.', isMark: false, isError: false }
81
+
82
+ ```
83
+
84
+ #### Example for upload:
85
+ > **Link:** [[dev source code](https://github.com/yuda-lyu/w-ftp/blob/master/g-upload.mjs)]
86
+ ```alias
87
+ import path from 'path'
88
+ import fs from 'fs'
89
+ import WFtp from './src/WFtp.mjs'
90
+
91
+
92
+ async function test_dw() {
93
+ let r
94
+
95
+ let ftp = WFtp()
96
+ // console.log('ftp', ftp)
97
+
98
+ await ftp.conn({
99
+ hostname: `hostname`,
100
+ port: `port`,
101
+ username: `username`,
102
+ password: `password`,
103
+ })
104
+
105
+ let fps = await ftp.ls('.')
106
+ console.log('ftp.ls', fps[0], fps.length)
107
+
108
+ r = await ftp.download('./DECL_20210805055044.csv', './_test_download_client/DECL_20210805055044.csv', (p) => {
109
+ console.log('ftp.download p', p.name, p.progress)
110
+ })
111
+ console.log('ftp.download', r)
112
+
113
+ r = await ftp.syncToLocal('.', './_test_download_client', (p) => {
114
+ console.log('ftp.syncToLocal p', p.name, p.progress)
115
+ })
116
+ console.log('ftp.syncToLocal', r)
117
+
118
+ r = await ftp.quit()
119
+ console.log('ftp.quit', r)
120
+
121
+ }
122
+ test_dw()
123
+ .catch((err) => {
124
+ console.log(err)
125
+ })
126
+ // ftp.ls {
127
+ // name: 'DECL_202108.csv',
128
+ // type: 0,
129
+ // time: 1658302140000,
130
+ // size: '218690',
131
+ // owner: 'ftp',
132
+ // group: 'ftp',
133
+ // userPermissions: { read: true, write: true, exec: false },
134
+ // groupPermissions: { read: true, write: true, exec: false },
135
+ // otherPermissions: { read: true, write: true, exec: false }
136
+ // } 74
137
+ // ftp.download p DECL_20210805055044.csv 4.7320871554333515
138
+ // ftp.download p DECL_20210805055044.csv 9.464174310866703
139
+ // ftp.download p DECL_20210805055044.csv 14.196261466300053
140
+ // ftp.download p DECL_20210805055044.csv 18.928348621733406
141
+ // ftp.download p DECL_20210805055044.csv 23.660435777166754
142
+ // ftp.download p DECL_20210805055044.csv 28.392522932600105
143
+ // ftp.download p DECL_20210805055044.csv 33.12461008803346
144
+ // ftp.download p DECL_20210805055044.csv 37.85669724346681
145
+ // ftp.download p DECL_20210805055044.csv 42.58878439890016
146
+ // ftp.download p DECL_20210805055044.csv 47.32087155433351
147
+ // ftp.download p DECL_20210805055044.csv 52.05295870976686
148
+ // ftp.download p DECL_20210805055044.csv 56.78504586520021
149
+ // ftp.download p DECL_20210805055044.csv 61.517133020633565
150
+ // ftp.download p DECL_20210805055044.csv 66.24922017606691
151
+ // ftp.download p DECL_20210805055044.csv 70.98130733150026
152
+ // ftp.download p DECL_20210805055044.csv 75.71339448693362
153
+ // ftp.download p DECL_20210805055044.csv 80.44548164236697
154
+ // ftp.download p DECL_20210805055044.csv 85.17756879780032
155
+ // ftp.download p DECL_20210805055044.csv 89.90965595323367
156
+ // ftp.download p DECL_20210805055044.csv 94.64174310866701
157
+ // ftp.download p DECL_20210805055044.csv 99.37383026410038
158
+ // ftp.download p DECL_20210805055044.csv 100
159
+ // ftp.download ok
160
+ // ftp.syncToLocal { num: 0, files: [] }
161
+ // ftp.quit { code: 221, text: '221 Goodbye.', isMark: false, isError: false }
162
+
163
+ ```
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues to `firsemisphere@gmail.com`
@@ -0,0 +1,14 @@
1
+ module.exports = {
2
+ 'presets': [
3
+ ['@babel/preset-env', {
4
+ 'useBuiltIns': 'entry',
5
+ 'corejs': 3
6
+ }]
7
+ ],
8
+ 'plugins': [
9
+ '@babel/plugin-transform-runtime',
10
+ '@babel/plugin-proposal-export-default-from',
11
+ '@babel/plugin-proposal-nullish-coalescing-operator',
12
+ '@babel/plugin-proposal-optional-chaining'
13
+ ]
14
+ }