fix: honor --dry-run in update and uninstall

This commit is contained in:
Yun Chan 2026-09-14 19:53:20 +09:00
parent 6229538d29
commit 744cb36d74
9 changed files with 113 additions and 23 deletions

View file

@ -22,7 +22,13 @@ after(async () => {
function run(args: string[]): string {
return execFileSync(process.execPath, [CLI, ...args, "--no-update-check"], {
encoding: "utf8",
env: { ...process.env, HOME: home, USERPROFILE: home, FORCE_COLOR: "0" },
env: {
...process.env,
HOME: home,
USERPROFILE: home,
FORCE_COLOR: "0",
DESIGNPACA_STATE_DIR: path.join(home, ".designpaca"),
},
});
}
@ -58,6 +64,52 @@ test("알 수 없는 대상은 종료 코드 2 로 거부한다", { skip: !built
);
});
test("update --dry-run 은 파일도 매니페스트도 건드리지 않는다", { skip: !built }, async () => {
run(["install", "-t", "claude-code", "-s", "user", "-y"]);
const manifestFile = path.join(home, ".designpaca", "manifest.json");
const skillMd = path.join(home, ".claude", "skills", "designpaca", "SKILL.md");
// 업데이트 대상이 있는 상태를 만든다
const manifest = JSON.parse(await fs.readFile(manifestFile, "utf8"));
manifest.installs[0].version = "0.0.1";
await fs.writeFile(manifestFile, JSON.stringify(manifest, null, 2) + "\n", "utf8");
const manifestBefore = await fs.readFile(manifestFile, "utf8");
const skillBefore = await fs.readFile(skillMd, "utf8");
const statBefore = await fs.stat(skillMd);
const out = run(["update", "--dry-run"]);
assert.ok(out.includes("업데이트 계획"));
assert.ok(out.includes("설치 계획"));
assert.equal(await fs.readFile(manifestFile, "utf8"), manifestBefore);
assert.equal(await fs.readFile(skillMd, "utf8"), skillBefore);
const statAfter = await fs.stat(skillMd);
assert.equal(statAfter.mtimeMs, statBefore.mtimeMs);
// 대조군: 실제 update 는 반영돼야 한다
run(["update"]);
const manifestAfter = JSON.parse(await fs.readFile(manifestFile, "utf8"));
assert.equal(manifestAfter.installs[0].version, run(["--version"]).trim());
run(["uninstall", "-y"]);
});
test("uninstall --dry-run 은 아무것도 지우지 않는다", { skip: !built }, async () => {
run(["install", "-t", "claude-code", "-s", "user", "-y"]);
const skillMd = path.join(home, ".claude", "skills", "designpaca", "SKILL.md");
const manifestFile = path.join(home, ".designpaca", "manifest.json");
const out = run(["uninstall", "--dry-run"]);
assert.ok(out.includes("제거 계획"));
await fs.access(skillMd);
const manifest = JSON.parse(await fs.readFile(manifestFile, "utf8"));
assert.equal(manifest.installs.length, 1);
run(["uninstall", "-y"]);
await assert.rejects(() => fs.access(skillMd));
});
test("설치 → doctor → 제거 왕복", { skip: !built }, async () => {
run(["install", "-t", "claude-code", "-s", "user", "-y"]);
const skillMd = path.join(home, ".claude", "skills", "designpaca", "SKILL.md");