mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 11:00:40 +08:00
Add Upgrade toKeep ignore option
- Add way to define files/folders to not be considered as toKeep
This commit is contained in:
parent
533ce665af
commit
e7c9d00aa7
3 changed files with 205 additions and 11 deletions
|
@ -19,6 +19,126 @@ parameters:
|
||||||
- '.env.local'
|
- '.env.local'
|
||||||
- '.env.local.php'
|
- '.env.local.php'
|
||||||
- 'tmp'
|
- 'tmp'
|
||||||
|
toKeepIgnore:
|
||||||
|
- 'public/legacy/modules/Accounts'
|
||||||
|
- 'public/legacy/modules/ACL'
|
||||||
|
- 'public/legacy/modules/ACLActions'
|
||||||
|
- 'public/legacy/modules/ACLRoles'
|
||||||
|
- 'public/legacy/modules/Activities'
|
||||||
|
- 'public/legacy/modules/Administration'
|
||||||
|
- 'public/legacy/modules/Alerts'
|
||||||
|
- 'public/legacy/modules/AM_ProjectTemplates'
|
||||||
|
- 'public/legacy/modules/AM_TaskTemplates'
|
||||||
|
- 'public/legacy/modules/AOBH_BusinessHours'
|
||||||
|
- 'public/legacy/modules/AOD_Index'
|
||||||
|
- 'public/legacy/modules/AOD_IndexEvent'
|
||||||
|
- 'public/legacy/modules/AOK_KnowledgeBase'
|
||||||
|
- 'public/legacy/modules/AOK_Knowledge_Base_Categories'
|
||||||
|
- 'public/legacy/modules/AOP_Case_Events'
|
||||||
|
- 'public/legacy/modules/AOP_Case_Updates'
|
||||||
|
- 'public/legacy/modules/AOR_Charts'
|
||||||
|
- 'public/legacy/modules/AOR_Conditions'
|
||||||
|
- 'public/legacy/modules/AOR_Fields'
|
||||||
|
- 'public/legacy/modules/AOR_Reports'
|
||||||
|
- 'public/legacy/modules/AOR_Scheduled_Reports'
|
||||||
|
- 'public/legacy/modules/AOS_Contracts'
|
||||||
|
- 'public/legacy/modules/AOS_Invoices'
|
||||||
|
- 'public/legacy/modules/AOS_Line_Item_Groups'
|
||||||
|
- 'public/legacy/modules/AOS_PDF_Templates'
|
||||||
|
- 'public/legacy/modules/AOS_Product_Categories'
|
||||||
|
- 'public/legacy/modules/AOS_Products'
|
||||||
|
- 'public/legacy/modules/AOS_Products_Quotes'
|
||||||
|
- 'public/legacy/modules/AOS_Quotes'
|
||||||
|
- 'public/legacy/modules/AOW_Actions'
|
||||||
|
- 'public/legacy/modules/AOW_Conditions'
|
||||||
|
- 'public/legacy/modules/AOW_Processed'
|
||||||
|
- 'public/legacy/modules/AOW_WorkFlow'
|
||||||
|
- 'public/legacy/modules/Audit'
|
||||||
|
- 'public/legacy/modules/BeanDictionary.php'
|
||||||
|
- 'public/legacy/modules/Bugs'
|
||||||
|
- 'public/legacy/modules/Calendar'
|
||||||
|
- 'public/legacy/modules/Calls'
|
||||||
|
- 'public/legacy/modules/Calls_Reschedule'
|
||||||
|
- 'public/legacy/modules/CampaignLog'
|
||||||
|
- 'public/legacy/modules/Campaigns'
|
||||||
|
- 'public/legacy/modules/CampaignTrackers'
|
||||||
|
- 'public/legacy/modules/Cases'
|
||||||
|
- 'public/legacy/modules/Charts'
|
||||||
|
- 'public/legacy/modules/Configurator'
|
||||||
|
- 'public/legacy/modules/Connectors'
|
||||||
|
- 'public/legacy/modules/Contacts'
|
||||||
|
- 'public/legacy/modules/Currencies'
|
||||||
|
- 'public/legacy/modules/Delegates'
|
||||||
|
- 'public/legacy/modules/DocumentRevisions'
|
||||||
|
- 'public/legacy/modules/Documents'
|
||||||
|
- 'public/legacy/modules/DynamicFields'
|
||||||
|
- 'public/legacy/modules/EAPM'
|
||||||
|
- 'public/legacy/modules/EmailAddresses'
|
||||||
|
- 'public/legacy/modules/EmailMan'
|
||||||
|
- 'public/legacy/modules/EmailMarketing'
|
||||||
|
- 'public/legacy/modules/Emails'
|
||||||
|
- 'public/legacy/modules/EmailTemplates'
|
||||||
|
- 'public/legacy/modules/EmailText'
|
||||||
|
- 'public/legacy/modules/Employees'
|
||||||
|
- 'public/legacy/modules/Favorites'
|
||||||
|
- 'public/legacy/modules/FP_Event_Locations'
|
||||||
|
- 'public/legacy/modules/FP_events'
|
||||||
|
- 'public/legacy/modules/Groups'
|
||||||
|
- 'public/legacy/modules/Help'
|
||||||
|
- 'public/legacy/modules/History'
|
||||||
|
- 'public/legacy/modules/Home'
|
||||||
|
- 'public/legacy/modules/iCals'
|
||||||
|
- 'public/legacy/modules/Import'
|
||||||
|
- 'public/legacy/modules/InboundEmail'
|
||||||
|
- 'public/legacy/modules/jjwg_Address_Cache'
|
||||||
|
- 'public/legacy/modules/jjwg_Areas'
|
||||||
|
- 'public/legacy/modules/jjwg_Maps'
|
||||||
|
- 'public/legacy/modules/jjwg_Markers'
|
||||||
|
- 'public/legacy/modules/LabelEditor'
|
||||||
|
- 'public/legacy/modules/Leads'
|
||||||
|
- 'public/legacy/modules/MailMerge'
|
||||||
|
- 'public/legacy/modules/Meetings'
|
||||||
|
- 'public/legacy/modules/MergeRecords'
|
||||||
|
- 'public/legacy/modules/ModuleBuilder'
|
||||||
|
- 'public/legacy/modules/MySettings'
|
||||||
|
- 'public/legacy/modules/Notes'
|
||||||
|
- 'public/legacy/modules/OAuth2Clients'
|
||||||
|
- 'public/legacy/modules/OAuth2Tokens'
|
||||||
|
- 'public/legacy/modules/OAuthKeys'
|
||||||
|
- 'public/legacy/modules/OAuthTokens'
|
||||||
|
- 'public/legacy/modules/Opportunities'
|
||||||
|
- 'public/legacy/modules/OptimisticLock'
|
||||||
|
- 'public/legacy/modules/OutboundEmailAccounts'
|
||||||
|
- 'public/legacy/modules/Project'
|
||||||
|
- 'public/legacy/modules/ProjectTask'
|
||||||
|
- 'public/legacy/modules/ProspectLists'
|
||||||
|
- 'public/legacy/modules/Prospects'
|
||||||
|
- 'public/legacy/modules/Relationships'
|
||||||
|
- 'public/legacy/modules/Releases'
|
||||||
|
- 'public/legacy/modules/Reminders'
|
||||||
|
- 'public/legacy/modules/Reminders_Invitees'
|
||||||
|
- 'public/legacy/modules/ResourceCalendar'
|
||||||
|
- 'public/legacy/modules/Roles'
|
||||||
|
- 'public/legacy/modules/SavedSearch'
|
||||||
|
- 'public/legacy/modules/Schedulers'
|
||||||
|
- 'public/legacy/modules/SchedulersJobs'
|
||||||
|
- 'public/legacy/modules/SecurityGroups'
|
||||||
|
- 'public/legacy/modules/Spots'
|
||||||
|
- 'public/legacy/modules/Studio'
|
||||||
|
- 'public/legacy/modules/SugarFeed'
|
||||||
|
- 'public/legacy/modules/SurveyQuestionOptions'
|
||||||
|
- 'public/legacy/modules/SurveyQuestionResponses'
|
||||||
|
- 'public/legacy/modules/SurveyQuestions'
|
||||||
|
- 'public/legacy/modules/SurveyResponses'
|
||||||
|
- 'public/legacy/modules/Surveys'
|
||||||
|
- 'public/legacy/modules/TableDictionary.php'
|
||||||
|
- 'public/legacy/modules/Tasks'
|
||||||
|
- 'public/legacy/modules/TemplateSectionLine'
|
||||||
|
- 'public/legacy/modules/Trackers'
|
||||||
|
- 'public/legacy/modules/UpgradeWizard'
|
||||||
|
- 'public/legacy/modules/UserPreferences'
|
||||||
|
- 'public/legacy/modules/Users'
|
||||||
|
- 'public/legacy/modules/vCals'
|
||||||
toExpand:
|
toExpand:
|
||||||
- 'public'
|
- 'public'
|
||||||
- 'public/legacy'
|
- 'public/legacy'
|
||||||
|
|
|
@ -46,6 +46,16 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
*/
|
*/
|
||||||
protected $toKeepKeys = [];
|
protected $toKeepKeys = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $toKeepIgnore = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool[]
|
||||||
|
*/
|
||||||
|
protected $toKeepIgnoreKeys = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
@ -107,16 +117,19 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
string $basePath = ''
|
string $basePath = ''
|
||||||
): void {
|
): void {
|
||||||
$origin = $this->newFinder($originPath)->files();
|
$origin = $this->newFinder($originPath)->files();
|
||||||
|
$destination = $this->newDestinationFinder($destinationPath);
|
||||||
|
$destination->files();
|
||||||
|
|
||||||
if (!$origin->hasResults()) {
|
if (!$origin->hasResults()) {
|
||||||
|
if ($destination->hasResults()) {
|
||||||
|
$this->addEntriesToRemove($destination, $manifest, $basePath);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addEntriesToCopy($origin, $manifest, $basePath);
|
$this->addEntriesToCopy($origin, $manifest, $basePath);
|
||||||
|
|
||||||
$destination = $this->newDestinationFinder($destinationPath);
|
|
||||||
$destination->files();
|
|
||||||
|
|
||||||
if (!$destination->hasResults()) {
|
if (!$destination->hasResults()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -216,10 +229,11 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($manifest[$pathFromBase]) &&
|
if ($this->isToKeepPath($basePath, $pathFromBase)) {
|
||||||
!$this->isToKeep($pathFromBase) &&
|
continue;
|
||||||
!$this->isToKeep($basePath)
|
}
|
||||||
) {
|
|
||||||
|
if (empty($manifest[$pathFromBase])) {
|
||||||
$manifest[$pathFromBase] = $this->newManifestEntry($pathFromBase, 'delete', $entry->getType());
|
$manifest[$pathFromBase] = $this->newManifestEntry($pathFromBase, 'delete', $entry->getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +251,6 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
/**
|
/**
|
||||||
* Set files to keep
|
* Set files to keep
|
||||||
* @param array $toKeep
|
* @param array $toKeep
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function setToKeep(array $toKeep): void
|
public function setToKeep(array $toKeep): void
|
||||||
{
|
{
|
||||||
|
@ -258,6 +271,39 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
return $this->toKeepKeys;
|
return $this->toKeepKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Files to always look at origin, even if to keep
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getToKeepIgnore(): array
|
||||||
|
{
|
||||||
|
return $this->toKeepIgnore;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to keepIgnore
|
||||||
|
* @param array $toKeepIgnore
|
||||||
|
*/
|
||||||
|
public function setToKeepIgnore(array $toKeepIgnore): void
|
||||||
|
{
|
||||||
|
$this->toKeepIgnore = $toKeepIgnore;
|
||||||
|
$this->toKeepIgnoreKeys = [];
|
||||||
|
|
||||||
|
foreach ($this->toKeepIgnore as $item) {
|
||||||
|
$this->toKeepIgnoreKeys[$item] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Files to always look at origin, even if to keep
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getToKeepIgnoreKeys(): array
|
||||||
|
{
|
||||||
|
return $this->toKeepIgnoreKeys;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add folder directories
|
* Add folder directories
|
||||||
* @param string $originPath
|
* @param string $originPath
|
||||||
|
@ -273,16 +319,19 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
): void {
|
): void {
|
||||||
$origin = $this->newFinder($originPath);
|
$origin = $this->newFinder($originPath);
|
||||||
$origin->directories();
|
$origin->directories();
|
||||||
|
$destination = $this->newDestinationFinder($destinationPath);
|
||||||
|
$destination->directories();
|
||||||
|
|
||||||
if (!$origin->hasResults()) {
|
if (!$origin->hasResults()) {
|
||||||
|
if ($destination->hasResults()) {
|
||||||
|
$this->addEntriesToRemove($destination, $manifest, $basePath);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addEntriesToCopy($origin, $manifest, $basePath);
|
$this->addEntriesToCopy($origin, $manifest, $basePath);
|
||||||
|
|
||||||
$destination = $this->newDestinationFinder($destinationPath);
|
|
||||||
$destination->directories();
|
|
||||||
|
|
||||||
if (!$destination->hasResults()) {
|
if (!$destination->hasResults()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -383,6 +432,16 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
return !empty($this->getToKeepKeys()[$path]);
|
return !empty($this->getToKeepKeys()[$path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if path is to ignore toKeep
|
||||||
|
* @param string $path
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isToKeepIgnore(string $path): bool
|
||||||
|
{
|
||||||
|
return !empty($this->getToKeepIgnoreKeys()[$path]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if path is to expand
|
* Check if path is to expand
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
@ -392,4 +451,18 @@ class FolderComparator implements FolderComparatorInterface
|
||||||
{
|
{
|
||||||
return !empty($this->getPathsToExpandKeys()[$path]);
|
return !empty($this->getPathsToExpandKeys()[$path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $basePath
|
||||||
|
* @param string $pathFromBase
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function isToKeepPath($basePath, string $pathFromBase): bool
|
||||||
|
{
|
||||||
|
if ($this->isToKeepIgnore($pathFromBase)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->isToKeep($pathFromBase) || $this->isToKeep($basePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ class UpgradePackageHandler extends PackageHandler
|
||||||
$this->compare = $compare;
|
$this->compare = $compare;
|
||||||
|
|
||||||
$this->compare->setToKeep($upgradeConfig['toKeep']);
|
$this->compare->setToKeep($upgradeConfig['toKeep']);
|
||||||
|
$this->compare->setToKeepIgnore($upgradeConfig['toKeepIgnore']);
|
||||||
$this->compare->setPathsToExpand($upgradeConfig['toExpand']);
|
$this->compare->setPathsToExpand($upgradeConfig['toExpand']);
|
||||||
$this->upgradeLogger = $upgradeLogger;
|
$this->upgradeLogger = $upgradeLogger;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue