Skip to content

Commit

Permalink
Merge pull request #301 from perry-mitchell/dependencies_upgrade
Browse files Browse the repository at this point in the history
Upgrade dependencies
  • Loading branch information
perry-mitchell authored Apr 20, 2022
2 parents e5c17f7 + 72e020c commit 6caa955
Show file tree
Hide file tree
Showing 30 changed files with 1,640 additions and 1,397 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"printWidth": 100,
"tabWidth": 4
"tabWidth": 4,
"trailingComma": "none",
"arrowParens": "avoid"
}
2,319 changes: 1,304 additions & 1,015 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,58 +57,58 @@
},
"homepage": "https://github.com/perry-mitchell/webdav-client#readme",
"dependencies": {
"axios": "^0.24.0",
"axios": "^0.26.1",
"base-64": "^1.0.0",
"fast-xml-parser": "^3.19.0",
"he": "^1.2.0",
"hot-patcher": "^0.5.0",
"layerr": "^0.1.2",
"md5": "^2.3.0",
"minimatch": "^3.0.4",
"minimatch": "^5.0.1",
"nested-property": "^4.0.0",
"path-posix": "^1.0.0",
"url-join": "^4.0.1",
"url-parse": "^1.5.3"
"url-parse": "^1.5.10"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.15.0",
"@types/node": "^17.0.8",
"@types/url-parse": "^1.4.4",
"babel-loader": "^8.2.2",
"@types/node": "^17.0.25",
"@types/url-parse": "^1.4.8",
"babel-loader": "^8.2.5",
"babel-plugin-transform-async-to-promises": "^0.8.18",
"buffer-equals": "^2.0.0",
"chai": "^4.3.4",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"concurrently": "^6.2.1",
"concurrently": "^7.1.0",
"copy-dir": "^1.3.0",
"directory-exists": "^2.0.1",
"exists-file": "^3.0.2",
"husky": "^4.3.8",
"karma": "^6.3.4",
"karma": "^6.3.19",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-chrome-launcher": "^3.1.1",
"karma-firefox-launcher": "^2.1.1",
"karma-mocha": "^2.0.1",
"karma-sinon": "^1.0.5",
"karma-spec-reporter": "^0.0.33",
"karma-spec-reporter": "^0.0.34",
"karma-webpack": "^5.0.0",
"lint-staged": "^11.1.2",
"lint-staged": "^12.3.8",
"mkdirp": "^1.0.4",
"mocha": "^9.1.0",
"nock": "^13.1.2",
"mocha": "^9.2.2",
"nock": "^13.2.4",
"nodemon": "^2.0.12",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"prettier": "^1.19.1",
"prettier": "^2.6.2",
"prettier-check": "^2.0.0",
"rimraf": "^3.0.2",
"sinon": "^12.0.1",
"typescript": "^4.3.5",
"wait-on": "^6.0.0",
"sinon": "^13.0.2",
"typescript": "^4.6.3",
"wait-on": "^6.0.1",
"webdav-server": "^2.6.2",
"webpack": "^5.51.1",
"webpack-cli": "^4.8.0"
"webpack": "^5.72.0",
"webpack-cli": "^4.9.2"
}
}
4 changes: 2 additions & 2 deletions source/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function request(requestOptions: RequestOptionsWithState): Promise<Respon
}

// Perform the request and handle digest authentication
return _request(requestOptions).then(function(response: Response) {
return _request(requestOptions).then(function (response: Response) {
if (response.status == 401) {
_digest.hasDigestAuth = parseDigestAuth(response, _digest);

Expand All @@ -97,7 +97,7 @@ export function request(requestOptions: RequestOptionsWithState): Promise<Respon
}
});

return _request(requestOptions).then(function(response2: Response) {
return _request(requestOptions).then(function (response2: Response) {
if (response2.status == 401) {
_digest.hasDigestAuth = false;
} else {
Expand Down
6 changes: 1 addition & 5 deletions source/tools/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ const SEP_PATH_WINDOWS = "__PATH_SEPARATOR_WINDOWS__";
export function encodePath(path) {
const replaced = path.replace(/\//g, SEP_PATH_POSIX).replace(/\\\\/g, SEP_PATH_WINDOWS);
const formatted = encodeURIComponent(replaced);
return formatted
.split(SEP_PATH_WINDOWS)
.join("\\\\")
.split(SEP_PATH_POSIX)
.join("/");
return formatted.split(SEP_PATH_WINDOWS).join("\\\\").split(SEP_PATH_POSIX).join("/");
}

export function getAllDirectories(path: string): Array<string> {
Expand Down
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (process.env.CI) {
browsers.push("CustomChrome");
}

module.exports = function(config) {
module.exports = function (config) {
config.set({
basePath: "../",
frameworks: ["mocha", "chai", "sinon"],
Expand Down
26 changes: 13 additions & 13 deletions test/node/auth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ const {

const DUMMYSERVER = "https://dummy.webdav.server";

describe("auth", function() {
afterEach(function() {
describe("auth", function () {
afterEach(function () {
nock.cleanAll();
});

it("should connect unauthenticated if no credentials are passed", function() {
it("should connect unauthenticated if no credentials are passed", function () {
nock(DUMMYSERVER)
.get("/file")
.reply(200, function() {
.reply(200, function () {
expect(this.req.headers.authorization).to.be.undefined;
return "";
});
const webdav = createWebDAVClient(DUMMYSERVER);
return webdav.getFileContents("/file");
});

it("should connect using HTTP Basic if user and password are provided", function() {
it("should connect using HTTP Basic if user and password are provided", function () {
nock(DUMMYSERVER)
.get("/file")
.reply(200, function() {
.reply(200, function () {
expect(this.req.headers.authorization).to.equal("Basic dXNlcjpwYXNz");
return "";
});
Expand All @@ -41,10 +41,10 @@ describe("auth", function() {
return webdav.getFileContents("/file");
});

it("should connect using a Bearer token if an object is provided", function() {
it("should connect using a Bearer token if an object is provided", function () {
nock(DUMMYSERVER)
.get("/file")
.reply(200, function() {
.reply(200, function () {
expect(this.req.headers.authorization).to.deep.equal("Bearer ABC123");
return "";
});
Expand All @@ -58,8 +58,8 @@ describe("auth", function() {
return webdav.getFileContents("/file");
});

describe("using Digest-enabled server", function() {
beforeEach(function() {
describe("using Digest-enabled server", function () {
beforeEach(function () {
this.client = createWebDAVClient(`http://localhost:${SERVER_PORT}/webdav/server`, {
username: SERVER_USERNAME,
password: SERVER_PASSWORD,
Expand All @@ -70,12 +70,12 @@ describe("auth", function() {
return this.server.start();
});

afterEach(function() {
afterEach(function () {
return this.server.stop();
});

it("should connect using Digest authentication if digest enabled", function() {
return this.client.exists("/alrighty.jpg").then(function(exists) {
it("should connect using Digest authentication if digest enabled", function () {
return this.client.exists("/alrighty.jpg").then(function (exists) {
expect(exists).to.be.true;
});
});
Expand Down
24 changes: 11 additions & 13 deletions test/node/operations/copyFile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const {

const TEST_CONTENTS = path.resolve(__dirname, "../../testContents");

describe("copyFile", function() {
beforeEach(function() {
describe("copyFile", function () {
beforeEach(function () {
this.client = createWebDAVClient(`http://localhost:${SERVER_PORT}/webdav/server`, {
username: SERVER_USERNAME,
password: SERVER_PASSWORD
Expand All @@ -26,40 +26,38 @@ describe("copyFile", function() {
return this.server.start();
});

afterEach(function() {
afterEach(function () {
restoreRequests();
return this.server.stop();
});

it("copies files from one directory to another", function() {
return this.client.copyFile("/alrighty.jpg", "/sub1/alrighty.jpg").then(function() {
it("copies files from one directory to another", function () {
return this.client.copyFile("/alrighty.jpg", "/sub1/alrighty.jpg").then(function () {
expect(fileExists(path.join(TEST_CONTENTS, "./alrighty.jpg"))).to.be.true;
expect(fileExists(path.join(TEST_CONTENTS, "./sub1/alrighty.jpg"))).to.be.true;
});
});

it("copies directories from one directory to another", function() {
return this.client.copyFile("/webdav", "/sub1/webdav").then(function() {
it("copies directories from one directory to another", function () {
return this.client.copyFile("/webdav", "/sub1/webdav").then(function () {
expect(directoryExists(path.join(TEST_CONTENTS, "./webdav"))).to.be.true;
expect(directoryExists(path.join(TEST_CONTENTS, "./sub1/webdav"))).to.be.true;
});
});

it("copies files with special characters", function() {
return this.client.copyFile("/sub1/ยากจน #1.txt", "/sub1/ยากจน #2.txt").then(function() {
it("copies files with special characters", function () {
return this.client.copyFile("/sub1/ยากจน #1.txt", "/sub1/ยากจน #2.txt").then(function () {
expect(fileExists(path.join(TEST_CONTENTS, "./sub1/ยากจน #2.txt"))).to.be.true;
});
});

it("allows specifying custom headers", async function() {
it("allows specifying custom headers", async function () {
await this.client.copyFile("/alrighty.jpg", "/sub1/alrighty.jpg", {
headers: {
"X-test": "test"
}
});
const [requestOptions] = this.requestSpy.firstCall.args;
expect(requestOptions)
.to.have.property("headers")
.that.has.property("X-test", "test");
expect(requestOptions).to.have.property("headers").that.has.property("X-test", "test");
});
});
24 changes: 11 additions & 13 deletions test/node/operations/createDirectory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const {
useRequestSpy
} = require("../../helpers.node.js");

describe("createDirectory", function() {
beforeEach(function() {
describe("createDirectory", function () {
beforeEach(function () {
this.client = createWebDAVClient(`http://localhost:${SERVER_PORT}/webdav/server`, {
username: SERVER_USERNAME,
password: SERVER_PASSWORD
Expand All @@ -23,52 +23,50 @@ describe("createDirectory", function() {
return this.server.start();
});

afterEach(function() {
afterEach(function () {
restoreRequests();
return this.server.stop();
});

it("creates directories", async function() {
it("creates directories", async function () {
const newDir = path.resolve(__dirname, "../../testContents/sub2");
expect(directoryExists(newDir)).to.be.false;
await this.client.createDirectory("/sub2");
expect(directoryExists(newDir)).to.be.true;
});

it("allows specifying custom headers", async function() {
it("allows specifying custom headers", async function () {
await this.client.createDirectory("/sub2", {
headers: {
"X-test": "test"
}
});
const [requestOptions] = this.requestSpy.firstCall.args;
expect(requestOptions)
.to.have.property("headers")
.that.has.property("X-test", "test");
expect(requestOptions).to.have.property("headers").that.has.property("X-test", "test");
});

it("adds the trailing slash to the directory name if missing", async function() {
it("adds the trailing slash to the directory name if missing", async function () {
await this.client.createDirectory("/subdirectory-1122");
const [requestOptions] = this.requestSpy.firstCall.args;
expect(requestOptions.url).to.satisfy(url => url.endsWith("/"));
});

describe("with recursive option", function() {
it("supports creating deep directories", async function() {
describe("with recursive option", function () {
it("supports creating deep directories", async function () {
const newDir = path.resolve(__dirname, "../../testContents/a/b/c/d/e");
expect(directoryExists(newDir)).to.be.false;
await this.client.createDirectory("/a/b/c/d/e", { recursive: true });
expect(directoryExists(newDir)).to.be.true;
});

it("supports creating deep directories which partially exist", async function() {
it("supports creating deep directories which partially exist", async function () {
const newDir = path.resolve(__dirname, "../../testContents/sub1/a/b");
expect(directoryExists(newDir)).to.be.false;
await this.client.createDirectory("/sub1/a/b", { recursive: true });
expect(directoryExists(newDir)).to.be.true;
});

it("has no effect when all paths exist", async function() {
it("has no effect when all paths exist", async function () {
await this.client.createDirectory("/a/b/c", { recursive: true });
await this.client.createDirectory("/a/b/c", { recursive: true });
await this.client.createDirectory("/a", { recursive: true });
Expand Down
Loading

0 comments on commit 6caa955

Please sign in to comment.