# titaniumlib

> Titanium SDK Library

Latest version **3.0.1** (published 2020-09-15) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install titaniumlib
pnpm add titaniumlib
yarn add titaniumlib
bun add titaniumlib
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2020-09-15 |
| First published | 2018-03-12 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.10.0 |
| Dependencies | 11 |
| Unpacked size | 136.3 KB |
| Known vulnerabilities | 0 (+3 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Axway, Inc. |
| Maintainers | cb1kenobi, appcelerator, awam |
| Keywords | axway, appcelerator, titanium, mobile |

## Links

- npm: https://www.npmjs.com/package/titaniumlib
- Repository: https://github.com/appcelerator/titaniumlib
- Issues: https://github.com/appcelerator/titaniumlib/issues
- npm.io page: https://npm.io/package/titaniumlib

## Dependencies (11)

- [tmp](https://npm.io/package/tmp.md) ^0.1.0
- [yauzl](https://npm.io/package/yauzl.md) ^2.10.0
- [semver](https://npm.io/package/semver.md) ^7.1.3
- [request](https://npm.io/package/request.md) ^2.88.2
- [appcd-fs](https://npm.io/package/appcd-fs.md) ^1.1.10
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [pluralize](https://npm.io/package/pluralize.md) ^8.0.0
- [snooplogg](https://npm.io/package/snooplogg.md) ^2.3.3
- [appcd-path](https://npm.io/package/appcd-path.md) ^1.1.10
- [appcd-util](https://npm.io/package/appcd-util.md) ^2.0.2
- [source-map-support](https://npm.io/package/source-map-support.md) ^0.5.16

## Recent versions

- 3.0.1 (latest) — 2020-09-15
- 3.0.0 — 2020-01-14
- 2.1.0 — 2020-01-13
- 2.0.1 — 2019-09-27
- 2.0.0 — 2019-08-14
- 1.4.0 — 2019-07-08
- 1.3.1 — 2019-04-24
- 1.3.0 — 2019-04-24
- 1.2.0 — 2019-03-29
- 1.1.1 — 2019-03-08
- 1.1.0 — 2019-03-06
- 1.0.0 — 2018-03-22
- 0.0.0 — 2018-03-12

## README

# Titanium SDK Library

A library of Titanium SDK platform APIs.

### Features

 * Detects installed Titanium SDKs and modules
 * Install or uninstall a Titanium SDKs

### Roadmap

 * Create, build, and clean projects
 * `tiapp.xml` reader/writer
 * Build pipeline
 * Asset management

## Options

`titaniumlib`'s options are set via the `options` export.

```js
import { options } from 'titaniumlib';

options.searchPaths = '/some/path';
```

| Name                           | Description                                                                            | Type                    | Default |
| ------------------------------ | -------------------------------------------------------------------------------------- | ----------------------- | ------- |
| `options.searchPaths`          | Additional path or list of Titanium locations to search for Titanium SDKs and modules. | String or Array[String] | `[]`    |
| `options.network.agentOptions` | Specific agent options like the SSL protocol. See the [agentOptions](https://www.npmjs.com/package/request#using-optionsagentoptions) for more info. | Object | |
| `options.network.caFile`       | Local path to a certificate authority file.                      | String | |
| `options.network.certFile`     | Local path to a PEM formatted certificate.                       | String | |
| `options.network.httpProxy`    | The URL for proxying http requests.                              | String | |
| `options.network.httpsProxy`   | The URL for proxying https requests.                             | String | |
| `options.network.keyFile`      | Local path to a PEM formatted private key.                       | String | |
| `options.network.passphrase`   | The passphrase for the key file.                                 | String | |
| `options.network.strictSSL`    | When `true`, requires SSL certificates be valid.                 | Boolean | `true` |
| `options.sdk.searchPaths`      | Additional path or list of paths to search for Titanium SDKs.    | String or Array[String] | `[]` |
| `options.sdk.urls.branches`    | The URL for the list of branches.                                | String | |
| `options.sdk.urls.build`       | The URL for downloading a CI build `.zip` file.                  | String | |
| `options.sdk.urls.builds`      | The URL for the list of CI builds.                               | String | |
| `options.sdk.urls.releases`    | The URL for the list of GA releases.                             | String | |
| `options.module.searchPaths`   | Additional path or list of paths to search for Titanium modules. | String or Array[String] | `[]` |

### Search Paths

There are different kinds of search paths. `options.searchPaths` is used to find Titanium installation directories. These paths would contain the `"mobilesdk"` and `"modules"` directory. Generally speaking, you probably should use `options.sdk.searchPaths` instead.

`options.sdk.searchPaths` are paths that contain actual SDK directories such as `"7.5.1.GA"`. These paths should _not_ point to the actual SDK directory, but rather its parent directory. `titaniumlib` will only scan the search paths and does not recursively descend directories.

## SDK

```js
import { sdk } from 'titaniumlib';
```

### `sdk.getBranches()`

Retrieves the list of CI branches.

Returns `Promise<Object>`.

```js
const branches = await sdk.getBranches();
console.log(branches);
```

```js
{
  defaultBranch: 'master',
  branches: [
      '3_5_X',
     '4_0_X',
     ...
     '8_0_X',
     'master',
     'next'
  ]
}
```

### `sdk.getBuilds([branch])`

Retreives a list of Titanium SDK continuous integration builds.

| Argument | Description             | Type   | Default    |            |
| -------- | ----------------------- | ------ | ---------- | ---------- |
| `branch` | The branch to retreive. | String | `"master"` | _optional_ |

Returns `Promise<Object>`.

```js
const builds = await sdk.getBuilds('8_0_X');
console.log(builds);
```

```js
{
  ...
  '8.1.0.v20190307130759': {
    version: '8.1.0',
    ts: '20190307130759',
    githash: '60e97ceeb124a20fb374c8a4ed4c2b2b6983831c',
    date: 2019-03-07T13:07:59.000Z,
    url: 'http://builds.appcelerator.com/mobile/master/mobilesdk-8.1.0.v20190307130759-osx.zip'
  },
  ...
}
```

### `sdk.getInstalledSDKs([force])`

Detects installed Titanium SDKs.

| Argument | Description                                             | Type    | Default |            |
| -------- | ------------------------------------------------------- | ------- | ------- | ---------- |
| `force`  | When `true`, bypasses the cache and redetects the SDKs. | Boolean | `false` | _optional_ |

Returns `Array.<TitaniumSDK>`.

```js
const sdks = await sdk.getInstalledSDKs();
console.log(sdks);
```

```js
[
  TitaniumSDK {
    name: '8.0.0',
    manifest: {}
      name: '8.0.0',
        version: '8.0.0',
        moduleAPIVersion: {
          android: '4',
          iphone: '2',
          windows: '6'
       },
       githash: '9bcd36593d',
       platforms: [ 'android', 'iphone' ]
    },
    path: '/Users/USER/Library/Application Support/Titanium/mobilesdk/osx/8.0.0'
  }
]
```

### `sdk.getPaths()`

Returns a list of possible SDK install paths.

Returns `Array.<String>`.

```js
const paths = sdk.getPaths();
console.log(paths);
```

```js
[
  '/Users/USER/Library/Application Support/Titanium/mobilesdk/osx',
  '/Library/Application Support/Titanium/mobilesdk/osx'
]
```

### `sdk.getReleases([noLatest])`

Retreives a map of Titanium SDK versions to release info including the download URL. By default,
the latest version is added to the map of releases.

| Argument   | Description                                              | Type    | Default |            |
| ---------- | -------------------------------------------------------- | ------- | ------- | ---------- |
| `noLatest` | When `true`, it does not determine the 'latest' release. | Boolean | `false` | _optional_ |

Returns `Promise<Object>`.

```js
const releases = await sdk.getReleases();
console.log(releases);
```

```js
{
  '7.5.1.GA': {
    version: '7.5.1',
    url: 'https://builds.appcelerator.com/mobile-releases/7.5.1/mobilesdk-7.5.1.GA-osx.zip'
  },
  latest: {
    version: '7.5.1',
    url: 'https://builds.appcelerator.com/mobile-releases/7.5.1/mobilesdk-7.5.1.GA-osx.zip'
  }
}
```

### `sdk.install(params)`

Install a Titanium SDK from either a URI or version. A URI may be either a local file, a URL, an
SDK version, a CI branch, or a CI branch and build hash.

| Argument | Description         | Type   | Default |            |
| -------- | ------------------- | ------ | ------- | ---------- |
| `params` | Various parameters. | Object | `{}`    | _optional_ |

> Note: All parameters are optional.

| Property      | Description                                                                 | Type   | Default           |
| ------------- | --------------------------------------------------------------------------- | ------ | ----------------- |
| `downloadDir` | When `uri` is a URL, release, or build, download the SDK to this directory. | String | A temp directory. |
| `installDir`  | The path to install the SDK.  | String |       The first path in the list of Titanium install locations. |
| `keep`        | When `true` and `uri` is a URL, release, or build, and `downloadDir` is specified, then the downloaded SDK `.zip` file is not deleted after install. | Boolean | `false` |
| `overwrite`   | When `true`, overwrites an existing Titanium SDK installation, otherwise an error is thrown. Note that if `overwrite=false`, it will not throw an error if a module is already installed. | Boolean | `false` |
| `uri`         | A URI to a local file or remote URL to download. | String | `"latest"` |

Returns `Promise<String>`.

#### Install from local file

```js
await sdk.install({
    uri: 'file:///path/to/sdk.zip'
});
```

```js
await sdk.install({
    uri: '/path/to/sdk.zip'
});
```

#### Install from URL

```js
await sdk.install({
    uri: 'https://builds.appcelerator.com/mobile/master/mobilesdk-8.1.0.v20190307130759-osx.zip'
});
```

#### Install release

```js
await sdk.install({
    uri: '7.5.0.GA'
});
```

```js
await sdk.install({
    uri: '7.5.0'
});
```

```js
await sdk.install({
    uri: 'latest'
});
```

#### Install latest CI build by branch

```js
await sdk.install({
    uri: 'master'
});
```

#### Install specific CI build by branch and git hash

```js
await sdk.install({
    uri: 'master:60e97ceeb124a20fb374c8a4ed4c2b2b6983831c'
});
```

#### Install specific CI build by git hash

> Note: This is horribly inefficient. It checks every single branch for a match. You should
> probably never do this.

```js
await sdk.install({
    uri: '60e97ceeb124a20fb374c8a4ed4c2b2b6983831c'
});
```

### `sdk.uninstall(nameOrPath)`

Deletes an installed Titanium SDK by name or path.

| Argument | Description                            | Type   |
| -------- | -------------------------------------- | ------ |
| `nameOrPath` | The SDK name or path to uninstall. | String |

Returns `Promise<Array<TitaniumSDK>>`. If SDK is not found, an error is thrown with a `err.code` of `ENOTFOUND`.

```js
const sdk = await sdk.uninstall('7.5.1.GA');
console.log(sdk);
```

```js
[
  TitaniumSDK {
    name: '7.5.1.GA',
    manifest: {}
      name: '7.5.1.GA',
        version: '7.5.1',
        moduleAPIVersion: {
          android: '4',
          iphone: '2',
          windows: '6'
       },
       githash: '4b82d9d6b2',
       platforms: [ 'android', 'iphone' ]
    },
    path: '/Users/USER/Library/Application Support/Titanium/mobilesdk/osx/7.5.1.GA'
  }
]
```

## Modules

```js
import { modules } from 'titaniumlib';
```

### `modules.getInstalledModules([force])`

Detects installed Titanium modules.

| Argument | Description                                                | Type    | Default |            |
| -------- | ---------------------------------------------------------- | ------- | ------- | ---------- |
| `force`  | When `true`, bypasses the cache and redetects the modules. | Boolean | `false` | _optional_ |

Returns `Object` where `platform` > `module name` > `version` > `module info`.

```js
const mods = await modules.getInstalledModules();
console.log(mods);
```

```js
{
  "android": {
    "facebook": {
      "7.3.1": {
        "path": "/Users/USER/Library/Application Support/Titanium/modules/android/facebook/7.3.1",
        "platform": "android",
        "version": "7.3.1",
        "apiversion": 4,
        "architectures": "arm64-v8a armeabi-v7a x86",
        "description": "facebook",
        "author": "Mark Mokryn and Ashraf A. S. (Appcelerator)",
        "license": "Apache License Version 2.0",
        "copyright": "Copyright (c) 2014 by Mark Mokryn, Copyright (c) 2009-present by Appcelerator",
        "name": "Facebook",
        "moduleid": "facebook",
        "guid": "e4f7ac61-1ee7-44c5-bc27-fa6876e2dce9",
        "minsdk": "7.0.0"
      }
    }
  },
  "commonjs": {
    ...
  },
  "iphone": {
   ...
  },
  "windows": {
    ...
  }
}
```

### `modules.getPaths()`

Returns a list of possible Titanium module install paths.

Returns `Array.<String>`.

```js
const paths = modules.getPaths();
console.log(paths);
```

```js
[
  '/Users/USER/Library/Application Support/Titanium/modules',
  '/Library/Application Support/Titanium/modules'
]
```

## Project

Not available yet.

## License

This project is open source under the [Apache Public License v2][1] and is developed by
[Axway, Inc](http://www.axway.com/) and the community. Please read the [`LICENSE`][1] file included
in this distribution for more information.

[1]: https://github.com/appcelerator/titaniumlib/blob/master/LICENSE

---
_Source: https://npm.io/package/titaniumlib · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
