MCPcopy
hub / github.com/meteor/meteor / ensurePluginsAreSynchronized

Method ensurePluginsAreSynchronized

tools/cordova/project.js:582–732  ·  view source on GitHub ↗
(pluginVersions, pluginsConfiguration = {})

Source from the content-addressed store, hash-verified

580 // Ensures that the Cordova plugins are synchronized with the app-level
581 // plugins.
582 ensurePluginsAreSynchronized(pluginVersions, pluginsConfiguration = {}) {
583 assert(pluginVersions);
584
585 buildmessage.assertInCapture();
586
587 buildmessage.enterJob({ title: "installing Cordova plugins"}, () => {
588 // Cordova plugin IDs have changed as part of moving to npm.
589 // We convert old plugin IDs to new IDs in the 1.2.0-cordova-changes
590 // upgrader and when adding plugins, but packages may still depend on
591 // the old IDs.
592 // To avoid attempts at duplicate installation, we check for old IDs here
593 // and convert them to new IDs when needed. We also convert old-style GitHub
594 // tarball URLs to new Git URLs, and check if other Git URLs contain a
595 // SHA reference.
596 pluginVersions = convertPluginVersions(pluginVersions);
597
598 // To ensure we do not attempt to install plugin versions incompatible
599 // with the current platform versions, we compare them against a list of
600 // pinned versions and adjust them if necessary.
601 this.ensurePinnedPluginVersions(pluginVersions);
602
603 if (buildmessage.jobHasMessages()) {
604 return;
605 }
606
607 // Also, we warn if any App.configurePlugin calls in mobile-config.js
608 // need to be updated (and in the meantime we take care of the
609 // conversion of the plugin configuration to the new ID).
610 pluginsConfiguration = _.object(_.map(pluginsConfiguration, (config, id) => {
611 const newId = newPluginId(id);
612 if (newId) {
613 Console.warn();
614 Console.labelWarn(`Cordova plugin ${id} has been renamed to ${newId} \
615as part of moving to npm. Please change the App.configurePlugin call in \
616mobile-config.js accordingly.`);
617 return [newId, config];
618 } else {
619 return [id, config];
620 }
621 }));
622
623 const installedPluginVersions =
624 convertPluginVersions(this.listInstalledPluginVersions());
625
626 // Due to the dependency structure of Cordova plugins, it is impossible to
627 // upgrade the version on an individual Cordova plugin. Instead, whenever
628 // a new Cordova plugin is added or removed, or its version is changed,
629 // we just reinstall all of the plugins.
630 let shouldReinstallAllPlugins = false;
631
632 // Iterate through all of the plugins and find if any of them have a new
633 // version. Additionally, check if we have plugins installed from a local
634 // path.
635 const pluginsFromLocalPath = {};
636 _.each(pluginVersions, (version, id) => {
637 // Check if plugin is installed from a local path.
638 const isPluginFromLocalPath = utils.isUrlWithFileScheme(version);
639

Callers 1

prepareFromAppBundleMethod · 0.95

Calls 15

removePluginsMethod · 0.95
addPluginMethod · 0.95
convertPluginVersionsFunction · 0.90
newPluginIdFunction · 0.90
mapMethod · 0.80
warnMethod · 0.80
labelWarnMethod · 0.80
eachMethod · 0.80

Tested by

no test coverage detected