Ship file viewer, editor improvements, and private package releases
This commit is contained in:
1 parent
645914955c
commit
a4a31032b9
158 files changed
+10523
-137
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/plugin",
|
||||
"version": "0.8.8",
|
||||
"version": "0.8.9",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -356,6 +356,8 @@ export async function discoverPlugins(
|
||||
if (!declared) continue;
|
||||
const manifest = pluginManifest(declared);
|
||||
if (manifest.autoDiscover === false) continue;
|
||||
// Skip before importing or invoking the factory: it may mutate package state.
|
||||
if (explicitNames.has(packageJson?.name ?? name)) continue;
|
||||
try {
|
||||
const plugin = await loadPlugin(packageRoot, manifest);
|
||||
enforcePermissions(name, packageManifest, modulePermissions(plugin), options);
|
||||
|
||||
@@ -5,6 +5,46 @@ import { join } from "node:path";
|
||||
import { createPluginRunner, discoverPlugins, resolvePlugins } from "../src/index.ts";
|
||||
import { parse } from "@wrnexus/syntax";
|
||||
|
||||
test("an explicitly configured package never imports its automatic factory", async () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-suppressed-factory-"));
|
||||
const app = join(root, "apps", "web");
|
||||
const pkg = join(root, "packages", "stateful");
|
||||
try {
|
||||
mkdirSync(app, { recursive: true });
|
||||
mkdirSync(pkg, { recursive: true });
|
||||
writeFileSync(
|
||||
join(root, "package.json"),
|
||||
JSON.stringify({ private: true, workspaces: ["apps/*", "packages/*"] }),
|
||||
);
|
||||
writeFileSync(
|
||||
join(app, "package.json"),
|
||||
JSON.stringify({ name: "web", dependencies: { "@test/stateful": "workspace:*" } }),
|
||||
);
|
||||
writeFileSync(
|
||||
join(pkg, "package.json"),
|
||||
JSON.stringify({
|
||||
name: "@test/stateful",
|
||||
type: "module",
|
||||
wrnexus: { plugin: { plugin: "./factory.ts", factory: true } },
|
||||
}),
|
||||
);
|
||||
writeFileSync(
|
||||
join(pkg, "factory.ts"),
|
||||
'throw new Error("Automatic factory imported"); export default () => ({name:"@test/stateful"});',
|
||||
);
|
||||
const explicit = { name: "@test/stateful" };
|
||||
const result = await discoverPlugins(app, [explicit], { strict: true });
|
||||
expect(resolvePlugins(result).map((plugin) => plugin.name)).toContain(explicit.name);
|
||||
await expect(discoverPlugins(app, [], { strict: true })).rejects.toThrow(
|
||||
"Automatic factory imported",
|
||||
);
|
||||
} finally {
|
||||
// mkdtemp creates this directory directly under the explicitly named temp root.
|
||||
if (root.startsWith(join(tmpdir(), "wrnexus-suppressed-factory-")))
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe("plugin ordering", () => {
|
||||
test("orders pre, normal, and post plugins", () => {
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user