Skip to content

Commit

Permalink
Merge pull request #158 from mean-expert-official/development
Browse files Browse the repository at this point in the history
Release 2.1.0-beta.11 🚀
  • Loading branch information
jonathan-casarrubias committed Oct 18, 2016
2 parents adaca80 + a617221 commit 68c9344
Show file tree
Hide file tree
Showing 24 changed files with 227 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "6"
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

This file is created to keep history of the LoopBack SDK Builder, it does not consider or keeps any history of its parent module `loopback-sdk-angular`.

## Release 2.1.0-beta.11

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/157
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/155
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/154
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/153
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/152
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/151
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/148
- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/147

## Release 2.1.0-beta.10

- Fix: https://github.com/mean-expert-official/loopback-sdk-builder/issues/142
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[![Build Status](https://travis-ci.org/mean-expert-official/loopback-sdk-builder.svg?branch=development)](https://travis-ci.org/mean-expert-official/loopback-sdk-builder)

![LoopBack SDK Builder](https://storage.googleapis.com/mean-expert-images/sdk-builder.jpg)

LoopBack SDK Builder
LoopBack SDK Builder
==================


The [@mean-expert/loopback-sdk-builder](https://www.npmjs.com/package/@mean-expert/loopback-sdk-builder) is a community driven module forked from the official `loopback-sdk-angular` and refactored to support [Angular 2](http://angular.io).

The [LoopBack SDK Builder](https://www.npmjs.com/package/@mean-expert/loopback-sdk-builder) will explore your [LoopBack Application](http://loopback.io) and will automatically build everything you need to start writing your [Angular 2 Applications](http://angular.io) right away. From Interfaces and Models to API Services and Real-time communications.
Expand Down
1 change: 1 addition & 0 deletions bin/lb-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ console.log(chalk.green('* CONTRIBUTORS
console.log(chalk.green('* João Ribeiro <http://jonnybgod.ghost.io> *'));
console.log(chalk.green('* Nikolay Matiushenkov <https://github.com/mnvx> *'));
console.log(chalk.green('* Sylvain Dumont <https://www.weboaks.com> *'));
console.log(chalk.green('* Yonggang Luo <https://github.com/lygstate> *'));
console.log(chalk.green('* *'));
console.log(chalk.green('* ORIGINALLY FORKED FROM *'));
console.log(chalk.green('* Miroslav Bajtos\' <[email protected]> *'));
Expand Down
4 changes: 2 additions & 2 deletions lib/angular2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ module.exports = function generate(ctx) {
{ module: 'ErrorHandler', from: './error.service'},
{ module: 'LoopBackAuth', from: './auth.service'},
{ module: 'LoopBackConfig', from: '../../lb.config'},
{ module: 'AccessToken', from: '../../models'},
{ module: 'AccessToken', from: '../../models/index'},
{ module: 'Observable', from: 'rxjs/Observable' },
{ module: 'ErrorObservable', from: 'rxjs/observable/ErrorObservable' },
{ module: 'rxjs/add/operator/catch' },
Expand Down Expand Up @@ -505,7 +505,7 @@ module.exports = function generate(ctx) {
* Testing if the param is route type
*/
function paramIsRoute(param) {
return (param.http && param.http.source === 'path') || (param.arg && param.arg.match(/(id|fk|file|container)/));
return (param.http && param.http.source === 'path') || (param.arg && param.arg.match(/(^id$|fk|file|container)/));
}
/**
* @method paramIsFunction
Expand Down
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "@mean-expert/loopback-sdk-builder",
"version": "2.1.0-beta.10",
"version": "2.1.0-beta.11",
"description": "Tool for auto-generating Software Development Kits (SDKs) for LoopBack",
"bin": {
"lb-sdk": "bin/lb-sdk"
},
"main": "index.js",
"scripts": {
"prepublish": "",
"test": "npm run test:angular2",
"pretest": "cd tests/angular2 && npm install",
"test:angular2": "cd tests/angular2 && ng lint && npm run test"
"test": "npm run load:api & npm run test:angular2",
"pretest": "cd tests/angular2 && npm install && npm install ../../ && npm run build:sdk",
"load:api": "cd tests/angular2 && NODE_ENV=testing node loopback/server",
"test:angular2": "cd tests/angular2 && npm test"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,6 +45,11 @@
"name": "Sylvain Dumont",
"email": "[email protected]",
"url": "https://www.weboaks.com"
},
{
"name": "Yonggang Luo",
"email": "[email protected]",
"url": "https://github.com/lygstate"
}
],
"license": "MIT",
Expand Down
34 changes: 34 additions & 0 deletions tests/angular2/.github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# How to contribute

I'm really glad you're reading this, volunteer developers to help this project are always welcome.

If you haven't already, follow me ([@johncasarrubias](irc://chat.freenode.net/opengovernment) on twitter). I want you to keep informed about new features and tutorials.

Here are some important resources:

* [MEAN Expert Blog](http://mean.expert) tutorials about the MEAN Stack.
* [WIKI](https://github.com/mean-expert-official/loopback-sdk-builder/wiki) official wiki documentation.
* [Angular 2 Testing](https://angular.io/docs/ts/latest/guide/testing.html) official documentation for testing environment.
* Bugs? [GitHub Issues](https://github.com/mean-expert-official/loopback-sdk-builder/issues) is where to report them

## Testing

Tests are being created and excecuted by using the Angular-CLI Tool, please refer to the official documentation.

````sh
$ cd to/loopback-sdk-builder
$ npm test
````

## Submitting changes

Please send a [GitHub Pull Request](https://github.com/mean-expert-official/loopback-sdk-builder/pull/new/master) with a clear list of what you've done (read more about [pull requests](http://help.github.com/pull-requests/)). When you send a pull request, we will love you forever if you include RSpec examples. We can always use more test coverage. Please follow our coding conventions (below) and make sure all of your commits are atomic (one feature per commit).

Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this:

$ git commit -m "A brief summary of the commit
>
> A paragraph describing what changed and its impact."

Thanks,
Jonathan Casarrubias, [MEAN Expert](http://mean.expert).
33 changes: 27 additions & 6 deletions tests/angular2/common/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,42 @@ module.exports = function (Room) {
}
);

Room.greetPost = greet;

// We receive 3 copies of the body from loopback, not sure why
// I would expect body.a, body.b and body.c in 1 object param.
Room.greetPost = (b1, b2, b3, next) => {
next(null, `${b1.a}:${b2.b}:${b3.c}`);
};

Room.remoteMethod(
'greetPost',
{
accepts: [
{ arg: 'a', type: 'string' },
{ arg: 'b', type: 'string' },
{ arg: 'c', type: 'string' }
{ arg: 'a', type: 'object', http: { source: 'body' }},
{ arg: 'b', type: 'object', http: { source: 'body' }},
{ arg: 'c', type: 'object', http: { source: 'body' }}
],
returns: { arg: 'greeting', type: 'string' },
returns: { arg: 'greeting', type: 'object' },
http: { path: '/who', verb: 'post' }
}
);

Room.singleParamPost = function (body, next) {
next(null, body);
};

Room.remoteMethod(
'singleParamPost',
{
accepts: {
arg: 'param',
type: 'object',
http: { source: 'body' }
},
returns: { arg: 'param', type: 'object', root: true },
http: { path: '/single-param-post', verb: 'post' }
}
);

Room.greetGet = greet;

Room.remoteMethod(
Expand Down
3 changes: 2 additions & 1 deletion tests/angular2/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = function (config) {
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma')
],
Expand All @@ -32,7 +33,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
browsers: ['PhantomJS'],
singleRun: false
});
};
25 changes: 25 additions & 0 deletions tests/angular2/loopback/boot/ng2finder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var net = require('net')

module.exports = function(app) {
if (process.NODE_ENV !== 'testing') return;
var testing = false;
var interval = setInterval(function () {
isPortTaken(9876, function (err, taken) {
if (!testing && taken) testing = true;
if (testing && !taken) process.exit()
})
}, 1000);
};

var isPortTaken = function(port, fn) {
var tester = net.createServer()
.once('error', function (err) {
if (err.code != 'EADDRINUSE') return fn(err)
fn(null, true)
})
.once('listening', function() {
tester.once('close', function() { fn(null, false) })
.close()
})
.listen(port)
}
8 changes: 6 additions & 2 deletions tests/angular2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
"lint": "tslint \"src/**/*.ts\"",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"test": "node loopback/server.js & ng test",
"build:sdk": "./node_modules/.bin/lb-sdk loopback/server.js src/app/shared/sdk -i enabled"
"pretest": "ng lint",
"test": "ng test --watch=false",
"build:sdk": "./node_modules/.bin/lb-sdk loopback/server.js src/app/shared/sdk -i enabled -w enabled"
},
"private": true,
"dependencies": {
Expand All @@ -21,6 +22,7 @@
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@mean-expert/loopback-component-realtime": "^1.0.0-beta.5",
"@types/socket.io-client": "^1.4.27",
"compression": "^1.0.3",
"config-chain": "^1.1.10",
Expand Down Expand Up @@ -51,7 +53,9 @@
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.2",
"karma-remap-istanbul": "^0.2.1",
"phantomjs": "^2.1.7",
"protractor": "4.0.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/angular2/src/app/access/access.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ const accessRoutes: Routes = [
}
];

export const accessRouting: ModuleWithProviders = RouterModule.forChild(accessRoutes);
export const accessRouting: ModuleWithProviders = RouterModule.forChild(accessRoutes);
4 changes: 2 additions & 2 deletions tests/angular2/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class AppComponent {
) {
this.logger.info('LoopBack SDK Builder - Test Application');
// Simple IO Test
//this.realTime.IO.emit('hello', 'world');
//this.realTime.IO.on('hello').subscribe((msg: any) => this.logger.info('REALTIME: ', msg));
// this.realTime.IO.emit('hello', 'world');
// this.realTime.IO.on('hello').subscribe((msg: any) => this.logger.info('REALTIME: ', msg));
// Simple FireLoop set and get examples.
let RoomReference: FireLoopRef<Room> = this.realTime.FireLoop.ref<Room>(Room);
// This will get the list of results and fire every time there is new data.
Expand Down
1 change: 0 additions & 1 deletion tests/angular2/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { SDKModule } from './shared/sdk/index';
import { routing, appRoutingProviders } from './app.routing';
Expand Down
1 change: 0 additions & 1 deletion tests/angular2/src/app/app.routing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { RoomComponent } from './room/room.component';
import { AuthGuard } from './shared/auth.guard';

const appRoutes: Routes = [
Expand Down
10 changes: 10 additions & 0 deletions tests/angular2/src/app/room-service.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ describe('Service: Room Service', () => {
})
));

it('should fetch filter as object from single-param post method',
async(inject([RoomApi], (roomApi: RoomApi) => {
let param = { child: 'filtered' };
return roomApi.singleParamPost(param).subscribe((result: { child: string, param: undefined }) => {
expect(result.param).toBe(undefined);
expect(result.child).toBe(param.child);
});
})
));

it('should include multiple layers',
async(inject([RoomApi, MessageApi], (roomApi: RoomApi, messageApi: MessageApi) => {
let room: Room = new Room({ name: Date.now().toString() });
Expand Down
2 changes: 1 addition & 1 deletion tests/angular2/src/app/room/room.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ const roomRoutes: Routes = [
}
];

export const roomRouting: ModuleWithProviders = RouterModule.forChild(roomRoutes);
export const roomRouting: ModuleWithProviders = RouterModule.forChild(roomRoutes);
Loading

0 comments on commit 68c9344

Please sign in to comment.