1
1
import * as path from "path" ;
2
- import { NativePlatformStatus , PACKAGE_JSON_FILE_NAME , APP_GRADLE_FILE_NAME , BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
2
+ import { NativePlatformStatus , PACKAGE_JSON_FILE_NAME , APP_GRADLE_FILE_NAME , BUILD_XCCONFIG_FILE_NAME , PLATFORMS_DIR_NAME } from "../constants" ;
3
3
import { getHash , hook } from "../common/helpers" ;
4
4
import { PrepareData } from "../data/prepare-data" ;
5
5
@@ -9,21 +9,19 @@ class ProjectChangesInfo implements IProjectChangesInfo {
9
9
10
10
public appResourcesChanged : boolean ;
11
11
public configChanged : boolean ;
12
- public packageChanged : boolean ;
13
12
public nativeChanged : boolean ;
14
13
public signingChanged : boolean ;
15
14
public nativePlatformStatus : NativePlatformStatus ;
16
15
17
16
public get hasChanges ( ) : boolean {
18
- return this . packageChanged ||
17
+ return this . nativeChanged ||
19
18
this . appResourcesChanged ||
20
19
this . configChanged ||
21
20
this . signingChanged ;
22
21
}
23
22
24
23
public get changesRequireBuild ( ) : boolean {
25
- return this . packageChanged ||
26
- this . appResourcesChanged ||
24
+ return this . appResourcesChanged ||
27
25
this . nativeChanged ;
28
26
}
29
27
@@ -57,18 +55,23 @@ export class ProjectChangesService implements IProjectChangesService {
57
55
this . _changesInfo = new ProjectChangesInfo ( ) ;
58
56
const isNewPrepareInfo = await this . ensurePrepareInfo ( platformData , projectData , prepareData ) ;
59
57
if ( ! isNewPrepareInfo ) {
60
- this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
61
-
62
58
const platformResourcesDir = path . join ( projectData . appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
63
59
this . _changesInfo . appResourcesChanged = this . containsNewerFiles ( platformResourcesDir , projectData ) ;
64
60
65
61
this . $nodeModulesDependenciesBuilder . getProductionDependencies ( projectData . projectDir )
66
- . filter ( dep => dep . nativescript && this . $fs . exists ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ) )
62
+ . filter ( dep => dep . nativescript && this . $fs . exists ( path . join ( dep . directory , PLATFORMS_DIR_NAME , platformData . platformNameLowerCase ) ) )
67
63
. map ( dep => {
68
64
this . _changesInfo . nativeChanged = this . _changesInfo . nativeChanged ||
69
- this . containsNewerFiles ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) , projectData ) ;
65
+ this . containsNewerFiles ( path . join ( dep . directory , PLATFORMS_DIR_NAME , platformData . platformNameLowerCase ) , projectData ) ||
66
+ this . isFileModified ( path . join ( dep . directory , PACKAGE_JSON_FILE_NAME ) ) ;
70
67
} ) ;
71
68
69
+ if ( ! this . _changesInfo . nativeChanged ) {
70
+ const packageJsonChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
71
+ this . _prepareInfo . projectFileHash = this . getProjectFileStrippedHash ( projectData . projectDir , platformData ) ;
72
+ this . _changesInfo . nativeChanged = packageJsonChanged ;
73
+ }
74
+
72
75
this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
73
76
74
77
if ( platformData . platformNameLowerCase === this . $devicePlatformsConstants . iOS . toLowerCase ( ) ) {
@@ -106,8 +109,6 @@ export class ProjectChangesService implements IProjectChangesService {
106
109
if ( this . _prepareInfo . changesRequireBuild ) {
107
110
this . _prepareInfo . changesRequireBuildTime = this . _prepareInfo . time ;
108
111
}
109
-
110
- this . _prepareInfo . projectFileHash = this . getProjectFileStrippedHash ( projectData . projectDir , platformData ) ;
111
112
}
112
113
113
114
this . _changesInfo . nativePlatformStatus = this . _prepareInfo . nativePlatformStatus ;
@@ -223,8 +224,7 @@ export class ProjectChangesService implements IProjectChangesService {
223
224
return false ;
224
225
}
225
226
226
- const dirFileStat = this . $fs . getFsStats ( dir ) ;
227
- if ( this . isFileModified ( dirFileStat , dir ) ) {
227
+ if ( this . isFileModified ( dir ) ) {
228
228
this . $logger . trace ( `containsNewerFiles returns true for ${ dir } as the dir itself has been modified.` ) ;
229
229
return true ;
230
230
}
@@ -234,7 +234,7 @@ export class ProjectChangesService implements IProjectChangesService {
234
234
const filePath = path . join ( dir , file ) ;
235
235
236
236
const fileStats = this . $fs . getFsStats ( filePath ) ;
237
- const changed = this . isFileModified ( fileStats , filePath ) ;
237
+ const changed = this . isFileModified ( filePath , fileStats ) ;
238
238
239
239
if ( changed ) {
240
240
this . $logger . trace ( `containsNewerFiles returns true for ${ dir } . The modified file is ${ filePath } ` ) ;
@@ -253,9 +253,10 @@ export class ProjectChangesService implements IProjectChangesService {
253
253
return false ;
254
254
}
255
255
256
- private isFileModified ( filePathStat : IFsStats , filePath : string ) : boolean {
257
- let changed = filePathStat . mtime . getTime ( ) >= this . _outputProjectMtime ||
258
- filePathStat . ctime . getTime ( ) >= this . _outputProjectCTime ;
256
+ private isFileModified ( filePath : string , filePathStats ?: IFsStats ) : boolean {
257
+ filePathStats = filePathStats || this . $fs . getFsStats ( filePath ) ;
258
+ let changed = filePathStats . mtime . getTime ( ) >= this . _outputProjectMtime ||
259
+ filePathStats . ctime . getTime ( ) >= this . _outputProjectCTime ;
259
260
260
261
if ( ! changed ) {
261
262
const lFileStats = this . $fs . getLsStats ( filePath ) ;
0 commit comments