Having been in the position where a project broke when switching to Composer 2, I have the same problem. Sure, in my case it was a bug that caused it which Composer 1 handled differently to Composer 2, but that doesn't matter. It means we can't switch Composer version across all projects blindly. It needs to be done and tested on a per-project basis. So I did some digging.
plugin-api-version
has been added in Composer v1.10.0. It doesn't appear that the plugin API version is identical to the Composer version, but it would appear that the major version at least matches, so it suffices to know whether Composer 1 or 2 has been used. However, you must keep in mind that plugin-api-version
is missing from composer.lock
files built with Composer version 1.9.0 or earlier. Based on that info, I wrote this shell script:
for f in $(find projects/ -maxdepth 2 -name composer.lock); do echo -n $f:; grep plugin-api-version $f || echo "plugin-api-version missing"; done
Some example output:
projects/abc/composer.lock: "plugin-api-version": "2.3.0"
projects/def/composer.lock:plugin-api-version missing
projects/ghi/composer.lock:plugin-api-version missing
projects/jkl/composer.lock:plugin-api-version missing
projects/mno/composer.lock: "plugin-api-version": "2.3.0"
projects/pqr/composer.lock: "plugin-api-version": "2.6.0"
projects/stu/composer.lock:plugin-api-version missing
projects/vwxyz/composer.lock: "plugin-api-version": "1.1.0"