Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Joomla 4 to be installed #126

Merged
merged 7 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/Joomlatools/Console/Command/Database/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,27 @@ protected function _getInstallFiles($sample_data = false)
$path = $this->target_dir.'/installation/sql/mysql/';
}

$files[] = $path.'joomla.sql';
$version = Util::getJoomlaVersion($this->target_dir);

if (version_compare($version->release, '4.0.0-alpha12', '>') &&
file_exists($path . "base.sql"))
{
$files[] = $path . "base.sql";
$files[] = $path . "extensions.sql";
$files[] = $path . "supports.sql";

}else{
$files[] = $path.'joomla.sql';
}

if ($sample_data)
{
$type = $sample_data == 'default' ? 'data' : $sample_data;
$sample_db = $path . 'sample_' . $type . '.sql';

$files[] = $sample_db;
if (file_exists($sample_db)){
$files[] = $sample_db;
}
}
}

Expand Down
35 changes: 35 additions & 0 deletions src/Joomlatools/Console/Command/Site/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$this->check($input, $output);

$this->importdb($input, $output);

$version = Util::getJoomlaVersion($this->target_dir);

if (version_compare($version->release, '4.0.0-alpha5', '>=')){
$this->configureDependencies($input, $output);
}

$this->createConfig($input, $output);

if ($this->symlink)
Expand All @@ -121,6 +128,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln("You can login using the following username and password combination: <info>admin</info>/<info>admin</info>.");
}

/*
* https://docs.joomla.org/J4.x:Setting_Up_Your_Local_Environment
*/
public function configureDependencies(InputInterface $input, OutputInterface $output)
{
$path = $this->target_dir;

$output->writeLn('<info>Installing Joomla 4 project dependencies</info>');

$remove_folders = array(
"$path/administrator/templates/atum/css",
"$path/templates/cassiopeia/css",
"$path/media/",
"$path/node_modules/",
"$path/libraries/vendor/",
"$path/administrator/cache/autoload_psr4.php",
"$path/installation/template/css"
);

foreach ($remove_folders AS $folder){
exec("rm -rf $folder;");
}

exec("composer --working-dir=$path --ignore-platform-reqs install;");

exec(" npm ci --prefix $path");
}

public function check(InputInterface $input, OutputInterface $output)
{
if (!file_exists($this->target_dir)) {
Expand Down
5 changes: 5 additions & 0 deletions src/Joomlatools/Console/Joomla/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public static function getJoomlaVersion($base)
return $version::RELEASE . '.' . $version::DEV_LEVEL;
}

//start to provide support for Joomla 4 onwards
if (defined( "$className::MAJOR_VERSION") && $version::MAJOR_VERSION == '4'){
return $version::MAJOR_VERSION . "." . $version::MINOR_VERSION . "." . $version::PATCH_VERSION . "." . $version:: EXTRA_VERSION;
}

return 'unknown';
};

Expand Down