setDescription('Installs bower dependencies')
->addOption('no-dev', 'd', InputOption::VALUE_NONE, 'Do not install dev dependencies')
->addOption('clear-cache', null, InputOption::VALUE_NONE, 'If defined forces to clear the cache before installation');
}
protected function doExecute(InputInterface $input, OutputInterface $output)
{
$grunt = $this->container['driver.grunt'];
$grunt->getProcessBuilderFactory()->setTimeout(600);
$bower = $this->container['driver.bower'];
$output->writeln("Using ".$grunt->getProcessBuilderFactory()->getBinary()." for driver");
$output->writeln("Using ".$bower->getProcessBuilderFactory()->getBinary()." for driver");
$version = trim($bower->command('-v'));
if (version::lt($version, '1.0.0-alpha.1')) {
throw new RuntimeException(sprintf(
'Bower version 1.0.0-alpha.1 is required (version %s provided), please install bower-canary : `npm install -g bower-canary or run npm install from root directory`', $version
));
}
$version = trim($grunt->command('--version'));
if (!version_compare('0.4.0', substr($version, -5), '<=')) {
throw new RuntimeException(sprintf(
'Grunt version >= 0.4.0 is required (version %s provided), please install grunt `http://gruntjs.com/getting-started`', $version
));
}
if ($input->getOption('clear-cache')) {
$output->write("Cleaning bower cache... ");
$bower->command(['cache', 'clean']);
$output->writeln("OK");
}
try {
$output->write("Installing assets...");
$grunt->command('install-assets');
$output->write(" OK");
$output->writeln("");
$this->container['console']->get('assets:compile-less')->execute($input, $output);
} catch (ExecutionFailureException $e) {
throw new RuntimeException('Unable to install bower dependencies', $e->getCode(), $e);
}
return 0;
}
}