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

figger

v3.2.4

Published

process application configuration files

Downloads

50

Readme

figger

Figger is a Node.js package to process configuration files. It can be used as a module within a Node.js project, and can also be used from the command-line to pre-compute a set of configurations and to optionally export 'env' files.

Configuration Format

The configuration format is pretty basic. The file can contain any number of comments, includes, or assignments. Anything else is ignored.

# set some default values
app-name    = My Application
app-secret  = hDaUIJv7zJNFztDz4c5f5z2K6FRSSUCS
app-welcome = ${app-name} says "welcome"

# load system base config
. /etc/my-app/app.conf

# load system config directory
. /etc/my-app/conf.d/*.conf
. /etc/my-app/conf.d/**/*.conf

# load additional config from local path
. local.conf

Note: this config is an example demonstrating some of the features of figger;
this note is ignored by figger because it does not contain any valid includes,
assignments, or comments.

Identifiers

Configuration identifiers can contain alpha-numeric characters or any of the following special characters: . _ - : @ $ !

Whitespace

Whitespace is ignored except when encountered inside a value.

Values

Configuration values can contain any literal character except newline. Leading and trailing whitespace is ignored, but internal whitespace is preserved. Quotes are OK, but a matched pair of leading and trailing quotes is ignored. Inside matched quotes, the escape sequences \n and \\ are available, which evaluate to a newline and a literal backslash, respectively. Leading and trailing space inside matched quotes are also preserved.

References

Configuration values can reference previously set values by including the referenced identifier surrounded by ${ ident }. So, ${app} would resolve to the value of the app identifier.

Silent Failure

Any figger input that is not recognized is marked as an error and ignored. This helps with generating polyglots or for providing contextual documentation.

Comments

Comments begin with a hash "#" and continue to the end of the line. Comments can appear on their own, or after an assignment.

Includes

Includes work a bit like bash. The include begins with a dot ".", followed by the path to the included file or files. The include path can be an absolute path, a path relative to the file which includes it, or a glob pattern.

Globbed include paths which match more than one file are loaded in unspecified order. You must take care to avoid configurations which might cause some kind of inconsistent result.

Module Use

To use figger as a module, pass the main configuration file to the figger function, and wait for the resulting Promise to resolve. The function also accepts an initial configuration object, which is useful for setting defaults or for chaining multiple configurations.

const figger = require("figger");
const join = require("path").join;

// load a single config file
figger("path/to/file.conf").then(config => {
    // config loaded
});

// load config with defaults
figger("path/to/file.conf", {port: 3456}).then(config => {
    // config loaded
});

// chain several configs
figger("first.conf")
    .then(conf => figger("second.conf", conf))
    .then(conf => {
        // configs loaded
    });

Command-line Use

The figger package includes a command-line tool, also called figger, which can be used to pre-process figger configs. It can optionally generate output in a format compatible with 'env' files or with bash.

# pre-process app.conf and generate single config file in settings.conf
figger app.conf > settings.conf

# generate .env file from app.conf
figger --envify app.conf > .env

# import result into bash shell
source <(figger --bashify app.conf)