8000 minor #24746 Add a link script to ease debugging Flex apps (dunglas) · symfony/symfony@abe3c96 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit abe3c96

Browse files
minor #24746 Add a link script to ease debugging Flex apps (dunglas)
This PR was merged into the 2.7 branch. Discussion ---------- Add a link script to ease debugging Flex apps | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24708 | License | MIT | Doc PR | n/a (Reopened because of mishandling in the previous PR) It's painful to debug and patch Flex apps because `symfony/symfony` isn't installed by default (only components are) but PRs must be opened against the monolithic repository. This tiny tool, inspired by `npm link`, scan the `vendor/` directory of the project, and replace `symfony/` dependencies by symlinks to the local clone of the `symfony/symfony` repositories. Usage: ``` git clone git@github.com:symfony/symfony.git cd symfony ./link /path/to/the/project ``` Commits ------- 381f5d1 Add a "link" script to ease debugging Flex apps
2 parents f1b7921 + 381f5d1 commit abe3c96

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

link

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* This file is part of the Symfony package.
6+
*
7+
* (c) Fabien Potencier <fabien@symfony.com>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php';
14+
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php';
15+
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOException.php';
16+
require __DIR__.'/src/Symfony/Component/Filesystem/Filesystem.php';
17+
18+
use Symfony\Component\Filesystem\Filesystem;
19+
20+
/**
21+
* Links dependencies to components to a local clone of the main symfony/symfony GitHub repository.
22+
*
23+
* @author Kévin Dunglas <dunglas@gmail.com>
24+
*/
25+
26+
if (2 !== $argc) {
27+
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL;
28+
echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
29+
exit(1);
30+
}
31+
32+
if (!is_dir("$argv[1]/vendor/symfony")) {
33+
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;
34+
exit(1);
35+
}
36+
37+
$sfPackages = array('symfony/symfony' => __DIR__);
38+
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
39+
$sfPackages[json_decode(file_get_contents("$dir/composer.json"))->name] = $dir;
40+
}
41+
42+
$filesystem = new Filesystem();
43+
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) {
44+
$package = 'symfony/'.basename($dir);
45+
if (is_link($dir)) {
46+
echo "\"$package\" is already a symlink, skipping.".PHP_EOL;
47+
continue;
48+
}
49+
50+
if (!isset($sfPackages[$package])) {
51+
continue;
52+
}
53+
54+
$sfDir = '\\' === DIRECTORY_SEPARATOR ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir)));
55+
56+
$filesystem->remove($dir);
57+
$filesystem->symlink($sfDir, $dir);
58+
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL;
59+
}

0 commit comments

Comments
 (0)
0