Skip to content

Commit 8e83cea

Browse files
committed
v4.3.5
1 parent c15ea8f commit 8e83cea

File tree

8 files changed

+76
-50
lines changed

8 files changed

+76
-50
lines changed

.github/workflows/ftp.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: 🚚 Get latest code
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- name: 📂 Sync files
1616
uses: ./

.github/workflows/ftps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: 🚚 Get latest code
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414

1515
- name: 📂 Sync files
1616
uses: ./

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: 🚚 Get latest code
23-
uses: actions/checkout@v3
23+
uses: actions/checkout@v4
2424

2525
- name: 📂 Sync files
26-
uses: SamKirkland/[email protected].4
26+
uses: SamKirkland/[email protected].5
2727
with:
2828
server: ftp.samkirkland.com
2929
username: myFtpUserName
@@ -86,7 +86,7 @@ jobs:
8686
runs-on: ubuntu-latest
8787
steps:
8888
- name: 🚚 Get latest code
89-
uses: actions/checkout@v3
89+
uses: actions/checkout@v4
9090
9191
- name: Use Node.js 16
9292
uses: actions/setup-node@v2
@@ -99,7 +99,7 @@ jobs:
9999
npm run build
100100
101101
- name: 📂 Sync files
102-
uses: SamKirkland/[email protected].4
102+
uses: SamKirkland/[email protected].5
103103
with:
104104
server: ftp.samkirkland.com
105105
username: myFtpUserName
@@ -116,10 +116,10 @@ jobs:
116116
runs-on: ubuntu-latest
117117
steps:
118118
- name: 🚚 Get latest code
119-
uses: actions/checkout@v3
119+
uses: actions/checkout@v4
120120
121121
- name: 📂 Sync files
122-
uses: SamKirkland/[email protected].4
122+
uses: SamKirkland/[email protected].5
123123
with:
124124
server: ftp.samkirkland.com
125125
username: myFtpUserName
@@ -139,10 +139,10 @@ jobs:
139139
runs-on: ubuntu-latest
140140
steps:
141141
- name: 🚚 Get latest code
142-
uses: actions/checkout@v3
142+
uses: actions/checkout@v4
143143
144144
- name: 📂 Sync files
145-
uses: SamKirkland/[email protected].4
145+
uses: SamKirkland/[email protected].5
146146
with:
147147
server: ftp.samkirkland.com
148148
username: myFtpUserName
@@ -161,10 +161,10 @@ jobs:
161161
runs-on: ubuntu-latest
162162
steps:
163163
- name: 🚚 Get latest code
164-
uses: actions/checkout@v3
164+
uses: actions/checkout@v4
165165
166166
- name: 📂 Sync files
167-
uses: SamKirkland/[email protected].4
167+
uses: SamKirkland/[email protected].5
168168
with:
169169
server: ftp.samkirkland.com
170170
username: myFtpUserName

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ inputs:
4545
required: false
4646
description: "Timeout in milliseconds for FTP operations"
4747
runs:
48-
using: "node16"
48+
using: "node20"
4949
main: "dist/index.js"
5050
branding:
5151
icon: "upload-cloud"

dist/index.js

+37-19
Original file line numberDiff line numberDiff line change
@@ -4122,8 +4122,8 @@ const fsStat = (0, util_1.promisify)(fs_1.stat);
41224122
const fsOpen = (0, util_1.promisify)(fs_1.open);
41234123
const fsClose = (0, util_1.promisify)(fs_1.close);
41244124
const fsUnlink = (0, util_1.promisify)(fs_1.unlink);
4125-
const LIST_COMMANDS_DEFAULT = ["LIST -a", "LIST"];
4126-
const LIST_COMMANDS_MLSD = ["MLSD", "LIST -a", "LIST"];
4125+
const LIST_COMMANDS_DEFAULT = () => ["LIST -a", "LIST"];
4126+
const LIST_COMMANDS_MLSD = () => ["MLSD", "LIST -a", "LIST"];
41274127
/**
41284128
* High-level API to interact with an FTP server.
41294129
*/
@@ -4134,7 +4134,7 @@ class Client {
41344134
* @param timeout Timeout in milliseconds, use 0 for no timeout. Optional, default is 30 seconds.
41354135
*/
41364136
constructor(timeout = 30000) {
4137-
this.availableListCommands = LIST_COMMANDS_DEFAULT;
4137+
this.availableListCommands = LIST_COMMANDS_DEFAULT();
41384138
this.ftp = new FtpContext_1.FTPContext(timeout);
41394139
this.prepareTransfer = this._enterFirstCompatibleMode([transfer_1.enterPassiveModeIPv6, transfer_1.enterPassiveModeIPv4]);
41404140
this.parseList = parseList_1.parseList;
@@ -4284,10 +4284,10 @@ class Client {
42844284
// Use MLSD directory listing if possible. See https://tools.ietf.org/html/rfc3659#section-7.8:
42854285
// "The presence of the MLST feature indicates that both MLST and MLSD are supported."
42864286
const supportsMLSD = features.has("MLST");
4287-
this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD : LIST_COMMANDS_DEFAULT;
4287+
this.availableListCommands = supportsMLSD ? LIST_COMMANDS_MLSD() : LIST_COMMANDS_DEFAULT();
42884288
await this.send("TYPE I"); // Binary mode
42894289
await this.sendIgnoringError("STRU F"); // Use file structure
4290-
await this.sendIgnoringError("OPTS UTF8 ON"); // Some servers expect UTF-8 to be enabled explicitly
4290+
await this.sendIgnoringError("OPTS UTF8 ON"); // Some servers expect UTF-8 to be enabled explicitly and setting before login might not have worked.
42914291
if (supportsMLSD) {
42924292
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
42934293
}
@@ -4322,6 +4322,9 @@ class Client {
43224322
secureOptions.host = (_b = secureOptions.host) !== null && _b !== void 0 ? _b : options.host;
43234323
await this.useTLS(secureOptions);
43244324
}
4325+
// Set UTF-8 on before login in case there are non-ascii characters in user or password.
4326+
// Note that this might not work before login depending on server.
4327+
await this.sendIgnoringError("OPTS UTF8 ON");
43254328
await this.login(options.user, options.password);
43264329
await this.useDefaultSettings();
43274330
return welcome;
@@ -4419,7 +4422,10 @@ class Client {
44194422
*/
44204423
async remove(path, ignoreErrorCodes = false) {
44214424
const validPath = await this.protectWhitespace(path);
4422-
return this.send(`DELE ${validPath}`, ignoreErrorCodes);
4425+
if (ignoreErrorCodes) {
4426+
return this.sendIgnoringError(`DELE ${validPath}`);
4427+
}
4428+
return this.send(`DELE ${validPath}`);
44234429
}
44244430
/**
44254431
* Report transfer progress for any upload or download to a given handler.
@@ -4628,10 +4634,13 @@ class Client {
46284634
async removeDir(remoteDirPath) {
46294635
return this._exitAtCurrentDirectory(async () => {
46304636
await this.cd(remoteDirPath);
4637+
// Get the absolute path of the target because remoteDirPath might be a relative path, even `../` is possible.
4638+
const absoluteDirPath = await this.pwd();
46314639
await this.clearWorkingDir();
4632-
if (remoteDirPath !== "/") {
4640+
const dirIsRoot = absoluteDirPath === "/";
4641+
if (!dirIsRoot) {
46334642
await this.cdup();
4634-
await this.removeEmptyDir(remoteDirPath);
4643+
await this.removeEmptyDir(absoluteDirPath);
46354644
}
46364645
});
46374646
}
@@ -4878,7 +4887,7 @@ var FileType;
48784887
FileType[FileType["File"] = 1] = "File";
48794888
FileType[FileType["Directory"] = 2] = "Directory";
48804889
FileType[FileType["SymbolicLink"] = 3] = "SymbolicLink";
4881-
})(FileType = exports.FileType || (exports.FileType = {}));
4890+
})(FileType || (exports.FileType = FileType = {}));
48824891
/**
48834892
* Describes a file, directory or symbolic link.
48844893
*/
@@ -4985,6 +4994,9 @@ class FTPError extends Error {
49854994
}
49864995
}
49874996
exports.FTPError = FTPError;
4997+
function doNothing() {
4998+
/** Do nothing */
4999+
}
49885000
/**
49895001
* FTPContext holds the control and data sockets of an FTP connection and provides a
49905002
* simplified way to interact with an FTP server, handle responses, errors and timeouts.
@@ -5037,9 +5049,8 @@ class FTPContext {
50375049
return;
50385050
}
50395051
this._closingError = err;
5040-
this.send("QUIT"); // Don't wait for an answer
50415052
// Close the sockets but don't fully reset this context to preserve `this._closingError`.
5042-
this._closeSocket(this._socket);
5053+
this._closeControlSocket();
50435054
this._closeSocket(this._dataSocket);
50445055
// Give the user's task a chance to react, maybe cleanup resources.
50455056
this._passToHandler(err);
@@ -5080,7 +5091,7 @@ class FTPContext {
50805091
this._removeSocketListeners(this.socket);
50815092
}
50825093
else {
5083-
this._closeSocket(this.socket);
5094+
this._closeControlSocket();
50845095
}
50855096
}
50865097
if (socket) {
@@ -5289,16 +5300,23 @@ class FTPContext {
52895300
});
52905301
}
52915302
/**
5292-
* Close a socket.
5303+
* Close the control socket. Sends QUIT, then FIN, and ignores any response or error.
5304+
*/
5305+
_closeControlSocket() {
5306+
this._removeSocketListeners(this._socket);
5307+
this._socket.on("error", doNothing);
5308+
this.send("QUIT");
5309+
this._closeSocket(this._socket);
5310+
}
5311+
/**
5312+
* Close a socket, ignores any error.
52935313
* @protected
52945314
*/
52955315
_closeSocket(socket) {
52965316
if (socket) {
52975317
this._removeSocketListeners(socket);
5298-
socket.on("error", () => { });
5299-
socket.on("timeout", () => socket.destroy());
5300-
socket.setTimeout(this.timeout);
5301-
socket.end();
5318+
socket.on("error", doNothing);
5319+
socket.destroy();
53025320
}
53035321
}
53045322
/**
@@ -5790,8 +5808,8 @@ function parseSize(value, info) {
57905808
* Parsers for MLSD facts.
57915809
*/
57925810
const factHandlersByName = {
5793-
"size": parseSize,
5794-
"sizd": parseSize,
5811+
"size": parseSize, // File size
5812+
"sizd": parseSize, // Directory size
57955813
"unique": (value, info) => {
57965814
info.uniqueID = value;
57975815
},

migration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Most features have been carried forward and improved upon. However, some feature
2525
### How to upgrade
2626

2727
1. Remove `with: fetch-depth: 2`. It is no longer needed and removing it will _slightly_ speed up deployments.
28-
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).
28+
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).
2929
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.
3030
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.
3131
5. Update your arguments to reflect the following changes:

package-lock.json

+22-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ftp-deploy-action",
3-
"version": "4.3.4",
3+
"version": "4.3.5",
44
"private": true,
55
"description": "Automate deploying websites and more with this GitHub action",
66
"main": "dist/index.js",
@@ -23,14 +23,14 @@
2323
"license": "MIT",
2424
"dependencies": {
2525
"@actions/core": "^1.9.1",
26-
"@samkirkland/ftp-deploy": "^1.2.3",
26+
"@samkirkland/ftp-deploy": "^1.2.4",
2727
"@types/jest": "^29.4.1",
2828
"jest": "^29.5.0",
2929
"ts-jest": "^29.0.5",
3030
"ts-node-dev": "^2.0.0"
3131
},
3232
"devDependencies": {
33-
"@types/node": "^14.0.27",
33+
"@types/node": "^20.11.24",
3434
"@typescript-eslint/eslint-plugin": "^5.33.1",
3535
"@typescript-eslint/parser": "^5.33.1",
3636
"@vercel/ncc": "^0.34.0",

0 commit comments

Comments
 (0)