diff --git a/.gitignore b/.gitignore index 5ef76e560..1ca53917d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,11 @@ -vendor/ -.DS_Store -phpunit.xml -composer.lock -.php_cs.cache -.php_cs -.*.swp -.*.swo -/build/logs/ +/bin/psalm.phar +/vendor/ +/.DS_Store +/.php_cs.cache +/.php_cs +/.*.swp +/.*.swo +/composer.lock +/phpunit.xml +/vendor-bin/*/composer.lock +/vendor-bin/*/vendor/ diff --git a/bin/build-phar.sh b/bin/build-phar.sh index c1a50468d..493f93a20 100755 --- a/bin/build-phar.sh +++ b/bin/build-phar.sh @@ -4,34 +4,8 @@ if ! php -r 'extension_loaded("bz2") or exit(1);' ; then exit 1 fi -composer global require 'humbug/php-scoper:^1.0@dev' -composer global require 'humbug/box:3.0.0-alpha.0' -composer install --no-dev -[ -d build ] || mkdir build -[ -d build/psalm ] || mkdir build/psalm -# increase FD limit, or Phar compression will fail -ulimit -Sn 4096 +composer bin box install -rm -f bin/psalm.phar +vendor/bin/box compile -# Prefixes the code to be bundled -php -d memory_limit=-1 `which php-scoper` add-prefix --prefix='PsalmPhar' --output-dir=build/psalm --force - -# Re-dump the loader to account for the prefixing -# and optimize the loader -composer dump-autoload --working-dir=build/psalm --classmap-authoritative --no-dev - -chmod 755 build/psalm/psalm - -cp bin/phar.psalm.xml build/psalm/psalm.xml - -./build/psalm/psalm --config=build/psalm/psalm.xml --root=build/psalm - -php -d memory_limit=-1 -d phar.readonly=0 `which box` compile - -# clean up build -rm -Rf build/psalm - -# reinstall deps (to regenerate autoloader and bring back dev deps) -rm -Rf vendor/* -composer install +bin/psalm.phar --config=bin/phar.psalm.xml --root=src diff --git a/box.json.dist b/box.json.dist index 227fbd149..1077461ac 100644 --- a/box.json.dist +++ b/box.json.dist @@ -1,23 +1,20 @@ { - "alias": "psalm.phar", - "base-path": "build/psalm", - "main" : "./psalm", - "output" : "../../build/psalm.phar", + "main" : "psalm", + "output" : "bin/psalm.phar", "directories" : [ "assets", + "src", "vendor" ], - "finder": [ - { - "in" : "src" - } - ], "files" : [ + "composer.json", + "composer.lock", "config.xsd" ], "intercept" : false, - "compactors" : [], + "compactors" : [ + "KevinGH\\Box\\Compactor\\PhpScoper" + ], "chmod" : "0755", - "shebang" : "#!/usr/bin/env php", - "stub" : true + "compression": "GZ" } diff --git a/composer.json b/composer.json index 72bc7f79d..2c6d674c1 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "phpunit/phpunit": "^5.7.4", "friendsofphp/php-cs-fixer": "^2.3|^2.4|^2.5|^2.6|^2.7|^2.8|^2.9", "squizlabs/php_codesniffer": "^3.0", - "php-coveralls/php-coveralls": "^2.0" + "php-coveralls/php-coveralls": "^2.0", + "bamarni/composer-bin-plugin": "^1.2" }, "suggest": { "ext-igbinary": "^2.0.5" diff --git a/scoper.inc.php b/scoper.inc.php index c2891800c..677dae19b 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -1,34 +1,6 @@ [ - Finder::create()->files()->in('src'), - Finder::create()->files()->in('assets'), - Finder::create() - ->files() - ->ignoreVCS(true) - ->notName('/LICENSE|.*\\.md|.*\\.dist|Makefile|composer\\.json|composer\\.lock/') - ->exclude([ - 'doc', - 'test', - 'test_old', - 'tests', - 'Tests', - 'vendor-bin', - ]) - ->in('vendor'), - Finder::create()->append([ - 'composer.json', - 'composer.lock', - 'config.xsd', - 'psalm' - ]), - ], - 'whitelist' => [ - - ], 'patchers' => [ function ($filePath, $prefix, $contents) { // diff --git a/vendor-bin/box/composer.json b/vendor-bin/box/composer.json new file mode 100644 index 000000000..52a61a825 --- /dev/null +++ b/vendor-bin/box/composer.json @@ -0,0 +1,7 @@ +{ + "minimum-stability": "dev", + "prefer-stable": true, + "require": { + "humbug/box": "dev-master" + } +}