Commit 78825ba
authored
Fixes #506. Alternative to #507.
## What changes for users
`mops install` (and any flow that runs `--lock check`) no longer fails
with `Mismatched number of resolved packages: N vs M` on projects whose
resolved deps include multiple aliases (e.g. `base`, `base@0`,
`base@0.16`) pinned to the same `name@version`. Previously the only
workaround was `--lock ignore`.
## Root cause
`getResolvedMopsPackageIds` returned a list with duplicates:
`resolvePackages()` keeps each alias as its own entry, then
`getPackageId` collapses the alias suffix via `getDepName`, so two
aliases pinning the same `name@version` produced the same id twice.
`mops.lock`'s `hashes` is keyed by packageId and naturally dedup'd, so
the count comparison in `checkLockFile` mismatched.
## Why this approach over #507
#507 dedupes only at the count comparison. This PR dedupes inside
`getResolvedMopsPackageIds`, which (a) makes the function's contract
match its name, and (b) stops sending duplicate ids to the canister's
`getFileHashesByPackageIds`. Downstream membership checks (`includes`,
`in`) were already dedupe-safe, so no other call site needed changes.
## Test plan
Added a regression fixture pinning `core` and `core@1` to `1.0.0` plus a
test asserting `mops install` exits clean and stderr doesn't contain the
mismatch error. Verified that reverting the fix makes the Jest test fail
with the expected error string.
1 parent 37bd049 commit 78825ba
4 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
74 | 95 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
0 commit comments