Skip to content

Commit

Permalink
Add deployment command for pwa to create the manifest.json file inste…
Browse files Browse the repository at this point in the history
…ad of using a controller.
  • Loading branch information
leganz committed Aug 21, 2020
1 parent 5f7135d commit a1fcacb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
52 changes: 52 additions & 0 deletions Console/DeployManifest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace LaravelPWA\Console\Commands;

use File;

use Illuminate\Console\Command;
use LaravelPWA\Services\ManifestService;

class DeployManifest extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'pwa:manifest-deploy';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Deploy the manifest.json into a json file.';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{

$output = (new ManifestService)->generate();
File::put(public_path("manifest.json"), json_encode($output, JSON_PRETTY_PRINT));

$this->line('manifest.json file has been created.');

}


}
15 changes: 14 additions & 1 deletion Providers/LaravelPWAServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function boot()
$this->registerViews();
$this->registerServiceworker();
$this->registerDirective();
$this->registerCommands();
}

/**
Expand Down Expand Up @@ -118,7 +119,19 @@ public function registerDirective()
});
}



/**
* Register the available commands
*
* @return void
*/
public function registerCommands()
{
$this->commands([
\LaravelPWA\Console\Commands\DeployManifest::class,
]);

}

/**
* Get the services provided by the provider.
Expand Down

0 comments on commit a1fcacb

Please sign in to comment.