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

@multitool-js/configmanager

v1.1.3

Published

ConfigManager allows to easily manage application configurations.

Downloads

33

Readme

Multitool JS / Config Manager

ConfigManager allows to easily manage application configurations.

The configManager tool reads the following configuration files (in the given order) and merges the configurations:

  • default.json - Default configurations.
  • production.json - Production configurations, enabled only with NODE_ENV = production.
  • development.json - Development configurations, enabled only with NODE_ENV != production.
  • local.json - Local configurations.
  • custom-environment-variables.json - Env variables overrides, loads the value of the environment variable as the config value.
    E.g. { "varaible": "ENV_VARIABLE_NAME" }.
    Additionally the env variable name can be prefixed with the following terms to forcefully cast/parse the value:
    • JSON: parses the value, if the value is not parsable the whole string is applied: { "varaible": "JSON:ENV_VARIABLE_NAME" }: | "ENV_VARIABLE_NAME" value | "varaible" value | | ------------------------- | ------------------ | | 'some_string' | "some_string" | | '{"some":"json"}' | { some: "json" } |

    • JSON_ONLY: parses the value, if the value is not parsable is ignored: { "varaible": "JSON_ONLY:ENV_VARIABLE_NAME" }: | "ENV_VARIABLE_NAME" value | "varaible" value | | ------------------------- | ------------------ | | 'some_string' | | | '{"some":"json"}' | { some: "json" } |

    • MERGE: like JSON but merges the value with current value (if present).

    • BOOLEAN: reads the strings 'true', '1', 'false', '0' and sets the corresponding boolean value.

    • NUMBER: casts the value as number. If the value is not a valid number the string is kept instead.

    • NUMBER_NAN: casts the value as number. If the value is not a valid number the property is set to NaN.

    • NUMBER_ONLY: casts the value as number. If the value is not a valid number is ignored.

How to use

const configManager = require('@multitool-js/configManager');

| method | description | | ---------- | -------------------------------------------------------------------------------- | | get | Retrives a property from the configuration. | | has | Checks if a property is defined in the configuration. | | set | Sets a property value in the configuration. | | reload | Reloads all the configuration values (loses unsaved values). | | save | Saves the configuration file (includes values set during runtime). | | saveSync | Synchronously saves the configuration file (includes values set during runtime). | | remove | Removes the currently saved configuration. | | removeSync | Synchronously removes the currently saved configuration. |

Built-in CLI

The ConfigManager tool also comes with a small CLI utility npx multitool-config to help you handle the config files: | command | description | | ------------------------------------------------- | ------------------------------------------------------------------------------------- | | init | creates "config" folder and files | | enable <config> | creates/enables <config> file | | disable <config> | disables <config> file | | remove <config> | removes <config> file | | add-property (ap) <property> | adds a new property to the config files. Asks the value for each enabled config file. | | remove-property (rp) <property> [<config file>] | removes a property from the config files. |