npm package: @pietert/cyran
Description: Release Automation tool for Streetsmart
Author: PieterT2000
Latest version: 0.5.8

## Release automation

- [Setup](#setup)
  - [Install](#install)
  - [Configure](#configure)
- [Commands](#commands)
  - [Creating a release](#triggering-a-release)
  - [Checking if release exists in Jira](#checking-if-a-release-exists-in-jira)
  - [Sending out release planning or notes email](#sending-out-a-release-planning-or-release-notes-email)
  - [Manually registering the redirect urls](#manually-registering-the-redirect-urls)
  - [For help and more info](#for-help-and-more-info)
- [FAQ](#faq)

## Setup

#### Install

Using NPM

```bash
npm i -g @pietert/cyran
```

or using Yarn

```bash
yarn add -g @pietert/cyran
```

#### Configure

Now run

```node
cyran init
```

You will be asked for:

- Jira endpoint: this should be in the form of `https://company_name.atlassian.net`
- username: your email that you use to login to Jira
- apiToken: you can create your token [here](https://id.atlassian.com/manage-profile/security/api-tokens).
- git repository name
- Github username - the username you use to login to GitHub
- Github Personal Access Token - You can create one [here](https://github.com/settings/tokens)
- Jenkins endpoint - the url of the Jenkins build server
- Streetsmart API clientId - the clientId that is used to register the redirect urls
- IdentityServer apiKey - the apiKey that is used to register redirect urls.
- Lastly, you will be asked to authenticate using the Microsoft auth flow. This is required for the application to be able to send emails on your behalf.

## Commands

_Note: the alias for every command below is after the pipe character._

##### Triggering a release

```node
cyran release|rel [version]
```

##### Checking if a release exists in Jira

```node
cyran release-exists|re <version>
```

##### Sending out a release-planning or release-notes email

```node
cyran send-email|se <ReleaseEmailType> <version>
```

where the `ReleaseEmailType` parameter can be `'release-planning'` or `'release-notes'`

##### Manually registering the redirect urls

```node
cyran register-redirects|rr <version>
```

##### For help and more info

```node
cyran - h;
```

## FAQ

### I get node-gyp errors during install; how do I solve this?

This package relies on the `node-gyp` package. It is recommended to update this package by running `npm i -g node-gyp`. The latest node-gyp package requires you to have Python 3 installed and Microsoft Visual Studio 2015 or higher. If node-gyp can't find these two dependencies, run `npm config edit`. Add the following code to it and save the config.

```bash
python=[PATH_TO_PYTHON.exe]
msvs_version={YOUR_VISUAL_STUDIO_VERSION}
```

Please see this [SO answer](https://stackoverflow.com/a/59882818/9713831) for more info.

### The script can't connect to the Jenkins endpoint

Please make sure you have turned on a VPN connection if your Jenkins server is behind a VPN.

### Error `No project could be found with key 'STREET'.`

If you get the error `No project could be found with key 'STREET'.`, make sure you are logged in on Atlassian / JIRA with the Cyclomedia / Microsoft account. If you use for instance Trello on a personal email, it could be logged in with that user.

## TODO

- [ ] When script fails at a certain stage, save state so that when you restart the script it automatically resume where it left off.
- [ ] Replace `@azure/identity` package which hand-rolled auth solution to prevent requesting users to log in everytime they start a release.
- [ ] Check for new version of script on startup.
- [ ] Automate step 1 of the release procedure