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 🙏

© 2021 – Pkg Stats / Ryan Hefner

rock

v0.4.0

Published

Generate and scaffold file structures or project skeletons from templates.

Downloads

119

Readme

Node.js - rock

Rock generates file structures or project skeletons based off of predefined templates.

Why?

Do you constantly finding yourself writing a lot of new libraries for Node.js and having to create the package.json, README, LICENSE, lib/, test/ files over and over again? Well, I did. I was getting annoyed of having to create the same file structure over and over again.

I stumbled upon a few solutions, but they all seem to do more than just generate a file structure from a template. That's all I wanted. Oh, and I wanted it to be programmatic too. So, if I wanted to build a blogging engine or another Rails clone in JS, I could leverage rock to generate the empty templates.

As it stands now, rock is written in Node.js. But the actual templates themselves could be for any language.

Installation

You will need Node.js and npm (Node.js Package Manager). This is bundled with Node.js. If you don't have npm, mozy on over to the Node.js download page. There are prebuilt binaries and installers for most platforms including Mac OS X, Windows, and Linux.

After you have installed Node.js and npm, you can install rock by running the following command:

npm install -g rock

Don't forget the -g flag. This will ensure that the rock command is available system wide.

Usage

rock [path] -r [rock]

example:

rock mylib -r node-lib

or

rock /tmp/mylib -r node-lib

Options

   --version              Print version and exit.
   -r ROCK, --rock ROCK   The rock path or Github repo.
   -c, --config           The config file. Defaults to ~/.rock/rock.conf.json
   -f, --file             If the rock is a single file. Supports http as well.  [false]
   --topen                Opening template value. Defaults to {{  [{{]
   --tclose               Closing template value. Defaults to }}  [}}]

Want to create a project from a rock hosted somewhere else? No problem:

rock myapp -r [email protected]:johndoe/myrepo.git

or use Github shorthand:

rock myapp -r johndoe/myrepo

Make Your Own Rocks

It's stupidly simple to make your own rocks. Create a Git repository on Github or an empty directory on your filesystem. Start making template files.

Example (myproject.js):

/*
   Author: {{author}} <{{email}}>
   File: {{-file}}
   Created: {{-date}}
*/

function main() {

}

Now, when you run:

rock myproj -r /path/to/my/rock/repo

Rock will prompt:

author: [YOU_TYPE_YOUR_NAME_HERE]
email: [YOU_TYPE_YOUR_EMAIL_HERE]

Rock, then will create the file structure of your new project with the values of your template tokens replaced with what you typed. Rock already understands -file, -date, and a few others.

Ignore Directories

In your rock repo, add a file .rock/rock.json. Add the following:

{
    "ignoreDirs": ["./dirToIgnore"]
}

Why would you do this? Let's say that you're calling rock programmatically and you don't want rock to prompt you for any tokens because you are going to use Mustache/Hogan/Handlebars in your own code.

Open / Close Templates

If you don't want to use the default {{ and }} and want to use something else, you can configure this behavior for your Rock in .rock/rock.json:

{
  "tokens": {
    "open": "#{",
    "close": "}"
  }
}

You may want to do this if you generate files that actually use Mustache templates.

Single File Rocks

Rock doesn't need to be used with just whole repos. It can be used with individual files as well.

Example:

http://localhost/data.txt:

Hi, @@[email protected]@ is going to build:
@@[email protected]@.

command:

rock /tmp/outputfile.txt -f --topen '@@' --tclose '@@' -r http://localhost/data.txt

prompts:

author: JP
project-name: Rock

output:

/tmp/outputfile.txt:

Hi, JP is going to build:
Rock

rock.conf.json

This file defaults to ~/.rock/rock.conf.json. You can set default values (prompt or skip).

{
  "templateValues": {
    "author": "JP Richardson"
  },
  "defaultValues": {
    "email": "[email protected]"
  }
}

So, if you were to run:

rock myapp -r rocktemplates/node-bin

it would not prompt you for author and it would prompt you for email but with a default of [email protected].

Rocks

See more rocks at: https://github.com/rocktemplates or browse 3rd party Rocks here: https://github.com/rocktemplates/rock/wiki/rocks

Roadmap to v1.0.0

  • Will probably change configuration from JSON to TOML. TOML needs to achieve stability first.
  • Create/fork site similar to component.io

Contributors

License

(The MIT License)

Copyright (c) 2012-2013, JP Richardson