Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"max-len": ["error", 120, 2],
"indent": ["error", 4, { "SwitchCase": 1 }],
"semi": ["error", "never"],
"quotes": ["error", "single"],
"arrow-parens": ["error", "always"],
"no-param-reassign": "error",
"space-before-function-paren": ["error", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"object-curly-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"keyword-spacing": ["error", { "before": true }],
"no-multiple-empty-lines": [2, { "max": 1 }],
"@typescript-eslint/no-this-alias": [
"error",
{
"allowDestructuring": true,
"allowedNames": ["engine"]
}
]
},
"ignorePatterns": ["dist"]

"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"max-len": ["error", 120, 2],
"indent": ["error", 4, { "SwitchCase": 1 }],
"semi": ["error", "never"],
"quotes": ["error", "single"],
"arrow-parens": ["error", "always"],
"no-param-reassign": "error",
"space-before-function-paren": [
"error",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"object-curly-spacing": ["error", "always"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"keyword-spacing": ["error", { "before": true }],
"no-multiple-empty-lines": [2, { "max": 1 }],
"@typescript-eslint/no-this-alias": [
"error",
{
"allowDestructuring": true,
"allowedNames": ["engine"]
}
]
},
"ignorePatterns": ["dist"]
}
84 changes: 42 additions & 42 deletions .github/workflows/gitstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
name: gitStream workflow automation

on:
workflow_dispatch:
inputs:
client_payload:
description: The Client payload
required: true
full_repository:
description: the repository name include the owner in `owner/repo_name` format
required: true
head_ref:
description: the head sha
required: true
base_ref:
description: the base ref
required: true
installation_id:
description: the installation id
required: false
resolver_url:
description: the resolver url to pass results to
required: true
resolver_token:
description: Optional resolver token for resolver service
required: false
default: ''
workflow_dispatch:
inputs:
client_payload:
description: The Client payload
required: true
full_repository:
description: the repository name include the owner in `owner/repo_name` format
required: true
head_ref:
description: the head sha
required: true
base_ref:
description: the base ref
required: true
installation_id:
description: the installation id
required: false
resolver_url:
description: the resolver url to pass results to
required: true
resolver_token:
description: Optional resolver token for resolver service
required: false
default: ''

jobs:
gitStream:
timeout-minutes: 5
# uncomment this condition, if you dont want any automation on dependabot PRs
# if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
name: gitStream workflow automation
steps:
- name: Evaluate Rules
uses: linear-b/gitstream-github-action@v1
id: rules-engine
with:
full_repository: ${{ github.event.inputs.full_repository }}
head_ref: ${{ github.event.inputs.head_ref }}
base_ref: ${{ github.event.inputs.base_ref }}
client_payload: ${{ github.event.inputs.client_payload }}
installation_id: ${{ github.event.inputs.installation_id }}
resolver_url: ${{ github.event.inputs.resolver_url }}
resolver_token: ${{ github.event.inputs.resolver_token }}
gitStream:
timeout-minutes: 5
# uncomment this condition, if you dont want any automation on dependabot PRs
# if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
name: gitStream workflow automation
steps:
- name: Evaluate Rules
uses: linear-b/gitstream-github-action@v1
id: rules-engine
with:
full_repository: ${{ github.event.inputs.full_repository }}
head_ref: ${{ github.event.inputs.head_ref }}
base_ref: ${{ github.event.inputs.base_ref }}
client_payload: ${{ github.event.inputs.client_payload }}
installation_id: ${{ github.event.inputs.installation_id }}
resolver_url: ${{ github.event.inputs.resolver_url }}
resolver_token: ${{ github.event.inputs.resolver_token }}
24 changes: 11 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@

name: Unit Tests

on:
pull_request
on: pull_request

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn install
- run: yarn build
- run: yarn test
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- run: yarn install
- run: yarn build
- run: yarn test
20 changes: 9 additions & 11 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"require": [
"test-utils/init.js",
"ts-node/register",
"source-map-support/register"
],
"watch-extensions": [
"ts"
],
"recursive": true,
"reporter": "spec",
"timeout": 0
"require": [
"test-utils/init.js",
"ts-node/register",
"source-map-support/register"
],
"watch-extensions": ["ts"],
"recursive": true,
"reporter": "spec",
"timeout": 0
}
53 changes: 42 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
DevCycle CLI
=================
# DevCycle CLI

DevCycle CLI for interacting with DevCycle features from the command line.

Expand All @@ -10,45 +9,61 @@ The CLI can be customized in several ways using command-line args or by creating
[![License](https://img.shields.io/npm/l/@devcycle/cli.svg)](https://github.com/DevCycleHQ/cli/blob/main/package.json)

<!-- toc -->
* [DevCycle CLI](#devcycle-cli)
* [Setup](#setup)
* [Authentication](#authentication)
* [Usage](#usage)
* [Commands](#commands)
* [Command Topics](#command-topics)
* [Repo Configuration](#repo-configuration)
<!-- tocstop -->

# Setup

## Install the CLI:

```sh-session
$ npm install -g @devcycle/cli
```

# Authentication

Many of the CLI commands require DevCycle API authorization. There are several ways to provide these credentials.

## Using Access Tokens

### Login Command (preferred)

By using the [`login sso` command](docs/login.md#dvc-login-sso), the CLI will retrieve and store an access token, which is valid for 24 hours.

The [`login again` command](docs/login.md#dvc-login-again) can be used to retrieve a new access token using the saved project and organization without prompting for them.

This process will open browser windows to interact with the DevCycle universal login page. It will first obtain a personal access token, then prompt you to choose an organization. A second browser window is used to authenticate the CLI with your chosen organization.

To switch organizations once logged in, the [`org` command](docs/org.md) can be used.

### Repo Init Command (preferred)

The [`repo init` command](docs/repo.md#dvc-repo-init) behaves in the same way as `login sso`, but creates a [repo configuration file](#repo-configuration) and stores the project and organization choices there instead.

## Using Client Credentials

### Client Credentials in Auth File

Use the [`dvc status` command](docs/status.md#dvc-status) to find the configuration file location for your platform. The credentials can be stored in the file pointed to by the Auth config path. Create the file if it does not exist, with the following contents.

```yaml
clientCredentials:
client_id: <your client id>
client_secret: <your client secret>
client_id: <your client id>
client_secret: <your client secret>
```

This file should **not** be checked in to version control.

The default location is based on the [oclif configDir](https://oclif.io/docs/config)

If you intend to run the CLI using options that override config file locations, the [`dvc status` command](docs/status.md#dvc-status) command can be run with those options to confirm that the file locations are as expected.

## Project Selection

You also need to specify the default project ID for the CLI to use.
Expand All @@ -58,34 +73,45 @@ If there is a repo configuration file, the [`dvc diff`](docs/diff.md) and [`dvc
Otherwise, this is chosen during login or set using the [project select command](docs/projects.md#dvc-projects-select)

### Environment Variables

Set the following environment variables:

```sh-session
$ export DVC_CLIENT_ID=<your client id>
$ export DVC_CLIENT_SECRET=<your client secret>
$ export DVC_PROJECT_KEY=<your project key>
```

### Command-Line Arguments

The CLI can be run with the following arguments:

```sh-session
$ dvc --client-id=<your client id> --client-secret=<your client secret> --project=<your project key>
```

### Github Action

The Devcycle Github actions are configured with auth information through the `project-key`, `client-id` and `client-secret` configuration parameters. This is passed to the CLI via command line arguments.

# Usage

<!-- usage -->
```sh-session
$ npm install -g @devcycle/cli
$ dvc COMMAND
running command...
$ dvc (--version)
@devcycle/cli/4.2.11 darwin-x64 node-v18.16.0
@devcycle/cli/4.2.10 darwin-arm64 node-v19.5.0
$ dvc --help [COMMAND]
USAGE
$ dvc COMMAND
...
```
<!-- usagestop -->

# Commands

<!-- commands -->
# Command Topics

Expand All @@ -102,16 +128,20 @@ USAGE
* [`dvc projects`](docs/projects.md) - Access Projects with the Management API
* [`dvc repo`](docs/repo.md) - Manage repository configuration
* [`dvc status`](docs/status.md) - Check CLI status
* [`dvc targetingrule`](docs/targetingrule.md) - Create a new Environment for an existing Feature.
* [`dvc usages`](docs/usages.md) - Print all DevCycle variable usages in the current version of your code.
* [`dvc variables`](docs/variables.md) - Access or modify Variables with the Management API

<!-- commandsstop -->

# Repo Configuration

The following commands can only be run from the root of a configured repository
* [`dvc diff`](docs/diff.md)
* [`dvc usages`](docs/usages.md)
* [`dvc alias`](docs/alias.md)
* [`dvc cleanup`](docs/cleanup.md)

- [`dvc diff`](docs/diff.md)
- [`dvc usages`](docs/usages.md)
- [`dvc alias`](docs/alias.md)
- [`dvc cleanup`](docs/cleanup.md)

Many of the options available as command-line args can also be specified using a repo configuration file. The default
location for this file is `<REPO ROOT>/.devcycle/config.yml`.
Expand All @@ -132,10 +162,10 @@ org:
codeInsights:
## add additional names to check for when looking for instances of DVCClient from an SDK
clientNames:
- "dvcClient"
- 'dvcClient'
## map the values used in your code to the corresponding variable key in DevCycle
variableAliases:
'VARIABLES.ENABLE_V1': 'enable-v1'
'VARIABLES.ENABLE_V1': 'enable-v1'
## fully override the regex patterns used to match variables for a specific file extension
## each pattern should contain exactly one capture group which matches on the key of the variable
## make sure the captured value contains the entire key parameter (including quotes, if applicable)
Expand Down Expand Up @@ -163,6 +193,7 @@ e.g. `bin/run diff origin/main...`
To run the test suite, run `yarn test`

## Publishing a new version

1. Create a branch off of `main` and run `npm version patch` to bump the CLI version. Create a PR for these changes.
2. Once merged, create a new Github release with a tag for the latest version.
3. From `main`, publish to NPM `npm publish --access public`
Loading