From 016ce1fbf62fe197c2221782372a74aef1617fbd Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:12:18 +0100 Subject: [PATCH 01/13] Remove invalid reference to Artisan --- app/Console/Commands/Install.php | 3 +-- install.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index f048fd7..c8a29f7 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -52,7 +52,7 @@ class Install extends Command ]); copy($basePath . '/.env.example', $basePath . '/.env'); - Artisan::call('key:generate'); + $this->call('key:generate'); // Command stack @@ -66,7 +66,6 @@ class Install extends Command try { - $npm->mustRun(); $progress->advance(); diff --git a/install.sh b/install.sh index 56cc55e..6bdca14 100644 --- a/install.sh +++ b/install.sh @@ -5,4 +5,5 @@ sleep 3 composer install echo "Full installation starting!" +sleep 3 php artisan application:install From 7c7d4a306c1ce103af2ded5f6eb2069a68a9d3ea Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:20:16 +0100 Subject: [PATCH 02/13] Separate process args --- app/Console/Commands/Install.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index c8a29f7..11f533e 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -56,9 +56,8 @@ class Install extends Command // Command stack - $composer = new Process('composer install', $basePath); - $npm = new Process('npm install', $basePath); - $npmBuild = new Process('npm run dev', $basePath); + $npm = new Process(['npm', 'install'], $basePath); + $npmBuild = new Process(['npm', 'run dev'], $basePath); $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); From c7caf3a67c6264539061c3cea9750941c1b673d0 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:23:46 +0100 Subject: [PATCH 03/13] Remove process args --- app/Console/Commands/Install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 11f533e..60c5017 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -56,8 +56,8 @@ class Install extends Command // Command stack - $npm = new Process(['npm', 'install'], $basePath); - $npmBuild = new Process(['npm', 'run dev'], $basePath); + $npm = new Process(['npm install', ''], $basePath); + $npmBuild = new Process(['npm run dev', ''], $basePath); $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); From 1bc63725c95d9d2ccfc11ce647037156dcfc13ab Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:27:33 +0100 Subject: [PATCH 04/13] Silence npm WARN output (when applicable) --- app/Console/Commands/Install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 60c5017..c4c8044 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -56,8 +56,8 @@ class Install extends Command // Command stack - $npm = new Process(['npm install', ''], $basePath); - $npmBuild = new Process(['npm run dev', ''], $basePath); + $npm = new Process(['npm install', '--silent'], $basePath); + $npmBuild = new Process(['npm run dev', '--silent'], $basePath); $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); From 1c08cd9057d3f1fc947a89948e96ed8c85610e18 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:29:55 +0100 Subject: [PATCH 05/13] Compat for npm in different directories --- app/Console/Commands/Install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index c4c8044..9c1f923 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -56,8 +56,8 @@ class Install extends Command // Command stack - $npm = new Process(['npm install', '--silent'], $basePath); - $npmBuild = new Process(['npm run dev', '--silent'], $basePath); + $npm = new Process(['/usr/bin/env npm install', '--silent'], $basePath); + $npmBuild = new Process(['/usr/bin/env npm run dev', '--silent'], $basePath); $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); From d121119706c97d4cb75a9cf764cb321667acf63b Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:37:11 +0100 Subject: [PATCH 06/13] Reverse npm silence --- app/Console/Commands/Install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 9c1f923..53792eb 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -56,8 +56,8 @@ class Install extends Command // Command stack - $npm = new Process(['/usr/bin/env npm install', '--silent'], $basePath); - $npmBuild = new Process(['/usr/bin/env npm run dev', '--silent'], $basePath); + $npm = new Process(['/usr/bin/env npm install'], $basePath); + $npmBuild = new Process(['/usr/bin/env npm run dev'], $basePath); $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); From 653641f4e866222018fb0b7f460f83f1e5435113 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:52:41 +0100 Subject: [PATCH 07/13] Replace Symfony Process --- app/Console/Commands/Install.php | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 53792eb..933d9f5 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -54,34 +54,23 @@ class Install extends Command copy($basePath . '/.env.example', $basePath . '/.env'); $this->call('key:generate'); - - // Command stack - $npm = new Process(['/usr/bin/env npm install'], $basePath); - $npmBuild = new Process(['/usr/bin/env npm run dev'], $basePath); - - $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); - $progress = $this->output->createProgressBar(3); - try - { - $npm->mustRun(); - $progress->advance(); + $npmOut = 0; + $npmBuildOut = 0; - $npmBuild->mustRun(); - $progress->advance(); - } - catch(ProcessFailedException $pfe) + exec('cd ' . $basePath . ' && npm install', null, $npmOut); + exec('cd ' . $basePath . '&& npm run dev', null, $npmBuildOut); + + + if($npmOut !== 0 && $npmBuildOut !== 0) { - $this->error('[!] One or more errors have ocurred whilst attempting to install dependencies. This is the error message: ' . $pfe->getMessage()); + $this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.'); $this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.'); return false; } - finally - { - $progress->finish(); - } + $settings = []; From 00f37d3f7edd8198df50f1f1fbbea78db2711ea5 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:53:00 +0100 Subject: [PATCH 08/13] Remove Symfony Process refs --- app/Console/Commands/Install.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 933d9f5..a668ce0 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -4,8 +4,6 @@ namespace App\Console\Commands; use Illuminate\Console\Command; use Illuminate\Support\Facades\Storage; -use Symfony\Component\Process\Exception\ProcessFailedException; -use Symfony\Component\Process\Process; class Install extends Command { From 96298cd38c2e0b44da7e60e86de3e1cc6c2c2e86 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 05:55:23 +0100 Subject: [PATCH 09/13] Add forgotten output for commands --- app/Console/Commands/Install.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index a668ce0..1c253d0 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -55,10 +55,13 @@ class Install extends Command $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); $npmOut = 0; - $npmBuildOut = 0; + $npmMessages = []; - exec('cd ' . $basePath . ' && npm install', null, $npmOut); - exec('cd ' . $basePath . '&& npm run dev', null, $npmBuildOut); + $npmBuildOut = 0; + $npmBuildMessages = []; + + exec('cd ' . $basePath . ' && npm install', $npmBuildOut, $npmOut); + exec('cd ' . $basePath . '&& npm run dev', $npmBuildMessages, $npmBuildOut); if($npmOut !== 0 && $npmBuildOut !== 0) From 669c3c87e6d7f4447890fbfee663c3738e36f8f4 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 06:01:10 +0100 Subject: [PATCH 10/13] Removed colons that artisan already added --- app/Console/Commands/Install.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 1c253d0..367669c 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -60,8 +60,8 @@ class Install extends Command $npmBuildOut = 0; $npmBuildMessages = []; - exec('cd ' . $basePath . ' && npm install', $npmBuildOut, $npmOut); - exec('cd ' . $basePath . '&& npm run dev', $npmBuildMessages, $npmBuildOut); + exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut); + exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut); if($npmOut !== 0 && $npmBuildOut !== 0) @@ -83,30 +83,30 @@ class Install extends Command { $this->info('== Database Settings (1/6) =='); - $settings['DB_USERNAME'] = $this->ask('Database username [root]: ') ?? 'root'; - $settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen): '); - $settings['DB_DATABASE'] = $this->ask('Database name: '); - $settings['DB_PORT'] = $this->ask('Database port [3306]: ') ?? 3306; - $settings['DB_HOST'] = $this->ask('Database hostname [localhost]: ') ?? 'localhost'; + $settings['DB_USERNAME'] = $this->ask('Database username [root]') ?? 'root'; + $settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)'); + $settings['DB_DATABASE'] = $this->ask('Database name'); + $settings['DB_PORT'] = $this->ask('Database port [3306]') ?? 3306; + $settings['DB_HOST'] = $this->ask('Database hostname [localhost]') ?? 'localhost'; $this->info('== Antispam Settings (2/6) (Recaptcha v2) =='); - $settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key: '); - $settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key: '); + $settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key'); + $settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key'); $this->info('== IP Geolocation Settings (3/6) (refer to README.md) =='); - $settings['APIGEO_API_KEY'] = $this->ask('API Key: '); + $settings['APIGEO_API_KEY'] = $this->ask('API Key'); $this->info('== Notification Settings (4/6) (Email) =='); - $settings['MAIL_USERNAME'] = $this->ask('SMTP Username: '); + $settings['MAIL_USERNAME'] = $this->ask('SMTP Username'); $settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen): '); - $settings['MAIL_PORT'] = $this->ask('SMTP Server Port [25]: ') ?? 25; - $settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname: '); + $settings['MAIL_PORT'] = $this->ask('SMTP Server Port [25]') ?? 25; + $settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname'); $this->info('== Notification Settings (5/6) (Slack) =='); - $settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL: '); + $settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL'); $this->info('== Web Settings (6/6) =='); - $settings['APP_URL'] = $this->ask('Application\'s URL [http://localhost]: ') ?? 'http://localhost'; + $settings['APP_URL'] = $this->ask('Application\'s URL [http://localhost]') ?? 'http://localhost'; } while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.')); From a3e727f1f14c500d00b0275ceed989df6a77f63c Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 06:14:07 +0100 Subject: [PATCH 11/13] Remove optional parameters in install cmd --- app/Console/Commands/Install.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 367669c..fb84bf5 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -77,17 +77,15 @@ class Install extends Command $settings = []; $this->info('>> Configuring application - We\'re going to ask a few questions here!'); - $this->info('>> Questions with a value in brackets are optional and you may leave them empty to use it'); - do { $this->info('== Database Settings (1/6) =='); - $settings['DB_USERNAME'] = $this->ask('Database username [root]') ?? 'root'; + $settings['DB_USERNAME'] = $this->ask('Database username'); $settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)'); $settings['DB_DATABASE'] = $this->ask('Database name'); - $settings['DB_PORT'] = $this->ask('Database port [3306]') ?? 3306; - $settings['DB_HOST'] = $this->ask('Database hostname [localhost]') ?? 'localhost'; + $settings['DB_PORT'] = $this->ask('Database port'); + $settings['DB_HOST'] = $this->ask('Database hostname'); $this->info('== Antispam Settings (2/6) (Recaptcha v2) =='); $settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key'); @@ -98,15 +96,15 @@ class Install extends Command $this->info('== Notification Settings (4/6) (Email) =='); $settings['MAIL_USERNAME'] = $this->ask('SMTP Username'); - $settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen): '); - $settings['MAIL_PORT'] = $this->ask('SMTP Server Port [25]') ?? 25; + $settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)'); + $settings['MAIL_PORT'] = $this->ask('SMTP Server Port'); $settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname'); $this->info('== Notification Settings (5/6) (Slack) =='); $settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL'); $this->info('== Web Settings (6/6) =='); - $settings['APP_URL'] = $this->ask('Application\'s URL [http://localhost]') ?? 'http://localhost'; + $settings['APP_URL'] = $this->ask('Application\'s URL'); } while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.')); From cb2b45b55faabbdb78fdfa3a3850a339b35da026 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 06:22:43 +0100 Subject: [PATCH 12/13] Simplify settings save call --- app/Console/Commands/Install.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index fb84bf5..aeac485 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -110,10 +110,7 @@ class Install extends Command foreach($settings as $keyname => $value) { - $this->callSilent('environment:modify', [ - 'key' => $keyname, - 'value' => $value - ]); + $this->callSilent('environment:modify ' . $keyname . ' ' . $value); } $this->info('>> Saved configuration settings!'); From 173dc57aa705b5fb92b4079a25237c2aa00e39d0 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Thu, 9 Jul 2020 06:27:21 +0100 Subject: [PATCH 13/13] Further simplify settings save call --- app/Console/Commands/Install.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index aeac485..f508d20 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -110,7 +110,10 @@ class Install extends Command foreach($settings as $keyname => $value) { - $this->callSilent('environment:modify ' . $keyname . ' ' . $value); + $this->callSilent('environment:modify', [ + $keyname, + $value + ]); } $this->info('>> Saved configuration settings!');