{"id":36542379,"url":"https://github.com/sergeyshpadyrev/variabler","last_synced_at":"2026-01-12T05:48:31.863Z","repository":{"id":37506254,"uuid":"502453612","full_name":"sergeyshpadyrev/variabler","owner":"sergeyshpadyrev","description":"Environment variables manager","archived":false,"fork":false,"pushed_at":"2022-07-04T15:55:24.000Z","size":1253,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T16:04:21.975Z","etag":null,"topics":["config","env","environment","environment-variables","react","react-native"],"latest_commit_sha":null,"homepage":"","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/sergeyshpadyrev.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":"2022-06-11T20:51:12.000Z","updated_at":"2024-12-12T12:53:38.000Z","dependencies_parsed_at":"2022-09-09T15:01:36.018Z","dependency_job_id":null,"html_url":"https://github.com/sergeyshpadyrev/variabler","commit_stats":null,"previous_names":["sergeyshpadyrev/react-native-envy"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/sergeyshpadyrev/variabler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyshpadyrev%2Fvariabler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyshpadyrev%2Fvariabler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyshpadyrev%2Fvariabler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyshpadyrev%2Fvariabler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergeyshpadyrev","download_url":"https://codeload.github.com/sergeyshpadyrev/variabler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergeyshpadyrev%2Fvariabler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28335283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T00:36:25.062Z","status":"online","status_checked_at":"2026-01-12T02:00:08.677Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["config","env","environment","environment-variables","react","react-native"],"created_at":"2026-01-12T05:48:31.791Z","updated_at":"2026-01-12T05:48:31.854Z","avatar_url":"https://github.com/sergeyshpadyrev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://img.shields.io/npm/v/variabler)](https://badge.fury.io/js/variabler)\n[![License: MIT](https://img.shields.io/npm/l/una-language)](https://opensource.org/licenses/MIT)\n![test github](https://github.com/sergeyshpadyrev/variabler/actions/workflows/test.github.yml/badge.svg?branch=main\u0026event=push)\n![test npm](https://github.com/sergeyshpadyrev/variabler/actions/workflows/test.npm.yml/badge.svg?branch=main\u0026event=push)\n\n**If you like this project, please support it with a star** 🌟\n\n# Variabler\n\nVariabler is a simple tool for managing environment-dependent variables in JavaScript projects.\u003cbr/\u003e\n\n## Installation\n\n#### Globally\n\n```sh\n# npm\nnpm install -g variabler\n# yarn\nyarn global add variabler\n```\n\nIf you install Variabler globally you can call it:\n\n- As `variabler` from `package.json` scripts\n- As `variabler` from CLI\n\n#### As dev dependency\n\n```sh\n# npm\nnpm install --save-dev variabler\n# yarn\nyarn add -D variabler\n```\n\nIf you install Variabler as a dev dependency you can call it:\n\n- As `variabler` from `package.json` scripts\n- As `./node_modules/.bin/variabler` from command line\n\n## Initialization\n\nTo init Variabler in your repository run the following command in your project directory:\n\n```sh\nvariabler init\n```\n\n## Description\n\nOriginally Variabler was created to manage environments and brands in React Native apps but indeed you can use it for React, Node.js or any other JavaScript framework as well. It's platform independent.\n\nVariabler is very convinient in the following cases:\n\n- To manage environments of the app. E.g., `local`, `staging` and `production`\n- To manage branded apps that are based on the single white labeled codebase\n\nUsually environments and branded apps have different bundle ids, have different setting files (like `sentry.settings` for Sentry or `branch.json` for Branch.io), have different constants (color themes, titles, etc...) and can even have different version numbers.\n\nTo manage it all in React Native you need to create its own Android flavour and iOS target for each environment and somehow manage all the differences between environemnts and branded apps. Variabler make it way much easier. Let's say we want to create `staging` and `production` apps.\n\nFirst, we create config:\n\n```json\n{\n  \"configurations\": {\n    \"default\": {\n      \"variables\": {\n        \"VERSION\": \"1.2.3\"\n      }\n    },\n    \"env\": {\n      \"local\": {\n        \"variables\": {\n          \"API_URL\": \"http://localhost:8080\",\n          \"APP_NAME\": \"Local\"\n        }\n      },\n      \"staging\": {\n        \"variables\": {\n          \"API_URL\": \"https://staging.example.com\",\n          \"APP_NAME\": \"Staging\"\n        }\n      },\n      \"production\": {\n        \"variables\": {\n          \"API_URL\": \"https://production.example.com\",\n          \"APP_NAME\": \"Production\"\n        }\n      }\n    }\n  },\n  \"templates\": [\n    { \"from\": \"api.js\", \"to\": \"src/api.js\" },\n    { \"from\": \"build.gradle\", \"to\": \"android/app/build.gradle\" }\n  ]\n}\n```\n\nAfter, we create template files:\n\n`api.js`:\n\n```js\nconst baseURL = '@API_URL@'\n\nexport const get = url =\u003e fetch('GET', `${baseUrl}/${url}`)\n```\n\n`build.gradle`:\n\n```\n...\napplicationId \"@BUNDLE_ID@\"\nversionName \"@VERSION@\"\n...\n```\n\nFinally, we add file destination paths to `.gitignore`:\n\n```\n/android/app/build.gradle\n/src/api.js\n```\n\nThat's it! \u003cbr/\u003e\nNow we can easily set environment using the command:\n\n```sh\nvariabler set env:staging\n```\n\nIt will create two files.\n\n`android/app/build.gradle`:\n\n```\n...\napplicationId \"com.example.app.staging\"\nversionName \"1.2.3\"\n...\n```\n\n`src/api.js`:\n\n```js\nconst baseURL = 'https://staging.example.com'\n\nexport const get = url =\u003e fetch('GET', `${baseUrl}/${url}`)\n```\n\n## Commands\n\n### add\n\nMakes file managed by Variabler:\n\n- Moves the file from original path to `variabler/templates`\n- Removes the original file from git (you need to commit this change)\n- Adds path to the original file to `.gitignore`\n- Adds original path and template path to `variabler/config.json`\n\nAfter running this command you can open the template file and put into it variable keys from `variabler/config.json`\n\nExample:\n\n```sh\nvariabler add ./path/to/file\n```\n\n#### Options\n\n##### Name\n\nIf there already exists a template with the same name you will be asked to choose a new name.\nOther way you need to provide name option to the command:\n\nExample:\n\n```sh\n# long way\nvariabler add ./path/to/file.txt --name myfile.txt\n# short way\nvariabler add ./path/to/file.txt -n myfile.txt\n```\n\n##### File\n\nIf you want to add file not as template but as file you can use the following options:\n\nExample:\n\n```sh\n# long way\nvariabler add --file assets/icon.png\n# short way\nvariabler add -f assets/icon.png\n```\n\n### check\n\nChecks the consistency:\n\n- Between variable keys used in templates and variables defined in config\n- Between file destinations and file sources defined in config\n\nResult:\n\n- Shows warning if variable is defined in config but not used in templates\n- Shows error if variable is used in templates but not defined in config\n\nExample:\n\n```\nvariabler check\n```\n\n### init\n\nInitializes Variabler in your repository:\n\n- Adds `variabler` directory that contains files, templates and config\n- Adds variabler files section into `.gitignore`\n\nBy default it creates two dummy templates (`api.js` and `settings.json`) and dummy icon files. \u003cbr/\u003e\nIt's needed just to help you understand how to use Variabler.\n\nExample:\n\n```sh\nvariabler init\n```\n\n### set\n\nSets variables:\n\n- Takes the files from `variabler/templates` directory\n- Fills the values from `variabler/config.json` to these files\n- Copies the files to the project structure according to the paths defined in `variabler/config.json`\n\nCopies files:\n\n- Take the files from `variabler/files` directory\n- Copies the files to the project structure according to the paths defined in `variabler/config.json`\n\nExample:\n\n```\nvariabler set\nvariabler set env:staging\nvariabler set env:production brand:pepsi\n```\n\nIf you don't pass any values to this command or don't pass enough of them, it will ask you to select one of the available options.\n\n## Advanced configuration\n\n### Working with files\n\nVariabler can copy environment-dependent files.\nUsually it's needed for copying brand-specific icons or environement-specific binary files.\n\nLet's say we need to use different icons for different app environments.\nWe create directory `variabler/files/icon` and put three files there:\n\n- `local.png`\n- `staging.png`\n- `production.png`\n\nThen we add file configuration to `config.json`:\n\n```json\n{\n  \"configurations\": {\n    \"default\": {\n      \"variables\": {\n        ...\n      }\n    },\n    \"env\": {\n      \"local\": {\n        \"files\": {\n          \"appIcon\": \"icon/local.png\"\n        },\n        \"variables\": {\n          ...\n        }\n      },\n      \"staging\": {\n        \"files\": {\n          \"appIcon\": \"icon/staging.png\"\n        },\n        \"variables\": {\n          ...\n        }\n      },\n      \"production\": {\n        \"files\": {\n          \"appIcon\": \"icon/production.png\"\n        },\n        \"variables\": {\n          ...\n        }\n      },\n    }\n  },\n  \"files\": [\n    { \"id\": \"appIcon\", \"to\": \"assets/icon.png\" }\n  ],\n  \"templates\": [\n    ...\n  ]\n}\n```\n\nThat's it! \u003cbr/\u003e\nNow `variabler set` command will copy the icon for selected environment to `assets/icon.png` destination.\n\n### Multiple variable lists\n\nIt's possible to use a few lists of variables.\n\nLet's say, we have a white labeled app that can:\n\n- Be branded as `cola` or `pepsi`\n- Be built for `staging` and `production` environments.\n\nFirst, we create variables config:\n\n```json\n{\n  \"configurations\": {\n    \"default\": {\n      \"variables\": {\n        \"VERSION\": \"1.2.3\"\n      }\n    },\n    \"brand\": {\n      \"cola\": {\n        \"variables\": {\n          \"BUNDLE_ID\": \"com.example.cola\"\n        }\n      },\n      \"pepsi\": {\n        \"variables\": {\n          \"BUNDLE_ID\": \"com.example.pepsi\"\n        }\n      }\n    },\n    \"env\": {\n      \"staging\": {\n        \"variables\": {\n          \"BUNDLE_EXTENSION\": \".staging\"\n        }\n      },\n      \"production\": {\n        \"variables\": {\n          \"BUNDLE_EXTENSION\": \"\"\n        }\n      }\n    }\n  },\n  \"templates\": [{ \"from\": \"build.gradle\", \"to\": \"./android/app/build.gradle\" }]\n}\n```\n\nAfter, we create `build.gradle` file template:\n\n```\n...\napplicationId \"@BUNDLE_ID@@BUNDLE_EXTENSION@\"\nversionName \"@VERSION@\"\n...\n```\n\nFinally, we add file destination paths to `.gitignore`:\n\n```\n/android/app/build.gradle\n```\n\nNow we can set variables:\n\n```sh\nvariabler set brand:pepsi env:staging\n```\n\nAfter we set variables, we gonna see the following code in `android/app/build.gradle`:\n\n```\n...\napplicationId \"com.example.pepsi.staging\"\nversionName \"1.2.3\"\n...\n```\n\n### Extending variable lists\n\nLet's say we need to have production candidate environment that is the same as production one but with a different bundle id. \u003cbr/\u003e\nTo do that we can inherit configurations in `config.json` with `extends` claim:\n\n```json\n{\n  \"configurations\": {\n    \"default\": {\n      \"variables\": {\n        \"VERSION\": \"1.2.3\"\n      }\n    },\n    \"env\": {\n      \"staging\": {\n        \"variables\": {\n          \"API_URL\": \"https://staging.example.com\",\n          \"BUNDLE_ID\": \"com.example.app.staging\"\n        }\n      },\n      \"production\": {\n        \"variables\": {\n          \"API_URL\": \"https://production.example.com\",\n          \"BUNDLE_ID\": \"com.example.app\"\n        }\n      },\n      \"production.candidate\": {\n        \"extends\": \"production\",\n        \"variables\": {\n          \"BUNDLE_ID\": \"com.example.app.candidate\"\n        }\n      }\n    }\n  },\n  \"templates\": [\n    { \"from\": \"api.js\", \"to\": \"src/api.js\" },\n    { \"from\": \"build.gradle\", \"to\": \"android/app/build.gradle\" }\n  ]\n}\n```\n\nWhen you set env to `production.candidate`, it takes all the variables defined in the `common` section, takes all the variables defined in the `production` section and overrides/extends them with the variables defined in the `production.candidate` section. So the full list of variables filled into template is:\n\n```\nAPI_URL: https://production.example.com\nBUNDLE_ID: com.example.app.candidate\nVERSION: 1.2.3\n```\n\n## Integrations\n\n### Vault\n\nVariabler can take variables from Vault secret manager.\n\nLet's say, you want to put production environment variables into Vault. \u003cbr/\u003e\nYou need to create a secret in a key-value storage and put the path to this secret to `config.json`:\n\n```json\n{\n  \"configurations\": {\n    \"default\": {\n      \"variables\": {\n        \"VERSION\": \"1.2.3\"\n      }\n    },\n    \"env\": {\n      \"staging\": {\n        \"variables\": {\n          \"API_URL\": \"https://staging.example.com\",\n          \"APP_NAME\": \"Staging\"\n        }\n      },\n      \"production\": {\n        \"variables\": \"vault://secret/production\"\n      }\n    }\n  },\n  \"templates\": [\n    { \"from\": \"api.js\", \"to\": \"src/api.js\" },\n    { \"from\": \"build.gradle\", \"to\": \"android/app/build.gradle\" }\n  ]\n}\n```\n\nVariabler doesn't handle connection to Vault by itself. \u003cbr/\u003e\nTo use Vault integration you need Vault CLI to be installed on your machine and you should be logged into Vault. \u003cbr/\u003e\nSo you need to check that the following command works in your terminal:\n\n```\nvault kv get secret/production\n```\n\nIf it works, it shows you something like this:\n\n```\n===== Secret Path =====\nsecret/data/production\n\n====== Data ======\nKey         Value\n---         -----\nAPI_URL     https://production.example.com\nAPP_NAME    Production\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeyshpadyrev%2Fvariabler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergeyshpadyrev%2Fvariabler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergeyshpadyrev%2Fvariabler/lists"}