{"id":18426149,"url":"https://github.com/wework/env-universal","last_synced_at":"2025-04-07T16:32:23.033Z","repository":{"id":57225941,"uuid":"71652128","full_name":"wework/env-universal","owner":"wework","description":"Standard environment definition, utilities and constants for browser and node JavaScript applications","archived":false,"fork":false,"pushed_at":"2020-06-02T18:26:16.000Z","size":412,"stargazers_count":8,"open_issues_count":35,"forks_count":4,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-22T21:25:14.584Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wework.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-22T16:44:43.000Z","updated_at":"2021-03-02T14:46:05.000Z","dependencies_parsed_at":"2022-08-24T11:00:34.524Z","dependency_job_id":null,"html_url":"https://github.com/wework/env-universal","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fenv-universal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fenv-universal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fenv-universal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wework%2Fenv-universal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wework","download_url":"https://codeload.github.com/wework/env-universal/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247688112,"owners_count":20979606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T05:07:01.719Z","updated_at":"2025-04-07T16:32:22.627Z","avatar_url":"https://github.com/wework.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"env-universal\n================\n\n[![Build Status][travis-image]][travis-url]\n[![Libraries.io for GitHub][librariesio-image]][librariesio-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n[![NPM version][npm-version-image]][npm-url]\n[![NPM downloads][npm-downloads-image]][npm-url]\n[![MIT License][license-image]][license-url]\n\n[![Sauce Test Status][saucelabs-image]][saucelabs-url]\n\n\u003eStandard environment definition, utilities and constants for browser and node JavaScript applications\n\n# Introduction\n\nThis package provides utilities for working with environment configuration consistently in different runtimes via configuration objects or environment variables.\n\nWe created this at [WeWork](https://www.wework.com) to provide our applications a more consistent runtime. We use it with tools like `dotenv` and `webpack` in universal JavaScript applications.\n\n\n# Environment configuration\n\nWe use a matrix of variables to define the environment of our applications:\n\nEnv          | Condition  |   Notes  |\n------------ | -----------|----------|\n`development`| `NODE_ENV` is undefined or 'development' | Should only be true in local development environments |\n`production` | `APP_ENV` is 'production' | `NODE_ENV` should be 'production' for deployments |\n`staging`    | `APP_ENV` is 'staging' | `NODE_ENV` should be 'production' for deployments |\n`preprod`    | `APP_ENV` is 'preprod' | `NODE_ENV` should be 'production' for deployments |\n`qa`    | `APP_ENV` is 'qa' | `NODE_ENV` should be 'production' for deployments |\n`test`       | `NODE_ENV` is 'test' or 'testCI' | |\n\n*Note that `NODE_ENV=production` only indicates that the app is deployed (vs running locally in development) and that `APP_ENV` specifies the environment.*\n\nRuntime      | Condition  |\n------------ | -----------|\n`server`     | `SERVER` has any value |\n`client`     | `CLIENT` has any value |\n\nBy default, config is read from environment variables (`process.env`), but you can also pass in your own configuration object.\n\n# Usage\n\nSee the [documentation](./API.md). Note that most util functions expect to receive `process.env` when not calling the root `env` function.\n\nThis package is bundled as a CommonJS module in `dist` and can be required like any other. The ES2015 source is also exposed via the [`jsnext:main` field in the `package.json`](https://github.com/rollup/rollup/wiki/jsnext:main) for loaders that support module syntax directly.\n\n## Webpack\n\n`utils.getPublicEnv` is very handy to safely expose environment config for a client bundle. See [docs for getPublicEnv](./API.md#getpublicenv), and our own use of it in [`test/browser/webpack.config.js`](./test/browser/webpack.config.js).\n\n## Examples\n\n```js\nimport getEnv from 'env-universal';\nconst env = getEnv();\n\nconsole.log(env.version);\nconsole.log(env.is.client);\nconsole.log(env.is.server);\nconsole.log(env.is.deployed);\nconsole.log(env.is.production);\nconsole.log(env.is.dev);\n```\n\n# Development\n\n1. Checkout this repo\n2. Run `npm install`\n3. Make changes in a feature branch and open a PR to `master`\n\nIn lieu of a formal style guide, please:\n\n - follow the conventions present in the codebase\n - respect the linter\n - keep tests green\n - maintain test coverage\n\n# npm scripts\n\n### npm scripts\n\nTarget | Behavior\n------------ | -------------\n**`npm test`** | Runs tests in browser and node runtimes\n**`npm run tdd`** | Runs tests, bundles and re-runs on file changes\n**`npm run test:coverage`** | Runs tests and outputs a code coverage report to `/coverage`\n**`npm run test:ci`** | Runs tests, outputs code coverage\n**`npm run lint`** | (*Run as a git pre-commit hook*) Runs `eslint`\n**`npm run docs`** | Generates `API.md` from JSDoc comments in `/src`\n**`npm run security-scan`** | (*Run as a git pre-push hook*) Checks npm dependencies for security vulnerabilities\n**`npm run release \u003cversion\u003e`** | Generates a changelog, updates package version, tags and pushes via [`np`](https://www.npmjs.com/package/np). This should only be run on an up-to-date `master` by a maintainer of this package. \u003cbr /\u003e\u003cbr /\u003eVersion can be a semver level: `patch | minor | major | prepatch | preminor | premajor | prerelease`, or a valid semver version: `1.2.3`.\n\n**`npm run` will list all npm scripts**\n\n\n[npm-url]: https://npmjs.org/package/env-universal\n[npm-version-image]: http://img.shields.io/npm/v/env-universal.svg?style=flat-square\n[npm-downloads-image]: http://img.shields.io/npm/dm/env-universal.svg?style=flat-square\n\n[coveralls-image]:https://coveralls.io/repos/github/wework/env-universal/badge.svg?branch=master\n[coveralls-url]:https://coveralls.io/github/wework/env-universal?branch=master\n\n[travis-url]:https://travis-ci.org/wework/env-universal\n[travis-image]: https://travis-ci.org/wework/env-universal.svg?branch=master\n\n[saucelabs-image]:https://saucelabs.com/browser-matrix/wework-env-universal.svg\n[saucelabs-url]:https://saucelabs.com/u/wework-env-universal\n\n[license-url]: LICENSE\n[license-image]: http://img.shields.io/badge/license-MIT-000000.svg?style=flat-square\n\n[librariesio-url]: https://libraries.io/npm/env-universal\n[librariesio-image]: https://img.shields.io/librariesio/github/wework/env-universal.svg?maxAge=2592000\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Fenv-universal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwework%2Fenv-universal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwework%2Fenv-universal/lists"}