diff --git a/.gitignore b/.gitignore index c7c91bd..53bfa4e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.idea/* /.DS_Store /phpunit.phar +/box.phar /composer.phar /php-cs-fixer.phar /phpunit.xml diff --git a/Makefile b/Makefile index b18476b..e9459ec 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ all:test setup: $(PHP_BIN) -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));" $(CURL_BIN) -SsLO https://phar.phpunit.de/phpunit.phar + $(CURL_BIN) -LSs https://box-project.github.io/box2/installer.php | $(PHP_BIN) install: $(PHP_BIN) composer.phar install @@ -21,7 +22,7 @@ testrunner: guard -i compile: - $(PHP_BIN) dbup compile + $(PHP_BIN) box.phar build changelog: git log --pretty=format:" * %h %s" $(SINCE)..$(UNTIL) -- src tests diff --git a/box.json b/box.json new file mode 100644 index 0000000..e18a954 --- /dev/null +++ b/box.json @@ -0,0 +1,16 @@ +{ + "output": "dbup.phar", + "chmod": "0755", + "extract": false, + "files": [ + "LICENCE" + ], + "finder": [ + { + "name": ["*.php"], + "exclude": ["Tests", "tests"], + "in": ["vendor", "src"] + } + ], + "stub": "src/Dbup/Resources/phar-stub.php" +} diff --git a/dbup.phar b/dbup.phar index 5b0f3d9..c14e046 100755 Binary files a/dbup.phar and b/dbup.phar differ diff --git a/src/Dbup/Command/CompileCommand.php b/src/Dbup/Command/CompileCommand.php deleted file mode 100644 index 31c8899..0000000 --- a/src/Dbup/Command/CompileCommand.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Dbup\Command; - -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; -use Dbup\Exception\RuntimeException; -use Dbup\Util\Compiler; - -/** - * @author Masao Maeda - */ -class CompileCommand extends Command -{ - protected function configure() - { - $this - ->setName('compile') - ->setDescription('Compile dbup.phar') - ->setHelp(' -The dbup compile comand compile dbup and make a new dbup.phar file. - ') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $compiler = new Compiler(); - $compiler->compile(); - } -} diff --git a/src/Dbup/Resources/phar-stub.php b/src/Dbup/Resources/phar-stub.php new file mode 100644 index 0000000..b40d14f --- /dev/null +++ b/src/Dbup/Resources/phar-stub.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ +Phar::mapPhar('dbup.phar'); +require_once 'phar://dbup.phar/vendor/autoload.php'; +use Dbup\Application; +$application = new Application(); +$application->run(); + +__HALT_COMPILER(); \ No newline at end of file diff --git a/src/Dbup/Util/Compiler.php b/src/Dbup/Util/Compiler.php deleted file mode 100644 index f45cfe6..0000000 --- a/src/Dbup/Util/Compiler.php +++ /dev/null @@ -1,66 +0,0 @@ -setSignatureAlgorithm(\Phar::SHA1); - - $phar->startBuffering(); - - // CLI Component files - foreach ($this->getFiles() as $file) { - $phar->addFromString($file->getPathName(), file_get_contents($file)); - } - - $this->addDbup($phar); - - // Stubs - $phar->setStub($this->getStub()); - $phar->stopBuffering(); - - unset($phar); - chmod($pharFile, 0777); - } - - /** - * Remove the shebang from the file before add it to the PHAR file. - * - * @param \Phar $phar PHAR instance - */ - protected function addDbup(\Phar $phar) - { - $content = file_get_contents(__DIR__ . '/../../../dbup'); - $content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content); - - $phar->addFromString('dbup', $content); - } - - protected function getStub() - { - return <<files()->exclude('tests')->name('*.php')->in(array('vendor', 'src')); - - return iterator_to_array($srcIterator); - } -} \ No newline at end of file