-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ac9bc0
commit 052a229
Showing
10 changed files
with
282 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="phpdrafter" default="setup"> | ||
<target name="setup" depends="clean"/> | ||
|
||
<target name="clean" unless="clean.done" description="Cleanup build artifacts"> | ||
<delete dir="${basedir}/bin"/> | ||
<delete dir="${basedir}/build/documentation"/> | ||
<delete dir="${basedir}/build/logfiles"/> | ||
<delete dir="${basedir}/build/phar"/> | ||
<delete> | ||
<fileset dir="${basedir}/build"> | ||
<include name="**/phpdraft*.phar"/> | ||
<include name="**/phpdraft*.phar.asc"/> | ||
</fileset> | ||
</delete> | ||
|
||
<property name="clean.done" value="true"/> | ||
</target> | ||
|
||
<target name="signed-phar" depends="phar" | ||
description="Create signed PHAR archive of PHPDraft and all its dependencies"> | ||
<exec executable="gpg" failonerror="true"> | ||
<arg value="--armor"/> | ||
<arg value="--detach-sign"/> | ||
<arg path="${basedir}/build/phpdraft-library-${version}.phar"/> | ||
</exec> | ||
|
||
<exec executable="gpg" failonerror="true"> | ||
<arg value="--armor"/> | ||
<arg value="--detach-sign"/> | ||
<arg path="${basedir}/build/phpdraft-${version}.phar"/> | ||
</exec> | ||
</target> | ||
|
||
<target name="phar" depends="-phar-determine-version,-phar-prepare" | ||
description="Create PHAR archive of PHPDraft and all its dependencies"> | ||
<antcall target="-phar-build"> | ||
<param name="type" value="release"/> | ||
</antcall> | ||
</target> | ||
|
||
<target name="phar-nightly" depends="-phar-prepare" | ||
description="Create PHAR archive of PHPDraft and all its dependencies (nightly)"> | ||
<antcall target="-phar-build"> | ||
<param name="type" value="nightly"/> | ||
</antcall> | ||
</target> | ||
|
||
<target name="-phar-prepare" depends="clean"> | ||
<mkdir dir="${basedir}/build/phar"/> | ||
<copy file="${basedir}/LICENSE" tofile="${basedir}/build/phar/LICENSE"/> | ||
<exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt"/> | ||
</target> | ||
|
||
<target name="-phar-build" depends="-phar-determine-version"> | ||
<copy todir="${basedir}/build/phar/phpdraft/src"> | ||
<fileset dir="${basedir}/src/"> | ||
<exclude name="**/*Test.php*"/> | ||
<include name="**/*.php"/> | ||
<include name="**/*.js*"/> | ||
<include name="**/*.css*"/> | ||
</fileset> | ||
</copy> | ||
<copy todir="${basedir}/build/phar/phpdraft"> | ||
<fileset dir="${basedir}"> | ||
<include name="**/*.json*"/> | ||
<include name="**/index.php"/> | ||
</fileset> | ||
</copy> | ||
|
||
<exec executable="${basedir}/build/phar-version.php" outputproperty="_version"> | ||
<arg value="${version}"/> | ||
<arg value="${type}"/> | ||
</exec> | ||
|
||
<exec executable="phpab" taskname="phpab"> | ||
<arg value="--all"/> | ||
<arg value="--static"/> | ||
<arg value="--once"/> | ||
<arg value="--phar"/> | ||
<arg value="--hash"/> | ||
<arg value="SHA-1"/> | ||
<arg value="--output"/> | ||
<arg path="${basedir}/build/phpdraft-library-${_version}.phar"/> | ||
<arg value="--template"/> | ||
<arg path="${basedir}/build/library-phar-autoload.php.in"/> | ||
<arg path="${basedir}/build/phar"/> | ||
</exec> | ||
|
||
<exec executable="phpab" taskname="phpab"> | ||
<arg value="--all"/> | ||
<arg value="--nolower"/> | ||
<arg value="--static"/> | ||
<arg value="--phar"/> | ||
<arg value="--hash"/> | ||
<arg value="SHA-1"/> | ||
<arg value="--output"/> | ||
<arg path="${basedir}/build/phpdraft-${_version}.phar"/> | ||
<arg value="--template"/> | ||
<arg path="${basedir}/build/binary-phar-autoload.php.in"/> | ||
<arg path="${basedir}/build/phar"/> | ||
</exec> | ||
|
||
<chmod file="${basedir}/build/phpdraft-${_version}.phar" perm="ugo+rx"/> | ||
</target> | ||
|
||
<target name="-phar-determine-version"> | ||
<exec executable="bash" outputproperty="version"> | ||
<arg value="-c"/> | ||
<arg value="php ${basedir}/index.php -v | grep -ohE '([0-9]{1,}\.)+[0-9]{1,}'"/> | ||
</exec> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
if (version_compare('5.6.0', PHP_VERSION, '>')) { | ||
fwrite( | ||
STDERR, | ||
'This version of PHPDraft requires PHP 5.6; using the latest version of PHP is highly recommended.' . PHP_EOL | ||
); | ||
|
||
die(1); | ||
} | ||
|
||
if (__FILE__ == realpath($GLOBALS['_SERVER']['SCRIPT_NAME'])) { | ||
$execute = true; | ||
} else { | ||
$execute = false; | ||
} | ||
|
||
define('__PHPDRAFT_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', __FILE__)); | ||
define('__PHPDRAFT_PHAR_ROOT__', 'phar://___PHAR___'); | ||
|
||
Phar::mapPhar('___PHAR___'); | ||
|
||
___FILELIST___ | ||
|
||
if ($execute) { | ||
if (isset($_SERVER['argv'][1]) && $_SERVER['argv'][1] == '--manifest') { | ||
print file_get_contents(__PHPDRAFT_PHAR_ROOT__ . '/manifest.txt'); | ||
exit; | ||
} | ||
|
||
require_once __PHPDRAFT_PHAR_ROOT__.DIRECTORY_SEPARATOR.'phpdraft'.DIRECTORY_SEPARATOR.'index.php'; | ||
} | ||
|
||
__HALT_COMPILER(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
define('__PHPDRAFT_PHAR__', str_replace(DIRECTORY_SEPARATOR, '/', __FILE__)); | ||
define('__PHPDRAFT_PHAR_ROOT__', 'phar://___PHAR___'); | ||
|
||
Phar::mapPhar('___PHAR___'); | ||
|
||
___FILELIST___ | ||
|
||
__HALT_COMPILER(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
print 'phpdraft/phpdraft: '; | ||
|
||
$tag = @exec('git describe --tags 2>&1'); | ||
|
||
if (strpos($tag, '-') === false && strpos($tag, 'No names found') === false) { | ||
print $tag; | ||
} else { | ||
$branch = @exec('git rev-parse --abbrev-ref HEAD'); | ||
$hash = @exec('git log -1 --format="%H"'); | ||
print $branch . '@' . $hash; | ||
} | ||
|
||
print "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
if (!isset($argv[1]) || !isset($argv[2])) { | ||
exit(1); | ||
} | ||
|
||
file_put_contents( | ||
__DIR__ . '/phar/phpdraft/index.php', | ||
str_replace( | ||
"define('VERSION', '');", | ||
"define('VERSION', '" . $argv[1] . "');", | ||
file_get_contents(__DIR__ . '/phar/phpdraft/index.php') | ||
) | ||
); | ||
|
||
if ($argv[2] == 'release') { | ||
print $argv[1]; | ||
} else { | ||
print $argv[2]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"tmpdir": "/tmp/drafter", | ||
"logo": "/home/smillernl/Documents/5acf473a9e6a3deb8e98a2b6373d0a83.png" | ||
"logo": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* This file contains the UI.php | ||
* | ||
* @package php-drafter\SOMETHING | ||
* @author Sean Molenaar<[email protected]> | ||
*/ | ||
|
||
namespace PHPDraft\Out; | ||
|
||
|
||
class UI | ||
{ | ||
static function main($argv = []) | ||
{ | ||
$options = getopt("f:t::i::hv"); | ||
if(!isset($argv[1])) | ||
{ | ||
file_put_contents('php://stderr', 'Not enough arguments'.PHP_EOL); | ||
self::help(); | ||
exit(1); | ||
} | ||
|
||
if (boolval(preg_match('/^\-/',$argv[1]))) | ||
{ | ||
if (isset($options['h'])) | ||
{ | ||
self::help(); | ||
exit(0); | ||
} | ||
|
||
if (isset($options['v'])) | ||
{ | ||
self::version(); | ||
exit(0); | ||
} | ||
|
||
elseif (isset($options['f'])) | ||
{ | ||
$file = $options['f']; | ||
} | ||
else | ||
{ | ||
file_put_contents('php://stderr', 'No file to parse'.PHP_EOL); | ||
exit(1); | ||
} | ||
} | ||
else | ||
{ | ||
$file = $argv[1]; | ||
} | ||
|
||
$template = (isset($options['t']) && $options['t']) ? $options['t']: 'default'; | ||
$image = (isset($options['i']) && $options['i']) ? $options['i']: NULL; | ||
|
||
return [ | ||
'file' => $file, | ||
'template' => $template, | ||
'image' => $image | ||
]; | ||
} | ||
|
||
static function help() | ||
{ | ||
echo 'This is a parser for API Blueprint files in PHP.'.PHP_EOL.PHP_EOL; | ||
echo "The following options can be used:.\n"; | ||
echo "\t-f\tSpecifies the file to parse.\n"; | ||
echo "\t-t\tSpecifies the template to use. (defaults to 'default')\n"; | ||
echo "\t-h\tDisplays this text.\n"; | ||
} | ||
|
||
static function version() | ||
{ | ||
$version = (VERSION === '0') ? @exec('git describe --tags 2>&1') : VERSION; | ||
echo 'PHPDraft: '.$version; | ||
} | ||
|
||
} |