npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

progene

v1.0.0

Published

Customize and reuse parametrizable commands across projects.

Downloads

5

Readme

Progene

Customize and reuse parametrizable Node.js commands accessible from terminal across software projects.

NPM

Index

  1. Installation
  2. Usage
  3. Commands
  4. How it works
  5. API
  6. Issues
  7. License
  8. Collaboration

Installation

$ npm i --g progene

Usage

To see the help of a command, run progene or any of its commands with the --help flag.

Explanation

  1. you write your own Node.js commands (separated by a namespace).

  2. you start progene in any project you are developing.

  3. you add your created progene command namespaces.

  4. you run any of the commands you have coded before, comfortably from your fresh project.

Commands

[...]: optional parameters.

<...>: required parameters.

progene init [directory]
progene add <namespace-path> [options]
progene run <namespace/command> [options]
progene remove <namespace> [options]

Initialize progene

$ progene init .

Write commands

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") + "!");
};

Add commands

$ progene add commands/namespace

Run commands

$ 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!

How it works

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.

Workflow

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: a module.exports = function(options) {...} file.
  • path/to/commands/namespace/command-2.js: a module.exports = function(options) {...} file.
  • path/to/commands/namespace/command-3.js: a module.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.

API

You can also use the programmatic API.

Usage

The API module works almost the same way that the command-line interface, but passing objects to every method, instead.

1. Import module

const Progene = require("progene");

2. Use the commands as static methods

To initialize a project:
Progene.init();

Or, alternatively, specify the directory:

Progene.init({
  base: __dirname + "/my/project" // 'base' is by default: process.cwd()
});
To add commands to the project:
Progene.add({ 
  command: "/path/of/commands/namespace",
  base: __dirname + "/my/project" // 'base' is by default: process.cwd()
});
To run a command:
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.

To remove a command:
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.

Issues

Expose any issue here.

Visit open issues here.

License

This is a project under WTFL, which means basically that you can do whatever you want with it.

Collaboration

Feel free to create your own branches.