Skip to content

Commit

Permalink
Cleanup command
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
caendesilva committed Oct 30, 2023
1 parent 2b5f3ff commit 1e6c6f1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions monorepo/DevTools/src/MonorepoReleaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function handle(): int

if ($this->newVersionType === 'major') {
$this->warn('This is a major release, please make sure to update the framework version in the Hyde composer.json file!');
} else if ($this->newVersionType === 'minor') {
} elseif ($this->newVersionType === 'minor') {
$this->warn('Please make sure to update the framework version in the Hyde composer.json file!');
}

Expand Down Expand Up @@ -123,7 +123,7 @@ protected function askForNewVersion(): void
break;
}

$this->newVersion = $major . '.' . $minor . '.' . $patch;
$this->newVersion = $major.'.'.$minor.'.'.$patch;

$this->info("New version: v$this->newVersion <fg=gray>($this->newVersionType)</>");
}
Expand All @@ -132,6 +132,7 @@ protected function runUnlessDryRun(string $command, bool $allowSilent = false):
{
if ($this->dryRun) {
$this->gray("DRY RUN: $command");

return null;
}

Expand Down Expand Up @@ -166,9 +167,9 @@ protected function prepareReleaseNotes(): void
$this->output->write('Transforming upcoming release notes... ');

$version = $this->newVersion;
$baseDir = __DIR__ . '/../../../';
$baseDir = __DIR__.'/../../../';

$notes = file_get_contents($baseDir .'RELEASE_NOTES.md');
$notes = file_get_contents($baseDir.'RELEASE_NOTES.md');

$notes = str_replace("\r", '', $notes);

Expand Down Expand Up @@ -208,7 +209,7 @@ protected function prepareReleaseNotes(): void
// remove empty lines
$notes = preg_replace('/\n{3,}/', "\n", $notes);

$this->line('Done. ');
$this->line('Done.');

$this->output->write('Resetting upcoming release notes stub... ');
file_put_contents($baseDir.'RELEASE_NOTES.md', <<<'MARKDOWN'
Expand Down Expand Up @@ -243,7 +244,7 @@ protected function prepareReleaseNotes(): void

MARKDOWN);

$this->line('Done. ');
$this->line('Done.');

$this->output->write('Updating changelog with the upcoming release notes... ');

Expand All @@ -254,22 +255,22 @@ protected function prepareReleaseNotes(): void
$changelog = substr_replace($changelog, $needle."\n\n".$notes, strpos($changelog, $needle), strlen($needle));
file_put_contents($baseDir.'/CHANGELOG.md', $changelog);

$this->line('Done. ');
$this->line('Done.');
}

protected function updateVersionConstant(): void
{
$this->output->write('Updating version constant... ');

$baseDir = __DIR__ . '/../../../';
$baseDir = __DIR__.'/../../../';
$version = ltrim($this->newVersion, 'v');

$kernelPath = $baseDir . '/packages/framework/src/Foundation/HydeKernel.php';
$kernelPath = $baseDir.'/packages/framework/src/Foundation/HydeKernel.php';
$hydeKernel = file_get_contents($kernelPath);
$hydeKernel = preg_replace('/final public const VERSION = \'(.*)\';/', "final public const VERSION = '$version';", $hydeKernel);
file_put_contents($kernelPath, $hydeKernel);

$this->line('Done. ');
$this->line('Done.');
}

protected function commitFrameworkVersion(): void
Expand All @@ -281,7 +282,7 @@ protected function commitFrameworkVersion(): void

$this->exitIfFailed();

$this->line('Done. ');
$this->line('Done.');
}

protected function makeMonorepoCommit(): void
Expand All @@ -293,7 +294,7 @@ protected function makeMonorepoCommit(): void

$this->exitIfFailed();

$this->line('Done. ');
$this->line('Done.');
}

protected function prepareFrameworkPR(): void
Expand All @@ -319,13 +320,13 @@ protected function getCompanionBody(): string
protected function preparePackagePR(string $package): void
{
// Create link to draft pull request merging develop into master
$link = sprintf('https://github.com/hydephp/' . $package . '/compare/master...develop?expand=1&draft=1&title=%s&body=%s',
$link = sprintf('https://github.com/hydephp/'.$package.'/compare/master...develop?expand=1&draft=1&title=%s&body=%s',
urlencode($this->getTitle()),
$this->newVersionType === 'patch' ? '' : $this->getCompanionBody()
);

$this->info("Opening $package pull request link in browser. Please review and submit the PR once all changes are propagated.");
shell_exec((PHP_OS_FAMILY === 'Windows' ? 'explorer' : 'open') . ' ' . escapeshellarg($link));
$this->runUnlessDryRun((PHP_OS_FAMILY === 'Windows' ? 'explorer' : 'open').' '.escapeshellarg($link), true);
}

protected function createNewBranch(): void
Expand All @@ -334,7 +335,7 @@ protected function createNewBranch(): void
$name = "$prefix-v$this->newVersion";

$this->info("Creating new branch $name... ");
$this->runUnlessDryRun('git checkout -b ' . $name, true);
$this->runUnlessDryRun('git checkout -b '.$name, true);

// Verify changed to new branch
$state = $this->runUnlessDryRun('git branch --show-current');
Expand Down

0 comments on commit 1e6c6f1

Please sign in to comment.