stepanenko3 / nova-command-runner
Laravel Nova 工具,用于运行 Artisan 和 bash(shell)命令。
v4.3.5
2024-03-27 20:00 UTC
Requires
- php: >=7.4
- laravel/nova: ^4.0
- stepanenko3/laravel-helpers: ^1.3.2
Requires (Dev)
- phpstan/phpstan: ^1.10
- tightenco/duster: ^2.7
- dev-main
- v4.3.5
- v4.3.4
- v4.3.3
- v4.3.2
- v4.3.1
- v4.3.0
- v4.2.7
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.11
- v4.0.10
- v4.0.9
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- 4.0.3
- 4.0
- dev-dependabot/npm_and_yarn/vite-5.4.8
- dev-dependabot/npm_and_yarn/tailwindcss-3.4.13
- dev-dependabot/npm_and_yarn/vite-5.4.7
- dev-dependabot/npm_and_yarn/vue/compiler-sfc-3.5.8
- dev-dependabot/npm_and_yarn/vitejs/plugin-vue-5.1.4
- dev-dependabot/npm_and_yarn/postcss-8.4.47
- dev-buttons-fix_postcss-fix_packages-update
- dev-fix-gray-button-color-and-remove-base-tailwind-styles
- dev-migrate-to-vite_less-depend-from-nova
- dev-new-version
- dev-build_resources_for_new_release
This package is auto-updated.
Last update: 2024-09-25 12:54:22 UTC
README
描述
此 Nova 工具允许您直接从 Nova 运行 artisan 和 bash 命令。
这是由 Nova Command Runner 的作者 guratr 开发的原始包的扩展版本。
要求
php: >=8.0
laravel/nova: ^4.0
功能
- ⌨️ 运行预定义的 artisan 和 shell 命令
- 📝 运行自定义 artisan 和 shell 命令
- 📄 在运行命令时使用变量
- 🙋♂️ 在运行命令时提示用户指定可选标志
- 📄 使用下拉框或提示用户输入变量值来使用预定义的变量值。
- 📖 跟踪命令运行历史
- 💾 无需数据库更改。所有内容都由单个配置文件管理。
- 🕔 队列长时间运行的命令
- ✅ 支持命令进度条
- 📱 响应式
- 🕶 暗黑模式
安装
您可以通过 composer 将 nova 工具安装到使用 Nova 的 Laravel 应用中
composer require stepanenko3/nova-command-runner
接下来,您必须在 Nova 中注册此工具。这通常在 NovaServiceProvider
的 tools
方法中完成。
// in app/Providers/NovaServiceProvder.php // ... public function tools() { return [ // ... new \Stepanenko3\NovaCommandRunner\CommandRunnerTool, ]; }
发布配置文件
php artisan vendor:publish --provider="Stepanenko3\NovaCommandRunner\ToolServiceProvider"
将您的命令添加到 config/nova-command-runner.php
用法
点击您 Nova 应用中的“命令运行器”菜单项以查看工具。
配置
所有配置都通过位于 config/nova-command-runner.php
的单个配置文件管理。
添加命令
所有需要轻松访问的命令都应该在配置文件中的 commands
数组中定义。
命令选项
- run : 要运行的命令(例如,route:cache)
- type : 按钮类(primary,secondary,success,danger,warning,info,light,dark,link)
- group: 组名称(可选)
- variables : 命令中使用的变量数组(可选)
- command_type : 命令类型。(artisan 或 bash。默认 artisan)
- flags : 命令的可选标志数组(可选)
- output_size: 将给定命令的输出裁剪到指定的行数
- timeout: 更新给定队列命令的超时限制
示例
'commands' => [ // Basic command 'Clear Cache' => [ 'run' => 'cache:clear', 'type' => 'danger', 'group' => 'Cache', ], // Bash command 'Disk Usage' => [ 'run' => 'df -h', 'type' => 'danger', 'group' => 'Statistics', 'command_type' => 'bash' ], // Command with variable 'Clear Cache' => [ 'run' => 'cache:forget {cache key}', 'type' => 'danger', 'group' => 'Cache' ], // Command with advanced variable customization 'Clear Cache' => [ 'run' => 'cache:forget {cache key}', 'type' => 'danger', 'group' => 'Cache', 'variables' => [ [ 'label' => 'cache key' // This needs to match with variable defined in the command, 'field' => 'select' // Allowed values (text,number,tel,select,date,email,password), 'options' => [ 'blog-cache' => 'Clear Blog Cache', 'app-cache' => 'Clear Application Cache' ], 'placeholder' => 'Select An Option' ] ] ], // Command with flags 'Run Migrations' => [ 'run' => 'migrate --force', 'type' => 'danger', 'group' => 'Migration', ], // Command with optional flags 'Run Migrations' => [ 'run' => 'migrate', 'type' => 'danger', 'group' => 'Migration', 'flags' => [ // These optional flags will be prompted as a checkbox for the user // And will be appended to the command if the user checks the checkbox '--force' => 'Force running in production' ] ], // Command with help text 'Run Migrations' => [ 'run' => 'migrate --force', 'type' => 'danger', 'group' => 'Migration', // You can also add html for help text. 'help' => 'This is a destructive operation. Proceed only if you really know what you are doing.' ], // Queueing commands 'Clear Cache' => [ 'run' => 'cache:clear --should-queue', 'type' => 'danger', 'group' => 'Cache', ], // Queueing commands on custom queue and connection 'Clear Cache' => [ 'run' => 'cache:clear --should-queue --cr-queue=high --cr-connection=database', 'type' => 'danger', 'group' => 'Cache', ], ],
带有进度条的命令
创建带进度条的 artisan 命令。例如
<?php namespace App\Console\Commands; use Illuminate\Console\Command; use Stepanenko3\NovaCommandRunner\Console\HasNovaProgressBar; class LongCommand extends Command { use HasNovaProgressBar; protected $signature = 'command:long'; public function handle() { $bar = $this->createProgressBar(10); foreach (range(1, 10) as $i) { sleep(1); $bar->advance(); } $bar->finish(); return Command::SUCCESS; } }
将您的命令添加到配置命令列表中
'commands' => [ ... // Queueing long-running commands with custom timeout limit and output size 'Long Command' => [ 'run' => 'command:long --should-queue', // '--should-queue' is a required option to display the progressbar 'type' => 'primary', 'group' => 'Application', 'timeout' => 120, // Updates the timeout limit for the given queued command 'output_size' => 3, // The number of last lines to be displayed in the output ], ]
其他自定义
// Limit the command run history to latest 10 runs 'history' => 10, // Tool name displayed in the navigation menu 'navigation_label' => 'Command Runner', // Any additional info to display on the tool page. Can contain string and html. 'help' => '', // Groups whose commands should not be running simultaneously, ['*'] to apply this globally to all commands 'unique_command_groups' => [], // Allow running of custom artisan and bash(shell) commands 'custom_commands' => ['artisan','bash'], // Allow running of custom artisan commands only(disable custom bash(shell) commands) 'custom_commands' => ['artisan'], // Allow running of custom bash(shell) commands only(disable custom artisan commands) 'custom_commands' => ['bash'], // Disable running of custom commands. 'custom_commands' => [], 'without_overlapping' => [ // Blocks running commands simultaneously under the given groups. Use '*' for block all groups 'groups' => [], // Blocks running commands simultaneously. Use '*' for block all groups 'commands' => [], ],
屏幕截图
致谢
贡献
感谢您考虑为此包做出贡献!请创建一个包含您贡献的 pull request,并详细说明您所提出的更改。
许可
此包是开源软件,许可协议为 MIT 许可。