Skip to content

Commit 1ccad7f

Browse files
committed
Nice outut
1 parent 2df5cf0 commit 1ccad7f

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/cli/controllers/BuildController.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,31 @@ public function options($actionID): array
2424

2525
public function actionBuild(): int
2626
{
27-
if (!$this->isEditionValid($this->craftEdition)) {
28-
throw new Exception('Invalid Craft CMS edition.');
29-
}
27+
$this->validateEdition($this->craftEdition);
3028

3129
return $this->run('/cloud/asset-bundles/publish', [
3230
'to' => $this->publishAssetBundlesTo,
3331
]);
3432
}
3533

36-
private function isEditionValid(string $edition): bool
34+
private function validateEdition(string $edition): void
3735
{
38-
$craftVersion = Craft::$app->getInfo()->version;
36+
$craftVersion = Craft::$app->getVersion();
37+
$editionFromEnv = App::env('CRAFT_EDITION');
3938

4039
// CRAFT_EDITION is enforced in these versions, so we don't need to validate
41-
if (App::env('CRAFT_EDITION') && Semver::satisfies($craftVersion, '^4.10 || ^5.2')) {
42-
return true;
40+
if ($editionFromEnv && Semver::satisfies($craftVersion, '^4.10 || ^5.2')) {
41+
return;
4342
}
4443

4544
$editionFromProjectConfig = Craft::$app->getProjectConfig()->get('system.edition', true);
4645

47-
if (!$editionFromProjectConfig) {
46+
if (!$editionFromProjectConfig || !$edition) {
4847
throw new Exception('Unable to determine the Craft CMS edition.');
4948
}
5049

5150
if ($edition !== $editionFromProjectConfig) {
52-
return false;
51+
throw new Exception("This Craft Cloud project is only valid for the Craft CMS edition “{$edition}”.");
5352
}
54-
55-
return true;
5653
}
5754
}

0 commit comments

Comments
 (0)