npm package: @siddhanthm/koa
Description: Build Tool for Salesforce CPQ
Latest version: 1.1.3

<h1 align="center">
  <br>
  <img src="https://cdn-images-1.medium.com/max/1600/1*OPxB5Kttf1PmtF_-HZ4EgA.png" alt="Koa The Dog" width="100">
  <br><br>
  	Koa	
  <br>
  <br>
</h1>
<h4 align="center">The swiss army knife for QTC Engineering.</h4>
<br>

**Koa** is a swiss army knife for Salesforce CPQ engineering tasks from the 
Terminal to improve engineering productivity. The goal is to reduce toil and 
manual clicking work in the GUI that slows down actual work. 

## Getting Started

### Prerequisites

__Disclaimer:__ _Koa works best on macOS and Linux._

* Unix-like operating system (macOS or Linux)
* `git` should be installed
* `python` should be installed

### Basic Installation

koa is installed by running the following commands in your terminal.

```shell
npm install -g @siddhanthm/koa
```

## Using Koa

### koa briki
Open the salesforce cpq briki
```shell
$ koa briki
```

### koa build
Builds and transpiles the Javascript client-side code with Gulp.js.

```shell
$ koa build
Running gulp build...
```

Run this command with `-f` to fix node and bower dependecy issues automatically. This is helpful if you get `ERROR: Path is undefined` errors when pushing to scratch orgs.

```shell
$ koa build -f
Installing bower dependencies...
Installing npm dependencies...
Running gulp build...
```

### koa clean
Cleans all the merged github branches and expired sfdx orgs

```shell
$ koa clean
```

### koa connect
Connects a TeamCity-created scratch org to local SFDX environment, allowing changes to be pushed to those orgs.

```shell
$ koa connect
```

### koa console
Koa contains an APEX console that reads each line one at a time and then executes all lines when `run` or `print` is entered. To start the console, run:

<pre>
$ koa console -u <b>scratch-org-name</b>
</pre>

From there APEX commands run them on your scratch org. SOQL commands that start with a "[" will get executed immediately.

```shell
[511] > [SELECT Id FROM Product2]
(Product2:{Id=01t19000004ceAgAAI}, Product2:{Id=01t19000004ceAhAAI}, Product2:{Id=01t19000004ceAiAAI}, Product2:{Id=01t19000004ceAjAAI}, Product2:{Id=01t19000004ceAkAAI}, Product2:{Id=01t19000004ceAlAAI}, Product2:{Id=01t19000004ceAmAAI}, Product2:{Id=01t19000004ceAnAAI}, Product2:{Id=01t19000004ceAoAAI}, Product2:{Id=01t19000004ceApAAI}, ...)
[511] > List<Product2> products = new List<Product2>();
[511] > products.add(new Product2(Name='Nick'));
[511] > print(products);
(Product2:{Name=Nick})
[511] >
```

### koa delete
Delete a local scratch org.

<pre>
$ koa delete -u <b>scratch-org-name</b>
Deleting scratch-org-name...
Enqueue scratch org with name: scratch-org-name for deletion?  Are you sure (y/n)?: y
Successfully marked scratch org scratch-org-name for deletion
</pre>

### koa display
Display information about a scratch org.

<pre>
$ koa display -u <b>scratch-org-name</b>
Displaying details for scratch-org-name...
=== Org Description
KEY              VALUE
───────────────  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Access Token     00D190000009VFq!AR8AQEQJruhwDR65rOP.yt4p_Zw.Rwm6x7LWUsWMExNhlKw0MlcOb8h7wcodhNxf5xjoKXOrToYx7G7AfNYNd27L2VvvOrae
Alias            devNoErrorOnNewQuote
Client Id        SalesforceDevelopmentExperience
Created By       siddhanth.maheshwari@steelbrick.com
Created Date     2019-01-21T21:21:42.000+0000
Dev Hub Id       siddhanth.maheshwari@steelbrick.com
Edition          Developer
Expiration Date  2019-02-20
Id               00D190000009VFqEAM
Instance Url     https://platform-innovation-1185-dev-ed.cs24.my.salesforce.com/
Org Name         CPQ SFDX
Password         3o-Ar]F0Vr
Status           Active
Username         test-f9tschut68cl@example.com
</pre>

### koa log
Tail live logs for a scratch org. These logs only show SOQL queries and user debug statements, filtering out a lot of junk logs provided by sfdx.

<pre>
$ koa log -u <b>scratch-org-name</b>
--- (210) Logging session started ---
21:50:53.0 (483449) | CODE_UNIT_STARTED | SBQQ.ServiceRouter.load(String)
21:50:53.0 (178776187) | CODE_UNIT_FINISHED | SBQQ.ServiceRouter.load(String)
21:50:53.0 (565893) | CODE_UNIT_STARTED | SBQQ.ServiceRouter.load(String)
21:50:54.428 (1437224689) | USER_DEBUG | {"queryInfo":{}}
21:50:54.428 (1439665104) | CODE_UNIT_FINISHED | SBQQ.ServiceRouter.load(String)
21:50:53.0 (225805) | CODE_UNIT_STARTED | SBQQ.ServiceRouter.load(String)
...
</pre>

### koa open
Opens a given scratch org and logs in.

<pre>
$ koa open -u <b>scratch-org-name</b>
$ koa open -d
</pre>

### koa org
Create a scratch org off the current branch, push default CPQ configurations and data.

<pre>
$ koa org -n <b>scratch-org-name</b>
</pre>

### koa orgs
To see all local scratch orgs, run:

```shell
$ koa orgs
```

### koa package
Generates a SFDX package and package version.

```shell
$ koa package
```

### koa push
Pushes local changes to given scratch org.

<pre>
$ koa push -u <b>scratch-org-name</b>
</pre>

### koa revive
Automatically create a scratch org from any version of CPQ with a version number or git SHA. This can be useful if you need to reproduce an issue in a v26 scratch org for instance.

To revive an old CPQ version, navigate outside your CPQ repo into another folder you'd like to clone an older version of CPQ. Then run:

```shell
$ koa revive 
23.0.20         25.0.9          27.0            208.1           212.0           216.10.1
23.0.23         25.0.10         27.0.1          208.1.1         212.1           216.10.2
23.0.24         25.0.11         27.0.3          208.2           212.2           216.10.3
23.0.25         25.0.12         27.0.4          208.3           212.3           216.10.4
23.0.26         25.0.13         27.0.5          208.4           212.4           218.1.0
23.1            25.0.14         27.0.7          208.5           212.5           218.2.0
23.1.1          25.0.15         27.0.7.1        208.6           212.6           218.3.0
23.2.1          25.0.16         27.0.7.2        208.6.1         212.8           218.5.0
23.2.3          25.0.19         27.0.14         208.6.2         212.9           218.6.0
23.4.1          25.0.20         27.0.15         208.7           212.10          218.7.0
23.5            25.1            27.0.16         208.8           212.11          218.8.0
Which version would you like to revive from? 27.0
Checking out git SHA (877deea76a891d64f782cc7f18fea788af138b84)...
...
```

To revive from a specific git SHA commit, run:

<pre>
$ koa revive -s <b>sha-number</b>
</pre>

### koa run
Run APEX scripts on a scratch org.

<pre>
$ koa run script.apex -u <b>scratch-org-name</b> 
Hello, world
</pre>

### koa service-cloud
Create a CPQ Service Cloud scratch org.

<pre>
koa service-cloud -u <b>scratch-org-name</b>
</pre>

### koa set-default
Sets the <b>scratch-org-name</b> as the default scratch org

<pre>
koa set-default -u <b>scratch-org-name</b>
</pre>

### koa sfm
Automatically clicks the SFM tile in Aloha for you.

<pre>
koa sfm
</pre>

### koa test
Run APEX tests. Provide either the test class name or additionally specify the
exact test methods to run as well in a comma-separated list.

<pre>
koa test -u <b>scratch-org-name</b> <b>TestClassName,AnotherTestClassName.TestMethodName</b>
</pre>

### koa trustmaster
Spins up multiple scratch orgs at the same time in various CPQ versions,
allowing you to QA bugs in different CPQ versions as a Trustmaster.

<pre>
$ koa trustmaster
What is your dev hub email address? <b>youremail@steelbrick.com</b>
Starting trustmaster...
....
All scratch orgs created.
</pre>

### koa user
Creates a new user for a given scratch org.

<pre>
koa user -n <b>user-name</b> -u <b>scratch-org-name</b>
</pre>

### koa userinfo
Displays user information for a given user.

<pre>
koa userinfo -n <b>user-name</b>
</pre>

### koa users
Displays all the users for a given scratch org.

<pre>
koa users -u <b>scratch-org-name</b>
</pre>

### koa web-test
Automatically setup and run the Selenium web test environment with the following command:

```shell
koa web-test
```

Specific tests can be run with:

<pre>
koa web-test <b>test-name</b>
</pre>

### Updates

TODO: Koa will automatically update itself every few weeks. If you'd like to upgrade at any point in time you just need to run:

```shell
koa upgrade
```

Magic! 🎉

### Contributions
I'm far from being a CPQ expert and suspect there are many ways to improve – if you have ideas on how to make the tool easier to maintain (and faster), don't hesitate to fork and send pull requests!