From 9e962b40ad43bfa8220bc8791e70513e3488297f Mon Sep 17 00:00:00 2001 From: filipenevola Date: Mon, 5 Oct 2020 13:32:12 -0400 Subject: [PATCH 1/3] When cordova add plugin fails using the id in the git URL we now retry using the plugin name. Fixes #11199 --- tools/cordova/project.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tools/cordova/project.js b/tools/cordova/project.js index 828c565982..9194c5d7f3 100644 --- a/tools/cordova/project.js +++ b/tools/cordova/project.js @@ -542,14 +542,14 @@ 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 +581,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(`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 +789,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 => { From f9aed3e2a69935b889bf68241948e9d15836abf3 Mon Sep 17 00:00:00 2001 From: filipenevola Date: Tue, 6 Oct 2020 18:52:51 -0400 Subject: [PATCH 2/3] When cordova add plugin fails using the id in the git URL we now retry using the plugin name. - improve logs --- tools/cordova/project.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/cordova/project.js b/tools/cordova/project.js index 9194c5d7f3..d224e2f56d 100644 --- a/tools/cordova/project.js +++ b/tools/cordova/project.js @@ -549,7 +549,8 @@ from Cordova project`, async () => { buildmessage.assertInJob(); if (utils.isUrlWithSha(version)) { - return usePluginName ? convertToGitUrl(version) : `${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 @@ -594,12 +595,12 @@ to Cordova project`, cordova_lib.plugin.bind(undefined, 'add', [target], commandOptions)); } catch (error) { if (retry && utils.isUrlWithSha(version)) { - Console.warn(`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 }); + 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; From 903ba00657b8d7625fa955d648b17295a68e8b1f Mon Sep 17 00:00:00 2001 From: filipenevola Date: Tue, 6 Oct 2020 18:55:51 -0400 Subject: [PATCH 3/3] When cordova add plugin fails using the id in the git URL we now retry using the plugin name. - history.md --- History.md | 4 ++++ 1 file changed, 4 insertions(+) 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