pixelfear/composer-dist-plugin
Composer 安装命令:
composer require pixelfear/composer-dist-plugin
包简介
Downloads distributable assets to be used in packages so you don't have to commit them.
README 文档
README
A Composer plugin that allows zip files containing distributable assets to be downloaded and extracted within a package's directory when it's installed.
Useful for packages that need to ship compiled css/js files but don't want to track them within git.
Note: This just downloads and extracts the zip.
It doesn't compile or create them. To do that, check the the Prerequisites section below.
Example
Suppose you publish a PHP package foo/bar which expects your compiled dist assets to be located in resources/dist. Place this configuration in the composer.json for foo/bar:
{
"name": "foo/bar",
"require": {
"pixelfear/composer-dist-plugin": "dev-master"
},
"extra": {
"download-dist": {
"url": "https://github.com/foo/bar/releases/download/{$version}/dist.tar.gz",
"path": "resources/dist"
}
}
}
Prerequisites
This plugin only downloads and extracts an existing zip from a URL. You will need to create the zip yourself.
A good solution for this could be using a GitHub Actions workflow.
For example, this workflow will do the following steps whenever you push a tag starting with v:
- Checkout your code using Git
- Run npm install
- Compile assets using Laravel Mix
- Create a tar.gz archive
- Create a GitHub release
- Upload the tar to the release
Of course, this means that archives will only exist for tagged releases. If you are installating a package using a branch like dev-master, the zip will 404. In this case you can manually compile your assets locally.
Configuration
Multiple bundles
In the example above, a single zip (bundle) is used. However, you may configure multiple bundles to be downloaded by providing an array of bundle objects.
"extra": { "download-dist": [ { "url": "...", "path": "dist/one", }, { "url": "...", "path": "dist/two" } ] }
Bundle options
For each bundle, the following options are available:
| Option | Description |
|---|---|
| url | The URL of the zip to download. Supports zip, tar, or tar.gz files. You can include {$version} in the URL which will be replaced by the version of the package being installed (eg. v1.0.0). |
| path | Where the zip should be extracted relative to your package's root. Defaults to dist. |
| name | Name of the bundle which will be displayed in the Composer output. Defaults to dist. |
pixelfear/composer-dist-plugin 适用场景与选型建议
pixelfear/composer-dist-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.25M 次下载、GitHub Stars 达 30, 最近一次更新时间为 2019 年 11 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 pixelfear/composer-dist-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pixelfear/composer-dist-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 4.25M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 16
- 依赖项目数: 49
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-25