Skip to content

Commit 8d1a90d

Browse files
authored
Merge pull request #43 from craftcms/feature/pt-1716-update-the-extension-to-have-build-command
Feature/pt 1716 update the extension to have build command
2 parents bdb7390 + 2ae8e54 commit 8d1a90d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/cli/controllers/AssetBundlesController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function init(): void
2727

2828
public function beforeAction($action): bool
2929
{
30+
// Don't allow if ephemeral, as the publish command won't create any files
3031
if (App::isEphemeral()) {
3132
throw new Exception('Asset bundle publishing is not supported in ephemeral environments.');
3233
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace craft\cloud\cli\controllers;
4+
5+
use Craft;
6+
use craft\console\Controller;
7+
use Illuminate\Support\Collection;
8+
use samdark\log\PsrMessage;
9+
use yii\console\ExitCode;
10+
11+
class BuildController extends Controller
12+
{
13+
public function actionIndex(string $json): int
14+
{
15+
$options = json_decode($json, true);
16+
$exitCode = ExitCode::OK;
17+
18+
Collection::make([
19+
'cloud/validate/project-type',
20+
'cloud/asset-bundles/publish',
21+
])->each(function(string $command) use ($options, &$exitCode) {
22+
$params = $options[$command] ?? [];
23+
$exitCode = $this->run("/$command", $params);
24+
25+
if ($exitCode !== ExitCode::OK) {
26+
Craft::error(new PsrMessage('Command failed.', [
27+
'command' => $command,
28+
'params' => $params,
29+
]));
30+
31+
return false;
32+
}
33+
});
34+
35+
return $exitCode;
36+
}
37+
}

0 commit comments

Comments
 (0)