moving some shared logic into new tool lib

Better output on 'pub install' fail
bin/generate: removed superflous imports