Skip to content

1. Install Builder & Build SDK

Jonathan Casarrubias edited this page Aug 23, 2017 · 18 revisions

LoopBack SDK Builder

Installation

The @mean-expert/loopback-sdk-builder should be installed using NPM as follows:

$ cd to/loopback/project
$ npm install --save @mean-expert/{loopback-component-realtime,loopback-sdk-builder}

SDK Builder CLI Tool

The @mean-expert/loopback-sdk-builder provides you with a built-in command line tool that allows you to build Software Development Kits fully compatible with Angular 2 Applications written in TypeScript Language.

Since Angular 2 is able to run in different environments, you will need to configure the @mean-expert/loopback-sdk-builder according your environment and the following configuration options.

$ cd to/loopback/project
$ ./node_modules/.bin/lb-sdk

******************************************* LoopBack SDK Builder 2.0 *******************************************

Generate Client SDK for your LoopBack Application.
Usage:
 ./node_modules/.bin/lb-sdk server/server app/shared/sdk -d [ng2web | ng2native | ng2universal] -i [enabled | disabled] -v [enabled | strict | disabled]

Options:
  -l, --library        Client's library (angular2, react <todo>, ...)               [default: "angular2"]
  -d, --driver         Platform specific drivers (ng2web, ng2native, ng2universal)  [default: "ng2web"]
  -i, --io             Enable PubSub, IO and FireLoop functionality                 [default: "enabled"]
  -w, --wipe           Automatically wipe SDK Directory                             [default: "disabled"]
  -v,                  Add default values in models                                 [default: "disabled"]
  -f                   Generate only FireLoop SDK + Auth Services                   [default: "disabled"]                        

IMPORTANT WARNING

The @mean-expert/loopback-sdk-builder will wipe everything inside the path/to/sdk directory you define, please make sure you always point to app/shared/sdk and not to other critical directories where you don't want to lose any information.

Generate Angular 2 SDK for Web and Progressive Apps

The default options will create an Angular 2 SDK for Web.

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk

Is equivalent to

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -l angular2 -d ng2web -i disabled

Generate Angular 2 SDK for NativeScript

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -d ng2native

Is equivalent to

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -l angular2 -d ng2native -i disabled

Enable Real Time Communication

FireLoop.io

To enable you will need to add the --io enabled or -i enabled flag.

Angular 2 for Web

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -d ng2web -i enabled

NativeScript 2

$ ./node_modules/.bin/lb-sdk server/server.js /path/to/client/sdk -d ng2native -i enabled

Recomended Use

Add a script within package.json

{
  "scripts": {
    "build:sdk": "./node_modules/.bin/lb-sdk server/server path/to/ng2-app/src/app/shared/sdk -d [ng2web | ng2native | ng2universal] -i [enabled | disabled]"
  }
}

then:

$ cd to/loopback/project
$ npm run build:sdk