chore: switch Peekaboo to SPM

This commit is contained in:
Peter Steinberger
2026-01-18 07:47:01 +00:00
parent ae0b4c4990
commit e5cca6e432
7 changed files with 43 additions and 132 deletions

View File

@@ -43,47 +43,6 @@ function hasGit(repoRoot) {
return result.status === 0;
}
function isSubmoduleDirty(submodulePath, repoRoot) {
const result = spawnSync("git", ["-C", submodulePath, "status", "--porcelain"], {
cwd: repoRoot,
encoding: "utf-8",
});
if (result.status !== 0) return false;
return result.stdout.trim().length > 0;
}
function shouldSyncSubmodule(name, repoRoot) {
const result = spawnSync("git", ["submodule", "status", "--recursive", "--", name], {
cwd: repoRoot,
encoding: "utf-8",
});
if (result.status !== 0) return false;
const line = result.stdout.trim().split("\n")[0];
if (!line) return false;
const marker = line[0];
return marker === "-" || marker === "+";
}
function syncPeekabooSubmodule(repoRoot) {
if (!hasGit(repoRoot)) return;
if (!fs.existsSync(path.join(repoRoot, ".gitmodules"))) return;
const peekabooPath = path.join(repoRoot, "Peekaboo");
if (fs.existsSync(peekabooPath) && isSubmoduleDirty(peekabooPath, repoRoot)) {
console.warn("[postinstall] Peekaboo submodule dirty; skipping update");
return;
}
if (!shouldSyncSubmodule("Peekaboo", repoRoot)) return;
const result = spawnSync(
"git",
["submodule", "update", "--init", "--recursive", "--", "Peekaboo"],
{ cwd: repoRoot, encoding: "utf-8" },
);
if (result.status !== 0) {
const stderr = result.stderr?.toString().trim();
console.warn(`[postinstall] Peekaboo submodule update failed: ${stderr || "unknown error"}`);
}
}
function extractPackageName(key) {
if (key.startsWith("@")) {
const idx = key.indexOf("@", 1);
@@ -293,7 +252,6 @@ function main() {
process.chdir(repoRoot);
ensureExecutable(path.join(repoRoot, "dist", "entry.js"));
syncPeekabooSubmodule(repoRoot);
if (!shouldApplyPnpmPatchedDependenciesFallback()) {
return;