Skip to content

Commit

Permalink
v4.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
SamKirkland committed Mar 2, 2024
1 parent c15ea8f commit 8e83cea
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ftp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: ./
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ftps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: ./
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: SamKirkland/[email protected].4
uses: SamKirkland/[email protected].5
with:
server: ftp.samkirkland.com
username: myFtpUserName
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v2
Expand All @@ -99,7 +99,7 @@ jobs:
npm run build
- name: 📂 Sync files
uses: SamKirkland/[email protected].4
uses: SamKirkland/[email protected].5
with:
server: ftp.samkirkland.com
username: myFtpUserName
Expand All @@ -116,10 +116,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: SamKirkland/[email protected].4
uses: SamKirkland/[email protected].5
with:
server: ftp.samkirkland.com
username: myFtpUserName
Expand All @@ -139,10 +139,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: SamKirkland/[email protected].4
uses: SamKirkland/[email protected].5
with:
server: ftp.samkirkland.com
username: myFtpUserName
Expand All @@ -161,10 +161,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: 📂 Sync files
uses: SamKirkland/[email protected].4
uses: SamKirkland/[email protected].5
with:
server: ftp.samkirkland.com
username: myFtpUserName
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ inputs:
required: false
description: "Timeout in milliseconds for FTP operations"
runs:
using: "node16"
using: "node20"
main: "dist/index.js"
branding:
icon: "upload-cloud"
Expand Down
56 changes: 37 additions & 19 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4122,8 +4122,8 @@ const fsStat = (0, util_1.promisify)(fs_1.stat);
const fsOpen = (0, util_1.promisify)(fs_1.open);
const fsClose = (0, util_1.promisify)(fs_1.close);
const fsUnlink = (0, util_1.promisify)(fs_1.unlink);
const LIST_COMMANDS_DEFAULT = ["LIST -a", "LIST"];
const LIST_COMMANDS_MLSD = ["MLSD", "LIST -a", "LIST"];
const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
const LIST_COMMANDS_MLSD = () => ["MLSD", "LIST -a", "LIST"];
/**
* High-level API to interact with an FTP server.
*/
Expand All @@ -4134,7 +4134,7 @@ class Client {
* @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
*/
constructor(timeout = 30000) {
this.availableListCommands = LIST_COMMANDS_DEFAULT;
this.availableListCommands = LIST_COMMANDS_DEFAULT();
this.ftp = new FtpContext_1.FTPContext(timeout);
this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, transfer_1.enterPassiveModeIPv4]);
this.parseList = parseList_1.parseList;
Expand Down Expand Up @@ -4284,10 +4284,10 @@ class Client {
// Use MLSD directory listing if possible. See https://tools.ietf.org/html/rfc3659#section-7.8:
// "The presence of the MLST feature indicates that both MLST and MLSD are supported."
const supportsMLSD = features.has("MLST");
this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD : LIST_COMMANDS_DEFAULT;
this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD() : LIST_COMMANDS_DEFAULT();
await this.send("TYPE I"); // Binary mode
await this.sendIgnoringError("STRU F"); // Use file structure
await this.sendIgnoringError("OPTS UTF8 ON"); // Some servers expect UTF-8 to be enabled explicitly
await this.sendIgnoringError("OPTS UTF8 ON"); // Some servers expect UTF-8 to be enabled explicitly and setting before login might not have worked.
if (supportsMLSD) {
await this.sendIgnoringError("OPTS MLST type;size;modify;unique;unix.mode;unix.owner;unix.group;unix.ownername;unix.groupname;"); // Make sure MLSD listings include all we can parse
}
Expand Down Expand Up @@ -4322,6 +4322,9 @@ class Client {
secureOptions.host = (_b = secureOptions.host) !== null && _b !== void 0 ? _b : options.host;
await this.useTLS(secureOptions);
}
// Set UTF-8 on before login in case there are non-ascii characters in user or password.
// Note that this might not work before login depending on server.
await this.sendIgnoringError("OPTS UTF8 ON");
await this.login(options.user, options.password);
await this.useDefaultSettings();
return welcome;
Expand Down Expand Up @@ -4419,7 +4422,10 @@ class Client {
*/
async remove(path, ignoreErrorCodes = false) {
const validPath = await this.protectWhitespace(path);
return this.send(`DELE ${validPath}`, ignoreErrorCodes);
if (ignoreErrorCodes) {
return this.sendIgnoringError(`DELE ${validPath}`);
}
return this.send(`DELE ${validPath}`);
}
/**
* Report transfer progress for any upload or download to a given handler.
Expand Down Expand Up @@ -4628,10 +4634,13 @@ class Client {
async removeDir(remoteDirPath) {
return this._exitAtCurrentDirectory(async () => {
await this.cd(remoteDirPath);
// Get the absolute path of the target because remoteDirPath might be a relative path, even `../` is possible.
const absoluteDirPath = await this.pwd();
await this.clearWorkingDir();
if (remoteDirPath !== "/") {
const dirIsRoot = absoluteDirPath === "/";
if (!dirIsRoot) {
await this.cdup();
await this.removeEmptyDir(remoteDirPath);
await this.removeEmptyDir(absoluteDirPath);
}
});
}
Expand Down Expand Up @@ -4878,7 +4887,7 @@ var FileType;
FileType[FileType["File"] = 1] = "File";
FileType[FileType["Directory"] = 2] = "Directory";
FileType[FileType["SymbolicLink"] = 3] = "SymbolicLink";
})(FileType = exports.FileType || (exports.FileType = {}));
})(FileType || (exports.FileType = FileType = {}));
/**
* Describes a file, directory or symbolic link.
*/
Expand Down Expand Up @@ -4985,6 +4994,9 @@ class FTPError extends Error {
}
}
exports.FTPError = FTPError;
function doNothing() {
/** Do nothing */
}
/**
* FTPContext holds the control and data sockets of an FTP connection and provides a
* simplified way to interact with an FTP server, handle responses, errors and timeouts.
Expand Down Expand Up @@ -5037,9 +5049,8 @@ class FTPContext {
return;
}
this._closingError = err;
this.send("QUIT"); // Don't wait for an answer
// Close the sockets but don't fully reset this context to preserve `this._closingError`.
this._closeSocket(this._socket);
this._closeControlSocket();
this._closeSocket(this._dataSocket);
// Give the user's task a chance to react, maybe cleanup resources.
this._passToHandler(err);
Expand Down Expand Up @@ -5080,7 +5091,7 @@ class FTPContext {
this._removeSocketListeners(this.socket);
}
else {
this._closeSocket(this.socket);
this._closeControlSocket();
}
}
if (socket) {
Expand Down Expand Up @@ -5289,16 +5300,23 @@ class FTPContext {
});
}
/**
* Close a socket.
* Close the control socket. Sends QUIT, then FIN, and ignores any response or error.
*/
_closeControlSocket() {
this._removeSocketListeners(this._socket);
this._socket.on("error", doNothing);
this.send("QUIT");
this._closeSocket(this._socket);
}
/**
* Close a socket, ignores any error.
* @protected
*/
_closeSocket(socket) {
if (socket) {
this._removeSocketListeners(socket);
socket.on("error", () => { });
socket.on("timeout", () => socket.destroy());
socket.setTimeout(this.timeout);
socket.end();
socket.on("error", doNothing);
socket.destroy();
}
}
/**
Expand Down Expand Up @@ -5790,8 +5808,8 @@ function parseSize(value, info) {
* Parsers for MLSD facts.
*/
const factHandlersByName = {
"size": parseSize,
"sizd": parseSize,
"size": parseSize, // File size
"sizd": parseSize, // Directory size
"unique": (value, info) => {
info.uniqueID = value;
},
Expand Down
2 changes: 1 addition & 1 deletion migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Most features have been carried forward and improved upon. However, some feature
### How to upgrade

1. Remove `with: fetch-depth: 2`. It is no longer needed and removing it will _slightly_ speed up deployments.
2. Change the version to `v4.X.X`, for example `SamKirkland/[email protected].4` (please check the [README](https://github.com/SamKirkland/FTP-Deploy-Action/blob/master/README.md) or the [releases page](https://github.com/SamKirkland/FTP-Deploy-Action/releases/latest) for the latest version).
2. Change the version to `v4.X.X`, for example `SamKirkland/[email protected].5` (please check the [README](https://github.com/SamKirkland/FTP-Deploy-Action/blob/master/README.md) or the [releases page](https://github.com/SamKirkland/FTP-Deploy-Action/releases/latest) for the latest version).
3. If you have a `.git-ftp-include` file you should delete it. Version 4 tracks files differently and no longer needs this config file.
4. If you have a `.git-ftp-ignore` file, you should transfer the options to the new `exclude` argument. **Note:** version 4 excludes any `.git*` and `node_modules/` files / folders by default.
5. Update your arguments to reflect the following changes:
Expand Down
36 changes: 22 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ftp-deploy-action",
"version": "4.3.4",
"version": "4.3.5",
"private": true,
"description": "Automate deploying websites and more with this GitHub action",
"main": "dist/index.js",
Expand All @@ -23,14 +23,14 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.9.1",
"@samkirkland/ftp-deploy": "^1.2.3",
"@samkirkland/ftp-deploy": "^1.2.4",
"@types/jest": "^29.4.1",
"jest": "^29.5.0",
"ts-jest": "^29.0.5",
"ts-node-dev": "^2.0.0"
},
"devDependencies": {
"@types/node": "^14.0.27",
"@types/node": "^20.11.24",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"@vercel/ncc": "^0.34.0",
Expand Down

0 comments on commit 8e83cea

Please sign in to comment.