Skip to content

Commit 8916631

Browse files
committed
ng-sample updates: faster compile, {N} as npm module
1 parent 037afe3 commit 8916631

File tree

5 files changed

+110
-52
lines changed

5 files changed

+110
-52
lines changed

ng-sample/gruntfile.js

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ module.exports = function(grunt) {
55
grunt.loadNpmTasks('grunt-ts');
66
grunt.loadNpmTasks('grunt-contrib-copy');
77
grunt.loadNpmTasks('grunt-contrib-clean');
8+
grunt.loadNpmTasks('grunt-shell');
89

910
var nsDistPath = process.env.NSDIST || '../deps/NativeScript/bin/dist';
1011

1112
var modulesPath = grunt.option("modulesPath", path.join(nsDistPath, 'modules'));
12-
var typingsPath = grunt.option("typingsPath", path.join(nsDistPath, 'definitions'));
1313

14-
var modulesDestPath = "app/tns_modules";
15-
var typingsDestPath = "src/typings/nativescript";
1614
var angularSrcPath = grunt.option("angularSrcPath") || "../src"
1715

1816
grunt.initConfig({
@@ -42,30 +40,9 @@ module.exports = function(grunt) {
4240
src: [
4341
'**/*',
4442
'!**/*.ts',
45-
'!typings/**/*'
4643
],
4744
dest: 'app'
4845
},
49-
modulesFiles: {
50-
expand: true,
51-
cwd: modulesPath,
52-
src: [
53-
'**/*',
54-
'!node_modules',
55-
'!node_modules/**/*',
56-
],
57-
dest: modulesDestPath
58-
},
59-
typingsFiles: {
60-
expand: true,
61-
cwd: typingsPath,
62-
src: [
63-
'**/*',
64-
'!es6-promise.d.ts',
65-
'!es-collections.d.ts',
66-
],
67-
dest: typingsDestPath
68-
},
6946
angularFiles: {
7047
expand: true,
7148
cwd: angularSrcPath,
@@ -75,14 +52,19 @@ module.exports = function(grunt) {
7552
],
7653
dest: 'src/'
7754
},
78-
tnsifyAngular: {
55+
tnsifyAngularAndroid: {
7956
expand: true,
8057
cwd: 'app/',
8158
src: [
8259
"angular2/**/*",
8360
"nativescript-angular/**/*",
8461
],
85-
dest: 'app/tns_modules',
62+
dest: 'platforms/android/src/main/assets/app/tns_modules',
63+
},
64+
},
65+
shell: {
66+
localInstallModules: {
67+
command: "npm install \"<%= nsPackagePath %>\""
8668
},
8769
},
8870
clean: {
@@ -92,8 +74,6 @@ module.exports = function(grunt) {
9274
src: [
9375
'angular2',
9476
'nativescript-angular',
95-
'typings',
96-
'tns_modules/angular2/**/*.dart',
9777
'**/*.js.map',
9878
]
9979
},
@@ -104,22 +84,12 @@ module.exports = function(grunt) {
10484
grunt.file.delete("app");
10585
});
10686

107-
grunt.registerTask("removeNSFiles", function() {
108-
grunt.file.delete(typingsDestPath);
109-
});
110-
11187
grunt.registerTask("checkModules", function() {
11288
if (!grunt.file.exists(modulesPath)) {
11389
grunt.fail.fatal("Modules path does not exist.");
11490
}
11591
});
11692

117-
grunt.registerTask("checkTypings", function() {
118-
if (!grunt.file.exists(typingsPath)) {
119-
grunt.fail.fatal("Typings path does not exist.");
120-
}
121-
});
122-
12393
grunt.registerTask("checkAngular", function() {
12494
if (!grunt.file.exists(path.join(angularSrcPath, 'angular2'))) {
12595
grunt.fail.fatal("angular2 path does not exist.");
@@ -132,25 +102,27 @@ module.exports = function(grunt) {
132102
grunt.registerTask("app", [
133103
"copy:appFiles",
134104
"ts:build",
135-
"prepareTnsModules",
105+
"preDeploy",
136106
]);
137107

138108
grunt.registerTask("app-full", [
139109
"full-clean",
140-
"updateTypings",
141-
"updateModules",
142-
"updateAngular",
143110
"app",
144111
]);
145112

146-
grunt.registerTask("updateModules", [
147-
"checkModules",
148-
"copy:modulesFiles",
149-
]);
113+
grunt.registerTask("getNSPackage", function() {
114+
var packageFiles = grunt.file.expand({
115+
cwd: nsDistPath
116+
},[
117+
'tns-core-modules*.tgz'
118+
]);
119+
var nsPackagePath = path.join(nsDistPath, packageFiles[0]);
120+
grunt.config('nsPackagePath', nsPackagePath);
121+
});
150122

151-
grunt.registerTask("updateTypings", [
152-
"checkTypings",
153-
"copy:typingsFiles",
123+
grunt.registerTask("updateModules", [
124+
"getNSPackage",
125+
"shell:localInstallModules",
154126
]);
155127

156128
grunt.registerTask("updateAngular", [
@@ -168,14 +140,18 @@ module.exports = function(grunt) {
168140
grunt.file.write(packagePath, JSON.stringify(packageData, null, 4));
169141
});
170142

171-
grunt.registerTask("prepareTnsModules", [
172-
"copy:tnsifyAngular",
143+
grunt.registerTask("prepare", [
144+
"updateModules",
145+
"updateAngular",
173146
"prepareQuerystringPackage",
147+
]);
148+
149+
grunt.registerTask("preDeploy", [
150+
"copy:tnsifyAngularAndroid",
174151
"clean:appBeforeDeploy",
175152
]);
176153

177154
grunt.registerTask("full-clean", [
178155
"removeAppDir",
179-
"removeNSFiles",
180156
]);
181157
}

ng-sample/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"grunt-ts": "4.2.0",
3838
"grunt-contrib-copy": "0.8.0",
3939
"grunt-contrib-clean": "0.6.0",
40+
"grunt-shell": "1.1.2",
4041
"typescript": "1.5.3"
4142
},
4243
"nativescript": {

ng-sample/src/android17-dummy.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
declare module android {
2+
export module app {
3+
export type Activity = any;
4+
export type Application = any;
5+
export type ActionBar = any;
6+
}
7+
8+
export module os {
9+
export type Bundle = any;
10+
}
11+
12+
export module content {
13+
export type Intent = any;
14+
export type Context = any;
15+
}
16+
17+
export module view {
18+
export type IMenuItem = any;
19+
export type ViewGroup = any;
20+
export type MotionEvent = any;
21+
}
22+
23+
export module widget {
24+
export type Button = any;
25+
export type TextView = any;
26+
export type Switch = any;
27+
export type EditText = any;
28+
}
29+
}

ng-sample/src/ios-dummy.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
declare type UIViewController = any;
2+
declare type UIApplication = any;
3+
declare var UIApplicationDelegate: any;
4+
declare type NSNotification = any;
5+
declare type UIColor = any;
6+
declare type UIButton = any;
7+
declare type UINavigationController = any;
8+
declare type UIGestureRecognizer = any;
9+
declare type UILabel = any;
10+
declare type UISwitch = any;
11+
declare type UITextField = any;
12+
declare type UITextView = any;

ng-sample/src/ns-dependencies.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/declarations.d.ts" />
2+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/data/observable/observable.d.ts" />
3+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/data/observable-array/observable-array.d.ts" />
4+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/core/view.d.ts" />
5+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/application/application.d.ts" />
6+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/color/color.d.ts" />
7+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/core/dependency-observable.d.ts" />
8+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/core/proxy.d.ts" />
9+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/core/bindable.d.ts" />
10+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/animation/animation.d.ts" />
11+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/content-view/content-view.d.ts" />
12+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/styling/styling.d.ts" />
13+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/styling/style-property.d.ts" />
14+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/styling/css-selector.d.ts" />
15+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/css/reworkcss.d.ts" />
16+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/frame/frame.d.ts" />
17+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/page/page.d.ts" />
18+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/action-bar/action-bar.d.ts" />
19+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/layouts/layout-base.d.ts" />
20+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/layouts/layout.d.ts" />
21+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/layouts/stack-layout/stack-layout.d.ts" />
22+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/layouts/dock-layout/dock-layout.d.ts" />
23+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/builder/component-builder.d.ts" />
24+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/builder/special-properties.d.ts" />
25+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/gestures/gestures.d.ts" />
26+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/text-base/text-base.d.ts" />
27+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/text/formatted-string.d.ts" />
28+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/text/span.d.ts" />
29+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/editable-text-base/editable-text-base.d.ts" />
30+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/text-view/text-view.d.ts" />
31+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/text-field/text-field.d.ts" />
32+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/button/button.d.ts" />
33+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/label/label.d.ts" />
34+
/// <reference path="../../deps/NativeScript/bin/dist/definitions/ui/switch/switch.d.ts" />
35+
36+
/// DISABLED reference path="../../deps/NativeScript/bin/dist/definitions/android17.d.ts" />
37+
/// DISABLED reference path="../../deps/NativeScript/bin/dist/definitions/ios.d.ts" />
38+
39+
/// <reference path="android17-dummy.d.ts" />
40+
/// <reference path="ios-dummy.d.ts" />

0 commit comments

Comments
 (0)