-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from craftcms/feature/pt-1716-update-the-exten…
…sion-to-have-build-command Feature/pt 1716 update the extension to have build command
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace craft\cloud\cli\controllers; | ||
|
||
use Craft; | ||
use craft\console\Controller; | ||
use Illuminate\Support\Collection; | ||
use samdark\log\PsrMessage; | ||
use yii\console\ExitCode; | ||
|
||
class BuildController extends Controller | ||
{ | ||
public function actionIndex(string $json): int | ||
{ | ||
$options = json_decode($json, true); | ||
$exitCode = ExitCode::OK; | ||
|
||
Collection::make([ | ||
'cloud/validate/project-type', | ||
'cloud/asset-bundles/publish', | ||
])->each(function(string $command) use ($options, &$exitCode) { | ||
$params = $options[$command] ?? []; | ||
$exitCode = $this->run("/$command", $params); | ||
|
||
if ($exitCode !== ExitCode::OK) { | ||
Craft::error(new PsrMessage('Command failed.', [ | ||
'command' => $command, | ||
'params' => $params, | ||
])); | ||
|
||
return false; | ||
} | ||
}); | ||
|
||
return $exitCode; | ||
} | ||
} |