Factor out shared Pub/Bower code to abstract PackageManager, use it wherever possible

@keertip

This is part 1 of generalization of package management. Part 2 will be: introduce a composition template with MetaPackageManager extending the same abstract PackageManager, but delegating each abstract API call to underlying PubManager and BowerManager objects (and potentially other package managers in the future).

Sorry for the large diff: it was a significant refactoring.