I'm trying to use jq to edit a composer.json file between development and production.
I've got to the point where I can select the items that I want to remove, but I can't figure out how to turn that into a delete statement.
Also - the only way I could get the select working is to use to_entries, which then breaks the structure of the require selection.
Any help would be appreciated!
composer.json (trimmed for a shorter post):
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^8.0",
"kreait/laravel-firebase": "^4.1",
"laravel/cashier-paddle": "^1.5",
"laravel/framework": "^8.75",
"laravel/sanctum": "^2.11",
"laravel/socialite": "^5.5",
"laravel/tinker": "^2.5",
"livewire/livewire": "^2.5",
"lorisleiva/laravel-actions": "^2.4",
"owenvoke/blade-fontawesome": "*",
"protonemedia/laravel-verify-new-email": "^1.5",
"pusher/pusher-php-server": "^7.0",
"rapidstatic/rapidstatic": "dev-master",
"rapidstatic/scraper": "dev-master",
"razorui/blade-application-ui": "^0.3.0"
}
}
jq:
jq '.require | to_entries | map(select(.key | contains("rapidstatic")))' composer.json
output:
[
{
"key": "rapidstatic/rapidstatic",
"value": "dev-master"
},
{
"key": "rapidstatic/scraper",
"value": "dev-master"
}
]