werbfred/composer-package-updater
最新稳定版本:1.0.2
Composer 安装命令:
composer require werbfred/composer-package-updater
包简介
This project provides a way to have scripts be executed on packages when they are being installed, updated and uninstalled.
关键字:
README 文档
README
This project provides a way to have scripts be executed on packages when they are being installed, updated and uninstalled.
Currently only scripts defined in the root composer.json file are being executed. This is a workaround to Composer's Issue 1993.
For security reasons, Composer\Script\PackageEvent will only be forwarded to the packages for which these events are being raised.
In my case, I have Drupal modules and themes hosted in a git repo. Once installed/updated via composer I want to:
- Run compass to generate .css files
- Remove some files (.gitignore, .sass directory, ...)
Each module or theme being responsible to perform its own install/update/uninstall tasks.
Setting it up !
Install this project via packagist :
composer require werbfred/composer-package-updater
Open the root composer.json file to update it with configuration below:
Autoload
Add "ComposerPackageUpdater\\composer\\": "vendor/werbfred/composer-package-updater/src/composer" to psr-4 in autoload section.
Example:
"autoload": {
"psr-4": {
"ComposerPackageUpdater\\composer\\": "vendor/werbfred/composer-package-updater/src/composer"
}
}
This will tell Composer where files of a given namespace are located. In our case Composer will be able to load our PackageUpdater class.
Note: More information on autoload section can be found here.
Scripts
Add below entries to the scripts section.
"scripts": {
"pre-package-install": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
"post-package-install": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
"pre-package-update": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
"post-package-update": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
"pre-package-uninstall": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent",
"post-package-uninstall": "ComposerPackageUpdater\\composer\\PackageUpdater::processPackageEvent"
}
The above will ensure that below PackageEvents can be forwarded :
- pre-package-install
- post-package-install
- pre-package-update
- post-package-update
- pre-package-uninstall
- post-package-uninstall
Note: More information on scripts section can be found here and there.
Configuration
Configuration must be added under dependency-scripts in extra section.
Parameters:
| Parameter | type | Default | Description |
|---|---|---|---|
| run | bool | false | If true package scripts will be called. Any other value will be considered as false. |
| trust | array | [] | List of packages for which you want the Composer\Script\PackageEvent be dispatched. |
Example:
"extra": {
"dependency-scripts": {
"run": true,
"trust": [ "dummy"
, "foobar" ]
}
}
Note: More information on extra section can be found here.
What do I need to put in my package's composer.json* file ?
You can now fill your scripts section with your own ones.
Be careful: Pathes in your autoloads section must be relative to your package's location.
Usefull Links
- Composer.json schema : https://getcomposer.org/doc/04-schema.md
- More on scripts : https://getcomposer.org/doc/articles/scripts.md
统计信息
- 总下载量: 1.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-26