1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AtlassianConnectCore\Console; |
4
|
|
|
|
5
|
|
|
use AtlassianConnectCore\Services\TenantService; |
6
|
|
|
use Illuminate\Console\Command; |
7
|
|
|
use Illuminate\Support\Facades\Schema; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class InstallCommand |
11
|
|
|
* |
12
|
|
|
* @package AtlassianConnectCore\Console |
13
|
|
|
*/ |
14
|
|
|
class InstallCommand extends Command |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* The name and signature of the console command. |
18
|
|
|
* |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $signature = 'plugin:install'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* The console command description. |
25
|
|
|
* |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
protected $description = 'Run the commands necessary to prepare plugin for development and use'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var TenantService |
32
|
|
|
*/ |
33
|
|
|
protected $tenantService; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* InstallCommand constructor. |
37
|
|
|
* |
38
|
|
|
* @param TenantService $tenantService |
39
|
|
|
*/ |
40
|
|
|
public function __construct(TenantService $tenantService) |
41
|
|
|
{ |
42
|
|
|
parent::__construct(); |
43
|
|
|
|
44
|
|
|
$this->tenantService = $tenantService; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Execute the console command. |
49
|
|
|
* |
50
|
|
|
* @return mixed |
51
|
|
|
*/ |
52
|
|
|
public function handle() |
53
|
|
|
{ |
54
|
|
|
$this->createDummyTenant(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Create the dummy tenant |
59
|
|
|
*/ |
60
|
|
|
protected function createDummyTenant() |
61
|
|
|
{ |
62
|
|
|
if(!Schema::hasTable($tableName = config('plugin.tenant'))) { |
63
|
|
|
throw new \Exception('Table ' . $tableName . ' should be exist. Please, run migrations'); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$this->tenantService->createOrUpdate([ |
67
|
|
|
'addon_key' => config('plugin.key'), |
68
|
|
|
'client_key' => 'f8e11216-24ba-344e-91b8-845af3d945f0', |
69
|
|
|
'public_key' => 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCK/XMT+GMfzH97nZD1Nj9riBgVZOO/vkJpBAltIEdPBigqHXuv7vG17QrTpzPZQ4ssrpD8RncnLGGevfEXbdNtx50+oUFMjQUde87uyOuBMa5LuhBu47++NEwQKXOC+uw+YJzLb564PDlZGp+OVcKuoDarC/zpw3LezQ2tEJB22QIDAQAB', |
70
|
|
|
'shared_secret' => 'vf7EKBf79AuaqBEthgiXIqEaEBsxYqndLFh/8VuSPeqE8flI6nJCCLRODOPwQpAXyasUm/f01/h7+diwqMdAYa', |
71
|
|
|
'server_version' => '100058', |
72
|
|
|
'plugin_version' => '1.3.175', |
73
|
|
|
'base_url' => 'https://test.atlassian.net', |
74
|
|
|
'product_type' => 'jira', |
75
|
|
|
'description' => 'Dummy tenant for local testing', |
76
|
|
|
'event_type' => 'installed', |
77
|
|
|
'is_dummy' => true |
78
|
|
|
]); |
79
|
|
|
|
80
|
|
|
$this->info('Tenant for local development created successfully'); |
81
|
|
|
|
82
|
|
|
$this->call('vendor:publish', ['--provider' => 'AtlassianConnectCore\ServiceProvider', '--force']); |
83
|
|
|
} |
84
|
|
|
} |