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

@netlify-tools/netlify-plugin-env

v0.1.3

Published

A Netlify build plugin to set ENV variables based on the context

Downloads

8

Readme

Netlify Plugin Env

Version License

This plugin helps to have your env variables separated by deploy context in a seamless way.

Why

It is pretty common to have multiple environments to test apps rigorously before promoting changes to production. This way, the app can be delivered with more confidence.

Netlify provides a great mechanism called deploy contexts. This mechanism allow to configure as many custom deploy contexts as you want, all you need is to add a new branch to your configuration. For instance, a branch called staging will match a deploy context called staging

That's great, isn't it? However there is a little limitation for configuring environment variables per deploy context. The only way to override an env variable for a context is through netlify.toml, which means code needs to be changed and sensitive information could be exposed.

So, this plugin aims to fix that.

Note @netlify-tools/cli can help with setting env variables by context

How it works

In order for this plugin to work properly env variables names need to have the format: [VARIABLE]_[DEPLOY-CONTEXT], so the plugin will check the process.env and will set for [VARIABLE] the value of [VARIABLE]_[DEPLOY-CONTEXT] if the current deploy context and [DEPLOY-CONTEXT] matches.

For instance:

AUTH_TOKEN=supersecret
AUTH_TOKEN_STAGING=secret@

the plugin will override the AUTH_TOKEN value with the one for AUTH_TOKEN_STAGING.

AUTH_SECRET === AUTH_TOKEN_STAGING === secret@

The next table show a few examples

| Deploy Context | Branch Deploy? | Variable | Notes | | -------------- | -------------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | | production | --- | AUTH_TOKEN_PRODUCTION | predefined deploy context | | deploy-preview | --- | AUTH_TOKEN_DEPLOY_PREVIEW | predefined deploy context | | branch-deploy | --- | AUTH_TOKEN_BRANCH_DEPLOY | predefined deploy context | | --- | staging | AUTH_TOKEN_STAGING | | | --- | feature/login | AUTH_TOKEN_FEATURE_LOGIN | | | deploy-preview | staging | AUTH_TOKEN_DEPLOY_PREVIEW_STAGING | allow combination between predefined deploy context and branch deploys. This is great for preview having different configuration per preview |

Usage

Add the plugin

Install it via npm

npm install --save-dev @netlify-tools/netlify-plugin-env

Install it via yarn

yarn add --dev @netlify-tools/netlify-plugin-env

Add a [[plugins]] entry to your netlify.toml file:

[[plugins]]
package = '@netlify-tools/netlify-plugin-env'