feat: add script dry-run functionality and enhance script management

- Introduced a new dry-run endpoint for executing scripts without saving changes.
- Implemented a dedicated ScriptDryRunPage for user interaction with dry-run functionality.
- Enhanced ScriptsPage to support navigation to the dry-run feature.
- Added LogViewer component for displaying logs during script execution.
- Created ScriptEditPage for editing scripts with integrated dry-run capabilities.
- Updated workflows to include new scripts for fetching and notifying data.
- Improved overall user experience with better navigation and error handling.
This commit is contained in:
2026-08-14 15:37:30 +07:00
parent 389f94f950
commit 8519c92ed1
17 changed files with 810 additions and 176 deletions
+60 -14
View File
@@ -1,20 +1,66 @@
function ntfyHeaders(ctx) {
const headers = {};
if (ctx.data?.title) {
log.info("ntfy: setting title %s", ctx.data.title);
headers.Title = ctx.data.title;
}
return headers;
}
export default async function ntfy(ctx) {
log.info({ ctx }, "ntfy incoming context");
const headers = {}
if(ctx.data?.title) {
log.info("ntfy: setting title %s", ctx.data.title);
headers.Title = ctx.data.title
const file = ctx.data?.file;
const hasFile = Buffer.isBuffer(file) || file instanceof Uint8Array;
log.info(
{
title: ctx.data?.title,
message: ctx.data?.message,
filename: ctx.data?.filename,
hasFile,
fileLength: hasFile ? file.length : 0,
attach: ctx.data?.attach,
},
"ntfy incoming context",
);
const headers = ntfyHeaders(ctx);
const ntfyUrl = ctx.config?.url || "https://ntfy.sh/scrunner";
if (hasFile) {
const filename = ctx.data?.filename || "attachment";
headers.Filename = filename;
if (ctx.data?.message) {
headers.Message = ctx.data.message;
}
if (ctx.data?.contentType) {
headers["Content-Type"] = ctx.data.contentType;
}
const ntfyUrl = ctx.config?.url || "https://ntfy.sh/scrunner";
log.info(
{ ntfyUrl, filename, length: file.length },
"ntfy uploading file",
);
await $axios.put(ntfyUrl, file, {
headers,
maxBodyLength: Infinity,
maxContentLength: Infinity,
});
return { sent: "true" };
}
log.info("ntfy sending message to %s", ntfyUrl);
const truncatedMessage = ctx.data?.message?.substring(0, 100);
log.info("ntfy messsage: %s", truncatedMessage);
if (ctx.data?.attach) {
log.info("ntfy: setting attach %s", ctx.data.attach);
headers.Attach = ctx.data.attach;
}
await $axios.post(ntfyUrl, ctx.data?.message || "Hello from scrunner", {
headers: headers
})
return {sent: "true"}
const truncatedMessage = ctx.data?.message?.substring(0, 100);
log.info("ntfy sending message to %s", ntfyUrl);
log.info("ntfy messsage: %s", truncatedMessage);
await $axios.post(ntfyUrl, ctx.data?.message || "Hello from scrunner", {
headers,
});
return { sent: "true" };
}