Don't blow away package manifest when updating#20
Merged
Conversation
mcmire
commented
Jul 20, 2022
120a622 to
e23c2e2
Compare
When we read a package manifest, we need a representation of the manifest that we can make reliable assumptions about. To do this, we disregard fields that we don't care about and we fill in default values for fields that we _do_ care about but haven't been explicitly provided. The problem is that when updating the version of a package, we are using a modified version of this representation of the manifest. That isn't good, because it means that the package's manifest ends up getting fundamentally changed. This commit fixes this by storing the original representation of the manifest when it is read. This representation is then used when the version is updated instead of the "parsed" representation. This does make the parsed representation immediately out of date, but that doesn't really matter.
e096a90 to
e8ccf1a
Compare
mcmire
commented
Aug 17, 2022
| readonly [PackageManifestFieldNames.Version]: SemVer; | ||
| readonly [PackageManifestFieldNames.Private]: boolean; | ||
| readonly [PackageManifestFieldNames.Workspaces]: string[]; | ||
| } & Readonly< |
Contributor
Author
There was a problem hiding this comment.
This got missed in a previous commit.
| [PackageManifestFieldNames.Version]: new SemVer('1.2.3'), | ||
| [PackageManifestFieldNames.Private]: false, | ||
| [PackageManifestFieldNames.Workspaces]: [], | ||
| [PackageManifestDependenciesFieldNames.Bundled]: {}, |
Contributor
Author
There was a problem hiding this comment.
This got missed in a previous commit, too.
| "dependencies": { | ||
| "@metamask/action-utils": "^0.0.2", | ||
| "@metamask/utils": "^2.0.0", | ||
| "@metamask/utils": "^2.1.0", |
Contributor
Author
There was a problem hiding this comment.
Bumped because we're using isPlainObject, which appeared in 2.1.0.
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.
When we read a package manifest, we need a representation of the
manifest that we can make reliable assumptions about. To do this, we
disregard fields that we don't care about and we fill in default values
for fields that we do care about but haven't been explicitly provided.
The problem is that when updating the version of a package, we are using
a modified version of this representation of the manifest. That isn't
good, because it means that the package's manifest ends up getting
fundamentally changed.
This commit fixes this by storing the original representation of the
manifest when it is read. This representation is then used when the
version is updated instead of the "parsed" representation. This does
make the parsed representation immediately out of date, but that doesn't
really matter.
Fixes #18.