Skip to content

Commit

Permalink
added skip dir support with regexr
Browse files Browse the repository at this point in the history
  • Loading branch information
Sharifur authored and Sharifur committed May 24, 2023
1 parent 4828767 commit d17e260
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions src/XgApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\File;

Expand All @@ -16,8 +17,8 @@ class XgApiClient
public function extensionCheck($name)
{
if (!extension_loaded($name)) {
$response = false;
} else {
$response = false;
} else {
$response = true;
}
return $response;
Expand Down Expand Up @@ -85,14 +86,15 @@ private function systemUpgradeWithLatestVersion(){
$getDirectory = ($getDirectory == 'change-logs.json') ? $getDirectory : chop($getDirectory, $file->getFilename());

// not to move if found these directories
$skipDir = ['.fleet/', '.idea/', '.vscode/'];
$skipFiles = ['.DS_Store'];
$cacheDirExist = in_array($getDirectory, $skipDir) && (str_contains($getDirectory, '.fleet/') || str_contains($getDirectory, '.idea') || str_contains($getDirectory, '.vscode'));
$skipDir = ['.fleet', '.idea', '.vscode/',"lang",'.git'];
$skipFiles = ['.DS_Store',"dynamic-style.css","dynamic-script.js"];

if (str_contains($getDirectory, '.git/')) {
//dd('Git'.$getDirectory);
//return response()->json('Alert...your update version folder have .git, please contact your author!!');

preg_match('/[a-zA-Z_]+?(?=\s*?[^\w]*?$)/',$getDirectory,$currentFolderName);
if (in_array(current($currentFolderName), $skipDir)) {
continue;
}

if (str_contains($getDirectory, 'custom/')) {
$changesLogs = json_decode(Storage::get($updatedFileLocation. '/change-logs.json'))->custom;
foreach($changesLogs as $changesLog) {
Expand All @@ -106,31 +108,12 @@ private function systemUpgradeWithLatestVersion(){
}
}
if (str_contains($getDirectory, 'assets/') && (!str_contains($getDirectory, 'Modules/') && !str_contains($getDirectory, 'plugins'))) {
//dd($getDirectory, $file->move(storage_path('../../' . $getDirectory)));

if (!in_array($file->getFilename(),$skipFiles)){
$file->move(storage_path('../../' . $getDirectory));
}
}


// if (str_contains($getDirectory, 'Modules/')) {
// //check change-logs file for which module will update;
// $modules = json_decode(Storage::get($updatedFileLocation. '/change-logs.json'))->modules;
// if (!in_array($file->getFilename(),$skipFiles)){
// foreach ($modules as $module) {
// if (str_contains($getDirectory, 'Modules/'.$module)) {
// $file->move(storage_path('../' . $getDirectory));
// }
// }
// }
// }
//did not found any use case
// elseif (($getDirectory !== 'change-logs.json') && !$cacheDirExist && $getDirectory !== 'custom/') {
// if (!in_array($file->getFilename(),$skipFiles)){
// $file->move(storage_path('../' . $getDirectory));
// }
// }

}
}

Expand Down Expand Up @@ -159,7 +142,7 @@ private function systemDbUpgrade($isTenant,$version){
try {
update_static_option("site_script_version",trim($version,"vV-"));
}catch (\Exception $e){}

return true;
} catch (\Exception $e) {
return false;
Expand All @@ -182,6 +165,7 @@ private function systemDbUpgrade($isTenant,$version){
Artisan::call('cache:clear');
//tenant database migrate
try {
//todo run a query to get all the tenant then run migrate one by one...
Artisan::call('tenants:migrate', ['--force' => true]);
}catch (\Exception $e){

Expand Down Expand Up @@ -337,9 +321,9 @@ public function VerifyLicense($purchaseCode,$email,$envatoUsername){
}

return [
"success" => false,
"message" => $messsage,
"data" => null
"success" => false,
"message" => $messsage,
"data" => null
];

}
Expand Down

0 comments on commit d17e260

Please sign in to comment.