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

simple-staging

v0.0.15

Published

Simple staging helper

Downloads

33

Readme

Simple staging

Simple module to define current staging level in project.

Motivation

This is a simple module to parse current staging value from environment variables or your code like this to achieve software release life cycle more easily.

Usage

As default, it would read a staging value from process.env.STAGE value and give it as an enum value with some simple flags such as inhouse and real to check if it is inhouse stage.

import { envDefault as currentStage } from 'simple-staging';

if (currentStage.flags.inhouse) {
  // Some codes for inhouse environment.
}

if (currentStage.flags.real) {
  // Some codes for real environment.
}

The case of React

In react, it doesn't use process.env.STAGE easily because there is no env in react environment. But the useful plugin captures environment variables that starts with REACT_APP_ prefix so we can use process.env.REACT_APP_STAGE instead of STAGE.

Default flags

| Flags | Levels | nodejs env | React env | | --------------- | -------------------------------------------------------------------------- | ---------------------- | -------------------------------- | | flags.inhouse | Test, Local, Alpha | STAGE_INHOUSE_LEVELS | REACT_APP_STAGE_INHOUSE_LEVELS | | flags.real | Beta, Demo1, Demo2, Demo3, ..., Experimental, UserTest RC, Release, Hotfix | STAGE_REAL_LEVELS | REACT_APP_STAGE_REAL_LEVELS | | flags.debug | Test, Local, Alpha, Beta | STAGE_DEBUG_LEVELS | REACT_APP_STAGE_DEBUG_LEVELS |

More flags

If you want to define more flags such as verbose, you can parse your staging flags with your custom attributes via $stage parser.

import { $stage, StagingLevel } from 'simple-staging';

const currentStage = $stage(process.env.STAGE, {
  attributes: {
    verbose: [StagingLevel.LOCAL, StagingLevel.ALPHA],
  },
});

if (currentStage.flags.verbose) {
  // Some codes for verbose environment.
}

Staging level

It has simple 39 levels.

enum StagingLevel {
  Test = 'test',
  Local = 'local',
  Alpha = 'alpha',
  Experimental = 'experimental',
  UserTest = 'usertest',
  Beta = 'beta',
  Demo1 = 'demo1',
  Demo2 = 'demo2',
  Demo3 = 'demo3',
  ...,
  Demo30 = 'demo30',
  RC = 'rc',
  Release = 'release',
  Hotfix = 'hotfix',
}

License

MIT