mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-30 07:05:24 +00:00
fix: finish 2.9.0 plugin moves and get every check green
This commit is contained in:
1 parent
8c1e02af89
commit
6489b62ece
335 files changed
+29878
-17749
No files matched your search
+61
-17
@@ -1,24 +1,68 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { defineConfig, type Plugin } from "vitest/config";
|
||||
|
||||
/**
|
||||
* The built plugin bundles the boot tests load (dist/plugins) still reach
|
||||
* compiled core by relative path for a few plugins. Point those imports at
|
||||
* core's source, so the bundle shares the one database and the singletons the
|
||||
* test booted instead of loading a second, uninitialized copy of core.
|
||||
*/
|
||||
function builtPluginCoreImports(): Plugin {
|
||||
return {
|
||||
name: "built-plugin-core-imports",
|
||||
enforce: "pre",
|
||||
resolveId(source, importer) {
|
||||
if (!importer || !source.startsWith(".")) return null;
|
||||
if (!importer.replace(/\\/g, "/").includes("/dist/plugins/")) return null;
|
||||
const target = path
|
||||
.resolve(path.dirname(importer), source)
|
||||
.replace(/\\/g, "/");
|
||||
const match = /\/dist\/backend\/(backend|types)\/(.*)\.js$/.exec(target);
|
||||
if (!match) return null;
|
||||
const base = path.resolve(__dirname, "src", match[1], match[2]);
|
||||
for (const candidate of [`${base}.ts`, `${base}.tsx`]) {
|
||||
if (fs.existsSync(candidate)) return candidate;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [builtPluginCoreImports()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@termix/plugin-sdk/frontend": path.resolve(
|
||||
__dirname,
|
||||
"./packages/plugin-sdk/src/frontend.ts",
|
||||
),
|
||||
"@termix/plugin-sdk/ui": path.resolve(
|
||||
__dirname,
|
||||
"./src/ui/plugin-host/sdk-ui.ts",
|
||||
),
|
||||
"@termix/plugin-host/testing": path.resolve(
|
||||
__dirname,
|
||||
"./src/ui/plugin-host/testing-host.tsx",
|
||||
),
|
||||
"@/types": path.resolve(__dirname, "./src/types"),
|
||||
"@": path.resolve(__dirname, "./src/ui"),
|
||||
},
|
||||
alias: [
|
||||
{
|
||||
find: "@termix/plugin-sdk/frontend",
|
||||
replacement: path.resolve(
|
||||
__dirname,
|
||||
"./packages/plugin-sdk/src/frontend.ts",
|
||||
),
|
||||
},
|
||||
{
|
||||
find: "@termix/plugin-sdk/ui",
|
||||
replacement: path.resolve(__dirname, "./src/ui/plugin-host/sdk-ui.ts"),
|
||||
},
|
||||
{
|
||||
find: "@termix/plugin-host/testing",
|
||||
replacement: path.resolve(
|
||||
__dirname,
|
||||
"./src/ui/plugin-host/testing-host.tsx",
|
||||
),
|
||||
},
|
||||
// What built plugin frontends import instead of "@/...". D1 removes it.
|
||||
{
|
||||
find: /^@termix\/legacy-core\/ui\/(.*)$/,
|
||||
replacement: path.resolve(__dirname, "./src/ui") + "/$1",
|
||||
},
|
||||
{
|
||||
find: /^@termix\/legacy-core\/types(.*)$/,
|
||||
replacement: path.resolve(__dirname, "./src/types") + "$1",
|
||||
},
|
||||
{ find: "@/types", replacement: path.resolve(__dirname, "./src/types") },
|
||||
{ find: "@", replacement: path.resolve(__dirname, "./src/ui") },
|
||||
],
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
|
||||
Reference in new issue
Block a user