Skip to content

Use package for projects #159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ src/nativescript-angular/**/*.js
.tscache
.nvm
.vscode
nativescript-angular*.tgz

tests/app/**/*.js
tests/app/global.d.ts
tests/test-output.txt
tests/app/nativescript-angular
tests/app/global.d.ts
tests/platforms
tests/lib
tests/node_modules
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ before_script:
- android-wait-for-emulator

script:
- npm install
- cd ./tests
- npm install
- tns platform add android
Expand Down
15 changes: 11 additions & 4 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function(grunt) {

var outDir = "bin/dist/modules";
var moduleOutDir = path.join(outDir, "nativescript-angular");
var packageName = "nativescript-angular-" + require("./package.json").version + ".tgz";

grunt.initConfig({
ts: {
Expand Down Expand Up @@ -65,14 +66,19 @@ module.exports = function(grunt) {
package: {
src: 'nativescript-angular*.tgz'
},
packageDefinitions: {
src: moduleOutDir + '/**/*.d.ts'
}
},
shell: {
package: {
command: "npm pack \"" + moduleOutDir + "\""
},
updateTests: {
command: "npm install ../" + packageName,
options: {
execOptions: {
cwd: "./tests"
}
}
}
},
});

Expand All @@ -84,7 +90,6 @@ module.exports = function(grunt) {
]);

grunt.registerTask("package", [
"clean:packageDefinitions",
"copy:handCodedDefinitions",
"copy:npmReadme",
"shell:package",
Expand All @@ -101,5 +106,7 @@ module.exports = function(grunt) {
"package"
]);

grunt.registerTask("updateTests", ["all", "shell:updateTests"]);

grunt.registerTask("default", ["all"]);
};
8 changes: 4 additions & 4 deletions src/nativescript-angular/application.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Type, ApplicationRef, Provider } from 'angular2/core';
import { Type, ComponentRef, Provider } from 'angular2/core';

export interface AppOptions {
cssFile?: string;
startPageActionBarHidden?: boolean;
}

export type BindingArray = Array<Type | Provider | Array<any>>;
export function bootstrap(appComponentType: any, componentInjectableBindings?: BindingArray): Promise<ApplicationRef>;
export function nativeScriptBootstrap(appComponentType: any, customProviders?: BindingArray, appOptions?: any): void;
export type ProviderArray = Array<Type | Provider | Array<any>>;
export function bootstrap(appComponentType: any, componentInjectableBindings?: ProviderArray): Promise<ComponentRef>;
export function nativeScriptBootstrap(appComponentType: any, customProviders?: ProviderArray, appOptions?: any): void;
18 changes: 9 additions & 9 deletions src/nativescript-angular/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'globals';
import 'reflect-metadata';
import './polyfills/array';
import {isPresent, Type} from 'angular2/src/facade/lang';
import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
import {platform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
import {bind, provide, Provider} from 'angular2/src/core/di';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';

Expand Down Expand Up @@ -45,7 +45,7 @@ import {defaultPageProvider, defaultDeviceProvider} from "./platform-providers";
import * as nativescriptIntl from "nativescript-intl";
global.Intl = nativescriptIntl;

let _platform = null;
let _platform: PlatformRef = null;

export interface AppOptions {
cssFile?: string;
Expand All @@ -63,19 +63,19 @@ export function bootstrap(appComponentType: any,
let defaultAppProviders: ProviderArray = [
APPLICATION_COMMON_PROVIDERS,
FORM_PROVIDERS,
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
provide(PLATFORM_DIRECTIVES, {useValue: NS_DIRECTIVES, multi: true}),
provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, true), deps: []}),
provide(PLATFORM_PIPES, { useValue: COMMON_PIPES, multi: true }),
provide(PLATFORM_DIRECTIVES, { useValue: COMMON_DIRECTIVES, multi: true }),
provide(PLATFORM_DIRECTIVES, { useValue: NS_DIRECTIVES, multi: true }),
provide(ExceptionHandler, { useFactory: () => new ExceptionHandler(DOM, true), deps: [] }),

defaultPageProvider,
defaultDeviceProvider,
NativeScriptRootRenderer,
provide(RootRenderer, {useClass: NativeScriptRootRenderer}),
provide(RootRenderer, { useClass: NativeScriptRootRenderer }),
NativeScriptRenderer,
provide(Renderer, {useClass: NativeScriptRenderer}),
provide(Renderer, { useClass: NativeScriptRenderer }),
COMPILER_PROVIDERS,
provide(XHR, {useClass: FileSystemXHR}),
provide(XHR, { useClass: FileSystemXHR }),
]

var appProviders = [defaultAppProviders];
Expand Down
1 change: 1 addition & 0 deletions tests/app/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../node_modules/tns-core-modules/tns-core-modules.d.ts" />
2 changes: 1 addition & 1 deletion tests/app/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// this import should be first in order to load some required settings (like globals and reflect-metadata)
import {nativeScriptBootstrap} from "./nativescript-angular/application";
import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";

nativeScriptBootstrap(AppComponent);
2 changes: 1 addition & 1 deletion tests/app/tests/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//make sure you import mocha-config before angular2/core
import {assert} from "./test-config";
import {bootstrap} from "../nativescript-angular/application";
import {bootstrap} from "nativescript-angular/application";
import {Component} from "angular2/core";

@Component({
Expand Down
12 changes: 8 additions & 4 deletions tests/app/tests/list-view-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
Component
} from 'angular2/core';
import {TestApp} from "./test-app";
import {device, platformNames} from "platform";
const IS_IOS = (device.os === platformNames.ios);

class DataItem {
constructor(public id: number, public name: string) { }
Expand Down Expand Up @@ -35,13 +37,14 @@ export class TestListViewComponent {
this.myItems.push(new DataItem(i, "data item " + i));
}
}

onSetupItemView(args) {
this.counter++;
}
}

describe('ListView-tests', () => {
// TODO: Skip list-view trest until
(IS_IOS ? describe.skip : describe)('ListView-tests', () => {
let testApp: TestApp = null;

before(() => {
Expand All @@ -57,14 +60,15 @@ describe('ListView-tests', () => {
afterEach(() => {
testApp.disposeComponents();
});

it('setupItemView is called for every item', (done) => {
return testApp.loadComponent(TestListViewComponent).then((componentRef) => {
const component = componentRef.instance;
setTimeout(() => {
assert.equal(component.counter, 2);
done();
}, 1000);
});
})
.catch(done);
});
});
15 changes: 11 additions & 4 deletions tests/app/tests/modal-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import {Component, ComponentRef} from "angular2/core";
import {TestApp} from "./test-app";
import {Page} from "ui/page";
import {topmost} from "ui/frame";
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "../nativescript-angular/directives/dialogs";
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "nativescript-angular/directives/dialogs";

import {device, platformNames} from "platform";
const CLOSE_WAIT = (device.os === platformNames.ios) ? 1000 : 0;

@Component({
selector: "modal-comp",
Expand Down Expand Up @@ -47,9 +50,13 @@ export class SuccessComponent {
describe('modal-dialog', () => {
let testApp: TestApp = null;

before(() => {
before((done) => {
return TestApp.create().then((app) => {
testApp = app;

// HACK: Wait for the navigations from the test runner app
// Remove the setTimeout when test runner start tests on page.navigatedTo
setTimeout(done, 1000);
})
});

Expand Down Expand Up @@ -83,7 +90,7 @@ describe('modal-dialog', () => {
var service = <ModalDialogService>ref.instance.service;
return service.showModal(ModalComponent, {});
})
.then((res) => done())
.then((res) => setTimeout(done, CLOSE_WAIT)) // wait for the dialog to close in IOS
.catch(done)
});

Expand All @@ -97,7 +104,7 @@ describe('modal-dialog', () => {
})
.then((res) => {
assert.strictEqual(res, context);
done();
setTimeout(done, CLOSE_WAIT) // wait for the dialog to close in IOS
})
.catch(done);
})
Expand Down
2 changes: 1 addition & 1 deletion tests/app/tests/platform-filter-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Component, ElementRef, provide} from "angular2/core";
import {ProxyViewContainer} from "ui/proxy-view-container";
import {dumpView, createDevice} from "./test-utils";
import {TestApp} from "./test-app";
import {DEVICE} from "../nativescript-angular/platform-providers";
import {DEVICE} from "nativescript-angular/platform-providers";
import {platformNames} from "platform";

@Component({
Expand Down
6 changes: 3 additions & 3 deletions tests/app/tests/property-sets.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
//make sure you import mocha-config before angular2/core
import {assert} from "./test-config";
import {bootstrap} from "../nativescript-angular/application";
import {bootstrap} from "nativescript-angular/application";
import {Component} from "angular2/core";
import {View} from "ui/core/view";
import {ViewUtil} from "../nativescript-angular/view-util";
import {NgView, ViewExtensions, ViewClassMeta} from "../nativescript-angular/element-registry";
import {ViewUtil} from "nativescript-angular/view-util";
import {NgView, ViewExtensions, ViewClassMeta} from "nativescript-angular/element-registry";
import {Red} from "color/known-colors";
import {device, Device, platformNames} from "platform";
import {createDevice} from "./test-utils";
Expand Down
2 changes: 1 addition & 1 deletion tests/app/tests/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {ROUTER_DIRECTIVES, Router, OnActivate, OnDeactivate, CanReuse, OnReuse,
LocationStrategy, RouteParams, ComponentInstruction, RouteConfig, Location } from 'angular2/router';
import {topmost, BackstackEntry} from "ui/frame";
import {Page} from "ui/page";
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../nativescript-angular/router/ns-router";
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router";

@Component({
template: `<StackLayout><Label text="Layout"></Label></StackLayout>`
Expand Down
4 changes: 2 additions & 2 deletions tests/app/tests/test-app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//make sure you import mocha-config before angular2/core
import {bootstrap, ProviderArray} from "../nativescript-angular/application";
import {bootstrap, ProviderArray} from "nativescript-angular/application";
import {Type, Component, ComponentRef, DynamicComponentLoader,
ViewChild, ElementRef, provide, ApplicationRef
} from "angular2/core";
Expand All @@ -8,7 +8,7 @@ import {View} from "ui/core/view";
import {GridLayout} from "ui/layouts/grid-layout";
import {LayoutBase} from "ui/layouts/layout-base";
import {topmost} from 'ui/frame';
import {APP_ROOT_VIEW} from "../nativescript-angular/platform-providers";
import {APP_ROOT_VIEW} from "nativescript-angular/platform-providers";

@Component({
selector: 'my-app',
Expand Down
12 changes: 6 additions & 6 deletions tests/app/tests/value-accessor-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import {DatePicker} from "ui/date-picker";
import {TimePicker} from "ui/time-picker";
import {ListPicker} from "ui/list-picker";
import {TextField} from "ui/text-field";
import {NumberValueAccessor} from "../nativescript-angular/value-accessors/number-value-accessor";
import {CheckedValueAccessor} from "../nativescript-angular/value-accessors/checked-value-accessor";
import {DateValueAccessor} from "../nativescript-angular/value-accessors/date-value-accessor";
import {TimeValueAccessor} from "../nativescript-angular/value-accessors/time-value-accessor";
import {SelectedIndexValueAccessor} from "../nativescript-angular/value-accessors/selectedIndex-value-accessor";
import {TextValueAccessor} from "../nativescript-angular/value-accessors/text-value-accessor";
import {NumberValueAccessor} from "nativescript-angular/value-accessors/number-value-accessor";
import {CheckedValueAccessor} from "nativescript-angular/value-accessors/checked-value-accessor";
import {DateValueAccessor} from "nativescript-angular/value-accessors/date-value-accessor";
import {TimeValueAccessor} from "nativescript-angular/value-accessors/time-value-accessor";
import {SelectedIndexValueAccessor} from "nativescript-angular/value-accessors/selectedIndex-value-accessor";
import {TextValueAccessor} from "nativescript-angular/value-accessors/text-value-accessor";
import {ElementRef} from 'angular2/core';

class TestElementRef implements ElementRef {
Expand Down
11 changes: 3 additions & 8 deletions tests/hooks/before-prepare/10-copy-renderer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
var path = require('path');
var shelljs = require('shelljs');
var execSync = require('child_process').execSync;

module.exports = function ($logger, $projectData, $usbLiveSyncService) {
var projectDir = path.join(__dirname, '..', '..');
var appDir = path.join(projectDir, 'app');
var srcDir = path.join(projectDir, '..', 'src');
module.exports = function($logger, $projectData, $usbLiveSyncService) {
if (!$usbLiveSyncService.isInitialized) {
shelljs.cp('-Rf', path.join(srcDir, 'nativescript-angular'), appDir);
shelljs.cp('-Rf', path.join(srcDir, 'global.d.ts'), appDir);
execSync("npm run updateTests", { stdio: [0, 1, 2]});
}
}
8 changes: 6 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@
},
"devDependencies": {
"chai": "^3.5.0",
"grunt-cli": "^1.2.0",
"karma": "^0.13.19",
"karma-chai": "^0.1.0",
"karma-mocha": "^0.2.1",
"karma-mocha-reporter": "^1.2.0",
"karma-nativescript-launcher": "^0.4.0",
"mocha": "^2.4.5",
"karma-mocha-reporter": "^1.2.0",
"nativescript-dev-typescript": "^0.3.1",
"shelljs": "^0.5.3",
"typescript": "1.8.2"
},
"scripts" :{
"updateTests" : "grunt updateTests"
}
}
}