-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AllBundles] added link script for development (#2412)
- Loading branch information
1 parent
499283f
commit 61406b8
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use Symfony\Component\Filesystem\Filesystem; | ||
use Symfony\Component\Finder\Finder; | ||
|
||
/** | ||
* Links dependencies to components to a local clone of the main Kunstmaan/KunstmaanBundlesCMS GitHub repository. | ||
* This is heavily based upon the link script used by Symfony itself. Credits to Kévin Dunglas for providing such an | ||
* awesome script | ||
* | ||
* @author Ruud Denivel <[email protected]> | ||
*/ | ||
|
||
if (2 !== $argc) { | ||
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL; | ||
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
if (!is_dir("$argv[1]/vendor/kunstmaan")) { | ||
echo "The directory \"$argv[1]\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?".PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
$filesystem = new Filesystem(); | ||
$directories = Finder::create() | ||
->directories() | ||
->depth(0) | ||
->in(__DIR__ . '/src/Kunstmaan/'); | ||
|
||
/** @var \Symfony\Component\Finder\SplFileInfo $dir */ | ||
foreach ($directories as $dir) { | ||
if ($filesystem->exists($composer = $dir->getPathname() . "/composer.json")) { | ||
$sfPackages[json_decode(file_get_contents($composer))->name] = $dir->getPathname(); | ||
} | ||
} | ||
|
||
foreach (glob("$argv[1]/vendor/kunstmaan/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { | ||
$package = 'kunstmaan/'.basename($dir); | ||
if (is_link($dir)) { | ||
echo "\"$package\" is already a symlink, skipping.".PHP_EOL; | ||
continue; | ||
} | ||
|
||
if (!isset($sfPackages[$package])) { | ||
continue; | ||
} | ||
|
||
$sfDir = '\\' === DIRECTORY_SEPARATOR ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir))); | ||
|
||
$filesystem->remove($dir); | ||
$filesystem->symlink($sfDir, $dir); | ||
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL; | ||
} | ||
|
||
foreach (glob("$argv[1]/var/cache/*") as $cacheDir) { | ||
$filesystem->remove($cacheDir); | ||
} |