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

@bb-tools/withenv

v0.2.1

Published

An environment variable loader for your monorepo.

Downloads

198

Readme

@bb-tools/withenv

This projects aims to simplify loading of environment variables with dotenv in a monorepo.

It consists of 2 parts:

  • A withenv command which we use to call dotenv before running commands.
  • A loadEnv function which you can reuse in any TS/JS code.

See the Configuration section for details about the .env.yaml file or continue reading for usage instructions.

Installation

npm install @bb-tools/withenv

Usage

withenv

Usage:

withenv <env> -- [command...]

Example:

withenv test -- jest

loadEnv

Usage:

import { loadEnv } from "withenv";

// Loads the environment into process.env
await loadEnv("test");

Configuration

Most of the magic behind withenv is a .env.yaml file whose goal is to define execution environments in a declarative way.

Example:

dev:
  nodeEnv: development
  files:
    - .env.dev

In this file, an environment named dev is declared.

As you might have guessed, when used with the dev environment, withenv will:

  • Set the NODE_ENV environment variable value to development.

  • Load non-sensitive environment variables from the .env.dev dotenv file located alongside the .env.yaml file.

  • Load local overrides and secrets from the .env.dev.local dotenv file.

Environment options

The properties described in the table below can be used for each environment defined in the .env.yaml file.

| Name | Description | Required | Default value | | --------- | ------------------------------------------------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------- | | nodeEnv | The value of NODE_ENV to use | NO | Environment name if it exists in the NodeEnv enum of @kwentapay/node-utils package. | | files | List of .env files to be loaded. | YES | | | alias | An optional alias to name the environment (e.g. development instead of dev) | NO | |

Local overrides

Local files can be defined for both the dotenv and withenv:

  • <environment_file>.local (e.g. .env.local) to define local environment variables.

  • .env.local.yaml to add new environments or override the existing ones.
    i.e.: This is where your personal secrets can be placed.

These files must be ignored by Git (documentation). For example, you can add the following lines to your .gitignore file:

*.local
*.local.yaml

More information

See: