项目作者: telerik

项目描述 :
NativeScript Cli Extension
高级语言: TypeScript
项目地址: git://github.com/telerik/nativescript-starter-kits.git
创建时间: 2017-05-23T12:34:07Z
项目社区:https://github.com/telerik/nativescript-starter-kits

开源协议:Apache License 2.0

下载


nativescript-starter-kits

A NativeScript CLI extension for managing templates

Automatic Installation

You can install this extension using the Nativescript CLI

  1. $ tns extension install nativescript-starter-kits

Manual Installation and Development

Download the GIT repository in you favorite projects directory

  1. $ git clone git@github.com:NativeScript/nativescript-starter-kits.git

Run the following commands to install all dependencies, transpile all Ts files and to pack the extension.

  1. $ npm i --ignore-scripts
  2. $ npm i -g grunt-cli (only in case you do not have it installed globally)
  3. $ grunt
  4. $ grunt pack

These commands will create a .tgz file in the extension folder

Install the npm package

  1. $ tns extension install <path to nativescript-starter-kits>.tgz

Public API

Get proper nativescript reference

  1. const pathToPackage = require("global-modules-path").getPath("nativescript", "tns");
  2. const tns = require(pathToPackage);

Load all available extensions

  1. /**
  2. * @name loadExtensions
  3. * @description Loads all currently installed extensions
  4. * @return {Promise<any>[]} - On Success: Array of Promises, one for each installed extension
  5. */
  6. Promise.all(tns.extensibilityService.loadExtensions()).then((loadedExtensions) => {
  7. console.log("All extensions loaded successfully!");
  8. }).catch((error) => {
  9. console.error(error);
  10. });
Get details for all installed templates
  1. /**
  2. * @name getTemplates
  3. * @description List all available templates
  4. * @return {Promise<Array<any>>} - On Success: Array of Objects with Details about each template
  5. */
  6. tns.templateService.getTemplates().then((templates) => {
  7. console.log(templates);
  8. }).catch((error) => {
  9. console.error(error);
  10. });
Get details for a single App template
  1. /**
  2. * @name getAppTemplateDetails
  3. * @description The method returns details about a single app template.
  4. * @param {string} templateName - The name of the template
  5. * @returns {Promise<any>} - Object with details about the app template
  6. */
  7. getAppTemplateDetails(templateName: string): any;
  8. tns.templateService.getAppTemplateDetails("templateName").then((details) => {
  9. console.log(details);
  10. }).catch((error) => {
  11. console.error(error);
  12. });

Run tests

Before running the test you need to transpile all files and dependencies.

  1. $ grunt pack
  2. $ npm run test

Issues

If you have found an issue with this extension, please report the problem in the Issues section.