Customize and reuse parametrizable Node.js commands accessible from terminal across software projects.
$ npm i --g progene
To see the help of a command, run progene
or any of its commands with the --help
flag.
-
you write your own Node.js commands (separated by a namespace).
-
you start
progene
in any project you are developing. -
you add your created
progene
command namespaces. -
you run any of the commands you have coded before, comfortably from your fresh project.
[...]
: optional parameters.
<...>
: required parameters.
progene init [directory]
progene add <namespace-path> [options]
progene run <namespace/command> [options]
progene remove <namespace> [options]
$ progene init .
File: commands/namespace/progene.json
Contents:
{}
File: commands/namespace/first.js
Contents:
module.exports = function(options) {
console.log(options.one + " - " + options.two);
};
File: commands/namespace/hello.js
Contents:
module.exports = function(options) {
console.log("Hello " + (options.name || "world") + "!");
};
$ progene add commands/namespace
$ progene run namespace/first --one 1 2 3 --two a b c
It prints: 1 2 3 - a b c
$ progene run namespace/hello --name developer
It prints: Hello developer!
Progene creates a .progene
folder when you run progene init
.
Under the .progene
folder, you find the namespaces of your commands.
Under each namespace folder, you find its corresponding commands, as *.js
files.
Under each namespace folder, you also find its corresponding progene.json
metadata file.
The progene.js
only has to be a valid JSON file, nothing is required inside.
This way, one can reuse all the commands that it writes in one project, for different projects.
The idea is that you start having:
path/to/project
And, on the other hand, your commands:
-
path/to/commands/namespace/progene.json
: a valid JSON file. -
path/to/commands/namespace/command-1.js
: amodule.exports = function(options) {...}
file. -
path/to/commands/namespace/command-2.js
: amodule.exports = function(options) {...}
file. -
path/to/commands/namespace/command-3.js
: amodule.exports = function(options) {...}
file.
Then you initialize progene
:
$ cd path/to/project
$ progene init
...in order to have:
-
path/to/project/.progene
: a folder for all the currently available commands in a project.
Then you add progene
command namespaces:
progene add path/to/commands/namespace
...in order to have:
-
path/to/project/.progene/namespace
: a namespace of commands. -
path/to/project/.progene/namespace/command-1.js
: a command. -
path/to/project/.progene/namespace/command-2.js
: a command. -
path/to/project/.progene/namespace/command-3.js
: a command.
Then you run progene
commands:
$ progene run namespace/command-1 --one 1 --two 2 --three 3
$ progene run namespace/command-2 --one 1 --two 2 --three 3
$ progene run namespace/command-3 --one 1 --two 2 --three 3
This way, you can reuse your commands across projects, polluting the least your projects' workspace.
You can also use the programmatic API.
The API module works almost the same way that the command-line interface, but passing objects to every method, instead.
const Progene = require("progene");
Progene.init();
Or, alternatively, specify the directory:
Progene.init({
base: __dirname + "/my/project" // 'base' is by default: process.cwd()
});
Progene.add({
command: "/path/of/commands/namespace",
base: __dirname + "/my/project" // 'base' is by default: process.cwd()
});
Progene.add({
command: "namespace/command",
base: __dirname + "/my/project", // 'base' is by default: process.cwd()
name: "Nobody",
surname: "None",
age: 88,
place: "The World"
});
Note: what the function at /my/project/.progene/namespace/command.js
returns is what this method will return.
Progene.remove({
command: "namespace/command",
base: __dirname + "/my/project", // 'base' is by default: process.cwd()
});
All the methods are chainable because they return the Progene
class again.
All the methods are chainable, except the Progene.run({ ... })
, which returns what the specified command itself returns, letting you use your own command-line interface also as programmatic APIs.
Expose any issue here.
Visit open issues here.
This is a project under WTFL, which means basically that you can do whatever you want with it.
Feel free to create your own branches.