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

config-update-tool

v0.1.5

Published

Command line tool for keeping configuration file up to date with templates

Downloads

7

Readme

Config Update Tool

Are you familiar with the situation when you have a configuration file template under VCS and you have to manually update its instance on a remote host each time you deploy any changes to the template (mostly add new config properties)?

Pretty annoying, isn't it?

So this command line tool could help you update your config files fast and handy. I hope.

Please, consider that it's just an MVP yet. I'm working on improvements (see GitHub Issues if interested).

Installation and usage

Prerequisites: Node.js (>=8).

Sorry, but this is it for now. I'm planning to add v6 compatibility.

Available formats

The tool can:

  • read .js and .json files;
  • write .js and .json files.

I'm going to add .yml and .xml support.

Using as a stand-alone tool

Install the tool globally (or locally without -g flag) by running

npm install -g config-update-tool

Then use cupd --help (it's like config update, aye?) or full config-update-tool --help to output the manual.

You can also clone the repo and then use npm run help to do the same.

You should see the following:

Usage: config-update-tool [--mode <mode>] [--input <path>] [--output <path>] 
[--backup] [--force]

Options:
  --help        Show help                                              [boolean]
  --version     Show version number                                    [boolean]
  -m, --mode    Usage mode: `create` for new config file and `merge` for
                modifying existing one                           [default: null]
  -i, --input   Path to the input file                  [string] [default: null]
  -o, --output  Path to the output file                 [string] [default: null]
  -b, --backup  Make a backup of the output file       [boolean] [default: null]
  --no-b        Don't make a backup of the output file
  -f, --force   Tool won't ask for user prompt and use template values
                                                       [boolean] [default: null]
  --no-f        Tool will ask for user prompt

All arguments are optional, you will be asked to enter missing ones in interactive mode anyway.

Mode

There are two usage modes for now: create and merge.

In the create mode the tool takes config template form the given input file and asks for config property values in interactive mode, then writes the data to the output file.

In the merge mode (my favorite one) the tool takes template's and existing config's data, then asks for missing properties only, removes redundant properties and overwrites output file (optionally it can create a backup file).

Using as a dependency

You can install the tool as a dependency to your project (probably a dev-dependency):

npm install config-update-tool --save-dev

And then just run it from your code like that:

const ConfigTool = require('config-update-tool');

ConfigTool.run([options])
  .catch(e => console.error(e));

You can pass all or some of the following options as options object properties:

  • mode - work mode (create or merge)
  • inputFile - absolute or relative to cwd path to the input config template file
  • outputFile - absolute or relative to cwd path to the config output file
  • backupRequired - if true, tool will make attempt to create a backup copy of the output file
  • isForce - if true, tool will take template values and won't ask for user prompt

These options will NOT be overwritten by command line arguments.