3.0.1 • Published 4 years ago

titaniumlib v3.0.1

Weekly downloads
244
License
Apache-2.0
Repository
github
Last release
4 years ago

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.

import { options } from 'titaniumlib';

options.searchPaths = '/some/path';
NameDescriptionTypeDefault
options.searchPathsAdditional path or list of Titanium locations to search for Titanium SDKs and modules.String or ArrayString[]
options.network.agentOptionsSpecific agent options like the SSL protocol. See the agentOptions for more info.Object
options.network.caFileLocal path to a certificate authority file.String
options.network.certFileLocal path to a PEM formatted certificate.String
options.network.httpProxyThe URL for proxying http requests.String
options.network.httpsProxyThe URL for proxying https requests.String
options.network.keyFileLocal path to a PEM formatted private key.String
options.network.passphraseThe passphrase for the key file.String
options.network.strictSSLWhen true, requires SSL certificates be valid.Booleantrue
options.sdk.searchPathsAdditional path or list of paths to search for Titanium SDKs.String or ArrayString[]
options.sdk.urls.branchesThe URL for the list of branches.String
options.sdk.urls.buildThe URL for downloading a CI build .zip file.String
options.sdk.urls.buildsThe URL for the list of CI builds.String
options.sdk.urls.releasesThe URL for the list of GA releases.String
options.module.searchPathsAdditional path or list of paths to search for Titanium modules.String or ArrayString[]

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

import { sdk } from 'titaniumlib';

sdk.getBranches()

Retrieves the list of CI branches.

Returns Promise<Object>.

const branches = await sdk.getBranches();
console.log(branches);
{
  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.

ArgumentDescriptionTypeDefault
branchThe branch to retreive.String"master"optional

Returns Promise<Object>.

const builds = await sdk.getBuilds('8_0_X');
console.log(builds);
{
  ...
  '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.

ArgumentDescriptionTypeDefault
forceWhen true, bypasses the cache and redetects the SDKs.Booleanfalseoptional

Returns Array.<TitaniumSDK>.

const sdks = await sdk.getInstalledSDKs();
console.log(sdks);
[
  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>.

const paths = sdk.getPaths();
console.log(paths);
[
  '/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.

ArgumentDescriptionTypeDefault
noLatestWhen true, it does not determine the 'latest' release.Booleanfalseoptional

Returns Promise<Object>.

const releases = await sdk.getReleases();
console.log(releases);
{
  '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.

ArgumentDescriptionTypeDefault
paramsVarious parameters.Object{}optional

Note: All parameters are optional.

PropertyDescriptionTypeDefault
downloadDirWhen uri is a URL, release, or build, download the SDK to this directory.StringA temp directory.
installDirThe path to install the SDK.StringThe first path in the list of Titanium install locations.
keepWhen true and uri is a URL, release, or build, and downloadDir is specified, then the downloaded SDK .zip file is not deleted after install.Booleanfalse
overwriteWhen 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.Booleanfalse
uriA URI to a local file or remote URL to download.String"latest"

Returns Promise<String>.

Install from local file

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

Install from URL

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

Install release

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

Install latest CI build by branch

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

Install specific CI build by branch and git hash

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.

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

sdk.uninstall(nameOrPath)

Deletes an installed Titanium SDK by name or path.

ArgumentDescriptionType
nameOrPathThe 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.

const sdk = await sdk.uninstall('7.5.1.GA');
console.log(sdk);
[
  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

import { modules } from 'titaniumlib';

modules.getInstalledModules([force])

Detects installed Titanium modules.

ArgumentDescriptionTypeDefault
forceWhen true, bypasses the cache and redetects the modules.Booleanfalseoptional

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

const mods = await modules.getInstalledModules();
console.log(mods);
{
  "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>.

const paths = modules.getPaths();
console.log(paths);
[
  '/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 and is developed by Axway, Inc and the community. Please read the LICENSE file included in this distribution for more information.