Skip to content

Commit

Permalink
Executing create-project on initial install using Composer plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Jan 5, 2017
1 parent 7cadb4f commit 6b273bf
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ protected function getBltPackage($operation) {
*/
protected function executeBltUpdate($version) {
$options = $this->getOptions();
if ($options['blt']['update']) {

if ($this->isInitialInstall()) {
$this->io->write('<info>Creating BLT templated files...</info>');
$success = $this->executeCommand('blt create-project', [], TRUE);
}
elseif ($options['blt']['update']) {
$this->io->write('<info>Updating BLT templated files...</info>');

// Rsyncs, updates composer.json, project.yml, executes scripted updates for version delta.
Expand All @@ -148,6 +153,27 @@ protected function executeBltUpdate($version) {
}
}

/**
* Determine if BLT is being installed for the first time on this project.
*
* This would execute in the context of `composer create-project`.
*
* @return bool
* TRUE if this is the initial install of BLT.
*/
protected function isInitialInstall() {
if (!file_exists($this->getRepoRoot() . '/blt/project.yml')
&& !file_exists($this->getRepoRoot() . '/blt/.schema-version')
&& file_exists($this->getRepoRoot() . '/.travis.yml')
&& file_exists($this->getRepoRoot() . '/LICENSE.txt')
&& file_exists($this->getRepoRoot() . '/README.md')
) {
return TRUE;
}

return FALSE;
}

/**
* Returns the repo root's filepath, assumed to be one dir above vendor dir.
*
Expand Down

0 comments on commit 6b273bf

Please sign in to comment.