Coder Social home page Coder Social logo

pake's Introduction

Pake

Pake is a PHP automation tool with capabilities similar to make. See Wiki for details.

Latest Stable Version Total Downloads

Installation

The recommended way to install Pake is through Composer. Just create a composer.json file and run the php composer.phar install command to install it:

{
    "require": {
        "indeyets/pake": "~1.99"
    }
}

pake's People

Contributors

gggeek avatar indeyets avatar rlerdorf avatar vierbergenlars avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pake's Issues

using composer does not set up autoloader properly for tests

After "composer install", the main pake.php and pakefile.php files do not include simpletest, which make running tests a bit cumbersome.

I tried adding an include_once("vendor/autoload.php") in the main pakefile.php file, but I got error about class redeclaration:

PHP Fatal error: Cannot redeclare pake_autoloader() (previously declared in D:\htdocs\pake_gg\lib\pake\autoload.php:13) in D:\htdocs\pake_gg\lib\pake\autoload.php on line 49
[24-Oct-2013 18:07:12 Europe/Paris] PHP Stack trace:
[24-Oct-2013 18:07:12 Europe/Paris] PHP 1. {main}() D:\htdocs\pake_gg\bin\pake.php:0
[24-Oct-2013 18:07:12 Europe/Paris] PHP 2. pakeApp->run() D:\htdocs\pake_gg\bin\pake.php:14
[24-Oct-2013 18:07:12 Europe/Paris] PHP 3. pakeApp->load_pakefile() D:\htdocs\pake_gg\lib\pake\pakeApp.class.php:130
[24-Oct-2013 18:07:12 Europe/Paris] PHP 4. require() D:\htdocs\pake_gg\lib\pake\pakeApp.class.php:325
[24-Oct-2013 18:07:12 Europe/Paris] PHP 5. include_once() D:\htdocs\pake_gg\pakefile.php:31
[24-Oct-2013 18:07:12 Europe/Paris] PHP 6. ComposerAutoloaderInitb4647cb076fe394b0c1c84e5c1a9ed26::getLoader() D:\htdocs\pake_gg\vendor\autoload.php:7

PHP warnings about invalid callbacks

I noticed that I get a lot of PHP warnings from pake during Travis builds, the first one with the following message:

PHP Warning:  call_user_func_array() expects parameter 1 to be a valid callback, class 'Pyrus\PackageFile\v2' does not have a method 'hasConcreteVersion' in phar:///home/travis/.phpenv/versions/5.3.27/bin/pyrus.phar/Pyrus-2.0.0a4/php/Pyrus/Package/Base.php on line 187

You can see the full trace here: https://travis-ci.org/flack/openpsa/jobs/23621240#L52

Is this a general problem in Pake or does it have to do with my setup somehow?

add a pake task for sftp upload

This is, afaik, not currently supported by pake, and enough of a chore to merit some pake_function of its own (either that, or have it working via pake_write_file).

From my limited web serach, it seems that using curl is better than using the ss2_sftp functions (wider installed base).

Sample code:

    $fp = fopen( $randfile, 'rb' );

    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, str_replace( 'http://', 'sftp://@', $srv ) . $remotefilename );
    if ( $user != "" ) curl_setopt( $ch, CURLOPT_USERPWD, $user );
    if ( $public_keyfile != "" ) curl_setopt( $ch, CURLOPT_SSH_PUBLIC_KEYFILE, $public_keyfile );
    if ( $private_keyfile != "" ) curl_setopt( $ch, CURLOPT_SSH_PRIVATE_KEYFILE, $private_keyfile );
    if ( $private_keypasswd != "" ) curl_setopt( $ch, CURLOPT_KEYPASSWD, $private_keypasswd );
    curl_setopt( $ch, CURLOPT_UPLOAD, 1 );
    curl_setopt( $ch, CURLOPT_INFILE, $fp );
    // set size of the file, which isn't _mandatory_ but helps libcurl to do
    // extra error checking on the upload.
    curl_setopt($ch, CURLOPT_INFILESIZE, filesize( $randfile ) );
    $ok = curl_exec( $ch );
    $errinfo = curl_error( $ch );
    curl_close( $ch );

    fclose( $fp );

    if ( !$ok )
    {
        throw new pakeException( "Couldn't write {$fullfilename} file: " . $errinfo );
    }

allow custom git command

I need to execute a "git log" command, which is, afaict, not supported yet.
Maybe a generic way to run other git commands would be ok (eg making public the method git_run)

Help: howto set command line arguments

I have this task that fails since phpunit needs *.php as an argument. How do I set this?

$task('test', 'Test using PHPUnit', function () use ($pake) {
    $process = $pake['process']('./vendor/bin/phpunit');

    return $process->error($process->stream(STDERR))
                   ->output($process->stream(STDOUT))
                   ->run();
});

Any advice is greatly appreciated!

plugins vs case-sensitive tasks

pake_import('phpExtension') doesn't correctly load pakePhpExtensionTask.class.php file on case-sensitive file-systems (it looks for "pakePhpextensionTask.class.php").

need to fix file-name or make pake_import() smarter. In latter case need to verify, that backwards compatibility is not broken

pake_chmod does double up directory

when calling pake_chmod like pake_chmod('', 'cache/', 0777) then it will fail
output:

chmod 777 cache/cache/
Warning: chmod(): file or directory not found in /usr/share/php/pake/pakeFunction.php:351

as you see it tries to chmod cache/cache/ instead of cache/ which will result phps chmod call to fail

we have discovered that it must relate to the following commit: d600cb1
d600cb1

PEAR Channel down

ATM, pear.indeyets.pp.ru is not reachable, so pake cannot be installed

Please add "--help" option

Please add a "--help" option. "pake --help" should do the same thing as
"pake help". It should work regardless of whether a Pakefile is available.

Add support for long descriptions for tasks

So far I have come up with the following implementation:

  • add a new function pake_londgdesc( $desc='' ) to allow adding a long description to every task
  • if $desc == '', the 'long' description is taken from the php docblock attached to the php function executing the task
  • if pake_longdesc() is not called for a task (or docblock is empty), its long description is equal to its short one
  • added a "help" task that takes as 1st parameter the name of another task to see its long description, eg "pake help build"

(available at the pakefile at https://github.com/gggeek/ezextensionbuilder/blob/master/pakefile.php)

And here is the explanation:

Writing a pakefile for a project is a very nice thing, considering that it boils down to writing php functions (esp. compared to ant / makefiles), but it is imho severely hampered by the lack of documentation about what is going on.

Esp. with a long lifetime / many developers project, having top-notch quality of the assumptions of the tasks is essential.
After many years it can e.g. be hard to remember the filesystem layout or xml tokens expected by the pakefile, and while php is a very much readable language, having better documentation of the available tasks would be imho a big improvement.

A common solution is to document the pakefile using wikis or word documents, but we all know that code and documentation tend to fall out of sync very easily. Otoh docblocks are well known, widely used and generally updated. The only downside of using them is that a single docblock now has 2 different users: developers of the pakefile and users of the pakefile. This is however countered by the fact that the pakefile developer can provide a custom long_desc instead of relying on docblock.

Last but not least the syntax $command help $subcommand is very common everywhere, from pear to svn.

Comments?

bad quoting in git commands (pull and maybe others) on windows

the escaping of the commands used for git cli should be fixed for it to work on windows: current code generates

git "--git-dir=d:\etc/.git" "--work-tree=d:\etc" pull

which gives this error:

.git""=="gui" was unexpected at this time.

a better syntax is

git --git-dir="d:\etc/.git" --work-tree="d:\etc" pull

The fix is the following:

private function git_run($command)
{
    if (self::$needs_work_tree_workaround === true) {
        $cmd = '(cd '.escapeshellarg($this->repository_path).' && git '.$command.')';
    } else {
        $cmd = 'git';
        // here I would also maybe use the constant for DIRECTORY_SEPARATOR instead of /
        $cmd .= ' --git-dir='.escapeshellarg($this->repository_path.'/.git');
        $cmd .= ' --work-tree='.escapeshellarg($this->repository_path);
        $cmd .= ' '.$command;
    }
    [...]

PEAR channel down

Same as Issue #11 posted 11months ago - Pear channel since few hours is down - can't resolve hostname - tried using diffrent servers and locations but problem is same.

Interactive mode

"pake -i" command should start interactive mode of pake. In this mode, pake should ask user for a task name and parameters.

"?" command should print list of tasks

^C, ^D and "quit_pake" should return user to shell

short names of tasks should be usable (just like those are usable in usual non-interactive mode)

Description of "--tasks" is incorrect

I have a project in which I use Pake 1.99.3. If I type "pake help", I get a
usage message which tells me that the effect of "--tasks" is to "Display the
tasks and dependencies, then exit". However, this is incorrect --
"pake --tasks" displays only the tasks, not their dependencies.

Add dbdeploy support like available in phing

Just seems to be a feature that would help drive uptake. Apologies, but I don't think I have the know-how to help out with this myself at the moment -- was just comparing Phing and Pake and saw that this was a feature which gave Phing an advantage :)

wrong phar generated

The run_phar not includes the sfYaml library for me. I have added this hotfix to the pakefile.php and it helped for me.

<?php
    $finder = pakeFinder::type('any')->ignore_version_control()->name('phar-stub.php', 
         '*.class.php', 'init.php', 'pakeFunction.php','sfYaml*.php');

The sfYaml include might missing on other formats.

ob_end_flush forcing headers to be sent back early breaks content-type

Hi Guys -

I'm using PAKE as part of a project at work. I'm installing it via composer (thanks for adding support!) with PHP 5.3.16. The problem I'm seeing is that like PAKE is calling ``ob_end_flush` during it's init process, which in turn is causing headers to be set early and an invalid content-type to be returned. In my simple PHP app, I added the following:

myapp.php

if (headers_sent($filename, $linenum)) {
    echo "Headers already sent in $filename on line $linenum\n";
}

And I get:

Headers already sent in /Users/brian/code/riot/apollo-js/vendor/indeyets/pake/lib/pake/init.php on line 69 

Investigating, it looks like the following is the culprit:

init.php

// fix php behavior if using cgi php
// from http://www.sitepoint.com/article/php-command-line-1/3
if (false !== strpos(PHP_SAPI, 'cgi'))
{
   // handle output buffering
   @ob_end_flush(); //Error is here

I verified that the output buffer was actually empty at the point this is being called by doing:

// fix php behavior if using cgi php
// from http://www.sitepoint.com/article/php-command-line-1/3
if (false !== strpos(PHP_SAPI, 'cgi'))
{
   // handle output buffering
  echo @ob_get_length; 
  @ob_end_flush(); //Error is here

The output is 0.

Am I missing something? I can't find any documentation that says that ob_end_flush will force headers to be set even if the buffer is empty. The article this references is pretty old.

With all that said, if I comment out this line my app works fine.

allow pakefile to add definition of custom parameters

Right now any custom parameter passed on the command line is rejected (ie. all the ones not defined in pakeapp class).

It would be nice if the user could add support for custom parameters, a la java (eg. -Dmyparam=myvalue), or by plain registration of more options.

As far as I can tell, this is now impossible, as the function run() does not allow to specify extra options definitions, but only options values. Also the do_option() method should be modified accordingly

Could not install using pear

I could not install using the pear installer

pear channel-discover pear.indeyets.pp.ru/
pear install indeyets/pake

Got the following error. Package "pake" Version "1.4.1" does not have REST dependency information available

I am on PHP 5.3.2 on an Ubuntu machine.
install failed

pakegit class not throwing an error for failed requests

In git_run command (line 182), if the call to pake_sh fails, and there is no 'cannot be used without a working tree' in the error msg, the exception is silently swallowed, which is not, imho, what the user usually wants

phar and plugins (PLUGINSDIRS)

I experienced because the following challenge with plugins

Because there is

Phar::interceptFileFuncs(); 

in the phar-stub.php the plugins are loaded from inside the pake. When I would like to extend pake.phar with some plugins not "built-in" into pake i have to use this workaround in
pakefile.php:

pakeApp::$PLUGINSDIRS[] = dirname(__FILE__).'/tasks';
pake_import('any_external_plugin');

so I can load 'any_external_plugin without re-building pake.phar.

I can see the pakeApp::$PLUGINSDIRS[] is an array so it is open for extension, but searching through the source code I haven't found a "best practice" to do that.

Am I wrong with the case? Any suggestion?
Thank you

pakefile.php local instance detection

The path detection

if ($_self_path != $_oldstyle_local and $_self_path != $_newstyle_local) {

not working on windows (slash vs backslash) in pakefile.php

I am using this patch to solve the problem:

$_oldstyle_local = dirname(__FILE__).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'pake.php';
$_newstyle_local = dirname(__FILE__).DIRECTORY_SEPARATOR.'bin'.DIRECTORY_SEPARATOR.'pake';
//$_oldstyle_local = dirname(__FILE__).'/bin/pake.php';
//$_newstyle_local = dirname(__FILE__).'/bin/pake';

This issue might can popup at other places if there is path compare or else.
What do you think about it?

pake test must exit with non-zero code if tests fail

We now use Travis for Continuous Integration with the Midgard PHP5 extension. The tests there are run with pake test. Now Pake exits with code 0 even if tests fail, so the CI environment doesn't notice the failure.

Tag a 1.7.1 release

After adding the composer.json and adding pake to packagist, we now require a tagged release in order to use it properly (well, we could use *@dev, but this would force our developers to have git installed, as there is no ZIP distribution without a recent tag).

It would be nice if you could tag a new release :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.