{"_id":"@amber.yuan/config-yml","_rev":"1-392d805e94b5bbf307ecdff29f8910ad","name":"@amber.yuan/config-yml","dist-tags":{"latest":"0.10.3"},"versions":{"0.10.3":{"name":"@amber.yuan/config-yml","version":"0.10.3","description":"Simple Yaml Config for Node.js","main":"index.js","scripts":{"test":"standard | snazzy && mocha","coverage":"nyc --reporter=lcov --reporter=text mocha","coveralls":"nyc --reporter=text-lcov mocha | coveralls"},"repository":{"type":"git","url":"git+https://github.com/Nordstrom/config.git"},"keywords":["Config","Yaml","Yml","Configuration","Settings","Parameters","Node.js","Stack","Deploy"],"author":{"name":"Andy Day"},"license":"MIT","bugs":{"url":"https://github.com/Nordstrom/config/issues"},"homepage":"https://github.com/Nordstrom/config#readme","standard":{"globals":["describe","it","before","after"]},"dependencies":{"js-yaml":"^3.6.1","lodash":"^4.13.1","moment":"^2.13.0","npmrc":"^1.1.1","shelljs":"^0.7.0","yargs":"^4.7.1"},"devDependencies":{"coveralls":"^3.0.1","decache":"^3.1.0","mocha":"^5.2.0","nyc":"^12.0.2","should":"^9.0.2","sinon":"^1.17.4","snazzy":"^7.0.0","standard":"^11.0.1"},"directories":{"test":"test"},"gitHead":"b8d99cfbe05acbcbc25f217686f263347076aa68","_id":"@amber.yuan/config-yml@0.10.3","_nodeVersion":"14.16.1","_npmVersion":"7.9.0","dist":{"integrity":"sha512-wy61Cz2DV6MfQoHcmp/H4r9/gghm9MW1FcLXKvwVMusS7iIRW9NBHhSL+RpeP03e7vSJpLsuRoxrtS2vQSAlZQ==","shasum":"496f798d45feb003ae2c9b514036b7785b754f99","tarball":"https://registry.npmjs.org/@amber.yuan/config-yml/-/config-yml-0.10.3.tgz","fileCount":27,"unpackedSize":28465,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiKB0KACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpB2xAAiaEj9zOKC7DrIYhWzED2IZRbAaqokccgOj2ueEPann/kRilk\r\njX0Oi5404IDqx97GIp9nJbeJhssWJ1R/0nyFH0WD+cDiF/o1bmUdYZv6AOQU\r\n/3tIt2TjdwSN6kNTp4vGIN1PGLCUrWbNUbuE27kLqjn2oi49369NwFaoV6Y5\r\nMtK/AVW1rvdyCcxM0rV7TBFhCGFpbJ5f2fKsz/X840blZjEKEDbxPVkzVF+L\r\nIpxsaWM7tipxGlNvQc4ixkMXNxyhtc8KQxFvhNKi5CohAi0sDEAJ8C8S7I+f\r\n1AfyB+6rDxim6VcruKXD/vY+ix6ms3U1xF9aQeDkilL3KEGmEcKXqd/PXH85\r\nOI3rw9yZk24ypxghNqocYn7cEWvmeF8GKAS+WdMX1Zu+8DgZxr6rvxtosxxq\r\nJnQ0YJ8lH+ICku/WTvLTCCpbWothyhfPPwnSU1xRZLYBHNrxVnF0NnMI4P3b\r\niv6kGyPTSQ/4bFdMBpgsBIseaIV6tV1G1g3+HVrT9t9Ran4jKOOBujckLxHh\r\nBW35eGF3/C/VBmsjU+My+8pO5G1De8Gruv7ebGejoXSaZprxQZ4lWc+A9CZF\r\nIsndc/fV2RtlBi8NmzjKL1e0WU4okPbgWYSkHw5C5PR0667fd5Hx9lokYIWm\r\n44Akq4fXm1Ciyar8rli1728o9X7gYbqPBe4=\r\n=MMj2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJpjlTqdqWtvT4dRxNHKxov2aokp9jq/PzMMgk9zyF5AIgaJlhtCjDTyZNzhRMwxFhXVSOdPBFRXYWR+lW2IDILj8="}]},"_npmUser":{"name":"amber.yuan","email":"yuanjuhong9998@163.com"},"maintainers":[{"name":"amber.yuan","email":"yuanjuhong9998@163.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/config-yml_0.10.3_1646796042137_0.7084219311783784"},"_hasShrinkwrap":false}},"time":{"created":"2022-03-09T03:20:42.003Z","0.10.3":"2022-03-09T03:20:42.493Z","modified":"2022-04-04T13:45:45.660Z"},"maintainers":[{"name":"amber.yuan","email":"yuanjuhong9998@163.com"}],"description":"Simple Yaml Config for Node.js","homepage":"https://github.com/Nordstrom/config#readme","keywords":["Config","Yaml","Yml","Configuration","Settings","Parameters","Node.js","Stack","Deploy"],"repository":{"type":"git","url":"git+https://github.com/Nordstrom/config.git"},"author":{"name":"Andy Day"},"bugs":{"url":"https://github.com/Nordstrom/config/issues"},"license":"MIT","readme":"# config-yml - Simple Yaml Config for Node.js\n\n[![Travis Build](https://travis-ci.org/Nordstrom/config.svg)](https://travis-ci.org/Nordstrom/config) [![Coverage Status](https://coveralls.io/repos/github/Nordstrom/config/badge.svg?branch=master)](https://coveralls.io/github/Nordstrom/config?branch=master) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![config-yml](https://img.shields.io/npm/v/config-yml.svg)](https://www.npmjs.com/package/config-yml)\n\n## Install\n```\n$ yarn add config-yml\n```\nor\n```\n$ npm install config-yml --save\n```\n\n## Usage\nUse config for yaml config files in Node.js projects.  For example you might have a project with the following\nconfig.yml file in the project dir.\n\n```yaml\n\napp:\n    url: http://myapp.com/home\n    cache: redis\n\ndb:\n    location: mysql-db-prod\n\n```\n\nThis config can be accessed like this.\n\n```javascript\n\nconst config = require('config-yml');\n\nconsole.log(config.app.url);\nconsole.log(config.app.cache);\nconsole.log(config.db.location);\n\n```    \n\n## Substitution\nYou can substitute variables in the config.yml like this.\n\n```yaml\n\ndns: myapp.com\n\napp:\n    url: http://${dns}/home\n    cache: redis\n\ndb:\n    location: mysql-db-prod\n\n```\n\nThis config would yield the following.\n\n```javascript\n\nconsole.log(config.app.url);\n\n// outputs - http://myapp.com/home\n\n```\n\n## Config Folder\nInstead of having a file named `config.yml` with all of your environment settings in place, you could have a `config` folder \nat the root level of your project. This module will read in every `.yml` file, and return an object that looks like:\n```javascript\n{\n    [file-name]: [parsed-file-contents],\n    ...,\n} \n```\n\nif you need to do cross-file referencing, you can, via dot-notation:\n```yaml\n# file `a.yml`\nfoo: bar\n```\n```yaml\n#file `b.yml`\nbaz: ${a.foo}\n```\nwill get you\n```javascript\n{\n    a: {foo: 'bar'},\n    b: {baz: 'bar'}\n}\n```\n\n## Environment Specific Settings\nBased on an Environment ID, you can designate specific override settings for different types of environments.  First\nyou have to specify your Environment ID.  You can do so in one of several ways.  The first Environment ID that is\nfound in the following order wins.\n\n1. [--env command line argument](#Environment-ID:---env-Argument)\n2. [--${static-environment} command line argument](#Environment-ID:---${static-environment}-Argument)\n3. [ENVIRONMENT_ID process environment setting](#Environment-ID:-ENVIRONMENT_ID)\n4. [git branch name with regex filtering](#Environment-ID:-git-branch)\n\n### Static Environments\nTo understand this better let's first talk about Static Environments.  These are environments that have their own\nenvironment specific settings or [Environment Overrides](#Environment-Overrides).  Not necessarily all environments\nhave their own environment specific settings, but those that do should be defined as Static Environments in\nthe config.yml as follows:\n\n```yaml\n\nenvironments:\n    static:\n        - dev\n        - test\n        - prod\n\n```\n\n### Keys as environments\nThe other approach you can take is to have top level keys that only consist of your environments. \n\n#### Using a single config.yml file\nsetup your config.yml as follows:\n```yaml\ndev:\n    # ...\ntest:\n    # ...\nprod:\n    # ...\n```\n\n#### Using a Config folder.\nYour filenames determine the keys, so your directory could be set as follows:\n\n```\nconfig/dev.yml\nconfig/test.yml\nconfig/prod.yml\n```\n\n### Environment ID: load Argument\nSet the Environment ID using the load function.\n\n```js\nconst config = require('config-yml').load('myenvironment')\n```\n\n\n### Environment ID: --env Argument\nSet the Environment ID using --env command line argument.\n\n```\nnode app.js --env feature-xyz\n```\n\nThis is often helpful when running gulp tasks.\n\n```\ngulp deploy --env feature-xyz\n```\n\n### Environment ID: --${static-environment} Argument\nFor Static Environments set the Environment ID using the static environment id as an argument.\n\n```\ngulp deploy --prod\n```\n\n### Environment ID: ENVIRONMENT_ID\nSet the Environment ID using ENVIRONMENT_ID process environment variable.\n\n```\nexport ENVIRONMENT_ID=feature-xyz\n```\n\n### Environment ID: git branch\nIf an Environment ID is not found using one of the other methods, it will use the git branch for the current project\nfolder.  This branch can be filtered using regex.  Let's say your current branch is `Features/ISSUE-123-feature-xyz`,\nand you have the following setting in your config.yml.\n\n```yaml\n\nbranchRegex: Features/ISSUE-\\d+-((\\w|-)+)\n\n```\n\nThe Environment ID will be `feature-zyz`.  If no branchRegex is given the branch name will be taken as is.\n\n\n### Environment ID Substitution\nThe Environment ID can be substituted into the config.yml.  Let's say you have an Environment ID `feature-xyz` and\nthe following config.yml.\n\n```yaml\ndns: ${envId}.myapp.com\n\napp:\n    url: http://${dns}/home\n    cache: redis\n\ndb:\n    location: MYSQL-DB-${ENVID}\n```\n\nThis will yield the following:\n\n```javascript\nconst config = require('config-yml');\n\nconsole.log(config.dns);          // feature-xyz.myapp.com\nconsole.log(config.app.url);      // http://feature-xyz.myapp.com\nconsole.log(config.db.location);  // MYSQL-DB-FEATURE-XYZ\n\n```\n\n### Environment Overrides\n\nFor Static Environments, settings can be overridden for that specific environment.  For example, with the following\nconfig.yml:\n\n```yaml\ndns: ${envId}.myapp.com\n\napp:\n    url: http://${dns}/home\n    cache: redis\n\ndb:\n    location: MYSQL-DB-${ENVID}\n\nprod:\n    app:\n        url: https://${dns}\n    db:\n        location: DB-${ENVID}\n\n```\n\nand the following app.js file:\n\n\n```javascript\nconst config = require('config-yml');\n\nconsole.log(config.dns);\nconsole.log(config.app.url);\nconsole.log(config.app.cache);\nconsole.log(config.db.location);\n\n```\n\nthe following command:\n\n```\nnode app.js --prod\n```\n\nwould output the following:\n\n```\nprod.myapp.com\nhttps://prod.myapp.com\nredis\nMYSQL-DB-PROD\n```\n","readmeFilename":"README.md"}