jamielsharief / task-runner
任务运行器
0.1.3
2021-09-17 14:40 UTC
Requires
- php: ^7.4 || ^8.0
- jamielsharief/data-transfer-object: ^0.1.1
- originphp/console: ^3.17.7
- originphp/dotenv: ^2.0
- originphp/process: ^3.17
- originphp/yaml: ^2.1
Requires (Dev)
- originphp/filesystem: ^3.0
- originphp/test-suite: ^3.11
- phpstan/phpstan: ^0.12.64
- phpunit/phpunit: ^9.2
This package is auto-updated.
Last update: 2024-09-17 21:26:08 UTC
README
在处理各种项目的过程中,有时几个月才检查一次,我希望有一种方式可以标准化每个项目的流程,这样就可以轻松设置、管理和使用。
安装
将其包含到您的项目中
$ composer require jamielsharief/task-runner
要构建PHAR文件作为bin/task.phar,运行以下命令,如果您希望将其安装到/usr/local/bin,请运行bin/task deploy。
$ git clone https://github.com/jamielsharief/task-runner task-runner
$ cd task-runner
$ composer install
$ bin/task build
使用方法
它会在工作目录中查找task.yml文件,或者您可以使用working-directory选项让它查找不同的文件夹。
$ bin/task --working-directory /somewhere/else
如果您的任务运行不符合预期,请使用verbose选项强制输出。
$ bin/task --verbose # show output and debug info
查看每个项目的可用任务
$ bin/task ______ __ ____ /_ __/___ ______/ /__ / __ \__ ______ ____ ___ _____ / / / __ `/ ___/ //_/ / /_/ / / / / __ \/ __ \/ _ \/ ___/ / / / /_/ (__ ) ,< / _, _/ /_/ / / / / / / / __/ / /_/ \__,_/____/_/|_| /_/ |_|\__,_/_/ /_/_/ /_/\___/_/ version dev +-----------+----------------------------------------------------+ | task | description | +-----------+----------------------------------------------------+ | test | runs PHPUnit tests | | coverage | Generates the code coverage | | release | Creates a release and updates the version number. | | build | Builds the PHAR | | deploy | Deploys the PHAR file | +-----------+----------------------------------------------------+
运行依赖于build(它又依赖于test)的deploy任务。
$ bin/task deploy ______ __ ____ /_ __/___ ______/ /__ / __ \__ ______ ____ ___ _____ / / / __ `/ ___/ //_/ / /_/ / / / / __ \/ __ \/ _ \/ ___/ / / / /_/ (__ ) ,< / _, _/ /_/ / / / / / / / __/ / /_/ \__,_/____/_/|_| /_/ |_|\__,_/_/ /_/_/ /_/\___/_/ version dev [ OK ] Run PHPUnit [ OK ] Run PHPStan [ OK ] Build PHAR archive [ OK ] Copy task.phar to local/bin
一个示例配置
dotenv: config/.env tasks: test: name: Run PHPUnit description: runs PHPUnit tests commands: - vendor/bin/phpunit output: true environment: XDEBUG_MODE: "off" coverage: name: Generate code coverage description: Generates the code coverage commands: - vendor/bin/phpunit --coverage-html coverage environment: XDEBUG_MODE: "coverage" phpstan: name: Run PHPStan description: Runs PHPStan to find errors in code commands: - vendor/bin/phpstan analyse src release: name: Create release description: Creates a release and updates version.txt commands: - bin/release output: true build: name: Build PHAR archive description: Builds the PHAR commands: - php -d phar.readonly=Off bin/build - composer update depends: - test - phpstan deploy: name: Copy app.phar to local/bin description: Deploys the PHAR file depends: - build commands: - cp bin/app.phar /usr/local/bin/app
键
全局键
dotenv (字符串)
一个指向.env文件的路径,这可以在全局或特定任务中使用。
dotenv: config/.env
环境
环境变量的键值数组
environment:
XDEBUG_MODE: "coverage"
任务特定键
这是在任务配置中设置任务特定设置的
dotenv (字符串)
一个指向.env文件的路径
dotenv: config/.env
环境
环境变量的键值数组
environment: XDEBUG_MODE: "coverage"
目录 (字符串)
您可以设置任务的当前目录,如果目录不存在,它将创建它。
directory: /tmp/build
输出 (布尔值)
将命令进程的输出直接发送到屏幕,默认为false
output: true
命令 (数组)
要运行的命令列表
commands: - mkdir foo
依赖于 (数组)
一个数组,包含此task所依赖的tasks,这些任务将首先运行
depends: - build
名称 (字符串)
如果您想在运行时显示不同的任务名称,请设置此选项,这不会更改调用任务的命令行名称。
描述 (字符串)
这会在列表屏幕上显示