mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 14:34:07 +00:00
fix(release): tolerate npm README metadata lag
This commit is contained in:
@@ -306,12 +306,26 @@ function readPackedPackage(tarballPath, extractDir) {
|
||||
tar.x({ file: tarballPath, cwd: extractDir, sync: true });
|
||||
const packageDir = path.join(extractDir, "package");
|
||||
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"));
|
||||
const files = listFiles(packageDir);
|
||||
return {
|
||||
packageJson,
|
||||
files: listFiles(packageDir),
|
||||
files,
|
||||
readme: readPackedPackageReadme(packageDir, files),
|
||||
};
|
||||
}
|
||||
|
||||
export function findPackedPackageReadmePath(files) {
|
||||
return files.find((file) => /^readme(?:\.(?:md|markdown|txt|rst))?$/iu.test(file)) ?? "";
|
||||
}
|
||||
|
||||
function readPackedPackageReadme(packageDir, files) {
|
||||
const readmePath = findPackedPackageReadmePath(files);
|
||||
if (!readmePath) {
|
||||
return "";
|
||||
}
|
||||
return fs.readFileSync(path.join(packageDir, readmePath), "utf8").trim();
|
||||
}
|
||||
|
||||
export async function verifyPublishedPluginRuntime(spec) {
|
||||
const workingDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-npm-runtime."));
|
||||
try {
|
||||
@@ -326,7 +340,18 @@ export async function verifyPublishedPluginRuntime(spec) {
|
||||
if (errors.length > 0) {
|
||||
throw new Error(errors.join("\n"));
|
||||
}
|
||||
const readme = await verifyPublishedPackageReadme(spec);
|
||||
let readme;
|
||||
try {
|
||||
readme = await verifyPublishedPackageReadme(spec);
|
||||
} catch (error) {
|
||||
if (!packedPackage.readme) {
|
||||
throw error;
|
||||
}
|
||||
console.error(
|
||||
`npm readme metadata for ${spec} was unavailable; verified README from published tarball instead.`,
|
||||
);
|
||||
readme = packedPackage.readme;
|
||||
}
|
||||
return {
|
||||
packageName: packedPackage.packageJson.name,
|
||||
version: packedPackage.packageJson.version,
|
||||
|
||||
Reference in New Issue
Block a user