mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-18 02:16:07 +00:00
fix(web): show page component icon on plugin cards (#2345)
Co-authored-by: dadachann <dadachann@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import test from 'node:test';
|
||||
import { createRequire } from 'node:module';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import ts from 'typescript';
|
||||
|
||||
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
|
||||
const sourcePath = path.resolve(
|
||||
currentDirectory,
|
||||
'../../src/app/home/plugins/components/plugin-market/PluginComponentIcons.ts',
|
||||
);
|
||||
const source = fs.readFileSync(sourcePath, 'utf8');
|
||||
const compiled = ts.transpileModule(source, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS },
|
||||
}).outputText;
|
||||
const sourceRequire = createRequire(sourcePath);
|
||||
const loadedModule = { exports: {} };
|
||||
new Function('require', 'module', 'exports', compiled)(
|
||||
sourceRequire,
|
||||
loadedModule,
|
||||
loadedModule.exports,
|
||||
);
|
||||
|
||||
const { AppWindow } = sourceRequire('lucide-react');
|
||||
const { pluginComponentIconMap } = loadedModule.exports;
|
||||
|
||||
test('maps the Page plugin component to the AppWindow icon', () => {
|
||||
assert.equal(pluginComponentIconMap.Page, AppWindow);
|
||||
});
|
||||
Reference in New Issue
Block a user