After the recently preview release of the SPFx version 1.18 I think it’s a good idea to give some space to an awesome tool that helps a lot in the upgrading process, this tool is: CLI for Microsoft 365
This tool can be installed on any platform (Windows, macOS or Linux) using NPM or yarn and it allows you to manage your Microsoft 365 tenant and SharePoint Framework projects.
Installation
To use the tool you have to install it globally using, for NPM:
npm i -g @pnp/cli-microsoft365
or using yarn:
yarn global add @pnp/cli-microsoft365
Login
To manage the your Microsoft 365 tenant or SharePoint project you have to login using…can you imagine? The login command!
m365 login
Ok, but how do I upgrade an SPFx project?
Well, I think this is the important section for which you started read this post so here we go.
Using the CLI for Microsoft 365 it can give you a list of code migrations to upgrade from the current SPFx version to a target one of your choice.
The code for the upgrade is the following:
m365 spfx project upgrade [options]
There are many available options, the principal one is the --toVersion (or -v) which specify the target version of the project, for example supposing that you have an SPFx project version 1.16 that you want to migrate to the 1.17 version you can use the following line of code:
m365 spfx project upgrade --toVersion 1.17.0
There are plenty of options, including the possibility to have the output result as json, text, csv and markdown using --output or you can have the report result stored in a specific file using --outputFile.
If you are interested in a more in depth documentation, or want to check the others options of the upgrade command, you can find it here.
Hope this helps!

Leave a comment