-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2a2c13
commit 59e82ea
Showing
14 changed files
with
947 additions
and
647 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Coderstm\Commands; | ||
|
||
use Coderstm\Services\Helpers; | ||
use Illuminate\Console\Command; | ||
|
||
class BuildTheme extends Command | ||
{ | ||
// The name and signature of the console command | ||
protected $signature = 'coderstm:theme-build {name}'; | ||
|
||
// The console command description | ||
protected $description = 'Build a theme using npm run theme:build --name={theme-name}'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
// Check if npm is installed and the test command can be run | ||
Helpers::checkNpmInstallation(); | ||
|
||
// Get the theme name from the command argument | ||
$themeName = $this->argument('name'); | ||
|
||
// Run the npm command to build the theme | ||
$npmBuildCommand = "npm run theme:build --name={$themeName}"; | ||
|
||
$output = null; | ||
$resultCode = null; | ||
|
||
// Execute the npm build command | ||
exec($npmBuildCommand, $output, $resultCode); | ||
|
||
// Output npm response | ||
foreach ($output as $line) { | ||
$this->line($line); | ||
} | ||
|
||
// Check if the command was successful | ||
if ($resultCode === 0) { | ||
$this->info("Theme '{$themeName}' built successfully!"); | ||
} else { | ||
$this->error("Failed to build the theme '{$themeName}'. Please check the npm output."); | ||
} | ||
|
||
return $resultCode; | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Coderstm\Exceptions; | ||
|
||
use Exception; | ||
|
||
class NpmNotFoundException extends Exception | ||
{ | ||
public function __construct($message = null) | ||
{ | ||
parent::__construct($message ?? 'Npm is not installed on the server. Please install npm and try again.'); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Coderstm\Exceptions; | ||
|
||
use Exception; | ||
|
||
class NpmNotInstalledException extends Exception | ||
{ | ||
public function __construct($message = null) | ||
{ | ||
parent::__construct($message ?? 'Npm is installed, but the test command failed. Make sure to run "npm install" in the project root.'); | ||
} | ||
} |
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
Oops, something went wrong.