@@ -5,14 +5,12 @@ module.exports = function(grunt) {
5
5
grunt . loadNpmTasks ( 'grunt-ts' ) ;
6
6
grunt . loadNpmTasks ( 'grunt-contrib-copy' ) ;
7
7
grunt . loadNpmTasks ( 'grunt-contrib-clean' ) ;
8
+ grunt . loadNpmTasks ( 'grunt-shell' ) ;
8
9
9
10
var nsDistPath = process . env . NSDIST || '../deps/NativeScript/bin/dist' ;
10
11
11
12
var modulesPath = grunt . option ( "modulesPath" , path . join ( nsDistPath , 'modules' ) ) ;
12
- var typingsPath = grunt . option ( "typingsPath" , path . join ( nsDistPath , 'definitions' ) ) ;
13
13
14
- var modulesDestPath = "app/tns_modules" ;
15
- var typingsDestPath = "src/typings/nativescript" ;
16
14
var angularSrcPath = grunt . option ( "angularSrcPath" ) || "../src"
17
15
18
16
grunt . initConfig ( {
@@ -42,30 +40,9 @@ module.exports = function(grunt) {
42
40
src : [
43
41
'**/*' ,
44
42
'!**/*.ts' ,
45
- '!typings/**/*'
46
43
] ,
47
44
dest : 'app'
48
45
} ,
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
- } ,
69
46
angularFiles : {
70
47
expand : true ,
71
48
cwd : angularSrcPath ,
@@ -75,14 +52,19 @@ module.exports = function(grunt) {
75
52
] ,
76
53
dest : 'src/'
77
54
} ,
78
- tnsifyAngular : {
55
+ tnsifyAngularAndroid : {
79
56
expand : true ,
80
57
cwd : 'app/' ,
81
58
src : [
82
59
"angular2/**/*" ,
83
60
"nativescript-angular/**/*" ,
84
61
] ,
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 %>\""
86
68
} ,
87
69
} ,
88
70
clean : {
@@ -92,8 +74,6 @@ module.exports = function(grunt) {
92
74
src : [
93
75
'angular2' ,
94
76
'nativescript-angular' ,
95
- 'typings' ,
96
- 'tns_modules/angular2/**/*.dart' ,
97
77
'**/*.js.map' ,
98
78
]
99
79
} ,
@@ -104,22 +84,12 @@ module.exports = function(grunt) {
104
84
grunt . file . delete ( "app" ) ;
105
85
} ) ;
106
86
107
- grunt . registerTask ( "removeNSFiles" , function ( ) {
108
- grunt . file . delete ( typingsDestPath ) ;
109
- } ) ;
110
-
111
87
grunt . registerTask ( "checkModules" , function ( ) {
112
88
if ( ! grunt . file . exists ( modulesPath ) ) {
113
89
grunt . fail . fatal ( "Modules path does not exist." ) ;
114
90
}
115
91
} ) ;
116
92
117
- grunt . registerTask ( "checkTypings" , function ( ) {
118
- if ( ! grunt . file . exists ( typingsPath ) ) {
119
- grunt . fail . fatal ( "Typings path does not exist." ) ;
120
- }
121
- } ) ;
122
-
123
93
grunt . registerTask ( "checkAngular" , function ( ) {
124
94
if ( ! grunt . file . exists ( path . join ( angularSrcPath , 'angular2' ) ) ) {
125
95
grunt . fail . fatal ( "angular2 path does not exist." ) ;
@@ -132,25 +102,27 @@ module.exports = function(grunt) {
132
102
grunt . registerTask ( "app" , [
133
103
"copy:appFiles" ,
134
104
"ts:build" ,
135
- "prepareTnsModules " ,
105
+ "preDeploy " ,
136
106
] ) ;
137
107
138
108
grunt . registerTask ( "app-full" , [
139
109
"full-clean" ,
140
- "updateTypings" ,
141
- "updateModules" ,
142
- "updateAngular" ,
143
110
"app" ,
144
111
] ) ;
145
112
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
+ } ) ;
150
122
151
- grunt . registerTask ( "updateTypings " , [
152
- "checkTypings " ,
153
- "copy:typingsFiles " ,
123
+ grunt . registerTask ( "updateModules " , [
124
+ "getNSPackage " ,
125
+ "shell:localInstallModules " ,
154
126
] ) ;
155
127
156
128
grunt . registerTask ( "updateAngular" , [
@@ -168,14 +140,18 @@ module.exports = function(grunt) {
168
140
grunt . file . write ( packagePath , JSON . stringify ( packageData , null , 4 ) ) ;
169
141
} ) ;
170
142
171
- grunt . registerTask ( "prepareTnsModules" , [
172
- "copy:tnsifyAngular" ,
143
+ grunt . registerTask ( "prepare" , [
144
+ "updateModules" ,
145
+ "updateAngular" ,
173
146
"prepareQuerystringPackage" ,
147
+ ] ) ;
148
+
149
+ grunt . registerTask ( "preDeploy" , [
150
+ "copy:tnsifyAngularAndroid" ,
174
151
"clean:appBeforeDeploy" ,
175
152
] ) ;
176
153
177
154
grunt . registerTask ( "full-clean" , [
178
155
"removeAppDir" ,
179
- "removeNSFiles" ,
180
156
] ) ;
181
157
}
0 commit comments