mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-21 14:22:14 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
56 lines
2.9 KiB
TypeScript
56 lines
2.9 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { assembleStandalone } from "../../../scripts/build/assembleStandalone.mjs";
|
|
|
|
// #7346: on macOS (and Linux AppImage) Electron builds, Turbopack's standalone tracer can leave
|
|
// a hollow (directory exists, contains zero files) externalized-package directory behind. #9913
|
|
// added `repairEmptyExternalPackageDirs` to overlay the real source package on top of a hollow
|
|
// bundle dir — but it only scans the TOP-LEVEL `<outDir>/node_modules`. This project builds with
|
|
// a custom, non-default `distDir` (".build/next", see next.config.mjs), and Next's standalone
|
|
// tracer also emits a SECOND, nested `node_modules` under `<outDir>/<relDistDir>/node_modules`
|
|
// (the same location `materializeBundledSymlinks` already treats as a distinct target — see
|
|
// assembleStandalone() step 7). A hollow externalized package dir landing in that nested
|
|
// location is never repaired, which reproduces the exact ERR_MODULE_NOT_FOUND class reported on
|
|
// #7346 even after #6794/#7353/#9913 all landed.
|
|
test("assembleStandalone repairs a hollow externalized package dir in the nested <distDir> node_modules, not just the top-level one", () => {
|
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "repair-nested-empty-pkg-"));
|
|
const projectRoot = path.join(tmp, "project");
|
|
const relDistDir = ".build/next";
|
|
const distDir = path.join(projectRoot, relDistDir);
|
|
const outDir = path.join(tmp, "dist");
|
|
|
|
// Real source package the repair should copy from.
|
|
const sourcePkgDir = path.join(projectRoot, "node_modules", "some-nested-pkg");
|
|
fs.mkdirSync(sourcePkgDir, { recursive: true });
|
|
fs.writeFileSync(path.join(sourcePkgDir, "package.json"), '{"name":"some-nested-pkg"}');
|
|
fs.writeFileSync(path.join(sourcePkgDir, "index.js"), "module.exports = {};");
|
|
|
|
// Fake standalone tree with a hollow externalized package dir under the NESTED
|
|
// <relDistDir>/node_modules (directory exists but contains zero files — the exact
|
|
// "hollow" shape repairEmptyExternalPackageDirs already repairs at the top level).
|
|
const standaloneDir = path.join(distDir, "standalone");
|
|
fs.mkdirSync(standaloneDir, { recursive: true });
|
|
fs.writeFileSync(path.join(standaloneDir, "server.js"), "// server");
|
|
const hollowNestedPkgDir = path.join(standaloneDir, relDistDir, "node_modules", "some-nested-pkg");
|
|
fs.mkdirSync(hollowNestedPkgDir, { recursive: true });
|
|
|
|
assembleStandalone({
|
|
distDir,
|
|
outDir,
|
|
projectRoot,
|
|
copyNatives: true,
|
|
});
|
|
|
|
const repairedIndexPath = path.join(outDir, relDistDir, "node_modules", "some-nested-pkg", "index.js");
|
|
assert.ok(
|
|
fs.existsSync(repairedIndexPath),
|
|
"hollow nested externalized package dir must be repaired with the real source package (index.js present)"
|
|
);
|
|
|
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
});
|