| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
pake_import('simpletest'); |
|---|
| 5 |
pake_import('pear'); |
|---|
| 6 |
|
|---|
| 7 |
pake_desc('create a single file with all pake classes'); |
|---|
| 8 |
pake_task('compact'); |
|---|
| 9 |
|
|---|
| 10 |
pake_desc('release a new pake version'); |
|---|
| 11 |
pake_task('release'); |
|---|
| 12 |
|
|---|
| 13 |
pake_task('foo'); |
|---|
| 14 |
|
|---|
| 15 |
function run_foo($task, $args) |
|---|
| 16 |
{ |
|---|
| 17 |
throw new Exception('test'); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
function run_compact($task, $args) |
|---|
| 27 |
{ |
|---|
| 28 |
$plugins = $args; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
$content = ''; |
|---|
| 32 |
$files = pakeFinder::type('file')->name('*.class.php')->in(getcwd().'/lib/pake'); |
|---|
| 33 |
$files[] = getcwd().'/bin/pake.php'; |
|---|
| 34 |
foreach ($args as $plugin_name) |
|---|
| 35 |
{ |
|---|
| 36 |
$files[] = getcwd().'/lib/pake/tasks/pake'.$plugin_name.'Task.class.php'; |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
foreach ($files as $file) |
|---|
| 40 |
{ |
|---|
| 41 |
$content .= file_get_contents($file); |
|---|
| 42 |
} |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
$content = preg_replace('/^\s*require_once[^;]+;/m', '', $content); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
$content = str_replace(array("\r\n"), "\n", $content); |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
$content = preg_replace(array("/<\?php/", "/<\?/", "/\?>/"), '', $content); |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
$content = preg_replace(array("/\n\s+\n/s", "/\n+/s"), "\n", $content); |
|---|
| 55 |
|
|---|
| 56 |
$content = "<?php\n".trim($content)."\n"; |
|---|
| 57 |
|
|---|
| 58 |
file_put_contents(getcwd().'/bin/pake_runtime.php', $content); |
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
pake_strip_php_comments(getcwd().'/bin/pake_runtime.php'); |
|---|
| 62 |
} |
|---|
| 63 |
|
|---|
| 64 |
function run_create_pear_package($task, $args) |
|---|
| 65 |
{ |
|---|
| 66 |
if (!isset($args[0]) || !$args[0]) |
|---|
| 67 |
{ |
|---|
| 68 |
throw new pakeException('You must provide pake version to release (1.1.X for example).'); |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
$version = $args[0]; |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
echo 'create pear package for version "'.$version."\"\n"; |
|---|
| 75 |
|
|---|
| 76 |
pake_copy(getcwd().'/package.xml.tmpl', getcwd().'/package.xml'); |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
$class_files = pakeFinder::type('file')->prune('.svn')->not_name('/^pakeApp.class.php$/')->name('*.php')->relative()->in('lib'); |
|---|
| 80 |
$xml_classes = ''; |
|---|
| 81 |
foreach ($class_files as $file) |
|---|
| 82 |
{ |
|---|
| 83 |
$dir_name = dirname($file); |
|---|
| 84 |
$file_name = basename($file); |
|---|
| 85 |
$xml_classes .= '<file role="php" baseinstalldir="'.$dir_name.'" install-as="'.$file_name.'" name="lib/'.$file.'"/>'."\n"; |
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
pake_replace_tokens('package.xml', getcwd(), '##', '##', array( |
|---|
| 90 |
'PAKE_VERSION' => $version, |
|---|
| 91 |
'CURRENT_DATE' => date('Y-m-d'), |
|---|
| 92 |
'CLASS_FILES' => $xml_classes, |
|---|
| 93 |
)); |
|---|
| 94 |
pake_replace_tokens('lib/pake/pakeApp.class.php', getcwd(), 'const VERSION = \'', '\';', array('1.1.DEV' => "const VERSION = '$version';")); |
|---|
| 95 |
|
|---|
| 96 |
pakePearTask::run_pear($task, $args); |
|---|
| 97 |
pake_remove('package.xml', getcwd()); |
|---|
| 98 |
pake_replace_tokens('lib/pake/pakeApp.class.php', getcwd(), 'const VERSION = \'', '\';', array($version => "const VERSION = '1.1.DEV';")); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
function run_release($task, $args) |
|---|
| 102 |
{ |
|---|
| 103 |
if (!isset($args[0]) || !$args[0]) |
|---|
| 104 |
{ |
|---|
| 105 |
throw new pakeException('You must provide pake version to release (1.1.X for example).'); |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
$version = $args[0]; |
|---|
| 109 |
|
|---|
| 110 |
pakeSimpletestTask::run_test($task, array()); |
|---|
| 111 |
|
|---|
| 112 |
if ($task->is_verbose()) echo 'releasing pake version "'.$version."\"\n"; |
|---|
| 113 |
|
|---|
| 114 |
array_unshift($args, $version); |
|---|
| 115 |
|
|---|
| 116 |
run_create_pear_package($task, $args); |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|