w-ftp 1.0.2 → 1.0.5

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/docs/index.html CHANGED
@@ -27,7 +27,7 @@
27
27
 
28
28
  <nav >
29
29
 
30
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ftpCheckFile">ftpCheckFile</a></li><li><a href="global.html#ftpConn">ftpConn</a></li><li><a href="global.html#ftpDownload">ftpDownload</a></li><li><a href="global.html#ftpLs">ftpLs</a></li><li><a href="global.html#ftpQuit">ftpQuit</a></li><li><a href="global.html#ftpStateFile">ftpStateFile</a></li><li><a href="global.html#ftpSyncToLocal">ftpSyncToLocal</a></li><li><a href="global.html#ftpSyncToRemote">ftpSyncToRemote</a></li><li><a href="global.html#ftpUpload">ftpUpload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
30
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#conn">conn</a></li><li><a href="global.html#download">download</a></li><li><a href="global.html#isFile">isFile</a></li><li><a href="global.html#isFolder">isFolder</a></li><li><a href="global.html#ls">ls</a></li><li><a href="global.html#quit">quit</a></li><li><a href="global.html#stateFile">stateFile</a></li><li><a href="global.html#syncToLocal">syncToLocal</a></li><li><a href="global.html#syncToRemote">syncToRemote</a></li><li><a href="global.html#upload">upload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
31
31
  </nav>
32
32
 
33
33
  <div id="main">
@@ -68,7 +68,7 @@
68
68
  <br class="clear">
69
69
 
70
70
  <footer>
71
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Jul 23 2022 21:29:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
71
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Sep 03 2022 15:35:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
72
72
  </footer>
73
73
 
74
74
  <script>prettyPrint();</script>
@@ -27,7 +27,7 @@
27
27
 
28
28
  <nav >
29
29
 
30
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#ftpCheckFile">ftpCheckFile</a></li><li><a href="global.html#ftpConn">ftpConn</a></li><li><a href="global.html#ftpDownload">ftpDownload</a></li><li><a href="global.html#ftpLs">ftpLs</a></li><li><a href="global.html#ftpQuit">ftpQuit</a></li><li><a href="global.html#ftpStateFile">ftpStateFile</a></li><li><a href="global.html#ftpSyncToLocal">ftpSyncToLocal</a></li><li><a href="global.html#ftpSyncToRemote">ftpSyncToRemote</a></li><li><a href="global.html#ftpUpload">ftpUpload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
30
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#conn">conn</a></li><li><a href="global.html#download">download</a></li><li><a href="global.html#isFile">isFile</a></li><li><a href="global.html#isFolder">isFolder</a></li><li><a href="global.html#ls">ls</a></li><li><a href="global.html#quit">quit</a></li><li><a href="global.html#stateFile">stateFile</a></li><li><a href="global.html#syncToLocal">syncToLocal</a></li><li><a href="global.html#syncToRemote">syncToRemote</a></li><li><a href="global.html#upload">upload</a></li><li><a href="global.html#WFtp">WFtp</a></li></ul>
31
31
  </nav>
32
32
 
33
33
  <div id="main">
@@ -626,7 +626,7 @@ Ftp.prototype.put = function(from, destination, callback) {
626
626
  // })
627
627
 
628
628
  socket.on('drain', () => {
629
- console.log('drain')
629
+ // console.log('drain')
630
630
  if (from.length > pointer + SLICE) {
631
631
  newBuf = from.slice(pointer, pointer + SLICE)
632
632
  pointer += SLICE
@@ -811,11 +811,14 @@ Ftp.prototype.getPasvSocket = function(callback = NOOP) {
811
811
  */
812
812
  Ftp.prototype.ls = function(filePath, callback) {
813
813
  function entriesToList(err, entries) {
814
+ // console.log('entriesToList', err, entries)
814
815
  if (err) {
815
816
  return callback(err)
816
817
  }
817
818
 
819
+ //ListingParser.parseFtpEntries是基於parse-listing解析, 但原始數據是ls而來, 本身就沒有到秒, 故只有類似dir提供的粗略時間, 無法像fs.statSync提供精確的產生與最新變更時間
818
820
  ListingParser.parseFtpEntries(entries.text || entries, (err, files) => {
821
+ // console.log('ListingParser.parseFtpEntries', err, files)
819
822
  if (err) {
820
823
  return callback(err)
821
824
  }
@@ -834,6 +837,7 @@ Ftp.prototype.ls = function(filePath, callback) {
834
837
  }
835
838
  else {
836
839
  this.raw('stat', filePath, (err, data) => {
840
+ // console.log('filePath', filePath, data)
837
841
  // We might be connected to a server that doesn't support the
838
842
  // 'STAT' command, which is set as default. We use 'LIST' instead,
839
843
  // and we set the variable `useList` to true, to avoid extra round
@@ -912,7 +916,7 @@ module.exports = Ftp
912
916
  <br class="clear">
913
917
 
914
918
  <footer>
915
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Jul 23 2022 21:29:33 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
919
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sat Sep 03 2022 15:35:03 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
916
920
  </footer>
917
921
 
918
922
  <script>prettyPrint();</script>
package/g-download.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs'
3
3
  import WFtp from './src/WFtp.mjs'
4
+ // import WFtp from './dist/w-ftp.umd.js'
4
5
 
5
6
 
6
7
  //st
@@ -23,18 +24,32 @@ async function test_dw() {
23
24
  password: st.dw.password,
24
25
  })
25
26
 
26
- let fps = await ftp.ls('.')
27
- console.log('ftp.ls', fps[0], fps.length)
27
+ async function core() {
28
28
 
29
- r = await ftp.download('./DECL_20210805055044.csv', './_test_download_client/DECL_20210805055044.csv', (p) => {
30
- console.log('ftp.download p', p.name, p.progress)
31
- })
32
- console.log('ftp.download', r)
29
+ let fps = await ftp.ls('.')
30
+ console.log('ftp.ls', fps[0], fps.length)
33
31
 
34
- r = await ftp.syncToLocal('.', './_test_download_client', (p) => {
35
- console.log('ftp.syncToLocal p', p.name, p.progress)
36
- })
37
- console.log('ftp.syncToLocal', r)
32
+ r = await ftp.isFile('./DECL_20210805055044.csv')
33
+ console.log('ftp.isFile', r)
34
+
35
+ r = await ftp.isFolder('./DECL_20210805055044.csv')
36
+ console.log('ftp.isFolder', r)
37
+
38
+ r = await ftp.download('./DECL_20210805055044.csv', './_test_download_client/DECL_20210805055044.csv', (p) => {
39
+ console.log('ftp.download p', p.name, p.progress)
40
+ })
41
+ console.log('ftp.download', r)
42
+
43
+ r = await ftp.syncToLocal('.', './_test_download_client', (p) => {
44
+ console.log('ftp.syncToLocal p', p.name, p.progress)
45
+ })
46
+ console.log('ftp.syncToLocal', r)
47
+
48
+ }
49
+ await core()
50
+ .catch((err) => {
51
+ console.log(err)
52
+ })
38
53
 
39
54
  r = await ftp.quit()
40
55
  console.log('ftp.quit', r)
@@ -55,6 +70,8 @@ test_dw()
55
70
  // groupPermissions: { read: true, write: true, exec: false },
56
71
  // otherPermissions: { read: true, write: true, exec: false }
57
72
  // } 74
73
+ // ftp.isFile false
74
+ // ftp.isFolder false
58
75
  // ftp.download p DECL_20210805055044.csv 4.7320871554333515
59
76
  // ftp.download p DECL_20210805055044.csv 9.464174310866703
60
77
  // ftp.download p DECL_20210805055044.csv 14.196261466300053
package/g-upload.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import path from 'path'
2
2
  import fs from 'fs'
3
3
  import WFtp from './src/WFtp.mjs'
4
+ // import WFtp from './dist/w-ftp.umd.js'
4
5
 
5
6
 
6
7
  //st
@@ -23,18 +24,32 @@ async function test_up() {
23
24
  password: st.up.password,
24
25
  })
25
26
 
26
- let fps = await ftp.ls('.')
27
- console.log('ftp.ls', fps[0], fps.length)
27
+ async function core() {
28
28
 
29
- r = await ftp.upload('./_test_upload_client/DECL_20210805055044.csv', './DECL_20210805055044.csv', (p) => {
30
- console.log('ftp.upload p', p.name, p.progress)
31
- })
32
- console.log('ftp.upload', r)
29
+ let fps = await ftp.ls('.')
30
+ console.log('ftp.ls', fps[0], fps.length)
33
31
 
34
- r = await ftp.syncToRemote('./_test_upload_client', '.', (p) => {
35
- console.log('ftp.syncToRemote p', p.name, p.progress)
36
- })
37
- console.log('ftp.syncToRemote', r)
32
+ r = await ftp.isFile('./DECL_20210805055044.csv')
33
+ console.log('ftp.isFile', r)
34
+
35
+ r = await ftp.isFolder('./DECL_20210805055044.csv')
36
+ console.log('ftp.isFolder', r)
37
+
38
+ r = await ftp.upload('./_test_upload_client/DECL_20210805055044.csv', './DECL_20210805055044.csv', (p) => {
39
+ console.log('ftp.upload p', p.name, p.progress)
40
+ })
41
+ console.log('ftp.upload', r)
42
+
43
+ r = await ftp.syncToRemote('./_test_upload_client', '.', (p) => {
44
+ console.log('ftp.syncToRemote p', p.name, p.progress)
45
+ })
46
+ console.log('ftp.syncToRemote', r)
47
+
48
+ }
49
+ await core()
50
+ .catch((err) => {
51
+ console.log(err)
52
+ })
38
53
 
39
54
  r = await ftp.quit()
40
55
  console.log('ftp.quit', r)
@@ -55,8 +70,9 @@ test_up()
55
70
  // groupPermissions: { read: true, write: true, exec: false },
56
71
  // otherPermissions: { read: true, write: true, exec: false }
57
72
  // } 73
73
+ // ftp.isFile false
74
+ // ftp.isFolder false
58
75
  // ftp.upload p DECL_20210805055044.csv 75.71339448693362
59
- // drain
60
76
  // ftp.upload p DECL_20210805055044.csv 100
61
77
  // ftp.upload ok
62
78
  // ftp.syncToRemote { num: 0, files: [] }
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "w-ftp",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "main": "dist/w-ftp.umd.js",
5
5
  "dependencies": {
6
+ "dayjs": "^1.11.5",
7
+ "debug": "^4.3.4",
8
+ "ftp-response-parser": "^1.0.1",
6
9
  "lodash": "^4.17.21",
7
- "wsemi": "^1.6.61"
10
+ "once": "^1.4.0",
11
+ "parse-listing": "^1.1.3",
12
+ "stream-combiner": "^0.2.2",
13
+ "unorm": "^1.6.0",
14
+ "wsemi": "^1.6.78"
8
15
  },
9
16
  "devDependencies": {
10
- "w-package-tools": "^1.0.65"
17
+ "w-package-tools": "^1.0.66"
11
18
  },
12
19
  "scripts": {
13
20
  "test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",