Skip to content
Snippets Groups Projects

Issue #3316721: Add script to convert this module into a core merge request

Merged Issue #3316721: Add script to convert this module into a core merge request
2 unresolved threads
2 unresolved threads
1 file
+ 12
10
Compare changes
  • Side-by-side
  • Inline
+ 12
10
@@ -31,7 +31,6 @@ class Converter {
self::info('Switched branches');
$fs = new Filesystem();
$core_module_path = static::getCoreModulePath($core_dir);
$package_manager_core_path = $core_dir . "/core/modules/package_manager";
// Remove old module
@@ -40,7 +39,7 @@ class Converter {
$fs->remove($package_manager_core_path);
self::info("Removed package manager");
$fs->mirror(self::getContribDir(), $core_module_path );
$fs->mirror(self::getContribDir(), $core_module_path);
self::info('Mirrored into core module');
// Remove unneeded
@@ -58,11 +57,12 @@ class Converter {
'DEVELOPING.md',
'scripts',
];
$removals = array_map(function ($path) use ($core_module_path) { return "$core_module_path/$path"; }, $removals);
$removals = array_map(function ($path) use ($core_module_path) {
return "$core_module_path/$path";
}, $removals);
$fs->remove($removals);
self::info('Remove not needed');
// Replace in file names and contents.
$replacements = [
$old_machine_name => $new_machine_name,
@@ -99,6 +99,7 @@ class Converter {
private static function getContribDir() {
return realpath(__DIR__ . '/../..');
}
/**
* @param $core_dir
*
@@ -118,7 +119,7 @@ class Converter {
$files = static::getDirContents($core_module_path, TRUE);
foreach ($files as $file) {
$filePath = $file->getRealPath();
file_put_contents($filePath,str_replace($search,$replace,file_get_contents($filePath)));
file_put_contents($filePath, str_replace($search, $replace, file_get_contents($filePath)));
}
}
@@ -188,10 +189,10 @@ class Converter {
private static function getDirContents(string $path, $excludeDirs = FALSE): array {
$rii = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path));
$files = array();
$files = [];
/** @var \SplFileInfo $file */
foreach ($rii as $file) {
if($excludeDirs && $file->isDir()) {
if ($excludeDirs && $file->isDir()) {
continue;
}
$files[] = $file;
@@ -204,12 +205,13 @@ class Converter {
* Ensures the git status is clean.
*
* @return bool
*
* @throws \Exception
*/
private static function ensureGitClean() {
$status_output = shell_exec('git status');
if (strpos($status_output, 'nothing to commit, working tree clean') === FALSE) {
throw new \Exception("git not clean: " .$status_output);
throw new \Exception("git not clean: " . $status_output);
}
return TRUE;
}
@@ -232,7 +234,7 @@ class Converter {
*/
private static function switchToBranches(string $core_dir, string $core_branch) {
// @todo Don't switch while developing this script. Uncomment before commit.
//static::switchToBranch('8.x-2.x');
// static::switchToBranch('8.x-2.x');
chdir($core_dir);
static::switchToBranch($core_branch);
}
@@ -318,7 +320,7 @@ class Converter {
if (!$skip) {
throw new \Exception("Didn't find matching begin");
}
$skip = false;
$skip = FALSE;
}
}
if ($skip) {
Loading