Update editor, themes, menus, backgrounds, and release tooling

This commit is contained in:
Knotty Wyvern
2026-10-14 16:19:51 -07:00
parent f6eaa52949
commit edef2520af
113 changed files with 5722 additions and 386 deletions
+22 -5
View File
@@ -1,6 +1,6 @@
import { lstat, readdir, readFile, mkdir, writeFile, realpath, rename, unlink } from "node:fs/promises";
import { lstat, readdir, readFile, mkdir, writeFile, realpath, link, unlink } from "node:fs/promises";
import { randomUUID } from "node:crypto";
import { resolve, relative, isAbsolute, join } from "node:path";
import { resolve, relative, isAbsolute, join, dirname } from "node:path";
import { pathToFileURL } from "node:url";
import { crc32, deflateRawSync } from "node:zlib";
@@ -50,9 +50,21 @@ function zip(files) {
return Buffer.concat([...local, ...central, end]);
}
export async function packagePlugin(source, destination = "plugin-packages") {
export async function packagePlugin(source, destination) {
const input = resolve(source);
const output = resolve(destination);
let project = input;
if (!destination) {
while (true) {
try { await readFile(join(project, "package.json")); break; }
catch (error) {
if (error.code !== "ENOENT") throw error;
const parent = dirname(project);
requireValue(parent !== project, "Pass an output folder when the compiled folder has no project root.");
project = parent;
}
}
}
const output = resolve(destination ?? join(project, "releases"));
const inputMeta = await lstat(input);
requireValue(inputMeta.isDirectory() && !inputMeta.isSymbolicLink(), "Select a compiled plugin folder.");
const files = [], names = new Set();
@@ -102,7 +114,12 @@ export async function packagePlugin(source, destination = "plugin-packages") {
const temporary = `${target}.${randomUUID()}.tmp`;
try {
await writeFile(temporary, archive, { flag: "wx" });
await rename(temporary, target);
try {
await link(temporary, target);
} catch (error) {
if (error.code !== "EEXIST") throw error;
requireValue((await readFile(target)).equals(archive), "The release file already contains different contents: " + target);
}
} finally {
await unlink(temporary).catch(error => { if (error.code !== "ENOENT") throw error; });
}