1
0
Fork 0

Use default configs, where applicable, in init

pull/6743/head
Zachary Flower 2017-10-13 22:39:08 -06:00
parent 6ce11697ec
commit 9ed0a2d35f
1 changed files with 15 additions and 5 deletions

View File

@ -154,11 +154,12 @@ EOT
$git = $this->getGitConfig(); $git = $this->getGitConfig();
$io = $this->getIO(); $io = $this->getIO();
$formatter = $this->getHelperSet()->get('formatter'); $formatter = $this->getHelperSet()->get('formatter');
$config = Factory::createConfig($io);
$defaults = $config->get('defaults');
// initialize repos if configured // initialize repos if configured
$repositories = $input->getOption('repository'); $repositories = $input->getOption('repository');
if ($repositories) { if ($repositories) {
$config = Factory::createConfig($io);
$repos = array(new PlatformRepository); $repos = array(new PlatformRepository);
foreach ($repositories as $repo) { foreach ($repositories as $repo) {
$repos[] = RepositoryFactory::fromString($io, $config, $repo); $repos[] = RepositoryFactory::fromString($io, $config, $repo);
@ -191,7 +192,9 @@ EOT
$name = basename($cwd); $name = basename($cwd);
$name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name); $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
$name = strtolower($name); $name = strtolower($name);
if (isset($git['github.user'])) { if ( isset($defaults['vendor']) ) {
$name = $defaults['vendor'] . '/' . $name;
} elseif (isset($git['github.user'])) {
$name = $git['github.user'] . '/' . $name; $name = $git['github.user'] . '/' . $name;
} elseif (!empty($_SERVER['USERNAME'])) { } elseif (!empty($_SERVER['USERNAME'])) {
$name = $_SERVER['USERNAME'] . '/' . $name; $name = $_SERVER['USERNAME'] . '/' . $name;
@ -240,7 +243,9 @@ EOT
$input->setOption('description', $description); $input->setOption('description', $description);
if (null === $author = $input->getOption('author')) { if (null === $author = $input->getOption('author')) {
if (isset($git['user.name']) && isset($git['user.email'])) { if ( isset($defaults['author']) && isset($defaults['author']['name']) && isset($defaults['author']['email']) ) {
$author = sprintf('%s <%s>', $defaults['author']['name'], $defaults['author']['email']);
} elseif (isset($git['user.name']) && isset($git['user.email'])) {
$author = sprintf('%s <%s>', $git['user.name'], $git['user.email']); $author = sprintf('%s <%s>', $git['user.name'], $git['user.email']);
} }
} }
@ -291,7 +296,12 @@ EOT
); );
$input->setOption('type', $type); $input->setOption('type', $type);
$license = $input->getOption('license') ?: false; if (null === $license = $input->getOption('license')) {
if ( isset($defaults['license']) ) {
$license = $defaults['license'];
}
}
$license = $io->ask( $license = $io->ask(
'License [<comment>'.$license.'</comment>]: ', 'License [<comment>'.$license.'</comment>]: ',
$license $license