Skip to content

Commit 4887915

Browse files
committed
fix: do not validate invalid platforms versions
1 parent eedfd5e commit 4887915

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/controllers/migrate-controller.ts

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
2626
private $addPlatformService: IAddPlatformService,
2727
private $pluginsService: IPluginsService,
2828
private $projectDataService: IProjectDataService,
29+
private $platformValidationService: IPlatformValidationService,
2930
private $resources: IResourceLoader) {
3031
super($fs, $platformCommandHelper, $platformsDataService, $packageInstallationManager, $packageManager, $pacoteService);
3132
}
@@ -159,6 +160,9 @@ Running this command will ${MigrateController.COMMON_MIGRATE_MESSAGE}`;
159160

160161
for (let platform of platforms) {
161162
platform = platform && platform.toLowerCase();
163+
if (!this.$platformValidationService.isValidPlatform(platform, projectData)) {
164+
continue;
165+
}
162166

163167
const hasRuntimeDependency = this.hasRuntimeDependency({ platform, projectData });
164168
if (hasRuntimeDependency && await this.shouldUpdateRuntimeVersion(this.verifiedPlatformVersions[platform.toLowerCase()], platform, projectData, allowInvalidVersions)) {

lib/declarations.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,11 @@ interface IPlatformValidationService {
10211021
*/
10221022
validatePlatform(platform: string, projectData: IProjectData): void;
10231023

1024+
/**
1025+
* Returns whether the passed platform is a valid one (from the supported ones)
1026+
*/
1027+
isValidPlatform(platform: string, projectData: IProjectData): boolean;
1028+
10241029
/**
10251030
* Gets first chance to validate the options provided as command line arguments.
10261031
* If no platform is provided or a falsy (null, undefined, "", false...) platform is provided,

lib/services/platform/platform-validation-service.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,25 @@ export class PlatformValidationService implements IPlatformValidationService {
1111
private $platformsDataService: IPlatformsDataService
1212
) { }
1313

14-
public validatePlatform(platform: string, projectData: IProjectData): void {
14+
public isValidPlatform(platform: string, projectData: IProjectData): boolean {
1515
if (!platform) {
16-
this.$errors.fail("No platform specified.");
16+
return false;
1717
}
1818

1919
platform = platform.split("@")[0].toLowerCase();
20-
2120
if (!this.$platformsDataService.getPlatformData(platform, projectData)) {
21+
return false;
22+
}
23+
24+
return true;
25+
}
26+
27+
public validatePlatform(platform: string, projectData: IProjectData): void {
28+
if (!platform) {
29+
this.$errors.fail("No platform specified.");
30+
}
31+
32+
if (!this.isValidPlatform(platform, projectData)) {
2233
const platformNames = helpers.formatListOfNames(this.$mobileHelper.platformNames);
2334
this.$errors.fail(`Invalid platform ${platform}. Valid platforms are ${platformNames}.`);
2435
}

0 commit comments

Comments
 (0)