Commit 8dca647
authored
Reworks the diff finder (#195)
This PR attempts to rework how the diff finder works to cover those two
improvements:
- The diff_finder now accepts an array of roots. This makes it possible
to restrict the crawling to the few folders we know may contain
workspaces, based on the prefixes passed to the `workspaces` key. For
example if we have a `"workspaces": ["packages/**"]` field, then we know
workspaces can only be in the `workspaces` folder.
- The diff_finder now stores an additional cache entry type called
Error, which indicates that a file returned an error when calling
`get_file_data`. The errors aren't immediately returned anymore during
crawling - instead, the consumer is expected to report them as it reads
the results from the diff_finder. This allows us to filter the results
useful to us before reporting errors, fixing the issue where Yarn was
reporting errors on malformed `package.json` files that weren't actually
part of the project's workspaces.
Another notable change is the attempt to switch to rkyv whenever
possible due to bincode [not being maintained
anymore](https://docs.rs/crate/bincode/latest). It makes the code more
complicated due to rkyv requiring
[boilerplate](https://github.com/rkyv/rkyv/blob/3b76edd96adf89b18ae06cdb2dd340886f724226/rkyv/examples/json_like_schema.rs#L6)
to support recursive types.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes filesystem diffing and persistence, and propagates changes
across crates.
>
> - **Diff finder redesign**: accepts `roots` to constrain scans, adds
`Error` cache entries, and renames `SaveState/SaveEntry` →
`CacheState/CacheEntry`; updates `ManifestFinder` and workspace
discovery to use rooted scanning and handle deferred errors
> - **Serialization migration**: replaces `bincode` with `rkyv` for
install state, lockfile, tree resolution, utils, primitives, semver, git
models, and switch manifest; adds required `Archive` derives and bounds
> - **Workspace detection**: computes roots from `workspaces` globs via
new `zpm_utils::Glob::prefix()` to limit crawl scope
> - **Macro enum enhancements**: supports `#[variant_struct_attr(...)]`,
per-variant `#[struct_attr(...)]`, and preserves field attributes in
generated structs
> - Minor config/dep updates: remove bincode deps/derives; add `rkyv`
deps; small API tweaks (e.g., `build::DiffFinder::new(root, roots,
state)`) and error variants cleanup
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
5f0ff2d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent ba5dbbc commit 8dca647
48 files changed
Lines changed: 563 additions & 337 deletions
File tree
- .claude
- packages
- zpm-config
- src
- zpm-git
- src
- zpm-macro-enum/src
- zpm-primitives
- src
- zpm-semver
- src
- zpm-switch
- src
- zpm-utils
- src
- zpm
- src
- manifest
- resolvers
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | | - | |
| 6 | + | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
0 commit comments