exed/beanstalk-satis-gen

Beanstalk Satis 生成器

0.2.1 2015-06-11 10:24 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:23:03 UTC


README

这是一个简单的工具,允许您通过从Beanstalk账户读取仓库并添加所有Composer包的仓库来将仓库添加到Satis JSON文件中。

您可以直接调用包含的PHP类来使用此工具,但主要的使用场景是通过构建一个phar并调用它。

安装

要安装,您可以克隆或下载仓库,并使用box构建一个.phar。本项目根目录下有一个box配置文件,因此只需在项目根目录中运行box build即可构建.phar。.phar文件将创建在bin/satis-update.phar

使用示例

bin/satis-update.phar generate config.json satis.json

config.json

{
  "subdomain": "demo",     # list repositories on the https://demo.beanstalkapp.com/ account
  "username":  "demouser", # log in with the demouser account
  "token":     "..."       # use this access token
}

satis.json

{
  "name": "My Package repository",
  "repositories": []
}

结果

这将扫描指定账户下指定用户可以访问的所有Git仓库。如果仓库的主分支根目录中有composer.json文件,并且该composer.json文件指示它应该在satis中,则该仓库将被添加到satis.json中

{"type": "vcs", "url": "the-repository-url"}

只有那些尚未存在的仓库才会被添加,因此可以安全地多次运行脚本。现有的仓库定义将被保留:脚本不会删除或更新它们。

生成命令完成后,最后更改集的哈希将被保存,这样未来的解析就不会那么慢。在更新已完成的satis.json时,应使用更新命令。

bin/satis-update.phar update config.json satis.json

此命令将读取自保存哈希(config.json中的parsed_to)以来的所有更改集,并解析这些更改以查看是否添加了新的composer.json或已编辑以包含所需的信号。

包信号

要使仓库出现在satis.json中,必须满足以下要求

  • 必须存在composer.json

  • composer.json中的name字段不能为空

  • type字段必须是一个绝对表示包或satis-package键存在于extra字段并设置为true的字段,如下所示

    {
        "extra": {
            "satis-package": true
        }
    }
    

高级使用

您可以在config.json文件中添加一个过滤器

{
  "subdomain": "demo", 
  "username":  "demouser",
  "token":     "...",
  "repository_filters": {
    "last_commit_within": "1 week"
  }
}

这将只扫描在过去一周内提交的仓库。这对于将脚本作为cron作业运行很有用,因为扫描许多仓库以查找composer.json文件可能会有些慢。

过滤器

last_commit_within目前是唯一的过滤器。它的值被评估为从当前时间开始的strtotime偏移量,因此所有strtotime偏移量都是有效的

  • "1 month"
  • "2 hours"
  • 等等。