Release RuneStone 0.1.7 with plugin documents and shared menus
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { mkdtemp, mkdir, readFile, writeFile, rm, realpath } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
// @ts-ignore The build tool is a JavaScript module.
|
||||
import { packagePlugin } from "./packagePlugin.mjs";
|
||||
|
||||
test("plugin packaging rejects invalid release inputs before writing an archive", async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), "runestone-packaging-"));
|
||||
const source = join(root, "plugin"), output = join(root, "releases");
|
||||
await mkdir(source);
|
||||
const manifest = {
|
||||
schemaVersion: 1, apiVersion: 1, id: "org.test.demo", name: "Demo", author: "Test",
|
||||
description: "Test plugin", version: "1.0.0", entry: "main.js", access: "full-app",
|
||||
};
|
||||
const save = async (changes = {}) => writeFile(join(source, "plugin.json"), JSON.stringify({ ...manifest, ...changes }));
|
||||
try {
|
||||
await assert.rejects(packagePlugin(source, output), /plugin.json at its root/);
|
||||
await save();
|
||||
await assert.rejects(packagePlugin(source, output), /entry module is missing/);
|
||||
await writeFile(join(source, "main.js"), "export function activate() {}");
|
||||
for (const [changes, message] of [
|
||||
[{ id: "../escape" }, /ID is invalid/],
|
||||
[{ version: "1.0" }, /version such as/],
|
||||
[{ entry: "../main.js" }, /compiled JavaScript/],
|
||||
[{ apiVersion: 99 }, /Unsupported/],
|
||||
[{ author: "" }, /valid author/],
|
||||
] as const) {
|
||||
await save(changes);
|
||||
await assert.rejects(packagePlugin(source, output), message);
|
||||
}
|
||||
await save();
|
||||
await assert.rejects(packagePlugin(source, source), /outside the plugin folder/);
|
||||
await writeFile(join(source, "invalid file.txt"), "test");
|
||||
await assert.rejects(packagePlugin(source, output), /Invalid package path/);
|
||||
await rm(join(source, "invalid file.txt"));
|
||||
const path = await packagePlugin(source, output);
|
||||
assert.equal(path, join(await realpath(output), "org.test.demo-1.0.0.zip"));
|
||||
const first = await readFile(path);
|
||||
await packagePlugin(source, output);
|
||||
assert.deepEqual(await readFile(path), first);
|
||||
} finally {
|
||||
// mkdtemp returns this test's unique directory under the operating system temp folder.
|
||||
assert.equal(root.startsWith(join(tmpdir(), "runestone-packaging-")), true);
|
||||
await rm(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user