mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
1da74794b6
* fix(release): define immutable release plan contract * fix(release): harden immutable plan authority * fix(release): tighten release plan authority * fix(release): share plugin publication authority * fix(release): verify plan authority remotely * fix(release): track ClawHub publication authorities * fix(release): trust remote tooling tag identity * fix(release): close plugin publication authority * fix(release): align npm authority selection * fix(release): bind plans to validation intent * fix(release): require qualification cadence * fix(release): reject lossy canonical values * fix(release): narrow qualification cadence * fix(release): bind plan parser dependency * fix(release): add tagless diagnostic plans * fix(release): attest release plan parser tree * fix(release): isolate verified plan parser snapshot * fix(release): verify plan tooling before execution
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import { writeFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { writeJsonFile } from "./temp-repo.js";
|
|
|
|
type PublishablePluginSurface = "npm" | "clawhub" | "both" | "clawhub-disabled";
|
|
|
|
type PublishablePluginFixtureOptions = {
|
|
extensionId?: string;
|
|
packageName?: string;
|
|
version: string;
|
|
publishTo: PublishablePluginSurface;
|
|
bundledDist?: boolean;
|
|
dependency?: {
|
|
packageName: string;
|
|
version: string;
|
|
requireLatest?: boolean;
|
|
};
|
|
};
|
|
|
|
export function writePublishablePluginFixture(
|
|
repoDir: string,
|
|
options: PublishablePluginFixtureOptions,
|
|
) {
|
|
const extensionId = options.extensionId ?? "demo-plugin";
|
|
const packageName = options.packageName ?? `@openclaw/${extensionId}`;
|
|
const packageDir = join(repoDir, "extensions", extensionId);
|
|
const publishToNpm = options.publishTo === "npm" || options.publishTo === "both";
|
|
const publishToClawHub = options.publishTo === "clawhub" || options.publishTo === "both";
|
|
const release = {
|
|
...(publishToNpm ? { publishToNpm: true } : {}),
|
|
...(publishToClawHub ? { publishToClawHub: true } : {}),
|
|
...(options.publishTo === "clawhub-disabled" ? { publishToClawHub: false } : {}),
|
|
...(options.dependency?.requireLatest
|
|
? { requireLatestDependencies: [options.dependency.packageName] }
|
|
: {}),
|
|
};
|
|
writeJsonFile(join(packageDir, "package.json"), {
|
|
name: packageName,
|
|
version: options.version,
|
|
type: "module",
|
|
repository: {
|
|
type: "git",
|
|
url: "https://github.com/openclaw/openclaw",
|
|
},
|
|
...(options.dependency
|
|
? { dependencies: { [options.dependency.packageName]: options.dependency.version } }
|
|
: {}),
|
|
openclaw: {
|
|
extensions: ["./index.ts"],
|
|
compat: { pluginApi: `>=${options.version}` },
|
|
build: {
|
|
openclawVersion: options.version,
|
|
...(options.bundledDist ? { bundledDist: true } : {}),
|
|
},
|
|
install: { npmSpec: packageName },
|
|
release,
|
|
},
|
|
});
|
|
const exportName = extensionId.replaceAll(/[-.]/g, "_");
|
|
writeFileSync(join(packageDir, "index.ts"), `export const ${exportName} = 1;\n`);
|
|
writeFileSync(join(packageDir, "README.md"), "# Demo plugin\n");
|
|
return { extensionId, packageDir, packageName };
|
|
}
|