Skip to content

Commit 21abc36

Browse files
committed
refactor(project-data): make appResourcesDirectoryPath getter
1 parent 1142680 commit 21abc36

9 files changed

+21
-18
lines changed

lib/definitions/project.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ interface IProjectData extends IProjectDir {
6161
dependencies: any;
6262
devDependencies: IStringDictionary;
6363
appDirectoryPath: string;
64+
appResourcesDirectoryPath: string;
6465
projectType: string;
6566
/**
6667
* Initializes project data with the given project directory. If none supplied defaults to --path option or cwd.

lib/project-data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ export class ProjectData implements IProjectData {
3333
public projectId: string;
3434
public projectName: string;
3535
public appDirectoryPath: string;
36-
public appResourcesDirectoryPath: string;
36+
get appResourcesDirectoryPath(): string {
37+
return this.getAppResourcesDirectoryPath();
38+
}
3739
public dependencies: any;
3840
public devDependencies: IStringDictionary;
3941
public projectType: string;

lib/providers/project-files-provider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export class ProjectFilesProvider extends ProjectFilesProviderBase {
2323
mappedFilePath = path.join(platformData.appDestinationDirectoryPath, path.relative(projectData.projectDir, parsedFilePath));
2424
}
2525

26-
const appResourcesDirectoryPath = projectData.getAppResourcesDirectoryPath();
26+
const appResourcesDirectoryPath = projectData.appResourcesDirectoryPath;
2727
const platformSpecificAppResourcesDirectoryPath = path.join(appResourcesDirectoryPath, platformData.normalizedPlatformName);
2828
if (parsedFilePath.indexOf(appResourcesDirectoryPath) > -1 && parsedFilePath.indexOf(platformSpecificAppResourcesDirectoryPath) === -1) {
2929
return null;
3030
}
3131

3232
if (parsedFilePath.indexOf(platformSpecificAppResourcesDirectoryPath) > -1) {
33-
const appResourcesRelativePath = path.relative(path.join(projectData.getAppResourcesDirectoryPath(),
33+
const appResourcesRelativePath = path.relative(path.join(projectData.appResourcesDirectoryPath,
3434
platformData.normalizedPlatformName), parsedFilePath);
3535
mappedFilePath = path.join(platformData.platformProjectService.getAppResourcesDestinationDirectoryPath(projectData), appResourcesRelativePath);
3636
}

lib/services/android-project-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
269269
shell.sed('-i', /__PROJECT_NAME__/, this.getProjectNameFromId(projectData), gradleSettingsFilePath);
270270

271271
// will replace applicationId in app/App_Resources/Android/app.gradle if it has not been edited by the user
272-
const userAppGradleFilePath = path.join(projectData.getAppResourcesDirectoryPath(), this.$devicePlatformsConstants.Android, "app.gradle");
272+
const userAppGradleFilePath = path.join(projectData.appResourcesDirectoryPath, this.$devicePlatformsConstants.Android, "app.gradle");
273273

274274
try {
275275
shell.sed('-i', /__PACKAGE__/, projectData.projectId, userAppGradleFilePath);
@@ -391,7 +391,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
391391
}
392392

393393
public ensureConfigurationFileInAppResources(projectData: IProjectData): void {
394-
const originalAndroidManifestFilePath = path.join(projectData.getAppResourcesDirectoryPath(), this.$devicePlatformsConstants.Android, this.getPlatformData(projectData).configurationFileName);
394+
const originalAndroidManifestFilePath = path.join(projectData.appResourcesDirectoryPath, this.$devicePlatformsConstants.Android, this.getPlatformData(projectData).configurationFileName);
395395

396396
const manifestExists = this.$fs.exists(originalAndroidManifestFilePath);
397397

lib/services/ios-entitlements-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class IOSEntitlementsService {
1313

1414
private getDefaultAppEntitlementsPath(projectData: IProjectData) : string {
1515
const entitlementsName = IOSEntitlementsService.DefaultEntitlementsName;
16-
const entitlementsPath = path.join(projectData.getAppResourcesDirectoryPath(),
16+
const entitlementsPath = path.join(projectData.appResourcesDirectoryPath,
1717
this.$mobileHelper.normalizePlatformName(this.$devicePlatformsConstants.iOS),
1818
entitlementsName);
1919
return entitlementsPath;

lib/services/ios-project-service.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
765765

766766
private getInfoPlistPath(projectData: IProjectData): string {
767767
return path.join(
768-
projectData.getAppResourcesDirectoryPath(),
768+
projectData.appResourcesDirectoryPath,
769769
this.getPlatformData(projectData).normalizedPlatformName,
770770
this.getPlatformData(projectData).configurationFileName
771771
);
@@ -785,7 +785,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
785785

786786
private async mergeInfoPlists(buildOptions: IRelease, projectData: IProjectData): Promise<void> {
787787
const projectDir = projectData.projectDir;
788-
const infoPlistPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
788+
const infoPlistPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
789789
this.ensureConfigurationFileInAppResources();
790790

791791
if (!this.$fs.exists(infoPlistPath)) {
@@ -1215,7 +1215,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12151215
}
12161216
}
12171217

1218-
const appResourcesXcconfigPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
1218+
const appResourcesXcconfigPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
12191219
if (this.$fs.exists(appResourcesXcconfigPath)) {
12201220
await this.mergeXcconfigFiles(appResourcesXcconfigPath, pluginsXcconfigFilePath);
12211221
}
@@ -1270,7 +1270,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12701270
}
12711271

12721272
private getBuildXCConfigFilePath(projectData: IProjectData): string {
1273-
const buildXCConfig = path.join(projectData.getAppResourcesDirectoryPath(),
1273+
const buildXCConfig = path.join(projectData.appResourcesDirectoryPath,
12741274
this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
12751275
return buildXCConfig;
12761276
}
@@ -1332,7 +1332,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13321332
const choicePersist = await this.$prompter.promptForChoice("Do you want to make teamId: " + teamId + " a persistent choice for your app?", choicesPersist);
13331333
switch (choicesPersist.indexOf(choicePersist)) {
13341334
case 0:
1335-
const xcconfigFile = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
1335+
const xcconfigFile = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
13361336
this.$fs.appendFile(xcconfigFile, "\nDEVELOPMENT_TEAM = " + teamId + "\n");
13371337
break;
13381338
case 1:
@@ -1350,7 +1350,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13501350
}
13511351

13521352
private validateApplicationIdentifier(projectData: IProjectData): void {
1353-
const infoPlistPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
1353+
const infoPlistPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
13541354
const mergedPlistPath = this.getPlatformData(projectData).configurationFilePath;
13551355

13561356
if (!this.$fs.exists(infoPlistPath) || !this.$fs.exists(mergedPlistPath)) {

lib/services/livesync/livesync-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
537537
}
538538
}
539539

540-
pattern.push(projectData.getAppResourcesDirectoryPath());
540+
pattern.push(projectData.appResourcesDirectoryPath);
541541

542542
const currentWatcherInfo = this.liveSyncProcessesInfo[liveSyncData.projectDir].watcherInfo;
543543
const areWatcherPatternsDifferent = () => _.xor(currentWatcherInfo.patterns, patterns).length;

lib/services/prepare-platform-js-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class PreparePlatformJSService extends PreparePlatformService implements
105105

106106
private copyAppResourcesFiles(config: IPreparePlatformJSInfo) {
107107
const appDestinationDirectoryPath = path.join(config.platformData.appDestinationDirectoryPath, constants.APP_FOLDER_NAME);
108-
const appResourcesSourcePath = config.projectData.getAppResourcesDirectoryPath();
108+
const appResourcesSourcePath = config.projectData.appResourcesDirectoryPath;
109109

110110
shell.cp("-Rf", appResourcesSourcePath, appDestinationDirectoryPath);
111111
}

lib/services/project-changes-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export class ProjectChangesService implements IProjectChangesService {
6060
this._changesInfo = new ProjectChangesInfo();
6161
if (!this.ensurePrepareInfo(platform, projectData, projectChangesOptions)) {
6262
this._newFiles = 0;
63-
this._changesInfo.appFilesChanged = this.containsNewerFiles(projectData.appDirectoryPath, projectData.getAppResourcesDirectoryPath(), projectData);
63+
this._changesInfo.appFilesChanged = this.containsNewerFiles(projectData.appDirectoryPath, projectData.appResourcesDirectoryPath, projectData);
6464
this._changesInfo.packageChanged = this.isProjectFileChanged(projectData, platform);
65-
this._changesInfo.appResourcesChanged = this.containsNewerFiles(projectData.getAppResourcesDirectoryPath(), null, projectData);
65+
this._changesInfo.appResourcesChanged = this.containsNewerFiles(projectData.appResourcesDirectoryPath, null, projectData);
6666
/*done because currently all node_modules are traversed, a possible improvement could be traversing only the production dependencies*/
6767
this._changesInfo.nativeChanged = projectChangesOptions.skipModulesNativeCheck ? false : this.containsNewerFiles(
6868
path.join(projectData.projectDir, NODE_MODULES_FOLDER_NAME),
@@ -73,7 +73,7 @@ export class ProjectChangesService implements IProjectChangesService {
7373
if (this._newFiles > 0 || this._changesInfo.nativeChanged) {
7474
this._changesInfo.modulesChanged = true;
7575
}
76-
const platformResourcesDir = path.join(projectData.getAppResourcesDirectoryPath(), platformData.normalizedPlatformName);
76+
const platformResourcesDir = path.join(projectData.appResourcesDirectoryPath, platformData.normalizedPlatformName);
7777
if (platform === this.$devicePlatformsConstants.iOS.toLowerCase()) {
7878
this._changesInfo.configChanged = this.filesChanged([path.join(platformResourcesDir, platformData.configurationFileName),
7979
path.join(platformResourcesDir, "LaunchScreen.storyboard"),
@@ -282,7 +282,7 @@ export class ProjectChangesService implements IProjectChangesService {
282282
return true;
283283
}
284284
const projectDir = projectData.projectDir;
285-
if (_.startsWith(path.join(projectDir, file), projectData.getAppResourcesDirectoryPath())) {
285+
if (_.startsWith(path.join(projectDir, file), projectData.appResourcesDirectoryPath)) {
286286
return true;
287287
}
288288
if (_.startsWith(file, NODE_MODULES_FOLDER_NAME)) {

0 commit comments

Comments
 (0)