diff --git a/config/update-config.json b/config/update-config.json index 11b428c..aa1dda2 100644 --- a/config/update-config.json +++ b/config/update-config.json @@ -1,262 +1,264 @@ { "profile": "varbase", "package": "vardot/varbase", - "8.4.*": { - "from": "8.4.*", - "to": "8.4.28", - "final_target_version": "8.4.28", - "composer-project-json-url": "8.4.28" - }, - "8.4.28": { - "from": "8.4.28", - "to": "8.6.3", - "final_target_version": "8.6.3", - "composer-project-json-url": "8.6.3", - "packages": { - "crucial": { - "drupal/varbase_carousels": "6.0", - "drupal/entity_browser": "2.0", - "drupal/video_embed_field": "2.0", - "drupal/varbase_media": "6.2", - "drupal/media_entity": "2.0-beta3", - "vardot/entity_browser_generic_embed": "8.1.x-dev", - "drupal/panelizer": "4.1" - } + "versions": { + "8.4.*": { + "from": "8.4.*", + "to": "8.4.28", + "final_target_version": "8.4.28", + "composer-project-json-url": "8.4.28" }, - "skip":[ - "media_entity_document", - "media_entity_image" - ], - "enable-after-update":[ - "entity_browser_generic_embed" - ] - }, - "8.5.*": { - "from": "8.5.*", - "to": "8.5.5", - "final_target_version": "8.5.5", - "composer-project-json-url": "8.5.5" - }, - "8.5.5": { - "from": "8.5.5", - "to": "8.6.3", - "final_target_version": "8.6.3", - "composer-project-json-url": "8.6.3", - "packages": { - "crucial": { - "drupal/varbase_carousels": "6.0", - "drupal/entity_browser": "2.0", - "drupal/video_embed_field": "2.0", - "drupal/varbase_media": "6.2", - "drupal/media_entity": "2.0-beta3", - "vardot/entity_browser_generic_embed": "8.1.x-dev", - "drupal/panelizer": "4.1" - } + "8.4.28": { + "from": "8.4.28", + "to": "8.6.3", + "final_target_version": "8.6.3", + "composer-project-json-url": "8.6.3", + "packages": { + "crucial": { + "drupal/varbase_carousels": "6.0", + "drupal/entity_browser": "2.0", + "drupal/video_embed_field": "2.0", + "drupal/varbase_media": "6.2", + "drupal/media_entity": "2.0-beta3", + "vardot/entity_browser_generic_embed": "8.1.x-dev", + "drupal/panelizer": "4.1" + } + }, + "skip":[ + "media_entity_document", + "media_entity_image" + ], + "enable-after-update":[ + "entity_browser_generic_embed" + ] }, - "skip":[ - "media_entity_document", - "media_entity_image" - ], - "enable-after-update":[ - "entity_browser_generic_embed" - ] - }, - "8.6.*": { - "from": "8.6.*", - "to": "8.6.13", - "final_target_version": "8.6.13", - "composer-project-json-url": "8.6.13" - }, - "8.6.13": { - "from": "8.6.13", - "to": "8.7.1", - "final_target_version": "8.7.1", - "composer-project-json-url": "8.7.1", - "skip":[ - "media_entity_googledocs" - ] - }, - "8.7.*": { - "from": "8.7.*", - "to": "8.8.4", - "final_target_version": "8.8.4", - "composer-project-json-url": "8.8.4" - }, - "8.8.0": { - "from": "8.8.0", - "to": "8.8.4", - "final_target_version": "8.8.4", - "composer-project-json-url": "8.8.4" - }, - "8.8.1": { - "from": "8.8.1", - "to": "8.8.4", - "final_target_version": "8.8.4", - "composer-project-json-url": "8.8.4" - }, - "8.8.2": { - "from": "8.8.2", - "to": "8.8.4", - "final_target_version": "8.8.4", - "composer-project-json-url": "8.8.4" - }, - "8.8.3": { - "from": "8.8.3", - "to": "8.8.4", - "final_target_version": "8.8.4", - "composer-project-json-url": "8.8.4" - }, - "8.8.4": { - "from": "8.8.4", - "to": "8.8.5", - "final_target_version": "8.8.5", - "composer-project-json-url": "8.8.5", - "skip":[ - "slick_media" - ] - }, - "8.8.5": { - "from": "8.8.5", - "to": "8.8.6", - "final_target_version": "8.8.6", - "composer-project-json-url": "8.8.6" - }, - "8.8.6": { - "from": "8.8.6", - "to": "8.8.7", - "final_target_version": "8.8.7", - "composer-project-json-url": "8.8.7", - "skip":[ - "event_log_track", - "event_log_track_auth", - "event_log_track_file", - "event_log_track_media", - "event_log_track_menu", - "event_log_track_node", - "event_log_track_taxonomy", - "event_log_track_user" - ] - }, - "8.8.7": { - "from": "8.8.7", - "to": "8.8.11", - "final_target_version": "~8.0", - "composer-project-json-url": "8.8.11" - }, - "8.8.8": { - "from": "8.8.8", - "to": "8.8.11", - "final_target_version": "~8.0", - "composer-project-json-url": "8.8.11" - }, - "8.8.9": { - "from": "8.8.9", - "to": "8.8.11", - "final_target_version": "~8.0", - "composer-project-json-url": "8.8.11" - }, - "8.8.10": { - "from": "8.8.10", - "to": "8.8.11", - "final_target_version": "~8.0", - "composer-project-json-url": "8.8.11" - }, - "8.8.11": { - "from": "8.8.11", - "to": "8.8.12", - "final_target_version": "~8.0", - "composer-project-json-url": "8.8.12" - }, - "8.8.12": { - "from": "8.8.12", - "to": "9.0.3", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.3", - "packages": { - "crucial": { - "drupal/varbase_layout_builder": "~9.0" - } + "8.5.*": { + "from": "8.5.*", + "to": "8.5.5", + "final_target_version": "8.5.5", + "composer-project-json-url": "8.5.5" }, - "skip":[ - "vartheme", - "vartheme_admin", - "adminimal_admin_toolbar", - "libraries", - "libraries_ui", - "smtp", - "media_library_theme_reset", - "color_field", - "features", - "l10n_client", - "tour_builder", - "webform_analysis", - "mail_edit" - ] - }, - "9.0.0": { - "from": "9.0.0", - "to": "9.0.3", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.3" - }, - "9.0.1": { - "from": "9.0.1", - "to": "9.0.3", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.3" - }, - "9.0.2": { - "from": "9.0.2", - "to": "9.0.3", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.3" - }, - "9.0.3": { - "from": "9.0.3", - "to": "9.0.4", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.4" - }, - "9.0.4": { - "from": "9.0.4", - "to": "9.0.6", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.6" - }, - "9.0.5": { - "from": "9.0.5", - "to": "9.0.6", - "final_target_version": "~9.0.0", - "composer-project-json-url": "9.0.6" - }, - "9.0.6": { - "from": "9.0.6", - "to": "9.0.7", - "final_target_version": "~9.0", - "composer-project-json-url": "9.0.7" - }, - "9.0.7": { - "from": "9.0.7", - "to": "9.0.10", - "final_target_version": "~9.0", - "composer-project-json-url": "9.0.10" - }, - "9.0.8": { - "from": "9.0.8", - "to": "9.0.10", - "final_target_version": "~9.0", - "composer-project-json-url": "9.0.10" - }, - "9.0.9": { - "from": "9.0.9", - "to": "9.0.10", - "final_target_version": "~9.0", - "composer-project-json-url": "9.0.10" - }, - "9.0.10": { - "from": "9.0.10", - "to": "9.0.10", - "final_target_version": "~9.0", - "composer-project-json-url": "9.0.10" + "8.5.5": { + "from": "8.5.5", + "to": "8.6.3", + "final_target_version": "8.6.3", + "composer-project-json-url": "8.6.3", + "packages": { + "crucial": { + "drupal/varbase_carousels": "6.0", + "drupal/entity_browser": "2.0", + "drupal/video_embed_field": "2.0", + "drupal/varbase_media": "6.2", + "drupal/media_entity": "2.0-beta3", + "vardot/entity_browser_generic_embed": "8.1.x-dev", + "drupal/panelizer": "4.1" + } + }, + "skip":[ + "media_entity_document", + "media_entity_image" + ], + "enable-after-update":[ + "entity_browser_generic_embed" + ] + }, + "8.6.*": { + "from": "8.6.*", + "to": "8.6.13", + "final_target_version": "8.6.13", + "composer-project-json-url": "8.6.13" + }, + "8.6.13": { + "from": "8.6.13", + "to": "8.7.1", + "final_target_version": "8.7.1", + "composer-project-json-url": "8.7.1", + "skip":[ + "media_entity_googledocs" + ] + }, + "8.7.*": { + "from": "8.7.*", + "to": "8.8.4", + "final_target_version": "8.8.4", + "composer-project-json-url": "8.8.4" + }, + "8.8.0": { + "from": "8.8.0", + "to": "8.8.4", + "final_target_version": "8.8.4", + "composer-project-json-url": "8.8.4" + }, + "8.8.1": { + "from": "8.8.1", + "to": "8.8.4", + "final_target_version": "8.8.4", + "composer-project-json-url": "8.8.4" + }, + "8.8.2": { + "from": "8.8.2", + "to": "8.8.4", + "final_target_version": "8.8.4", + "composer-project-json-url": "8.8.4" + }, + "8.8.3": { + "from": "8.8.3", + "to": "8.8.4", + "final_target_version": "8.8.4", + "composer-project-json-url": "8.8.4" + }, + "8.8.4": { + "from": "8.8.4", + "to": "8.8.5", + "final_target_version": "8.8.5", + "composer-project-json-url": "8.8.5", + "skip":[ + "slick_media" + ] + }, + "8.8.5": { + "from": "8.8.5", + "to": "8.8.6", + "final_target_version": "8.8.6", + "composer-project-json-url": "8.8.6" + }, + "8.8.6": { + "from": "8.8.6", + "to": "8.8.7", + "final_target_version": "8.8.7", + "composer-project-json-url": "8.8.7", + "skip":[ + "event_log_track", + "event_log_track_auth", + "event_log_track_file", + "event_log_track_media", + "event_log_track_menu", + "event_log_track_node", + "event_log_track_taxonomy", + "event_log_track_user" + ] + }, + "8.8.7": { + "from": "8.8.7", + "to": "8.8.11", + "final_target_version": "~8.0", + "composer-project-json-url": "8.8.11" + }, + "8.8.8": { + "from": "8.8.8", + "to": "8.8.11", + "final_target_version": "~8.0", + "composer-project-json-url": "8.8.11" + }, + "8.8.9": { + "from": "8.8.9", + "to": "8.8.11", + "final_target_version": "~8.0", + "composer-project-json-url": "8.8.11" + }, + "8.8.10": { + "from": "8.8.10", + "to": "8.8.11", + "final_target_version": "~8.0", + "composer-project-json-url": "8.8.11" + }, + "8.8.11": { + "from": "8.8.11", + "to": "8.8.12", + "final_target_version": "~8.0", + "composer-project-json-url": "8.8.12" + }, + "8.8.12": { + "from": "8.8.12", + "to": "9.0.3", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.3", + "packages": { + "crucial": { + "drupal/varbase_layout_builder": "~9.0" + } + }, + "skip":[ + "vartheme", + "vartheme_admin", + "adminimal_admin_toolbar", + "libraries", + "libraries_ui", + "smtp", + "media_library_theme_reset", + "color_field", + "features", + "l10n_client", + "tour_builder", + "webform_analysis", + "mail_edit" + ] + }, + "9.0.0": { + "from": "9.0.0", + "to": "9.0.3", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.3" + }, + "9.0.1": { + "from": "9.0.1", + "to": "9.0.3", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.3" + }, + "9.0.2": { + "from": "9.0.2", + "to": "9.0.3", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.3" + }, + "9.0.3": { + "from": "9.0.3", + "to": "9.0.4", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.4" + }, + "9.0.4": { + "from": "9.0.4", + "to": "9.0.6", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.6" + }, + "9.0.5": { + "from": "9.0.5", + "to": "9.0.6", + "final_target_version": "~9.0.0", + "composer-project-json-url": "9.0.6" + }, + "9.0.6": { + "from": "9.0.6", + "to": "9.0.7", + "final_target_version": "~9.0", + "composer-project-json-url": "9.0.7" + }, + "9.0.7": { + "from": "9.0.7", + "to": "9.0.10", + "final_target_version": "~9.0", + "composer-project-json-url": "9.0.10" + }, + "9.0.8": { + "from": "9.0.8", + "to": "9.0.10", + "final_target_version": "~9.0", + "composer-project-json-url": "9.0.10" + }, + "9.0.9": { + "from": "9.0.9", + "to": "9.0.10", + "final_target_version": "~9.0", + "composer-project-json-url": "9.0.10" + }, + "9.0.10": { + "from": "9.0.10", + "to": "9.0.10", + "final_target_version": "~9.0", + "composer-project-json-url": "9.0.10" + } } } \ No newline at end of file diff --git a/src/Commands/RefactorComposerCommand.php b/src/Commands/RefactorComposerCommand.php index d6a42e5..6550894 100644 --- a/src/Commands/RefactorComposerCommand.php +++ b/src/Commands/RefactorComposerCommand.php @@ -214,9 +214,10 @@ public function generate($savePath, $drupalPath) { $updateConfig = array_replace_recursive($updateConfig, $extraConfig); $varbaseMetaData = []; - $composerProjectJsonUrl = "https://packagist.org/packages/vardot/varbase.json"; + $composerProjectJsonUrl = "https://repo.packagist.org/p2/vardot/varbase.json"; $filename = uniqid(sys_get_temp_dir().'/') . ".json"; $hostname = parse_url($composerProjectJsonUrl, PHP_URL_HOST); + $downloader->copy($hostname, $composerProjectJsonUrl, $filename, FALSE); if (file_exists($filename)) { @@ -265,24 +266,30 @@ public function generate($savePath, $drupalPath) { $scripts = []; - foreach ($updateConfig as $key => $conf) { + foreach ($updateConfig['versions'] as $key => $conf) { if (isset($conf["from"]) && isset($conf["to"])) { $conf["from"] = preg_replace("/\*/", ".*", $conf["from"]); $conf["to"] = preg_replace("/\*/", ".*", $conf["to"]); + if (($conf["from"] == $conf['to']) + && ($conf["from"] == $latestTags['version']) + && ($latestTags['version'] == $profileVersion)) { + continue; + } + foreach($latestTags as $key => $value){ - if(preg_match('/' . $conf['to'] . '/', $key)){ + if(preg_match('/' . $conf['to'] . '/', $key ?? '')){ $conf["to"] = $key; break; } } - if (preg_match('/' . $conf['to'] . '/', $profileVersion)) { + if (preg_match('/' . $conf['to'] . '/', $profileVersion ?? '')) { continue; } - if (preg_match('/' . $conf["from"] . '/', $profileVersion)) { + if (preg_match('/' . $conf["from"] . '/', $profileVersion ?? '')) { if (isset($conf["composer-project-json-url"])) { diff --git a/src/Commands/VersionCheckComposerCommand.php b/src/Commands/VersionCheckComposerCommand.php index 73e89b9..74f5d50 100644 --- a/src/Commands/VersionCheckComposerCommand.php +++ b/src/Commands/VersionCheckComposerCommand.php @@ -199,7 +199,7 @@ public function getVersion($type) { $updateConfig = array_replace_recursive($updateConfig, $extraConfig); $varbaseMetaData = []; - $composerProjectJsonUrl = "https://packagist.org/packages/vardot/varbase.json"; + $composerProjectJsonUrl = "https://repo.packagist.org/p2/vardot/varbase.json"; $filename = uniqid(sys_get_temp_dir().'/') . ".json"; $hostname = parse_url($composerProjectJsonUrl, PHP_URL_HOST); $downloader->copy($hostname, $composerProjectJsonUrl, $filename, FALSE); diff --git a/src/Helpers/VersionHelper.php b/src/Helpers/VersionHelper.php index 28115c1..f3ce559 100644 --- a/src/Helpers/VersionHelper.php +++ b/src/Helpers/VersionHelper.php @@ -14,41 +14,14 @@ class VersionHelper { * @return string|array */ public static function getLatestVersionInfo($metaData) { - $tags = []; $latestTags = []; - $versionsArray = []; - if (isset($metaData["package"])) { - $versionsArray = $metaData["package"]["versions"]; - } - else { - return $latestTags; - } - - if ($versionsArray && sizeof($versionsArray)) { - foreach ($versionsArray as $version => $meta) { - if (preg_match('/\d+\.\d+.\d+/', $version)) { - $numbers = []; - preg_match('/(\d+\.\d+).(\d+)/', $version, $numbers); - if (sizeof($numbers)) { - $major = $numbers[1]; - $minor = $numbers[2]; - if (isset($tags[$major])) { - if($tags[$major] < $minor) { - $tags[$major] = $minor; - } - } - else { - $tags[$major] = $minor; - } - } - } - } - - foreach ($tags as $major => $minor) { - $latestTags[$major.".".$minor] = $major.".".$minor; - } + if (isset($metaData["packages"]) + && isset($metaData["packages"]) + && isset($metaData["packages"]["vardot/varbase"][0])) { + $latestTags = $metaData["packages"]["vardot/varbase"][0]; } + return $latestTags; } @@ -90,10 +63,18 @@ public static function getVersionInfo($packages, $updateConfig, $latestVersions) "current" => $profileVersion ]; - foreach ($updateConfig as $key => $conf) { + foreach ($updateConfig['versions'] as $key => $conf) { + if (isset($conf["from"]) && isset($conf["to"])) { - $conf_from = preg_replace("/\*/", ".*", $conf["from"] ?: ''); - $conf_to = preg_replace("/\*/", ".*", $conf["to"] ?: ''); + + $conf_from = preg_replace("/\*/", ".*", $conf["from"]); + $conf_to = preg_replace("/\*/", ".*", $conf["to"]); + + if (($conf_from == $conf_to) + && ($conf_from == $latestVersions['version']) + && ($latestVersions['version'] == $profileVersion)) { + unset($versionInfo["next"]); + } foreach ($latestVersions as $key => $value) { if (preg_match("/" . $conf_to . "/", $key ?? '')) { @@ -102,11 +83,6 @@ public static function getVersionInfo($packages, $updateConfig, $latestVersions) } } - if ($conf_to == $conf_from) { - unset($versionInfo["next"]); - break; - } - if (preg_match("/" . $conf_to . "/", $profileVersion ?? '')) { continue; }