util.env
Manages environment type and versioning for a project.
Last updated 7 months ago by jmquigley .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install util.env 
SYNC missed versions from official npm registry.

util.env

Manages environment type and version strings for a project.

build analysis code style: prettier testing NPM coverage

This module contains helper functions for interacting with the runtime environment for an application to determine they type of environment. The application that uses this script will have three types of environments:

  • Development
  • Test
  • Production

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as an application dependency:

$ yarn add --dev util.env

To build the app and run all tests:

$ yarn run all

Usage

This module is generally used during the build process under CI to identify the type of build being performed. The mode is determined in one of two ways.

  1. NODE_ENV environment variable set to development, test, or production.
  2. A command line option

The command line arguments passed to the build used to determine the type are:

  • --development
  • --testing
  • --production

API

It exposes the following functions that can be used within the build:

  • getBranch() - retrieves the git branch name for this package for that mode
  • getMode() - gets the current mode string (development, test, production)
  • getVersion() - gets the version string associate with this mode
  • isDevelopment() - the '--development' flag was passed.
  • isTesting() - the '--testing' flag was passed
  • isProduction() - the '--production' flag was passed
  • show() - prints debug information to the console.

The use of this module also exposes the getVersion function. When this function is called it will determine the type and build the corresponding version string. When the environment is development or testing the string is:

{branch}_r{revision count}-b{build number}

Where branch is the name of the branch where this build is occuring. In development this is usually the develop branch. When it is the testing environment it is usually the master. The revision count is computed from git. It counts the number of revisions associated with that branch. The build number is retrieved from the environment. In Jenkins this is an environment variable set to $BUILD_NUMBER. This script assumes Jenkins.

When the environment is production the string uses semver.

{major}.{minor}.{revision count}

The major and minor versions are retrieved from package.json. The revision count is computed from git (the same as testing/development).

Current Tags

  • 0.0.33                                ...           latest (7 months ago)

31 Versions

  • 0.0.33                                ...           7 months ago
  • 0.0.32                                ...           7 months ago
  • 0.0.31                                ...           7 months ago
  • 0.0.30                                ...           8 months ago
  • 0.0.29                                ...           9 months ago
  • 0.0.28                                ...           9 months ago
  • 0.0.27                                ...           a year ago
  • 0.0.26                                ...           a year ago
  • 0.0.25                                ...           2 years ago
  • 0.0.24                                ...           2 years ago
  • 0.0.23                                ...           2 years ago
  • 0.0.22                                ...           2 years ago
  • 0.0.21                                ...           2 years ago
  • 0.0.20                                ...           2 years ago
  • 0.0.19                                ...           2 years ago
  • 0.0.18                                ...           2 years ago
  • 0.0.17                                ...           2 years ago
  • 0.0.16                                ...           2 years ago
  • 0.0.15                                ...           2 years ago
  • 0.0.14                                ...           2 years ago
  • 0.0.13                                ...           2 years ago
  • 0.0.12                                ...           2 years ago
  • 0.0.11                                ...           2 years ago
  • 0.0.10                                ...           3 years ago
  • 0.0.9                                ...           3 years ago
  • 0.0.8                                ...           3 years ago
  • 0.0.7                                ...           3 years ago
  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 62
Last Day 0
Last Week 62
Last Month 4
Dependencies (4)
Dev Dependencies (23)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |