Skip to content

v6x/simple-staging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •