Skip to content

Commit b42f1a9

Browse files
committed
Make symlinking work in both directions
1 parent 2b14bb3 commit b42f1a9

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

.maintenance/clone-all-repositories.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,24 @@
88
'package-index',
99
'sample-plugin',
1010
'snapshot-command',
11+
'wp-cli-dev',
1112
);
1213

1314
$request = 'https://api.github.com/orgs/wp-cli/repos?per_page=100';
1415
$response = shell_exec( "curl -s {$request}" );
1516
$repositories = json_decode( $response );
16-
17+
$pwd = getcwd();
1718

1819
foreach ( $repositories as $repository ) {
1920
if ( in_array( $repository->name, $skip_list, true ) ) {
2021
continue;
2122
}
2223

23-
if ( is_dir( $repository->name ) ) {
24-
printf( "Skipping \033[33mwp-cli/{$repository->name}\033[0m, folder exists.\n" );
25-
continue;
24+
if ( ! is_dir( $repository->name ) ) {
25+
printf( "Fetching \033[32mwp-cli/{$repository->name}\033[0m:\n" );
26+
system( "git clone {$repository->clone_url}" );
27+
} else {
28+
printf( "Updating \033[33mwp-cli/{$repository->name}\033[0m:\n" );
29+
system( "cd {$repository->name} && git checkout master && git pull; cd {$pwd}" );
2630
}
27-
28-
printf( "Fetching \033[32mwp-cli/{$repository->name}\033[0m:\n" );
29-
system( "git clone {$repository->clone_url}" );
3031
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
$repositories = glob( '*', GLOB_ONLYDIR );
4+
$pwd = getcwd();
5+
$symlinks = glob( 'vendor/*', GLOB_ONLYDIR );
6+
7+
foreach ( $repositories as $repository ) {
8+
if ( ! is_dir( "{$repository}/vendor" ) && is_file( "{$repository}/composer.json" ) ) {
9+
printf( "Symlinking \033[33mwp-cli/{$repository}/vendor\033[0m folder:\n" );
10+
11+
// We don't symlink the vendor folder directly, but rather create a real
12+
// vendor folder and symlink each of the subfolders instead.
13+
// This is done so that the "vendor/" rule in .gitignore still works.
14+
mkdir( "{$repository}/vendor" );
15+
foreach ( $symlinks as $symlink ) {
16+
// Symlink entries already contain the `vendor/` folder suffix.
17+
symlink( "../../{$symlink}", "{$repository}/{$symlink}" );
18+
}
19+
}
20+
}

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,8 @@
325325
"scripts": {
326326
"pre-install-cmd": "php .maintenance/clone-all-repositories.php",
327327
"pre-update-cmd": "php .maintenance/clone-all-repositories.php",
328+
"post-install-cmd": "php .maintenance/symlink-vendor-folders.php",
329+
"post-update-cmd": "php .maintenance/symlink-vendor-folders.php",
328330
"behat": "run-behat-tests",
329331
"behat-rerun": "rerun-behat-tests",
330332
"lint": "run-linter-tests",

0 commit comments

Comments
 (0)