Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12738

cordova ignores plugin dependency version

    XMLWordPrintableJSON

    Details

      Description

      You can see this with the cordova-plugin-file-transfer. When you install this plugin and it installs the cordova-plugin-file plugin dependency the CLI writes
      Fetching plugin "cordova-plugin-file" via npm

      The first problem is in the PluginInfo _parseDependency function
      https://git-wip-us.apache.org/repos/asf?p=cordova-lib.git;a=blob;f=cordova-common/src/PluginInfo/PluginInfo.js;h=48174707b0dbf6f60eb65faeb14c51e4b3868b1b;hb=HEAD#l108

      It does not parse out the dependency version. This part:

              var dep =
                  { id : tag.attrib.id
                  , url : tag.attrib.url || ''
                  , subdir : tag.attrib.subdir || ''
                  , commit : tag.attrib.commit
                  };
      

      Should be:

              var dep =
                  { id : tag.attrib.id
                  , url : tag.attrib.url || ''
                  , subdir : tag.attrib.subdir || ''
                  , commit : tag.attrib.commit
                  , version : tag.attrib.version
                  };
      

      The second problem is in the plugman installDependency method
      https://git-wip-us.apache.org/repos/asf?p=cordova-lib.git;a=blob;f=cordova-lib/src/plugman/install.js;h=fca77c688d2b8f19ce63cb176f50ecd44c9a9032;hb=HEAD#l603

      The dep_src is only constructed using the plugin id.

      This:

      var dep_src = dep.url.length ? dep.url : dep.id;
      

      Should look something like:

              var dep_src;
      
              if (dep.url.length) {
                  dep_src = dep.url;
              }
              else if (dep.version) {
                  dep_src = dep.id + '@' + dep.version;
              } else {
                  dep_src = dep.id;
              } 
      

      With these changes the Cordova CLI correctly reports:

      Fetching plugin "cordova-plugin-file@^4.0.0" via npm

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Nikita Matrosov Nikita Matrosov
                Reporter:
                mpridham Marcus Pridham
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: