lastcall/composer-upstream-files
Composer 安装命令:
composer require lastcall/composer-upstream-files
包简介
Composer command to update application files from various upstream sources.
README 文档
README
Composer Upstream Files Plugin is brought to you by your friends at Last Call Media, this Composer plugin allows you to update files belonging to your application from various upstream sources. There are a couple of different use cases for this:
- You have files that are required for specific versions of your application dependencies, but which need to live as part of your application. For example, Drupal's
index.phpfile is required, but must live outside of thecoredirectory when you use a Composer based installation. - You have files you want to allow modifications to (so they're not appropriate for inclusion in a library), but that you want to keep in sync between different projects. For example, a default
.eslintrcorphpcs.xml.dist.
In all cases, the files that would be managed by this plugin should be committed to the application's repository. This plugin does not automatically update these files - it only provides a Composer command you can use to update them -- you should do this periodically, then review and commit the resulting changes.
Installation
Install this plugin in your application with Composer:
composer require --dev lastcall/composer-upstream-files
Usage
Upstream files are defined in the extra section of your composer.json. Example:
{
"name": "my-awesome-site",
"require": {
"my/package": "^1.0.0"
},
"extra": {
"upstream-files": {
"files": {
"https://raw.githubusercontent.com/LastCallMedia/Drupal-Scaffold/circle20/.editorconfig": ".editorconfig",
"https://raw.githubusercontent.com/LastCallMedia/Drupal-Scaffold/circle20/web/.htaccess": "web/.htaccess"
}
}
}
}
In this example, we've defined two files with upstream sources. The key of the files array is the source, and the value is the destination. When we run composer upstream-files:update, both files will be refreshed from their respective URLs. We would then review and commit the changes.
Tokens
This plugin supports using tokens to reduce the amount of stuff you have to type and update. Tokens are enclosed in double brackets. Example:
{
"extra": {
"upstream-files": {
"tokens": {
"scaffold": "https://raw.githubusercontent.com/LastCallMedia/Drupal-Scaffold",
"drupal": "https://raw.githubusercontent.com/drupal/drupal/{{drupal/core.version}}"
},
"files": {
"{{drupal}}/index.php": "web/index.php",
"{{scaffold}}/.editorconfig": ".editorconfig"
}
}
}
}
You can define any tokens you want to use under the tokens key, and use them as replacements for your files. Additionally, you can reference the current version of any installed package by using {{PACKAGENAME.version}} (as we did with drupal/core above). Tokens are replaced recursively, so if your token contains a token, that's fine.
Manifests
You can also reference "manifests", or JSON files that contain an upstream-files specification. These manifests can be local or remote. See this example:
// composer.json { "extra": { "upstream-files": { "tokens": { "scaffoldBranch": "master" }, "manifests": [ "drupal.json", "http://github.com/LastCallMedia/Drupal-Scaffold/upstream-files.json" ] } } }
// drupal.json { "tokens": { "drupal": "https://raw.githubusercontent.com/drupal/drupal/{{drupal/core.version}}" }, "files": { "{{drupal}}/index.php": "web/index.php", } }
// http://github.com/LastCallMedia/Drupal-Scaffold/upstream-files.json { "tokens": { "scaffold": "https://raw.githubusercontent.com/LastCallMedia/Drupal-Scaffold/{{scaffoldBranch}}" }, "files": { "{{scaffold}}/.editorconfig": ".editorconfig" } }
Manifests can also specify other manifests, which is handy when you need to specify a lot of files.
Exclusions
It is also possible to exclude files based on their source or destination. This is most useful when you use manifests from upstream projects, and don't want to pull in certain files from upstream:
{
"extra": {
"upstream-files": {
"manifests": [
"drupal.json",
],
"sourceExcludes": [
"@LastCallMedia/Drupal-Scaffold@"
],
"destinationExcludes": [
"/\\.gitattributes/"
]
}
}
}
The sourceExcludes and destinationExcludes properties are both arrays of regular expressions indicating the files you wish to exclude. sourceExcludes will be matched against the fully resolved source URL, and destinationExcludes will be matched against the fully resolved destination path.
lastcall/composer-upstream-files 适用场景与选型建议
lastcall/composer-upstream-files 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.32k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2017 年 12 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lastcall/composer-upstream-files 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lastcall/composer-upstream-files 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-02