phug/split

Pug (前身为 Jade) 是一个用于 PHP 的外观引擎,它是一个通过缩进来结构化的 HTML 模板引擎

1.4.0 2023-08-19 13:43 UTC

This package is auto-updated.

Last update: 2024-09-19 17:00:49 UTC


README

Latest Stable Version Tests

Split 是一个处理单仓库的工具,可以下载为单个包、多个包或两者兼备。

安装

composer require phug/split

用法

composer.json 文件放在主包仓库的子目录中。

vendor/bin/split update

使用以下选项进行检查:

vendor/bin/split update --help

使用以下选项检查其他命令:

vendor/bin/split --help

通过环境变量传递 GIT 认证

导出环境变量,例如:

REPOSITORY_CREDENTIALS=my-git-username:my-authentication-token
vendor/bin/split update --git-credentials=$REPOSITORY_CREDENTIALS

示例

phug-php/phug 是一个库,可以通过 phug/phug 完全要求,也可以作为分离的包 phug/parserphug/compiler 等要求。

每个包由 src/Phug 中的一个目录定义,其中每个目录都有一个专门的 composer.json 文件。

一旦您创建了 GitHuba(或其他 git 发布者)仓库,并在 packagist.org(您可以使用仅包含基本信息的单个 composer.json 文件提交仓库,split 将稍后插入实际内容)上注册了它们。

现在,您可以从单仓库简单地运行 vendor/bin/split update 或从钩子或作业自动运行此命令。

例如,phug/phug 使用 GitHub Actions 在每次提交后自动触发它:.github/workflows/split.yml

它依赖于非常少的步骤

  • 通过 shivammathur/setup-php@v2 加载 PHP

  • 使用 actions/cache@v2 缓存依赖文件夹以使作业更快(可选)

  • 使用以下方式安装 phug/split

    test -f composer.json && mv composer.json composer.json.save -f
    composer require phug/split --no-interaction
    test -f composer.json.save && mv composer.json.save composer.json -f

    (mv 命令是可选的,这里只安装 phug/split,因为您的其他依赖项不需要为此作业)

  • 运行 split update 命令

    - name: Split monorepository
      run: vendor/bin/split update --git-credentials=$REPOSITORY_CREDENTIALS
      env:
        REPOSITORY_CREDENTIALS: ${{ secrets.REPOSITORY_CREDENTIALS }}

    在此处,我们使用 git-credentials 传递 git 凭据,因为作业运行者将没有经过身份验证的 git 用户能够将内容推送到您的仓库。

    认证变量是您的 git 用户名,后跟 :,后跟您可以通过页面 https://github.com/settings/tokens 生成的一个认证令牌(参见文档:管理您的个人访问令牌)。

    不要将此清晰的令牌直接放在 GitHub Action 文件中,请使用存储库密钥(参见文档:加密密钥)以保持其私密性。