mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:50:43 +00:00
test(plugins): support live clawhub legacy zips
This commit is contained in:
@@ -305,6 +305,29 @@ function assertClawHubExternalInstallContract(installPath) {
|
||||
}
|
||||
}
|
||||
|
||||
function assertClawHubArtifactMetadata(record, pluginId) {
|
||||
if (record.artifactKind === "legacy-zip") {
|
||||
if (record.artifactFormat !== "zip") {
|
||||
throw new Error(
|
||||
`missing ClawHub legacy ZIP artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") {
|
||||
throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`);
|
||||
}
|
||||
if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") {
|
||||
throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`);
|
||||
}
|
||||
if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) {
|
||||
throw new Error(
|
||||
`missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function assertPluginDirDeps() {
|
||||
const sourceDir = process.argv[3];
|
||||
assertSimplePlugin(
|
||||
@@ -534,17 +557,7 @@ function assertClawHubInstalled() {
|
||||
if (typeof record.installPath !== "string" || record.installPath.length === 0) {
|
||||
throw new Error(`missing ClawHub install path for ${pluginId}`);
|
||||
}
|
||||
if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") {
|
||||
throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`);
|
||||
}
|
||||
if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") {
|
||||
throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`);
|
||||
}
|
||||
if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) {
|
||||
throw new Error(
|
||||
`missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
|
||||
);
|
||||
}
|
||||
assertClawHubArtifactMetadata(record, pluginId);
|
||||
|
||||
const installPath = record.installPath.replace(/^~(?=$|\/)/u, process.env.HOME);
|
||||
const extensionsRoot = path.join(process.env.HOME, ".openclaw", "extensions");
|
||||
@@ -554,7 +567,9 @@ function assertClawHubInstalled() {
|
||||
if (!fs.existsSync(installPath)) {
|
||||
throw new Error(`ClawHub install path missing on disk: ${installPath}`);
|
||||
}
|
||||
assertClawHubExternalInstallContract(installPath);
|
||||
if (record.artifactKind === "npm-pack") {
|
||||
assertClawHubExternalInstallContract(installPath);
|
||||
}
|
||||
fs.writeFileSync("/tmp/plugins-clawhub-install-path.txt", installPath, "utf8");
|
||||
}
|
||||
|
||||
@@ -596,10 +611,10 @@ function assertClawHubRemoved() {
|
||||
}
|
||||
|
||||
function assertClawHubUpdated() {
|
||||
assertUpdateOutput(
|
||||
"/tmp/plugins-clawhub-update.log",
|
||||
`${process.env.CLAWHUB_PLUGIN_ID} already at 0.1.0.`,
|
||||
);
|
||||
const output = fs.readFileSync("/tmp/plugins-clawhub-update.log", "utf8");
|
||||
if (!output.includes(`${process.env.CLAWHUB_PLUGIN_ID} already at `)) {
|
||||
throw new Error(`expected ClawHub update to report already-at version:\n${output}`);
|
||||
}
|
||||
assertClawHubInstalled();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user