sanatorium/githelper

此包的最新版本(3.1.0)没有提供许可信息。

管理版本化扩展和依赖的扩展

安装: 0

依赖者: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 0

开放问题: 0

类型:平台扩展

3.1.0 2016-10-11 13:31 UTC

README

管理版本化扩展和依赖的扩展

Preview

文档

管理Cartalyst平台内git包的辅助工具。

配置

您可以在config/sanatorium-githelper.php中设置扩展或任何其他包的路径。

/*
|--------------------------------------------------------------------------
| Paths
|--------------------------------------------------------------------------
|
| Following paths will be scanned by this extension to find
| versioned extensions. These will be available in admin
| area for automated operations.
|
*/

'paths' => [
    'extensions/sanatorium',
    '../langs',
]

直接从git更新扩展

现在当您将扩展同步到git时,您可能希望始终保持扩展的最新版本。以下artisan命令(php artisan dev)是为了这个目的而设计的。

<?php

/**
 * Class Dev
 *
 * Enables you to clone git repositories
 * instead of the composer packages,
 * Meant for development envs.
 *
 * To enable, set environment variable
 * PREFER_GIT=1
 * PREFER_GIT_VENDORS=acme,sanatorium
 *
 *
 * NOTICE OF LICENSE
 *
 * @package    App\Console\Commands
 * @version    1.0.0
 * @author     Sanatorium
 * @license    WTFPL
 * @copyright  (c) 2015-2016, Sanatorium
 * @link       http://sanatorium.ninja
 */

namespace App\Console\Commands;

use Illuminate\Console\Command;

class Dev extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'dev';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Enables clone git repositories instead of composer';

    /**
     * Checks if current environment configuration
     * is set to prefer git packages, if TRUE
     * triggers cloneGitComposerPackages()
     *
     * @return mixed
     */
    public function handle()
    {
        if ( env('PREFER_GIT') == 1 ) {
            
            $this->cloneGitComposerPackages();
            
        }
    }

    /**
     * Takes composer required, scans for packages,
     * checks them against the allowed regular
     * expression found in environment.
     *
     * @see PREFER_GIT_REGEX
     * @example PREFER_GIT_REGEX=/sanatorium\/((?!lang).)*$/
     * @return void
     */
    public function cloneGitComposerPackages()
    {
        $regex = env('PREFER_GIT_REGEX');

        $composerPath = base_path('composer.json');
        
        $composer = json_decode( file_get_contents( $composerPath ), true );

        foreach ($composer['require'] as $package => $version) {

            if ( preg_match($regex, $package) ) {

                $this->clonePackage($package);

            }

        }
    }

    /**
     * Git clones package using git command.
     * Function exec() has to be enabled.
     *
     * @param $package Full name of composer package
     */
    public function clonePackage($package)
    {
        // @todo make this configurable
        $prefix = 'platform-';

        $gitRepo = 'git@github.com:' . str_replace('/', '/' . $prefix, $package)  . '.git';

        $targetPath = base_path('extensions/' . $package);

        if (exec('echo test') == 'test') {
            // Delete the original directory
            exec('rm -rf ' . $targetPath);

            // Clone the package to target directory
            exec('git clone ' . $gitRepo . ' ' . $targetPath);
        } else {
           $this->error('Can\'t use git repositories, as exec() function is disabled' . PHP_EOL);
        }

    }
}

变更日志

  • 3.0.6 - 2016-10-02 - 批量修补包
  • 3.0.5 - 2016-09-30 - 可配置版本限制
  • 0.2.0 - 2016-05-05 - 更进一步的版本控制,显示扩展的期望功能清单(readme,lanuages)

支持

将所有问题/问题指向github 问题,我们将尽快处理。