fix(ci): 배포 검증 상태를 격리한다
All checks were successful
ci / build (push) Successful in 33s

This commit is contained in:
Yun Chan 2026-08-24 14:14:29 +09:00
parent 4d813420dc
commit cb3c323c9f
7 changed files with 54 additions and 20 deletions

View file

@ -1,17 +1,27 @@
import os from "node:os";
import path from "node:path";
/** designpaca 자체 상태 디렉터리 (~/.designpaca) */
export function stateDir(home = os.homedir()): string {
return path.join(home, ".designpaca");
/**
* CI·테스트처럼 실제 사용자 설치 기록과 분리해야 하는 실행은 전용 상태 디렉터리를 쓴다.
* 사용자 설치 경로의 기준 홈은 바꾸지 않고, designpaca 자체 상태만 격리한다.
*/
function isolatedStateDir(): string | undefined {
const dir = process.env["DESIGNPACA_STATE_DIR"]?.trim();
return dir ? path.resolve(dir) : undefined;
}
export function manifestPath(home = os.homedir()): string {
/** designpaca 자체 상태 디렉터리 (~/.designpaca) */
export function stateDir(home?: string): string {
if (home) return path.join(home, ".designpaca");
return isolatedStateDir() ?? path.join(os.homedir(), ".designpaca");
}
export function manifestPath(home?: string): string {
return path.join(stateDir(home), "manifest.json");
}
/** 업데이트 확인 캐시 */
export function updateCachePath(home = os.homedir()): string {
export function updateCachePath(home?: string): string {
return path.join(stateDir(home), "update-check.json");
}

View file

@ -0,0 +1,23 @@
import assert from "node:assert/strict";
import os from "node:os";
import path from "node:path";
import { test } from "node:test";
import { manifestPath, stateDir, updateCachePath } from "../src/paths.ts";
test("DESIGNPACA_STATE_DIR 은 사용자 홈을 바꾸지 않고 상태 파일만 격리한다", () => {
const before = process.env["DESIGNPACA_STATE_DIR"];
const isolated = path.join(os.tmpdir(), "designpaca-isolated-state");
try {
process.env["DESIGNPACA_STATE_DIR"] = isolated;
assert.equal(stateDir(), path.resolve(isolated));
assert.equal(manifestPath(), path.join(path.resolve(isolated), "manifest.json"));
assert.equal(updateCachePath(), path.join(path.resolve(isolated), "update-check.json"));
const explicitHome = path.join(os.tmpdir(), "designpaca-explicit-home");
assert.equal(stateDir(explicitHome), path.join(explicitHome, ".designpaca"));
} finally {
if (before === undefined) delete process.env["DESIGNPACA_STATE_DIR"];
else process.env["DESIGNPACA_STATE_DIR"] = before;
}
});