Skip to content

Commit

Permalink
Core: Fix phar generator
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed May 5, 2017
1 parent 1d2b1df commit 94159c5
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ php:
- '5.6'
- '7.0'
before_script:
- composer -n install
- composer -n install --no-dev
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then pecl install runkit; fi
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then echo "runkit.internal_override=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "7.0" ]]; then pecl install uopz; fi
Expand Down
37 changes: 37 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
</fileset>
<fileset dir="vendor/michelf/php-markdown/">
<include name="**/*.php"/>
<exclude name="**/Readme.php"/>
</fileset>
</copy>
<copy todir="${basedir}/build/phar/phpdraft/src/QL">
<fileset dir="vendor/ql/uri-template/src">
<include name="**/*.php"/>
</fileset>
Expand All @@ -75,6 +78,13 @@
</fileset>
</copy>

<exec executable="perl">
<arg value="-pi"/>
<arg value="-e"/>
<arg value="s/\'vendor\/autoload.php/__DIR__\ .\ \'src\/PHPDraft\/Core\/Autoloader.php/g"/>
<arg value="${basedir}/build/phar/phpdraft/index.php"/>
</exec>

<exec executable="${basedir}/build/phar-version.php" outputproperty="_version">
<arg value="${version}"/>
<arg value="${type}"/>
Expand Down Expand Up @@ -111,6 +121,33 @@
<chmod file="${basedir}/build/phpdraft-${_version}.phar" perm="ugo+rx"/>
</target>

<target name="-dependencies-installed">
<available file="${basedir}/composer.lock" property="dependencies-installed"/>
</target>

<target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
<exec executable="composer" taskname="composer">
<arg value="update"/>
<arg value="--no-interaction"/>
<arg value="--no-progress"/>
<arg value="--no-ansi"/>
<arg value="--no-suggest"/>
<arg value="--optimize-autoloader"/>
<arg value="--prefer-stable"/>
</exec>
</target>

<target name="validate-composer-json" unless="validate-composer-json.done" description="Validate composer.json">
<exec executable="composer" failonerror="true" taskname="composer">
<arg value="validate"/>
<arg value="--no-check-lock"/>
<arg value="--strict"/>
<arg value="${basedir}/composer.json"/>
</exec>

<property name="validate-composer-json.done" value="true"/>
</target>

<target name="-phar-determine-version">
<exec executable="bash" outputproperty="version">
<arg value="-c"/>
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
],
"require": {
"php": ">=5.4.0",
"composer/installers": "~1.0",
"ql/uri-template": "1.*",
"michelf/php-markdown": "1.*"
"michelf/php-markdown": "1.*",
"theseer/autoload": "^1.22"
},
"require-dev": {
"theseer/autoload": "^1.22",
"phpunit/phpunit": "5.7.*"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/PHPDraft/Core/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ($classname) {
$classname = ltrim($classname, '\\');
preg_match('/^(.+)?([^\\\\]+)$/U', $classname, $match);
$classname = str_replace('\\', '/', $match[1]) . str_replace(['\\', '_'], '/', $match[2]) . '.php';
if (strpos($classname, 'PHPDraft') !== FALSE){
if (in_array($classname, ['PHPDraft', 'Mitchelf', 'QL']) !== FALSE){
include_once $classname;
}
}
Expand Down

0 comments on commit 94159c5

Please sign in to comment.