From eb1f39d2fdd89d4a12f4c2592f714b485c3e7aa7 Mon Sep 17 00:00:00 2001 From: Sinan Samet Date: Thu, 15 Dec 2022 14:40:02 +0100 Subject: [PATCH] Add track state option --- dist/index.js | 34 +++++++++++++++++++++------------- src/main.ts | 1 + 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0528622..4201943 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3191,9 +3191,13 @@ function downloadFileList(client, logger, path) { }); } function createLocalState(localFiles, logger, args) { - logger.verbose(`Creating local state at ${args["local-dir"]}${args["state-name"]}`); - fs_1.default.writeFileSync(`${args["local-dir"]}${args["state-name"]}`, JSON.stringify(localFiles, undefined, 4), { encoding: "utf8" }); - logger.verbose("Local state created"); + if (args["track-state"]) { + logger.verbose(`Creating local state at ${args["local-dir"]}${args["state-name"]}`); + fs_1.default.writeFileSync(`${args["local-dir"]}${args["state-name"]}`, JSON.stringify(localFiles, undefined, 4), { encoding: "utf8" }); + logger.verbose("Local state created"); + } else { + logger.verbose(`Not creating a local state because tracking is disabled`); + } } function connect(client, args, logger) { return __awaiter(this, void 0, void 0, function* () { @@ -3242,15 +3246,17 @@ function getServerFiles(client, logger, timings, args) { logger.all("Clear complete"); throw new Error("dangerous-clean-slate was run"); } - const serverFiles = yield downloadFileList(client, logger, args["state-name"]); - logger.all(`----------------------------------------------------------------`); - logger.all(`Last published on 📅 ${new Date(serverFiles.generatedTime).toLocaleDateString(undefined, { weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric" })}`); - // apply exclude options to server - if (args.exclude.length > 0) { - const filteredData = serverFiles.data.filter((item) => (0, utilities_1.applyExcludeFilter)({ path: item.name, isDirectory: () => item.type === "folder" }, args.exclude)); - serverFiles.data = filteredData; + if (args['track-state']) { + const serverFiles = yield downloadFileList(client, logger, args["state-name"]); + logger.all(`----------------------------------------------------------------`); + logger.all(`Last published on 📅 ${new Date(serverFiles.generatedTime).toLocaleDateString(undefined, { weekday: "long", year: "numeric", month: "long", day: "numeric", hour: "numeric", minute: "numeric" })}`); + // apply exclude options to server + if (args.exclude.length > 0) { + const filteredData = serverFiles.data.filter((item) => (0, utilities_1.applyExcludeFilter)({ path: item.name, isDirectory: () => item.type === "folder" }, args.exclude)); + serverFiles.data = filteredData; + } + return serverFiles; } - return serverFiles; } catch (error) { logger.all(`----------------------------------------------------------------`); @@ -3946,6 +3952,7 @@ function getDefaultSettings(withoutDefaults) { "log-level": (_j = withoutDefaults["log-level"]) !== null && _j !== void 0 ? _j : "standard", "security": (_k = withoutDefaults.security) !== null && _k !== void 0 ? _k : "loose", "timeout": (_l = withoutDefaults.timeout) !== null && _l !== void 0 ? _l : 30000, + "track-state": (_m = withoutDefaults["track-state"]) !== null && _m !== void 0 ? _m : true, }; } exports.getDefaultSettings = getDefaultSettings; @@ -9037,7 +9044,8 @@ async function runDeployment() { "dangerous-clean-slate": (0, parse_1.optionalBoolean)("dangerous-clean-slate", core.getInput("dangerous-clean-slate")), "exclude": (0, parse_1.optionalStringArray)("exclude", core.getMultilineInput("exclude")), "log-level": (0, parse_1.optionalLogLevel)("log-level", core.getInput("log-level")), - "security": (0, parse_1.optionalSecurity)("security", core.getInput("security")) + "security": (0, parse_1.optionalSecurity)("security", core.getInput("security")), + "track-state": (0, parse_1.optionalString)(core.getInput("track-state")), }; await (0, ftp_deploy_1.deploy)(args); } @@ -9293,4 +9301,4 @@ module.exports = require("util"); /******/ module.exports = __webpack_exports__; /******/ /******/ })() -; \ No newline at end of file +; diff --git a/src/main.ts b/src/main.ts index b3b58a5..6cef690 100644 --- a/src/main.ts +++ b/src/main.ts @@ -14,6 +14,7 @@ async function runDeployment() { "local-dir": optionalString(core.getInput("local-dir")), "server-dir": optionalString(core.getInput("server-dir")), "state-name": optionalString(core.getInput("state-name")), + "track-state": optionalString(core.getInput("track-state")), "dry-run": optionalBoolean("dry-run", core.getInput("dry-run")), "dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")), "exclude": optionalStringArray("exclude", core.getMultilineInput("exclude")),