Skip to content

Commit bac6571

Browse files
committed
refactor(project-data): make appResourcesDirectoryPath getter
1 parent 64a973d commit bac6571

9 files changed

+21
-18
lines changed

lib/definitions/project.d.ts

+1
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

+3-1
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

+2-2
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
252252
shell.sed('-i', /__PROJECT_NAME__/, this.getProjectNameFromId(projectData), gradleSettingsFilePath);
253253

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

257257
try {
258258
shell.sed('-i', /__PACKAGE__/, projectData.projectId, userAppGradleFilePath);
@@ -374,7 +374,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
374374
}
375375

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

379379
const manifestExists = this.$fs.exists(originalAndroidManifestFilePath);
380380

lib/services/ios-entitlements-service.ts

+1-1
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

+6-6
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
759759

760760
private getInfoPlistPath(projectData: IProjectData): string {
761761
return path.join(
762-
projectData.getAppResourcesDirectoryPath(),
762+
projectData.appResourcesDirectoryPath,
763763
this.getPlatformData(projectData).normalizedPlatformName,
764764
this.getPlatformData(projectData).configurationFileName
765765
);
@@ -779,7 +779,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
779779

780780
private async mergeInfoPlists(buildOptions: IRelease, projectData: IProjectData): Promise<void> {
781781
const projectDir = projectData.projectDir;
782-
const infoPlistPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
782+
const infoPlistPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
783783
this.ensureConfigurationFileInAppResources();
784784

785785
if (!this.$fs.exists(infoPlistPath)) {
@@ -1209,7 +1209,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12091209
}
12101210
}
12111211

1212-
const appResourcesXcconfigPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
1212+
const appResourcesXcconfigPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
12131213
if (this.$fs.exists(appResourcesXcconfigPath)) {
12141214
await this.mergeXcconfigFiles(appResourcesXcconfigPath, pluginsXcconfigFilePath);
12151215
}
@@ -1264,7 +1264,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
12641264
}
12651265

12661266
private getBuildXCConfigFilePath(projectData: IProjectData): string {
1267-
const buildXCConfig = path.join(projectData.getAppResourcesDirectoryPath(),
1267+
const buildXCConfig = path.join(projectData.appResourcesDirectoryPath,
12681268
this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
12691269
return buildXCConfig;
12701270
}
@@ -1326,7 +1326,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13261326
const choicePersist = await this.$prompter.promptForChoice("Do you want to make teamId: " + teamId + " a persistent choice for your app?", choicesPersist);
13271327
switch (choicesPersist.indexOf(choicePersist)) {
13281328
case 0:
1329-
const xcconfigFile = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
1329+
const xcconfigFile = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, "build.xcconfig");
13301330
this.$fs.appendFile(xcconfigFile, "\nDEVELOPMENT_TEAM = " + teamId + "\n");
13311331
break;
13321332
case 1:
@@ -1344,7 +1344,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
13441344
}
13451345

13461346
private validateApplicationIdentifier(projectData: IProjectData): void {
1347-
const infoPlistPath = path.join(projectData.getAppResourcesDirectoryPath(), this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
1347+
const infoPlistPath = path.join(projectData.appResourcesDirectoryPath, this.getPlatformData(projectData).normalizedPlatformName, this.getPlatformData(projectData).configurationFileName);
13481348
const mergedPlistPath = this.getPlatformData(projectData).configurationFilePath;
13491349

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

lib/services/livesync/livesync-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi
525525
}
526526
}
527527

528-
pattern.push(projectData.getAppResourcesDirectoryPath());
528+
pattern.push(projectData.appResourcesDirectoryPath);
529529

530530
const currentWatcherInfo = this.liveSyncProcessesInfo[liveSyncData.projectDir].watcherInfo;
531531

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

+1-1
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

+4-4
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 = 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)