-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
27 changed files
with
2,085 additions
and
126 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
/node_modules | ||
/vendor | ||
/.idea | ||
/.vscode | ||
/.vagrant | ||
.phpunit.result.cache | ||
|
||
/sample/dist | ||
/.proton-cache | ||
/sample-dist | ||
/.proton-cache |
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
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,36 @@ | ||
<?php | ||
|
||
namespace App\Commands; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
|
||
class Watch extends Command | ||
{ | ||
/** | ||
* The signature of the command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'watch'; | ||
|
||
/** | ||
* The description of the command. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Watch the template folders for changes and rebuild'; | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() | ||
{ | ||
//---------------------------------- | ||
// Watch | ||
//---------------------------------- | ||
$watcher = new \App\Proton\Watcher($this); | ||
$watcher->watch(); | ||
} | ||
} |
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,53 @@ | ||
<?php | ||
|
||
namespace App\Proton; | ||
|
||
use Symfony\Component\Process\ExecutableFinder; | ||
use Symfony\Component\Process\Process; | ||
|
||
//--------------------------------------------------------------------------------- | ||
// Proton BrowserSyncServer | ||
//--------------------------------------------------------------------------------- | ||
class BrowserSyncServer implements ProcessInterface | ||
{ | ||
public string $path; | ||
public Process $process; | ||
|
||
public function __construct(string $path) | ||
{ | ||
$this->path = $path; | ||
|
||
$command = [ | ||
(new ExecutableFinder)->find('node'), | ||
realpath(__DIR__ . '/../bin/browser-sync.js'), | ||
$this->path, | ||
]; | ||
$this->process = new Process( | ||
command: $command, | ||
timeout: null, | ||
); | ||
} | ||
|
||
public function stop(): void | ||
{ | ||
$this->process->stop(); | ||
} | ||
|
||
public function start(): void | ||
{ | ||
$this->process->start(); | ||
|
||
if (! $this->process->isRunning()) { | ||
throw new \Exception("Could not start server. Make sure you have required browser-sync. Error output: " . $this->process->getErrorOutput()); | ||
} | ||
|
||
$this->process->waitUntil(function ($type, $buffer) { | ||
if (Process::ERR === $type) { | ||
echo 'ERR:'.$buffer; | ||
} else { | ||
echo $buffer; | ||
} | ||
return false !== strpos($buffer, 'Watching files'); | ||
}); | ||
} | ||
} |
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,93 @@ | ||
<?php | ||
|
||
namespace App\Proton; | ||
|
||
use LaravelZero\Framework\Commands\Command; | ||
|
||
//--------------------------------------------------------------------------------- | ||
// Proton Builder | ||
//--------------------------------------------------------------------------------- | ||
class Builder | ||
{ | ||
protected Config $config; | ||
protected Data $data; | ||
protected AssetManager $assetManager; | ||
protected FilesystemManager $fsManager; | ||
protected PageManager $pageManager; | ||
protected Command $cmd; | ||
|
||
public function __construct(Command $cmd) | ||
{ | ||
$this->cmd = $cmd; | ||
$this->config = new Config(); | ||
|
||
$this->fsManager = new FilesystemManager($this->config); | ||
$this->fsManager->pathChecker(); | ||
|
||
$data = new Data($this->config); | ||
$this->pageManager = new PageManager($this->config, $data); | ||
$this->assetManager = new AssetManager($this->config); | ||
} | ||
|
||
public function build(): void | ||
{ | ||
if ($this->config->settings->debug) { | ||
$this->cmd->info('Configuration:'); | ||
$this->config->dump(); | ||
$this->cmd->info('Collected Data:'); | ||
$this->data->dump(); | ||
} | ||
$this->compilePages(); | ||
$this->buildSitemap(); | ||
$this->copyAssets(); | ||
$this->runNPMBuild(); | ||
} | ||
|
||
public function runNPMBuild(): void | ||
{ | ||
$command = $this->config->settings->npmBuild; | ||
if ($command) { | ||
$this->cmd->info("Running NPM Build: $command"); | ||
$process = new TerminalCommand($command); | ||
$process->start(); | ||
} | ||
} | ||
|
||
public function buildSitemap(): void | ||
{ | ||
if ($this->config->settings->sitemap) { | ||
$this->cmd->info('Building Sitemap'); | ||
$sitemap = new \App\Proton\Sitemap($this->config); | ||
$sitemap->write(); | ||
} | ||
} | ||
|
||
public function clean(bool $clean=false): void | ||
{ | ||
if ($clean) { | ||
$this->cmd->info('Cleaning previous builds'); | ||
$this->fsManager->cleanupDist(); | ||
} | ||
$this->fsManager->clearCache(); | ||
} | ||
|
||
public function copyAssets(): void | ||
{ | ||
$this->cmd->info('Copying Assets'); | ||
$this->assetManager->copyAssets(); | ||
} | ||
|
||
public function compilePages(): void | ||
{ | ||
$this->cmd->info('Compiling Pages'); | ||
$this->pageManager->compilePages(); | ||
} | ||
|
||
public function refreshData(): void | ||
{ | ||
$this->cmd->info("Refreshing Data"); | ||
$this->pageManager->refreshData(); | ||
$this->cmd->info("Recompiling All Pages"); | ||
$this->pageManager->compilePages(); | ||
} | ||
} |
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
Oops, something went wrong.