Skip to content

Commit

Permalink
chore!: Remove podspec support from framework tag (apache#1340)
Browse files Browse the repository at this point in the history
This has been deprecated in favour of the <podspec> tag that allows much
more control over pod dependencies.

Closes apache#812.
  • Loading branch information
dpogue authored Jun 7, 2023
1 parent 700c32b commit 76e33d9
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 158 deletions.
69 changes: 4 additions & 65 deletions lib/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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');
Expand Down Expand Up @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion lib/plugman/pluginHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]++;
Expand Down
64 changes: 0 additions & 64 deletions tests/spec/unit/Api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

This file was deleted.

Empty file.

This file was deleted.

Empty file.

0 comments on commit 76e33d9

Please sign in to comment.