Skip to content

Commit

Permalink
Merge pull request #148 from acquia/ACMS-3705
Browse files Browse the repository at this point in the history
ACMS-3705: Enabling themes first before modules.
  • Loading branch information
vishalkhode1 committed Apr 3, 2024
2 parents 1547049 + 0f42c38 commit 31950ad
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
12 changes: 9 additions & 3 deletions src/Cli.php
Expand Up @@ -236,15 +236,21 @@ public function alterModulesAndThemes(array &$starterKit, array $userInputValues
*/
private function alterPackagesForLowCode(array $starter_kit): array {
$packages = $this->packages->getInstalledPackages();
$sitestudio_version = $packages['acquia/cohesion']->version ?? "";
if ($sitestudio_version && version_compare($sitestudio_version, "7.5", "<")) {
$sitestudioVersion = $packages['acquia/cohesion']->version ?? "";
// If site studio version is 7.4.3 or less then
// replace themes and modules respectively.
if ($sitestudioVersion && version_compare($sitestudioVersion, "7.5", "<")) {
// Replace gin theme with acquia_claro.
$starter_kit = Utility::replaceValueByKey($starter_kit, "themes.require", "gin", "acquia_claro");
$starter_kit = Utility::replaceValueByKey($starter_kit, "themes.install", "gin", "acquia_claro");
$starter_kit = Utility::removeValueByKey($starter_kit, "modules.require", "sitestudio_gin");
$starter_kit = Utility::removeValueByKey($starter_kit, "modules.install", "sitestudio_gin");
// Replace sitestudio_gin module with sitestudio_claro.
$starter_kit = Utility::replaceValueByKey($starter_kit, "modules.install", "sitestudio_gin", "sitestudio_claro");
// Removing gin_toolbar to corporate the claro theme.
$starter_kit = Utility::removeValueByKey($starter_kit, "modules.install", "gin_toolbar");
$starter_kit['themes']['admin'] = "acquia_claro";
}

return $starter_kit;
}

Expand Down
38 changes: 33 additions & 5 deletions src/Helpers/Task/InstallTask.php
Expand Up @@ -233,11 +233,29 @@ public function run(array $args): void {
$this->print("Enabling modules for the starter-kit:", 'headline');
$isDemoContent = FALSE;
$modulesList = JsonParser::installPackages($bundleModules);
if ($key = array_search('acquia_cms_starter', $modulesList)) {
// Remove acquia_cms_starter module in the list of modules to install.
// Because we install this module separately in the last.
unset($modulesList[$key]);
$isDemoContent = TRUE;
// List of modules to be installed separately.
$isolateInstallModules = [
'sitestudio_gin',
'sitestudio_claro',
'gin_toolbar',
'acquia_cms_starter',
];
$dependencyModules = [];
foreach ($isolateInstallModules as $mkey => $module) {
if ($key = array_search($module, $modulesList)) {
if ($module === 'acquia_cms_starter') {
// Remove acquia_cms_starter module in the list of modules to install.
// Because we install this module separately in the last.
$isDemoContent = TRUE;
unset($modulesList[$key]);
unset($isolateInstallModules[$mkey]);
}
if (!empty($isolateInstallModules[$mkey]) && $isolateInstallModules[$mkey] === $module) {
$dependencyModules[] = $isolateInstallModules[$mkey];
unset($modulesList[$key]);
}

}
}
// Enable modules.
$this->enableModules->execute([
Expand All @@ -252,6 +270,16 @@ public function run(array $args): void {
'starter_kit' => $this->bundle,
]);

// Enable modules required by theme as sitestudio_claro, sitestudio_gin
// and gin_toolbar having system requirements to install theme first.
if (!empty($dependencyModules)) {
$this->print("Enabling modules required for theme:", 'headline');
$this->enableModules->execute([
'modules' => $dependencyModules,
'keys' => $args['keys'],
]);
}

// Toggle modules based on environments.
$this->print("Toggle modules for the starter-kit:", 'headline');
$this->toggleModules->execute([
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CliTest.php
Expand Up @@ -132,8 +132,8 @@ public function testAlterPackagesForLowCode(): void {
$expected['themes']['install'] = ["acquia_claro"];
$expected['themes']['admin'] = "acquia_claro";
unset($expected['modules']['require'][11]);
unset($expected['modules']['install'][5]);
unset($expected['modules']['install'][6]);
$expected['modules']['install'][5] = "sitestudio_claro";
$this->assertEquals($expected, $cli->alterModulesAndThemes($starter_kit, []));

$package->method('getInstalledPackages')->willReturnCallback(function ($reset) {
Expand Down

0 comments on commit 31950ad

Please sign in to comment.