Source of file UpgradeDevBuild.php

Size: 1,654 Bytes - Last Modified: 2020-07-03T12:08:09+00:00

/var/www/docs.ssmods.com/process/src/src/Tasks/IndividualTasks/UpgradeDevBuild.php

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
<?php

namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;

use Sunnysideup\UpgradeToSilverstripe4\Tasks\Helpers\ComposerJsonFixes;
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;

/**
 * Remove installer folder from composer.json file so that package
 * installs into vendor folder.
 */
class UpgradeDevBuild extends Task
{
    protected $taskStep = 's20';

    protected $package = '';

    protected $newVersion = '';

    protected $newPackage = '';

    public function getTitle()
    {
        return 'Upgrade references to sake';
    }

    public function getDescription()
    {
        return '
            Upgrades any reference to framework/sake or framework/cli-script.php';
    }

    public function runActualTask($params = [])
    {
        $command = <<<'EOT'

        if (isset($data["scripts"])) {
            foreach ($data["scripts"] as $type => $commands) {
                foreach ($commands as $key => $command) {
                    $data[$type][$key] = str_replace("php framework/cli-script.php", "vendor/bin/sake", $command);
                    $data[$type][$key] = str_replace("framework/sake ", "vendor/bin/sake ", $command);
                }
            }
        }

EOT;
        $comment = 'Updating framework/sake to vendor/bin/sake';
        ComposerJsonFixes::inst($this->mu())->UpdateJSONViaCommandLine(
            $this->mu()->getGitRootDir(),
            $command,
            $comment
        );
        $this->setCommitMessage('MINOR: Updating framework/sake to vendor/bin/sake');
    }

    protected function hasCommitAndPush()
    {
        return $this->mu()->getIsModuleUpgrade();
    }
}