adlacruzes / composer-import-scripts
Composer plugin to import composer scripts from sources
Installs: 18 504
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:composer-plugin
Requires
- php: ^7.2 || ^8.0
- composer-plugin-api: ^1.0 || ^2.0
Requires (Dev)
- composer/composer: ^1.9 || ^2.0.0
- ergebnis/composer-normalize: ^2.19
- friendsofphp/php-cs-fixer: 2.19.3 || ^3.4.0
- phpstan/phpstan: ^1.10.40
- phpstan/phpstan-phpunit: ^1.3.15
- phpstan/phpstan-strict-rules: ^1.5.2
- phpunit/phpunit: ^8.5.34 || ^9.6.13
README
Composer import scripts is a plugin to import composer scripts from files/URLs at runtime.
I needed a simple way to import scripts and unify commands across multiple libraries. If you need a more powerful tool, you can look at the excellent composer-merge-plugin.
Imported commands have to be invoked with composer run
.
Can this plugin import scripts from...
- other composer.json files? Yes
- public URLs? Yes
Table of Contents
Installation
composer require adlacruzes/composer-import-scripts
As of Composer 2.2.0, the allow-plugins
option adds a layer of security allowing you to restrict which Composer plugins are able to execute code during a Composer run.
Use this setting to allow only packages you trust to execute code.
{ "config": { "allow-plugins": { "adlacruzes/composer-import-scripts": true } } }
Usage
{ "extra": { "import-scripts": { "include": [ "file1.json", "file2.json", "https://url.json" ], "allow_failures": false, "override": true } } }
Configuration
include
required
include
setting is a list of files to import. These files need to be valid JSON according to the import scripts schema.
allow_failures
optional
default: false
allow_failures
is a setting that controls errors from the plugin. If set to true
the following file errors will be ignored and zero scripts will be imported from these files:
- Invalid JSON schema
- Invalid file
override
optional
default: true
When override
is set to true
the scripts from the include
setting will override the scripts with the same name defined in composer.json
JSON schema
This is the scheme files must adapt.
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "scripts": { "type": [ "object" ], "additionalProperties": { "type": ["string", "array"] } } }, "required": [ "scripts" ] }
An example of this schema:
{ "scripts": { "one": "echo one", "two": "echo two", "three": "echo three", "other": [ "echo four", "echo five" ] } }