{"id":24780775,"url":"https://github.com/christiaanwesterbeek/switchenv","last_synced_at":"2025-03-24T05:13:50.394Z","repository":{"id":33713485,"uuid":"160943025","full_name":"christiaanwesterbeek/switchenv","owner":"christiaanwesterbeek","description":"command line tool for quickly switching .env file from Keepass entries (content from the Notes field)","archived":false,"fork":false,"pushed_at":"2022-12-03T21:56:38.000Z","size":1611,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T14:45:33.096Z","etag":null,"topics":["cli","command-line-tool","env","environments","keepass","npm-scripts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christiaanwesterbeek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-08T13:41:27.000Z","updated_at":"2022-01-03T13:51:25.000Z","dependencies_parsed_at":"2023-01-15T02:10:45.258Z","dependency_job_id":null,"html_url":"https://github.com/christiaanwesterbeek/switchenv","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiaanwesterbeek%2Fswitchenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiaanwesterbeek%2Fswitchenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiaanwesterbeek%2Fswitchenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christiaanwesterbeek%2Fswitchenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christiaanwesterbeek","download_url":"https://codeload.github.com/christiaanwesterbeek/switchenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245212301,"owners_count":20578443,"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":["cli","command-line-tool","env","environments","keepass","npm-scripts"],"created_at":"2025-01-29T10:50:45.152Z","updated_at":"2025-03-24T05:13:50.376Z","avatar_url":"https://github.com/christiaanwesterbeek.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# switchenv\n[![build status](https://travis-ci.org/christiaanwesterbeek/switchenv.svg?branch=master)](https://travis-ci.org/christiaanwesterbeek/switchenv)\n[![known vulnerabilities](https://snyk.io/test/github/christiaanwesterbeek/switchenv/badge.svg?targetFile=package.json)](https://snyk.io/test/github/christiaanwesterbeek/switchenv?targetFile=package.json)\n[![npm version](https://badge.fury.io/js/switchenv.svg)](https://www.npmjs.org/package/switchenv)\n\nCommand line tool to quickly switch .env file from Keepass entries (content from the Notes field)\n\n![thousand words](https://raw.githubusercontent.com/christiaanwesterbeek/switchenv/develop/media/thousand-words.png)\n\n\n## Install\n\n`yarn add -D switchenv`\n\nor\n\n`npm install -D switchenv`\n\n## Usage\n\nYou need to go through a one time setup per project. That will take you a few minutes.\nAfterwards you'll be able to run this command to change your .env file.\n\n`yarn switchenv development`\n\nor\n\n`npm run switchenv development`\n\nIt will read and decrypt the keepass file and look for an entry with the title: development.\nThe Notes of that entry will overwrite the .env file.\n\nNota Bene: It will overwrite the .env file without warning!\n\n## Setup\n\nYou need to do this setup once per project.\n\n1. Go to your project folder where the `package.json` resides.\n2. Create a directory to store your keepass file and keyfile in.\n3. Add the created directory to your .gitignore file!!\n\n  NB: Your keepass and key file should never be committed!\n\n4. In that directory create a keepass file.\n5. Create a new entry in the keepass file for each environment.\n\n  - The Title field of the entry should be the name of your environment. Use names like development, staging, production.\n  - The Notes field of the entry is the desired contents of your .env file for that environment.\n\n6. Generate a key file for the keepass file. Preferably store it in the same directory as your keepass file.\n7. In your app's `package.json` file add a `switchenv` command in the `scripts` section.\n\n```\n{\n  ...\n  \"scripts\": {\n    \"switchenv\": \"node ./node_modules/switchenv --source /envs/keepass.kdbx --key /envs/keyfile\"\n  },\n  ...\n}\n```\n\nIn this example\n- `--source /envs/keepass.kdbx` is the path to the keepass file.\n- `--key /envs/keyfile` is the path to the key file.\n\n### Optionally\n\n- `--target /config.js` if you want to write to something else than /.env\n- `--title .env-{title}-backend` if you have longer entry titles like `.env-development-backend` instead of just `development`. In this case, you can still run `yarn switchenv development`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristiaanwesterbeek%2Fswitchenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristiaanwesterbeek%2Fswitchenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristiaanwesterbeek%2Fswitchenv/lists"}