mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-16 09:22:00 +00:00
* refactor(ingestion): remove dormant import resolvers Remove the unused LanguageProvider importResolver contract, factory and strategy chain. Keep active scope resolver helpers and their semantic tests. Verified 5,309 corpus edges unchanged, 7,411 focused tests, typechecks, build and resolver benchmarks. Full local suite is still running; graph analysis remains partial on deleted and comment-only regions. * refactor: colocate language import helpers Keep import policy beside language resolvers and share only generic indexes. Pass the existing ordered candidates explicitly so lookup behavior and cache identities stay unchanged. * fix: defer MCP imports and narrow Python paths * fix(python): prefer packages in relative imports * test(python): pin package-first import lookup * test(python): use a valid parent-relative import --------- Co-authored-by: Gergely Magyar <magyargergo@users.noreply.github.com> Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
60 lines
2.7 KiB
TypeScript
60 lines
2.7 KiB
TypeScript
/**
|
|
* AST Vite discovery ignores commented-out `lib.entry` text and refuses a
|
|
* default export that is not a single static config object.
|
|
*/
|
|
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { loadNodeWorkspacePackages } from '../../src/core/ingestion/languages/typescript/workspace-packages.js';
|
|
|
|
describe('vite lib.entry discovery ignores comments and refuses disagreeing entries', () => {
|
|
let dir: string;
|
|
const w = (p: string, s: string) => {
|
|
fs.mkdirSync(path.dirname(path.join(dir, p)), { recursive: true });
|
|
fs.writeFileSync(path.join(dir, p), s);
|
|
};
|
|
beforeAll(() => {
|
|
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'gn-vite-comment-'));
|
|
w('package.json', JSON.stringify({ name: 'root', private: true, workspaces: ['packages/*'] }));
|
|
// A commented-out stale entry BEFORE the live one; both files exist.
|
|
w(
|
|
'packages/commented/package.json',
|
|
JSON.stringify({ name: '@acme/commented', exports: { '.': './dist/bundle.js' } }),
|
|
);
|
|
w(
|
|
'packages/commented/vite.config.ts',
|
|
`// old lib: { entry: "src/wrong.ts" }\n/* also once: lib: { entry: 'src/wrong.ts' } */\nexport default defineConfig({ build: { lib: { entry: "src/right.ts" } } });\n`,
|
|
);
|
|
w('packages/commented/src/wrong.ts', 'export const wrong = 1;\n');
|
|
w('packages/commented/src/right.ts', 'export const right = 1;\n');
|
|
// Two LIVE lib objects that disagree: ambiguous, refuse.
|
|
w(
|
|
'packages/twolive/package.json',
|
|
JSON.stringify({ name: '@acme/twolive', main: 'dist/index.js' }),
|
|
);
|
|
w(
|
|
'packages/twolive/vite.config.ts',
|
|
`const a = { lib: { entry: 'src/a.ts' } };\nexport default process.env.X ? a : { build: { lib: { entry: 'src/b.ts' } } };\n`,
|
|
);
|
|
w('packages/twolive/src/a.ts', 'export const a = 1;\n');
|
|
w('packages/twolive/src/b.ts', 'export const b = 1;\n');
|
|
});
|
|
afterAll(() => {
|
|
fs.rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 50 });
|
|
});
|
|
|
|
it('picks the live entry, never the commented one', async () => {
|
|
const pkgs = await loadNodeWorkspacePackages(dir);
|
|
const entries = pkgs!.byName.get('@acme/commented')!.entries;
|
|
expect(entries).toContain('packages/commented/src/right');
|
|
expect(entries).not.toContain('packages/commented/src/wrong');
|
|
});
|
|
|
|
it('refuses when two live lib entries name different existing files', async () => {
|
|
const pkgs = await loadNodeWorkspacePackages(dir);
|
|
const entries = pkgs!.byName.get('@acme/twolive')!.entries;
|
|
expect(entries).not.toContain('packages/twolive/src/a');
|
|
expect(entries).not.toContain('packages/twolive/src/b');
|
|
});
|
|
});
|