kylos/comp-manager

v2.1 2019-09-12 20:08 UTC

This package is not auto-updated.

Last update: 2024-05-03 18:54:11 UTC


README

ComposerManages is a package created to automate dev processes.

Requirements

Composer   
PHP > 7.2    

# Usage
### 1. Installation

composer require kylos/comp-manager  

### 2. In main composer.json file you need specify when and which script need to be executed.
**This system base on composer-events. If you look for more information - find all event types to use on https://getcomposer.org/doc/articles/scripts.md .

For example:
To execute script you need to provide proper path in Your composer.json scripts section.

The main method You will need to use: "Kylos\\CompManager\\ComposerScripts::methodName"
In method name need to use one of method names:

  • copy
  • move
  • settings
  • cleanUp

This methods are described well below Available scripts to use section

For example in composer.json

"scripts": {    
    "post-install-cmd": [    
      "Kylos\\CompManager\\ComposerScripts::settings",    
      "Kylos\\CompManager\\ComposerScripts::cleanUp"    
    ],    
  },    

You need to define extra property to every single command that's need to use extras for proper work.
See how in next steps...

For some commands You will need to provide additional informations in 'extras' in composer.json for proper work.

Available scripts to use

## Copy or update files Copies files from given place to another by path.

For example:

"scripts": {    
    "post-install-cmd": [    
      "Kylos\\CompManager\\ComposerScripts::copy",    
    ]    
  },    
"extra" {    
    "copy-file" : {    
      "file-path-to-copy/" : "final-file-path-to-copy/"    
    }    
}    

Move files Moves files from place to place.

For example:

"scripts": {    
    "post-install-cmd": [    
      "Kylos\\CompManager\\ComposerScripts::move",    
    ]    
  }    
"extra" {    
    "move-file": {    
          "file-path-to-move/": "file-path-moved/"    
    }    
}    

Edit settings files Edit files content By changing everything between defined tags. Usable especially for config files.

You can define every tag you want to change content between.

For example:

"scripts": {    
    "post-install-cmd": [    
      "Kylos\\CompManager\\ComposerScripts::settings",    
    ]    
  },    
"extra": {    
    "settings": {    
      ".htaccess": {    
        "destinationFile": "destination/.htaccess",    
        "pattern": "## KYLOS CUSTOM ##",  
        "position": "start"  
      }    
    },    
  }    

Explanation:

  • .htaccess is a filepath to file You want to get configuration from. With tags defined (how to exactly see below)
  • destinationFile is a filename to edit configuration or create this file if does not exists.
  • pattern set your 'pattern between'
  • position set position start and end for text to be added. If is not defined content will add content at the end of the file.

Example:

  In destination file You have to wrap your code in given pattern.  

Destination file

   ## KYLOS CUSTOM ##  
        your code  
   ## KYLOS CUSTOM ##  

Effect after installation in destination/.htaccess

SOME CODE  
THAT EXISTED BEFORE  
  
## KYLOS CUSTOM ##    
your code    
## KYLOS CUSTOM ##    

Clean up For example:

 "scripts": {       "post-install-cmd": [    
         "Kylos\\CompManager\\ComposerScripts::cleanUp",    
       ]  
 }    

Clean up package when is installed.

Files and directories that will going to be cleaned

  • .git
  • .github
  • test
  • tests
  • travis
  • demo
  • example
  • examples
  • doc
  • docs
  • license
  • changelog*
  • changes*
  • faq*
  • contributing*
  • history*
  • upgrading*',
  • upgrade*
  • package*
  • readme*
  • {,.}*.yml
  • *.md
  • *.xml
  • *.txt
  • *.dist
  • .php_cs*
  • .scrutinizer
  • .gitignore
  • .gitattributes
  • .editorconfig
  • dockerfile
  • composer.lock