Skip to content

Commit

Permalink
CB-12606 Fix plugin dependency installation
Browse files Browse the repository at this point in the history
  • Loading branch information
alsorokin committed Mar 27, 2017
1 parent 43d7eaf commit 4c99c0d
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 4 deletions.
31 changes: 28 additions & 3 deletions cordova-lib/spec-plugman/install.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

/* jshint sub:true */
/* globals fail*/

var helpers = require('../spec-cordova/helpers'),
path = require('path'),
Expand Down Expand Up @@ -65,10 +66,11 @@ var helpers = require('../spec-cordova/helpers'),
'C@1.0.0' : path.join(plugins_dir, 'dependencies', 'C@1.0.0'),
'Test1' : path.join(plugins_dir, 'dependencies', 'Test1'),
'Test2' : path.join(plugins_dir, 'dependencies', 'Test2'),
'Test3' : path.join(plugins_dir, 'dependencies', 'Test3')
'Test3' : path.join(plugins_dir, 'dependencies', 'Test3'),
'Test4' : path.join(plugins_dir, 'dependencies', 'Test4')
},
results = {},
TIMEOUT = 60000,
TIMEOUT = 90000,
superspawn = require('cordova-common').superspawn;


Expand Down Expand Up @@ -649,11 +651,34 @@ describe('end-to-end plugin dependency tests', function() {
}, TIMEOUT)
.fin(done);
}, TIMEOUT);

it('Test 033 : should use a dev version of a dependent plugin if it is already installed', function(done) {
//Test4 has this dependency in its plugin.xml:
//<dependency id="cordova-plugin-file" url="https://github.com/apache/cordova-plugin-file" />
cordova.raw.create('hello3')
.then(function() {
process.chdir(project);
return cordova.raw.platform('add', 'android', {'fetch': true});
})
.then(function() {
return cordova.raw.plugin('add', 'https://github.com/apache/cordova-plugin-file');
})
.then(function() {
return cordova.raw.plugin('add', plugins['Test4'], {'fetch': true});
})
.then(function() {
expect(path.join(pluginsDir, 'cordova-plugin-file')).toExist();
expect(path.join(pluginsDir, 'Test4')).toExist();
}, function (error) {
fail(error);
})
.fin(done);
}, TIMEOUT);
});

describe('end', function() {

it('Test 033 : end', function() {
it('Test 034 : end', function() {
shell.rm('-rf', temp_dir);
}, TIMEOUT);
});
1 change: 1 addition & 0 deletions cordova-lib/spec-plugman/plugins/dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ I -> C@1.0.0
Test1 --> cordova-plugin-file@2.0.0
Test2 --> cordova-plugin-file@2.X.0
Test3 --> cordova-plugin-file@3.0.0
Test4 --> cordova-plugin-file@https://github.com/apache/cordova-plugin-file

11 changes: 11 additions & 0 deletions cordova-lib/spec-plugman/plugins/dependencies/Test4/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "test4",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
46 changes: 46 additions & 0 deletions cordova-lib/spec-plugman/plugins/dependencies/Test4/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013 Anis Kadri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="Test4"
version="0.0.0">

<name>Plugin Test4</name>

<dependency id="cordova-plugin-file" url="https://github.com/apache/cordova-plugin-file" />

<asset src="www/plugin-test.js" target="plugin-test.js" />

<config-file target="config.xml" parent="/*">
<access origin="build.phonegap.com" />
</config-file>

<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="plugins">
<plugin name="Test4"
value="org.test.Test4.Test4"/>
</config-file>

<source-file src="src/android/Test4.java"
target-dir="src/com/phonegap/Test4" />
</platform>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./dependencies/Test3/src/android/Test4.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./dependencies/Test4/www/plugin-test.js
3 changes: 2 additions & 1 deletion cordova-lib/src/plugman/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ function installDependency(dep, install, options) {
if (options.force ||
semver.satisfies(version_installed, version_required, /*loose=*/true) ||
version_required === null ||
version_required === undefined ) {
version_required === undefined ||
version_required === '' ) {
events.emit('log', 'Plugin dependency "' + (version_installed ? dep.id+'@'+version_installed : dep.id) + '" already fetched, using that version.');
} else {
var msg = 'Version of installed plugin: "' +
Expand Down

0 comments on commit 4c99c0d

Please sign in to comment.