phug / split
Pug (前身为 Jade) 是一个用于 PHP 的外观引擎,它是一个通过缩进来结构化的 HTML 模板引擎
资助包维护!
kylekatarnls
Open Collective
Tidelift
Requires
- php: ^7.3 || ^8.0
- ext-json: *
- simple-cli/simple-cli: ^1.6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15.0 || ^3.23.0
- nette/utils: ^3.2.10
- phan/phan: ^3.2.10 || ^5.4.2
- phpmd/phpmd: ^2.13.0
- phpstan/phpstan: ^0.11.15 || ^1.10.29
- phpunit/phpunit: ^8.5.33 || ^9.6.11
- squizlabs/php_codesniffer: ^3.7.2
- vimeo/psalm: ^4.30.0 || ^5.14.1
README
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/parser
、phug/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 文件中,请使用存储库密钥(参见文档:加密密钥)以保持其私密性。