mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 14:45:24 +00:00
feat: shared list kit, settings search, rail order and ui consistency fixes
This commit is contained in:
1 parent
3ed5775ed5
commit
58c3434e58
68 files changed
+2078
-512
No files matched your search
@@ -276,7 +276,13 @@ export function createPluginAssetsRouter(
|
||||
: "no-cache",
|
||||
);
|
||||
res.type(CONTENT_TYPES[path.extname(file)] ?? "application/octet-stream");
|
||||
res.sendFile(file);
|
||||
// Installed plugins unpack under .unpacked/, which send would refuse as a
|
||||
// dotfile path. resolvePluginAsset already kept the file in the plugin.
|
||||
res.sendFile(file, { dotfiles: "allow" }, (error) => {
|
||||
if (error && !res.headersSent) {
|
||||
res.status(404).json({ error: "Not found" });
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
|
||||
let root = "";
|
||||
let plugin: { id: string; dir: string; manifest: never };
|
||||
let installed: { id: string; dir: string; manifest: never };
|
||||
let server: Server;
|
||||
let baseUrl = "";
|
||||
|
||||
@@ -32,6 +33,14 @@ beforeAll(async () => {
|
||||
write("locales/translated/de_DE.json", "{}");
|
||||
write("manifest.json", "{}");
|
||||
fs.writeFileSync(path.join(root, "outside.js"), "nope");
|
||||
const unpacked = path.join(root, ".unpacked", "gadget");
|
||||
fs.mkdirSync(path.join(unpacked, "dist"), { recursive: true });
|
||||
fs.writeFileSync(path.join(unpacked, "dist", "frontend.js"), "export {}");
|
||||
installed = {
|
||||
id: "gadget",
|
||||
dir: unpacked,
|
||||
manifest: { id: "gadget", version: "1.0.0" } as never,
|
||||
};
|
||||
plugin = {
|
||||
id: "gizmo",
|
||||
dir: path.join(root, "gizmo"),
|
||||
@@ -41,7 +50,9 @@ beforeAll(async () => {
|
||||
const app = express();
|
||||
app.use(
|
||||
"/plugin-assets",
|
||||
createPluginAssetsRouter((id) => (id === "gizmo" ? plugin : undefined)),
|
||||
createPluginAssetsRouter((id) =>
|
||||
id === "gizmo" ? plugin : id === "gadget" ? installed : undefined,
|
||||
),
|
||||
);
|
||||
server = await new Promise<Server>((resolve) => {
|
||||
const created = app.listen(0, "127.0.0.1", () => resolve(created));
|
||||
@@ -111,6 +122,12 @@ describe("resolvePluginAsset", () => {
|
||||
});
|
||||
|
||||
describe("GET /plugin-assets", () => {
|
||||
it("serves an installed plugin unpacked under a dot folder", async () => {
|
||||
const res = await fetch(`${baseUrl}/plugin-assets/gadget/frontend.js`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(await res.text()).toBe("export {}");
|
||||
});
|
||||
|
||||
it("serves a bundle as a module any origin can load", async () => {
|
||||
const res = await fetch(`${baseUrl}/plugin-assets/gizmo/frontend.js`);
|
||||
expect(res.status).toBe(200);
|
||||
|
||||
Reference in new issue
Block a user