Skip to content

Commit

Permalink
Add box setting for Phar
Browse files Browse the repository at this point in the history
  • Loading branch information
ngyuki committed Jul 29, 2018
1 parent 97c7ea3 commit 386d679
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@
/sql/config.php
/.bin/
/.envrc
/*.phar
101 changes: 0 additions & 101 deletions bin/compile.php

This file was deleted.

12 changes: 0 additions & 12 deletions bin/compile.stub

This file was deleted.

15 changes: 14 additions & 1 deletion bin/db-migrate
Expand Up @@ -17,5 +17,18 @@ if ($loader === null) {

use ngyuki\DbMigrate\Console\Application;

$application = new Application();
$version = '@git-version@';
if (preg_match('/^@/', $version)) {
$version = 'UNKNOWN';
}
if (preg_match('/-/', $version) && !preg_match('/^@/', '@git-commit@')) {
$version = "$version (@git-commit@)";
}
$longVersion = sprintf('<info>%s</info> version <comment>%s</comment>', basename(__FILE__), $version);
if (!preg_match('/^@/', '@datetime@')) {
$longVersion = "$longVersion @datetime@";
}

$application = new Application(basename(__FILE__), $version);
$application->setLongVersion($longVersion);
$application->run();
38 changes: 38 additions & 0 deletions box.json
@@ -0,0 +1,38 @@
{
"directories": [
"src"
],
"files": [
"vendor/autoload.php"
],
"finder": [
{
"in": [
"vendor/composer",
"vendor/symfony/console",
"vendor/symfony/filesystem",
"vendor/symfony/polyfill-mbstring"
],
"exclude": [
"Tests"
],
"notName": [
"*.md",
"composer.json",
"phpunit.xml",
"phpunit.xml.dist"
]
}
],
"main": "bin/db-migrate",
"output": "db-migrate.phar",
"chmod": "0755",
"stub": true,
"git-commit": "git-commit",
"git-version": "git-version",
"datetime": "datetime",
"compression": "GZ",
"compactors": [
"Herrera\\Box\\Compactor\\Php"
]
}
5 changes: 5 additions & 0 deletions composer.json
Expand Up @@ -50,6 +50,11 @@
"@composer test",
"@composer cs",
"@composer phan"
],
"build": [
"[ -e box.phar ] || curl -LS https://box-project.github.io/box2/installer.php | php",
"@composer dump-autoload -o -a --no-dev",
"@php -d phar.readonly=0 box.phar build -v"
]
}
}
21 changes: 17 additions & 4 deletions src/Console/Application.php
Expand Up @@ -10,15 +10,17 @@

class Application extends BaseApplication
{
const NAME = 'db-migrate';
const VERSION = '@dev';
/**
* @var string
*/
private $longVersion;

/**
* {@inheritdoc}
*/
public function __construct()
public function __construct($name = null, $version = null)
{
parent::__construct(self::NAME, self::VERSION);
parent::__construct($name, $version);

$commands = array();
$commands[] = new Command\MigrateCommand();
Expand All @@ -34,6 +36,17 @@ public function __construct()
$this->addCommands($commands);
}

public function setLongVersion($longVersion)
{
$this->longVersion = $longVersion;
return $this;
}

public function getLongVersion()
{
return $this->longVersion;
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 386d679

Please sign in to comment.