diff --git a/.github/workflows/ftp.yml b/.github/workflows/ftp.yml index aed29bc..de8743a 100644 --- a/.github/workflows/ftp.yml +++ b/.github/workflows/ftp.yml @@ -3,8 +3,6 @@ name: FTP Test on: push: branches: [ master ] - pull_request: - branches: [ master ] jobs: deploy: @@ -12,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: 🚚 Get latest code - uses: actions/checkout@v2 + uses: actions/checkout@v2.3.2 - name: 📂 Sync files uses: ./ diff --git a/.github/workflows/ftps.yml b/.github/workflows/ftps.yml index eba473f..8c59ffe 100644 --- a/.github/workflows/ftps.yml +++ b/.github/workflows/ftps.yml @@ -3,8 +3,6 @@ name: FTPS Test on: push: branches: [ master ] - pull_request: - branches: [ master ] jobs: deploy: @@ -12,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: 🚚 Get latest code - uses: actions/checkout@v2 + uses: actions/checkout@v2.3.2 - name: 📂 Sync files uses: ./ @@ -21,4 +19,4 @@ jobs: username: test@samkirkland.com password: ${{ secrets.ftp_password }} protocol: ftps - secure: strict + security: strict diff --git a/dist/index.js b/dist/index.js index 938d875..329860d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1739,12 +1739,11 @@ exports.HashDiff = HashDiff; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prettyError = void 0; const types_1 = __webpack_require__(6703); -function outputOriginalErrorAndExit(logger, error) { +function logOriginalError(logger, error) { logger.all(); logger.all(`----------------------------------------------------------------`); logger.all(`---------------------- Full Error below ----------------------`); logger.all(error); - process.exit(); } /** * Converts a exception to helpful debug info @@ -1755,41 +1754,36 @@ function prettyError(logger, args, error) { logger.all(`----------------------------------------------------------------`); logger.all(`--------------- 🔥🔥🔥 A error occurred 🔥🔥🔥 --------------`); logger.all(`----------------------------------------------------------------`); + const ftpError = error; if (typeof error.code === "string") { const errorCode = error.code; if (errorCode === "ENOTFOUND") { logger.all(`The server "${args.server}" doesn't seem to exist. Do you have a typo?`); - outputOriginalErrorAndExit(logger, error); } } - if (typeof error.name === "string") { + else if (typeof error.name === "string") { const errorName = error.name; if (errorName.includes("ERR_TLS_CERT_ALTNAME_INVALID")) { 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.`); logger.all(`This is a common issue with shared hosts. You have a few options:`); logger.all(` - Ignore this error by setting security back to loose`); logger.all(` - Contact your hosting provider and ask them for your servers hostname`); - outputOriginalErrorAndExit(logger, error); } } - const ftpError = error; - if (typeof ftpError.code === "number") { + else if (typeof ftpError.code === "number") { if (ftpError.code === types_1.ErrorCode.NotLoggedIn) { const serverRequiresFTPS = ftpError.message.toLowerCase().includes("must use encryption"); if (serverRequiresFTPS) { logger.all(`The server you are connecting to requires encryption (ftps)`); logger.all(`Enable FTPS by using the protocol option.`); - outputOriginalErrorAndExit(logger, error); } else { logger.all(`Could not login with the username "${args.username}" and password "${args.password}".`); 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!`); - outputOriginalErrorAndExit(logger, error); } } } - // unknown error :( - outputOriginalErrorAndExit(logger, error); + logOriginalError(logger, error); } exports.prettyError = prettyError; @@ -1833,7 +1827,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deploy = exports.excludeDefaults = void 0; +exports.deploy = exports.getLocalFiles = exports.excludeDefaults = void 0; const ftp = __importStar(__webpack_require__(7957)); const readdir_enhanced_1 = __importDefault(__webpack_require__(8811)); const crypto_1 = __importDefault(__webpack_require__(6417)); @@ -1902,7 +1896,7 @@ function getLocalFiles(args) { type: "file", name: stat.path, size: stat.size, - hash: yield fileHash(stat.path, "sha256") + hash: yield fileHash(args["local-dir"] + stat.path, "sha256") }); continue; } @@ -1912,12 +1906,13 @@ function getLocalFiles(args) { } return { description: types_1.syncFileDescription, - version: types_1.currentVersion, + version: types_1.currentSyncFileVersion, generatedTime: new Date().getTime(), data: records }; }); } +exports.getLocalFiles = getLocalFiles; function downloadFileList(client, logger, path) { return __awaiter(this, void 0, void 0, function* () { // note: originally this was using a writable stream instead of a buffer file @@ -2116,7 +2111,7 @@ function getServerFiles(client, logger, timings, args) { // set the server state to nothing, because we don't know what the server state is return { description: types_1.syncFileDescription, - version: types_1.currentVersion, + version: types_1.currentSyncFileVersion, generatedTime: new Date().getTime(), data: [], }; @@ -2194,7 +2189,7 @@ function deploy(deployArgs) { // header // todo allow swapping out library/version text based on if we are using action logger.all(`----------------------------------------------------------------`); - logger.all(`🚀 Thanks for using ftp-deploy version ${types_1.currentVersion}. Let's deploy some stuff! `); + logger.all(`🚀 Thanks for using ftp-deploy version ${types_1.currentSyncFileVersion}. Let's deploy some stuff! `); logger.all(`----------------------------------------------------------------`); logger.all(`If you found this project helpful, please support it`); logger.all(`by giving it a ⭐ on Github --> https://github.com/SamKirkland/FTP-Deploy-Action`); @@ -2216,8 +2211,10 @@ function deploy(deployArgs) { yield global.reconnect(); try { const serverFiles = yield getServerFiles(client, logger, timings, args); + timings.start("logging"); const diffTool = new HashDiff_1.HashDiff(); const diffs = diffTool.getDiffs(localFiles, serverFiles, logger); + timings.stop("logging"); totalBytesUploaded = diffs.sizeUpload + diffs.sizeReplace; timings.start("upload"); try { @@ -2226,11 +2223,9 @@ function deploy(deployArgs) { catch (e) { if (e.code === types_1.ErrorCode.FileNameNotAllowed) { logger.all("Error 553 FileNameNotAllowed, you don't have access to upload that file"); - logger.all(e); - process.exit(); } logger.all(e); - process.exit(); + throw e; } finally { timings.stop("upload"); @@ -2246,6 +2241,7 @@ function deploy(deployArgs) { } catch (error) { errorHandling_1.prettyError(logger, args, error); + throw error; } finally { client.close(); @@ -2258,6 +2254,7 @@ function deploy(deployArgs) { logger.all(`Time spent connecting to server: ${timings.getTimeFormatted("connecting")}`); logger.all(`Time spent deploying: ${timings.getTimeFormatted("upload")} (${uploadSpeed}/second)`); logger.all(` - changing dirs: ${timings.getTimeFormatted("changingDir")}`); + logger.all(` - logging: ${timings.getTimeFormatted("logging")}`); logger.all(`----------------------------------------------------------------`); logger.all(`Total time: ${timings.getTimeFormatted("total")}`); logger.all(`----------------------------------------------------------------`); @@ -2274,8 +2271,8 @@ exports.deploy = deploy; "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ErrorCode = exports.syncFileDescription = exports.currentVersion = void 0; -exports.currentVersion = "1.0.0"; +exports.ErrorCode = exports.syncFileDescription = exports.currentSyncFileVersion = void 0; +exports.currentSyncFileVersion = "1.0.0"; 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"; var ErrorCode; (function (ErrorCode) { @@ -3303,12 +3300,8 @@ class Client { return res; } catch (err) { - // Receiving an FTPError means that the last transfer strategy failed and we should - // try the next one. Any other exception should stop the evaluation of strategies because - // something else went wrong. - if (!(err instanceof FtpContext_1.FTPError)) { - throw err; - } + // Try the next candidate no matter the exact error. It's possible that a server + // answered incorrectly to a strategy, for example a PASV answer to an EPSV. } } throw new Error("None of the available transfer strategies work."); @@ -3970,9 +3963,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.enterPassiveModeIPv6 = exports.enterPassiveModeIPv4 = void 0; /** * Public API */ @@ -4131,7 +4125,7 @@ function positiveIntermediate(code) { } exports.positiveIntermediate = positiveIntermediate; function isNotBlank(str) { - return str !== ""; + return str.trim() !== ""; } @@ -4157,7 +4151,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -6655,11 +6649,12 @@ function optionalInt(argumentName, rawValue) { core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`); } function optionalStringArray(argumentName, rawValue) { + console.log(rawValue); if (rawValue.length === 0) { return undefined; } // split value by space and comma - return rawValue.split(", "); + return rawValue.split("\n").filter(str => str !== ""); } diff --git a/package-lock.json b/package-lock.json index e5479d4..f895e0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ftp-deploy-action", - "version": "1.0.1", + "version": "4.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -147,9 +147,9 @@ } }, "@samkirkland/ftp-deploy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-1.0.0.tgz", - "integrity": "sha512-K1Iu2FJZuPH30v9EUmXQjS/8nTtFUTWURKv4SN4F6jSViyoUrf+ZtlzLZaUQU4/WMC80qdtEKCAvV3DTHSCfBA==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-1.0.1.tgz", + "integrity": "sha512-axyX1OLDulqh7/NW/yrcu/BQCGGgY/lt8AI7cHotR8ebq1awYHkf3aV0sEc11Blb2ZtezyKmd8SMIEVN4UGLQg==", "requires": { "basic-ftp": "^4.6.2", "lodash": "^4.17.20", @@ -345,9 +345,9 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, "basic-ftp": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-4.6.2.tgz", - "integrity": "sha512-UO1L54c/ThZkW9ygaN3NJ4igA6BLoATUpaYARrmH4EXV86WNsk1BS2plFeePx3/vMaoLf1cLWI67uuMayZagDw==" + "version": "4.6.3", + "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-4.6.3.tgz", + "integrity": "sha512-u/zMus8UacMmsxko3szgmuMYaf7pvYV/k/rMJb1I9RCByURWaVP7/jii/8cvPWF3Co7qqBgwRMhyI5vg727OhA==" }, "binary-extensions": { "version": "2.1.0", diff --git a/package.json b/package.json index 69791ef..154fb94 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", - "@samkirkland/ftp-deploy": "^1.0.0", + "@samkirkland/ftp-deploy": "^1.0.1", "ts-node-dev": "^1.0.0-pre.62" }, "devDependencies": { diff --git a/src/main.ts b/src/main.ts index f07fc6c..dbf5d7c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -129,10 +129,12 @@ function optionalInt(argumentName: string, rawValue: string): number | undefined } function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined { + console.log(rawValue); + if (rawValue.length === 0) { return undefined; } // split value by space and comma - return rawValue.split(", "); + return rawValue.split("\n").filter(str => str !== ""); }