Extracting the first library product from SPM manifest

Just wanted to share this for anyone else who might need it (after having a first time experience with jq - might be obvious to you who are used to it, but took me longer than I'd care to admit to get it right).

I'm using it for GitHub CI workflows where I want to do api breakage analytics and docc documentation generation for a wide range of repositories that can share the same workflow actions.

To extract the first library product defined from a repo:

swift package dump-package | jq -r '.products | .[] | select(.type | has("library")) | .name' | head -1

will just return the name of the product that can be passed on to docc / swift package diagnose-api-breaking-changes as needed.

Sample output in project directory:

> swift package dump-package | jq -r '.products | .[] | select(.type | has("library")) | .name' | head -1
Frostflake
>