basic-sftp
Version:
🤹🏻♀️ A basic promise-based SFTP Client
64 lines (63 loc) • 2.99 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Client = void 0;
const ssh2_js_1 = require("./ssh2.js");
const connect_js_1 = __importStar(require("./functions/connect.js"));
const end_js_1 = __importDefault(require("./functions/end.js"));
const ls_js_1 = __importDefault(require("./functions/ls.js"));
const ensureDir_js_1 = __importDefault(require("./functions/ensureDir.js"));
const is_js_1 = __importDefault(require("./functions/is.js"));
const uploadFile_js_1 = __importDefault(require("./functions/uploadFile.js"));
const unlink_js_1 = __importDefault(require("./functions/unlink.js"));
const downloadFile_js_1 = __importDefault(require("./functions/downloadFile.js"));
const Client = class {
constructor() {
/** Establishes the connection */
this.connect = connect_js_1.default;
/** Reestablishes the connection */
this.reconnect = connect_js_1.reconnect;
/** Get original `ssh2.sftp` connection */
this.getConnection = ssh2_js_1.getConnection;
/** Closes the connection */
this.end = end_js_1.default;
/** Lists the contents of a directory */
this.ls = ls_js_1.default;
/** Get the type from path: File | Directory | null */
this.is = is_js_1.default;
/** Creates the path recursively, if it does not exist */
this.ensureDir = ensureDir_js_1.default;
/** Uploads a local file to the remote server */
this.uploadFile = uploadFile_js_1.default;
/** Downloads a remote file to the local workspace */
this.downloadFile = downloadFile_js_1.default;
/** Remove all files and directories from a directory, including the directory itself, if it exists */
this.unlink = unlink_js_1.default;
}
};
exports.Client = Client;