Sitecore CLI, Sitecore's command line tool, will be installed on macOS this time. This is because Sitecore CLI also runs on macOS since it is provided as a command that runs on PowerShell Core and .NET Core 3.1 base.
Installation in a Windows environment has already been introduced in the following page.
Install
PowerShell must be installed in order to use the Sitecore CLI. If you have already installed PowerShell, you can skip this step. This time, since we will install using Homebrew, please check the official website for Homebrew and install it.
Installing PowerShell for macOS
PowerShell installation is automatically set up with a single command line if homebrew is already installed. Open a terminal and execute the following command
brew install powershell --cask
After installation is complete, verify that it starts with the following command
pwsh
Installing .NET Core 3.1
Next, install .NET Core 3.1. Download the installer from the following site and install it.
After installation, dotnet commands may not work because the path is not followed. To get it to work, add a symbolic link. Note that on my macOS, I installed the x64 binary, so I ran the following commands.
sudo ln -s /usr/local/share/dotnet/x64/dotnet /usr/local/bin
Install Sitecore CLI
From here, we will make it available on a per-project basis, just as we did with the previous installation. First, move the directory (if it does not exist, create it).
cd Projects/SampleDemo
First, create a definition file.
dotnet new tool-manifest
The next step is to set up the nuget gallery, which can be omitted if it has already been done previously.
dotnet nuget add source -n Sitecore https://sitecore.myget.org/F/sc-packages/api/v3/index.json
Finally, install the command
dotnet tool install Sitecore.CLI
The command is now installed. Initialize and install the plug-ins.
dotnet sitecore init
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Serialization
dotnet sitecore plugin add -n Sitecore.DevEx.Extensibility.Publishing
Login
Login to the actual Sitecore instance. Specify the edit server and authentication server. The following is a sample domain name.
dotnet sitecore login --cm https://shinharaxm-cm.sitecoredemo.com/ --auth https://shinharaxm-id.sitecoredemo.com/ --allow-write true
After executing the command, the browser will start and the login screen will appear.
After performing the login, the screen will switch to a confirmation screen asking if you wish to grant privileges.
If you allow it, the command line screen switches from the login confirmation mode, indicating that the login is complete.
We have confirmed that you can log in.
Operation check
We will actually execute the command and check the result. This time, since we have not prepared data to be imported, we will update the Index as follows.
dotnet sitecore index schema-populate
dotnet sitecore index rebuild
We were able to successfully execute the process on the command line for the remotely prepared Sitecore instance.
Summary
We have confirmed that Sitecore CLI is also available for macOS. If headless development is the main focus, it will be possible to develop on macOS and work with servers deployed in the cloud. NET Core is now available for macOS, and the tools are supported, so we can work on non-Windows platforms as well.