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

module-butler

v1.0.3

Published

A CLI that takes in module names and outputs a folder for each module name.

Downloads

3

Readme

module-butler

A CLI that takes in module names and outputs a folder for each module name.

oclif Version Downloads/week License

Table of Contents

Geting started

  1. Install module-butler within your project or globally or use it with npx directly.
yarn add -D module-butler

or

npm install -D module-butler

or

npx module-butler init
  1. Set up module-butler by running:
module-butler init

or

npx module-butler init
  1. Makes changes in .module-butler/config.js
  2. Make changes to any template in .module-butler/templates/.
  3. Add your GraphQL fragments in .module-butler/inpug.graphql. (See example)
  4. Generate your modules by running:
module-butler generate

or

npx module-butler generate

Example

The following example used the templates that come out-of-the-box when running module-butler init.

Input

// .module-butler/input.graphql
Hello,
World

// Tip: add all your modules to generate all modules at the same time.

Outputs

modules/ is the default output directory. You can change it by changing outputDirectory in .module-butler/config.js.

// modules/Hello/index.js
console.log('module name:', 'Hello');
// modules/World/index.js
console.log('module name:', 'World');

Tips

Add a script in package.json

It is recommended to add a script in package.json, that runs module-butler generate and any other script, like prettier. For example:

{
  "scripts": {
    "module-butler": "module-butler generate && relay-compiler && prettier --write modules/"
  }
}

Then you can just run npm run module-butler or yarn module-butler.

Adding/removing/customizing templates

By default, running module-butler init, provides you with a default index.js template and you can change it any way you want. You can then, for example, create a utils.ts template for your utility functions. You can even change the file name of the template, like adding the module name, {{name}}, or changing the file extension to .ts instead of .js.

Templates

Templates in .module-butler/templates/ use handlebars as the templating language.

  • Both the file name and file content are templatable, and have access to the same handlebars context.
  • You can refer to .module-butler/templateAPI.ts for the full handlebars context.
  • You can add or remove templates
  • The handlebars file extension of templates (i.e. .hbs) is removed when generating your modules, but you are free to remove it from the template itself. The .hbs extension is only used for code editors, like VS Code, to recognize that its a handlebars file and give you syntax highlighting for that.

Usage

$ npm install -g module-butler
$ module-butler COMMAND
running command...
$ module-butler (-v|--version|version)
module-butler/1.0.3 darwin-x64 node-v14.17.1
$ module-butler --help [COMMAND]
USAGE
  $ module-butler COMMAND
...

Commands

module-butler generate [MODULE1] [MODULE2] [MODULE3] [MODULE4] [MODULE5] [MODULE6] [MODULE7] [MODULE8] [MODULE9] [MODULE10]

generates modules using module names (comma and/or line separated) in .module-butler/input and template files in the templates directory.

USAGE
  $ module-butler generate [MODULE1] [MODULE2] [MODULE3] [MODULE4] [MODULE5] [MODULE6] [MODULE7] [MODULE8] [MODULE9] 
  [MODULE10]

ARGUMENTS
  MODULE1   Name of module
  MODULE2   Name of module
  MODULE3   Name of module
  MODULE4   Name of module
  MODULE5   Name of module
  MODULE6   Name of module
  MODULE7   Name of module
  MODULE8   Name of module
  MODULE9   Name of module
  MODULE10  Name of module

OPTIONS
  -F, --force  forcibly overwrite existing files
  -h, --help   show help for generate command

See code: src/commands/generate.ts

module-butler help [COMMAND]

display help for module-butler

USAGE
  $ module-butler help [COMMAND]

ARGUMENTS
  COMMAND  command to show help for

OPTIONS
  --all  see all commands in CLI

See code: @oclif/plugin-help

module-butler init

sets up module-butler by creating config.js, templates/*.hbs files, input in .module-butler/ directory.

USAGE
  $ module-butler init

OPTIONS
  -h, --help  show help for init command

See code: src/commands/init.ts