mirror of
https://github.com/fccview/cronmaster.git
synced 2026-02-20 07:44:19 -05:00
Compare commits
2 Commits
1.4.0
...
bugfix/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
968fbae13c | ||
|
|
c739d29141 |
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
@@ -2,7 +2,7 @@ name: Docker
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main", "legacy", "feature/*", "bugfix/*"]
|
branches: ["main", "legacy", "feature/*"]
|
||||||
tags: ["*"]
|
tags: ["*"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { join } from "path";
|
|||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import { exec } from "child_process";
|
import { exec } from "child_process";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
import { SCRIPTS_DIR } from "@/app/_utils/scripts";
|
import { SCRIPTS_DIR, normalizeLineEndings } from "@/app/_utils/scripts";
|
||||||
import { loadAllScripts, type Script } from "@/app/_utils/scriptScanner";
|
import { loadAllScripts, type Script } from "@/app/_utils/scriptScanner";
|
||||||
|
|
||||||
const execAsync = promisify(exec);
|
const execAsync = promisify(exec);
|
||||||
@@ -62,7 +62,9 @@ const saveScriptFile = async (filename: string, content: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteScriptFile = async (filename: string) => {
|
const deleteScriptFile = async (filename: string) => {
|
||||||
const scriptPath = join(await SCRIPTS_DIR(), filename);
|
const isDocker = process.env.DOCKER === "true";
|
||||||
|
const scriptsDir = isDocker ? "/app/scripts" : await SCRIPTS_DIR();
|
||||||
|
const scriptPath = join(scriptsDir, filename);
|
||||||
if (existsSync(scriptPath)) {
|
if (existsSync(scriptPath)) {
|
||||||
await unlink(scriptPath);
|
await unlink(scriptPath);
|
||||||
}
|
}
|
||||||
@@ -95,7 +97,8 @@ export const createScript = async (
|
|||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const fullContent = metadataHeader + content;
|
const normalizedContent = normalizeLineEndings(content);
|
||||||
|
const fullContent = metadataHeader + normalizedContent;
|
||||||
|
|
||||||
await saveScriptFile(filename, fullContent);
|
await saveScriptFile(filename, fullContent);
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
@@ -145,7 +148,8 @@ export const updateScript = async (
|
|||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const fullContent = metadataHeader + content;
|
const normalizedContent = normalizeLineEndings(content);
|
||||||
|
const fullContent = metadataHeader + normalizedContent;
|
||||||
|
|
||||||
await saveScriptFile(existingScript.filename, fullContent);
|
await saveScriptFile(existingScript.filename, fullContent);
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
@@ -203,7 +207,8 @@ export const cloneScript = async (
|
|||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const fullContent = metadataHeader + originalContent;
|
const normalizedContent = normalizeLineEndings(originalContent);
|
||||||
|
const fullContent = metadataHeader + normalizedContent;
|
||||||
|
|
||||||
await saveScriptFile(filename, fullContent);
|
await saveScriptFile(filename, fullContent);
|
||||||
revalidatePath("/");
|
revalidatePath("/");
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ export const getHostScriptPath = async (filename: string): Promise<string> => {
|
|||||||
return `bash ${join(hostScriptsDir, filename)}`;
|
return `bash ${join(hostScriptsDir, filename)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const normalizeLineEndings = (content: string): string => {
|
||||||
|
return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||||
|
};
|
||||||
|
|
||||||
export { SCRIPTS_DIR };
|
export { SCRIPTS_DIR };
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# @title: Hi, this is a demo script
|
# @title: Hi, this is a demo script
|
||||||
# @description: This script logs a "hello world" to teach you how scripts work.
|
# @description: This script logs a "hello world" to teach you how scripts work.
|
||||||
|
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
echo 'Hello World' > hello.txt
|
echo 'Hello World' > hello.txt
|
||||||
Reference in New Issue
Block a user