Update licenses and add robots.txt

This commit is contained in:
Bad Manners 2024-08-26 12:53:45 -03:00
parent 57c2c7c649
commit 4194154818
6 changed files with 88 additions and 29 deletions

View file

@ -28,9 +28,7 @@ async function deployLftp({ host, user, password, targetFolder, sourceFolder, as
},
);
await new Promise((resolve, reject) => {
process.on("close", (code) =>
(code === 0) ? resolve(0) : reject(`lftp failed with code ${code}`),
);
process.on("close", (code) => (code === 0 ? resolve(0) : reject(`lftp failed with code ${code}`)));
});
}

View file

@ -33,8 +33,8 @@ const fetchRetry = fetchRetryWrapper(global.fetch);
const isLibreOfficeRunning = async () =>
new Promise<boolean>((res) => {
spawn("ps", ["-ax"], {stdio: 'pipe'});
const lines = createInterface({ input: spawn("ps", ["-ax"], {stdio: 'pipe'}).stdout });
spawn("ps", ["-ax"], { stdio: "pipe" });
const lines = createInterface({ input: spawn("ps", ["-ax"], { stdio: "pipe" }).stdout });
lines.on("line", (line) => {
if (line.includes("libreoffice") && line.includes("--writer")) {
res(true);
@ -65,11 +65,11 @@ async function exportStory(slug: string, options: { outputDir: string }) {
/* Spawn Astro dev server */
console.log("Starting Astro development server...");
const devServerProcess = spawn("./node_modules/.bin/astro", ["dev"], { stdio: 'pipe' });
const devServerProcess = spawn("./node_modules/.bin/astro", ["dev"], { stdio: "pipe" });
let astroURL: string | null = null;
try {
astroURL = await new Promise<string>((resolve, reject) => {
const localServerRegex = /Local\s+(http:\/\/\S+)/
const localServerRegex = /Local\s+(http:\/\/\S+)/;
const lines = createInterface({ input: devServerProcess.stdout });
lines.on("line", (line) => {
const match = localServerRegex.exec(line);
@ -104,13 +104,11 @@ async function exportStory(slug: string, options: { outputDir: string }) {
if (!response.ok) {
throw new Error(`Failed to reach API (status code ${response.status})`);
}
const data: { story: string, description: Record<string, string>, thumbnail: string | null } = await response.json();
const data: { story: string; description: Record<string, string>; thumbnail: string | null } =
await response.json();
await Promise.all(
Object.entries(data.description).map(async ([filename, description]) => {
return await writeFile(
join(outputDir, filename),
description,
);
return await writeFile(join(outputDir, filename), description);
}),
);
if (data.thumbnail) {
@ -144,11 +142,9 @@ async function exportStory(slug: string, options: { outputDir: string }) {
await writeFile(join(outputDir, `${slug}.md`), storyText.replaceAll(/=(?==)/g, "= ").replaceAll("*", "\\*"));
const tempDir = await mkdtemp(join(tmpdir(), "export-story-"));
await writeFile(join(tempDir, "temp.txt"), storyText.replaceAll(/\n\n+/g, "\n"));
spawnSync(
"libreoffice",
["--convert-to", "rtf:Rich Text Format", "--outdir", tempDir, join(tempDir, "temp.txt")],
{ stdio: "ignore" },
);
spawnSync("libreoffice", ["--convert-to", "rtf:Rich Text Format", "--outdir", tempDir, join(tempDir, "temp.txt")], {
stdio: "ignore",
});
const rtfText = await readFile(join(tempDir, "temp.rtf"), "utf-8");
const rtfStyles = getRTFStyles(rtfText);
await writeFile(