The `flagsmith-cli` is a command-line interface tool designed to fetch feature flags and environment configurations from the Flagsmith API. Its primary use case is to generate a local JSON file, typically `flagsmith.json`, which can then be baked into an application as default flag state. This enables defensive coding practices, provides offline support, and facilitates CI/CD integration for feature flag management. The current stable version is `0.2.3`. Releases occur on an as-needed basis, focusing on bug fixes, dependency updates, and minor feature additions. The CLI is built on Oclif and ships with TypeScript types, targeting Node.js environments `>=12.0.0`. It serves as a crucial component for applications leveraging Flagsmith in scenarios requiring static flag data.
npm install flagsmith-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates installing the CLI, fetching flags into a `flagsmith.json` file, and then importing and initializing the Flagsmith client with these default flags for application use.
Ensure `FLAGSMITH_ENVIRONMENT` is set in your shell/CI environment, or use `flagsmith get YOUR_ENVIRONMENT_KEY`.
Include `-i <value>` or `--identity=<value>` when using any `-t <trait_key>=<trait_value>` flag.
Use the `-a <value>` or `--api=<value>` flag to specify your custom Flagsmith API endpoint, e.g., `--api https://your.custom.flagsmith.com/api/v1/`.
Use the `-o <value>` or `--output=<value>` flag to set the desired output file path, e.g., `--output ./src/flagsmith.ts`.
Add the `-i <identity_value>` or `--identity=<identity_value>` flag when using `-t <trait_key>=<trait_value>`.
Verify the `--output` path used during CLI execution matches your import path. Ensure your build tool (e.g., webpack, esbuild, TypeScript) is configured to handle JSON file imports.
Set the `FLAGSMITH_ENVIRONMENT` environment variable (e.g., `export FLAGSMITH_ENVIRONMENT='your_key'`) or pass the key directly as an argument: `flagsmith get your_key`.
No dependency data recorded yet.