commands: features, metrics, experiments #31
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New commands
Adds the following new commands:
You can run
yarn build && ./bin/run features list > output.json
to put the features response into a fileoutput.json
.Architecture
Standardizes the architecture for networking and command generation. Running
yarn plop command
andyarn plop repository
will generate some standardized files which include considerations for default arguments and flags (e.g. pagination, profile, base URL, etc.). See the plop templates for details.This approach will allow us to wrap the networking calls in case we need to change the implementation for whatever reason (e.g. if we need to move to a different generator instead of typescript-axios).
The repositories also attach the user agent
growthbook-cli/<version>
.Commands
Commands are bootstrapped with default args that the user can configure, e.g. base URL and profile. We also have reusable command flags for pagination.
Repositories
The repositories are generated so contributors don't need to worry about the interfaces and super methods. Provided the resource exists, generating a new repository is as simple as running
yarn plop repository
(or justyarn plop
and choosing "repository"). Doingyarn plop repository DataSource
results in the following:And for the experiments repo:
This means you can now call
this.api()
in any repository to get the OpenAPI-generated API client already configured with the right base URL, and auth and user agent headers. For example, to add support to get an experiment by ID to the generatedExperimentsRepository
, we can add a method with a similar (or the same) signature and forward it:The
BaseRepository
implements the OpenAPI configuration as well as other configuration:/api/v1
if left blankgrowthbook-cli/<cli-version>
is added to the user agent headerTesting these changes
Run
yarn build
then run all of the above-mentioned commands. Instead ofgrowthbook
for local development you'll need to run./bin/run
instead so./bin/run features list
.You can run
yarn build && ./bin/run features list > output.json
to put the features response into a fileoutput.json
.