Skip to content

Instantly share code, notes, and snippets.

@torkiljohnsen
Forked from mathiasverraes/deps.ini
Created January 22, 2012 14:45

Revisions

  1. torkiljohnsen revised this gist Mar 20, 2012. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions vendors.php
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@
    foreach ($deps as $name => $dep)
    {
    $dep = array_map('trim', $dep);
    if(!(isset($dep['git']) && !isset($dep['svn'])) || !isset($dep['version']) || !isset($dep['target'])) {
    if(!(isset($dep['git']) || isset($dep['svn'])) || !isset($dep['version']) || !isset($dep['target'])) {
    exit("deps: Missing variables in [$name]".PHP_EOL);
    }

    @@ -69,4 +69,3 @@

    system($update);
    }

  2. Torkil Johnsen revised this gist Jan 22, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vendors.php
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,7 @@
    if (isset($dep['git'])) {
    $update = sprintf('cd %s && git fetch origin && git fetch --tags origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version']));
    } elseif (isset($dep['svn'])) {
    $update = sprintf('svn update -r %d %s', escapeshellarg($dep['version']), escapeshellarg($installDir));
    $update = sprintf('cd %s && svn update -r %d', escapeshellarg($installDir), escapeshellarg($dep['version']));
    }

    system($update);
  3. Torkil Johnsen revised this gist Jan 22, 2012. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions vendors.php
    Original file line number Diff line number Diff line change
    @@ -33,17 +33,17 @@

    $deps = parse_ini_file($rootDir.'/deps.ini', true, INI_SCANNER_RAW);
    if (false === $deps) {
    exit("The deps.ini file is not valid ini syntax. Perhaps missing a trailing newline?\n");
    exit("The deps.ini file is not valid ini syntax. Perhaps missing a trailing newline?\n");
    }

    foreach ($deps as $name => $dep)
    {
    $dep = array_map('trim', $dep);
    if(!(isset($dep['git']) && !isset($dep['svn'])) || !isset($dep['version']) || !isset($dep['target'])) {
    exit("deps: Missing variables in [$name]".PHP_EOL);
    }
    $dep = array_map('trim', $dep);
    if(!(isset($dep['git']) && !isset($dep['svn'])) || !isset($dep['version']) || !isset($dep['target'])) {
    exit("deps: Missing variables in [$name]".PHP_EOL);
    }

    $installDir = $rootDir.'/'.$dep['target'];
    $installDir = $rootDir.'/'.$dep['target'];
    $install = false;
    if (!is_dir($installDir)) {
    $install = true;
  4. Torkil Johnsen revised this gist Jan 22, 2012. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions vendors.php
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,9 @@
    * target=path/to/vendor/name
    * version=COMMITISH
    * [some_other_name]
    * svn=REPO
    * target=path/to/other/vendor/name
    * version=number
    * ...
    */

    @@ -36,7 +39,7 @@
    foreach ($deps as $name => $dep)
    {
    $dep = array_map('trim', $dep);
    if(!isset($dep['git']) || !isset($dep['version']) || !isset($dep['target'])) {
    if(!(isset($dep['git']) && !isset($dep['svn'])) || !isset($dep['version']) || !isset($dep['target'])) {
    exit("deps: Missing variables in [$name]".PHP_EOL);
    }

    @@ -46,13 +49,24 @@
    $install = true;
    echo "> Installing $name\n";

    system(sprintf('git clone %s %s', escapeshellarg($dep['git']), escapeshellarg($installDir)));
    if (isset($dep['git'])) {
    $install = sprintf('git clone %s %s', escapeshellarg($dep['git']), escapeshellarg($installDir));
    } elseif (isset($dep['svn'])) {
    $install = sprintf('svn checkout %s %s', escapeshellarg($dep['svn']), escapeshellarg($installDir));
    }
    system($install);
    }

    if (!$install) {
    echo "> Updating $name\n";
    }

    system(sprintf('cd %s && git fetch origin && git fetch --tags origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version'])));
    if (isset($dep['git'])) {
    $update = sprintf('cd %s && git fetch origin && git fetch --tags origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version']));
    } elseif (isset($dep['svn'])) {
    $update = sprintf('svn update -r %d %s', escapeshellarg($dep['version']), escapeshellarg($installDir));
    }

    system($update);
    }

  5. @mathiasverraes mathiasverraes revised this gist Jan 21, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vendors.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * [some_name]
    * git=REPO
    * target=path/to/vendor/name
    * version=origin/COMMITISH
    * version=COMMITISH
    * [some_other_name]
    * ...
    */
    @@ -53,6 +53,6 @@
    echo "> Updating $name\n";
    }

    system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version'])));
    system(sprintf('cd %s && git fetch origin && git fetch --tags origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version'])));
    }

  6. @mathiasverraes mathiasverraes revised this gist Jan 21, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion vendors.php
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    * [some_name]
    * git=REPO
    * target=path/to/vendor/name
    * version=COMMITISH
    * version=origin/COMMITISH
    * [some_other_name]
    * ...
    */
  7. @mathiasverraes mathiasverraes created this gist Jan 21, 2012.
    58 changes: 58 additions & 0 deletions vendors.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    #!/usr/bin/env php
    <?php
    /*
    * Custom version of Symfony2's vendor script
    * Put this file in /bin and make a deps.ini file in the root, looking like this:
    *
    * [some_name]
    * git=REPO
    * target=path/to/vendor/name
    * version=COMMITISH
    * [some_other_name]
    * ...
    */

    /*
    * This file is part of the Symfony framework.
    *
    * (c) Fabien Potencier <[email protected]>
    *
    * For the full copyright and license information, please view the LICENSE
    * file that was distributed with this source code.
    */

    set_time_limit(0);

    $rootDir = dirname(__DIR__);
    if (!is_dir("$rootDir/vendor")) {
    mkdir("$rootDir/vendor", 0777, true);
    }

    $deps = parse_ini_file($rootDir.'/deps.ini', true, INI_SCANNER_RAW);
    if (false === $deps) {
    exit("The deps.ini file is not valid ini syntax. Perhaps missing a trailing newline?\n");
    }

    foreach ($deps as $name => $dep)
    {
    $dep = array_map('trim', $dep);
    if(!isset($dep['git']) || !isset($dep['version']) || !isset($dep['target'])) {
    exit("deps: Missing variables in [$name]".PHP_EOL);
    }

    $installDir = $rootDir.'/'.$dep['target'];
    $install = false;
    if (!is_dir($installDir)) {
    $install = true;
    echo "> Installing $name\n";

    system(sprintf('git clone %s %s', escapeshellarg($dep['git']), escapeshellarg($installDir)));
    }

    if (!$install) {
    echo "> Updating $name\n";
    }

    system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($dep['version'])));
    }