Skip to content

Commit 39d6874

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Fix PR comments
1 parent 69a5c05 commit 39d6874

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

lib/definitions/project.d.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ interface IPlatformProjectService {
4242
isPlatformPrepared(projectRoot: string): IFuture<boolean>;
4343
addLibrary(libraryPath: string): IFuture<void>;
4444
canUpdatePlatform(currentVersion: string, newVersion: string): IFuture<boolean>;
45-
updatePlatform(currentVersion: string, newVersion: string, canUpdate: boolean): IFuture<boolean>;
45+
/**
46+
* Provides a platform specific update logic for the specified runtime versions.
47+
* @return true in cases when the update procedure should continue.
48+
*/
49+
updatePlatform(currentVersion: string, newVersion: string, canUpdate: boolean, addPlatform?: Function, removePlatform?: (platforms: string[]) => IFuture<void>): IFuture<boolean>;
4650
preparePluginNativeCode(pluginData: IPluginData, options?: any): IFuture<void>;
4751
removePluginNativeCode(pluginData: IPluginData): IFuture<void>;
4852
afterPrepareAllPlugins(): IFuture<void>;

lib/services/android-project-service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
2020
constructor(private $androidEmulatorServices: Mobile.IEmulatorPlatformServices,
2121
private $androidToolsInfo: IAndroidToolsInfo,
2222
private $childProcess: IChildProcess,
23-
private $commandsService: ICommandsService,
2423
private $errors: IErrors,
2524
$fs: IFileSystem,
2625
private $hostInfo: IHostInfo,
@@ -156,11 +155,12 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
156155
return Future.fromResult(true);
157156
}
158157

159-
public updatePlatform(currentVersion: string, newVersion: string, canUpdate: boolean): IFuture<boolean> {
158+
public updatePlatform(currentVersion: string, newVersion: string, canUpdate: boolean, addPlatform?: Function, removePlatforms?: (platforms: string[]) => IFuture<void>): IFuture<boolean> {
160159
return (() => {
161160
if(semver.eq(newVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE)) {
162-
this.$commandsService.tryExecuteCommand(process.argv[2], ["remove"].concat(process.argv.slice(4))).wait();
163-
this.$commandsService.tryExecuteCommand(process.argv[2], process.argv.slice(3)).wait();
161+
let platformLowercase = this.platformData.normalizedPlatformName.toLowerCase();
162+
removePlatforms([platformLowercase.split("@")[0]]).wait();
163+
addPlatform(platformLowercase).wait();
164164
return false;
165165
}
166166

lib/services/ios-project-service.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,17 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
247247
let isUpdateConfirmed = this.$prompter.confirm(`We need to override xcodeproj file. The old one will be saved at ${this.$options.profileDir}. Are you sure?`, () => true).wait();
248248
if(isUpdateConfirmed) {
249249
// Copy old file to options["profile-dir"]
250-
let sourceFile = path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName));
250+
let sourceFile = path.join(this.platformData.projectRoot, `${this.$projectData.projectName}.xcodeproj`);
251251
let destinationFile = path.join(this.$options.profileDir, "xcodeproj");
252252
this.$fs.deleteDirectory(destinationFile).wait();
253253
shell.cp("-R", path.join(sourceFile, "*"), destinationFile);
254-
this.$logger.info("Backup file %s at location %s", sourceFile, destinationFile);
255-
this.$fs.deleteDirectory(path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName))).wait();
254+
this.$logger.info(`Backup file ${sourceFile} at location ${destinationFile}`);
255+
this.$fs.deleteDirectory(sourceFile).wait();
256256

257257
// Copy xcodeProject file
258258
let cachedPackagePath = path.join(this.$npmInstallationManager.getCachedPackagePath(this.platformData.frameworkPackageName, newVersion), constants.PROJECT_FRAMEWORK_FOLDER_NAME, util.format("%s.xcodeproj", IOSProjectService.IOS_PROJECT_NAME_PLACEHOLDER));
259-
shell.cp("-R", path.join(cachedPackagePath, "*"), path.join(this.platformData.projectRoot, util.format("%s.xcodeproj", this.$projectData.projectName)));
260-
this.$logger.info("Copied from %s at %s.", cachedPackagePath, this.platformData.projectRoot);
259+
shell.cp("-R", path.join(cachedPackagePath, "*"), sourceFile);
260+
this.$logger.info(`Copied from ${cachedPackagePath} at ${this.platformData.projectRoot}.`);
261261

262262
let pbxprojFilePath = path.join(this.platformData.projectRoot, this.$projectData.projectName + IOSProjectService.XCODE_PROJECT_EXT_NAME, "project.pbxproj");
263263
this.replaceFileContent(pbxprojFilePath).wait();

lib/services/platform-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ export class PlatformService implements IPlatformService {
450450

451451
private updatePlatformCore(platformData: IPlatformData, currentVersion: string, newVersion: string, canUpdate: boolean): IFuture<void> {
452452
return (() => {
453-
let update = platformData.platformProjectService.updatePlatform(currentVersion, newVersion, canUpdate).wait();
453+
let update = platformData.platformProjectService.updatePlatform(currentVersion, newVersion, canUpdate, this.addPlatform.bind(this), this.removePlatforms.bind(this)).wait();
454454
if(update) {
455455
// Remove old framework files
456456
let oldFrameworkData = this.getFrameworkFiles(platformData, currentVersion).wait();

0 commit comments

Comments
 (0)