diff --git a/.gitattributes b/.gitattributes index 90c4a5d..91d3c46 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,14 +1,15 @@ * text=auto /.github export-ignore -/doc export-ignore /tests export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.php_cs.dist export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore /CODE_OF_CONDUCT.md export-ignore -/README.md export-ignore +/ecs.php export-ignore +/infection.json.dist export-ignore +/link export-ignore +/Makefile export-ignore /phpstan.neon export-ignore +/phpstan-baseline.neon export-ignore /phpunit.xml.dist export-ignore +/rector export-ignore diff --git a/link b/link new file mode 100644 index 0000000..e25523c --- /dev/null +++ b/link @@ -0,0 +1,68 @@ +#!/usr/bin/env php +exists($composer = "$dir/composer.json")) { + $packages[json_decode(file_get_contents($composer))->name] = $dir; + } +} + +if (is_dir("$pathToProject/vendor/spomky-labs/phpwa")) { + if ($filesystem->exists($composer = "$pathToProject/vendor/spomky-labs/phpwa/composer.json")) { + $packages[json_decode(file_get_contents($composer))->name] = realpath(__DIR__); + } +} + +foreach (glob("$pathToProject/vendor/spomky-labs/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { + $package = 'spomky-labs/'.basename($dir); + if (!$copy && is_link($dir)) { + echo "\"$package\" is already a symlink, skipping.".PHP_EOL; + continue; + } + + if (!isset($packages[$package])) { + continue; + } + + $packageDir = ('\\' === DIRECTORY_SEPARATOR || $copy) ? $packages[$package] : $filesystem->makePathRelative($packages[$package], dirname(realpath($dir))); + $filesystem->remove($dir); + + if ($copy) { + $filesystem->mirror($packageDir, $dir); + echo "\"$package\" has been copied from \"$packages[$package]\".".PHP_EOL; + } else { + $filesystem->symlink(rtrim($packageDir, '/'), $dir); + echo "\"$package\" has been linked to \"$packages[$package]\".".PHP_EOL; + } +}