This is an automated email from the ASF dual-hosted git repository.

dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new 76e33d96 chore!: Remove podspec support from framework tag (#1340)
76e33d96 is described below

commit 76e33d96f2f1d891188f80e42f42f5fb997e2cea
Author: Darryl Pogue <[email protected]>
AuthorDate: Tue Jun 6 22:59:56 2023 -0700

    chore!: Remove podspec support from framework tag (#1340)
    
    This has been deprecated in favour of the <podspec> tag that allows much
    more control over pod dependencies.
    
    Closes #812.
---
 lib/Api.js                                         | 69 ++--------------------
 lib/plugman/pluginHandlers.js                      |  2 +-
 tests/spec/unit/Api.spec.js                        | 64 --------------------
 .../plugin.xml                                     | 14 -----
 .../www/test.js                                    |  0
 .../sample-cordova-plugin-with-spec/plugin.xml     | 14 -----
 .../sample-cordova-plugin-with-spec/www/test.js    |  0
 7 files changed, 5 insertions(+), 158 deletions(-)

diff --git a/lib/Api.js b/lib/Api.js
index d37adf80..a7fced47 100644
--- a/lib/Api.js
+++ b/lib/Api.js
@@ -265,9 +265,7 @@ class Api {
             .then(() => {
                 if (plugin != null) {
                     const podSpecs = plugin.getPodSpecs ? 
plugin.getPodSpecs(this.platform) : [];
-                    const frameworkTags = plugin.getFrameworks(this.platform);
-                    const frameworkPods = frameworkTags.filter(obj => obj.type 
=== 'podspec');
-                    return this.addPodSpecs(plugin, podSpecs, frameworkPods, 
installOptions);
+                    return this.addPodSpecs(plugin, podSpecs, installOptions);
                 }
             })
             // CB-11022 Return truthy value to prevent running prepare after
@@ -313,9 +311,7 @@ class Api {
             .then(() => {
                 if (plugin != null) {
                     const podSpecs = plugin.getPodSpecs ? 
plugin.getPodSpecs(this.platform) : [];
-                    const frameworkTags = plugin.getFrameworks(this.platform);
-                    const frameworkPods = frameworkTags.filter(obj => obj.type 
=== 'podspec');
-                    return this.removePodSpecs(plugin, podSpecs, 
frameworkPods, uninstallOptions);
+                    return this.removePodSpecs(plugin, podSpecs, 
uninstallOptions);
                 }
             })
             // CB-11022 Return truthy value to prevent running prepare after
@@ -328,10 +324,9 @@ class Api {
      * @param  {PluginInfo}  plugin  A PluginInfo instance that represents 
plugin
      *   that will be installed.
      * @param  {Object}  podSpecs: the return value of 
plugin.getPodSpecs(this.platform)
-     * @param  {Object}  frameworkPods: framework tags object with type === 
'podspec'
      * @return  {Promise}  Return a promise
      */
-    addPodSpecs (plugin, podSpecs, frameworkPods, installOptions) {
+    addPodSpecs (plugin, podSpecs, installOptions) {
         const project_dir = this.locations.root;
         const project_name = 
this.locations.xcodeCordovaProj.split(path.sep).pop();
         const minDeploymentTarget = 
this.getPlatformInfo().projectConfig.getPreference('deployment-target', 'ios');
@@ -400,36 +395,7 @@ class Api {
                     });
                 }
             });
-        }
-
-        if (frameworkPods.length) {
-            events.emit('warn', '"framework" tag with type "podspec" is 
deprecated and will be removed. Please use the "podspec" tag.');
-            events.emit('verbose', 'Adding pods since the plugin contained 
<framework>(s) with type="podspec"');
-            frameworkPods.forEach(obj => {
-                const spec = getVariableSpec(obj.spec, installOptions);
-                const podJson = {
-                    name: obj.src,
-                    type: obj.type,
-                    spec
-                };
-
-                const val = podsjsonFile.getLibrary(podJson.name);
-                if (val) { // found
-                    if (podJson.spec !== val.spec) { // exists, different 
spec, print warning
-                        events.emit('warn', `${plugin.id} depends on 
${podJson.name}@${podJson.spec}, which conflicts with another plugin. 
${podJson.name}@${val.spec} is already installed and was not overwritten.`);
-                    }
-                    // increment count, but don't add in Podfile because it 
already exists
-                    podsjsonFile.incrementLibrary(podJson.name);
-                } else { // not found, write new
-                    podJson.count = 1;
-                    podsjsonFile.setJsonLibrary(podJson.name, podJson);
-                    // add to Podfile
-                    podfileFile.addSpec(podJson.name, podJson.spec);
-                }
-            });
-        }
 
-        if (podSpecs.length > 0 || frameworkPods.length > 0) {
             // now that all the pods have been processed, write to pods.json
             podsjsonFile.write();
 
@@ -454,11 +420,10 @@ class Api {
      * @param  {PluginInfo}  plugin  A PluginInfo instance that represents 
plugin
      *   that will be installed.
      * @param  {Object}  podSpecs: the return value of 
plugin.getPodSpecs(this.platform)
-     * @param  {Object}  frameworkPods: framework tags object with type === 
'podspec'
      * @return  {Promise}  Return a promise
      */
 
-    removePodSpecs (plugin, podSpecs, frameworkPods, uninstallOptions) {
+    removePodSpecs (plugin, podSpecs, uninstallOptions) {
         const project_dir = this.locations.root;
         const project_name = 
this.locations.xcodeCordovaProj.split(path.sep).pop();
 
@@ -523,33 +488,7 @@ class Api {
                     }
                 });
             });
-        }
-
-        if (frameworkPods.length) {
-            events.emit('warn', '"framework" tag with type "podspec" is 
deprecated and will be removed. Please use the "podspec" tag.');
-            events.emit('verbose', 'Adding pods since the plugin contained 
<framework>(s) with type=\"podspec\"'); /* eslint no-useless-escape : 0 */
-            frameworkPods.forEach(obj => {
-                const spec = getVariableSpec(obj.spec, uninstallOptions);
-                const podJson = {
-                    name: obj.src,
-                    type: obj.type,
-                    spec
-                };
-
-                const val = podsjsonFile.getLibrary(podJson.name);
-                if (val) { // found, decrement count
-                    podsjsonFile.decrementLibrary(podJson.name);
-                } else { // not found (perhaps a sync error)
-                    const message = util.format('plugin \"%s\" podspec \"%s\" 
does not seem to be in pods.json, nothing to remove. Will attempt to remove 
from Podfile.', plugin.id, podJson.name); /* eslint no-useless-escape : 0 */
-                    events.emit('verbose', message);
-                }
-
-                // always remove from the Podfile
-                podfileFile.removeSpec(podJson.name);
-            });
-        }
 
-        if (podSpecs.length > 0 || frameworkPods.length > 0) {
             // now that all the pods have been processed, write to pods.json
             podsjsonFile.write();
 
diff --git a/lib/plugman/pluginHandlers.js b/lib/plugman/pluginHandlers.js
index dfe4e068..b4e963ea 100644
--- a/lib/plugman/pluginHandlers.js
+++ b/lib/plugman/pluginHandlers.js
@@ -97,7 +97,7 @@ const handlers = {
 
                 if (keepFrameworks.indexOf(src) < 0) {
                     if (obj.type === 'podspec') {
-                        // podspec handled in Api.js
+                        events.emit('error', '"framework" tag with type 
"podspec" is no longer supported. Please use the "podspec" tag.');
                     } else {
                         project.frameworks[src] = project.frameworks[src] || 0;
                         project.frameworks[src]++;
diff --git a/tests/spec/unit/Api.spec.js b/tests/spec/unit/Api.spec.js
index f7c48b91..9d383557 100644
--- a/tests/spec/unit/Api.spec.js
+++ b/tests/spec/unit/Api.spec.js
@@ -298,70 +298,6 @@ describe('Platform Api', () => {
                         });
                 });
             });
-            describe('with frameworks of `podspec` type', () => {
-                let podsjson_mock;
-                let podfile_mock;
-                const my_pod_json = {
-                    type: 'podspec',
-                    src: 'podsource!',
-                    spec: 'podspec!'
-                };
-                beforeEach(() => {
-                    podsjson_mock = jasmine.createSpyObj('podsjson mock', 
['getLibrary', 'incrementLibrary', 'write', 'setJsonLibrary']);
-                    podfile_mock = jasmine.createSpyObj('podfile mock', 
['isDirty', 'addSpec', 'write', 'install']);
-                    spyOn(my_plugin, 
'getFrameworks').and.returnValue([my_pod_json]);
-                    PodsJson_mod.PodsJson.and.returnValue(podsjson_mock);
-                    Podfile_mod.Podfile.and.returnValue(podfile_mock);
-                });
-                // TODO: a little help with clearly labeling / describing the 
tests below? :(
-                it('should warn if Pods JSON contains name/src but differs in 
spec', () => {
-                    podsjson_mock.getLibrary.and.returnValue({
-                        spec: `something different from ${my_pod_json.spec}`
-                    });
-                    spyOn(events, 'emit');
-                    return api.addPlugin(my_plugin)
-                        .then(() => {
-                            expect(events.emit).toHaveBeenCalledWith('warn', 
jasmine.stringMatching(/which conflicts with another plugin/g));
-                        });
-                });
-                it('should increment Pods JSON file if pod name/src already 
exists in file', () => {
-                    podsjson_mock.getLibrary.and.returnValue({
-                        spec: my_pod_json.spec
-                    });
-                    return api.addPlugin(my_plugin)
-                        .then(() => {
-                            
expect(podsjson_mock.incrementLibrary).toHaveBeenCalledWith('podsource!');
-                        });
-                });
-                it('on a new framework/pod name/src/key, it should add a new 
json to podsjson and add a new spec to podfile', () => {
-                    return api.addPlugin(my_plugin)
-                        .then(() => {
-                            
expect(podsjson_mock.setJsonLibrary).toHaveBeenCalledWith(my_pod_json.src, 
jasmine.any(Object));
-                            
expect(podfile_mock.addSpec).toHaveBeenCalledWith(my_pod_json.src, 
my_pod_json.spec);
-                        });
-                });
-                it('should write out podfile and install if podfile was 
changed', () => {
-                    podfile_mock.isDirty.and.returnValue(true);
-                    podfile_mock.install.and.returnValue({ then: function () { 
} });
-                    return api.addPlugin(my_plugin)
-                        .then(() => {
-                            expect(podfile_mock.write).toHaveBeenCalled();
-                            expect(podfile_mock.install).toHaveBeenCalled();
-                        });
-                });
-                it('if two frameworks with the same name are added, should 
honour the spec of the first-installed plugin', () => {
-                    podsjson_mock.getLibrary.and.returnValue({
-                        spec: `something different from ${my_pod_json.spec}`
-                    });
-                    return api.addPlugin(my_plugin)
-                        .then(() => {
-                            // Increment will non-destructively set the spec 
to keep it as it was...
-                            
expect(podsjson_mock.incrementLibrary).toHaveBeenCalledWith(my_pod_json.src);
-                            // ...whereas setJson would overwrite it 
completely.
-                            
expect(podsjson_mock.setJsonLibrary).not.toHaveBeenCalled();
-                        });
-                });
-            });
         });
         describe('removePlugin', () => {
             const my_plugin = {
diff --git 
a/tests/spec/unit/fixtures/sample-cocoapod-plugin-no-spec-overlapping-dependency/plugin.xml
 
b/tests/spec/unit/fixtures/sample-cocoapod-plugin-no-spec-overlapping-dependency/plugin.xml
deleted file mode 100644
index 25eb367f..00000000
--- 
a/tests/spec/unit/fixtures/sample-cocoapod-plugin-no-spec-overlapping-dependency/plugin.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?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-no-spec-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" weak="false" type="podspec"/>
-    </platform>
-</plugin>
-
diff --git 
a/tests/spec/unit/fixtures/sample-cocoapod-plugin-no-spec-overlapping-dependency/www/test.js
 
b/tests/spec/unit/fixtures/sample-cocoapod-plugin-no-spec-overlapping-dependency/www/test.js
deleted file mode 100644
index e69de29b..00000000
diff --git 
a/tests/spec/unit/fixtures/sample-cordova-plugin-with-spec/plugin.xml 
b/tests/spec/unit/fixtures/sample-cordova-plugin-with-spec/plugin.xml
deleted file mode 100644
index 0d8bf9ae..00000000
--- a/tests/spec/unit/fixtures/sample-cordova-plugin-with-spec/plugin.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?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-with-spec"
-    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"/>
-    </platform>
-</plugin>
-
diff --git 
a/tests/spec/unit/fixtures/sample-cordova-plugin-with-spec/www/test.js 
b/tests/spec/unit/fixtures/sample-cordova-plugin-with-spec/www/test.js
deleted file mode 100644
index e69de29b..00000000


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to