mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-06 14:30:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3bf7c25fc |
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
import { runtimeFailureMessage } from "./containerRuntime.shared.cjs";
|
import { runtimeFailureMessage } from "@/domain/systemManager/containerRuntime.shared.cjs";
|
||||||
|
|
||||||
export type {
|
export type {
|
||||||
ContainerRuntimeId,
|
ContainerRuntimeId,
|
||||||
@@ -6,7 +6,7 @@ export type {
|
|||||||
KubeContextInfo,
|
KubeContextInfo,
|
||||||
KubectlPodInfo,
|
KubectlPodInfo,
|
||||||
RuntimeProbeFlags,
|
RuntimeProbeFlags,
|
||||||
} from "./containerRuntime.shared.cjs";
|
} from "@/domain/systemManager/containerRuntime.shared.cjs";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
NETCATTY_POPUP_HISTORY_MARKER,
|
NETCATTY_POPUP_HISTORY_MARKER,
|
||||||
@@ -24,7 +24,7 @@ export {
|
|||||||
reconcileContainerSource,
|
reconcileContainerSource,
|
||||||
rememberedContainerSource,
|
rememberedContainerSource,
|
||||||
sourcesFromCapabilities,
|
sourcesFromCapabilities,
|
||||||
} from "./containerRuntime.shared.cjs";
|
} from "@/domain/systemManager/containerRuntime.shared.cjs";
|
||||||
|
|
||||||
export function describeRuntimeFailure(
|
export function describeRuntimeFailure(
|
||||||
result: { error?: string; errorCode?: string } | null | undefined,
|
result: { error?: string; errorCode?: string } | null | undefined,
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const test = require("node:test");
|
||||||
|
const assert = require("node:assert/strict");
|
||||||
|
const { spawnSync } = require("node:child_process");
|
||||||
|
const path = require("node:path");
|
||||||
|
|
||||||
|
// Use native ESM linking, rather than Node's CommonJS interop or a bundler,
|
||||||
|
// so a missing browser export fails exactly as it does in the renderer.
|
||||||
|
async function checkDevImport() {
|
||||||
|
const { createServer } = await import("vite");
|
||||||
|
const { SourceTextModule, createContext } = await import("node:vm");
|
||||||
|
const { mkdtempSync, rmSync } = await import("node:fs");
|
||||||
|
const { createRequire } = await import("node:module");
|
||||||
|
const assert = (await import("node:assert/strict")).default;
|
||||||
|
const require = createRequire(`${process.cwd()}/package.json`);
|
||||||
|
const temp = require("./electron/bridges/tempDirBridge.cjs");
|
||||||
|
const cacheDir = mkdtempSync(`${temp.getTempFilePath("container-runtime-vite")}-`);
|
||||||
|
let server;
|
||||||
|
try {
|
||||||
|
server = await createServer({
|
||||||
|
cacheDir,
|
||||||
|
logLevel: "error",
|
||||||
|
server: { port: 0, strictPort: false, open: false },
|
||||||
|
optimizeDeps: { entries: [], noDiscovery: true },
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
const origin = server.resolvedUrls.local[0];
|
||||||
|
const context = createContext({});
|
||||||
|
const modules = new Map();
|
||||||
|
async function load(url) {
|
||||||
|
if (!modules.has(url)) {
|
||||||
|
modules.set(url, (async () => {
|
||||||
|
const response = await fetch(url);
|
||||||
|
assert.equal(response.status, 200, url);
|
||||||
|
return new SourceTextModule(await response.text(), { context, identifier: url });
|
||||||
|
})());
|
||||||
|
}
|
||||||
|
return modules.get(url);
|
||||||
|
}
|
||||||
|
const entry = await load(new URL("/domain/systemManager/containerRuntime.ts", origin).href);
|
||||||
|
await entry.link((specifier, importer) => load(new URL(specifier, importer.identifier).href));
|
||||||
|
await entry.evaluate();
|
||||||
|
const runtime = entry.namespace;
|
||||||
|
assert.equal(runtime.firstContainerRuntime(["podman"]), "podman");
|
||||||
|
assert.equal(runtime.buildContainerExecShellCommand("podman", "abc").includes("podman exec"), true);
|
||||||
|
assert.equal(runtime.describeRuntimeFailure({ errorCode: "nerdctlUnreachable" }, key => key, "fallback"), "systemManager.errors.nerdctlUnreachable");
|
||||||
|
assert.equal(runtime.describeRuntimeFailure({ error: "original error" }, key => key, "fallback"), "original error");
|
||||||
|
assert.equal(runtime.describeRuntimeFailure(null, key => key, "fallback"), "fallback");
|
||||||
|
} finally {
|
||||||
|
await server?.close();
|
||||||
|
rmSync(cacheDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test("Vite serves the renderer container runtime with browser-compatible exports", { timeout: 60_000 }, () => {
|
||||||
|
const result = spawnSync(process.execPath, [
|
||||||
|
"--experimental-vm-modules", "--input-type=module", "-e",
|
||||||
|
`(${checkDevImport.toString()})().catch(error => { console.error(error); process.exitCode = 1; });`,
|
||||||
|
], { cwd: path.resolve(__dirname, ".."), encoding: "utf8", timeout: 55_000 });
|
||||||
|
assert.equal(result.status, 0, result.error?.message || `${result.stdout}\n${result.stderr}`);
|
||||||
|
});
|
||||||
@@ -83,6 +83,10 @@ export default defineConfig(() => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
|
// The shared runtime is also required by Electron; convert it for browser builds.
|
||||||
|
commonjsOptions: {
|
||||||
|
include: [/node_modules/, /domain\/systemManager\/containerRuntime\.shared\.cjs$/],
|
||||||
|
},
|
||||||
chunkSizeWarningLimit: 3000,
|
chunkSizeWarningLimit: 3000,
|
||||||
target: 'esnext', // Required for top-level await in WASM modules
|
target: 'esnext', // Required for top-level await in WASM modules
|
||||||
sourcemap: false, // Disable source maps to avoid missing map file warnings
|
sourcemap: false, // Disable source maps to avoid missing map file warnings
|
||||||
@@ -124,6 +128,8 @@ export default defineConfig(() => {
|
|||||||
plugins: [suppressMonacoSourcemapWarning(), devContentSecurityPolicyPlugin(), warnOnOutdatedOptimizeDep(), tailwindcss(), react()],
|
plugins: [suppressMonacoSourcemapWarning(), devContentSecurityPolicyPlugin(), warnOnOutdatedOptimizeDep(), tailwindcss(), react()],
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: [
|
include: [
|
||||||
|
// Keep the renderer alias pre-bundled so dev serves ESM instead of raw CommonJS.
|
||||||
|
'@/domain/systemManager/containerRuntime.shared.cjs',
|
||||||
'ai',
|
'ai',
|
||||||
'@ai-sdk/openai',
|
'@ai-sdk/openai',
|
||||||
'@ai-sdk/anthropic',
|
'@ai-sdk/anthropic',
|
||||||
|
|||||||
Reference in new issue
Block a user