Repository navigation
Add pks rm and bump the version to 0.6.0 - #70
Merged
Merged
Conversation
pks rm to delete a pack and the references to itpks rm and bump the version to 0.6.0
Contributor
`write_package_todo_to_disk` and `delete_package_todo_from_disk` unwrapped every IO result, so a failed write or delete panicked. `pks rm` rewrites or deletes a single pack's todo file and should report a failure like any other error, so both now return a `Result`, and `write_violations_to_disk` passes it up to `update`. An `update` that cannot write a todo file now prints the error and exits 2, where it used to panic and exit 101. The `File::create` before each write is gone too: `fs::write` creates the file itself.
`pks rm packs/foo` deletes the pack's directory after removing it from other packs' `dependencies`, `ignored_dependencies` and `visible_to` lists, and dropping the violations their package_todo.yml files record on it. Deleting only the directory leaves `validate` failing on dependencies that name a missing pack (packwerk-extensions rejects such `visible_to` entries too), and `check` failing on stale todo entries. Each package.yml it changes is rewritten through `write_pack_to_disk`, as `add-dependency` does, so the file loses its comments and takes pks's key order. #60 edits these lists as text instead, and once it lands `rm` can do the same. Unless given `--force`, it refuses while other packs may still use the pack, because once the pack is gone `check` cannot see their references to it: - Other packs reference its constants. Each reference is listed as file:line:column and constant. - It has Ruby files under lib/, other than lib/tasks/, that the Zeitwerk resolver doesn't know because they are outside the autoload roots. Gem-style packs keep their code there. Without this check, a widely used gem pack in a large app was deleted without objection. The experimental parser reads definitions from every file, so the check is skipped with it. The root pack can't be removed, and neither can a pack with other packs nested inside it, even with `--force`, since the nested packs would go without their references being removed. Fixes #16.
`pks rm` is a new command, and pre-1.0 a new feature wants a minor bump. Once this merges, auto-release.yml tags and releases v0.6.0, since Cargo.toml's version has no tag yet. Retitle `## Unreleased` to `## 0.6.0`, the heading dist takes the release notes from, and add an entry for the one user-visible change in this release that didn't have one: the warm-cache speedup from skipping files that haven't changed (#59).
dduugg
force-pushed
the
pks-rm-subcommand
branch
from
October 11, 2026 20:13
320accf to
e09f637
Compare
Contributor
Author
|
Thanks for the nudge. I've rebuilt this on The cost is that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pks rm packs/foodeletes a pack along with what other packs say about it. It removes the pack from theirdependencies,ignored_dependenciesandvisible_tolists, drops the violations theirpackage_todo.ymlfiles record on it (deleting a todo file that ends up empty), and then deletes the pack's directory. Deleting the directory by hand leavespks validatefailing on dependencies that name a missing pack (packwerk-extensions rejects suchvisible_toentries too) andpks checkfailing on stale todo entries.Unless given
--force, it refuses to remove a pack that other packs may still use, because once the pack is gonecheckcan't see their references to it:file:line:columnand the constant.lib/(other thanlib/tasks/) that are outside the autoload roots, the Zeitwerk resolver never learns their constants, so references to them can't be checked. Gem-style packs keep their code there, and without this check a gem pack used across a large app was deleted without objection. The experimental parser reads definitions from every file, so the check is skipped with it.The root pack can't be removed, and neither can a pack with other packs nested inside it, even with
--force.This PR also bumps the version to 0.6.0, so merging it releases v0.6.0.
Fixes #16.
Release
auto-release.ymldispatches the v0.6.0 release once this lands on main, sinceCargo.toml's version has no tag yet. 0.6.0 is a minor bump becausepks rmis a new feature.## Unreleasedin the CHANGELOG is now## 0.6.0, the heading dist takes the release notes from.How this relates to #60
package.ymlthatrmchanges is rewritten throughwrite_pack_to_disk, asadd-dependencyandcheck-unused-dependencies --auto-correctdo on main, so the file loses its comments and takes pks's key order. Preserve comments when auto-correcting unused dependencies #60 edits these lists as text instead, and once it landsrmcan do the same.tests/rm_test.rshas two ignored tests for that: a removal that keeps comments and key order, and the warning when a flow-style list has to be rewritten. Both fail today and pass against a build ofrmthat uses Preserve comments when auto-correcting unused dependencies #60's edit. Preserve comments when auto-correcting unused dependencies #60 should switchrmover and enable them before it merges.Commits
package_todo.ymlwrites return errors instead of panicking, sormcan report them.rm.Design notes
pks updatewould also pick up any unrelated drift.package.ymlwith it, and thenrmcould no longer find the pack to clean up the references to it.Who this affects
pks rmis new.pks updatereports a failure to write a todo file as an error and exits 2, where it used to panic.Test plan
tests/rm_test.rs: a removal that touches every kind of reference, checked byte for byte and followed by passingvalidateandcheck; refusals for references, for unresolvablelib/code, and for both at once, each leaving the fixture unchanged;--force; the root pack; nested packs; an unknown pack; and a trailing slash.lib/tasks/exclusion fails a test.validatepassed in both.checkmatched its baseline in one, and in the other reported the leftover references against the pack that defines an enclosing namespace, which is how the resolver already treats a missing constant.pks --versionprintspks 0.6.0, andCHANGELOG.mdhas the exact## 0.6.0heading thatauto-release.ymlchecks for.cargo test(333 passed, 2 ignored), fmt, and clippy with-Dwarnings.