This package includes below features:
- Command for showing each env status, whether it is using for testing or available for using.
- Commands for easing arc diff and arc land.
- Command for identifying whether a source branch can be merged into a target branch.
Recommended git flow as below:
-
Install
npm install --save-dev env-status -
Create
.envstatus.jsfile in your project root as below.module.exports = { envs: ['production', 'staging', 'dev', 'dev1', 'dev2', 'dev3'], url: function (env) { return `https://raw.githubusercontent.com/juicecube/env-status/master/envs/${env}.json`; }, gen: 'dist/env-status.json' };
envsis an array of the name of all the envs. (required)urlis a function returning the json file described next part. (required)genthe env status file output path.
-
Everytime you publish your project, publish a json file contains blow information.
{ "branch": "master", "commit": "17f53ca090d44fd89f805425dee8f21a801a967d", "author": "webyom <[email protected]>", "date": 1561874837800 }branchis the branch you checkout when you publish your project.commitis the the HEAD commit hash when you publish your project.authoris the HEAD commit author when you publish your project.dateis the timestamp when you publish your project.
-
env-status
env-statuswill show all the env statusenv-status stagingwill show staging and production (if defined) statusenv-status --initwill create.envstatus.jsconfig file in your project root.env-status --genwill generate the json file for publishing. -
merge-validate
Validate whether a source branch can be merged into target branch.
merge-validate <srouce-branch> <target-branch> -
env-build-validate
Validate whether a branch can be built in current environment.
env-build-validate
-
getLastCommit(now: Date): object
Return the last commit information of current branch as below.
{ branch: 'master', commit: '197b0c4', author: 'webyom', date: 1562055960000 }
-
getBranchName(): string
Return current working branch name.
-
getBranchType(branch: string): string
Return branch type, refer to
BRANCH_TYPESfor full possible value list. -
fetchEnvData(env: string): Promise<object>
Return the last commit information of current branch as below.
{ env: 'production', version: '1.1.0', branch: 'master', commit: '17f53ca090d44fd89f805425dee8f21a801a967d', author: 'webyom <[email protected]>', date: 1561874837800 }
or
{ env: 'production', err: 'CONFIG_UNDEFINED' // refer to FETCH_ERR for full possible value list }
-
isEnvAvailable(env: string): Promise<bool>
Return a promise of bool, telling whether an env available.
-
FETCH_ERR
{ CONFIG_UNDEFINED: 'CONFIG_UNDEFINED', URL_FUNCTION_UNDEFINED: 'URL_FUNCTION_UNDEFINED', LOAD_ERROR: 'LOAD_ERROR', PARSE_RESPONSE_ERROR: 'PARSE_RESPONSE_ERROR' }
-
BRANCH_TYPES
{ SPRINT: 'SPRINT', // sprint/xxx SPRINT_FEATURE: 'SPRINT_FEATURE', // feat/xxx SPRINT_FIX: 'SPRINT_FIX', // fix/xxx HOTFIX: 'HOTFIX', // hotfix/xxx MASTER: 'MASTER', // master OTHERS: 'OTHERS' }



