savim-ftp
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -16,2 +16,6 @@ /// <reference types="node" /> | ||
deleteFile(filenameWithPath: string): Promise<void>; | ||
createFolder(filenameWithPath: string): Promise<void>; | ||
deleteFolder(filenameWithPath: string): Promise<void>; | ||
getFolders(path: string): Promise<string[]>; | ||
getFiles(path: string): Promise<string[]>; | ||
} | ||
@@ -18,0 +22,0 @@ import { Writable } from 'stream'; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
var basicFtp = require('basic-ftp'); | ||
var path = require('path'); | ||
var stream = require('stream'); | ||
@@ -200,2 +201,116 @@ | ||
_proto.createFolder = /*#__PURE__*/function () { | ||
var _createFolder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(filenameWithPath) { | ||
return _regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return this.client.ensureDir(filenameWithPath); | ||
case 2: | ||
_context5.next = 4; | ||
return this.client.ensureDir('~'); | ||
case 4: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee5, this); | ||
})); | ||
function createFolder(_x6) { | ||
return _createFolder.apply(this, arguments); | ||
} | ||
return createFolder; | ||
}(); | ||
_proto.deleteFolder = /*#__PURE__*/function () { | ||
var _deleteFolder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(filenameWithPath) { | ||
return _regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context6.next = 2; | ||
return this.client.removeDir(filenameWithPath); | ||
case 2: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6, this); | ||
})); | ||
function deleteFolder(_x7) { | ||
return _deleteFolder.apply(this, arguments); | ||
} | ||
return deleteFolder; | ||
}(); | ||
_proto.getFolders = /*#__PURE__*/function () { | ||
var _getFolders = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(path$1) { | ||
return _regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
_context7.next = 2; | ||
return this.client.list(path$1); | ||
case 2: | ||
return _context7.abrupt("return", _context7.sent.filter(function (v) { | ||
return v.isDirectory === true; | ||
}).map(function (v) { | ||
return path.join(path$1, v.name); | ||
})); | ||
case 3: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
})); | ||
function getFolders(_x8) { | ||
return _getFolders.apply(this, arguments); | ||
} | ||
return getFolders; | ||
}(); | ||
_proto.getFiles = /*#__PURE__*/function () { | ||
var _getFiles = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(path$1) { | ||
return _regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return this.client.list(path$1); | ||
case 2: | ||
return _context8.abrupt("return", _context8.sent.filter(function (v) { | ||
return v.isFile === true; | ||
}).map(function (v) { | ||
return path.join(path$1, v.name); | ||
})); | ||
case 3: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee8, this); | ||
})); | ||
function getFiles(_x9) { | ||
return _getFiles.apply(this, arguments); | ||
} | ||
return getFiles; | ||
}(); | ||
return SavimFTPProvider; | ||
@@ -202,0 +317,0 @@ }(); // https://github.com/patrickjuchli/basic-ftp/blob/master/src/StringWriter.ts |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,r=(t=require("regenerator-runtime"))&&"object"==typeof t&&"default"in t?t.default:t,e=require("basic-ftp"),n=require("stream");function u(t,r,e,n,u,i,o){try{var c=t[i](o),a=c.value}catch(t){return void e(t)}c.done?r(a):Promise.resolve(a).then(n,u)}function i(t){return function(){var r=this,e=arguments;return new Promise((function(n,i){var o=t.apply(r,e);function c(t){u(o,n,i,c,a,"next",t)}function a(t){u(o,n,i,c,a,"throw",t)}c(void 0)}))}}function o(t,r){return(o=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}var c=function(){function t(t){this.config=t,this.name="ftp",this.client=new e.Client}var u=t.prototype;return u.isHealthy=function(){var t=i(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.access(this.config);case 3:return t.next=5,this.client.list();case 5:return t.abrupt("return",!0);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",!1);case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(){return t.apply(this,arguments)}}(),u.getFile=function(){var t=i(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new a,t.next=3,this.client.downloadTo(n,e);case 3:return t.abrupt("return",n.getText());case 4:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.uploadFile=function(){var t=i(r.mark((function t(e,u,i){var o;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Buffer.isBuffer(u)&&(o=n.Readable.from(u)),u instanceof n.Readable&&(o=u),"string"==typeof u&&(o=n.Readable.from(Buffer.from(u,"utf8"))),t.abrupt("return",this.client.uploadFrom(o,e,i));case 4:case"end":return t.stop()}}),t,this)})));return function(r,e,n){return t.apply(this,arguments)}}(),u.deleteFile=function(){var t=i(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.remove(e);case 2:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),t}(),a=function(t){var r,e;function n(){var r;return(r=t.apply(this,arguments)||this).buf=Buffer.alloc(0),r}e=t,(r=n).prototype=Object.create(e.prototype),r.prototype.constructor=r,o(r,e);var u=n.prototype;return u._write=function(t,r,e){t instanceof Buffer?(this.buf=Buffer.concat([this.buf,t]),e(null)):e(new Error("StringWriter expects chunks of type 'Buffer'."))},u.getText=function(){return this.buf.toString("utf8")},n}(n.Writable);exports.SavimFTPProvider=c,exports.StringWriter=a; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,r=(t=require("regenerator-runtime"))&&"object"==typeof t&&"default"in t?t.default:t,e=require("basic-ftp"),n=require("path"),i=require("stream");function u(t,r,e,n,i,u,c){try{var o=t[u](c),a=o.value}catch(t){return void e(t)}o.done?r(a):Promise.resolve(a).then(n,i)}function c(t){return function(){var r=this,e=arguments;return new Promise((function(n,i){var c=t.apply(r,e);function o(t){u(c,n,i,o,a,"next",t)}function a(t){u(c,n,i,o,a,"throw",t)}o(void 0)}))}}function o(t,r){return(o=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t})(t,r)}var a=function(){function t(t){this.config=t,this.name="ftp",this.client=new e.Client}var u=t.prototype;return u.isHealthy=function(){var t=c(r.mark((function t(){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.client.access(this.config);case 3:return t.next=5,this.client.list();case 5:return t.abrupt("return",!0);case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",!1);case 11:case"end":return t.stop()}}),t,this,[[0,8]])})));return function(){return t.apply(this,arguments)}}(),u.getFile=function(){var t=c(r.mark((function t(e){var n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=new s,t.next=3,this.client.downloadTo(n,e);case 3:return t.abrupt("return",n.getText());case 4:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.uploadFile=function(){var t=c(r.mark((function t(e,n,u){var c;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return Buffer.isBuffer(n)&&(c=i.Readable.from(n)),n instanceof i.Readable&&(c=n),"string"==typeof n&&(c=i.Readable.from(Buffer.from(n,"utf8"))),t.abrupt("return",this.client.uploadFrom(c,e,u));case 4:case"end":return t.stop()}}),t,this)})));return function(r,e,n){return t.apply(this,arguments)}}(),u.deleteFile=function(){var t=c(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.remove(e);case 2:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.createFolder=function(){var t=c(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.ensureDir(e);case 2:return t.next=4,this.client.ensureDir("~");case 4:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.deleteFolder=function(){var t=c(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.removeDir(e);case 2:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.getFolders=function(){var t=c(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.list(e);case 2:return t.abrupt("return",t.sent.filter((function(t){return!0===t.isDirectory})).map((function(t){return n.join(e,t.name)})));case 3:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),u.getFiles=function(){var t=c(r.mark((function t(e){return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.client.list(e);case 2:return t.abrupt("return",t.sent.filter((function(t){return!0===t.isFile})).map((function(t){return n.join(e,t.name)})));case 3:case"end":return t.stop()}}),t,this)})));return function(r){return t.apply(this,arguments)}}(),t}(),s=function(t){var r,e;function n(){var r;return(r=t.apply(this,arguments)||this).buf=Buffer.alloc(0),r}e=t,(r=n).prototype=Object.create(e.prototype),r.prototype.constructor=r,o(r,e);var i=n.prototype;return i._write=function(t,r,e){t instanceof Buffer?(this.buf=Buffer.concat([this.buf,t]),e(null)):e(new Error("StringWriter expects chunks of type 'Buffer'."))},i.getText=function(){return this.buf.toString("utf8")},n}(i.Writable);exports.SavimFTPProvider=a,exports.StringWriter=s; | ||
//# sourceMappingURL=savim-ftp.cjs.production.min.js.map |
import _regeneratorRuntime from 'regenerator-runtime'; | ||
import { Client } from 'basic-ftp'; | ||
import { join } from 'path'; | ||
import { Writable, Readable } from 'stream'; | ||
@@ -193,2 +194,116 @@ | ||
_proto.createFolder = /*#__PURE__*/function () { | ||
var _createFolder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(filenameWithPath) { | ||
return _regeneratorRuntime.wrap(function _callee5$(_context5) { | ||
while (1) { | ||
switch (_context5.prev = _context5.next) { | ||
case 0: | ||
_context5.next = 2; | ||
return this.client.ensureDir(filenameWithPath); | ||
case 2: | ||
_context5.next = 4; | ||
return this.client.ensureDir('~'); | ||
case 4: | ||
case "end": | ||
return _context5.stop(); | ||
} | ||
} | ||
}, _callee5, this); | ||
})); | ||
function createFolder(_x6) { | ||
return _createFolder.apply(this, arguments); | ||
} | ||
return createFolder; | ||
}(); | ||
_proto.deleteFolder = /*#__PURE__*/function () { | ||
var _deleteFolder = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(filenameWithPath) { | ||
return _regeneratorRuntime.wrap(function _callee6$(_context6) { | ||
while (1) { | ||
switch (_context6.prev = _context6.next) { | ||
case 0: | ||
_context6.next = 2; | ||
return this.client.removeDir(filenameWithPath); | ||
case 2: | ||
case "end": | ||
return _context6.stop(); | ||
} | ||
} | ||
}, _callee6, this); | ||
})); | ||
function deleteFolder(_x7) { | ||
return _deleteFolder.apply(this, arguments); | ||
} | ||
return deleteFolder; | ||
}(); | ||
_proto.getFolders = /*#__PURE__*/function () { | ||
var _getFolders = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(path) { | ||
return _regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
while (1) { | ||
switch (_context7.prev = _context7.next) { | ||
case 0: | ||
_context7.next = 2; | ||
return this.client.list(path); | ||
case 2: | ||
return _context7.abrupt("return", _context7.sent.filter(function (v) { | ||
return v.isDirectory === true; | ||
}).map(function (v) { | ||
return join(path, v.name); | ||
})); | ||
case 3: | ||
case "end": | ||
return _context7.stop(); | ||
} | ||
} | ||
}, _callee7, this); | ||
})); | ||
function getFolders(_x8) { | ||
return _getFolders.apply(this, arguments); | ||
} | ||
return getFolders; | ||
}(); | ||
_proto.getFiles = /*#__PURE__*/function () { | ||
var _getFiles = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(path) { | ||
return _regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
_context8.next = 2; | ||
return this.client.list(path); | ||
case 2: | ||
return _context8.abrupt("return", _context8.sent.filter(function (v) { | ||
return v.isFile === true; | ||
}).map(function (v) { | ||
return join(path, v.name); | ||
})); | ||
case 3: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee8, this); | ||
})); | ||
function getFiles(_x9) { | ||
return _getFiles.apply(this, arguments); | ||
} | ||
return getFiles; | ||
}(); | ||
return SavimFTPProvider; | ||
@@ -195,0 +310,0 @@ }(); // https://github.com/patrickjuchli/basic-ftp/blob/master/src/StringWriter.ts |
{ | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -82,4 +82,4 @@ "main": "dist/index.js", | ||
"basic-ftp": "^5.0.2", | ||
"savim": "^1.0.2" | ||
"savim": "^1.1.1" | ||
} | ||
} |
import { AccessOptions, Client, UploadOptions } from 'basic-ftp'; | ||
import { join } from 'path'; | ||
import { SavimProviderInterface } from 'savim'; | ||
@@ -61,2 +62,23 @@ import { Readable, Stream } from 'stream'; | ||
} | ||
async createFolder(filenameWithPath: string) { | ||
await this.client.ensureDir(filenameWithPath); | ||
await this.client.ensureDir('~'); | ||
} | ||
async deleteFolder(filenameWithPath: string) { | ||
await this.client.removeDir(filenameWithPath); | ||
} | ||
async getFolders(path: string): Promise<string[]> { | ||
return (await this.client.list(path)) | ||
.filter((v) => v.isDirectory === true) | ||
.map((v) => join(path, v.name)); | ||
} | ||
async getFiles(path: string): Promise<string[]> { | ||
return (await this.client.list(path)) | ||
.filter((v) => v.isFile === true) | ||
.map((v) => join(path, v.name)); | ||
} | ||
} | ||
@@ -63,0 +85,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
49793
695
Updatedsavim@^1.1.1