mirror of
https://github.com/morluto/rea.git
synced 2026-11-10 00:36:35 +00:00
* fix(javascript): require exact loader suffix case * fix(javascript): share exact loader mode across import resolution * test(process): align symlink fixture with filesystem checkpoints * test(javascript): normalize the module resolution oracle path separators * test(frida): assert the CLI spawn Evidence contract * test(mcp): use an unsupported analysis-view parent * test(browser): separate source-location line bounds from parity * fix(javascript): preserve uncertain loader provenance * test(javascript): cover uncertain require resolution * fix(javascript): retain conditional Electron evidence * fix(javascript): preserve timed semantic provenance * fix(javascript): retain conditional builtin effects * test(javascript): distinguish bundled host authority * fix(javascript): preserve nested loader invocation identity * test(javascript): qualify Electron fixture authority * fix(javascript): preserve loader invocation authority * fix(javascript): respect source order for resolver escapes * fix(javascript): check nested loader callable mutations * fix(javascript): retain conditional constructor requests * fix(reference): retain constructor loader relationships * fix(reference): follow nested loader callable paths * refactor(javascript): share callable mutation interpretation * fix(javascript): require exact package loader suffixes * refactor(javascript): unify conditional relation evidence * refactor(javascript): unify conditional node evidence * fix(javascript): retain unknown authority for mixed case sources * fix(javascript): preserve loader uncertainty for dotfiles * fix(reference): classify javascript suffix dotfiles * test(reference): cover suffix dotfiles through cli * fix(javascript): retain equivalent conditional built-in origins * fix(javascript): preserve wrapped resolver operation * fix(javascript): retain nested conditional built-in receivers * test(javascript): declare CommonJS in native addon fixtures * fix(javascript): retain wrapped resolver candidates * style: format merged native command schema * fix(javascript): preserve uncertain loader authority * test(javascript): require candidate preload evidence * test(javascript): cover reference loader member writes --------- Co-authored-by: ShuaixinHuang <1836656514@qq.com>
107 lines
4.0 KiB
TypeScript
107 lines
4.0 KiB
TypeScript
import { expect } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
import { analyzeJavaScriptDirectory } from "../../support/cli/javascriptApplication.js";
|
|
import { writeFixtureFiles } from "../../support/javascriptApplicationFixture.js";
|
|
|
|
cliTest.for(["CLI", "stdio MCP"] as const)(
|
|
"keeps package context conditional for uppercase source suffixes through %s",
|
|
async (surface, { cli }) => {
|
|
const root = await createTestTempDirectory("rea-package-suffix-case-");
|
|
const source = 'require("./dep.cjs");';
|
|
await writeFixtureFiles(root, {
|
|
"common/package.json": '{"type":"commonjs"}',
|
|
"common/entry.JS": source,
|
|
"common/entry.TS": source,
|
|
"common/mixed.JS":
|
|
'import {join} from "node:path"; require("./dep.cjs");',
|
|
"common/.MJS": 'import {join} from "node:path"; require("./dep.cjs");',
|
|
"common/lower.js": source,
|
|
"common/dep.cjs": "module.exports = {};",
|
|
"module/package.json": '{"type":"module"}',
|
|
"module/entry.JS": source,
|
|
"module/entry.TS": source,
|
|
"module/mixed.JS":
|
|
'import {join} from "node:path"; require("./dep.cjs");',
|
|
"lower-module/package.json": '{"type":"module"}',
|
|
"lower-common/package.json": '{"type":"commonjs"}',
|
|
"lower-module/.cjs": 'require("./dep.cjs");',
|
|
"lower-common/.mjs": 'require("./dep.cjs");',
|
|
"module/.MJS": 'import {join} from "node:path"; require("./dep.cjs");',
|
|
"module/ordinary.js": "console.log('module');",
|
|
"module/main.mjs":
|
|
'import {BrowserWindow} from "electron"; import {fileURLToPath} from "node:url"; new BrowserWindow({webPreferences:{sandbox:false,preload:fileURLToPath(new URL("./entry.JS",import.meta.url))}});',
|
|
"module/dep.cjs": "module.exports = {};",
|
|
});
|
|
const result = await analyzeJavaScriptDirectory(surface, cli, root);
|
|
for (const source of [
|
|
"common/entry.JS",
|
|
"common/entry.TS",
|
|
"module/entry.JS",
|
|
"module/entry.TS",
|
|
"common/mixed.JS",
|
|
"module/mixed.JS",
|
|
"common/.MJS",
|
|
"module/.MJS",
|
|
"lower-common/.mjs",
|
|
"lower-module/.cjs",
|
|
]) {
|
|
const edges = result.graph.edges.filter(
|
|
({ relation, properties, evidence }) =>
|
|
relation === "imports" &&
|
|
properties.specifier === "./dep.cjs" &&
|
|
properties.loader_authority === "candidate" &&
|
|
evidence.location.available &&
|
|
evidence.location.value.kind === "source-range" &&
|
|
evidence.location.value.source === source,
|
|
);
|
|
expect(edges.length, source).toBeGreaterThan(0);
|
|
for (const edge of edges) {
|
|
expect(edge.properties.resolved_path, source).toBeNull();
|
|
expect(edge.evidence.confidence, source).toBe("low");
|
|
}
|
|
}
|
|
for (const source of [
|
|
"common/mixed.JS",
|
|
"module/mixed.JS",
|
|
"common/.MJS",
|
|
"module/.MJS",
|
|
]) {
|
|
expect(
|
|
result.graph.nodes.flatMap(({ observations }) => observations),
|
|
).toContainEqual(
|
|
expect.objectContaining({
|
|
properties: expect.objectContaining({
|
|
path: source,
|
|
module_format: "unknown",
|
|
}),
|
|
}),
|
|
);
|
|
expect(result.graph.edges).toContainEqual(
|
|
expect.objectContaining({
|
|
properties: expect.objectContaining({ specifier: "node:path" }),
|
|
evidence: expect.objectContaining({
|
|
location: expect.objectContaining({
|
|
value: expect.objectContaining({ source }),
|
|
}),
|
|
}),
|
|
}),
|
|
);
|
|
}
|
|
expect(result.graph.edges).toContainEqual(
|
|
expect.objectContaining({
|
|
properties: expect.objectContaining({
|
|
specifier: "./dep.cjs",
|
|
resolved_path: "common/dep.cjs",
|
|
}),
|
|
evidence: expect.objectContaining({
|
|
location: expect.objectContaining({
|
|
value: expect.objectContaining({ source: "common/lower.js" }),
|
|
}),
|
|
}),
|
|
}),
|
|
);
|
|
},
|
|
);
|