Unicorn 4 will feature full support for Sitecore PowerShell Extensions (SPE) to perform Unicorn actions. If you’ve ever wanted deep programmatic control over Unicorn (for example “I want to sync Foundation.*”), or if you’ve got an existing deployment process that’s already using SPE Remoting to perform deployment tasks - this is for you.
To use Unicorn cmdlets in SPE, all that is necessary is to install the SPE package along with Unicorn. Unicorn 4 comes with configuration that remains quiescent until SPE is installed that will automatically enable the Unicorn cmdlets. In case that’s not clear enough: SPE is an optional addition and will not be required to use Unicorn 4.
So what can we do with Unicorn cmdlets for SPE?
The result of
Get-UnicornConfiguration is an array of
IConfiguration objects, which you can spelunk (e.g. with their
Name property) or pass to other cmdlets. Configurations are read only.
Sync cmdlets make use of Write-Progress to provide a similar progress bar experience to the Control Panel, albeit a bit less responsive.
Sometimes you want to only sync a portion of a configuration. You can do that with PowerShell using
The cmdlet to reserialize is called
Reserialize is not an approved verb for a cmdlet :)
Sometimes you want to only reserialize a portion of a configuration. You can do that with PowerShell using
You can also dump out the raw YAML for an item - or items. The output of
ConvertTo-RainbowYaml is either a string or array of strings depending on how many items were passed to it. Note that unless
-Raw is specified, the default field formatters and excluded fields Unicorn ships with are used. These are non-customizable and do not follow Unicorn defaults if changed.
This capability enables casual use of YAML serialization without having to use Unicorn or set up a configuration. It’s not a good solution for general purpose synchronization though simply because the nuances of storing trees of items in files are many. Very many. But I’m curious what uses people will find for this :)
In Rainbow the
IItemData interface is the internal unit of an Item. The
ConvertFrom-RainbowYaml cmdlet converts raw YAML string(s) into
IItemData which you can then spelunk as objects or deserialize as needed.
To deserialize items, use
Import-RainbowItem which takes
IItemData items in and deserializes them into the Sitecore database. No comparison is done before deserialization, which makes this a bit slower than a full Unicorn sync.
As a shorthand
Import-RainbowItem also accepts YAML strings, however as
IItemData can represent any sort of item, it is not limited only to deserializing YAML-sourced items.
Does this mean the existing PowerShell Remote API is obsolete?
No. The existing PowerShell API uses Windows PowerShell to provide remote syncing capability and does not require installing Sitecore PowerShell. They serve different parallel purposes, and both are here to stay.
I’ll be releasing a beta once I finish the features I have planned. Yep, there’s at least one more ;)