Skip to content

Show user friendly message when the plugin is not supported for installed platform #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 33 additions & 31 deletions lib/services/plugins-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,50 +61,52 @@ export class PluginsService implements IPluginsService {
public prepare(pluginData: IPluginData): IFuture<void> {
return (() => {
let action = (pluginDestinationPath: string, platform: string, platformData: IPlatformData) => {
let skipExecution = false;
// Process .js files
let installedFrameworkVersion = this.getInstalledFrameworkVersion(platform).wait();
let pluginPlatformsData = pluginData.platformsData;
if(pluginPlatformsData) {
let pluginVersion = (<any>pluginPlatformsData)[platform];
if(!pluginVersion) {
this.$logger.warn(`${pluginData.name} is not supported for ${platform}.`);
return;
}

if(semver.gt(pluginVersion, installedFrameworkVersion)) {
this.$logger.warn(`${pluginData.name} ${pluginVersion} for ${platform} is not compatible with the currently installed framework version ${installedFrameworkVersion}.`);
skipExecution = true;
return;
}
}

this.$fs.ensureDirectoryExists(pluginDestinationPath).wait();
shelljs.cp("-R", pluginData.fullPath, pluginDestinationPath);

let pluginPlatformsFolderPath = path.join(pluginDestinationPath, pluginData.name, "platforms", platform);
let pluginConfigurationFilePath = path.join(pluginPlatformsFolderPath, platformData.configurationFileName);
let configurationFilePath = platformData.configurationFilePath;

if(!skipExecution) {
this.$fs.ensureDirectoryExists(pluginDestinationPath).wait();
shelljs.cp("-R", pluginData.fullPath, pluginDestinationPath);

let pluginPlatformsFolderPath = path.join(pluginDestinationPath, pluginData.name, "platforms", platform);
let pluginConfigurationFilePath = path.join(pluginPlatformsFolderPath, platformData.configurationFileName);
let configurationFilePath = platformData.configurationFilePath;

if(this.$fs.exists(pluginConfigurationFilePath).wait()) {
// Validate plugin configuration file
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath).wait();
this.validateXml(pluginConfigurationFileContent, pluginConfigurationFilePath);

// Validate configuration file
let configurationFileContent = this.$fs.readText(configurationFilePath).wait();
this.validateXml(configurationFileContent, configurationFilePath);

// Merge xml
let resultXml = this.mergeXml(configurationFileContent, pluginConfigurationFileContent, platformData.mergeXmlConfig || []).wait();
this.validateXml(resultXml);
this.$fs.writeFile(configurationFilePath, resultXml).wait();
}

if(this.$fs.exists(pluginPlatformsFolderPath).wait()) {
shelljs.rm("-rf", pluginPlatformsFolderPath);
}
if(this.$fs.exists(pluginConfigurationFilePath).wait()) {
// Validate plugin configuration file
let pluginConfigurationFileContent = this.$fs.readText(pluginConfigurationFilePath).wait();
this.validateXml(pluginConfigurationFileContent, pluginConfigurationFilePath);

// TODO: Add libraries
// Validate configuration file
let configurationFileContent = this.$fs.readText(configurationFilePath).wait();
this.validateXml(configurationFileContent, configurationFilePath);

// Show message
this.$logger.out(`Successfully prepared plugin ${pluginData.name} for ${platform}.`);
// Merge xml
let resultXml = this.mergeXml(configurationFileContent, pluginConfigurationFileContent, platformData.mergeXmlConfig || []).wait();
this.validateXml(resultXml);
this.$fs.writeFile(configurationFilePath, resultXml).wait();
}

if(this.$fs.exists(pluginPlatformsFolderPath).wait()) {
shelljs.rm("-rf", pluginPlatformsFolderPath);
}

// TODO: Add libraries

// Show message
this.$logger.out(`Successfully prepared plugin ${pluginData.name} for ${platform}.`);
};

this.executeForAllInstalledPlatforms(action);
Expand Down