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

@ -9,7 +9,7 @@ CI는 self-hosted **`linux-builder`** 러너(host 모드)에서 돈다. host 모
| 필요 | 확인 | 없을 때 |
|---|---|---|
| Node 20 이상 | `node -v` | `fnm install 22 && fnm default 22` 후 러너 재시작 |
| Node 22.6 이상 | `node -v` | `fnm install 22 && fnm default 22` 후 러너 재시작 |
| pnpm 10 | `pnpm -v` | `corepack enable && corepack prepare pnpm@10.5.2 --activate` |
| git, curl, tar, python3 | `command -v` | 배포판 패키지로 설치 |
@ -35,7 +35,7 @@ git.chanpaca.net/<owner>/designpaca
| 이름 | 용도 | 발급처 |
|---|---|---|
| `NPM_TOKEN` | npmjs 배포 | npmjs.com → Access Tokens → **Automation** 타입 |
| `NPM_TOKEN` | npmjs 배포 (**태그 릴리스 필수** — 없으면 `publish-npm.sh` 가 exit 1) | npmjs.com → Access Tokens → **Automation** 타입 |
| `FORGEJO_NPM_TOKEN` | 사설 레지스트리 미러 | Forgejo → 설정 → 애플리케이션 → 액세스 토큰 (`write:package` 권한) |
| `RELEASE_TOKEN` | 릴리스 생성·자산 업로드 | Forgejo 액세스 토큰 (`write:repository`) |
| `CF_API_TOKEN` | Cloudflare Pages 배포 | Cloudflare → API Tokens → **Edit Cloudflare Workers** 템플릿 |
@ -47,8 +47,8 @@ git.chanpaca.net/<owner>/designpaca
|---|---|---|
| `FORGEJO_NPM_OWNER` | `yunchan` | 사설 npm 패키지 소유자 |
> **시크릿이 없어도 파이프라인은 죽지 않는다.** `publish-npm.sh`는 `FORGEJO_NPM_TOKEN`이 없으면 미러를 건너뛰고,
> 릴리스 스텝은 `CF_API_TOKEN`이 없으면 페이지 배포를 건너뛴다. 하나씩 붙여가며 굴릴 수 있다.
> **`NPM_TOKEN` 은 필수다.** 없으면 `publish-npm.sh` 가 exit 1 로 멈춘다. 나머지는 선택이다 — `publish-npm.sh`는 `FORGEJO_NPM_TOKEN`이 없으면 미러를 건너뛰고,
> 릴리스 스텝은 `CF_API_TOKEN`이 없으면 페이지 배포를 건너뛴다.
## 3. 릴리스 절차
@ -151,7 +151,7 @@ SSH 키는 이미 Forgejo 에 등록돼 있어(`encep-win`) 토큰도 비밀번
| # | 증상 | 원인 |
|---|---|---|
| 1 | `exit 126` / 허가 거부 | Windows 에서 만든 `.sh` 가 mode 100644 로 커밋됐다. `git update-index --chmod=+x` + 워크플로에서 `bash script` 로 호출 |
| 2 | `Node 20 이상이 필요하다 (현재 v18)` | 러너에 Node 18 뿐. fnm 으로 22 설치. **그리고 `verify-node.sh` 가 Node 가 *없을 때만* 대체 경로를 훑고 있었다** — 낡았을 때도 찾도록 고침 |
| 2 | `Node 20 이상이 필요하다 (현재 v18)` (당시 메시지. 현재 기준은 22.6 이상) | 러너에 Node 18 뿐. fnm 으로 22 설치. **그리고 `verify-node.sh` 가 Node 가 *없을 때만* 대체 경로를 훑고 있었다** — 낡았을 때도 찾도록 고침 |
| 3 | `ERR_MODULE_NOT_FOUND: picocolors` | tarball 을 풀어 `node dist/index.js` 를 직접 불렀다. 그건 npx 경로가 아니다. 임시 프로젝트에 `npm i` 후 실행하도록 교체 |
| 4 | 초록불인데 `# pass 0` | 빌드보다 테스트가 먼저라 CLI 테스트 6개가 전부 SKIP. 순서를 바꾸고 **SKIP 이 있으면 실패시키는 단계**를 넣었다 |