Update editor, themes, menus, backgrounds, and release tooling
This commit is contained in:
@@ -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; });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user