{"id":20556468,"url":"https://github.com/flagsmith/flagsmith-cli","last_synced_at":"2025-07-09T07:07:54.783Z","repository":{"id":58033935,"uuid":"526564372","full_name":"Flagsmith/flagsmith-cli","owner":"Flagsmith","description":"A CLI to fetch and output your Flagsmith features to a file","archived":false,"fork":false,"pushed_at":"2025-05-13T15:17:39.000Z","size":32367,"stargazers_count":5,"open_issues_count":3,"forks_count":3,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-07-09T07:04:10.201Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/Flagsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-19T10:35:08.000Z","updated_at":"2025-04-09T09:17:38.000Z","dependencies_parsed_at":"2025-06-19T10:41:36.758Z","dependency_job_id":"920b044c-6b1d-4aed-bc9a-a7a8e0d583ea","html_url":"https://github.com/Flagsmith/flagsmith-cli","commit_stats":{"total_commits":19,"total_committers":3,"mean_commits":6.333333333333333,"dds":0.1578947368421053,"last_synced_commit":"f1237e968ecdbbd936f3785cd709fd80c80950ca"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Flagsmith/flagsmith-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flagsmith","download_url":"https://codeload.github.com/Flagsmith/flagsmith-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flagsmith%2Fflagsmith-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264411145,"owners_count":23603802,"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-16T03:28:04.722Z","updated_at":"2025-07-09T07:07:54.767Z","avatar_url":"https://github.com/Flagsmith.png","language":"TypeScript","readme":"\u003cimg width=\"100%\" src=\"https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png\"/\u003e\n\nflagsmith-cli\n=================\n\nRetrieve Flagsmith state from an API and store it in a file.\n\nThis CLI can be used to bake default flags into your application as part of CI/CD, this provides support for offline applications and is also advised as part of our [Defensive Coding and Default Flags Documentation](https://docs.flagsmith.com/guides-and-examples/defensive-coding). An example of this can be seen [here](./example).\n\n\n# Populating defaultFlags in your Project\n\nThe steps to using this to provide default flags are as follows. An example of this can be found [here](./example). The main steps to achieving this are as follows:\n\n\n1. Install the cli ``npm i flagsmith-cli --save-dev``\n2. Call the cli as part of postinstall to create a ``flagsmith.json`` file:\n\n```export FLAGSMITH_ENVIRONMENT=API_KEY```\n\n```\n\"postinstall\": \"flagsmith get\"\n```\nAn example of this can be seen [here](./example/src/index.tsx). \n3. In your application, import the outputted JSON and initialise the client with the json ``flagsmith.init({state:json, environmentID: json.environmentID})``\n\n**Example:**\n\n```typescript\nimport flagsmith from 'flagsmith'\nimport state from './flagsmith.json'\n\nflagsmith.init({state, environmentID: state.environmentID})\n```\n\n**Example with React:**\n\n```jsx\nimport state from './flagsmith.json'\nReactDOM.render(\n  \u003cFlagsmithProvider options={{environmentID: state.environmentID, state}} flagsmith={flagsmith}\u003e\n    \u003cApp /\u003e\n  \u003c/FlagsmithProvider\u003e,\n  document.getElementById('root')\n);\n```\n\n\u003c!-- tocstop --\u003e\n# Usage - Global\n\u003c!-- usage --\u003e\n```sh-session\n$ npm install -g flagsmith-cli\n$ flagsmith COMMAND\nrunning command...\n$ flagsmith (--version)\nflagsmith-cli/0.1.2 darwin-arm64 node-v18.13.0\n$ flagsmith --help [COMMAND]\nUSAGE\n  $ flagsmith COMMAND\n...\n```\n\u003c!-- usagestop --\u003e\n# Commands\n\u003c!-- commands --\u003e\n* [`flagsmith get [ENVIRONMENT]`](#flagsmith-get-environment)\n* [`flagsmith help [COMMANDS]`](#flagsmith-help-commands)\n\n## `flagsmith get [ENVIRONMENT]`\n\nRetrieve flagsmith features from the Flagsmith API and output them to a file.\n\n```\nUSAGE\n  $ flagsmith get [ENVIRONMENT] [-o \u003cvalue\u003e] [-a \u003cvalue\u003e] [-t\n    \u003cvalue\u003e -i \u003cvalue\u003e] [-p] [-e flags|environment]\n\nARGUMENTS\n  ENVIRONMENT  The flagsmith environment key to use, defaults to the environment\n               variable FLAGSMITH_ENVIRONMENT\n\nFLAGS\n  -a, --api=\u003cvalue\u003e      [default: https://edge.api.flagsmith.com/api/v1/] The\n                         API URL to fetch the feature flags from\n  -e, --entity=\u003coption\u003e  [default: flags] The entity to fetch, this will either\n                         be the flags or an environment document used for [local\n                         evaluation](https://docs.flagsmith.com/clients/server-s\n                         ide#local-evaluation-mode-network-behaviour).\n                         \u003coptions: flags|environment\u003e\n  -o, --output=\u003cvalue\u003e   [default: ./flagsmith.json] The file path output\n  -p, --pretty           Prettify the output JSON\n\nIDENTITY FLAGS\n  -i, --identity=\u003cvalue\u003e                    The identity for which to fetch\n                                            feature flags\n  -t, --trait=\u003ctrait_key\u003e=\u003ctrait_value\u003e...  Trait key-value pair, separated by\n                                            an equals sign (=)\n\nDESCRIPTION\n  Retrieve flagsmith features from the Flagsmith API and output them to a file.\n\nEXAMPLES\n  $ flagsmith get \u003cENVIRONMENT_API_KEY\u003e\n\n  $ FLAGSMITH_ENVIRONMENT=abc123... flagsmith get\n\n  $ FLAGSMITH_ENVIRONMENT=ser.abc123... flagsmith get -e environment\n\n  $ flagsmith get -o ./my-file.json\n\n  $ flagsmith get -a https://flagsmith.example.com/api/v1/\n\n  $ flagsmith get -i flagsmith_identity\n\n  $ flagsmith get -i flagsmith_identity -t my_trait_key=some_trait_value -t other_trait=other_value\n\n  $ flagsmith get -p\n```\n\n_See code: [dist/commands/get/index.ts](https://github.com/Flagsmith/flagsmith-cli/blob/v0.1.4/dist/commands/get/index.ts)_\n\n## `flagsmith help [COMMANDS]`\n\nDisplay help for flagsmith.\n\n```\nUSAGE\n  $ flagsmith help [COMMANDS] [-n]\n\nARGUMENTS\n  COMMANDS  Command to show help for.\n\nFLAGS\n  -n, --nested-commands  Include all nested commands in the output.\n\nDESCRIPTION\n  Display help for flagsmith.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagsmith%2Fflagsmith-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflagsmith%2Fflagsmith-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflagsmith%2Fflagsmith-cli/lists"}