build: update dist files

This commit is contained in:
Emmanuel Lampe 2023-08-07 09:02:22 +02:00
parent 3e10fb64bf
commit dd31710189
No known key found for this signature in database
GPG key ID: 2E080FC227CB0AE7
2 changed files with 26 additions and 3 deletions

27
dist/index.js vendored
View file

@ -9405,8 +9405,8 @@ async function main() {
const settings = await getSettings();
configureAxios(settings.panelHost, settings.apiKey, settings.proxy);
const { serverIds, sourceListPath, targetPath, restart, targets } =
settings;
const { serverIds, sourceListPath, targetPath, restart, targets, decompressTarget } =
settings;
for (const serverId of serverIds) {
for (const source of sourceListPath) {
@ -9415,7 +9415,12 @@ async function main() {
const buffer = await fs.readFile(source);
await uploadFile(serverId, targetFile, buffer);
if (decompressTarget && isArchiveFile(targetFile)) {
await decompressFile(serverId, targetFile);
}
}
for (const element of targets) {
const { source, target } = element;
await validateSourceFile(source);
@ -9423,6 +9428,10 @@ async function main() {
const buffer = await fs.readFile(source);
await uploadFile(serverId, targetFile, buffer);
if (decompressTarget && isArchiveFile(targetFile)) {
await decompressFile(serverId, targetFile);
}
}
if (restart) await restartServer(serverId);
@ -9439,6 +9448,7 @@ async function getSettings() {
const apiKey = getInput("api-key", { required: true });
const restart = getInput("restart") == "true";
const proxy = getInput("proxy");
const decompressTarget = getInput("decompress-target") == "true";
let sourcePath = getInput("source");
let sourceListPath = getMultilineInput("sources");
@ -9501,6 +9511,7 @@ async function getSettings() {
targetPath,
serverIds,
targets,
decompressTarget,
};
}
@ -9532,6 +9543,11 @@ async function validateSourceFile(source) {
}
}
function isArchiveFile(fileName) {
const ext = path.extname(fileName).toLowerCase();
return ['.zip', '.tar', '.tar.gz', '.tgz', '.rar'].includes(ext);
}
function getTargetFile(targetPath, source) {
return targetPath.endsWith("/")
? path.join(targetPath, path.basename(source))
@ -9558,6 +9574,13 @@ async function restartServer(serverId) {
});
}
async function decompressFile(serverId, targetFile) {
await axios.post(`/api/client/servers/${serverId}/files/decompress`, {
root: "/",
file: targetFile,
});
}
function getInput(name, options = { required: false }) {
return core.getInput(name, { ...options, trimWhitespace: true });
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long