fix: 补齐发布包补丁文件
This commit is contained in:
1 parent
0d9f4a7d6f
commit
fb072d844b
3 files changed
+51
-8
No files matched your search
@@ -26,6 +26,26 @@ export async function checkPackage(directory) {
|
||||
.sort();
|
||||
if (JSON.stringify(actual) !== JSON.stringify(expected))
|
||||
throw new Error("Release file list mismatch");
|
||||
|
||||
const packagePath = path.join(directory, "package.json");
|
||||
let releasePackage;
|
||||
try {
|
||||
releasePackage = JSON.parse(await readFile(packagePath, "utf8"));
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
}
|
||||
const patchedDependencies = releasePackage?.pnpm?.patchedDependencies ?? {};
|
||||
for (const [dependency, patchPath] of Object.entries(patchedDependencies)) {
|
||||
if (
|
||||
typeof patchPath !== "string" ||
|
||||
path.isAbsolute(patchPath) ||
|
||||
patchPath.split("/").includes("..")
|
||||
)
|
||||
throw new Error("Invalid patched dependency path: " + dependency);
|
||||
if (!actual.includes(patchPath))
|
||||
throw new Error(`Release is missing patched dependency ${dependency}: ${patchPath}`);
|
||||
}
|
||||
|
||||
for (const file of manifest.files) {
|
||||
if (file.path.startsWith("/") || file.path.split("/").includes(".."))
|
||||
throw new Error("Unsafe release path");
|
||||
|
||||
Reference in new issue
Block a user