├── .gitignore ├── lib ├── cocoapods_plugin.rb ├── cocoapods-schoutedenapus.rb └── cocoapods-schoutedenapus │ ├── command.rb │ ├── gem_version.rb │ ├── converter.rb │ └── command │ └── schoutedenapus.rb ├── .travis.yml ├── Gemfile ├── spec ├── fixtures │ ├── Package.swift │ └── Stencil.podspec.json ├── converter_spec.rb ├── command │ └── schoutedenapus_spec.rb └── spec_helper.rb ├── Rakefile ├── README.md ├── cocoapods-schoutedenapus.gemspec └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | pkg 3 | .idea/ 4 | Gemfile.lock 5 | -------------------------------------------------------------------------------- /lib/cocoapods_plugin.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-schoutedenapus/command' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-schoutedenapus.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-schoutedenapus/gem_version' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-schoutedenapus/command.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-schoutedenapus/command/schoutedenapus' 2 | -------------------------------------------------------------------------------- /lib/cocoapods-schoutedenapus/gem_version.rb: -------------------------------------------------------------------------------- 1 | module CocoapodsSchoutedenapus 2 | VERSION = '0.0.2' 3 | end 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode7.1 2 | language: objective-c 3 | cache: bundler 4 | before_install: 5 | - bundle install 6 | - bundle exec pod repo update --silent 7 | script: bundle exec rake 8 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | 5 | group :development do 6 | gem 'cocoapods' 7 | 8 | gem 'mocha' 9 | gem 'bacon' 10 | gem 'mocha-on-bacon' 11 | gem 'prettybacon' 12 | end 13 | -------------------------------------------------------------------------------- /spec/fixtures/Package.swift: -------------------------------------------------------------------------------- 1 | import PackageDescription 2 | 3 | let package = Package( 4 | name: "Stencil", 5 | dependencies: [ 6 | .Package(url: "https://github.com/kylef/PathKit.git", majorVersion: 0, minor: 6), 7 | ] 8 | ) 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'bundler/gem_tasks' 2 | 3 | def specs(dir) 4 | FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ') 5 | end 6 | 7 | desc 'Runs all the specs' 8 | task :specs do 9 | sh "bundle exec bacon #{specs('**')}" 10 | end 11 | 12 | task default: :specs 13 | -------------------------------------------------------------------------------- /spec/converter_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../spec_helper', __FILE__) 2 | 3 | module Schoutedenapus 4 | describe Converter do 5 | describe 'Conversion' do 6 | it 'can convert a podspec' do 7 | fixture = File.new('spec/fixtures/Package.swift').read() 8 | spec = Pod::Specification.from_file('spec/fixtures/Stencil.podspec.json') 9 | 10 | actual = Converter.new(spec).to_s 11 | 12 | actual.should == fixture 13 | end 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Schoutedenapus 2 | 3 | [![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/) 4 | 5 | Generate Swift packages from podspecs. 6 | 7 | Looking for the reverse conversion? => [Chocolat][1] 8 | 9 | ## Usage 10 | 11 | Running 12 | 13 | $ pod lib schoutedenapus POD_SPEC 14 | 15 | will generate a new `Package.swift` in the current directory. 16 | 17 | As of right now, Schoutedenapus will only pick up the name and dependencies 18 | from the original podspec, you will have to manually move your source files 19 | into a directory structure that works with SPM. 20 | 21 | ## Installation 22 | 23 | Schoutedenapus is a CocoaPods plugin distributed as RubyGem: 24 | 25 | $ gem install cocoapods-schoutedenapus 26 | 27 | [1]: https://github.com/neonichu/Chocolat 28 | -------------------------------------------------------------------------------- /spec/command/schoutedenapus_spec.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../../spec_helper', __FILE__) 2 | 3 | module Pod 4 | describe Command::Lib::Schoutedenapus do 5 | describe 'CLAide' do 6 | it 'registers it self' do 7 | Command.parse(%w( lib schoutedenapus )).should.be.instance_of Command::Lib::Schoutedenapus 8 | end 9 | 10 | it 'parses a given spec' do 11 | cmd = Command.parse(%w( lib schoutedenapus spec/fixtures/Stencil.podspec.json )) 12 | cmd.validate! 13 | 14 | cmd.instance_variable_get('@spec').name.should == 'Stencil' 15 | end 16 | 17 | it 'generates a Package.swift file' do 18 | cmd = Command.parse(%w( lib schoutedenapus spec/fixtures/Stencil.podspec.json )) 19 | cmd.run 20 | 21 | FileUtils.compare_file('spec/fixtures/Package.swift', 'Package.swift').should == true 22 | FileUtils.rm_f('Package.swift') 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /cocoapods-schoutedenapus.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'cocoapods-schoutedenapus/gem_version.rb' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = 'cocoapods-schoutedenapus' 8 | spec.version = CocoapodsSchoutedenapus::VERSION 9 | spec.authors = ['Boris Bügling'] 10 | spec.email = ['boris@icculus.org'] 11 | spec.summary = 'Generate Swift packages from podspecs.' 12 | spec.homepage = 'https://github.com/neonichu/Schoutedenapus' 13 | spec.license = 'MIT' 14 | 15 | spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) 16 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 17 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 18 | spec.require_paths = ['lib'] 19 | 20 | spec.add_development_dependency 'bundler', '~> 1.3' 21 | spec.add_development_dependency 'rake' 22 | end 23 | -------------------------------------------------------------------------------- /spec/fixtures/Stencil.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Stencil", 3 | "version": "0.4.0", 4 | "summary": "Stencil is a simple and powerful template language for Swift.", 5 | "homepage": "https://github.com/kylef/Stencil", 6 | "license": { 7 | "type": "BSD", 8 | "file": "LICENSE" 9 | }, 10 | "authors": { 11 | "Kyle Fuller": "inbox@kylefuller.co.uk" 12 | }, 13 | "social_media_url": "http://twitter.com/kylefuller", 14 | "source": { 15 | "git": "https://github.com/kylef/Stencil.git", 16 | "tag": "0.4.0" 17 | }, 18 | "source_files": [ 19 | "Sources/*.swift", 20 | "Sources/TemplateLoader/*.swift" 21 | ], 22 | "platforms": { 23 | "ios": "8.0", 24 | "osx": "10.9" 25 | }, 26 | "requires_arc": true, 27 | "dependencies": { 28 | "PathKit": [ "~> 0.5.0" ] 29 | }, 30 | "test_specification": { 31 | "source_files": [ 32 | "Tests/*.swift", 33 | "Tests/TemplateLoader/*.swift", 34 | "Tests/Nodes/*.swift" 35 | ], 36 | "dependencies": { 37 | "Spectre": [ "~> 0.5.0" ], 38 | "PathKit": [ "~> 0.5.0" ] 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/cocoapods-schoutedenapus/converter.rb: -------------------------------------------------------------------------------- 1 | module Schoutedenapus 2 | class Converter 3 | def initialize(spec) 4 | @spec = spec 5 | end 6 | 7 | def to_s 8 | return <<-EOF 9 | import PackageDescription 10 | 11 | let package = Package( 12 | \tname: "#{@spec.name}"#{dependencies} 13 | ) 14 | EOF 15 | end 16 | 17 | private 18 | 19 | def dependency_to_package(dep) 20 | set = Pod::Config.instance.sources_manager.search(dep) 21 | Pod::Command::help! "Could not find pod '#{dep.name}'" if set.nil? 22 | url = set.specification.source[:git] 23 | # FIXME: Should use the lowest matching version 24 | major = set.versions.first.major 25 | minor = set.versions.first.minor 26 | "\t\t.Package(url: \"#{url}\", majorVersion: #{major}, minor: #{minor})," 27 | end 28 | 29 | def dependencies 30 | return '' if @spec.dependencies.count == 0 31 | 32 | deps = @spec.dependencies.map { |dep| dependency_to_package(dep) }.join("\n") 33 | dependencies = <<-EOF 34 | , 35 | \tdependencies: [ 36 | #{deps} 37 | \t] 38 | EOF 39 | dependencies.rstrip! 40 | end 41 | end 42 | end -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Boris Bügling 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /lib/cocoapods-schoutedenapus/command/schoutedenapus.rb: -------------------------------------------------------------------------------- 1 | require 'cocoapods-schoutedenapus/converter' 2 | 3 | module Pod 4 | class Command 5 | class Lib 6 | class Schoutedenapus < Lib 7 | self.summary = 'Generate Swift packages from podspecs.' 8 | 9 | self.arguments = [ CLAide::Argument.new('PODSPEC', true) ] 10 | 11 | def initialize(argv) 12 | @spec = spec_with_path(argv.shift_argument) 13 | super 14 | end 15 | 16 | def validate! 17 | super 18 | help! 'A podspec is required.' unless @spec 19 | end 20 | 21 | def run 22 | File.write('Package.swift', ::Schoutedenapus::Converter.new(@spec).to_s) 23 | end 24 | 25 | private 26 | 27 | def spec_with_path(path) 28 | return if path.nil? || !Pathname.new(path).exist? 29 | 30 | if Pathname.new(path).directory? 31 | help! path + ': is a directory.' 32 | return 33 | end 34 | 35 | unless ['.podspec', '.json'].include? Pathname.new(path).extname 36 | help! path + ': is not a podspec.' 37 | return 38 | end 39 | 40 | Specification.from_file(path) 41 | end 42 | end 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'pathname' 2 | ROOT = Pathname.new(File.expand_path('../../', __FILE__)) 3 | $LOAD_PATH.unshift((ROOT + 'lib').to_s) 4 | $LOAD_PATH.unshift((ROOT + 'spec').to_s) 5 | 6 | require 'bundler/setup' 7 | require 'bacon' 8 | require 'mocha-on-bacon' 9 | require 'pretty_bacon' 10 | require 'pathname' 11 | require 'cocoapods' 12 | 13 | Mocha::Configuration.prevent(:stubbing_non_existent_method) 14 | 15 | require 'cocoapods_plugin' 16 | 17 | #-----------------------------------------------------------------------------# 18 | 19 | module Pod 20 | # Disable the wrapping so the output is deterministic in the tests. 21 | # 22 | UI.disable_wrap = true 23 | 24 | # Redirects the messages to an internal store. 25 | # 26 | module UI 27 | @output = '' 28 | @warnings = '' 29 | 30 | class << self 31 | attr_accessor :output 32 | attr_accessor :warnings 33 | 34 | def puts(message = '') 35 | @output << "#{message}\n" 36 | end 37 | 38 | def warn(message = '', _actions = []) 39 | @warnings << "#{message}\n" 40 | end 41 | 42 | def print(message) 43 | @output << message 44 | end 45 | end 46 | end 47 | end 48 | 49 | #-----------------------------------------------------------------------------# 50 | --------------------------------------------------------------------------------