Skip to content

Commit 55f16bb

Browse files
committed
Merge pull request #159 from NativeScript/use-package-for-projects
Use package for projects
2 parents 1c677a0 + 276c405 commit 55f16bb

17 files changed

+70
-53
lines changed

Diff for: .gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ src/nativescript-angular/**/*.js
77
.tscache
88
.nvm
99
.vscode
10+
nativescript-angular*.tgz
1011

1112
tests/app/**/*.js
12-
tests/app/global.d.ts
1313
tests/test-output.txt
14-
tests/app/nativescript-angular
15-
tests/app/global.d.ts
1614
tests/platforms
1715
tests/lib
1816
tests/node_modules

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ before_script:
2929
- android-wait-for-emulator
3030

3131
script:
32+
- npm install
3233
- cd ./tests
3334
- npm install
3435
- tns platform add android

Diff for: gruntfile.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module.exports = function(grunt) {
1010

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

1415
grunt.initConfig({
1516
ts: {
@@ -65,14 +66,19 @@ module.exports = function(grunt) {
6566
package: {
6667
src: 'nativescript-angular*.tgz'
6768
},
68-
packageDefinitions: {
69-
src: moduleOutDir + '/**/*.d.ts'
70-
}
7169
},
7270
shell: {
7371
package: {
7472
command: "npm pack \"" + moduleOutDir + "\""
7573
},
74+
updateTests: {
75+
command: "npm install ../" + packageName,
76+
options: {
77+
execOptions: {
78+
cwd: "./tests"
79+
}
80+
}
81+
}
7682
},
7783
});
7884

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

8692
grunt.registerTask("package", [
87-
"clean:packageDefinitions",
8893
"copy:handCodedDefinitions",
8994
"copy:npmReadme",
9095
"shell:package",
@@ -101,5 +106,7 @@ module.exports = function(grunt) {
101106
"package"
102107
]);
103108

109+
grunt.registerTask("updateTests", ["all", "shell:updateTests"]);
110+
104111
grunt.registerTask("default", ["all"]);
105112
};

Diff for: src/nativescript-angular/application.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Type, ApplicationRef, Provider } from 'angular2/core';
1+
import { Type, ComponentRef, Provider } from 'angular2/core';
22

33
export interface AppOptions {
44
cssFile?: string;
55
startPageActionBarHidden?: boolean;
66
}
77

8-
export type BindingArray = Array<Type | Provider | Array<any>>;
9-
export function bootstrap(appComponentType: any, componentInjectableBindings?: BindingArray): Promise<ApplicationRef>;
10-
export function nativeScriptBootstrap(appComponentType: any, customProviders?: BindingArray, appOptions?: any): void;
8+
export type ProviderArray = Array<Type | Provider | Array<any>>;
9+
export function bootstrap(appComponentType: any, componentInjectableBindings?: ProviderArray): Promise<ComponentRef>;
10+
export function nativeScriptBootstrap(appComponentType: any, customProviders?: ProviderArray, appOptions?: any): void;

Diff for: src/nativescript-angular/application.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'globals';
1515
import 'reflect-metadata';
1616
import './polyfills/array';
1717
import {isPresent, Type} from 'angular2/src/facade/lang';
18-
import {platform, ComponentRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
18+
import {platform, ComponentRef, PlatformRef, PLATFORM_DIRECTIVES, PLATFORM_PIPES} from 'angular2/core';
1919
import {bind, provide, Provider} from 'angular2/src/core/di';
2020
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
2121

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

48-
let _platform = null;
48+
let _platform: PlatformRef = null;
4949

5050
export interface AppOptions {
5151
cssFile?: string;
@@ -63,19 +63,19 @@ export function bootstrap(appComponentType: any,
6363
let defaultAppProviders: ProviderArray = [
6464
APPLICATION_COMMON_PROVIDERS,
6565
FORM_PROVIDERS,
66-
provide(PLATFORM_PIPES, {useValue: COMMON_PIPES, multi: true}),
67-
provide(PLATFORM_DIRECTIVES, {useValue: COMMON_DIRECTIVES, multi: true}),
68-
provide(PLATFORM_DIRECTIVES, {useValue: NS_DIRECTIVES, multi: true}),
69-
provide(ExceptionHandler, {useFactory: () => new ExceptionHandler(DOM, true), deps: []}),
66+
provide(PLATFORM_PIPES, { useValue: COMMON_PIPES, multi: true }),
67+
provide(PLATFORM_DIRECTIVES, { useValue: COMMON_DIRECTIVES, multi: true }),
68+
provide(PLATFORM_DIRECTIVES, { useValue: NS_DIRECTIVES, multi: true }),
69+
provide(ExceptionHandler, { useFactory: () => new ExceptionHandler(DOM, true), deps: [] }),
7070

7171
defaultPageProvider,
7272
defaultDeviceProvider,
7373
NativeScriptRootRenderer,
74-
provide(RootRenderer, {useClass: NativeScriptRootRenderer}),
74+
provide(RootRenderer, { useClass: NativeScriptRootRenderer }),
7575
NativeScriptRenderer,
76-
provide(Renderer, {useClass: NativeScriptRenderer}),
76+
provide(Renderer, { useClass: NativeScriptRenderer }),
7777
COMPILER_PROVIDERS,
78-
provide(XHR, {useClass: FileSystemXHR}),
78+
provide(XHR, { useClass: FileSystemXHR }),
7979
]
8080

8181
var appProviders = [defaultAppProviders];

Diff for: tests/app/global.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference path="../node_modules/tns-core-modules/tns-core-modules.d.ts" />

Diff for: tests/app/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// this import should be first in order to load some required settings (like globals and reflect-metadata)
2-
import {nativeScriptBootstrap} from "./nativescript-angular/application";
2+
import {nativeScriptBootstrap} from "nativescript-angular/application";
33
import {AppComponent} from "./app.component";
44

55
nativeScriptBootstrap(AppComponent);

Diff for: tests/app/tests/bootstrap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//make sure you import mocha-config before angular2/core
22
import {assert} from "./test-config";
3-
import {bootstrap} from "../nativescript-angular/application";
3+
import {bootstrap} from "nativescript-angular/application";
44
import {Component} from "angular2/core";
55

66
@Component({

Diff for: tests/app/tests/list-view-tests.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {
44
Component
55
} from 'angular2/core';
66
import {TestApp} from "./test-app";
7+
import {device, platformNames} from "platform";
8+
const IS_IOS = (device.os === platformNames.ios);
79

810
class DataItem {
911
constructor(public id: number, public name: string) { }
@@ -35,13 +37,14 @@ export class TestListViewComponent {
3537
this.myItems.push(new DataItem(i, "data item " + i));
3638
}
3739
}
38-
40+
3941
onSetupItemView(args) {
4042
this.counter++;
4143
}
4244
}
4345

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

4750
before(() => {
@@ -57,14 +60,15 @@ describe('ListView-tests', () => {
5760
afterEach(() => {
5861
testApp.disposeComponents();
5962
});
60-
63+
6164
it('setupItemView is called for every item', (done) => {
6265
return testApp.loadComponent(TestListViewComponent).then((componentRef) => {
6366
const component = componentRef.instance;
6467
setTimeout(() => {
6568
assert.equal(component.counter, 2);
6669
done();
6770
}, 1000);
68-
});
71+
})
72+
.catch(done);
6973
});
7074
});

Diff for: tests/app/tests/modal-dialog.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {Component, ComponentRef} from "angular2/core";
44
import {TestApp} from "./test-app";
55
import {Page} from "ui/page";
66
import {topmost} from "ui/frame";
7-
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "../nativescript-angular/directives/dialogs";
7+
import {ModalDialogHost, ModalDialogOptions, ModalDialogParams, ModalDialogService} from "nativescript-angular/directives/dialogs";
8+
9+
import {device, platformNames} from "platform";
10+
const CLOSE_WAIT = (device.os === platformNames.ios) ? 1000 : 0;
811

912
@Component({
1013
selector: "modal-comp",
@@ -47,9 +50,13 @@ export class SuccessComponent {
4750
describe('modal-dialog', () => {
4851
let testApp: TestApp = null;
4952

50-
before(() => {
53+
before((done) => {
5154
return TestApp.create().then((app) => {
5255
testApp = app;
56+
57+
// HACK: Wait for the navigations from the test runner app
58+
// Remove the setTimeout when test runner start tests on page.navigatedTo
59+
setTimeout(done, 1000);
5360
})
5461
});
5562

@@ -83,7 +90,7 @@ describe('modal-dialog', () => {
8390
var service = <ModalDialogService>ref.instance.service;
8491
return service.showModal(ModalComponent, {});
8592
})
86-
.then((res) => done())
93+
.then((res) => setTimeout(done, CLOSE_WAIT)) // wait for the dialog to close in IOS
8794
.catch(done)
8895
});
8996

@@ -97,7 +104,7 @@ describe('modal-dialog', () => {
97104
})
98105
.then((res) => {
99106
assert.strictEqual(res, context);
100-
done();
107+
setTimeout(done, CLOSE_WAIT) // wait for the dialog to close in IOS
101108
})
102109
.catch(done);
103110
})

Diff for: tests/app/tests/platform-filter-components.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, ElementRef, provide} from "angular2/core";
44
import {ProxyViewContainer} from "ui/proxy-view-container";
55
import {dumpView, createDevice} from "./test-utils";
66
import {TestApp} from "./test-app";
7-
import {DEVICE} from "../nativescript-angular/platform-providers";
7+
import {DEVICE} from "nativescript-angular/platform-providers";
88
import {platformNames} from "platform";
99

1010
@Component({

Diff for: tests/app/tests/property-sets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//make sure you import mocha-config before angular2/core
22
import {assert} from "./test-config";
3-
import {bootstrap} from "../nativescript-angular/application";
3+
import {bootstrap} from "nativescript-angular/application";
44
import {Component} from "angular2/core";
55
import {View} from "ui/core/view";
6-
import {ViewUtil} from "../nativescript-angular/view-util";
7-
import {NgView, ViewExtensions, ViewClassMeta} from "../nativescript-angular/element-registry";
6+
import {ViewUtil} from "nativescript-angular/view-util";
7+
import {NgView, ViewExtensions, ViewClassMeta} from "nativescript-angular/element-registry";
88
import {Red} from "color/known-colors";
99
import {device, Device, platformNames} from "platform";
1010
import {createDevice} from "./test-utils";

Diff for: tests/app/tests/router.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {ROUTER_DIRECTIVES, Router, OnActivate, OnDeactivate, CanReuse, OnReuse,
2020
LocationStrategy, RouteParams, ComponentInstruction, RouteConfig, Location } from 'angular2/router';
2121
import {topmost, BackstackEntry} from "ui/frame";
2222
import {Page} from "ui/page";
23-
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "../nativescript-angular/router/ns-router";
23+
import {NS_ROUTER_DIRECTIVES, NS_ROUTER_PROVIDERS} from "nativescript-angular/router/ns-router";
2424

2525
@Component({
2626
template: `<StackLayout><Label text="Layout"></Label></StackLayout>`

Diff for: tests/app/tests/test-app.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//make sure you import mocha-config before angular2/core
2-
import {bootstrap, ProviderArray} from "../nativescript-angular/application";
2+
import {bootstrap, ProviderArray} from "nativescript-angular/application";
33
import {Type, Component, ComponentRef, DynamicComponentLoader,
44
ViewChild, ElementRef, provide, ApplicationRef
55
} from "angular2/core";
@@ -8,7 +8,7 @@ import {View} from "ui/core/view";
88
import {GridLayout} from "ui/layouts/grid-layout";
99
import {LayoutBase} from "ui/layouts/layout-base";
1010
import {topmost} from 'ui/frame';
11-
import {APP_ROOT_VIEW} from "../nativescript-angular/platform-providers";
11+
import {APP_ROOT_VIEW} from "nativescript-angular/platform-providers";
1212

1313
@Component({
1414
selector: 'my-app',

Diff for: tests/app/tests/value-accessor-tests.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import {DatePicker} from "ui/date-picker";
77
import {TimePicker} from "ui/time-picker";
88
import {ListPicker} from "ui/list-picker";
99
import {TextField} from "ui/text-field";
10-
import {NumberValueAccessor} from "../nativescript-angular/value-accessors/number-value-accessor";
11-
import {CheckedValueAccessor} from "../nativescript-angular/value-accessors/checked-value-accessor";
12-
import {DateValueAccessor} from "../nativescript-angular/value-accessors/date-value-accessor";
13-
import {TimeValueAccessor} from "../nativescript-angular/value-accessors/time-value-accessor";
14-
import {SelectedIndexValueAccessor} from "../nativescript-angular/value-accessors/selectedIndex-value-accessor";
15-
import {TextValueAccessor} from "../nativescript-angular/value-accessors/text-value-accessor";
10+
import {NumberValueAccessor} from "nativescript-angular/value-accessors/number-value-accessor";
11+
import {CheckedValueAccessor} from "nativescript-angular/value-accessors/checked-value-accessor";
12+
import {DateValueAccessor} from "nativescript-angular/value-accessors/date-value-accessor";
13+
import {TimeValueAccessor} from "nativescript-angular/value-accessors/time-value-accessor";
14+
import {SelectedIndexValueAccessor} from "nativescript-angular/value-accessors/selectedIndex-value-accessor";
15+
import {TextValueAccessor} from "nativescript-angular/value-accessors/text-value-accessor";
1616
import {ElementRef} from 'angular2/core';
1717

1818
class TestElementRef implements ElementRef {

Diff for: tests/hooks/before-prepare/10-copy-renderer.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
var path = require('path');
2-
var shelljs = require('shelljs');
1+
var execSync = require('child_process').execSync;
32

4-
module.exports = function ($logger, $projectData, $usbLiveSyncService) {
5-
var projectDir = path.join(__dirname, '..', '..');
6-
var appDir = path.join(projectDir, 'app');
7-
var srcDir = path.join(projectDir, '..', 'src');
3+
module.exports = function($logger, $projectData, $usbLiveSyncService) {
84
if (!$usbLiveSyncService.isInitialized) {
9-
shelljs.cp('-Rf', path.join(srcDir, 'nativescript-angular'), appDir);
10-
shelljs.cp('-Rf', path.join(srcDir, 'global.d.ts'), appDir);
5+
execSync("npm run updateTests", { stdio: [0, 1, 2]});
116
}
127
}

Diff for: tests/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@
4444
},
4545
"devDependencies": {
4646
"chai": "^3.5.0",
47+
"grunt-cli": "^1.2.0",
4748
"karma": "^0.13.19",
4849
"karma-chai": "^0.1.0",
4950
"karma-mocha": "^0.2.1",
51+
"karma-mocha-reporter": "^1.2.0",
5052
"karma-nativescript-launcher": "^0.4.0",
5153
"mocha": "^2.4.5",
52-
"karma-mocha-reporter": "^1.2.0",
5354
"nativescript-dev-typescript": "^0.3.1",
5455
"shelljs": "^0.5.3",
5556
"typescript": "1.8.2"
57+
},
58+
"scripts" :{
59+
"updateTests" : "grunt updateTests"
5660
}
57-
}
61+
}

0 commit comments

Comments
 (0)