|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Acacha\ForgePublish\Commands; |
|
4
|
|
|
|
|
5
|
|
|
use Acacha\ForgePublish\ForgePublishRCFile; |
|
6
|
|
|
use Illuminate\Console\Command; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class PublishInit. |
|
10
|
|
|
* |
|
11
|
|
|
* @package Acacha\ForgePublish\Commands |
|
12
|
|
|
*/ |
|
13
|
|
|
class PublishInit extends Command |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* The name and signature of the console command. |
|
17
|
|
|
* |
|
18
|
|
|
* @var string |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $signature = 'publish:init'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The console command description. |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $description = 'Config acacha forge publish '; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Execute the console command. |
|
31
|
|
|
* |
|
32
|
|
|
*/ |
|
33
|
|
|
public function handle() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->info('Hello! Together we are going to config Acacha Laravel Forge publish ...'); |
|
36
|
|
|
|
|
37
|
|
|
if (! ForgePublishRCFile::exists()) { |
|
38
|
|
|
$this->call('publish:rc'); |
|
39
|
|
|
}; |
|
40
|
|
|
|
|
41
|
|
|
$this->confirmAnUserIsCreatedInAcachaLaravelForge(); |
|
42
|
|
|
|
|
43
|
|
|
$this->call('publish:url'); |
|
44
|
|
|
|
|
45
|
|
|
$this->call('publish:email'); |
|
46
|
|
|
|
|
47
|
|
|
$this->login(); |
|
48
|
|
|
|
|
49
|
|
|
$this->call('publish:check_token'); |
|
50
|
|
|
|
|
51
|
|
|
$this->call('publish:server'); |
|
52
|
|
|
|
|
53
|
|
|
$this->call('publish:domain'); |
|
54
|
|
|
|
|
55
|
|
|
$this->call('publish:project_type'); |
|
56
|
|
|
|
|
57
|
|
|
$this->call('publish:site_directory'); |
|
58
|
|
|
|
|
59
|
|
|
$this->call('publish:site'); |
|
60
|
|
|
|
|
61
|
|
|
$this->call('publish:github'); |
|
62
|
|
|
|
|
63
|
|
|
$this->finish(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Confirm an user is created in Acacha Laravel Forge. |
|
68
|
|
|
*/ |
|
69
|
|
|
protected function confirmAnUserIsCreatedInAcachaLaravelForge() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->info(''); |
|
72
|
|
|
$this->info('Please visit and login on http://forge.acacha.org'); |
|
73
|
|
|
$this->info(''); |
|
74
|
|
|
$this->error('Please use Github Social Login for login!!!'); |
|
75
|
|
|
|
|
76
|
|
|
while (! $this->confirm('Do you have an user created at http:://forge.acacha.com?')) { |
|
|
|
|
|
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Login |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function login() |
|
84
|
|
|
{ |
|
85
|
|
|
if (fp_env('ACACHA_FORGE_ACCESS_TOKEN')) { |
|
86
|
|
|
$this->info('You have a token already configured in your environment.'); |
|
87
|
|
|
if (! $this->confirm('Do you want to relogin?')) { |
|
88
|
|
|
return; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
$this->info('I need permissions to operate in Acacha Forge in your name...'); |
|
93
|
|
|
$this->info('So we need to obtain a valid token. Two options here:'); |
|
94
|
|
|
$this->info('1) Login: You provide your user credentials and I obtain the token from Laravel Forge'); |
|
95
|
|
|
$this->info('2) Personal Access Token: You provide a Personal Access token'); |
|
96
|
|
|
|
|
97
|
|
|
$option = $this->choice('Which one you prefer?', ['Login', 'Personal Access Token'], 0); |
|
98
|
|
|
|
|
99
|
|
|
if ($option == 'Login') { |
|
100
|
|
|
$this->call('publish:login', [ |
|
101
|
|
|
'email' => fp_env('ACACHA_FORGE_EMAIL') |
|
102
|
|
|
]); |
|
103
|
|
|
} else { |
|
104
|
|
|
$this->call('publish:token'); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Finish command. |
|
110
|
|
|
*/ |
|
111
|
|
|
protected function finish() |
|
112
|
|
|
{ |
|
113
|
|
|
$this->info(''); |
|
114
|
|
|
$this->info('Ok! let me resume: '); |
|
115
|
|
|
$this->call('publish:info'); |
|
116
|
|
|
|
|
117
|
|
|
$this->info(''); |
|
118
|
|
|
$this->info('Perfect! All info is saved to your environment (.env file).'); |
|
119
|
|
|
$this->info(''); |
|
120
|
|
|
$this->error('If needed, remember to rerun your server to apply changes in .env file!!!'); |
|
121
|
|
|
$this->info(''); |
|
122
|
|
|
|
|
123
|
|
|
$this->info("I have finished! Congratulations and enjoy Acha Laravel Forge!"); |
|
124
|
|
|
|
|
125
|
|
|
$this->info("You are now ready to publish your awesome project to Laravel Forge using:"); |
|
126
|
|
|
|
|
127
|
|
|
$this->info("**** php artisan publish ***"); |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
This check looks for
whileloops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.Consider removing the loop.