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

Add options to lunar:install and lunar:hub:install to allow for non-prompting usage #1294

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a9b87f7
Updating docs versions
glennjacobs Sep 22, 2023
072ad32
Check if the user is null when logging out
dewebdesigns Sep 23, 2023
fbe1639
Fixes #1261
alecritson Sep 27, 2023
a256047
Merge pull request #1274 from lunarphp/hotfix/fix-scout-db-empty-search
alecritson Sep 27, 2023
1f25964
Check if the user is null when logging out #1269
alecritson Sep 28, 2023
a226892
Format config files more in line with the Laravel skeleton (#1273)
adevade Sep 28, 2023
3b1c248
Cover situation when all of discount isnt actually able to be used (#…
ryanmitchell Sep 29, 2023
ecb29f1
Allow section to be null on attributes (#1259)
netzknecht Sep 29, 2023
2a1c79a
Support blank and null coupons (#1293)
ryanmitchell Oct 6, 2023
73a2bc5
Fix duplicating product associations #1289 (#1291)
alecritson Oct 6, 2023
9e58629
Add options to allow for retaining existing configuration if exists a…
charlielangridge Oct 6, 2023
66a2541
Fix order create docs #1284 (#1292)
alecritson Oct 6, 2023
47b4c57
Discount documentation fixes (#1282)
NuktukDev Oct 6, 2023
91f1b98
Merge remote-tracking branch 'origin/0.6' into 0.6
charlielangridge Oct 6, 2023
0c48d04
Add the facility to set new admin user details through options
charlielangridge Oct 6, 2023
4f83fa2
Change options to accept inputs
charlielangridge Oct 6, 2023
9121128
Merge branch 'main' into 0.6
charlielangridge Oct 18, 2023
3eb77de
Merge branch 'main' into 0.6
charlielangridge Oct 18, 2023
8895072
Merge branch '0.8' into 0.6
glennjacobs Dec 18, 2023
70b5591
Merge branch '0.8' into 0.6
glennjacobs May 6, 2024
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
10 changes: 5 additions & 5 deletions packages/admin/src/Console/Commands/InstallHub.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InstallHub extends Command
*
* @var string
*/
protected $signature = 'lunar:hub:install';
protected $signature = 'lunar:hub:install {--firstName= : Admin User First Name} {--lastName= : Admin User Last Name} {--email= : Admin User Email} {--password= : Admin User Password}';

/**
* The console command description.
Expand All @@ -45,10 +45,10 @@ public function handle()
if (! Staff::whereAdmin(true)->exists()) {
$this->info('Create an admin user');

$firstname = $this->ask('Whats your first name?');
$lastname = $this->ask('Whats your last name?');
$email = $this->ask('Whats your email address?');
$password = $this->secret('Enter a password');
$firstname = $this->option('firstName') ?? $this->ask('Whats your first name?');
$lastname = $this->option('lastName') ?? $this->ask('Whats your last name?');
$email = $this->option('email') ?? $this->ask('Whats your email address?');
$password = $this->option('password') ?? $this->secret('Enter a password');

/** @var Staff $staff */
$staff = Staff::create([
Expand Down
46 changes: 26 additions & 20 deletions packages/core/src/Console/InstallLunar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InstallLunar extends Command
*
* @var string
*/
protected $signature = 'lunar:install';
protected $signature = 'lunar:install {--retainConfig : Retain existing configuration if exists } {--migrate : Run Database Migrations} {--firstName= : Admin User First Name} {--lastName= : Admin User Last Name} {--email= : Admin User Email} {--password= : Admin User Password}';

/**
* The console command description.
Expand All @@ -47,28 +47,28 @@ public function handle(): void
$this->newLine();
$this->info('Publishing configuration...');

if (! $this->configExists('lunar')) {
if (!$this->configExists('lunar')) {
$this->publishConfiguration();
} else {
if ($this->shouldOverwriteConfig()) {
if ($this->option('retainConfig') || !$this->shouldOverwriteConfig()) {
$this->line('Existing configuration was not overwritten');
} else {
$this->line('Overwriting configuration file...');
$this->publishConfiguration($force = true);
} else {
$this->line('Existing configuration was not overwritten');
}
}

if ($this->confirm('Run database migrations?', true)) {
if ($this->option('migrate') || $this->confirm('Run database migrations?', true)) {
$this->call('migrate');
}

DB::transaction(function () {
if (! Country::count()) {
if (!Country::count()) {
$this->info('Importing countries');
$this->call('lunar:import:address-data');
}

if (! Channel::whereDefault(true)->exists()) {
if (!Channel::whereDefault(true)->exists()) {
$this->info('Setting up default channel');

Channel::create([
Expand All @@ -79,7 +79,7 @@ public function handle(): void
]);
}

if (! Language::count()) {
if (!Language::count()) {
$this->info('Adding default language');

Language::create([
Expand All @@ -89,7 +89,7 @@ public function handle(): void
]);
}

if (! Currency::whereDefault(true)->exists()) {
if (!Currency::whereDefault(true)->exists()) {
$this->info('Adding a default currency (USD)');

Currency::create([
Expand All @@ -102,7 +102,7 @@ public function handle(): void
]);
}

if (! CustomerGroup::whereDefault(true)->exists()) {
if (!CustomerGroup::whereDefault(true)->exists()) {
$this->info('Adding a default customer group.');

CustomerGroup::create([
Expand All @@ -112,7 +112,7 @@ public function handle(): void
]);
}

if (! CollectionGroup::count()) {
if (!CollectionGroup::count()) {
$this->info('Adding an initial collection group');

CollectionGroup::create([
Expand All @@ -121,7 +121,7 @@ public function handle(): void
]);
}

if (! TaxClass::count()) {
if (!TaxClass::count()) {
$this->info('Adding a default tax class.');

TaxClass::create([
Expand All @@ -130,7 +130,7 @@ public function handle(): void
]);
}

if (! Attribute::count()) {
if (!Attribute::count()) {
$this->info('Setting up initial attributes');

$group = AttributeGroup::create([
Expand Down Expand Up @@ -224,7 +224,7 @@ public function handle(): void
]);
}

if (! ProductType::count()) {
if (!ProductType::count()) {
$this->info('Adding a product type.');

$type = ProductType::create([
Expand All @@ -240,7 +240,13 @@ public function handle(): void
if ($this->isHubInstalled()) {
$this->newLine();
$this->line('Installing Admin Hub.');
$this->call('lunar:hub:install');
$this->call('lunar:hub:install', [
'--firstName' => $this->option('firstName'),
'--lastName' => $this->option('lastName'),
'--email' => $this->option('email'),
'--password' => $this->option('password'),
]);

}

$this->newLine();
Expand All @@ -255,15 +261,15 @@ public function handle(): void
/**
* Checks if config exists given a filename.
*
* @param string $fileName
* @param string $fileName
*/
private function configExists($fileName): bool
{
if (! File::isDirectory(config_path($fileName))) {
if (!File::isDirectory(config_path($fileName))) {
return false;
}

return ! empty(File::allFiles(config_path($fileName)));
return !empty(File::allFiles(config_path($fileName)));
}

/**
Expand All @@ -280,7 +286,7 @@ private function shouldOverwriteConfig(): bool
/**
* Publishes configuration for the Service Provider.
*
* @param bool $forcePublish
* @param bool $forcePublish
*/
private function publishConfiguration($forcePublish = false): void
{
Expand Down
Loading