1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ReliqArts\Docweaver\Console\Command; |
6
|
|
|
|
7
|
|
|
use Carbon\Carbon; |
8
|
|
|
use ReliqArts\Docweaver\Exception\InvalidDirectory; |
9
|
|
|
|
10
|
|
|
class Publish extends SingleProductCommand |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* The name and signature of the console command. |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $signature = 'docweaver:publish |
18
|
|
|
{product? : Product name} |
19
|
|
|
{source? : Product repository} |
20
|
|
|
{--y|y : Whether to skip confirmation} |
21
|
|
|
'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The console command description. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $description = 'Publish documentation for product'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Execute the console command. |
32
|
|
|
* |
33
|
|
|
* @throws InvalidDirectory |
34
|
|
|
*/ |
35
|
|
|
public function handle(): void |
36
|
|
|
{ |
37
|
|
|
$productName = $this->argument('product'); |
38
|
|
|
$productSource = $this->argument('source'); |
39
|
|
|
$skipConfirmation = $this->option('y'); |
40
|
|
|
$confirmationMessage = sprintf( |
41
|
|
|
"This command will attempt to pull documentation for product (%s) from %s}. \n" |
42
|
|
|
. 'Please ensure your internet connection is stable. Ready?', |
43
|
|
|
$productName, |
|
|
|
|
44
|
|
|
$productSource |
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
$this->comment(PHP_EOL |
48
|
|
|
. "<info>♣♣♣</info> Docweaver DocumentationPublisher \n" |
49
|
|
|
. 'Help is here, try: php artisan docweaver:publish --help'); |
50
|
|
|
|
51
|
|
|
if ($skipConfirmation || $this->confirm($confirmationMessage)) { |
52
|
|
|
$this->info("Publishing {$productName}.\nT: " . Carbon::now()->toCookieString() . '----------'); |
53
|
|
|
|
54
|
|
|
$result = $this->publisher->publish($productName, $productSource, $this); |
|
|
|
|
55
|
|
|
|
56
|
|
|
$this->displayResult($result); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|