# Uhray App Scripts

This cli provide script functionality that we can use across all of our projects.

To install the CLI cloball, you run `npm install -g uhray-app-scripts`, then you can try:

```
$ uhray-app-scripts

  Usage: index [options] [command]

  Options:

    -v, --version                 output the version number
    -h, --help                    output usage information

  Commands:

    configure                     configure repo
    ionic_after_build [options]   Handle post build
    ionic_before_build [options]  Prepare everything before platform is added
    ionic_build [options]         Build IPA/APK
    ionic_post_install            Prepare everything in a local repository after install
```

However, more likely you will install in your project (`npm install --save-dev uhray-app-scripts`). Then you may configure your package.json file to use this. You'll also need to set up a `.uhray-app-scripts.json` file.

Platforms:

- [Ionic](#ionic)
- [Angular](#angular)
- [APIs](#apis)

## Ionic

There are four main commands related to ionic:

- `ionic_build` - this allows you to build the app on our C.I. so you don't need to maintain necessary binaries on your machine.
- `ionic_before_build` - This runs in the C.I. before build and does the following:
  - 1.  Updates the app icon to have a version banner
  - 1.  Installs all cordova modules
- `ionic_after_build` - This updates our delivery URL for clients if the build is from `master`.
- `ionic_post_install` - Copies our custom [Ionic Generators](src/templates/ionic_generators) so running the `ionic generate` command inserts code in our format.

### Configuring for Ionic

**Step 1** setting up the `.uhray-app-scripts.json` file:

The minimum requirements are below. There are some other undocumented configs we may expose later.

```js
{
  "bitrise": {
    "app": "<<Bitrise App Id>>",
    "token": "<<Bitrise build token>>"
    "fullToken": "Bitrise full token>>",
    "build": {
      "dev": {
        "ios_code_signing": "<<ios code signing for dev... full name, not just ID>>"
        "ios_provisioning_profile": "<<dev ios provisioning profile>>"
      }
    }
  }
}
```

**Step 2** adding commands to the packaing.json "scripts" section:

For example:

```json
    "build:dev:ios": "uhray-app-scripts ionic_build --platform ios",
    "build:dev:android": "uhray-app-scripts ionic_build --platform android",
    "ionic_before_build": "uhray-app-scripts ionic_before_build",
    "ionic_after_build": "uhray-app-scripts ionic_after_build",
    "postinstall": "uhray-app-scripts ionic_post_install"
```

## Angular

// coming soon

## APIs

// coming soon
