Skip to content

Commit 6339e9c

Browse files
authored
Merge pull request #4559 from Laravel-Backpack/install-console-ui-improvements
Improvements on console UI for install command
2 parents 91d9b78 + 9a629d6 commit 6339e9c

File tree

8 files changed

+809
-198
lines changed

8 files changed

+809
-198
lines changed

src/BackpackServiceProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class BackpackServiceProvider extends ServiceProvider
2020
\Backpack\CRUD\app\Console\Commands\CreateUser::class,
2121
\Backpack\CRUD\app\Console\Commands\PublishBackpackMiddleware::class,
2222
\Backpack\CRUD\app\Console\Commands\PublishView::class,
23-
\Backpack\CRUD\app\Console\Commands\RequireDevTools::class,
23+
\Backpack\CRUD\app\Console\Commands\Addons\RequireDevTools::class,
24+
\Backpack\CRUD\app\Console\Commands\Addons\RequireEditableColumns::class,
25+
\Backpack\CRUD\app\Console\Commands\Addons\RequirePro::class,
2426
\Backpack\CRUD\app\Console\Commands\Fix::class,
2527
];
2628

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?php
2+
3+
namespace Backpack\CRUD\app\Console\Commands\Addons;
4+
5+
use Illuminate\Console\Command;
6+
7+
class RequireDevTools extends Command
8+
{
9+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
10+
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;
11+
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'backpack:require:devtools
18+
{--debug} : Show process output or not. Useful for debugging.';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Require Backpack DevTools on dev';
26+
27+
/**
28+
* Backpack addons install attribute.
29+
*
30+
* @var array
31+
*/
32+
public static $addon = [
33+
'name' => 'DevTools',
34+
'description' => [
35+
'Helps generate models, migrations, operations and CRUDs',
36+
],
37+
'path' => 'vendor/backpack/devtools',
38+
'command' => 'backpack:require:devtools',
39+
];
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return mixed Command-line output
45+
*/
46+
public function handle()
47+
{
48+
// Check if it is installed
49+
if ($this->isInstalled()) {
50+
$this->newLine();
51+
$this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red');
52+
$this->newLine();
53+
54+
return;
55+
}
56+
57+
$this->newLine();
58+
$this->infoBlock('Connecting to the Backpack add-on repository');
59+
60+
// Check if repositories exists
61+
$this->composerRepositories();
62+
63+
// Check for authentication
64+
$this->checkForAuthentication();
65+
66+
$this->newLine();
67+
$this->progressBlock($this->description);
68+
69+
// Require package
70+
try {
71+
$this->composerRequire('backpack/devtools', ['--dev', '--with-all-dependencies']);
72+
} catch (\Throwable $e) {
73+
$this->errorProgressBlock();
74+
$this->line(' '.$e->getMessage(), 'fg=red');
75+
$this->newLine();
76+
77+
return;
78+
}
79+
80+
// Display general error in case it failed
81+
if (! $this->isInstalled()) {
82+
$this->errorProgressBlock();
83+
$this->note('For further information please check the log file.');
84+
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/');
85+
$this->newLine();
86+
87+
return;
88+
}
89+
90+
// Finish
91+
$this->closeProgressBlock();
92+
$this->newLine();
93+
94+
// manually include the command in the run-time
95+
if (! class_exists(\Backpack\DevTools\Console\Commands\InstallDevTools::class)) {
96+
include base_path('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php');
97+
}
98+
99+
$this->call(\Backpack\DevTools\Console\Commands\InstallDevTools::class);
100+
}
101+
102+
public function isInstalled()
103+
{
104+
return file_exists(self::$addon['path'].'/composer.json');
105+
}
106+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace Backpack\CRUD\app\Console\Commands\Addons;
4+
5+
use Illuminate\Console\Command;
6+
7+
class RequireEditableColumns extends Command
8+
{
9+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
10+
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;
11+
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'backpack:require:editablecolumns
18+
{--debug} : Show process output or not. Useful for debugging.';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Require Backpack Editable Columns';
26+
27+
/**
28+
* Backpack addons install attribute.
29+
*
30+
* @var array
31+
*/
32+
public static $addon = [
33+
'name' => 'Editable Columns',
34+
'description' => [
35+
'Allow your admins to make small changes from the table view',
36+
],
37+
'path' => 'vendor/backpack/editable-columns',
38+
'command' => 'backpack:require:editablecolumns',
39+
];
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return mixed Command-line output
45+
*/
46+
public function handle()
47+
{
48+
// Check if it is installed
49+
if ($this->isInstalled()) {
50+
$this->newLine();
51+
$this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red');
52+
$this->newLine();
53+
54+
return;
55+
}
56+
57+
$this->newLine();
58+
$this->infoBlock('Connecting to the Backpack add-on repository');
59+
60+
// Check if repositories exists
61+
$this->composerRepositories();
62+
63+
// Check for authentication
64+
$this->checkForAuthentication();
65+
66+
$this->newLine();
67+
$this->progressBlock($this->description);
68+
69+
// Require package
70+
try {
71+
$this->composerRequire('backpack/editable-columns');
72+
} catch (\Throwable $e) {
73+
$this->errorProgressBlock();
74+
$this->line(' '.$e->getMessage(), 'fg=red');
75+
$this->newLine();
76+
77+
return;
78+
}
79+
80+
// Display general error in case it failed
81+
if (! $this->isInstalled()) {
82+
$this->errorProgressBlock();
83+
$this->note('For further information please check the log file.');
84+
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/products/editable-columns');
85+
$this->newLine();
86+
87+
return;
88+
}
89+
90+
// Finish
91+
$this->closeProgressBlock();
92+
$this->newLine();
93+
}
94+
95+
public function isInstalled()
96+
{
97+
return file_exists(self::$addon['path'].'/composer.json');
98+
}
99+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
3+
namespace Backpack\CRUD\app\Console\Commands\Addons;
4+
5+
use Illuminate\Console\Command;
6+
7+
class RequirePro extends Command
8+
{
9+
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
10+
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;
11+
12+
/**
13+
* The name and signature of the console command.
14+
*
15+
* @var string
16+
*/
17+
protected $signature = 'backpack:require:pro
18+
{--debug} : Show process output or not. Useful for debugging.';
19+
20+
/**
21+
* The console command description.
22+
*
23+
* @var string
24+
*/
25+
protected $description = 'Require Backpack Pro';
26+
27+
/**
28+
* Backpack addons install attribute.
29+
*
30+
* @var array
31+
*/
32+
public static $addon = [
33+
'name' => 'Backpack Pro',
34+
'description' => [
35+
'Adds 5 operations, 10 filters, 28 fields, 6 columns, charts',
36+
],
37+
'path' => 'vendor/backpack/pro',
38+
'command' => 'backpack:require:pro',
39+
];
40+
41+
/**
42+
* Execute the console command.
43+
*
44+
* @return mixed Command-line output
45+
*/
46+
public function handle()
47+
{
48+
// Check if it is installed
49+
if ($this->isInstalled()) {
50+
$this->closeProgressBlock();
51+
$this->line(' It was already installed.', 'fg=gray');
52+
$this->newLine();
53+
54+
return;
55+
}
56+
57+
$this->newLine();
58+
$this->infoBlock('Connecting to the Backpack add-on repository');
59+
60+
// Check if repositories exists
61+
$this->composerRepositories();
62+
63+
// Check for authentication
64+
$this->checkForAuthentication();
65+
66+
$this->newLine();
67+
$this->progressBlock($this->description);
68+
69+
// Require package
70+
try {
71+
$this->composerRequire('backpack/pro');
72+
} catch (\Throwable $e) {
73+
$this->errorProgressBlock();
74+
$this->line(' '.$e->getMessage(), 'fg=red');
75+
$this->newLine();
76+
77+
return;
78+
}
79+
80+
// Display general error in case it failed
81+
if (! $this->isInstalled()) {
82+
$this->errorProgressBlock();
83+
$this->note('For further information please check the log file.');
84+
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/');
85+
$this->newLine();
86+
87+
return;
88+
}
89+
90+
// Finish
91+
$this->closeProgressBlock();
92+
$this->newLine();
93+
}
94+
95+
public function isInstalled()
96+
{
97+
return file_exists(self::$addon['path'].'/composer.json');
98+
}
99+
}

0 commit comments

Comments
 (0)