The spa creator (spa.exe) is fully documented and open source for you to integrate into your tool chain as much as you wish. It’s written in C# and the source is available as a zip below. Do note that it contains pngquant which may be optionally used to compress png images.
Creator source documentation – View the source code documentation.
Source code (Version 2) – Download the source code for the creator here as a zip (~340kb).
Source code (Version 3) – Download the source code for the creator here as a zip (~360kb).