mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-20 23:41:57 +02:00
remove build-prefixed, build in external repository
This commit is contained in:
parent
958994e038
commit
3dc532fff0
@ -23,6 +23,7 @@ script:
|
||||
composer check-cs
|
||||
composer phpstan
|
||||
fi
|
||||
|
||||
# Rector demo run
|
||||
- |
|
||||
if [[ $RUN_RECTOR == true ]]; then
|
||||
|
@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
use Nette\Utils\FileSystem;
|
||||
use Nette\Utils\Json;
|
||||
|
||||
require_once __DIR__ . '/../bootstrap.php';
|
||||
|
||||
$buildDestination = getenv('BUILD_DESTINATION');
|
||||
|
||||
// load
|
||||
$composerJsonPath = $buildDestination . '/composer.json';
|
||||
$composerContent = Json::decode(FileSystem::read($composerJsonPath), Json::FORCE_ARRAY);
|
||||
|
||||
// remove unused sections
|
||||
unset($composerContent['require-dev'], $composerContent['scripts'], $composerContent['config'], $composerContent['autoload-dev'], $composerContent['authors']);
|
||||
|
||||
// change name
|
||||
$composerContent['name'] = 'rector/rector-prefixed';
|
||||
|
||||
// keep only requirements on PHP 7.1+
|
||||
$composerContent['require'] = [
|
||||
'php' => '^7.1',
|
||||
];
|
||||
|
||||
// save
|
||||
FileSystem::write($composerJsonPath, Json::encode($composerContent, Json::PRETTY));
|
@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# print each statement before run (https://stackoverflow.com/a/9966150/1348344)
|
||||
set -x
|
||||
|
||||
BUILD_DESTINATION="../rector-prefixed-build"
|
||||
|
||||
# cleanup build
|
||||
rm -rf $BUILD_DESTINATION
|
||||
mkdir $BUILD_DESTINATION
|
||||
|
||||
# prefix current code to $BUILD_DESTINATION directory (see "scoper.inc.php" for settings)
|
||||
vendor/bin/php-scoper add-prefix --no-interaction --output-dir=$BUILD_DESTINATION
|
||||
|
||||
# prefix namespace in *.yml, *.yaml and *.neon files
|
||||
# but not in /config, since there is only Rector\ services and "class names" that are not prefixed
|
||||
# ref https://unix.stackexchange.com/a/15309/74260
|
||||
(find $BUILD_DESTINATION -path $BUILD_DESTINATION/config -prune -o -type f \( -name \*.yml -o -name \*.yaml -o -name \*.neon \) | xargs perl -pi -e 's/((?:\\{1,2}\w+|\w+\\{1,2})(?:\w+\\{0,2})+)/RectorPrefixed\\\1/g')
|
||||
|
||||
# un-prefix Rector files, so it's public API, in configs etc.
|
||||
# e.g.
|
||||
# -use RectorPrefixed\Rector\...
|
||||
# +use Rector\...
|
||||
|
||||
# "sed" cdommand format help:
|
||||
# s#<old-code>#<new-code>#g
|
||||
# s#RectorPrefixed\\Rector#Rector#g
|
||||
# "RectorPrefixed\Rector" => "Rector"
|
||||
(find $BUILD_DESTINATION -type f | xargs sed -i 's/RectorPrefixed\\Rector/Rector/g')
|
||||
(find $BUILD_DESTINATION -type f | xargs sed -i 's/RectorPrefixed\\\\Rector/Rector/g')
|
||||
|
||||
# unprefix container dump - see https://github.com/symfony/symfony/blob/226e2f3949c5843b67826aca4839c2c6b95743cf/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php#L897
|
||||
(find $BUILD_DESTINATION -type f | xargs sed -i 's/use Symfony/use RectorPrefixed\\\\Symfony/g')
|
||||
|
||||
# for cases like: https://github.com/rectorphp/rector-prefixed/blob/6b690e46e54830a944618d3a2bf50a7c2bd13939/src/Bridge/Symfony/NodeAnalyzer/ControllerMethodAnalyzer.php#L16
|
||||
# "'" ref https://stackoverflow.com/a/24509931/1348344
|
||||
# "prune" ref https://stackoverflow.com/a/4210072/1348344
|
||||
(find $BUILD_DESTINATION -path $BUILD_DESTINATION/vendor -prune -o -type f | xargs sed -i "s#'RectorPrefixed\\#'#g")
|
||||
(find $BUILD_DESTINATION -path $BUILD_DESTINATION/vendor -prune -o -type f | xargs sed -i "s#'RectorPrefixed\\\\#'#g")
|
||||
|
||||
# Nette string validator
|
||||
# callable|Nette\\DI\\Statement|array:1 => callable|RectorPrefixed\\Nette\\DI\\Statement|array:1
|
||||
sed -i 's#|Nette\\\\DI#|RectorPrefixed\\\\Nette\\\\DI#g' $BUILD_DESTINATION/vendor/nette/di/src/DI/Compiler.php
|
||||
|
||||
# Symfony Bridge => keep Symfony classes
|
||||
|
||||
# RectorPrefixed\App\\Kernel => App\Kernel
|
||||
sed -i 's#RectorPrefixed\\\\App\\\\Kernel#App\\Kernel#g' $BUILD_DESTINATION/packages/Symfony/src/Bridge/DefaultAnalyzedSymfonyApplicationContainer.php
|
||||
# RectorPrefixed\Symfony\Component\HttpKernel\Kernel => Symfony\Component\HttpKernel\Kernel
|
||||
(find $BUILD_DESTINATION/packages/Symfony/src/Bridge -type f | xargs sed -i 's#RectorPrefixed\\Symfony\\Component#Symfony\\Component#g')
|
||||
|
||||
# copy template files
|
||||
cp composer.json $BUILD_DESTINATION/composer.json
|
||||
cp bin/rector-prefixed/template/README.md $BUILD_DESTINATION/README.md
|
||||
cp bin/rector-prefixed/template/.travis.yml $BUILD_DESTINATION/.travis.yml
|
||||
|
||||
# rebuild composer dump so the new prefixed namespaces are autoloaded
|
||||
# the new "RectorPrefixed\" is taken into account thanks to /vendor/composer/installed.json file,
|
||||
composer dump-autoload -d $BUILD_DESTINATION --no-dev
|
||||
|
||||
# make bin executable
|
||||
chmod +x $BUILD_DESTINATION/bin/rector
|
||||
|
||||
# clear kernel cache to make use of this new one,
|
||||
# #todo? maybe prefix this cache as well?
|
||||
(find $BUILD_DESTINATION -type f | xargs sed -i 's#_rector_cache#_prefixed_rector_cache#g')
|
||||
rm -rf /tmp/_prefixed_rector_cache
|
||||
|
||||
# build composer.json
|
||||
BUILD_DESTINATION=$BUILD_DESTINATION bin/rector-prefixed/build-composer-json.php
|
||||
|
||||
# run it to test it
|
||||
build/bin/rector
|
@ -1,25 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# print each statement before run (https://stackoverflow.com/a/9966150/1348344) so we can see what is going on
|
||||
set -x
|
||||
|
||||
cd build
|
||||
|
||||
# init non-existing .git or fetch existing one
|
||||
if [ ! -d .git ]; then
|
||||
git init
|
||||
# travis needs token to push
|
||||
if [ $TRAVIS == true ]; then
|
||||
git remote add -f origin https://$GITHUB_TOKEN@github.com/rectorphp/rector-prefixed.git
|
||||
else
|
||||
git remote add -f origin git@github.com:rectorphp/rector-prefixed.git
|
||||
fi
|
||||
|
||||
else
|
||||
git fetch origin
|
||||
fi
|
||||
|
||||
git add .
|
||||
git commit -m "rebuild prefixed Rector"
|
||||
# needs to be force pushed to delete old files
|
||||
git push origin master -f
|
@ -1,11 +0,0 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
|
||||
script:
|
||||
- bin/rector process src --level symfony40 --dry-run
|
||||
|
||||
notifications:
|
||||
email: false
|
@ -1,29 +0,0 @@
|
||||
# Prefixed Rector
|
||||
|
||||
[](https://travis-ci.org/rectorphp/rector-prefixed)
|
||||
[](https://packagist.org/packages/rector/rector)
|
||||
|
||||
Rector **instantly upgrades PHP & YAML code of your application**, with focus on open-source projects.
|
||||
Read more about it in [original repository](https://github.com/rectorphp/rector).
|
||||
|
||||
<br>
|
||||
|
||||
Since Rector **uses project's autoload to analyze type of elements**, it cannot be installed as project in standalone directory but needs to be added as dependency. In case you have composer versions conflicts, use this prefixed version.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
composer require rector/rector-prefixed:@dev --dev
|
||||
```
|
||||
|
||||
## Build & Deploy
|
||||
|
||||
Go to [`rector/rector` repository](https://github.com/rectorphp/rector) and run:
|
||||
|
||||
```bash
|
||||
composer publish-prefixed
|
||||
```
|
||||
|
||||
## How to Contribute
|
||||
|
||||
This is an automatically generated repository. See `composer publish-prefixed`(https://github.com/rectorphp/rector/blob/master/composer.json) in original repository for more.
|
@ -25,7 +25,6 @@
|
||||
"thecodingmachine/safe": "^0.1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
"humbug/php-scoper": "^0.9.2",
|
||||
"phpunit/phpunit": "^7.3",
|
||||
"symplify/changelog-linker": "^5.1.3",
|
||||
"symplify/monorepo-builder": "^5.1.3",
|
||||
@ -115,16 +114,11 @@
|
||||
"vendor/bin/changelog-linker dump-merges --in-categories",
|
||||
"vendor/bin/changelog-linker linkify"
|
||||
],
|
||||
"rector-prefixed": [
|
||||
"bin/rector-prefixed/build-prefixed-rector.sh",
|
||||
"bin/rector-prefixed/publish-to-github.sh"
|
||||
],
|
||||
"pre-autoload-dump": [
|
||||
"Rector\\Tests\\Composer\\AutoloadWrongCasesEventSubscriber::preAutoloadDump"
|
||||
]
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"rector-prefixed": "Builds new version of rector/rector-prefixed and pushes it to Github",
|
||||
"update-docs": "Regenerate descriptions of all Rectors to docs/AllRectorsOverview.md file",
|
||||
"changelog": "Generates new changelog for new merged PRs into CHANGELOG.md"
|
||||
},
|
||||
|
@ -1,51 +0,0 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Isolated\Symfony\Component\Finder\Finder;
|
||||
|
||||
return [
|
||||
'prefix' => 'RectorPrefixed',
|
||||
'finders' => [
|
||||
Finder::create()
|
||||
->files()
|
||||
->ignoreVCS(true)
|
||||
// ↓ this is regex!
|
||||
->notName('#LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock|.*\\.sh#')
|
||||
// depends on PHPUnit that is not part of the prefixed package
|
||||
->notName('#AbstractRectorTestCase\\.php#')
|
||||
->in(__DIR__ .'/bin')
|
||||
->in(__DIR__ .'/config')
|
||||
->in(__DIR__ .'/packages')
|
||||
->in(__DIR__ .'/src')
|
||||
->in(__DIR__ .'/vendor')
|
||||
->exclude([
|
||||
'docs',
|
||||
'Tests',
|
||||
'tests',
|
||||
'Test',
|
||||
'test',
|
||||
'humbug/php-scoper',
|
||||
'tracy/tracy',
|
||||
])
|
||||
,
|
||||
// to make "composer dump" work
|
||||
Finder::create()->append([
|
||||
'composer.json',
|
||||
// Fixes non-standard php-cs-fixer tests in /src
|
||||
__DIR__ . '/vendor/friendsofphp/php-cs-fixer/tests/TestCase.php',
|
||||
// Files dependencies in prod vendor
|
||||
__DIR__ . '/vendor/humbug/php-scoper/src/functions.php',
|
||||
__DIR__ . '/vendor/tracy/tracy/src/shortcuts.php',
|
||||
// dependency for "composer dump"
|
||||
__DIR__ . '/vendor/composer/installed.json'
|
||||
]),
|
||||
// 'whitelist' - be careful, this adds aliases to end of each whitelisted class
|
||||
|
||||
// Fixes non-standard php-cs-fixer tests in /src:
|
||||
// "Could not scan for classes inside "/var/www/rector/build/vendor/friendsofphp/php-cs-fixer/tests/Test/AbstractFixerTestCase.php" which does not appear to be a file nor a folder"
|
||||
Finder::create()
|
||||
->files()
|
||||
->in(__DIR__ . '/vendor/friendsofphp/php-cs-fixer/tests/Test')
|
||||
],
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user