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

doctor-env

v1.1.1

Published

Vital utility for describing and checking environment variables

Downloads

20

Readme

doctor-env

Vital utility for describing and checking environment variables.
Let's start describing environment variables together :two_men_holding_hands:

:point_right: The envConfig.json file with the description of variables can also be imported into your typescript code :point_left:

Installing

For the latest stable version:

npm install -g doctor-env

Usage

cd path/to/my/project
doctor-env ./mainProjectModule
# or
doctor-env ./mainProjectModule/envConfig.json

 

Config example

Files are located like this:
:file_folder: project

├─ :file_folder: nodejs
│    └─ :page_facing_up: envConfig.json

├─ :file_folder: couch_db
│    └─ :page_facing_up: envConfig.json

├─ :file_folder: postgres_db
│    └─ :page_facing_up: envConfig.json

│     outputFiles:
├─ :page_facing_up: _couchdb.env
├─ :page_facing_up: _postgres.env
└─ :page_facing_up: _my-nodejs-server.env

Main module config nodejs/envConfig.json:

{
  "module": {
    "name": "my-nodejs-server",
    "dependencies": {
      "couch": "../couch_db",
      "pg": "../postgres_db"
    },
    "comment": "There may be a description of your module with variables here. Script does not use this information."
    // C-style comments are also supported
  },
  "config": {
    "MY_MAGIC_VAR": {
      "desc": [
        "Multiline description example.",
        "British scientists have found that",
        "describing environment variables in one file",
        "is pretty damn convenient thing."
      ],
      "value": "Forced value 1.618034"
    },
    "POSTGRES_PORT": {
      "value": "5432"
    },
    "POSTGRES_PASSWORD": {
      "refTo": "pg.POSTGRES_PASSWORD"
    },
    "COUCHDB_PASSWORD": {
      "refTo": "couch.COUCHDB_PASSWORD"
    }
  }
}

Child module postgres_db/envConfig.json:

{
  "module": {
    "name": "postgres",
    "comment": [
      "PostgreSQL docker container environment description.",
      "Read more about environment variables here: https://hub.docker.com/_/postgres"
    ]
  },
  "config": {
    "POSTGRES_USER": {
      "desc": "This variable will create the specified user with superuser power and a database with the same name",
      "default": "postgres"
    },
    "POSTGRES_PASSWORD": {
      "secret": true,
      "desc": "Admin password"
    }
  }
}

Child module couch_db/envConfig.json:

{
  "module": {
    "name": "couchdb"
  },
  "config": {
    "COUCHDB_USER": {
      "desc": "Will create an admin user with the given username",
      "default": "BilboBaggins"
    },
    "COUCHDB_PASSWORD": {
      "secret": true,
      "desc": "Admin password"
    }
  }
}

Enter the missing variables

console

Output files:

:page_facing_up: _couchdb.env

COUCHDB_USER=BilboBaggins
COUCHDB_PASSWORD=mama

:page_facing_up: _postgres.env

POSTGRES_USER=postgres
POSTGRES_PASSWORD=papa

:page_facing_up: _my-nodejs-server.env

MY_MAGIC_VAR=Forced value 1.618034
POSTGRES_PORT=5432
PROJECT_NAME=Falcon_9
POSTGRES_PASSWORD=papa
COUCHDB_PASSWORD=mama

Specification of envConfig.json

module: {} block

  • "name" - Required. Module name. The output .env file name is generated from the module name as follows: _<module_name>.env. Example: module name database1, output file _database1.env.
  • "dependencies: { ... }" - Optional. List of links to related modules. Parent modules can use variable configs from child modules (description, default value). Variable values are synchronized between parent and child modules.

config: {} block

  • "desc" - Optional. Variable description, very useful if you are not psychic.

  • "default" - Optional. Default value of variable. It is used if user enters nothing (i.e. empty line "").
    :warning: Not recommended to use this field for private/secret data.

  • "value" - Optional. Forced value of variable. The user will not enter it. The value is immediately assigned to the corresponding variable.
    :warning: Not recommended to use this field for private/secret data.

  • "refTo" - Optional. The config of this variable refers to the variable from dependencies list. Template: <moduleAlias>.<externalVarName>. Example: myDatabase.DB_PASSWORD. If the variable is not found in the child module, an error will be thrown.

  • "secret" - Optional. If true - value of the variable will not be displayed on the screen when typing it from the keyboard. Also warnings will be displayed if you mistakenly set the "value" or "default" fields.

  • "optional" - Optional. If true - and if the value of the variable is empty string, this variable will not be saved in the .env file.

  • "clearBefore" - Optional. If true - value of the variable in the corresponding .env file will be CLEARED before running the check algorithm.

Priority

If "value" field is set, field "default" will be ignored.

License

MIT