yoanm/composer-config-manager

This package is abandoned and no longer maintained. No replacement package was suggested.

command line to manage composer configuration file

2.1.1 2017-05-04 10:49 UTC

This package is auto-updated.

Last update: 2022-02-21 19:24:41 UTC


README

Scrutinizer Build Status Scrutinizer Code Quality Code Coverage

Travis Build Status PHP Versions

Latest Stable Version

Command to manage composer configuration file

Install

composer global require yoanm/composer-config-manager

Add the following in your .bashrc file :

export PATH=~/.composer/vendor/bin:$PATH 

How to

just type the following

composercm create "vendor/package-name" path/to/repository/directory [OPTIONS]
composercm update path/to/repository/directory [OPTIONS]

In case you launch the command from the repository directory, you can simply use

composercm create "vendor/package-name" [OPTIONS]
composercm update [OPTIONS]
  • Type composercm list to list all available command
  • Type composercm help COMMAND_NAME or composercm COMMAND_NAME -h to display help for a specific command

See below for more information regarding command line options

  • composercm update command will take the current composer.json file and will applied given values

Create

  • A --template option is available, given values will be applied to the template
  • Values are appended in a default order

Update

  • A --template option is available, see below how templates are managed
  • Key order are kept from old configuration file. New one are appended in a default order

Templates

  • Multiple template could be provided. Update workflow is the following
    • 1 - Templates between them If more than one template is given,

      • the first first one is updated with values from the second one
      • resulting configuration is updated with third template

      ...

      • resulting configuration is updated with X template
    • 2 - Resulting configuration with existing one

      • For update command only, in case at least a template was given
    • 3 - Resulting configuration with command line values

      • Could by skipped if only templates are used

Key order

  • By default key order as the one defined in composer documentation website
  • It's possible to use the --template option to define key order of final configuration     For instance, defined a template file name key_order.json with following content :  
{
  "name": null,
  "type": null,
  "license": null,
  "version": null,
  "description": null,
  "keywords": [],
  "authors": {},
  "provide": {},
  "suggest": {},
  "support": {},
  "autoload": {},
  "autoload-dev": {},
  "require": {},
  "require-dev": {},
  "scripts": {}
}

  Then use the following command :

composercm [create|update] [ARGS] [OPTIONS] --template key_order.json

Resulting file will have keys ordered like in key_order.json file. All keys could be added in key_order.json, in case no value is given for a key, key will not appear in final file.

  In case you also want to provide a template with default value, use the following:

composercm [create|update] [ARGS] [OPTIONS] --template key_order.json --template default_values.json [--template another.json]

Managed properties

Following properties could be defined with option from command line :

  • Package name
  • Package type
  • License
  • Version
  • Description
  • Keywords Many allowed
  • Author Many allowed
  • Provided packages Many allowed
  • Suggested packages Many allowed
  • Support Many allowed
  • PSR-0 / PSR-4 Autoload Many allowed
  • PSR-0 / PSR-4 Autoload dev Many allowed
  • Required packages Many allowed
  • Required dev packages Many allowed
  • Scripts

All others properties could ever be defined in templates and will be managed in a default way (could produce unexpected merge for complex nested values)

Full composer configuration

{
  "name": "vendor/package-name",
  "type": "library",
  "license": "LICENSE_TYPE",
  "version": "X.Y.Z",
  "description": "package description",
  "keywords": ["KEYWORD1", "KEYWORD2"],
  "authors": [
    {
      "name": "name1",
      "email": "email1",
      "role": "role1"
    },
    {
      "name": "name2",
      "email": "email2",
      "role": "role2"
    }
  ],
  "provide": {
    "package1": "~x.y",
    "package2": "x.y.z",
  },
  "suggest": {
    "package1": "Description 1",
    "package2": "Description 2",
  },
  "support": {
    "type1": "url1"
  },
  "autoload": {
    "psr-0": {
      "\\RootNamespace\\SubNamespace": "path"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "\\RootNamespace\\SubNamespace\\": "path"
    }
  },
  "require": {
    "requirement1": ">=x.y"
  },
  "require-dev": {
    "requirement1": ">=x.y"
  },
  "scripts": {
    "script-1": [
      "command_1",
      "command_2"
    ],
    "script-2": [
      "command_1",
      "command_2"
    ],
  }
}

Contributing

See contributing note