-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStarterKitPostInstall.php
72 lines (53 loc) · 2.55 KB
/
StarterKitPostInstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;
class StarterKitPostInstall
{
public function handle($console)
{
$originalAppName = env('APP_URL');
$originalAppUrl = env('APP_URL');
$originalAppKey = env('APP_KEY');
$appName = $console->ask('What should be your app name?');
$appName = preg_replace('/([\'|\"|#])/m', '', $appName);
$appURL = $console->ask('What is the app url?');
$env = app('files')->get(base_path('.env.thoughtco'));
$env = str_replace("APP_NAME=", "APP_NAME=\"{$appName}\"", $env);
$env = str_replace('APP_URL=', "APP_URL=\"{$appURL}\"", $env);
$env = str_replace('APP_KEY=', "APP_KEY=\"{$originalAppKey}\"", $env);
// output to console
$console->info('<info>[✓]</info> generate env');
app('files')->put(base_path('.env'), $env);
// success of starter kit installed
$console->info('<info>[✓]</info> starter kit installed!');
// delete starter kit .env
app('files')->delete(base_path('.env.thoughtco'));
$console->info('<info>[✓]</info> .env.thoughtco deleted');
// delete composer.json.bak
app('files')->delete(base_path('composer.json.bak'));
$console->info('<info>[✓]</info> composer.json.bak deleted');
// delete public/css
app('files')->deleteDirectory(public_path('css'));
$console->info('<info>[✓]</info> css folder deleted');
// delete public/img
app('files')->deleteDirectory(public_path('img'));
$console->info('<info>[✓]</info> img folder deleted');
// delete public/js
app('files')->deleteDirectory(public_path('js'));
$console->info('<info>[✓]</info> js folder deleted');
// to be super sure we're clear on everything
// we don't need to do all of this stuff below,
// but just trying to head off some issues
Artisan::call('statamic:glide:clear');
$console->info('<info>[✓]</info> statamic glide cache cleared');
Artisan::call('statamic:stache:clear');
$console->info('<info>[✓]</info> statamic stache cleared');
Artisan::call('route:clear');
$console->info('<info>[✓]</info> laravel routes cleared');
Artisan::call('config:clear');
$console->info('<info>[✓]</info> laravel config cleared');
Artisan::call('cache:clear');
$console->info('<info>[✓]</info> laravel cache cleared');
}
}