0.0.12 • Published 2 years ago

simple-staging v0.0.12

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

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

FlagsLevelsnodejs envReact env
flags.inhouseTest, Local, AlphaSTAGE_INHOUSE_LEVELSREACT_APP_STAGE_INHOUSE_LEVELS
flags.realBeta, Demo1, Demo2, Demo3, ..., Experimental, UserTest RC, Release, HotfixSTAGE_REAL_LEVELSREACT_APP_STAGE_REAL_LEVELS
flags.debugTest, Local, Alpha, BetaSTAGE_DEBUG_LEVELSREACT_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

0.0.11

2 years ago

0.0.12

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago