Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PluginInfo): add podspec plugins support (#177) #178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions spec/PluginInfo/PluginInfo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,23 @@ describe('PluginInfo', function () {
});
});

it('Test 005: read podspec', function () {
const p = new PluginInfo(path.join(pluginsDir, 'org.test.plugins.withcocoapods'));
const result = p.getPodSpecs('ios');
expect(result.length).toBe(1);
const podSpec = result[0];
expect(Object.keys(podSpec.declarations).length).toBe(2);
expect(Object.keys(podSpec.sources).length).toBe(1);
expect(Object.keys(podSpec.libraries).length).toBe(4);
expect(Object.keys(podSpec.plugins).length).toBe(2);
expect(podSpec.declarations['use-frameworks']).toBe('true');
expect(podSpec.sources['https://github.com/CocoaPods/Specs.git'].source).toBe('https://github.com/CocoaPods/Specs.git');
expect(podSpec.libraries.AFNetworking.spec).toBe('~> 3.2');
expect(podSpec.libraries.Eureka['swift-version']).toBe('4.1');
expect(podSpec.plugins['my-other-plugin'].name).toBe('my-other-plugin');
expect(podSpec.plugins['cocoapods-art'].options).toBe(":sources => [ 'my.source.url' ]");
});

describe('Platform', () => {
it('Test 019: platform supports xml passthrough', function () {
const platforms = pluginPassthrough.getPlatforms();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<pod name="Eureka" swift-version="4.1" />
<pod name="AcknowList" />
</pods>
<plugins>
<plugin name="my-other-plugin" />
<plugin name="cocoapods-art" options=":sources =&gt; [ &apos;my.source.url&apos; ]" />
</plugins>
</podspec>
</platform>
</plugin>
11 changes: 10 additions & 1 deletion src/PluginInfo/PluginInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ class PluginInfo {
* <pod name="Foobar4" swift-version="4.1" />
* <pod name="Foobar5" swift-version="3.0" />
* </pods>
* <plugins>
* <plugin name="my-other-plugin" />
* <plugin name="cocoapods-art" options=":sources =&gt; [ &apos;my.repo.name&apos; ]" />
* </plugins>
* </podspec>
*
* @param {string} platform
Expand All @@ -286,6 +290,7 @@ class PluginInfo {
return this._getTagsInPlatform('podspec', platform).map(tag => {
const config = tag.find('config');
const pods = tag.find('pods');
const pluginsTag = tag.find('plugins');

const sources = config && config.findall('source')
.map(el => ({ source: el.attrib.url }))
Expand All @@ -297,7 +302,11 @@ class PluginInfo {
.map(t => t.attrib)
.reduce((acc, val) => Object.assign(acc, { [val.name]: val }), {});

return { declarations, sources, libraries };
const plugins = pluginsTag && pluginsTag.findall('plugin')
.map(t => t.attrib)
.reduce((acc, val) => Object.assign(acc, { [val.name]: val }), {});

return { declarations, sources, libraries, plugins };
});
}

Expand Down