Add track state option

This commit is contained in:
Sinan Samet 2022-12-15 14:40:02 +01:00
parent cfcb39fa3c
commit eb1f39d2fd
2 changed files with 22 additions and 13 deletions

34
dist/index.js vendored
View File

@ -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__;
/******/
/******/ })()
;
;

View File

@ -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")),