Skip to content

Commit

Permalink
Merge pull request #62 from open-sausages/pulls/2.0/actually-working-…
Browse files Browse the repository at this point in the history
…repository

BUG Fix --repository so that it actually works
  • Loading branch information
Damian Mooyman authored Dec 6, 2017
2 parents 1ee78d9 + 7cae2df commit d27b173
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/Commands/Release/Archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ protected function fire()
// Get arguments
$project = $this->getProject();
$releasePlan = $this->getReleasePlan();
$repository = $this->getInputRepository();

// Ensure we wait, even if just building archive
$wait = new WaitStep($this, $project, $releasePlan);
$wait->run($this->input, $this->output);

// Create packages
$package = new BuildArchive($this, $project, $releasePlan);
$package = new BuildArchive($this, $project, $releasePlan, $repository);
$package->run($this->input, $this->output);
}
}
99 changes: 86 additions & 13 deletions src/Utility/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,100 @@ public static function createProject(
$repository = null,
$preferDist = false
) {
$command = [
"composer",
"create-project",
// Create-options
$createOptions = [
"--no-secure-http",
"--no-interaction",
"--ignore-platform-reqs",
$recipe,
$directory,
$version
];

// Set dev / stable options
if ($preferDist) {
$command[] = "--prefer-dist";
$command[] = "--no-dev";
$createOptions[] = "--prefer-dist";
$createOptions[] = "--no-dev";
} else {
$command[] = "--prefer-source";
$command[] = "--keep-vcs";
$createOptions[] = "--prefer-source";
$createOptions[] = "--keep-vcs"; // create only
}

// If using a repository, we must delay for a later update
if ($repository) {
$createOptions[] = '--repository';
$createOptions[] = $repository;
$createOptions[] = '--no-install';
}

// Create comand
$runner->runCommand(array_merge([
"composer",
"create-project",
$recipe,
$directory,
$version
], $createOptions), "Could not create project with version {$version}");

// Update un-installed project with custom repository
if ($repository) {
$command[] = '--repository';
$command[] = $repository;
// Add repository temporarily
$runner->runCommand([
'composer',
'config',
'repositories.temp',
'composer',
$repository,
'--working-dir',
$directory,
]);
// Enable http:// local repositories
$runner->runCommand([
'composer',
'config',
'secure-http',
'false',
'--working-dir',
$directory,
]);

// update options
$updateOptions = [
"--no-interaction",
"--ignore-platform-reqs",
];

// Set dev / stable options
if ($preferDist) {
$updateOptions[] = "--prefer-dist";
$updateOptions[] = "--no-dev";
} else {
$updateOptions[] = "--prefer-source";
}

// Update with the given repository
$runner->runCommand(array_merge([
'composer',
'update',
'--working-dir',
$directory,
], $updateOptions), "Could not update project");

// Revert changes made above
$runner->runCommand([
'composer',
'config',
'--unset',
'repositories.temp',
'--working-dir',
$directory,
]);
$runner->runCommand([
'composer',
'config',
'--unset',
'secure-http',
'--working-dir',
$directory,
]);
}
$runner->runCommand($command, "Could not create project with version {$version}");
}

/**
Expand Down

0 comments on commit d27b173

Please sign in to comment.