diff --git a/History.md b/History.md index d3e859ab17..2685511aec 100644 --- a/History.md +++ b/History.md @@ -12,6 +12,8 @@ N/A * Facebook OAuth has been updated to `1.7.3` now using Facebook GraphAPI v8. +* Cordova add plugin works again with plugin id or plugin name in the git URL as it was before Meteor 1.11. [#11202](https://github.com/meteor/meteor/pull/11202) + ## v1.11.1, 2020-09-16 ### Breaking changes @@ -49,6 +51,8 @@ N/A instead of `dns.lookup()` which might be breaking on some environments. See [nodemailer changelog](https://github.com/nodemailer/nodemailer/blob/master/CHANGELOG.md) for more information. +* (Added later) Cordova add plugin is not working with plugin name in the git URL when the plugin id was different than the name in the config.xml. Fixed on [#11202](https://github.com/meteor/meteor/pull/11202) + ### Migration steps N/A diff --git a/tools/cordova/project.js b/tools/cordova/project.js index 828c565982..d224e2f56d 100644 --- a/tools/cordova/project.js +++ b/tools/cordova/project.js @@ -542,14 +542,15 @@ from Cordova project`, async () => { // Construct a target suitable for 'cordova plugin add' from an id and // version, converting or resolving a URL or path where needed. - targetForPlugin(id, version) { + targetForPlugin(id, version, { usePluginName = false } = {}) { assert(id); assert(version); buildmessage.assertInJob(); if (utils.isUrlWithSha(version)) { - return `${id}@${convertToGitUrl(version)}`; + return usePluginName ? convertToGitUrl(version) : + `${id}@${convertToGitUrl(version)}`; } else if (utils.isUrlWithFileScheme(version)) { // Strip file:// and resolve the path relative to the cordova-build // directory @@ -581,15 +582,29 @@ from Cordova project`, async () => { } } - addPlugin(id, version, config = {}) { - const target = this.targetForPlugin(id, version); + addPlugin(id, version, config = {}, options = {}) { + const { retry = true } = options; + const target = this.targetForPlugin(id, version, options); if (target) { const commandOptions = _.extend(this.defaultOptions, { cli_variables: config, link: utils.isUrlWithFileScheme(version) }); - this.runCommands(`adding plugin ${target} \ + try { + this.runCommands(`adding plugin ${target} \ to Cordova project`, cordova_lib.plugin.bind(undefined, 'add', [target], - commandOptions)); + commandOptions)); + } catch (error) { + if (retry && utils.isUrlWithSha(version)) { + Console.warn(`Cordova plugin add for ${id} failed with plugin id + in the URL with hash, retrying now with plugin name. If this works you + can ignore the error above or you can update your plugin declaration + to use the id from config.xml instead of the name from package.json`); + this.addPlugin(id, version, config, { ...options, + usePluginName: true, retry: false }); + return; + } + throw error; + } } } @@ -775,7 +790,6 @@ perform cordova plugins reinstall`); // @scope/plugin@1.0.0 => { 'com.cordova.plugin': 'scope/plugin' } const installed = this.listInstalledPluginVersions(); const installedPluginsNames = Object.keys(installed); - const installedPluginsVersions = Object.values(installed); const missingPlugins = {}; Object.keys(requiredPlugins).filter(plugin => {