Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements on console UI for install command #4559

Merged
merged 21 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3874986
Improvements on console UI for install command
promatik Jul 30, 2022
c6d5e06
Apply fixes from StyleCI
StyleCIBot Jul 30, 2022
2fc5279
Added missing function to RequireDevTools class
promatik Jul 30, 2022
e143e84
Merge branch 'install-console-ui-improvements' of https://github.com/…
promatik Jul 30, 2022
ded4d72
Fix for PHP7
promatik Jul 30, 2022
38a82cd
Apply suggestions from code review
promatik Jul 31, 2022
83368c4
Fix console width win/unix
promatik Jul 31, 2022
97858ba
Merge branch 'install-console-ui-improvements' of https://github.com/…
promatik Aug 1, 2022
02284b6
Default bar color to gray
promatik Aug 1, 2022
8c037c1
Apply suggestions from code review
tabacitu Aug 1, 2022
fa5d428
Setup installation on a low verbose level
promatik Aug 1, 2022
0417172
Merge branch 'install-console-ui-improvements' of https://github.com/…
promatik Aug 1, 2022
2ab770b
Apply fixes from StyleCI
StyleCIBot Aug 1, 2022
e1e0f2a
Added steps as info block titles
promatik Aug 2, 2022
4a91035
Apply fixes from StyleCI
StyleCIBot Aug 2, 2022
e06af5f
Using color instead of back ticks in artisan serve code snippet
promatik Aug 2, 2022
853eab7
Merge branch 'install-console-ui-improvements' of https://github.com/…
promatik Aug 2, 2022
a4bf6b1
Validate if user model has timestamps
promatik Aug 2, 2022
b72ccd7
Replace bcrypt with Hash::make
promatik Aug 2, 2022
ff69474
Removed user count
promatik Aug 2, 2022
9a629d6
Get back user count
promatik Aug 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/BackpackServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ class BackpackServiceProvider extends ServiceProvider
\Backpack\CRUD\app\Console\Commands\CreateUser::class,
\Backpack\CRUD\app\Console\Commands\PublishBackpackMiddleware::class,
\Backpack\CRUD\app\Console\Commands\PublishView::class,
\Backpack\CRUD\app\Console\Commands\RequireDevTools::class,
\Backpack\CRUD\app\Console\Commands\Addons\RequireDevTools::class,
tabacitu marked this conversation as resolved.
Show resolved Hide resolved
\Backpack\CRUD\app\Console\Commands\Addons\RequireEditableColumns::class,
\Backpack\CRUD\app\Console\Commands\Addons\RequirePro::class,
\Backpack\CRUD\app\Console\Commands\Fix::class,
];

Expand Down
106 changes: 106 additions & 0 deletions src/app/Console/Commands/Addons/RequireDevTools.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

namespace Backpack\CRUD\app\Console\Commands\Addons;

use Illuminate\Console\Command;

class RequireDevTools extends Command
{
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:require:devtools
{--debug} : Show process output or not. Useful for debugging.';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Require Backpack DevTools on dev';

/**
* Backpack addons install attribute.
*
* @var array
*/
public static $addon = [
'name' => 'DevTools',
'description' => [
'Helps generate models, migrations, operations and CRUDs',
],
'path' => 'vendor/backpack/devtools',
'command' => 'backpack:require:devtools',
];

/**
* Execute the console command.
*
* @return mixed Command-line output
*/
public function handle()
{
// Check if it is installed
if ($this->isInstalled()) {
$this->newLine();
$this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red');
$this->newLine();

return;
}

$this->newLine();
$this->infoBlock('Connecting to the Backpack add-on repository');

// Check if repositories exists
$this->composerRepositories();

// Check for authentication
$this->checkForAuthentication();

$this->newLine();
$this->progressBlock($this->description);

// Require package
try {
$this->composerRequire('backpack/devtools', ['--dev', '--with-all-dependencies']);
} catch (\Throwable $e) {
$this->errorProgressBlock();
$this->line(' '.$e->getMessage(), 'fg=red');
$this->newLine();

return;
}

// Display general error in case it failed
if (! $this->isInstalled()) {
$this->errorProgressBlock();
$this->note('For further information please check the log file.');
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/');
$this->newLine();

return;
}

// Finish
$this->closeProgressBlock();
$this->newLine();

// manually include the command in the run-time
if (! class_exists(\Backpack\DevTools\Console\Commands\InstallDevTools::class)) {
include base_path('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php');
}

$this->call(\Backpack\DevTools\Console\Commands\InstallDevTools::class);
}

public function isInstalled()
{
return file_exists(self::$addon['path'].'/composer.json');
}
}
99 changes: 99 additions & 0 deletions src/app/Console/Commands/Addons/RequireEditableColumns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace Backpack\CRUD\app\Console\Commands\Addons;

use Illuminate\Console\Command;

class RequireEditableColumns extends Command
{
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:require:editablecolumns
{--debug} : Show process output or not. Useful for debugging.';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Require Backpack Editable Columns';

/**
* Backpack addons install attribute.
*
* @var array
*/
public static $addon = [
'name' => 'Editable Columns',
'description' => [
'Allow your admins to make small changes from the table view',
],
'path' => 'vendor/backpack/editable-columns',
'command' => 'backpack:require:editablecolumns',
];

/**
* Execute the console command.
*
* @return mixed Command-line output
*/
public function handle()
{
// Check if it is installed
if ($this->isInstalled()) {
$this->newLine();
$this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red');
$this->newLine();

return;
}

$this->newLine();
$this->infoBlock('Connecting to the Backpack add-on repository');

// Check if repositories exists
$this->composerRepositories();

// Check for authentication
$this->checkForAuthentication();

$this->newLine();
$this->progressBlock($this->description);

// Require package
try {
$this->composerRequire('backpack/editable-columns');
} catch (\Throwable $e) {
$this->errorProgressBlock();
$this->line(' '.$e->getMessage(), 'fg=red');
$this->newLine();

return;
}

// Display general error in case it failed
if (! $this->isInstalled()) {
$this->errorProgressBlock();
$this->note('For further information please check the log file.');
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/products/editable-columns');
$this->newLine();

return;
}

// Finish
$this->closeProgressBlock();
$this->newLine();
}

public function isInstalled()
{
return file_exists(self::$addon['path'].'/composer.json');
}
}
99 changes: 99 additions & 0 deletions src/app/Console/Commands/Addons/RequirePro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php

namespace Backpack\CRUD\app\Console\Commands\Addons;

use Illuminate\Console\Command;

class RequirePro extends Command
{
use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
use \Backpack\CRUD\app\Console\Commands\Traits\AddonsHelper;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'backpack:require:pro
{--debug} : Show process output or not. Useful for debugging.';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Require Backpack Pro';

/**
* Backpack addons install attribute.
*
* @var array
*/
public static $addon = [
'name' => 'Backpack Pro',
'description' => [
'Adds 5 operations, 10 filters, 28 fields, 6 columns, charts',
],
'path' => 'vendor/backpack/pro',
'command' => 'backpack:require:pro',
];

/**
* Execute the console command.
*
* @return mixed Command-line output
*/
public function handle()
{
// Check if it is installed
if ($this->isInstalled()) {
$this->closeProgressBlock();
$this->line(' It was already installed.', 'fg=gray');
$this->newLine();

return;
}

$this->newLine();
$this->infoBlock('Connecting to the Backpack add-on repository');

// Check if repositories exists
$this->composerRepositories();

// Check for authentication
$this->checkForAuthentication();

$this->newLine();
$this->progressBlock($this->description);

// Require package
try {
$this->composerRequire('backpack/pro');
} catch (\Throwable $e) {
$this->errorProgressBlock();
$this->line(' '.$e->getMessage(), 'fg=red');
$this->newLine();

return;
}

// Display general error in case it failed
if (! $this->isInstalled()) {
$this->errorProgressBlock();
$this->note('For further information please check the log file.');
$this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/');
$this->newLine();

return;
}

// Finish
$this->closeProgressBlock();
$this->newLine();
}

public function isInstalled()
{
return file_exists(self::$addon['path'].'/composer.json');
}
}
Loading