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

humphrey

v0.1.0

Published

> *Let Humphrey do the grunt work for you*

Downloads

1

Readme

Humphrey

Let Humphrey do the grunt work for you

Humphrey is a tool which simplifies and speeds up using Grunt. It allows you to scaffold snippets of the grunt file and add them with a single command. To maximise the resuse of these snippets Humphrey adds a bit of convention to the grunt file with a standard directory structure and lifecycle (see below).

Install Humphrey

Install humphrey globally using npm

npm install -g humphrey

The lifecycle of a Humphrey project

  • setup - Tasks that need to be run to setup the project. eg installing dependencies
  • validate - Tasks that validate the source code. eg. jshint
  • build - Tasks that process the source files, and output the final result to the app directory. eg. processing SASS files, minifying javascript
  • test - Test the build. eg. jasmine, mocha
  • package - Package the contents of the app directory. eg. create a tar, war or zip file
  • archive - Do something with the generated package eg. publish to an artifact repository
  • deploy - Deploy the app somewhere. eg. S3, github pages

Each stage in the lifecycle is available as a grunt task and each one will run all preceding lifecycle tasks first. The default grunt task is "test", running this will run - setup, validate, build and test tasks.

Preparing your project

Before running Humphrey you first need to setup package.json

npm init

Setting up your project with Humphrey

humphrey init

This will setup the Gruntfile.js and put in place the following directories structure.

  • src - Your source code lives here
  • test - Test cases live here
  • build - This is where all compilation happens
  • app - This is where the built files will end up
  • dist - This is where any packages would end up

build, app and dist directories should not be checked in to your version control system

You can now build your project

grunt build

At this stage this will simply copy the contents of the src directory to the app directory, without doing any processing.

Installing modules with Humphrey

humphrey module:install jshint

This will install the jshint module, which will get applied at the validate stage in the build.

humphrey module:install htmlmin

Now your html will be minified. This module runs during the build stage.

humphrey module:install jade

This will install the jade module, to generate html from your jade files. This module also gets applied at the build stage. Because you already have the htmlmin module running during this stage you will be prompted for where in the chain you wish to put the jade module. In this case we want it to run before htmlmin so that our html generated from the jade files will also be minified.

humphrey module:install serve

This will install the serve module. This module starts a local web server on the app directory. It watches the src directory and rebuilds the project and refreshes the browser on any changes. This module does not hook into any of the lifecycle stages, instead it adds it's own grunt task.

grunt serve

A selection of other modules are available at https://github.com/codeecho/humphrey-modules

Creating your own modules

A module consists of just 2 files

module.json

This is a simple json file containing a number of properties about your module eg.

{
	"packages": ["grunt-contrib-jshint"],
	"goal": "validate",
	"tasks": ["jshint"]
}
  • packages - An array of packages to install from npm for your module eg. ["grunt-jshint"]
  • goal - The stage in the lifecycle at which your module should apply. eg. "build". If this is set to a stage that doesn't exist a new one will be created.
  • tasks - An array of grunt tasks to call

config.js

This javascript file contains the config that you want to add to the grunt config. eg.

{
	jshint: {
		all: ["build/stage/**/*.js"]
	}
}

Managing module repositories

List repositories

humphrey modules:list-repositories

Add a local repository

humphrey modules:add-local-repository /path/to/your/repository

Add a remote repository

humphrey modules:add-remote-repository http://path/to/your/repository

Remove a local repository

humphrey modules:remove-local-repository /path/to/your/repository

Remove a remote repository

humphrey modules:remove-remote-repository http://path/to/your/repository