Skip to content

Commit

Permalink
Merge pull request #156 from simonh1000/sh/deps
Browse files Browse the repository at this point in the history
update deps
  • Loading branch information
simonh1000 authored May 13, 2023
2 parents c72b1b7 + acee8bd commit 2fac5ac
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 128 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

## 2.3.2

- Requre node 8.0
- Require node 8.0

## 2.3.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ A script to run a simple ftp server (using [ftp-srv](https://github.com/trs/ftp-
To use open a console to run the ftp server:

```
cd test
npm run server
```

Expand Down
185 changes: 115 additions & 70 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ftp-deploy",
"version": "2.4.3",
"version": "2.4.4",
"author": "Simon Hampton",
"description": "Ftp a folder from your local disk to an ftp destination",
"main": "src/ftp-deploy",
Expand All @@ -10,14 +10,14 @@
},
"dependencies": {
"bluebird": "^3.7.2",
"minimatch": "5.0.1",
"minimatch": "9.0.0",
"promise-ftp": "^1.3.5",
"read": "^1.0.7",
"read": "^2.1.0",
"ssh2-sftp-client": "^7.2.1",
"upath": "^2.0.1"
},
"devDependencies": {
"chai": "^4.3.6",
"chai": "^4.3.7",
"delete": "^1.1.0",
"ftp-srv": "^4.6.2",
"mocha": "^9.1.3"
Expand All @@ -35,7 +35,7 @@
"url": "https://github.com/simonh1000/ftp-deploy/issues"
},
"engines": {
"node": ">=10"
"node": ">=12"
},
"contributors": [
{
Expand Down
30 changes: 0 additions & 30 deletions playground/test_script.js

This file was deleted.

11 changes: 6 additions & 5 deletions src/ftp-deploy.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
// Mocha tests. https://mochajs.org/#working-with-promises

const path = require("path");
const fs = require("fs");
Expand All @@ -10,11 +11,12 @@ const statP = utils.promisify(fs.stat);

const del = require("delete");
const FtpDeploy = require("./ftp-deploy");
const { assert } = require("console");

const config = {
user: "anonymous",
password: "anon", // Optional, prompted if none given
host: "localhost",
host: "127.0.0.1",
port: 2121,
localRoot: path.join(__dirname, "../test/local"),
remoteRoot: "/ftp",
Expand Down Expand Up @@ -64,10 +66,9 @@ describe("ftp-deploy.spec: deploy tests", () => {
return d.deploy(config);
})
.then(() => {
// Should reject if file does not exist
// Will reject if file does not exist
return statP(remoteDir + "/test-inside-root.txt");
})
.catch((err) => done(err));
});
});
it("should put a dot file", () => {
const d = new FtpDeploy();
Expand All @@ -77,7 +78,7 @@ describe("ftp-deploy.spec: deploy tests", () => {
return d.deploy(config);
})
.then(() => {
// Should reject if file does not exist
// Will reject if file does not exist
return statP(remoteDir + "/.testfile");
});
});
Expand Down
28 changes: 14 additions & 14 deletions src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Promise = require("bluebird");
const read = require("read");
const readP = util.promisify(read);

const minimatch = require("minimatch");
const { minimatch } = require("minimatch");

// P H A S E 0

Expand All @@ -15,7 +15,7 @@ function checkIncludes(config) {
if (!config.include || !config.include.length) {
return Promise.reject({
code: "NoIncludes",
message: "You need to specify files to upload - e.g. ['*', '**/*']"
message: "You need to specify files to upload - e.g. ['*', '**/*']",
});
} else {
return Promise.resolve(config);
Expand All @@ -34,9 +34,9 @@ function getPassword(config) {
config.host +
" (ENTER for none): ",
default: "",
silent: true
silent: true,
};
return readP(options).then(res => {
return readP(options).then((res) => {
let config2 = Object.assign(config, { password: res });
return config2;
});
Expand Down Expand Up @@ -66,7 +66,7 @@ function canIncludePath(includes, excludes, filePath) {
// A method for parsing the source location and storing the information into a suitably formated object
function parseLocal(includes, excludes, localRootDir, relDir) {
// reducer
let handleItem = function(acc, item) {
let handleItem = function (acc, item) {
const currItem = path.join(fullDir, item);
const newRelDir = path.relative(localRootDir, currItem);

Expand Down Expand Up @@ -112,26 +112,26 @@ function countFiles(filemap) {
}

function deleteDir(ftp, dir) {
return ftp.list(dir).then(lst => {
return ftp.list(dir).then((lst) => {
let dirNames = lst
.filter(f => f.type == "d" && f.name != ".." && f.name != ".")
.map(f => path.posix.join(dir, f.name));
.filter((f) => f.type == "d" && f.name != ".." && f.name != ".")
.map((f) => path.posix.join(dir, f.name));

let fnames = lst
.filter(f => f.type != "d")
.map(f => path.posix.join(dir, f.name));
.filter((f) => f.type != "d")
.map((f) => path.posix.join(dir, f.name));

// delete sub-directories and then all files
return Promise.mapSeries(dirNames, dirName => {
return Promise.mapSeries(dirNames, (dirName) => {
// deletes everything in sub-directory, and then itself
return deleteDir(ftp, dirName).then(() => ftp.rmdir(dirName));
}).then(() => Promise.mapSeries(fnames, fname => ftp.delete(fname)));
}).then(() => Promise.mapSeries(fnames, (fname) => ftp.delete(fname)));
});
}

mkDirExists = (ftp, dir) => {
// Make the directory using recursive expand
return ftp.mkdir(dir, true).catch(err => {
return ftp.mkdir(dir, true).catch((err) => {
if (err.message.startsWith("EEXIST")) {
return Promise.resolve();
} else {
Expand All @@ -149,5 +149,5 @@ module.exports = {
canIncludePath: canIncludePath,
countFiles: countFiles,
mkDirExists: mkDirExists,
deleteDir: deleteDir
deleteDir: deleteDir,
};
6 changes: 3 additions & 3 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const FtpSrv = require("ftp-srv");
const port = 2121;
const homeDir =
require("os").homedir() + "/code/projects/ftp-deploy/test/remote";
console.log("serving", homeDir);
// console.log("serving", homeDir);

const options = {
greeting: ["test ftp server", homeDir],
url: "ftp://127.0.0.1:" + port,
anonymous: true,
greeting: ["test ftp server", homeDir],
pasv_url: "127.0.0.1",
url: "ftp://127.0.0.1:" + port,
};

const ftpServer = new FtpSrv(options);
Expand Down

0 comments on commit 2fac5ac

Please sign in to comment.