An easy to use npm package that lets you write and run command line scripts in a yaml format. You can define which commands run in series and which commands run in parallel.
It let you load scripts to be used again and also creates a log file for each run for tracking.
npm i -g yamlscript
You have to write the commands in a yaml format as a list of dictionaries, where the value of a key named c
(required) of each dictionary is the command, value of a key named title
(optional) is the title of the command, and the value of a key named next
(optional) is the next set of commands that will be excuted after the command finishes.
Example of the yaml script file
- c : mkdir <somefolder>
title : Making a directory named <somefolder>
- c : git clone https://github.com/<someuser>/<someNodeRepo>.git <somename>
title : Cloning a node repo in a folder named <somename>
next :
- c : cd <somename> && npm install
title : Installing node dependencies
next:
- c : cd <somename> && mkdir <dummyname>
title : Making a directory named <dummyname>
next :
- c : cd <somename> && git remote set-url origin <someurl>
title : Changing the remote of the node repo
next :
- c : touch <file.txt>
title : Creating <file.txt>
- c : cd <somename> && git add . && git commit -m 'initial commit' && git push
title : Commit and push
- c : cd <somename>/<dummyname> && touch <someotherfile>
title : Creating a file named <someotherfile>
- c : cd <somename> && mkdir <anotherdummyname>
title : Making a directory named <anotherdummyname>
next:
- c : cp package.json <somename>/<anotherdummyname>/<myfile>
title : Copying a package.json into <myfile>
- c : cd <somename> && touch <somefile>
title : Making a file named <somefile>
- c : git clone https://github.com/<someuser>/<somePhpRepo>.git <someothername>
next:
- c : cd <someothername> && composer install
next :
- c : cd <someothername> && cp .env.example .env
next :
- c : cd <someothername> && php artisan migrate
- c : cd <someothername> && mkdir <somefolder>
- c : cd <someothername> && touch <somefile>
The commands will be executed in the following order
Creates an initial yaml script under the name of script.yaml, or a script with the commands if provided.
Example: yamlscript make
or yamlscript make "git clone <myrepourl>" "mkdir folder"
Validates the script first then loads the script to be used later, it will be loaded under the alias name if provided if not it will be loaded under the script file name.
Example: yamlscript load script.yaml
or yamlscript load script.yaml myscript
Run an already loaded script, or a quick run without the script being loaded by typing the path of the script.
Example: yamlscript run myscript
or yamlscript run ./script.yaml
Display an already loaded script.
Example: yamlscript display myscript
or yamlscript d myscript
Validate that a script in a correct Yaml format without loading it.
Example: yamlscript validate script.yaml
or yamlscript val script.yaml
Remove an already loaded script.
Example: yamlscript remove myscript
or yamlscript rm myscript
List all the loaded scripts.
Example: yamlscript list
or yamlscript ls
Contributions are always welcome!