Skip to content

Commit f0ef801

Browse files
committed
local-dir path, excludes param logging
1 parent 649aa38 commit f0ef801

File tree

6 files changed

+40
-47
lines changed

6 files changed

+40
-47
lines changed

.github/workflows/ftp.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ name: FTP Test
33
on:
44
push:
55
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
86

97
jobs:
108
deploy:
119
name: 🚀 Deploy website every commit
1210
runs-on: ubuntu-latest
1311
steps:
1412
- name: 🚚 Get latest code
15-
uses: actions/checkout@v2
13+
uses: actions/checkout@v2.3.2
1614

1715
- name: 📂 Sync files
1816
uses: ./

.github/workflows/ftps.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ name: FTPS Test
33
on:
44
push:
55
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
86

97
jobs:
108
deploy:
119
name: 🚀 Deploy website every commit
1210
runs-on: ubuntu-latest
1311
steps:
1412
- name: 🚚 Get latest code
15-
uses: actions/checkout@v2
13+
uses: actions/checkout@v2.3.2
1614

1715
- name: 📂 Sync files
1816
uses: ./
@@ -21,4 +19,4 @@ jobs:
2119
2220
password: ${{ secrets.ftp_password }}
2321
protocol: ftps
24-
secure: strict
22+
security: strict

dist/index.js

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,12 +1739,11 @@ exports.HashDiff = HashDiff;
17391739
Object.defineProperty(exports, "__esModule", ({ value: true }));
17401740
exports.prettyError = void 0;
17411741
const types_1 = __webpack_require__(6703);
1742-
function outputOriginalErrorAndExit(logger, error) {
1742+
function logOriginalError(logger, error) {
17431743
logger.all();
17441744
logger.all(`----------------------------------------------------------------`);
17451745
logger.all(`---------------------- Full Error below ----------------------`);
17461746
logger.all(error);
1747-
process.exit();
17481747
}
17491748
/**
17501749
* Converts a exception to helpful debug info
@@ -1755,41 +1754,36 @@ function prettyError(logger, args, error) {
17551754
logger.all(`----------------------------------------------------------------`);
17561755
logger.all(`--------------- 🔥🔥🔥 A error occurred 🔥🔥🔥 --------------`);
17571756
logger.all(`----------------------------------------------------------------`);
1757+
const ftpError = error;
17581758
if (typeof error.code === "string") {
17591759
const errorCode = error.code;
17601760
if (errorCode === "ENOTFOUND") {
17611761
logger.all(`The server "${args.server}" doesn't seem to exist. Do you have a typo?`);
1762-
outputOriginalErrorAndExit(logger, error);
17631762
}
17641763
}
1765-
if (typeof error.name === "string") {
1764+
else if (typeof error.name === "string") {
17661765
const errorName = error.name;
17671766
if (errorName.includes("ERR_TLS_CERT_ALTNAME_INVALID")) {
17681767
logger.all(`The certificate for "${args.server}" is likely shared. The host did not place your server on the list of valid domains for this cert.`);
17691768
logger.all(`This is a common issue with shared hosts. You have a few options:`);
17701769
logger.all(` - Ignore this error by setting security back to loose`);
17711770
logger.all(` - Contact your hosting provider and ask them for your servers hostname`);
1772-
outputOriginalErrorAndExit(logger, error);
17731771
}
17741772
}
1775-
const ftpError = error;
1776-
if (typeof ftpError.code === "number") {
1773+
else if (typeof ftpError.code === "number") {
17771774
if (ftpError.code === types_1.ErrorCode.NotLoggedIn) {
17781775
const serverRequiresFTPS = ftpError.message.toLowerCase().includes("must use encryption");
17791776
if (serverRequiresFTPS) {
17801777
logger.all(`The server you are connecting to requires encryption (ftps)`);
17811778
logger.all(`Enable FTPS by using the protocol option.`);
1782-
outputOriginalErrorAndExit(logger, error);
17831779
}
17841780
else {
17851781
logger.all(`Could not login with the username "${args.username}" and password "${args.password}".`);
17861782
logger.all(`Make sure you can login with those credentials. If you have a space or a quote in your username or password be sure to escape them!`);
1787-
outputOriginalErrorAndExit(logger, error);
17881783
}
17891784
}
17901785
}
1791-
// unknown error :(
1792-
outputOriginalErrorAndExit(logger, error);
1786+
logOriginalError(logger, error);
17931787
}
17941788
exports.prettyError = prettyError;
17951789

@@ -1833,7 +1827,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18331827
return (mod && mod.__esModule) ? mod : { "default": mod };
18341828
};
18351829
Object.defineProperty(exports, "__esModule", ({ value: true }));
1836-
exports.deploy = exports.excludeDefaults = void 0;
1830+
exports.deploy = exports.getLocalFiles = exports.excludeDefaults = void 0;
18371831
const ftp = __importStar(__webpack_require__(7957));
18381832
const readdir_enhanced_1 = __importDefault(__webpack_require__(8811));
18391833
const crypto_1 = __importDefault(__webpack_require__(6417));
@@ -1902,7 +1896,7 @@ function getLocalFiles(args) {
19021896
type: "file",
19031897
name: stat.path,
19041898
size: stat.size,
1905-
hash: yield fileHash(stat.path, "sha256")
1899+
hash: yield fileHash(args["local-dir"] + stat.path, "sha256")
19061900
});
19071901
continue;
19081902
}
@@ -1912,12 +1906,13 @@ function getLocalFiles(args) {
19121906
}
19131907
return {
19141908
description: types_1.syncFileDescription,
1915-
version: types_1.currentVersion,
1909+
version: types_1.currentSyncFileVersion,
19161910
generatedTime: new Date().getTime(),
19171911
data: records
19181912
};
19191913
});
19201914
}
1915+
exports.getLocalFiles = getLocalFiles;
19211916
function downloadFileList(client, logger, path) {
19221917
return __awaiter(this, void 0, void 0, function* () {
19231918
// note: originally this was using a writable stream instead of a buffer file
@@ -2116,7 +2111,7 @@ function getServerFiles(client, logger, timings, args) {
21162111
// set the server state to nothing, because we don't know what the server state is
21172112
return {
21182113
description: types_1.syncFileDescription,
2119-
version: types_1.currentVersion,
2114+
version: types_1.currentSyncFileVersion,
21202115
generatedTime: new Date().getTime(),
21212116
data: [],
21222117
};
@@ -2194,7 +2189,7 @@ function deploy(deployArgs) {
21942189
// header
21952190
// todo allow swapping out library/version text based on if we are using action
21962191
logger.all(`----------------------------------------------------------------`);
2197-
logger.all(`🚀 Thanks for using ftp-deploy version ${types_1.currentVersion}. Let's deploy some stuff! `);
2192+
logger.all(`🚀 Thanks for using ftp-deploy version ${types_1.currentSyncFileVersion}. Let's deploy some stuff! `);
21982193
logger.all(`----------------------------------------------------------------`);
21992194
logger.all(`If you found this project helpful, please support it`);
22002195
logger.all(`by giving it a ⭐ on Github --> https://github.com/SamKirkland/FTP-Deploy-Action`);
@@ -2216,8 +2211,10 @@ function deploy(deployArgs) {
22162211
yield global.reconnect();
22172212
try {
22182213
const serverFiles = yield getServerFiles(client, logger, timings, args);
2214+
timings.start("logging");
22192215
const diffTool = new HashDiff_1.HashDiff();
22202216
const diffs = diffTool.getDiffs(localFiles, serverFiles, logger);
2217+
timings.stop("logging");
22212218
totalBytesUploaded = diffs.sizeUpload + diffs.sizeReplace;
22222219
timings.start("upload");
22232220
try {
@@ -2226,11 +2223,9 @@ function deploy(deployArgs) {
22262223
catch (e) {
22272224
if (e.code === types_1.ErrorCode.FileNameNotAllowed) {
22282225
logger.all("Error 553 FileNameNotAllowed, you don't have access to upload that file");
2229-
logger.all(e);
2230-
process.exit();
22312226
}
22322227
logger.all(e);
2233-
process.exit();
2228+
throw e;
22342229
}
22352230
finally {
22362231
timings.stop("upload");
@@ -2246,6 +2241,7 @@ function deploy(deployArgs) {
22462241
}
22472242
catch (error) {
22482243
errorHandling_1.prettyError(logger, args, error);
2244+
throw error;
22492245
}
22502246
finally {
22512247
client.close();
@@ -2258,6 +2254,7 @@ function deploy(deployArgs) {
22582254
logger.all(`Time spent connecting to server: ${timings.getTimeFormatted("connecting")}`);
22592255
logger.all(`Time spent deploying: ${timings.getTimeFormatted("upload")} (${uploadSpeed}/second)`);
22602256
logger.all(` - changing dirs: ${timings.getTimeFormatted("changingDir")}`);
2257+
logger.all(` - logging: ${timings.getTimeFormatted("logging")}`);
22612258
logger.all(`----------------------------------------------------------------`);
22622259
logger.all(`Total time: ${timings.getTimeFormatted("total")}`);
22632260
logger.all(`----------------------------------------------------------------`);
@@ -2274,8 +2271,8 @@ exports.deploy = deploy;
22742271
"use strict";
22752272

22762273
Object.defineProperty(exports, "__esModule", ({ value: true }));
2277-
exports.ErrorCode = exports.syncFileDescription = exports.currentVersion = void 0;
2278-
exports.currentVersion = "1.0.0";
2274+
exports.ErrorCode = exports.syncFileDescription = exports.currentSyncFileVersion = void 0;
2275+
exports.currentSyncFileVersion = "1.0.0";
22792276
exports.syncFileDescription = "DO NOT DELETE THIS FILE. This file is used to keep track of which files have been synced in the most recent deployment. If you delete this file a resync will need to be done (which can take a while) - read more: https://github.com/SamKirkland/FTP-Deploy-Action";
22802277
var ErrorCode;
22812278
(function (ErrorCode) {
@@ -3303,12 +3300,8 @@ class Client {
33033300
return res;
33043301
}
33053302
catch (err) {
3306-
// Receiving an FTPError means that the last transfer strategy failed and we should
3307-
// try the next one. Any other exception should stop the evaluation of strategies because
3308-
// something else went wrong.
3309-
if (!(err instanceof FtpContext_1.FTPError)) {
3310-
throw err;
3311-
}
3303+
// Try the next candidate no matter the exact error. It's possible that a server
3304+
// answered incorrectly to a strategy, for example a PASV answer to an EPSV.
33123305
}
33133306
}
33143307
throw new Error("None of the available transfer strategies work.");
@@ -3970,9 +3963,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
39703963
o[k2] = m[k];
39713964
}));
39723965
var __exportStar = (this && this.__exportStar) || function(m, exports) {
3973-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
3966+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
39743967
};
39753968
Object.defineProperty(exports, "__esModule", ({ value: true }));
3969+
exports.enterPassiveModeIPv6 = exports.enterPassiveModeIPv4 = void 0;
39763970
/**
39773971
* Public API
39783972
*/
@@ -4131,7 +4125,7 @@ function positiveIntermediate(code) {
41314125
}
41324126
exports.positiveIntermediate = positiveIntermediate;
41334127
function isNotBlank(str) {
4134-
return str !== "";
4128+
return str.trim() !== "";
41354129
}
41364130

41374131

@@ -4157,7 +4151,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
41574151
var __importStar = (this && this.__importStar) || function (mod) {
41584152
if (mod && mod.__esModule) return mod;
41594153
var result = {};
4160-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4154+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
41614155
__setModuleDefault(result, mod);
41624156
return result;
41634157
};
@@ -6655,11 +6649,12 @@ function optionalInt(argumentName, rawValue) {
66556649
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
66566650
}
66576651
function optionalStringArray(argumentName, rawValue) {
6652+
console.log(rawValue);
66586653
if (rawValue.length === 0) {
66596654
return undefined;
66606655
}
66616656
// split value by space and comma
6662-
return rawValue.split(", ");
6657+
return rawValue.split("\n").filter(str => str !== "");
66636658
}
66646659

66656660

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"license": "MIT",
2323
"dependencies": {
2424
"@actions/core": "^1.2.6",
25-
"@samkirkland/ftp-deploy": "^1.0.0",
25+
"@samkirkland/ftp-deploy": "^1.0.1",
2626
"ts-node-dev": "^1.0.0-pre.62"
2727
},
2828
"devDependencies": {

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ function optionalInt(argumentName: string, rawValue: string): number | undefined
129129
}
130130

131131
function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined {
132+
console.log(rawValue);
133+
132134
if (rawValue.length === 0) {
133135
return undefined;
134136
}
135137

136138
// split value by space and comma
137-
return rawValue.split(", ");
139+
return rawValue.split("\n").filter(str => str !== "");
138140
}

0 commit comments

Comments
 (0)