fix(core,cli): harden install engine and argument parsing

- Reject unknown flags with exit 2 and never write on --dry-run, even in a TTY
- Treat files already matching the new content as up to date after an interrupted update
- Remove unmodified orphan files from older versions, keep and report modified ones and shared paths
- Degrade malformed manifests instead of blocking installs; readIfExists only maps ENOENT/ENOTDIR to null
- Block downgrades from older CLIs (semver), honor uninstall --scope, dedupe targets, fix next-step output and table width
- Deeper package verification, LF normalization for .mjs, MIT LICENSE
This commit is contained in:
Yun Chan 2026-10-09 18:18:49 +09:00
parent 97f2c241e4
commit eecd3f03ff
29 changed files with 867 additions and 124 deletions

View file

@ -32,6 +32,10 @@ export interface InstallOutcome {
skipped: string[];
/** 덮기 전에 남긴 백업(.orig) */
backedUp?: string[];
/** 새 버전에서 빠져 지운 이전 설치 파일 */
removedStale?: string[];
/** 새 버전에서 빠졌지만 수정돼 있어 남긴 파일 */
keptStale?: string[];
blocked?: string;
}
@ -68,6 +72,8 @@ export async function runInstall(opts: InstallOptions): Promise<InstallOutcome[]
written: res.written.length,
skipped: res.skipped,
backedUp: res.backedUp,
removedStale: res.removedStale,
keptStale: res.keptStale,
});
}
return outcomes;
@ -90,6 +96,14 @@ export function printOutcomes(outcomes: InstallOutcome[], dryRun = false): void
console.log(warn(` 기존 파일을 덮기 전에 백업해 두었습니다:`));
for (const b of fold(o.backedUp)) console.log(dim(` ${tildify(b)}`));
}
if (o.removedStale && o.removedStale.length > 0) {
console.log(info(` 새 버전에서 빠진 파일 ${o.removedStale.length}개를 제거했습니다:`));
for (const r of fold(o.removedStale)) console.log(dim(` ${tildify(r)}`));
}
if (o.keptStale && o.keptStale.length > 0) {
console.log(warn(` 새 버전에서 빠졌지만 수정돼 있어 남겨 두었습니다 (uninstall --force 로 지울 수 있습니다):`));
for (const k of fold(o.keptStale)) console.log(dim(` ${tildify(k)}`));
}
}
}