We've just published a new version of the Office 365 CLI with new commands for working with and managing Office 365 tenants and SharePoint Framework projects on any platform.
Manage Office 365 and SharePoint Framework projects on any platform
Office 365 CLI is a cross-platform CLI that allows you to manage various configuration settings of Office 365 and SharePoint Framework projects no matter which operating system or shell you use.
While building solutions for Office 365 expands beyond the Windows operating system, managing many of the platform settings is possible only through PowerShell on Windows. As more and more users work on non-Windows machines, it's inconvenient for them to have to use a Windows virtual machine to configure their tenants. With the Office 365 CLI you can configure your tenant no matter which operating system you use. Additionally, using the Office 365 CLI, you can manage your SharePoint Framework projects.
New version of Office 365 CLI - v1.4.0
Once again, we have no breaking changes in this release, but we do have a major addition to the Office 365 CLI's capabilities.
Upgrade SharePoint Framework projects
Starting from this release, you can use the Office 365 CLI to upgrade your SharePoint Framework projects to a newer version of the SharePoint Framework. Upgrading SharePoint Framework projects goes beyond installing new versions of the SharePoint Framework packages. Sometimes, it's necessary to update the project settings files, sometimes the components' manifests, sometimes the version of React used by the project, sometimes a combination of the above. So instead of having to investigate what needs to be changed in your project to upgrade it to a newer version of the SharePoint Framework, you can use the Office 365 CLI to have it do it for you.
To upgrade your project to the latest version of the SharePoint Framework supported by the Office 365 CLI, change the working directory to where your SharePoint Framework project is located and execute:
o365 spfx project upgrade --output md > report.md
This command will analyze your project and provide you with a Markdown report with all the findings required to upgrade your project.
If you want to upgrade your project to a specific version of the SharePoint Framework, you can specify the version as well:
o365 spfx project upgrade --toVersion 1.5.1 --output md > report.md
Important:: The Office 365 CLI doesn't change your SharePoint Framework project files. Instead, it analyzes your project and provides you with a report detailing the necessary changes you have to apply yourself, to upgrade your project.
With the release of this command, the Office 365 CLI is no longer focusing exclusively on managing Office 365 tenants. We hope that you find this addition helpful, and don't hesitate to reach out to us if you have feedback or ideas for other useful commands for managing projects.
For more information about upgrading SharePoint Framework projects using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Check files in and out
As a part of your deployment automation, you might want to provision some files, such as assets or documents. Depending how the versioning settings on the target document library are configured, files might required to be checked in before they can be used. For this release of the Office 365 CLI, Velin Georgiev contributed commands to check files in and out.
To check in a file, execute:
spo file checkin --webUrl https://contoso.sharepoint.com/sites/project-x --fileUrl '/sites/project-x/documents/Test1.docx'
To check out a file before updating it, execute:
spo file checkout --webUrl https://contoso.sharepoint.com/sites/project-x --fileUrl '/sites/project-x/documents/Test1.docx'
For more information about working with files using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
In some cases, when automating deployment of SharePoint solutions, you might need to rename a folder. This might be the case for example, if you need to provision a new data structure, but don't want to lose any of the previously created content. Velin Georgiev extended the Office 365 CLI with the ability to rename folders.
To rename a folder using the Office 365 CLI, execute:
spo folder rename --webUrl https://contoso.sharepoint.com/sites/project-x --folderUrl '/Shared Documents/My Folder 1' --name 'My Folder 2'
For more information about working with folders using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
Retrieving and updating list items
List items are one of the core building blocks in SharePoint. They can store regular content but also application settings or log information. Previously, using the Office 365 CLI, you could add or remove list items. For this release, Mark Powney contributed commands that allow you to retrieve and update a list item.
To get a list item, execute:
spo listitem get --listTitle "Demo List" --id 147 --webUrl https://contoso.sharepoint.com/sites/project-x
To update a list item, execute:
spo listitem set --contentType Item --listTitle "Demo List" --id 147 --webUrl https://contoso.sharepoint.com/sites/project-x --Title "Demo Item"
For more information about working with list items using the Office 365 CLI, see the documentation at aka.ms/o365-cli.
This release wouldn't be possible without the help of (in alphabetical order) Vincent Biret, Andrew Connell, Velin Georgiev and Mark Powney.
Thank you all for the time you chose to spend on the Office 365 CLI and your help to advance it!
Recently, we've been discussing and researching a couple of things.
Setup script for the PnP SharePoint Starter Kit
Recently, the SharePoint PnP team released the SharePoint Starter Kit: an end-to-end solution illustrating how to use the latest capabilities to build a modern intranet on Office 365. This starter kit will keep evolving as new capabilities are added to Office 365.
To help you setup the solution in your tenant, the PnP team released a setup script based on PnP PowerShell. Due to the current limitations of PnP PowerShell this script can be used only on Windows.
What if we had an equivalent script built in bash, using the Office 365 CLI which you could use on any platform?
I've already started working on this script in a separate repo. The basic structure is almost in place and ready for external contributions. Would you be interested in helping out with it?
More commands, what else
Office 365 is evolving and new capabilities are being released every day. With the Office 365 CLI we aim to help you manage your tenant on any platform in a consistent way, no matter which part of Office 365 you interact with. So far, we barely scratched the surface with what's possible in Office 365. In the upcoming versions of the Office 365 CLI, you can expect us to add more commands across the different workloads in Office 365.
Try it today
Get the latest release of the Office 365 CLI from npm by executing in the command line:
npm i -g @pnp/office365-cli
If you need more help getting started or want more details about the commands, the architecture or the project, go to aka.ms/o365cli. If you see any room for improvement, please, don't hesitate to reach out to us either on GitHub, on twitter with the #office365cli hashtag or on gitter.