Start multiple projects using 1 command(npm start).

Adem Aytac 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago
projects 57b719fa2c keeping projects folder for the multiple projects 1 year ago
.gitignore 57b719fa2c keeping projects folder for the multiple projects 1 year ago
README.md 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago
general-stuff.js 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago
index.js 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago
package-lock.json 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago
package.json 9ba24c98ad readme added and version bumped to 1.1.0 1 year ago

README.md

start-multiple-projects

This project will start multiple other projects in the same terminal, with different colors. And watch on all the projects for changes.

Install

npm install

Configure your own projects

  1. Fork the project
  2. update the index.js
  3. run start function from general-stuff.js

Little documentation on how to use the start function

  1. Declare an apps array, each object has to have those fields.

    {
    option: number, // mandatory, hex or binary converted to decimal (1, 2, 4, 8, 16, ...)
    name: string, // mandatory, name of the project
    enable: boolean, // mandatory, check if the project has to run
    color: string, // mandatory, color to display in terminal for this project
    custom: string, // mandatory if startFile is not provided, custom script to run, instead of nodemon to watch the current project
    startFile: string, // mandatory if custom is not provided, location to the start file of the project
    options: any, // optional, is used only when startFile is used, this is used to passed to project as argument
    otherfields: any, // optional, you can declare other fields to use in your commands
    }
    

    There is a COLORS enum inside the general-stuff.js file.

    const { COLORS } = require('./general-stuff');
    // Those colors can be used.
    COLORS.black
    COLORS.red
    COLORS.green
    COLORS.yellow
    COLORS.blue
    COLORS.magenta
    COLORS.cyan
    COLORS.white
    COLORS.gray
    COLORS.close
    
  2. Declare your common commands to run on all projects(with startFile property provided)

    1. This need to be an array with strings, which will be concatenated
    2. you can use the properties of the project objects here as well, by using {{propertyName}}
    3. all the strings inside this array will be concatenated witg &&

eg.

[
  'echo "hello world"', // first command
  'cd ~/projects/{{name}}' // cd to the project folder of the current project in the list, name property is used here, but you can also declare your own properties
]
  1. Pass the apps and commands [and optionValue] to the start function, and the projects will start in the same terminal ;)
const { start } = require('./general-stuff')
...
start(apps, command);

yargs package is also installed as a dependency, you can use that for example to enable or disable from the command line and pass it to the start function as the third parameter. For an example, you can see the index.js file.

const { argv } = require('yargs');
const value = parseInt(argv.option, 10);
...
start(apps, command, value);