Merge remote-tracking branch 'lyrixx/create-project-delete-vcs'
Conflicts: composer.json composer.lockpull/1223/merge
commit
2a0e783c42
|
@ -26,6 +26,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
use Composer\Package\Version\VersionParser;
|
use Composer\Package\Version\VersionParser;
|
||||||
|
@ -50,7 +52,8 @@ class CreateProjectCommand extends Command
|
||||||
new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'Pick a different repository url to look for the package.'),
|
new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'Pick a different repository url to look for the package.'),
|
||||||
new InputOption('dev', null, InputOption::VALUE_NONE, 'Whether to install dependencies for development.'),
|
new InputOption('dev', null, InputOption::VALUE_NONE, 'Whether to install dependencies for development.'),
|
||||||
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Whether to disable custom installers.'),
|
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Whether to disable custom installers.'),
|
||||||
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.')
|
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
|
||||||
|
new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deletion vcs folder.'),
|
||||||
))
|
))
|
||||||
->setHelp(<<<EOT
|
->setHelp(<<<EOT
|
||||||
The <info>create-project</info> command creates a new project from a given
|
The <info>create-project</info> command creates a new project from a given
|
||||||
|
@ -84,11 +87,12 @@ EOT
|
||||||
$input->getOption('dev'),
|
$input->getOption('dev'),
|
||||||
$input->getOption('repository-url'),
|
$input->getOption('repository-url'),
|
||||||
$input->getOption('no-custom-installers'),
|
$input->getOption('no-custom-installers'),
|
||||||
$input->getOption('no-scripts')
|
$input->getOption('no-scripts'),
|
||||||
|
$input->getOption('keep-vcs')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false)
|
public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $keepVcs = false)
|
||||||
{
|
{
|
||||||
$config = Factory::createConfig();
|
$config = Factory::createConfig();
|
||||||
|
|
||||||
|
@ -146,7 +150,7 @@ EOT
|
||||||
}
|
}
|
||||||
unset($candidates);
|
unset($candidates);
|
||||||
|
|
||||||
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>', true);
|
$io->write('<info>Installing ' . $package->getName() . ' (' . VersionParser::formatVersion($package, false) . ')</info>');
|
||||||
|
|
||||||
if ($disableCustomInstallers) {
|
if ($disableCustomInstallers) {
|
||||||
$io->write('<info>Custom installers have been disabled.</info>');
|
$io->write('<info>Custom installers have been disabled.</info>');
|
||||||
|
@ -162,7 +166,7 @@ EOT
|
||||||
$package->getRepository()->notifyInstall($package);
|
$package->getRepository()->notifyInstall($package);
|
||||||
}
|
}
|
||||||
|
|
||||||
$io->write('<info>Created project in ' . $directory . '</info>', true);
|
$io->write('<info>Created project in ' . $directory . '</info>');
|
||||||
chdir($directory);
|
chdir($directory);
|
||||||
|
|
||||||
putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion());
|
putenv('COMPOSER_ROOT_VERSION='.$package->getPrettyVersion());
|
||||||
|
@ -183,6 +187,25 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$installer->run();
|
$installer->run();
|
||||||
|
|
||||||
|
if (!$keepVcs && (
|
||||||
|
!$io->isInteractive() ||
|
||||||
|
$io->askConfirmation('<info>Do you want remove all previous VCS history ?</info> [<comment>yes</comment>]: ', true)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
$finder = new Finder();
|
||||||
|
$finder->in($directory)->ignoreVCS(false)->ignoreDotFiles(false);
|
||||||
|
foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg') as $vcsName) {
|
||||||
|
$finder->name($vcsName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$fs = new Filesystem();
|
||||||
|
try {
|
||||||
|
$fs->remove($finder);
|
||||||
|
} catch (IOException $e) {
|
||||||
|
$io->write("<error>An error occured while removing the .git directory</error>");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createDownloadManager(IOInterface $io, Config $config)
|
protected function createDownloadManager(IOInterface $io, Config $config)
|
||||||
|
|
Loading…
Reference in New Issue