public function packCommand($in, $out): int
    {
        $time = \microtime(1);
        $workDir = $in->getPwd();

        $dir = $in->getOpt('dir') ?: $workDir;
        $cpr = $this->configCompiler($dir);

        $counter = null;
        $refresh = $in->boolOpt('refresh');
        $pharFile = $workDir . '/' . $in->sameOpt(['o', 'output'], \basename($workDir) . '.phar');

        // use fast build
        if ($this->input->boolOpt('fast')) {
            $cpr->setModifies($cpr->findChangedByGit());
            $this->output->liteNote('Use fast build, will only pack changed or new files(from git status)');
        }

        $out->liteInfo(
            "Now, will begin building phar package.\n from path: <comment>$workDir</comment>\n" .
            " phar file: <info>$pharFile</info>"
        );

        $out->info('Pack file to Phar: ');
        $cpr->onError(function ($error) {
            $this->output->warning($error);
        });

        if ($in->getOpt('debug')) {
            $cpr->onAdd(function ($path) {
                $this->output->write(" <comment>+</comment> $path");
            });
        } else {
            $counter = Show::counterTxt('Handling ...', 'Done.');
            $cpr->onAdd(function () use ($counter) {
                $counter->send(1);
            });
        }

        // packing ...
        $cpr->pack($pharFile, $refresh);

        // end
        if ($counter) {
            $counter->send(-1);
        }

        $out->write([
            PHP_EOL . '<success>Phar build completed!</success>',
            " - Phar file: $pharFile",
            ' - Phar size: ' . round(filesize($pharFile) / 1024 / 1024, 2) . ' Mb',
            ' - Pack Time: ' . round(microtime(1) - $time, 3) . ' s',
            ' - Pack File: ' . $cpr->getCounter(),
            ' - Commit ID: ' . $cpr->getVersion(),
        ]);

        return 0;
    }
public function packCommand($in, $out): int
    {
        $time = \microtime(1);
        $workDir = $in->getPwd();

        $dir = $in->getOpt('dir') ?: $workDir;
        $cpr = $this->configCompiler($dir);

        $counter = null;
        $refresh = $in->boolOpt('refresh');
        $pharFile = $workDir . '/' . $in->sameOpt(['o', 'output'], \basename($workDir) . '.phar');

        // use fast build
        if ($this->input->boolOpt('fast')) {
            $cpr->setModifies($cpr->findChangedByGit());
            $this->output->liteNote('Use fast build, will only pack changed or new files(from git status)');
        }

        $out->liteInfo(
            "Now, will begin building phar package.\n from path: <comment>$workDir</comment>\n" .
            " phar file: <info>$pharFile</info>"
        );

        $out->info('Pack file to Phar: ');
        $cpr->onError(function ($error) {
            $this->output->warning($error);
        });

        if ($in->getOpt('debug')) {
            $cpr->onAdd(function ($path) {
                $this->output->write(" <comment>+</comment> $path");
            });
        } else {
            $counter = Show::counterTxt('Handling ...', 'Done.');
            $cpr->onAdd(function () use ($counter) {
                $counter->send(1);
            });
        }

        // packing ...
        $cpr->pack($pharFile, $refresh);

        // end
        if ($counter) {
            $counter->send(-1);
        }

        $out->write([
            PHP_EOL . '<success>Phar build completed!</success>',
            " - Phar file: $pharFile",
            ' - Phar size: ' . round(filesize($pharFile) / 1024 / 1024, 2) . ' Mb',
            ' - Pack Time: ' . round(microtime(1) - $time, 3) . ' s',
            ' - Pack File: ' . $cpr->getCounter(),
            ' - Commit ID: ' . $cpr->getVersion(),
        ]);

        return 0;
    }
public function packCommand ( $ in , $ out ) : int { $ time = \ microtime ( 1 ) ; $ workDir = $ in -> getPwd ( ) ; $ dir = $ in -> getOpt ( 'dir' ) ? : $ workDir ; $ cpr = $ this -> configCompiler ( $ dir ) ; $ counter = null ; $ refresh = $ in -> boolOpt ( 'refresh' ) ; $ pharFile = $ workDir . '/' . $ in -> sameOpt ( [ 'o' , 'output' ] , \ basename ( $ workDir ) . '.phar' ) ; // use fast build if ( $ this -> input -> boolOpt ( 'fast' ) ) { $ cpr -> setModifies ( $ cpr -> findChangedByGit ( ) ) ; $ this -> output -> liteNote ( 'Use fast build, will only pack changed or new files(from git status)' ) ; } $ out -> liteInfo ( "Now, will begin building phar package.\n from path: <comment>$workDir</comment>\n" . " phar file: <info>$pharFile</info>" ) ; $ out -> info ( 'Pack file to Phar: ' ) ; $ cpr -> onError ( function ( $ error ) { $ this -> output -> warning ( $ error ) ; } ) ; if ( $ in -> getOpt ( 'debug' ) ) { $ cpr -> onAdd ( function ( $ path ) { $ this -> output -> write ( " <comment>+</comment> $path" ) ; } ) ; } else { $ counter = Show :: counterTxt ( 'Handling ...' , 'Done.' ) ; $ cpr -> onAdd ( function ( ) use ( $ counter ) { $ counter -> send ( 1 ) ; } ) ; } // packing ... $ cpr -> pack ( $ pharFile , $ refresh ) ; // end if ( $ counter ) { $ counter -> send ( - 1 ) ; } $ out -> write ( [ PHP_EOL . '<success>Phar build completed!</success>' , " - Phar file: $pharFile" , ' - Phar size: ' . round ( filesize ( $ pharFile ) / 1024 / 1024 , 2 ) . ' Mb' , ' - Pack Time: ' . round ( microtime ( 1 ) - $ time , 3 ) . ' s' , ' - Pack File: ' . $ cpr -> getCounter ( ) , ' - Commit ID: ' . $ cpr -> getVersion ( ) , ] ) ; return 0 ; }
pack project to a phar package
@usage {fullCommand} [--dir DIR] [--output FILE] [...]
@options
-d, --dir STRING        Setting the project directory for packing.
default is current work-dir.(<cyan>{workDir}</cyan>)
-c, --config STRING     Use the custom config file for build phar(<cyan>./phar.build.inc</cyan>)
-o, --output STRING     Setting the output file name(<cyan>{defaultPkgName}.phar</cyan>)
--fast BOOL             Fast build. only add modified files by <cyan>git status -s</cyan>
--refresh BOOL          Whether build vendor folder files on phar file exists(<cyan>False</cyan>)
@param  \Inhere\Console\IO\Input  $in
@param  \Inhere\Console\IO\Output $out
@return int
@throws \UnexpectedValueException
@throws \RuntimeException
@throws \BadMethodCallException
@throws \Exception
pack project to a phar package