#!/usr/bin/perl
# boostrap development environment
use strict;

sub diag {
    warn "------> $_[0]\n";
}

if (`cpanm --version` !~ /cpanminus/) {
    die "cpanm: not found. Install it first with: curl -L cpanmin.us | perl - App::cpanminus\n";
}

diag "Installing Module::Install and plugins";
system "cpanm", qw(
  Module::Install
  Module::Install::AuthorTests
  Module::Install::ReadmeFromPod
  Module::Install::Repository
  Module::Install::Authority
);

diag "Installing dependencies";
system "cpanm", "--installdeps", ".";

# FIXME should go to cpanfile/devel_requires or Plack::Devel bundle
diag "Installing devel devependencies";
system "cpanm", qw(
  FCGI
  FCGI::ProcManager
  MIME::Types
  Authen::Simple::Passwd
  CGI::Emulate::PSGI
  CGI::Compile
  IO::Handle::Util
  LWP::Protocol::http10
  Log::Log4perl
  HTTP::Server::Simple::PSGI
  HTTP::Request::AsCGI
);

diag "Running tests";
system "prove", "-lr", "t";

warn "\nYour development environment is set up. Happy hacking!\n";