Scripts-dev directive for composer

Overview

scriptsdev for Composer Build Status

It's like require-dev, but for scripts

Installation

Just run composer require neronmoon/scriptsdev --dev

Usage

After installing you able to add extra.scripts-dev directive in your composer.json

...
"extra": {
    "scripts-dev": {
        "post-install-cmd": [
            "npm install --dev"
        ],
        "post-update-cmd": "php ./someCoolCommand.php",
        "test": "phpunit"
    },
}
...

Deprecated Usage

...
"scripts-dev": {
    "post-install-cmd": [
        "npm install --dev"
    ],
    "post-update-cmd": "php ./someCoolCommand.php"
}
...

Known issues

  • Usage of this plugin will cause minor warning of validation process. composer validate command will display something like this.
./composer.json is valid, but with a few warnings
See https://getcomposer.org/doc/04-schema.md for details on the schema
Description for non-existent script "test" found in "scripts-descriptions"
Comments
  • Tag a release

    Tag a release

    This composer plugin is very useful and works well, but we need a stable version to manage this package properly in composer

    Can you publish a release please?

    opened by benatespina 6
  • PHP Fatal error:  Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() on Composer2 and this package 0.1.8

    PHP Fatal error: Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() on Composer2 and this package 0.1.8

    Hi! i've found some bug

    Composer2 snapshot and composer 2.0.4 at least

    Installing neronmoon/scriptsdev (v0.1.8): Extracting archive PHP Fatal error: Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in vendor/neronmoon/scriptsdev/src/Plugin.php:26

    Full stack trace

    Installing neronmoon/scriptsdev (v0.1.8): Extracting archive
    PHP Fatal error:  Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in my_project/vendor/neronmoon/scriptsdev/src/Plugin.php:26
    
    Full stack trace:
    #0 phar:///....composer.phar/src/Composer/Plugin/PluginManager.php(319): ScriptsDev\Plugin->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
    #1 phar:///.../composer.phar/src/Composer/Plugin/PluginManager.php(223): Composer\Plugin\PluginManager->addPlugin(Object(ScriptsDev\Plugin), false)
    #2 phar:///.../composer.phar/src/Composer/Installer/PluginInstaller.php(76): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage), true)
    #3 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}(NULL)
    #4 phar:///.../composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func(Object(Closure), NULL)
    #5 phar:///.../composer.phar/vendor/react/promise/src in my_project/vendor/neronmoon/scriptsdev/src/Plugin.php on line 26
    
    Fatal error: Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in my_project/vendor/neronmoon/scriptsdev/src/Plugin.php:26
    Stack trace:
    #0 phar:///.../composer.phar/src/Composer/Plugin/PluginManager.php(319): ScriptsDev\Plugin->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
    #1 phar:///.../composer.phar/src/Composer/Plugin/PluginManager.php(223): Composer\Plugin\PluginManager->addPlugin(Object(ScriptsDev\Plugin), false)
    #2 phar:///.../composer.phar/src/Composer/Installer/PluginInstaller.php(76): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage), true)
    #3 [internal function]: Composer\Installer\PluginInstaller->Composer\Installer\{closure}(NULL)
    #4 phar:///.../composer.phar/vendor/react/promise/src/React/Promise/FulfilledPromise.php(20): call_user_func(Object(Closure), NULL)
    #5 phar:///.../composer.phar/vendor/react/promise/src in my_project/vendor/neronmoon/scriptsdev/src/Plugin.php on line 26
    
    opened by hanovruslan 3
  • Add support for Composer 2

    Add support for Composer 2

    Before this PR we couldn't install scriptsdev with Composer 2:

    $ ./composer.phar --version
    Composer version 2.0.0-alpha2 2020-06-24 21:36:18
    $ ./composer.phar require neronmoon/scriptsdev --dev
                                                                                                                                              
      [InvalidArgumentException]                                                                                                              
      Package neronmoon/scriptsdev at version  has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version  
                                                                                                                                              
    

    Closes #18

    opened by villfa 3
  • Composer 2.0 support

    Composer 2.0 support

    Hey,

    I'm relieved to see this repository is still getting some attention. I've been using this package for a couple of years now and enjoying it's functionality each day.

    This opened issue is merely as a bit of a heads up and a place for other users of this package to check support/progress :)

    Are you planning on integrating support for composer 2.0 which is expected to be released somewhere in June?

    I just ran composer update after updating to composer 2 and was greeted with the following: neronmoon/scriptsdev v0.1.6 requires composer-plugin-api ^1.0 -> found composer-plugin-api[2.0.0] but it does not match the constraint.

    Background info: https://github.com/composer/composer/blob/master/CHANGELOG.md https://github.com/composer/composer/blob/master/UPGRADE-2.0.md

    Regards, Levi

    opened by Levivb 1
  • Fix TypeError with recent version of Composer

    Fix TypeError with recent version of Composer

    This PR fixes the following error that I got with composer 1.10.1:

    PHP Fatal error:  Uncaught TypeError: Return value of "ScriptsDev\DevScriptProxyCommand::execute()" must be of the type int, "NULL" returned. in /.../vendor/symfony/console/Command/Command.php:258
    Stack trace:
    #0 /.../vendor/symfony/console/Application.php(912): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #1 /.../vendor/symfony/console/Application.php(264): Symfony\Component\Console\Application->doRunCommand(Object(ScriptsDev\DevScriptProxyCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
    #2 /.../vendor/composer/composer/src/Composer/Console/Application.php(281): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Comp in /.../vendor/symfony/console/Command/Command.php on line 258
    

    See also: https://github.com/symfony/console/blob/5fa1caadc8cdaa17bcfb25219f3b53fe294a9935/Command/Command.php#L255-L259

    opened by villfa 1
  • Protect plugin against undefined method errors

    Protect plugin against undefined method errors

    This package is causing PHP fatal errors when running composer validate if the composer.json being validated has a branch alias:

    $ composer --ansi validate composer.json
    Fatal error: Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code:26
    Stack trace:
    #0 /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(236): ScriptsDev\Plugin_composer_tmp2->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
    #1 /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(ScriptsDev\Plugin_composer_tmp2))
    #2 /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(261): Composer\Plugin\PluginManager->registerPackage(Object(Composer\Package\CompletePackage))
    #3 /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(76): Composer\Plugin\PluginManager->loadRepository(Object(Composer\Repository\InstalledFilesystemRepository))
    #4 /var/www in /var/www/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(195) : eval()'d code on line 26
    

    This PR probably involves the most simplistic "solution" possible. But if it's naive, it should at least prevent fatal errors.

    opened by TravisCarden 1
  • Extracting archivePHP Fatal error at version 0.1.4

    Extracting archivePHP Fatal error at version 0.1.4

    composer version 1.8.4 and some prior to this one

    stack trace

     - Installing neronmoon/scriptsdev (v0.1.4): Loading from cache
     Extracting archivePHP Fatal error:  Uncaught TypeError: Argument 1 passed to ScriptsDev\PackageScriptsExtractor::extract() must be an instance of Composer\Package\Package, instance of Composer\Package\RootAliasPackage given, called in ... vendor/neronmoon/scriptsdev/src/Plugin.php on line 24 and defined in ... vendor/neronmoon/scriptsdev/src/PackageScriptsExtractor.php:29
    Stack trace:
    #0 vendor/neronmoon/scriptsdev/src/Plugin.php(24): ScriptsDev\PackageScriptsExtractor->extract(Object(Composer\Package\RootAliasPackage))
    #1 composer.phar/src/Composer/Plugin/PluginManager.php(236): ScriptsDev\Plugin->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
    #2 composer.phar/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(ScriptsDev\Plugin))
    #3 composer.phar/src/Compo in vendor/neronmoon/scriptsdev/src/PackageScriptsExtractor.php on line 29
    
    Fatal error: Uncaught TypeError: Argument 1 passed to ScriptsDev\PackageScriptsExtractor::extract() must be an instance of Composer\Package\Package, instance of Composer\Package\RootAliasPackage given, called in vendor/neronmoon/scriptsdev/src/Plugin.php on line 24 and defined in vendor/neronmoon/scriptsdev/src/PackageScriptsExtractor.php:29
    Stack trace:
    #0 vendor/neronmoon/scriptsdev/src/Plugin.php(24): ScriptsDev\PackageScriptsExtractor->extract(Object(Composer\Package\RootAliasPackage))
    #1 composer.phar/src/Composer/Plugin/PluginManager.php(236): ScriptsDev\Plugin->activate(Object(Composer\Composer), Object(Composer\IO\ConsoleIO))
    #2 composer.phar/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin(Object(ScriptsDev\Plugin))
    #3 composer.phar/src/Compo in vendor/neronmoon/scriptsdev/src/PackageScriptsExtractor.php on line 29
    
    

    version 0.1.3 is OK

    also updating from 0.1.3 to 0.1.4 is OK

    opened by hanovruslan 1
  • [Question] Support scripts-descriptions

    [Question] Support scripts-descriptions

    Hi! Thanks again for this very useful composer plugin!

    But i have an other one question (problem?): Lately composer got nice feature "scripts-descriptions" but i found that composer validate fires warning on scripts related to dev env

    {
        "extra": {
            "branch-alias": {
                "dev-master": "1.0-dev"
            },
            "scripts-dev": {
                "dev-script": [
                    "@composer update --no-scripts nothing",
                    "@composer check-platform-reqs",
                    "@composer validate --strict"
                ]
            }
        },
        "scripts-descriptions": {
            "dev-script": "Do dev stuff"
        }
    }
    

    and i wonder does this behavior depends on scriptdev plugin only or not not at all ? Or partly ?

    opened by hanovruslan 1
  • [Question] short syntax for scrtiptdev commands

    [Question] short syntax for scrtiptdev commands

    Hi! Is it possible to add short syntax support for composer scriptdev commands? For now it looks like this

    composer --dev run-script my-script-dev-command
    

    and short syntax is

    composer --dev my-script-dev-command
    

    non-dev (basically composer scripts) available just like short syntax above so it will be more usefull to add short syntax for dev scripts

    honestly i dont know composer that well to find out where this support suppose to be added. Maybe in composer plugins. If so let me know. Thanks!

    opened by hanovruslan 1
  • Feature request: moving the scripts-dev section into extra

    Feature request: moving the scripts-dev section into extra

    Please consider moving the scripts-dev section into extra to avoid $ composer validate complaining it is not defined and the definition does not allow additional properties.

    $ composer validate
    ./composer.json is valid for simple usage with composer but has
    strict errors that make it unable to be published as a package:
    See https://getcomposer.org/doc/04-schema.md for details on the schema
    The property scripts-dev is not defined and the definition does not allow additional properties
    

    Besides, phpstorm also flags the scripts-dev section as an error.

    opened by TangRufus 1
  • Fix Call to undefined method Composer\Package\RootAliasPackage::setScripts()

    Fix Call to undefined method Composer\Package\RootAliasPackage::setScripts()

    I have split this PR in 2 commits on purpose:

    the first one shows how to reproduce the undefined method error. By running the testsuite you'll get:

      - Installing neronmoon/scriptsdev (dev-fix-setscripts): Symlinking from /home/.../scriptsdev
    PHP Fatal error:  Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in /home/.../scriptsdev/src/Plugin.php:27
    Stack trace:
    #0 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(236): ScriptsDev\Plugin->activate()
    #1 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin()
    #2 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/PluginInstaller.php(62): Composer\Plugin\PluginManager->registerPackage()
    #3 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(173): Composer\Installer\PluginInstaller->install()
    #4 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(160): Composer\Installer\InstallationManager->install()
    #5 /home/.../scriptsdev/vendor/comp in /home/.../scriptsdev/src/Plugin.php on line 27
    Traceback (most recent call last):
      File "tests/tests.py", line 64, in <module>
        check('SCRIPTSDEV RULEZ', test('extra-with-branch-alias', ['composer', 'update']))
      File "tests/tests.py", line 34, in check
        raise Exception('EXPECTED\n"%s"\nBUT FOUND\n"%s"' % (expect, actual))
    Exception: EXPECTED
    "SCRIPTSDEV RULEZ"
    BUT FOUND
    "string(33) "Composer\Package\RootAliasPackage"
    
    Fatal error: Uncaught Error: Call to undefined method Composer\Package\RootAliasPackage::setScripts() in /home/.../scriptsdev/src/Plugin.php:27
    Stack trace:
    #0 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(236): ScriptsDev\Plugin->activate()
    #1 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Plugin/PluginManager.php(205): Composer\Plugin\PluginManager->addPlugin()
    #2 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/PluginInstaller.php(62): Composer\Plugin\PluginManager->registerPackage()
    #3 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(173): Composer\Installer\PluginInstaller->install()
    #4 /home/.../scriptsdev/vendor/composer/composer/src/Composer/Installer/InstallationManager.php(160): Composer\Installer\InstallationManager->install()
    #5 /home/.../scriptsdev/vendor/comp in /home/.../scriptsdev/src/Plugin.php on line 27
    "
    
    opened by villfa 0
  • Work for satisfy recent Composer versions and a couple of features

    Work for satisfy recent Composer versions and a couple of features

    In Composer versions before composer/composer@599ad77167bc8cee895f024a20292689fd84153f the RootPackageInterface only defines a sub-set of operations needed by neronmoon/scriptsdev and RootAliasPackage only implemented those methods defined by the interface. Most of the unimplemented methods in RootAliasPackage can be worked around because the getter methods that are implemented proxy to the aliased package which we can modify by unwrapping.

    opened by ghost 2
Releases(v0.1.9)
Owner
Vitaliy Krasnoperov
DevOps at day, game developer at night
Vitaliy Krasnoperov
A tidy conditional Blade directive for checking if something is in an array

A tidy conditional Blade directive for checking if something is in an array. This package provides a small @in directive that allows you to simplify i

Ryan Chandler 0 Oct 7, 2022
A composer plugin, to install differenty types of composer packages in custom directories outside the default composer default installation path which is in the vendor folder.

composer-custom-directory-installer A composer plugin, to install differenty types of composer packages in custom directories outside the default comp

Mina Nabil Sami 136 Dec 30, 2022
Composer plugin replacing placeholders in the scripts section by dynamic values

Composer Substitution Plugin The Composer Substitution plugin replaces placeholders in the scripts section by dynamic values. It also permits to cache

Fabien Villepinte 49 Jan 8, 2022
One-file composer scripts

Melody - One-file composer scripts Create a file named test.php: <?php <<<CONFIG packages: - "symfony/finder: ~2.8" CONFIG; $finder = Symfony\Com

SensioLabs 399 Aug 18, 2022
This repository contains research materials and dev notes for the DSM research

DSM Research This repository contains a loosely-organized information regarding the processes of DSM loading. A lot of information present here was co

DSM 11 Jun 28, 2021
Wp-to-txp - @WordPress to @Textpattern dev guide

WordPress to Textpattern dev guide Helping poor WP devs to find their track… Contents Themes development Plugins development Related Awesome Textpatte

Nicolas Morand 2 Jan 10, 2020
I am actively working on this - v1.3 stable-DEV

Batch-OBF-php This Obf .bat files v swag ngl only reason im posting the code is cuz i people have said im ratting them by changing the code of the .ba

INZO_Technologies 1 Jan 26, 2022
Il était une fois un dev est une plateforme proposant une nouvelle expérience d'apprentissage

Il était une fois un dev - Domaine métier Présentation Il était une fois un dev est une plateforme proposant une nouvelle expérience d'apprentissage.

Incentive factory 7 Sep 21, 2022
Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

Stef Dawson 8 Oct 3, 2020
Magento-composer-installer - Composer installer for Magento modules

!!! support the maintainer of this project via Patreon: https://www.patreon.com/Flyingmana Magento Composer Installer The purpose of this project is t

null 213 Sep 24, 2022
Composer Repository Manager for selling Magento 2 extension and offering composer installation for ordered packages.

Magento 2 Composer Repository Credits We got inspired by https://github.com/Genmato. Composer Repository for Magento 2 This extension works as a Magen

EAdesign 18 Dec 16, 2021
Composer registry manager that help to easily switch to the composer repository you want

CRM - Composer Registry Manager Composer Registry Manager can help you easily and quickly switch between different composer repositories. 简体中文 Install

Tao 500 Dec 29, 2022
Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.

Imposter Plugin Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins. Built with ♥ by Typ

Typist Tech 127 Dec 17, 2022
Dependency graph visualization for composer.json (PHP + Composer)

clue/graph-composer Graph visualization for your project's composer.json and its dependencies: Table of contents Usage graph-composer show graph-compo

Christian Lück 797 Jan 5, 2023
Composer Registrar Composer Plugin for Magento 2

This module add a global registration.php that replace the default glob search performed for each request to discover the components not installed from composer.

OpenGento 3 Mar 22, 2022
Drupal Composer Scaffold - A flexible Composer project scaffold builder

This project provides a composer plugin for placing scaffold files (like index.php, update.php, …) from the drupal/core project into their desired location inside the web root. Only individual files may be scaffolded with this plugin.

Drupal 44 Sep 22, 2022
Victor The Cleaner for Composer - This tool removes unnecessary files and directories from Composer vendor directory.

Victor The Cleaner for Composer This tool removes unnecessary files and directories from Composer vendor directory. The Cleaner leaves only directorie

David Grudl 133 Oct 26, 2022
Opinionated version of Wikimedia composer-merge-plugin to work in pair with Bamarni composer-bin-plugin.

Composer Inheritance Plugin Opinionated version of Wikimedia composer-merge-plugin to work in pair with bamarni/composer-bin-plugin. Usage If you are

Théo FIDRY 25 Dec 2, 2022
Block malicious scripts using botscout.com protection for your laravel app

Laravel BotScout Protect your website against automated scripts using the botscout.com API. Installation You can install the package via composer: com

Nicolas Beauvais 64 Jul 30, 2022