-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't blow away package manifest when updating #20
Conversation
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
readonly [PackageManifestFieldNames.Name]: string; | ||
readonly [PackageManifestFieldNames.Version]: SemVer; | ||
readonly [PackageManifestFieldNames.Private]: boolean; | ||
readonly [PackageManifestFieldNames.Workspaces]: string[]; | ||
} & Readonly< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got missed in a previous commit.
@@ -105,11 +171,6 @@ export function buildMockManifest( | |||
[PackageManifestFieldNames.Version]: new SemVer('1.2.3'), | |||
[PackageManifestFieldNames.Private]: false, | |||
[PackageManifestFieldNames.Workspaces]: [], | |||
[PackageManifestDependenciesFieldNames.Bundled]: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got missed in a previous commit, too.
@@ -23,7 +23,7 @@ | |||
}, | |||
"dependencies": { | |||
"@metamask/action-utils": "^0.0.2", | |||
"@metamask/utils": "^2.0.0", | |||
"@metamask/utils": "^2.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumped because we're using isPlainObject
, which appeared in 2.1.0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
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.