abdelhamiderrahmouni / prodtools
我用来优化工作的工具集。
v0.5.2
2024-06-11 17:30 UTC
Requires
- php: ^8.1
- ext-zip: *
- guzzlehttp/guzzle: ^7.5
- illuminate/collections: ^10.0
- illuminate/http: ^10.0
- intervention/image: ^3.6
- nunomaduro/termwind: ^1.15.1
- spatie/image-optimizer: ^1.7
Requires (Dev)
- laravel-zero/framework: ^10.2
- laravel/pint: ^1.13
- mockery/mockery: ^1.6
- pestphp/pest: ^2.22
README
Prodtools
一套命令行工具,帮助我更快地发布代码,使用laravel zero制作。
可用功能
- 语言文件翻译。
- 资产图像优化。
- 文件/文件夹/项目压缩
文档
通用用途
安装
您可以通过composer安装此包
composer global require abdelhamiderrahmouni/prodtools
将其添加到您的PATH中
export PATH="$PATH:$HOME/.composer/vendor/bin"
使用方法
该包提供三个主要命令
翻译
此命令将您的语言文件从源语言翻译为目标语言或多种语言,支持多种语言,并可以以JSON格式输出结果。
prodtools translate <from> <to:multiple languages> [--json]
示例:以下将翻译包含从 en
语言到 fr
和 ar
语言的php文件,并输出ar
和fr
语言的文件夹。
prodtools translate en fr ar
以下将翻译包含从 en
语言到 fr
和 ar
语言的JSON文件,并将翻译输出到ar.json
和fr.json
文件。
prodtools translate en fr ar --json
您可以在superduper filament starter kit上找到更多详细信息。@riodwanto是该命令的原始作者,我只是添加了JSON输出功能。
资产优化
此命令背后的想法源于在发布应用程序之前优化资产文件夹中图像的需求。由于手动执行此操作是一项繁琐的任务,因此我决定自动化它。
此命令将优化资产文件夹中的图像。
prodtools images:comporess <path> # defaults to public/assets
选项
path
是包含要优化的图像的文件夹的路径;默认情况下为 public/assets。
参数
--keep
保留原始图像;默认情况下为 false。--prefix
在原始文件夹的名称前添加前缀;默认情况下为 "old_"。--details
显示优化详情;默认情况下为 false。
项目压缩
此命令将项目文件和文件夹压缩成单个存档文件。
prodtools compress <path> # defaults to current directory
选项
path
是要压缩的文件夹的路径;默认情况下为当前目录。
参数
--exclude
指定要排除的文件和文件夹;默认情况下为 ".git,node_modules"。--include
确保目录和文件包含在zip中。--output-name|name
指定输出文件名;默认情况下为以蛇形命名的文件夹名称,例如 "folder_name.zip"。--chunk-size
每个块的最大大小(MB),0 为不切块。--excludes_file
一个包含要排除的目录和文件的文件(应位于项目路径的根目录),默认情况下将查找.prodtools_compress_excludes
。
prodtools compress # compress the current directory, this will look for .prodtools_compress_excludes file in the root of the project and exclude the files and folders mentioned in it. prodtools compress --exclude=".git,node_modules,.github,.idea,storage,.env,public/.htaccess" prodtools compress --include="node_modules" # compress the current directory and include the node_modules folder. prodtools compress --output-name="my_project.zip" # compress the current directory and name the output file my_project.zip. prodtools compress --chunk-size="10" # compress the current directory and split the output file into chunks of 10MB.
从Unsplash获取随机图片
此命令将下载随机图片并保存到指定的文件夹。
prodtools images:get <folder> --amount "<count>" --size "<width>x<height>" --terms "<search terms>" --multi-size --sizes "<width>x<height>,<width>x<height>,..." --amounts "<count>,<count>,..."
选项
folder
是保存图片的文件夹;默认情况下,命令将在当前路径中创建名为 local_images 的文件夹。
参数
--amount
是要下载的图片数量;默认情况下为 5。--size
是要下载的图片大小;默认情况下为 200x200。--terms
是要使用的搜索词;默认为空。--multi-size
是下载多个图像尺寸的标志;默认为 false。--sizes
是要下载的图像尺寸;默认为 "200x200,1280x720"。--amounts
是每个尺寸要下载的图像数量;默认为 "5,5"。
示例
prodtools images:get public/assets/images --amount "10" --size "1920x1080" --terms "nature,animals"
prodtools images:get public/assets/images --multi-size --sizes "1920x1080,1280x720,640x480" --amounts "5,3,2" # make sure the amounts match the sizes count
开发
构建独立应用程序
运行以下命令以构建独立应用程序
php production-tools app:build prodtools
然后您可以直接执行它
./builds/prodtools
或在 Windows 上
C:\application\path> php builds\prodtools # this is still not ready for windows
许可证
Laravel Zero 是一个开源软件,根据 MIT 许可证授权。