{"_id":"@naturacosmeticos/check-environment-variables","_rev":"29-6304b0d97e7e5ce07e577ec020dcdcba","name":"@naturacosmeticos/check-environment-variables","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@naturacosmeticos/check-environment-variables","version":"0.0.1","description":"Check needed environment variables","main":"./index.js","bin":{"check-variables":"./checkVariables.js","validate-spec":"./validateSpecYaml.js"},"scripts":{"lint":"eslint src/ integrationTests/ *.js","lint:fix":"eslint --fix src/ integrationTests/ *.js","test":"npm run test:unit && npm run test:integration","test:unit":"mocha --recursive --exit --colors --exclude \"./test/**/*.steps.js\" \"./bin/**/*.test.js\"  \"./src/**/*.test.js\"","test:integration":"cucumber-js --exit -f progress-bar integrationTests","test:coverage":"nyc npm test"},"keywords":["Environment","12-factor"],"standard":{"globals":["describe","it"]},"author":{"name":"Natura Cosméticos","email":"TDDAArquitetura@natura.net"},"contributors":[{"name":"Alberto Silva","email":"alberto@vizir.com.br"},{"name":"Fabrício Campos","email":"fabricio@vizir.com.br"}],"devDependencies":{"@naturacosmeticos/eslint-config-natura":"^1.0.0","chai":"^4.2.0","cross-env":"^5.2.0","cucumber":"^5.1.0","eslint":"^5.15.3","eslint-plugin-import":"^2.16.0","faker":"^4.1.0","mocha":"^6.0.2","nyc":"^13.3.0","proxyquire":"^2.1.0","sinon":"^7.3.1","standard":"^12.0.1"},"dependencies":{"chalk":"^2.4.2","commander":"^2.19.0","yaml":"^1.4.0"},"homepage":"https://github.com/natura-cosmeticos/check-environment-variables#readme","bugs":{"url":"https://github.com/natura-cosmeticos/check-environment-variables/issues"},"license":"MIT","gitHead":"86357c68e7a94c9c6f609c996a964bd30e9d17f4","_id":"@naturacosmeticos/check-environment-variables@0.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-dVeVGgSES48x2gXGKmjzZmrVclXjDrQYQMVP6s4iDXn6PdKLP9JShwnb0EZk10zQM7OZO3fcUVhmnmys2/yjlA==","shasum":"c7d026c14bc3c86dce079de105e713e118fade4f","tarball":"https://registry.npmjs.org/@naturacosmeticos/check-environment-variables/-/check-environment-variables-0.0.1.tgz","fileCount":47,"unpackedSize":40366,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc+r2ZCRA9TVsSAnZWagAAeNMQAKMUPXDYstX9RDgSM6Al\nZQJUAYP9aX74skICGmFdJkf4GSegteKGhleMNY0gu06IUywbKKOgld9m0n8L\nwvKmC6XQrQXR1lUA3JIdcEY6D31OmWdeVidcc9EkwqyT5W9sE7veyqWZjFMT\nxS5RrD5GO/9zHisLFXuGMoTkAcdngv3yO/iQIeGgtC0rPvafzQ48Pdfy+/uQ\nGJd0YV6HB3llgP2jXWh2J4Yj+oQ+ydPSUlUzrRV0DAFw2qvOBcKaveH5Xbd3\nB3XU4UolNYnt2Y9vBGD4pDhowr5LnNhuitEv0TEen9dNJqFeMC36f2XQvRI4\nRKMDfdi4yyR+tzDpWbottkFmjlU+Xl9foGrCuYtRwZuRBZbFUWs05d1gNxaQ\nA7m0dIs0ysdYr4s85hXb0n4D7j4VGzxzWhJMQCWfkzkhldjjqp58ZcX0p/bV\nOL9XGkRZoEp1D61/ArjdKxRa89zbw91EgjFLVB8NPKXAVrwjNTd9vBo3k30n\n0S07O9SfTU6Obv290ds6/b8soLgYXvOCIvILl3JLm3YHsfR1a1aRQ1yeUq8I\nBizVd4E3iqcbTVkLiblOCTDtLtP5bo5dam7IeKjQFDPz3culXwCMUzVPsnVs\nzsbQ2S974mYp0rWZstKIjqESB7LE1exsnv12xB+azDTKCb6i4HNZGTcCvP4H\n4Aue\r\n=VbF7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEmlXBr2eQJzBxYLWkqn7f46JKbbP6arYDuSPNcUDiFsAiB/fhTKJnEt2+0zkWIc0HH3f0o5AMbrnzkUAAcNuU3rLA=="}]},"maintainers":[{"name":"darthaud","email":"arthaud@gmail.com"},{"name":"fabricioffc","email":"ffc.fabricio@gmail.com"},{"name":"handrus","email":"handrus@gmail.com"}],"_npmUser":{"name":"fabricioffc","email":"ffc.fabricio@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/check-environment-variables_0.0.1_1559936409215_0.30282834666317204"},"_hasShrinkwrap":false}},"time":{"created":"2019-06-07T19:40:09.051Z","0.0.1":"2019-06-07T19:40:09.375Z","modified":"2024-02-19T17:01:23.970Z"},"maintainers":[{"email":"marcelofabricanti@hotmail.com","name":"marcelofabricanti"},{"email":"designsystem@natura.net","name":"designsystemnatura"},{"email":"mport.dev@gmail.com","name":"mukaportes"},{"email":"vicentelyrio@gmail.com","name":"vicentelyrio"},{"email":"matheusrobert8@gmail.com","name":"robert-lichtnow"},{"email":"douglasofreitas@gmail.com","name":"douglasofreitas"},{"email":"npm@jimmyandrade.com","name":"jimmyandrade"},{"email":"lauralucca@gmail.com","name":"lauralucca"},{"email":"marcelsaito@gmail.com","name":"marcelsaitonatura"},{"email":"eliisrael@gmail.com","name":"eliisrael"}],"description":"Check needed environment variables","homepage":"https://github.com/natura-cosmeticos/check-environment-variables#readme","keywords":["Environment","12-factor"],"contributors":[{"name":"Alberto Silva","email":"alberto@vizir.com.br"},{"name":"Fabrício Campos","email":"fabricio@vizir.com.br"}],"author":{"name":"Natura Cosméticos","email":"TDDAArquitetura@natura.net"},"bugs":{"url":"https://github.com/natura-cosmeticos/check-environment-variables/issues"},"license":"MIT","readme":"[![Known Vulnerabilities](https://snyk.io/test/github/natura-cosmeticos/check-environment-variables/badge.svg?targetFile=package.json)](https://snyk.io/test/github/natura-cosmeticos/check-environment-variables?targetFile=package.json)\n[![Build Status](https://travis-ci.org/natura-cosmeticos/check-environment-variables.svg?branch=master)](https://travis-ci.org/natura-cosmeticos/check-environment-variables)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/8426d68f7eac481c9f3ae07b8eb1805b)](https://www.codacy.com/app/fabricioffc/check-environment-variables?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=natura-cosmeticos/check-environment-variables&amp;utm_campaign=Badge_Grade)\n\n\n# check-environment-variables\n\nCheck environment variables helps verify variables set by setup files (ex: spec.yaml) and also in the environment itself.\n\n### How to use\n\nIf you want to check your environment variables you can run: `check-variables`, when you execute this binary file it will\nlook for a file, on the same level with the name `checkVariablesSpec.yaml`, and it is going to compare the variables on\nthe **process.env** and compare against the specification on the file.\n\nSee this example file:\n```yaml\ncheckVariables:\n  START_SERVER: # required boolean variable (true or false)\n    type: boolean\n    required: true\n  REQUEST_TIMEOUT: number # not require number\n  API_HOST: url # not required url\n  FROM_EMAIL: email # not required url\n  NAMESPACE: string # not required string\n  ENDPOINT: true # required variable to have on process.env\n  AWS_REGION: # the variable value should be one of the possibleValues\n    type: enum\n    possibleValues:\n      - us-east-2\n      - us-east-1\n      - us-west-1\n      - us-west-2\n  MY_OTHER_VARIABLE: # an string, starting with maria, with length from 7 to 20\n    type: string\n    required: true\n    minLength: 7\n    maxLength: 20\n    regex: ^maria\n```\n\nIf you run `check-variables` against this file it is going to check the varaibles `START_SERVER, REQUEST_TIMEOUT, API_HOST, FROM_EMAIL, NAMESPACE, ENDPOINT, AWS_REGION, MY_OTHER_VARIABLE` on your **process.env**\n\nOptions of `check-variables`:\n```bash\n# default value for yamlFile is \"checkVariablesSpec.yaml\"\nUsage: check-variables [options] [yamlFile]\n\nOptions:\n  -V, --version                output the version number\n  -b, --bail                   Indicates whether or not the proccess exits with status non ok when oneor more variables are wrong\n  -f, --formatter [formatter]  The formatter of output: json, inline, pretty (default: \"pretty\")\n  -h, --help                   output usage information\n```\n\nIn order to check variables in a spec file, you need to run: `validate-spec-yaml [MY_SPEC_FILE_PATH]`\n\nThe comparison will occur according to the templates files in `/templates`.\n\n#### Using programatically\n```javascript\nconst checkVariables = require('check-variables');\n\nconst myVariables = {\n  myServerShouldStart: process.env.START_SERVER,\n  region: process.env.REGION\n}\n\n// follow the same specification of \"checkVariablesSpec.yaml\" file\nconst mySpecification = {\n  myServerShouldStart: 'boolean',\n  region: {\n    type: 'enum',\n    possibleValues: ['north', 'south']\n  }\n}\nconst result = checkVariables(myVariables, mySpecification) // as the first parameter you can also use process.env\nresult.assertVariablesAreOK() // throws an AssertionError if something is not right\nresult.success // false when the specification is not valid, true when validation happened\nresult.messages // when at least one of the specification are invalid you can see what is invalid\nresult.hasErrors  // false when all variables respects the rules in specification\nresult.variables // an array, items has the fields: 'variable' -> name of the variable, 'value' -> the value of variable, 'error' -> null if the value of the variable is ok against the rule, string containing the error if not ok\n```\n\n### Supported setup files\n\nThe current version only supports `spec.yaml`, an internal Natura environment setup file.\n\n### Setup\n\nRun `npm i`.\n\n### Testing\n\nJust run `npm test`.\n\n\n### Lint\n\nTo verify if any lint rule was broken run: `npm run lint`.\n\n### How to contribute\n\nYou can contribute submitting [pull requests](https://github.com/natura-cosmeticos/check-environment-variables/pulls).\n","readmeFilename":"README.md"}