From 80d0c2029b8f588f8b00e3a1ca8daac4edc3144e Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Mon, 18 Dec 2017 10:14:24 +0100 Subject: [PATCH 1/5] Move "scripts-description" to toplevel Fixes #6881 --- doc/articles/scripts.md | 18 ++++++++---------- res/composer-schema.json | 4 ++++ src/Composer/Console/Application.php | 10 +++++++++- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index e5c9be0c6..fda45f22d 100644 --- a/doc/articles/scripts.md +++ b/doc/articles/scripts.md @@ -278,16 +278,14 @@ JSON array of commands. ## Custom descriptions. -You can set custom script descriptions with the following extra in your composer.json: +You can set custom script descriptions with the following in your `composer.json`: - ```json - { - "extra": { - "scripts-description": { - "test": "Run all tests!" - } - } - } - ``` +```json +{ + "scripts-description": { + "test": "Run all tests!" + } +} +``` > **Note:** You can only set custom descriptions of custom commands. diff --git a/res/composer-schema.json b/res/composer-schema.json index b98348222..0ae737444 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -447,6 +447,10 @@ } } }, + "scripts-description": { + "type": ["object"], + "description": "Descriptions for scripts listeners, shown in console help." + }, "support": { "type": "object", "properties": { diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index d8ab8eb76..20975a10a 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -228,7 +228,15 @@ class Application extends BaseApplication if ($this->has($script)) { $io->writeError('A script named '.$script.' would override a Composer command and has been skipped'); } else { - $description = isset($composer['extra']['scripts-description'][$script]) ? $composer['extra']['scripts-description'][$script] : null; + $description = null; + + if (isset($composer['scripts-description'][$script])) { + $description = $composer['scripts-description'][$script]; + } elseif (isset($composer['extra']['scripts-description'][$script])) { + $io->writeError('You are using "scripts-description" in "extra" which is deprecated. Move "scripts-description" to the topmost level next to "scripts" instead.'); + $description = $composer['extra']['scripts-description'][$script]; + } + $this->add(new Command\ScriptAliasCommand($script, $description)); } } From ad56577223d1a7945af7e67f8f1e25c1360cbc3d Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Mon, 18 Dec 2017 10:43:30 +0100 Subject: [PATCH 2/5] Ensure scripts description items are strings --- res/composer-schema.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/res/composer-schema.json b/res/composer-schema.json index 0ae737444..d5946f64b 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -449,7 +449,10 @@ }, "scripts-description": { "type": ["object"], - "description": "Descriptions for scripts listeners, shown in console help." + "description": "Descriptions for scripts listeners, shown in console help.", + "additionalProperties": { + "type": "string" + } }, "support": { "type": "object", From 8424235fac3ea7ceaf5f855ffed23351c21a91ca Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Mon, 18 Dec 2017 10:46:07 +0100 Subject: [PATCH 3/5] Rename to "scripts-descriptions" --- doc/articles/scripts.md | 2 +- res/composer-schema.json | 2 +- src/Composer/Console/Application.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index fda45f22d..00eae08b4 100644 --- a/doc/articles/scripts.md +++ b/doc/articles/scripts.md @@ -282,7 +282,7 @@ You can set custom script descriptions with the following in your `composer.json ```json { - "scripts-description": { + "scripts-descriptions": { "test": "Run all tests!" } } diff --git a/res/composer-schema.json b/res/composer-schema.json index d5946f64b..558f54d5c 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -447,7 +447,7 @@ } } }, - "scripts-description": { + "scripts-descriptions": { "type": ["object"], "description": "Descriptions for scripts listeners, shown in console help.", "additionalProperties": { diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 20975a10a..9e120abdf 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -230,10 +230,10 @@ class Application extends BaseApplication } else { $description = null; - if (isset($composer['scripts-description'][$script])) { - $description = $composer['scripts-description'][$script]; + if (isset($composer['scripts-descriptions'][$script])) { + $description = $composer['scripts-descriptions'][$script]; } elseif (isset($composer['extra']['scripts-description'][$script])) { - $io->writeError('You are using "scripts-description" in "extra" which is deprecated. Move "scripts-description" to the topmost level next to "scripts" instead.'); + $io->writeError('You are using "scripts-description" in "extra" which is deprecated. Use "scripts-descriptions" on the topmost level next to "scripts" instead.'); $description = $composer['extra']['scripts-description'][$script]; } From 7369aba645bed5fc1025581342d7e2b54aa468db Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Mon, 18 Dec 2017 11:39:40 +0100 Subject: [PATCH 4/5] Fix some grammar --- res/composer-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/composer-schema.json b/res/composer-schema.json index 558f54d5c..80a8312b4 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -379,7 +379,7 @@ }, "scripts": { "type": ["object"], - "description": "Scripts listeners that will be executed before/after some events.", + "description": "Script listeners that will be executed before/after some events.", "properties": { "pre-install-cmd": { "type": ["array", "string"], @@ -449,7 +449,7 @@ }, "scripts-descriptions": { "type": ["object"], - "description": "Descriptions for scripts listeners, shown in console help.", + "description": "Descriptions for custom commands, shown in console help.", "additionalProperties": { "type": "string" } From b32c7b3d16b2fa2c9b1933664df92df95ee49223 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 18 Dec 2017 13:39:20 +0100 Subject: [PATCH 5/5] Remove BC warning as this was never released --- src/Composer/Console/Application.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 9e120abdf..655b059d7 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -232,9 +232,6 @@ class Application extends BaseApplication if (isset($composer['scripts-descriptions'][$script])) { $description = $composer['scripts-descriptions'][$script]; - } elseif (isset($composer['extra']['scripts-description'][$script])) { - $io->writeError('You are using "scripts-description" in "extra" which is deprecated. Use "scripts-descriptions" on the topmost level next to "scripts" instead.'); - $description = $composer['extra']['scripts-description'][$script]; } $this->add(new Command\ScriptAliasCommand($script, $description));