Repository navigation
Conversation
This revives the old 'composer' flag from Jako. If set to true, the vendor folder will be moved temporarily and restored after the transport package is created.
Contributor
|
In that case, a composer.phar file has to be added in the "build": {
"scriptsAfter": [
"script.composer.php"
]
}script.composer.php <?php
/**
* Resolve Composer dependencies
*
* @package gpm
* @subpackage build
*
* @var array $options
* @var xPDOTransport $transport
*/
use Composer\Console\HtmlOutputFormatter;
use Composer\Factory;
use Composer\Installer;
use Composer\IO\BufferIO;
use Symfony\Component\Console\Output\StreamOutput;
use xPDO\Transport\xPDOTransport;
$success = true;
if ($transport->xpdo) {
switch ($options[xPDOTransport::PACKAGE_ACTION]) {
case xPDOTransport::ACTION_INSTALL:
case xPDOTransport::ACTION_UPGRADE:
$transport->xpdo->log(xPDO::LOG_LEVEL_INFO, 'Installing/updating dependencies, this may take some time...');
$path = MODX_CORE_PATH . "components/{$transport->name}/";
// Set Composer environment variables
putenv("COMPOSER={$path}composer.json");
putenv("COMPOSER_HOME={$path}.composer");
putenv("COMPOSER_VENDOR_DIR={$path}vendor/");
// Change the path to the package namespace folder, to prevent autoloading other namespaces
chdir($path);
require "phar://{$path}composer.phar/vendor/autoload.php";
// Run Composer without proc_open/exec
$io = new BufferIO('', StreamOutput::VERBOSITY_NORMAL, new HtmlOutputFormatter());
$composer = Factory::create($io);
$install = Installer::create($io, $composer);
$install
->setPreferDist(true)
->setDevMode(false)
->setOptimizeAutoloader(true)
->setUpdate(false)
->setPreferStable(true);
try {
$install->run();
} catch (Exception $e) {
$transport->xpdo->log(xPDO::LOG_LEVEL_ERROR, get_class($e) . ' installing dependencies: ' . $e->getMessage());
echo get_class($e) . ': ' . $e->getMessage() . "\n";
$success = false;
}
$output = $io->getOutput();
$output = nl2br(trim($output));
$transport->xpdo->log(xPDO::LOG_LEVEL_INFO, $output);
break;
case xPDOTransport::ACTION_UNINSTALL:
break;
}
}
return $success; |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This revives the old 'composer' flag from @Jako . If set to true, the vendor folder will be moved temporarily and restored after the transport package is created.