Backport metadata.json detection logic to berks2

Since Berks3 doesn't upload metadata.rb, cookbooks uploaded with berks3 will not be detected properly by berks2, causing it to download every time, and other odd behavior.

This pulls in the 2 changes related to detecting cookbooks by .json from master.