spfx project upgrade fails when .yo-rc.json & package.json are out of sync #1408
-
DescriptionThe spfx project upgrade command returned a message that project doesn't need to be upgraded despite the package.json references to old versions of @microsoft/sp* packages Steps to reproduceIn an spfx project, the .yo-rc.json file contained current spfx version: {
"@microsoft/generator-sharepoint": {
"isCreatingSolution": true,
"environment": "spo",
"version": "1.10.0",
"libraryName": "library",
"libraryId": "db85a7f3***",
"packageManager": "npm",
"componentType": "extension",
"extensionType": "ApplicationCustomizer"
}
} The package.json file contained references to older versions {
"dependencies": {
"@microsoft/sp-application-base": "1.9.1",
"@microsoft/sp-core-library": "1.9.1",
"@microsoft/sp-dialog": "1.9.1",
}
} Expected resultI expected a report of changes to make to upgrade the project. Actual result"Error: Project doesn't need to be upgraded" EnvironmentWin10, PWSH |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 5 replies
-
Good catch @pschaeflein. I'd suggest we change detecting the project version to use the package version instead of .yo-rc.json which is more reliable. Agreed @VelinGeorgiev @garrytrinder? |
Beta Was this translation helpful? Give feedback.
-
Agreed, It maybe worth considering returning a message in the upgrade output to state that the |
Beta Was this translation helpful? Give feedback.
-
I am ok with this. |
Beta Was this translation helpful? Give feedback.
-
So this seems to be harder than it seems to do correctly. Some versions of SPFx use different versions of the core packages, eg.: 1.3.2
1.1.3:
1.1.1:
1.0.2
1.0.1
Right now, we use the Event by looking at multiple packages and adjusting the order to something like this:
It would still return incorrect version v1.0.1 where sp-webpart-base is v1.0.0 as well as some other version that don't have corresponding package versions. With such inconsistencies in place, I'd say that we keep what we have because it seems like the most reliable way of detecting project version. What do you think @pschaeflein @garrytrinder @VelinGeorgiev? |
Beta Was this translation helpful? Give feedback.
-
Great analysis @waldekmastykarz 👏🏻 I agree that we should keep the current check in place based on your findings. |
Beta Was this translation helpful? Give feedback.
-
If I run the job today, do I care if the project is 1.1.1 or 1.1.3? I mean, it ends up as 1.10 afterwards, right? Not sure if these old, incremental differences matter. |
Beta Was this translation helpful? Give feedback.
-
They actually might. The way upgrade guidance is done is that v1.8 only knows how to upgrade v1.7 project. It doesn't know what's been done in the previous versions. So theoretically, if there is anything relevant done between v1.1.1 and v1.1.3 the upgrade guidance wouldn't contain these changes and you could end up with a broken project. That's theory. I've never looked at what's the reality of this because the mechanism worked so far, until you get to an issue like you mentioned :) How about an alternative: before we start the upgrade logic, we add extra logic to verify the project's integrity and if there is anything out of the ordinary, we communicate that first. Would that address the issue you mentioned @pschaeflein? |
Beta Was this translation helpful? Give feedback.
-
On a different note @pschaeflein, do you know how your project ended up in this state (meaning different version in .yo-rc.json and package.json)? |
Beta Was this translation helpful? Give feedback.
They actually might. The way upgrade guidance is done is that v1.8 only knows how to upgrade v1.7 project. It doesn't know what's been done in the previous versions. So theoretically, if there is anything relevant done between v1.1.1 and v1.1.3 the upgrade guidance wouldn't contain these changes and you could end up with a broken project. That's theory. I've never looked at what's the reality of this because the mechanism worked so far, until you get to an issue like you mentioned :)
How about an alternative: before we start the upgrade logic, we add extra logic to verify the project's integrity and if there is anything out of the ordinary, we communicate that first. Would that address th…