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:
parent
97f2c241e4
commit
eecd3f03ff
29 changed files with 867 additions and 124 deletions
|
|
@ -1,14 +1,18 @@
|
|||
import { readManifest, removeInstall, tildify, type TargetId } from "@designpaca/core";
|
||||
import { dim, heading, ok, warn } from "../ui.ts";
|
||||
import { readManifest, removeInstall, tildify, type Scope, type TargetId } from "@designpaca/core";
|
||||
import { dim, heading, info, ok, warn } from "../ui.ts";
|
||||
|
||||
export async function runUninstall(opts: {
|
||||
targets?: TargetId[];
|
||||
/** 직접 지정했을 때만 넘긴다 — 기본값으로 걸러 내면 project 설치를 놓친다 */
|
||||
scope?: Scope;
|
||||
force?: boolean;
|
||||
dryRun?: boolean;
|
||||
}): Promise<number> {
|
||||
const manifest = await readManifest();
|
||||
const targets = manifest.installs.filter(
|
||||
(i) => !opts.targets || opts.targets.length === 0 || opts.targets.includes(i.target),
|
||||
(i) =>
|
||||
(!opts.targets || opts.targets.length === 0 || opts.targets.includes(i.target)) &&
|
||||
(opts.scope === undefined || i.scope === opts.scope),
|
||||
);
|
||||
|
||||
if (targets.length === 0) {
|
||||
|
|
@ -29,6 +33,10 @@ export async function runUninstall(opts: {
|
|||
);
|
||||
for (const p of res.keptModified.slice(0, 5)) console.log(dim(` ${tildify(p)}`));
|
||||
}
|
||||
if (res.sharedKept.length > 0) {
|
||||
console.log(info(` 다른 대상과 공유 중이라 남긴 파일 ${res.sharedKept.length}개 (그 대상을 제거할 때 함께 지워진다)`));
|
||||
for (const p of res.sharedKept.slice(0, 5)) console.log(dim(` ${tildify(p)}`));
|
||||
}
|
||||
if (res.refused.length > 0) {
|
||||
code = 1;
|
||||
console.log(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue