pjclient v1.1.7
pjclient
The Project Client is a command-line tool that is used to initialize, update and run any project.
HOW TO CONFIGURE pjconfig.json
In pjconfig.json you can create more commands and for every of it you can define different options
.
For all commands
and options
you can add sub options.
- commands: array of commands
- options: array of options
Each of it can have this attributes:
- name: used to match command or options, if it isn't present the command is every runned
- cmd: contains the command executed
- description: used to describe command or option
Which command can execute?
All terminal commands can executed directly:
- start a server,
- for example standalone.bat or standalone.sh for wildfly
- download project from repository
- for example git clone or svn co
- update project
- git pull or svn update
- push docker image
docker push <user>/<image>:<version>
- etc..
In addition you can run javascript with prefix :
and create a custom module with a plugin
.
INSTALLATION & USAGE
npm install -g pjclient
Create project configuration
To create a configuration file you can use default command init
pjclient init
at console you see
2019-06-06T16:21:12.532Z pjclient running ...
2019-06-06T16:21:12.534Z ERROR: No configuration found pjconfig.json ( use init command to create template)!!!
2019-06-06T16:21:12.534Z >>> init
The file was saved!
configuration file created by init
command:
(pjconfig.json)
{"commands":[{"name":"hello","cmd":"echo hello"}]}
If you run pjclient with "hello" command
pjclient hello
you will see
luca@enoz:~/provapjclient$ pjclient hello
2019-06-06T16:25:57.690Z pjclient running ...
2019-06-06T16:25:57.692Z >>> hello
hello
2019-06-06T16:25:57.698Z >>> fine comando!!
Define and use an environment variable
You can create an environment variable with nodejs process.env
in this way
{"cmd":":process.env.rootPath='/path/example'"},
{"cmd":"echo $rootPat"}
NOTE: in this example you create a rootPath environment-variable with /path/example value.
DEFAULT COMMANDS
init - init config file pjconfig.json
help - show help
commands
list - lista all commands
- init: create default pjconfig.json file
- commands list: show the list of commands
EXTRA COMMANDS
In addiction to default command the pjclient provides any javascript function to manage files:
- Replace text in a file
....
"cmd":":fsTools.replaceText(inputFile,stringInFile,stringToReplace);"
....
- Replace text for all files in a directory that match regex
...
"cmd":":fsTools.replaceFiles(inputDir,regex,stringInFile,stringToReplace)"
...
CREATE A PLUGIN
If you want extends pjclient with new features, you would follow this step:
1. implement a javascript module
(pluginExample.js)
// plugin example
module.exports = {
sum: function(a, b) { console.log(a + b); },
subtract: function(a,b) { console.log(a-b); },
multiply: function(a,b) { console.log(a*b); },
divide: function(a,b) { console.log(a/b); }
};
(pjconfig.json)
{
// here place commands ...
"plugins":[
{"name":"mioplugin","module":"<path>/pluginExample"}
]
}
NOTE:
<path>
is the place where module is saved.
3. use it in a command
(pjconfig.json)
"commands":[
{"name":"sum","cmd":":myPlugin.sum(1,2);"}
],
"plugins":[
{"name":"myPlugin","module":"pluginExample"}
]
NOTE: To use your plugin you must reference it with the attribute name
{"name":"myPlugin","module":"pluginExample"}
on "cmd"{"name":"sum","cmd":":myPlugin.sum(1,2);"}
License
MIT
Collaborators
- Luca Salzone luca.salzone@gmail.com
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago