Keep copied source packages out of parent Git repositories

This commit is contained in:
gitea committed 2026-10-12 12:27:46 +08:00
1 parent 2654e1b870
commit fa304ca4dc
4 files changed
+33 -4

No files matched your search

+10 -1
View File
@@ -2,9 +2,18 @@ import { describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { homebrewFormulaPrefix, installHomebrewSkill } from "./update.js";
import { handleUpdateCommand, homebrewFormulaPrefix, installHomebrewSkill } from "./update.js";
describe("Homebrew skill refresh", () => {
test("a copied source package cannot update its parent application's Git repository", async () => {
const dir = mkdtempSync(join(tmpdir(), "seal-source-update-test-"));
try {
await expect(handleUpdateCommand({ appRoot: dir, entryFile: join(dir, "src", "cli.ts") }))
.rejects.toMatchObject({ exitCode: 13 });
expect(existsSync(join(dir, "bun.lock"))).toBe(false);
} finally { rmSync(dir, { recursive: true, force: true }); }
});
test("uses the upgraded formula executable even when PATH contains an older standalone CLI", () => {
const dir = mkdtempSync(join(tmpdir(), "seal-brew-skill-test-"));
const originalPath = process.env.PATH;
+5 -1
View File
@@ -1,4 +1,4 @@
import { chmodSync, mkdirSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
import { chmodSync, existsSync, mkdirSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
import { basename, dirname, isAbsolute, join, relative } from "node:path";
import { spawn, spawnSync } from "node:child_process";
import { isCompiledBinary } from "../../core/runtime.js";
@@ -131,6 +131,10 @@ export async function handleUpdateCommand(runtime: CliRuntime, options: UpdateOp
return;
}
// Source updates must operate on this package's checkout, never a parent app's repository.
if (!existsSync(join(runtime.appRoot, ".git"))) {
throw validationError("当前源码安装目录不是 seal-use 的 Git 工作区。请使用发行版二进制,或从 seal-use 仓库通过 npm link 安装。");
}
try {
runCommand("git", ["-C", runtime.appRoot, "pull", "--ff-only"]);
} catch (err) {