-
-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
49e5291
commit abbcbf6
Showing
127 changed files
with
18,045 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
/npm-debug.log | ||
/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "bagisto/laravel-installer", | ||
"license": "MIT", | ||
"description": "Installer package", | ||
"authors": [ | ||
{ | ||
"name": "Bagisto", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": {}, | ||
"autoload": { | ||
"psr-4": { | ||
"Webkul\\Installer\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Webkul\\Installer\\Providers\\InstallerServiceProvider" | ||
], | ||
"aliases": {} | ||
} | ||
}, | ||
"minimum-stability": "dev" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build" | ||
}, | ||
"devDependencies": { | ||
"autoprefixer": "^10.4.16", | ||
"axios": "^1.6.4", | ||
"laravel-vite-plugin": "^0.7.2", | ||
"postcss": "^8.4.23", | ||
"tailwindcss": "^3.3.2", | ||
"vite": "^4.0.0", | ||
"vue": "^3.4.19" | ||
}, | ||
"dependencies": { | ||
"@vee-validate/i18n": "^4.9.1", | ||
"@vee-validate/rules": "^4.9.1", | ||
"@vitejs/plugin-vue": "^4.2.3", | ||
"mitt": "^3.0.0", | ||
"vee-validate": "^4.9.1", | ||
"vue-flatpickr": "^2.3.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
Empty file.
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Attribute/DatabaseSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Core/CountriesSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Core/DatabaseSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Core/StatesSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/EmailTemplate/DatabaseSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Lead/DatabaseSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/User/DatabaseSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/User/RoleSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/User/UserSeeder.php
100755 → 100644
Empty file.
Empty file modified
0
packages/Webkul/Installer/src/Database/Seeders/Workflow/DatabaseSeeder.php
100755 → 100644
Empty file.
110 changes: 110 additions & 0 deletions
110
packages/Webkul/Installer/src/Helpers/DatabaseManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
|
||
namespace Webkul\Installer\Helpers; | ||
|
||
use Exception; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Facades\Schema; | ||
use Webkul\Installer\Database\Seeders\DatabaseSeeder as KrayinDatabaseSeeder; | ||
use Webkul\Installer\Database\Seeders\ProductTableSeeder; | ||
|
||
class DatabaseManager | ||
{ | ||
/** | ||
* Check Database Connection. | ||
*/ | ||
public function isInstalled() | ||
{ | ||
if (! file_exists(base_path('.env'))) { | ||
return false; | ||
} | ||
|
||
try { | ||
DB::connection()->getPDO(); | ||
|
||
$isConnected = (bool) DB::connection()->getDatabaseName(); | ||
|
||
if (! $isConnected) { | ||
return false; | ||
} | ||
|
||
$hasUserTable = Schema::hasTable('users'); | ||
|
||
if (! $hasUserTable) { | ||
return false; | ||
} | ||
|
||
$userCount = DB::table('users')->count(); | ||
|
||
if (! $userCount) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} catch (Exception $e) { | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Drop all the tables and migrate in the database | ||
* | ||
* @return void|string | ||
*/ | ||
public function migration() | ||
{ | ||
try { | ||
Artisan::call('migrate:fresh'); | ||
|
||
return response()->json([ | ||
'success' => true, | ||
'message' => 'Tables is migrated successfully.', | ||
]); | ||
} catch (Exception $e) { | ||
return response()->json([ | ||
'error' => $e->getMessage(), | ||
], 500); | ||
} | ||
} | ||
|
||
/** | ||
* Seed the database. | ||
* | ||
* @return void|string | ||
*/ | ||
public function seeder($data) | ||
{ | ||
$data['parameter'] = [ | ||
'locale' => $data['parameter']['default_locales'], | ||
'currency' => $data['parameter']['allowed_locales'], | ||
]; | ||
|
||
try { | ||
app(KrayinDatabaseSeeder::class)->run($data['parameter']); | ||
|
||
$this->storageLink(); | ||
} catch (Exception $e) { | ||
return $e->getMessage(); | ||
} | ||
} | ||
|
||
/** | ||
* Storage Link. | ||
*/ | ||
private function storageLink() | ||
{ | ||
Artisan::call('storage:link'); | ||
} | ||
|
||
/** | ||
* Generate New Application Key | ||
*/ | ||
public function generateKey() | ||
{ | ||
try { | ||
Artisan::call('key:generate'); | ||
} catch (Exception $e) { | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
packages/Webkul/Installer/src/Helpers/EnvironmentManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
|
||
namespace Webkul\Installer\Helpers; | ||
|
||
use Exception; | ||
|
||
class EnvironmentManager | ||
{ | ||
/** | ||
* Create a helper instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct(protected DatabaseManager $databaseManager) {} | ||
|
||
/** | ||
* Generate ENV File and Installation. | ||
* | ||
* @param [object] $request | ||
*/ | ||
public function generateEnv($request) | ||
{ | ||
$envExamplePath = base_path('.env.example'); | ||
|
||
$envPath = base_path('.env'); | ||
|
||
if (! file_exists($envPath)) { | ||
if (file_exists($envExamplePath)) { | ||
copy($envExamplePath, $envPath); | ||
} else { | ||
touch($envPath); | ||
} | ||
} | ||
|
||
try { | ||
$response = $this->setEnvConfiguration($request->all()); | ||
|
||
$this->databaseManager->generateKey(); | ||
|
||
return $response; | ||
} catch (Exception $e) { | ||
return $e; | ||
} | ||
} | ||
|
||
/** | ||
* Set the ENV file configuration. | ||
* | ||
* @return string | ||
*/ | ||
public function setEnvConfiguration($request) | ||
{ | ||
$envDBParams = []; | ||
|
||
/** | ||
* Update params with form-data. | ||
*/ | ||
if (isset($request['db_hostname'])) { | ||
$envDBParams['DB_HOST'] = $request['db_hostname']; | ||
$envDBParams['DB_DATABASE'] = $request['db_name']; | ||
$envDBParams['DB_PREFIX'] = $request['db_prefix'] ?? ''; | ||
$envDBParams['DB_USERNAME'] = $request['db_username']; | ||
$envDBParams['DB_PASSWORD'] = $request['db_password']; | ||
$envDBParams['DB_CONNECTION'] = $request['db_connection']; | ||
$envDBParams['DB_PORT'] = (int) $request['db_port']; | ||
} | ||
|
||
if (isset($request['app_name'])) { | ||
$envDBParams['APP_NAME'] = $request['app_name'] ?? null; | ||
$envDBParams['APP_URL'] = $request['app_url']; | ||
$envDBParams['APP_LOCALE'] = $request['app_locale']; | ||
$envDBParams['APP_TIMEZONE'] = $request['app_timezone']; | ||
} | ||
|
||
$data = file_get_contents(base_path('.env')); | ||
|
||
foreach ($envDBParams as $key => $value) { | ||
if (preg_match('/\s/', $value)) { | ||
$value = '"'.$value.'"'; | ||
} | ||
|
||
$data = preg_replace("/$key=(.*)/", "$key=$value", $data); | ||
} | ||
|
||
try { | ||
file_put_contents(base_path('.env'), $data); | ||
} catch (Exception $e) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
packages/Webkul/Installer/src/Helpers/ServerRequirements.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
namespace Webkul\Installer\Helpers; | ||
|
||
class ServerRequirements | ||
{ | ||
/** | ||
* Minimum PHP Version Supported (Override is in installer.php config file). | ||
* | ||
* @var string | ||
*/ | ||
private $minPhpVersion = '8.1.0'; | ||
|
||
/** | ||
* Check for the server requirements. | ||
*/ | ||
public function validate(): array | ||
{ | ||
// Server Requirements | ||
$requirements = [ | ||
'php' => [ | ||
'calendar', | ||
'ctype', | ||
'curl', | ||
'dom', | ||
'fileinfo', | ||
'filter', | ||
'gd', | ||
'hash', | ||
'intl', | ||
'json', | ||
'mbstring', | ||
'openssl', | ||
'pcre', | ||
'pdo', | ||
'session', | ||
'tokenizer', | ||
'xml', | ||
], | ||
]; | ||
|
||
$results = []; | ||
|
||
foreach ($requirements as $type => $requirement) { | ||
foreach ($requirement as $item) { | ||
$results['requirements'][$type][$item] = true; | ||
|
||
if (! extension_loaded($item)) { | ||
$results['requirements'][$type][$item] = false; | ||
|
||
$results['errors'] = true; | ||
} | ||
} | ||
} | ||
|
||
return $results; | ||
} | ||
|
||
/** | ||
* Check PHP version requirement. | ||
* | ||
* @return array | ||
*/ | ||
public function checkPHPversion(?string $minPhpVersion = null) | ||
{ | ||
$minVersionPhp = $minPhpVersion ?? $this->minPhpVersion; | ||
|
||
$currentPhpVersion = $this->getPhpVersionInfo(); | ||
|
||
$supported = version_compare($currentPhpVersion['version'], $minVersionPhp) >= 0; | ||
|
||
return [ | ||
'full' => $currentPhpVersion['full'], | ||
'current' => $currentPhpVersion['version'], | ||
'minimum' => $minVersionPhp, | ||
'supported' => $supported, | ||
]; | ||
} | ||
|
||
/** | ||
* Get current Php version information. | ||
* | ||
* @return array | ||
*/ | ||
private static function getPhpVersionInfo() | ||
{ | ||
$currentVersionFull = PHP_VERSION; | ||
|
||
preg_match("#^\d+(\.\d+)*#", $currentVersionFull, $filtered); | ||
|
||
return [ | ||
'full' => $currentVersionFull, | ||
'version' => $filtered[0] ?? $currentVersionFull, | ||
]; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/Webkul/Installer/src/Http/Controllers/Controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Webkul\Installer\Http\Controllers; | ||
|
||
use Illuminate\Foundation\Bus\DispatchesJobs; | ||
use Illuminate\Foundation\Validation\ValidatesRequests; | ||
use Illuminate\Routing\Controller as BaseController; | ||
|
||
class Controller extends BaseController | ||
{ | ||
use DispatchesJobs, ValidatesRequests; | ||
} |
Oops, something went wrong.