composer plugin for a better frontend setup

Overview

License Packagist Version Tests

node-composer

composer plugin for a better frontend setup

PHP projects mostly are Web-Applications. Many Web-Applications also need a frontend part which runs in the browser. In modern Web-Development there often a whole build-chain connected to the frontend, so you can compile e.g. your scss, build your JavaScript with webpack and optimize your images.

This plugin provides a way to automatically download and installthe right version of node.js, npm and yarn. The binaries are linked to the bin-directory specified in your composer.json.

After that your can use node, npm and yarn in your composer-scripts.

Setup

The setup is pretty easy. Simply install the plugin in specify the node-version in your composer.json extra configs.

Example composer.json

{
    "name": "my/project",
    "type": "project",
    "license": "MIT",
    "authors": [
        {
            "name": "Marius Büscher",
            "email": "[email protected]"
        }
    ],
    "require": {
        "mariusbuescher/node-composer": "*"
    },
    "extra": {
        "mariusbuescher": {
            "node-composer": {
                "node-version": "4.8.3",
                "yarn-version": "0.22.0"
            }
        }
    }
}

Configuration

There are three parameters you can configure: The node version (node-version), the yarn version (yarn-version) and the download url template for the node.js binary archives (node-download-url).

In the node download url the following parameters are replaced:

  • version: ${version}
  • type of your os: ${osType}
  • system architecture: ${architecture}
  • file format ${format}

Example composer.json:

{
    // ...
    "extra": {
        "mariusbuescher": {
            "node-composer": {
                "node-version": "6.11.0",
                "yarn-version": "0.24.5",
                "node-download-url": "https://nodejs.org/dist/v${version}/node-v${version}-${osType}-${architecture}.${format}"
            }
        }
    }
}
Comments
  • Automatic package versioning based on NodeJS releases

    Automatic package versioning based on NodeJS releases

    This is unusual pull request, but I really would like that this would be included in the project, because this will add a possibility to use node-composer with such tools like Dependabot.

    This pull request adds a GitHub Action that runs every 24 hours and checks if new NodeJS version is released. If so, it will release new version for node-composer with similar version number like NodeJS. For example if GitHub Action detects if there was a new NodeJS 14.15.1 released it automatically releases node-composer with v14.15.1-1 tag.

    If node-composer is included in other PHP project and than newer NodeJS 14.15.2 is released. Such tools like Dependabot will notify project owner about possible upgrade. If owner accepts this change, newer NodeJS version also for that project will be installed.

    So basically this change adds possibility easier to upgrade to newer NodeJS when is possible.

    This is how these automatically releases looks on GitHub: image

    There is one possible issue with this pull request. Master branch should not contain any dev code. Because every 24 hours automatic release will be generated. But from what I see, I don't think that could happen very often for this repo.

    I really hope this change will be included. For me that would be very useful thing and I think for many others too.

    opened by MekDrop 2
  • Bump minimal PHP version to 7.1

    Bump minimal PHP version to 7.1

    It seems that ZipArchiver on Windows with PHP 7.0 can't extract correctly node archives, so I bumped minimal required PHP version in composer.json to 7.1

    opened by MekDrop 0
  • Lowercase architecture mapping

    Lowercase architecture mapping

    It seems that some GitHub machines returns architecture in uppercase, but on my localhost I see only lowercase variants, so change makes sure that mapping allways works as architecture value is in lowercase.

    opened by MekDrop 0
  • Adds amd64 and i586 architectures to ArchitectureMap

    Adds amd64 and i586 architectures to ArchitectureMap

    After running CI tests I found out that amd64 and i586 values are needed to be added into ArchitectureMap file, because some GitHub machines returns these values instead of x64 or x86. So, here is the fix.

    opened by MekDrop 0
  • Added GitHub action to test code on each pull request

    Added GitHub action to test code on each pull request

    After merging this every time after somebody creates pull request to the repository new Github Action called 'Tests' stars thats will test if new changes will work good enough with PHP 7.1-7.4, Composer 1-2, windows/ubuntu/macos (right now only works X86/X64 architectures).

    And this is an example how these tests could look in GitHub: image

    opened by MekDrop 0
  • Added composer.json description and newer symfony proccess versions can be used

    Added composer.json description and newer symfony proccess versions can be used

    description field in composer.json if type is not library is required. So I added.

    Also, from now it's possible to use this little composer-plugin in projects with never symfony process versions.

    opened by MekDrop 0
  • Fix Process.php expected type

    Fix Process.php expected type

    symfony/process in 3.x and below expects a string, but in 4.x and up expects an array. This will fix anyone using 4 and up, and should be split out into a different base version.

    This fix should be tagged in a 2.x version

    fixes #16

    opened by kyletaylored 0
  • Symfony Process.php construct() must be of the type array, string given

    Symfony Process.php construct() must be of the type array, string given

    This seems to be broken when using Composer 2.3, but the underlying issue is the Symfony Process 5.4 library that expects an array, while this package is using the 2.x version.

    https://github.com/symfony/process/blob/5.4/Process.php#L143

    In Process.php line 143:
    
      [TypeError]
      Argument 1 passed to Symfony\Component\Process\Process::__construct() must be of the type array, string given, called in /project/vendor/mariusbuescher/node-composer/src/Installer/NodeInstaller.php on line 84
    
    
    Exception trace:
      at phar:///opt/homebrew/Cellar/composer/2.3.2/bin/composer/vendor/symfony/process/Process.php:143
    
    opened by kyletaylored 3
  • If specific packages are found in project installation, gets versions from yarn and nodejs from these packages config

    If specific packages are found in project installation, gets versions from yarn and nodejs from these packages config

    Similar to #14 but instead of having multiple version conflicts, correct nodejs and yarn versions are detected from imponeer/composer-nodejs-installer and imponeer/composer-yarn-installer package data. So, if any of these packages are installed in project, config values will be overwritten from these packages data.

    F.e., if project has such composer.json:

    {
      "name": "dummy/dummy",
      "description": "Dummy project to test if configuration works",
      "type": "project",
      "require": {
        "mariusbuescher/node-composer": "@dev",
        "imponeer/composer-nodejs-installer": "1.0.0"
      }
    }
    

    Node 1.0.0 will be installed

    or if project has such composer.json:

    {
      "name": "dummy/dummy",
      "description": "Dummy project to test if configuration works",
      "type": "project",
      "require": {
        "mariusbuescher/node-composer": "@dev",
        "imponeer/composer-nodejs-installer": "1.0.0",
        "imponeer/composer-yarn-installer": "1.0.0",
      }
    }
    

    Node 1.0.0 and yarn 1.0.0 will be installed

    or if project has such composer.json:

    {
      "name": "dummy/dummy",
      "description": "Dummy project to test if configuration works",
      "type": "project",
      "require": {
        "mariusbuescher/node-composer": "@dev",
        "imponeer/composer-yarn-installer": "1.0.0",
      }
    }
    

    Latest nodejs and yarn 1.0.0 version will be installed

    or if such composer.json:

    {
      "name": "dummy/dummy",
      "description": "Dummy project to test if configuration works",
      "type": "project",
      "require": {
        "mariusbuescher/node-composer": "@dev",
        "imponeer/composer-yarn-installer": "1.0.0",
      },
      "extra": {
            "mariusbuescher": {
                "node-composer": {
                    "node-version": "6.11.0"            
                }
            }
        }
    }
    

    Yarn 1.0.0 and node 6.11.0 will be installed

    However if both ways are defined, data from packages (not extras will take a priority). So, that's means that such composer.json config:

    {
      "name": "dummy/dummy",
      "description": "Dummy project to test if configuration works",
      "type": "project",
      "require": {
        "mariusbuescher/node-composer": "@dev",
        "imponeer/composer-yarn-installer": "1.0.0",
      },
      "extra": {
            "mariusbuescher": {
                "node-composer": {
                    "yarn-version": "0.11.0" 
                    "node-version": "6.11.0" 
                }
            }
        }
    }
    

    This would install yarn 1.0.0 and node 6.11.0

    Of cource it will be possible to use composer version constraints for such new functionality. So, it would be easier to update package nodejs versions.

    Yeah, I know this is a bit hardcoded that is not very good practice but I think this would be maybe a bit better way to solve this problem than #14 and this doesn't required to solve a big problem how to handle multiple installed nodejs and yarn versions. What do you think?

    opened by MekDrop 5
  • Adds possibility to define config not only in project extras but also in dependencies

    Adds possibility to define config not only in project extras but also in dependencies

    This will let to define config not only in project level but also in also in dependencies.

    If there are multiple dependencies, with different node or yarn versions, max versions will be selected (yeah I, know, that would be awesome to have multiple nodejs and/or yarn versions installed, but I think this requires some huge changes... so at least something for now...)

    Project level config definitions takes priority. That means if these are found, all configs in dependencies will be ignored.

    Accepting this change let others to create libraries that depends on node-composer that could be used in projects. For example, a package that automatically bumps owen version everytime new nodejs is released (similar thing that I tried to achieve with #2 pull request). Or some package that automatically tries to deal with front-end npm assets management.

    Note: #10 must be merged first to make sure that all platform tests succeeds.

    opened by MekDrop 1
  • Adds release drafter GitHub action

    Adds release drafter GitHub action

    Release drafter is amazing GitHub Action to easy maintan changes list between releases - You don't need anymore to walk between all pull requests and see what changed. The list will be generated automatically!

    This pull request adds this amazing tool. I think it could save many your free time when you are doing releases.

    opened by MekDrop 0
  • Project future

    Project future

    I created issue from comment on my pull request:

    Sorry, it is still early though. I like your idea, but I am not sure if I will continue to maintain this project. Actually this hasn't been touched in years. If you are interested, you can continue maintaining it.

    Originally posted by @mariusbuescher in https://github.com/mariusbuescher/node-composer/pull/2#issuecomment-719373183

    opened by MekDrop 3
Releases(v1.2.2)
Owner
Marius Büscher
Marius Büscher
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
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
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
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
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
Cbe frontauth - A Textpattern plugin to manage backend connections from frontend and protect content from non-logged users

cbe_frontauth This client-side plugin lets your users (or you) manage backend connection from frontend, i.e. connect and disconnect as they (you) woul

null 4 Jan 31, 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
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
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
Better Version of Cvolton's GMDprivateServer

BetterCvoltonGDPS Better Version of Cvolton's GMDprivateServer Supported version of Geometry Dash: 1.0 - 2.11 (so any version of Geometry Dash works,

foxodever 17 Nov 20, 2022
Run the following commands in your terminal to setup the project

Run the following commands in your terminal to setup the project You must have the LAMP installed on your system git clone https://github.com/Bashar-A

null 1 Nov 6, 2021
We go for better world

Nasa-Space-Apps-Challenge-2021 We go for better world Team: Dynamo Warrior Team Member Mazharul Hasan Fozilatunnesa Mestu Paul Nayeem Hossain Belal Ud

Mazharul Hasan 7 Dec 10, 2021
This is a setup for a Tor based shared web hosting server

General Information: This is a setup for a Tor based shared hosting server. It is provided as is and before putting it into production you should make

Daniel Winzen 312 Dec 24, 2022
Production ready scalable Magento setup utilizing the docker

Magento docker image Requirements This docker image expects 2 other linked containers to work . Mysqldb or Mariadb linked as 'db' Memcached linked as

Paim pozhil 49 Jun 21, 2021
Magento 2 SEO extension will do perfectly for your better SEO.

Magento 2 SEO extension will do perfectly for your better SEO. This is a bundle of outstanding features that are auto-active when you install it from Mageplaza without any code modifications. It is also friendly with your store if you need to insert meta keywords and meta descriptions for your product.

Mageplaza 121 Oct 28, 2022
Magento 2 Blog Extension is a better blog extension for Magento 2 platform. These include all useful features of Wordpress CMS

Magento 2 Blog extension FREE Magento 2 Better Blog by Mageplaza is integrated right into the Magento backend so you can manage your blog and your e-c

Mageplaza 113 Dec 14, 2022