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

node-nmconfig

v1.2.2

Published

Reconfig based Namshi style config files helper

Downloads

43

Readme

nmConfig

Build Status

Handy and strongly opinionated config helper on top of reconfig.

So what about it?

Here in Namshi we like our configuration: incremental, overridable, and defined in a compact way. As well as we like to don't go nuts when we clone a project repo for the 1st time. This is why we came up with tools like reconfig and file-ensure. With nmConfig we put all this things together in a convenient lib that turns all of this in a matter of a require() instruction.

What does it do:

  • Automatically creates a config/ directory and the needed files if they are not present:
config/
     |- base.yml
     |- dev.example.yml
     |- staging.yml
     |- live.yml
  • Compiles your config files, figures out your environment and applies the needed merging on the base.yml one:

#base.yml
characters:
  yoda: jedi
  anakin: jedi
  obiWan: jedi

#dev.yml
characters:
  anakin: sith

will result in:

{
  characters: {
    yoda: 'jedi',
    anakin: 'sith',
    obiWan: 'jedi'
  }
}

You can eventually define configuration paths in your app's package.json too, using your app's name as key, and they'll be added to the final configuration:


// Put something like this in your package.json

{
  "name": "myConfigurableApp",
  "version": "0.0.1",
  "description": "I can configure apps",
  "myConfigurableApp": {
    "characters": {
      "benSolo": "sith"
    }
  }

// and you'll obtain:

{
  characters: {
    yoda: 'jedi',
    anakin: 'sith',
    obiWan: 'jedi',
    benSolo: 'sith'
  }
}
  • returns you a reconfig instance:
console.log(config.get('characters.anakin'));

// ==> 'sith'
  • Figures out a reconfig's env overrider prefix from your package.json:
//pacakage.json
{
  "name": "myApp",
  "version": "0.1.0",
  "description": "this is my app, there are many like it, but this one is mine!"
// [...]
}

will yield a MYAPP_CONFIG env prefix for reconfig (check this section on reconfig's doc for more infos on what this does)

  • Ensure you've a dev.yml on your dev machine, or eventually creates one from dev.example.yml

Options Params:

Options parameters:

  • baseFiles: A list of files creating the base configuration before applying the environment specific config. These files will be merged in order, the env file will be the last applied.

  • separator: The separator Reconfig will use for console vars overlays.

  • projectName: Defines Your project's name. If none is given, the project's name will be inferred form your package.json "name" value. All spaces will be removed.

  • prefix: The prefix that Reconfig will use while grabbing console variable and applying overlays.

  • ensure: Tells to nmConfig to check for the existence of .yml file. If a .example.yml is found, it will be used to produce the ensured file.

  • env: Forced value for the environment: by default nmConfig will read you env form: - PROJECTNAME_ENV - NODE_ENV - or default to "dev"

NOTE: If you want to output the value of your system configuration on loading your config then you can set an option in your environment config file with a value of verboseConfig: true at the top level. If this is set then the config will be printed to STDOUT.

Installation

Install this library via NPM:

npm install node-nmconfig

Usage

var config = require('node-nmconfig')();

// or

var config = require('node-nmconfig')({ /* options */ });

If you need it on the client side we highly recommend browserify.

Tests

This library is a little convenience wrapper on top of extensively tested projects, so for once we can be a little bit lazy and skip them ;) We do like tests tho, so if you feel giving us a hand we'll be more than happy to see some PR love on this side :D