Skip to content

feat(wpm): add expose and unexpose subcommands for bin/ entry links (Fixes #1835) - #1844

Open
caomengxuan666 wants to merge 1 commit into
mainfrom
feat/1835-wpm-expose-unexpose
Open

caomengxuan666 wants to merge 1 commit into
mainfrom
feat/1835-wpm-expose-unexpose

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1835.

Summary

  • Added wpm expose <package>... [--force] [--dry-run] [--json] and wpm unexpose <package>... [--dry-run] [--json] in src/commands/wpm.cpp:
    • wpm expose materializes an installed package's declared commands as entry links in <root>/bin (handling aliases, bundled packages without receipts, and --force / --dry-run / --json), reconciles intra-package declared links from the install receipt, and records the exposed entry links in the receipt.
    • wpm unexpose removes the package's declared <root>/bin entry links and drops them from the receipt's recorded destinations without removing the package payload, usr/bin shims, or receipt.
  • Wired expose / unexpose into print_usage(), dispatch(), and REGISTER_COMMAND help/examples.
  • Added unit test wpm_expose_and_unexpose_manage_bin_links_without_uninstalling in tests/unit/wpm/wpm_unit_test.cpp.

Verification

  • Built test-wpm with MSVC (cmake --preset test) and ran wpm.*: 91/91 passed.

@caomengxuan666

Copy link
Copy Markdown
Member Author

CAPTAIN 裁决:需拆分(本 PR 不直合)

复核结论(队长简报 review-wc-1844.md):本 PR 装了两个特性——

  • A 面(wpm 需要事后暴露/收回开关:已装包命令在 winuxcmd\bin 的补建与撤销(install -g 的正身) #1835 本体):wpm expose/unexpose 子命令 + receipt destinations 同步,机制成立,复用既有 entry-link 物化与错误文案键,无平行状态。
  • B 面(题外第二特性):declared intra-package links(links.json 去重归档)子系统约 350 行,改动 install / uninstall / links rebuild 三条主路径与 receipt 格式(新增 links 字段),且零钉;正文仅以 expose 条目下从句带过,未披露三条主路径与 receipt 格式的变更。

按单一机制纪律,裁决拆分:

  1. A 面单独成 PR 修 wpm 需要事后暴露/收回开关:已装包命令在 winuxcmd\bin 的补建与撤销(install -g 的正身) #1835(本 PR 只留 A 面、或新开 PR,均可)。合入前补 A 面缺口钉:无 receipt 随包包的 expose(单内头号场景)、幂等(重复 expose/unexpose)、--force 覆盖既有目标、别名 expose。
  2. B 面另立 PR,挂 niu-git#23 配对单,补齐钉后再审:links.json 解析、声明链接 install 物化、receipt links 字段往返、rebuild 对账、uninstall 清理、硬链接回退警告。
  3. unexpose 命名空间删除语义须先裁决:现实现按声明名删 bin\ 下同名文件,不校验该文件确为本包链接(expose 侧有 same_file 校验、unexpose 侧无),与 uninstall 只删 receipt 记录 destinations 的语义不一致;同名文件若已被另一包或用户替换,unexpose 会误删。拆分时或加守卫,或在正文论证 name-namespace 契约并经队长确认。
  4. 正文须补 B 面完整披露(install 失败条件、receipt 格式、rebuild/uninstall 语义变更)与删除节(本 PR 实际 −6、近乎纯增量;B 面须交代 install 期此前对 links.json 整文件忽略的旧行为去向)。

拆分后队长阶段在 X299 按 #1835 验收三条逐条实机跑(已装未暴露包补暴露后命令可运行;撤销后链接消失而 wpm list / receipt 仍示已安装;普通 install/uninstall 不回归),随包无 receipt 场景一并复现。#1835 保持 open。

@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain update: the A side of this PR (expose/unexpose + receipt
destination sync) has been split out and relayed as #2012 per
the owner's direction, with the unexpose ownership guard from the r1
review implemented (a bin name is deleted only when verifiably this
package's link - payload identity, or the receipt record when the
payload is gone; foreign files are skipped and reported) and the
A-side pin gaps filled (bundled no-receipt, idempotency, --force,
alias, guard).

This PR is therefore re-scoped to the B side only: the declared
intra-package links subsystem (links.json reconcile, the receipt
links field, install/uninstall/rebuild declared-set handling, the
hardlink-fallback warning). Please rebase onto main, drop the
expose/unexpose hunks (they land via the relay), and add the B-side
pins the r1 review listed (declared-link install materialization,
receipt links round-trip, rebuild reconcile, uninstall cleanup,
hardlink fallback warning) before re-requesting review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wpm 需要事后暴露/收回开关:已装包命令在 winuxcmd\bin 的补建与撤销(install -g 的正身)

1 participant