Repository: cordova-lib Updated Branches: refs/heads/master bef308869 -> 3b38b5382
CB-9825 framework tag spec parsing Tests for cocoapod integration for plugins Tests for conflicting spec dependency Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/4353e104 Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/4353e104 Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/4353e104 Branch: refs/heads/master Commit: 4353e10473ecd5d4b8b10b39ca60cc20d508be14 Parents: bef3088 Author: juliascript <[email protected]> Authored: Fri Jul 1 11:42:45 2016 -0700 Committer: Shazron Abdullah <[email protected]> Committed: Thu Aug 18 23:20:28 2016 -0700 ---------------------------------------------------------------------- .../plugin.xml | 15 +++ .../www/test.js | 0 .../plugin.xml | 14 +++ .../www/test.js | 0 cordova-lib/spec-cordova/platform.spec.js | 114 +++++++++++++++++++ cordova-lib/src/cordova/util.js | 2 +- 6 files changed, 144 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/plugin.xml b/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/plugin.xml new file mode 100644 index 0000000..ec193d0 --- /dev/null +++ b/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/plugin.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + xmlns:android="http://schemas.android.com/apk/res/android" + id="sample-cocoapod-plugin-overlapping-dependency" + version="1.1.3-dev"> + + <name>Test Plugin</name> + + <asset src="www/test.js" target="test.js" /> + <platform name="ios"> + <framework src="AFNetworking" spec="~> 2.0" weak="false" type="podspec"/> + <framework src="CWStatusBarNotification" weak="false" type="podpsec"/> + </platform> +</plugin> + http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/www/test.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/www/test.js b/cordova-lib/spec-cordova/fixtures/plugins/sample-cocoapod-plugin-overlapping-dependency/www/test.js new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/plugin.xml ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/plugin.xml b/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/plugin.xml new file mode 100644 index 0000000..6ea800f --- /dev/null +++ b/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/plugin.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + xmlns:android="http://schemas.android.com/apk/res/android" + id="sample-cordova-plugin-cocoapod-dependent" + version="1.1.3-dev"> + + <name>Test Plugin</name> + + <asset src="www/test.js" target="test.js" /> + <platform name="ios"> + <framework src="AFNetworking" spec="~> 3.0" weak="false" type="podspec"/> + </platform> +</plugin> + http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/www/test.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/www/test.js b/cordova-lib/spec-cordova/fixtures/plugins/sample-cordova-plugin-cocoapod-dependent/www/test.js new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/spec-cordova/platform.spec.js ---------------------------------------------------------------------- diff --git a/cordova-lib/spec-cordova/platform.spec.js b/cordova-lib/spec-cordova/platform.spec.js index a944a24..fffe5ce 100644 --- a/cordova-lib/spec-cordova/platform.spec.js +++ b/cordova-lib/spec-cordova/platform.spec.js @@ -356,3 +356,117 @@ describe('plugin add and rm end-to-end --fetch', function () { .fin(done); }, 60000); }); + +describe('cocoapod plugin add and rm end-to-end', function () { + + var tmpDir = helpers.tmpDir('cocoapod_plugin_test'); + var project = path.join(tmpDir, 'hello4'); + + var samplePlugin = path.join(__dirname, 'fixtures', 'plugins', 'sample-cordova-plugin-cocoapod-dependent'); + var overlappingDependencyPlugin = path.join(__dirname, 'fixtures', 'plugins', 'sample-cocoapod-plugin-overlapping-dependency'); + var AFNetworking = 'AFNetworking', + CWStatusBarNotification = 'CWStatusBarNotification'; + var podfile, podsJSON, workspace; + + beforeEach(function() { + process.chdir(tmpDir); + }); + + afterEach(function() { + process.chdir(path.join(__dirname, '..')); // Needed to rm the dir on Windows. + shell.rm('-rf', tmpDir); + }); + + it('installs and uninstalls plugin depending on new pod and existing pod', function(done) { + + cordova.raw.create('hello4') + .then(function() { + process.chdir(project); + //TODO: change this to cordova-ios on npm + return cordova.raw.platform('add', 'https://github.com/juliascript/cordova-ios.git#CB-9825'); + }) + .then(function() { + return cordova.raw.plugin('add', samplePlugin); + }) + .then(function() { + podfile = path.resolve('./platforms/ios/Podfile'); + podsJSON = path.resolve('./platforms/ios/pods.json'); + workspace = path.resolve('./platforms/ios/HelloCordova.xcworkspace'); + + //podfile should have been created + fs.exists(podfile, function(podfileExists){ + expect(podfileExists); + }); + + //pods.json should have been created + fs.exists(podsJSON, function(podsJSONExists){ + expect(podsJSONExists); + }); + + //workspace should have been created + fs.exists(workspace, function(workspaceCreated){ + expect(workspaceCreated); + }); + + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + expect(podfileContent.includes(AFNetworking)); + + var podsJSONContent = require(podsJSON); + expect(podsJSONContent[AFNetworking] !== null); + + return cordova.raw.plugin('add', overlappingDependencyPlugin); + }) + .then(function() { + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + var numberOfTimesAFNetworkingIsInPodfile = podfileContent.match(/AFNetworking/g || []).length; + + expect(podfileContent.includes(CWStatusBarNotification)); + expect(numberOfTimesAFNetworkingIsInPodfile).toEqual(1); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + var countPropertyOfAFNetworkingInPodsJSON = podsJSONContent[AFNetworking].count; + var specPropertyOfAFNetworkingInPodsJSON = podsJSONContent[AFNetworking].spec; + + expect(countPropertyOfAFNetworkingInPodsJSON).toEqual(2); + //spec property should not be changed because of overlapping dependency + expect(specPropertyOfAFNetworkingInPodsJSON).toEqual('~> 3.0'); + + return cordova.raw.plugin('rm','sample-cocoapod-plugin-overlapping-dependency'); + }) + .then(function() { + //expect only AFNetworking + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + + expect(podfileContent.includes(CWStatusBarNotification)).toBe(false); + expect(podfileContent.includes(AFNetworking)); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + + expect(podsJSONContent[AFNetworking]); + expect(podsJSONContent[CWStatusBarNotification] === undefined); + + return cordova.raw.plugin('rm', 'sample-cordova-plugin-cocoapod-dependent'); + }) + .then(function() { + //expect no pods + delete require.cache[require.resolve(podfile)]; + var podfileContent = fs.readFileSync(podfile, {'encoding' : 'utf8'}); + + expect(podfileContent.includes(CWStatusBarNotification)).toBe(false); + expect(podfileContent.includes(AFNetworking)).toBe(false); + + delete require.cache[require.resolve(podsJSON)]; + var podsJSONContent = require(podsJSON); + + expect(podsJSONContent[AFNetworking] === undefined); + expect(podsJSONContent[CWStatusBarNotification] === undefined); + }) + .fail(function(err) { + console.error(err); + expect(err).toBeUndefined(); + }) + .fin(done); + }, 60000); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4353e104/cordova-lib/src/cordova/util.js ---------------------------------------------------------------------- diff --git a/cordova-lib/src/cordova/util.js b/cordova-lib/src/cordova/util.js index e617e08..1dffcd8 100644 --- a/cordova-lib/src/cordova/util.js +++ b/cordova-lib/src/cordova/util.js @@ -416,4 +416,4 @@ function getAvailableNpmVersions(module_name) { return result[Object.keys(result)[0]].versions; }); }); -} \ No newline at end of file +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
