11import * 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" ;
33import { getHash , hook } from "../common/helpers" ;
44import { PrepareData } from "../data/prepare-data" ;
55
@@ -9,21 +9,19 @@ class ProjectChangesInfo implements IProjectChangesInfo {
99
1010 public appResourcesChanged : boolean ;
1111 public configChanged : boolean ;
12- public packageChanged : boolean ;
1312 public nativeChanged : boolean ;
1413 public signingChanged : boolean ;
1514 public nativePlatformStatus : NativePlatformStatus ;
1615
1716 public get hasChanges ( ) : boolean {
18- return this . packageChanged ||
17+ return this . nativeChanged ||
1918 this . appResourcesChanged ||
2019 this . configChanged ||
2120 this . signingChanged ;
2221 }
2322
2423 public get changesRequireBuild ( ) : boolean {
25- return this . packageChanged ||
26- this . appResourcesChanged ||
24+ return this . appResourcesChanged ||
2725 this . nativeChanged ;
2826 }
2927
@@ -57,18 +55,23 @@ export class ProjectChangesService implements IProjectChangesService {
5755 this . _changesInfo = new ProjectChangesInfo ( ) ;
5856 const isNewPrepareInfo = await this . ensurePrepareInfo ( platformData , projectData , prepareData ) ;
5957 if ( ! isNewPrepareInfo ) {
60- this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
61-
6258 const platformResourcesDir = path . join ( projectData . appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
6359 this . _changesInfo . appResourcesChanged = this . containsNewerFiles ( platformResourcesDir , projectData ) ;
6460
6561 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 ) ) )
6763 . map ( dep => {
6864 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 ) ) ;
7067 } ) ;
7168
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+
7275 this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
7376
7477 if ( platformData . platformNameLowerCase === this . $devicePlatformsConstants . iOS . toLowerCase ( ) ) {
@@ -106,8 +109,6 @@ export class ProjectChangesService implements IProjectChangesService {
106109 if ( this . _prepareInfo . changesRequireBuild ) {
107110 this . _prepareInfo . changesRequireBuildTime = this . _prepareInfo . time ;
108111 }
109-
110- this . _prepareInfo . projectFileHash = this . getProjectFileStrippedHash ( projectData . projectDir , platformData ) ;
111112 }
112113
113114 this . _changesInfo . nativePlatformStatus = this . _prepareInfo . nativePlatformStatus ;
@@ -223,8 +224,7 @@ export class ProjectChangesService implements IProjectChangesService {
223224 return false ;
224225 }
225226
226- const dirFileStat = this . $fs . getFsStats ( dir ) ;
227- if ( this . isFileModified ( dirFileStat , dir ) ) {
227+ if ( this . isFileModified ( dir ) ) {
228228 this . $logger . trace ( `containsNewerFiles returns true for ${ dir } as the dir itself has been modified.` ) ;
229229 return true ;
230230 }
@@ -234,7 +234,7 @@ export class ProjectChangesService implements IProjectChangesService {
234234 const filePath = path . join ( dir , file ) ;
235235
236236 const fileStats = this . $fs . getFsStats ( filePath ) ;
237- const changed = this . isFileModified ( fileStats , filePath ) ;
237+ const changed = this . isFileModified ( filePath , fileStats ) ;
238238
239239 if ( changed ) {
240240 this . $logger . trace ( `containsNewerFiles returns true for ${ dir } . The modified file is ${ filePath } ` ) ;
@@ -253,9 +253,10 @@ export class ProjectChangesService implements IProjectChangesService {
253253 return false ;
254254 }
255255
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 ;
259260
260261 if ( ! changed ) {
261262 const lFileStats = this . $fs . getLsStats ( filePath ) ;
0 commit comments