Library to manage environment variables and stages.
yarn add node-stage@poviolabs/node-stage#v2
# update
yarn up node-stage@poviolabs/node-stage#v2
stages:
myapp-dev: # one stage per deploy
moduleName:
variableKey: variableValue
## dotenv overrides
# envFiles: [ '.env.myapp-dev.secrets' ]
## environment overrides
# environment:
# app__spaDeploy__s3__bucket: myapp-dev-website
import { loadConfig } from "node-stage";
const config = await loadConfig("/path/to/config.yaml", process.env.STAGE);
Root from where to fetch config.yaml
and the base for all relative paths.
The slug of the deployment (ie. myapp-prd/mystage-stg/mystage-dev). This is the base of the config set in conifg.yaml
.
Release of the build (ie the git sha) and is unique per code. Autodetected from most CI services or Git.
Release is the id that services like Docker and Sentry will use to identify the build. Most of the time this is independent of the stage, but in some cases, we have a separate build per stage.
- gitsha - (default) make the same build for all stages
- gitsha-stage - make a build based on the stage and git sha in cases where the build is different per stage
If the stage has multiple services, you can define the one you want to deploy here.
Example configuration
stages:
myapp-prd: &myapp-prd
yaml_local_override: correct
myapp-prd-worker:
<<: *myapp-prd
stage: myapp-prd
CONFIG_PREFIX=app CONFIG_FILE=config.yaml
Fetches the variable at the specified path and returns it.
Example:
node-stage env var moduleName.variableKey
Set up ./test/secrets.env
with credentials to do a E2E test.
# test with ts-node
yarn test:ts-node:cli --help
# build new version
yarn build
# test build
yarn test:cli --help