Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports.prepare = function (cordovaProject, options) {
var self = this;
var platformJson = PlatformJson.load(this.locations.root, this.platform);
var munger = new PlatformMunger(this.platform, this.locations.root, platformJson, new PluginInfoProvider());
this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
// Update own www dir with project's www assets and plugins' assets and js-files
return Q.when(updateWww(cordovaProject, this.locations))
.then(function () {
// update project according to config.xml changes.
return updateProjectAccordingTo(self._config, self.locations);
})
.then(function () {
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
})
.then(function () {
events.emit('verbose', 'Prepared android project successfully');
});
module.exports.prepare = function (cordovaProject, options) {
var self = this;
var platformJson = PlatformJson.load(this.locations.root, this.platform);
var munger = new PlatformMunger(this.platform, this.locations.root, platformJson, new PluginInfoProvider());
this._config = updateConfigFilesFrom(cordovaProject.projectConfig, munger, this.locations);
// Update own www dir with project's www assets and plugins' assets and js-files
return Q.when(updateWww(cordovaProject, this.locations)).then(function () {
// update project according to config.xml changes.
return updateProjectAccordingTo(self._config, self.locations);
}).then(function () {
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
updateFileResources(cordovaProject, path.relative(cordovaProject.root, self.locations.root));
}).then(function () {
events.emit('verbose', 'Prepared android project successfully');
});
};
function getInstalledPlugins (projectRoot) {
var pluginsDir = path.join(projectRoot, 'plugins');
// TODO: This should list based off of platform.json, not directories within plugins/
var pluginInfoProvider = new PluginInfoProvider();
return pluginInfoProvider.getAllWithinSearchPath(pluginsDir);
}
if (pluginSource.hasOwnProperty('id')) {
// Note that currently version is only saved here if it was explicitly specified when the plugin was added.
var parsedSpec = pluginSpec.parse(pluginSource.id);
version = parsedSpec.version;
if (version) {
version = module.exports.versionString(version);
}
if (parsedSpec.scope) {
scopedPackage = parsedSpec.package;
}
}
if (!version) {
// Fallback on getting version from the plugin folder, if it's there
var pluginInfoProvider = new PluginInfoProvider();
var dir = path.join(projectRoot, 'plugins', pluginName);
try {
// pluginInfoProvider.get() will throw if directory does not exist.
var pluginInfo = pluginInfoProvider.get(dir);
if (pluginInfo) {
version = module.exports.versionString(pluginInfo.version);
}
} catch (err) {
}
}
if (scopedPackage) {
version = scopedPackage + '@' + version;
}
.then(function() {
var pluginInfoProvider = new PluginInfoProvider();
return opts.plugins.reduce(function(soFar, target) {
return soFar.then(function() {
if (target[target.length - 1] == path.sep) {
target = target.substring(0, target.length - 1);
}
// Fetch the plugin first.
var fetchOptions = {
searchpath: searchPath,
noregistry: opts.noregistry,
fetch: opts.fetch || false,
save: opts.save,
nohooks: opts.nohooks,
link: opts.link,
pluginInfoProvider: pluginInfoProvider,
variables: opts.cli_variables,
module.exports.prepare = function (cordovaProject, options) {
var self = this;
var platformJson = PlatformJson.load(this.locations.root, 'ios');
var munger = new PlatformMunger('ios', this.locations.root, platformJson, new PluginInfoProvider());
this._config = updateConfigFile(cordovaProject.projectConfig, munger, this.locations);
// Update own www dir with project's www assets and plugins' assets and js-files
return Q.when(updateWww(cordovaProject, this.locations))
.then(function () {
// update project according to config.xml changes.
return updateProject(self._config, self.locations);
})
.then(function () {
updateIcons(cordovaProject, self.locations);
updateSplashScreens(cordovaProject, self.locations);
updateLaunchStoryboardImages(cordovaProject, self.locations);
updateFileResources(cordovaProject, self.locations);
})
.then(function () {
it('Test 001 : should return a list of top-level plugins based on what is inside a platform.json file', function() {
var tlps = {
'hello':'',
'isitme':'',
'yourelookingfor':''
};
var platformJson = new PlatformJson('filePath', 'platform', {
installed_plugins:tlps,
dependent_plugins:[]
});
var pluginInfoProvider = new PluginInfoProvider();
Object.keys(tlps).forEach(function(k) {
pluginInfoProvider.put({id:k, dir: path.join('plugins_dir', k), getDependencies: function() {return[];}});
});
spyOn(xml_helpers, 'parseElementtreeSync').and.returnValue({findall:function(){}});
var obj = dependencies.generateDependencyInfo(platformJson, 'plugins_dir', pluginInfoProvider);
expect(obj.top_level_plugins).toEqual(Object.keys(tlps));
});
it('Test 002 : should return a dependency graph for the plugins', function() {
function getAllPluginsHookScriptFiles (hook, opts) {
var scripts = [];
var currentPluginOptions;
var plugins = (new PluginInfoProvider()).getAllWithinSearchPath(path.join(opts.projectRoot, 'plugins'));
plugins.forEach(function (pluginInfo) {
currentPluginOptions = {
id: pluginInfo.id,
pluginInfo: pluginInfo,
dir: pluginInfo.dir
};
scripts = scripts.concat(getPluginScriptFiles(currentPluginOptions, hook, opts.cordova.platforms));
});
return scripts;
}
get: function (platformRoot) {
if (!_instance) {
_instance = new PlatformMunger('osx', platformRoot, PlatformJson.load(platformRoot, 'osx'),
new PluginInfoProvider());
}
return _instance;
}
};
function getAllPluginsHookScriptFiles(hook, opts) {
var scripts = [];
var currentPluginOptions;
var plugins = (new PluginInfoProvider()).getAllWithinSearchPath(path.join(opts.projectRoot, 'plugins'));
plugins.forEach(function(pluginInfo) {
currentPluginOptions = {
id: pluginInfo.id,
pluginInfo: pluginInfo,
dir: pluginInfo.dir
};
scripts = scripts.concat(getPluginScriptFiles(currentPluginOptions, hook, opts.cordova.platforms));
});
return scripts;
}