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

envset

v0.9.0

Published

Set env vars before running your program

Downloads

27

Readme

envset

envset runs another program with a custom environment according to values defined in a .envset config file, which follows the ini file format. You can share this file between team members.

Inspired by daemontools' tool envdir.


Environment level configuration

Application configuration usually is environment specific and changes between build distributions.

If you follow the 12 factor app guidelines, then you know you should store your configuration in the environment.

By application configuration we mean small and oftentimes sensitive data such as API keys, database credentials. Not all environment configuration is sensitive and are instead build distribution specific values such as the application's TCP port, base URL to build OAuth callbacks, or logging verbosity.

envset helps you manage and set environment variables for multiple build distributions and share environment variables between team members.

Is as simple as calling:

envset development -- node server.js

Examples

An .envset file could look like this:

[production]
NODE_AWS_SECRET_ACCESS_KEY=FS40N0QY22p2bpciAh7wuAeHjJURgXIBQ2cGodpJD3FRjw2EyYGjyXpi73Ld8zWO
NODE_AWS_ACCESS_KEY_ID=LSLhv74Q1vH8auQKUt5pFwnix0FUl0Ml
NODE_HONEYBADGER_KEY=LCgZgqsxKfhO
NODE_POSTGRES_ENDPOINT=50.23.54.25
NODE_POSTGRES_DATABASE=myproject
NODE_POSTGRES_PSWD=Pa$sW03d
NODE_POSTGRES_USER=myproject

[development]
NODE_AWS_SECRET_ACCESS_KEY=HN5ITok3lDaA1ASHxtEpy1U9XCjZwThmfgoIYZk8bkOqc5yk6sT7AWd3ooNeRFV9
NODE_AWS_ACCESS_KEY_ID=m35W4PGGVZfj1gOxYvztFxBD5F2605B3
NODE_HONEYBADGER_KEY=f3MNPUhZoki6
NODE_POSTGRES_ENDPOINT=localhost
NODE_POSTGRES_DATABASE=postgres
NODE_POSTGRES_PSWD=postgres
NODE_POSTGRES_USER=postgres

To use it, simply prefix the call to your program with envset and the name of the environment:

$ envset development -- node app.js

You can:

[local]
MSG=Hello World
envset local -- env | grep MSG | say

Getting Started

Install the module globally with:

npm install envset -g

This will provide a CLI interface, which can be accessed via terminal:

$ envset

If you have recently installed node or npm and get an EACCES error during installation on envset look at this page about fixing permissions on npm.

Documentation

Commands

If you type envset without arguments it will display help and a list of supported environment names.

.envset file

.envsetrc

You can create an .envsetrc file with configuration options for envset.

The default .envsetrc looks like this:

;Default environment names
filename=./.envset
exportEnvironment=NODE_ENV

[environments]
names[]=test
names[]=staging
names[]=production
names[]=development

Configuration

Follows rc standards.

Post and pre installation hooks

The package.json file includes two installation live cycle scripts:

postinstall:

Executed after installation of the module. It creates a default .envsetrc config file in the user's home directory.

postuninstall:

Executed after uninstalling the module. It removes the .envsetrc file created during installation.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Release History

  • 2015-11-02: v0.2.0: Initial npm release.
  • 2015-11-21: v0.3.0: Added '--' to separate command.
  • 2015-11-23: v0.4.0: Print env if no command provided.

TODO

  • Tests
  • Programmatic interface
  • Output to stdout so that we can pipe commands

License

Copyright (c) 2015 goliatone
Licensed under the MIT license.