cocoaseeds 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +71 -0
- data/bin/seed +2 -0
- data/lib/cocoaseeds/command.rb +20 -0
- data/lib/cocoaseeds/core.rb +204 -0
- data/lib/cocoaseeds/seed.rb +15 -0
- data/lib/cocoaseeds/version.rb +3 -0
- data/lib/cocoaseeds.rb +6 -123
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951e8b5214913a0838ccf3097355d1c76efd5d81
|
4
|
+
data.tar.gz: 28a5cd47e476845404435bd5f44f1e51a8ef81cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f5a996f3c116c56a0735d959a4edb254875b3ca098f34895756ac929931755333e1d6ffcb46c409c7e6efffb49d96ee404a11d6b8e43fbfa235c64c0d404f09
|
7
|
+
data.tar.gz: d08f4d66db90463dcc1fa70cfa478fe2ff7bda2d95230fd338cff5eeac1407bae3878588f752ed897e14ea5ce198259f86654a152dd3e381b355ceddbb89f8dc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Suyeol Jeon (xoul.kr)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
CocoaSeeds
|
2
|
+
==========
|
3
|
+
|
4
|
+
[](https://rubygems.org/gems/cocoaseeds)
|
5
|
+
|
6
|
+
Git Submodule Alternative for Cocoa.
|
7
|
+
|
8
|
+
|
9
|
+
Why?
|
10
|
+
----
|
11
|
+
|
12
|
+
- iOS 7 projects are not available to use Swift libraries from [CocoaPods](https://cocoapods.org) or [Carthage](https://github.com/Carthage/Carthage).
|
13
|
+
> ld: warning: embedded dylibs/frameworks only run on iOS 8 or later
|
14
|
+
|
15
|
+
- CocoaSeeds just downloads the source code and add to your Xcode project. No static libraries, no dynamic frameworks at all.
|
16
|
+
- Git Submodule sucks.
|
17
|
+
- It can be used with CocoaPods and Carthage.
|
18
|
+
|
19
|
+
|
20
|
+
Installation
|
21
|
+
------------
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ [sudo] gem install cocoaseeds
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
Seedfile
|
29
|
+
--------
|
30
|
+
|
31
|
+
You have to write a **Seedfile** in the same directory with **.xcodeproj**.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
github 'Alamofire/Alamofire', '1.2.1', :files => 'Source/*.{swift,h}'
|
35
|
+
github 'devxoul/JLToast', '1.2.2', :files => 'JLToast/*.{swift,h}'
|
36
|
+
github 'Masonry/SnapKit', '0.10.0', :files => 'Source/*.{swift,h}'
|
37
|
+
```
|
38
|
+
|
39
|
+
<pre>
|
40
|
+
MyProject/
|
41
|
+
|-- MyProject/
|
42
|
+
| |-- AppDelegate.swift
|
43
|
+
| `-- ...
|
44
|
+
|-- MyProject.xcodeproj
|
45
|
+
|-- <b>Seedfile</b>
|
46
|
+
`-- ...
|
47
|
+
</pre>
|
48
|
+
|
49
|
+
|
50
|
+
Using CocoaSeeds
|
51
|
+
----------------
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ seed install
|
55
|
+
```
|
56
|
+
|
57
|
+
Then all the source files will be automatically added to your Xcode project with group named 'Seeds'.
|
58
|
+
|
59
|
+

|
60
|
+
|
61
|
+
|
62
|
+
FAQ
|
63
|
+
---
|
64
|
+
|
65
|
+
Yes, you can add **Seeds** folder to **.gitignore**.
|
66
|
+
|
67
|
+
|
68
|
+
License
|
69
|
+
-------
|
70
|
+
|
71
|
+
CocoaSeeds is under MIT license. See the LICENSE file for more info.
|
data/bin/seed
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module CocoaSeed
|
4
|
+
class Command
|
5
|
+
def self.run(argv)
|
6
|
+
case argv[0]
|
7
|
+
when 'install'
|
8
|
+
CocoaSeed::Core.new(Dir.pwd).install
|
9
|
+
when '--version'
|
10
|
+
puts CocoaSeed::VERSION
|
11
|
+
else
|
12
|
+
self.help
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.help
|
17
|
+
puts 'Usage: seed install'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module CocoaSeed
|
5
|
+
class Core
|
6
|
+
attr_reader :root_path, :seedfile_path, :lockfile_path
|
7
|
+
attr_accessor :project, :seedfile, :lockfile
|
8
|
+
attr_reader :seeds, :locks
|
9
|
+
attr_reader :source_files, :file_references
|
10
|
+
|
11
|
+
def initialize(root_path)
|
12
|
+
@root_path = root_path
|
13
|
+
@seedfile_path = File.join(root_path, "Seedfile")
|
14
|
+
@lockfile_path = File.join(root_path, "Seeds", "Seedfile.lock")
|
15
|
+
@seeds = {}
|
16
|
+
@locks = {}
|
17
|
+
@source_files = {}
|
18
|
+
@file_references = []
|
19
|
+
end
|
20
|
+
|
21
|
+
def install
|
22
|
+
self.prepare_requirements
|
23
|
+
self.analyze_dependencies
|
24
|
+
self.remove_seeds
|
25
|
+
self.install_seeds
|
26
|
+
self.configure_project
|
27
|
+
self.configure_phase
|
28
|
+
self.project.save
|
29
|
+
self.build_lockfile
|
30
|
+
end
|
31
|
+
|
32
|
+
def prepare_requirements
|
33
|
+
# .xcodeproj
|
34
|
+
project_filename = Dir.glob("#{root_path}/*.xcodeproj")[0]
|
35
|
+
if not project_filename
|
36
|
+
puts "Couldn't find .xcodeproj file.".red
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
self.project = Xcodeproj::Project.open(project_filename)
|
40
|
+
|
41
|
+
# Seedfile
|
42
|
+
begin
|
43
|
+
self.seedfile = File.read(self.seedfile_path)
|
44
|
+
rescue Errno::ENOENT
|
45
|
+
puts "Couldn't find Seedfile.".red
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
# Seedfile.lock - optional
|
50
|
+
begin
|
51
|
+
self.lockfile = File.read(self.lockfile_path)
|
52
|
+
rescue Errno::ENOENT
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def analyze_dependencies
|
57
|
+
puts "Anaylizing dependencies"
|
58
|
+
|
59
|
+
# Seedfile.lock
|
60
|
+
if self.lockfile
|
61
|
+
locks = YAML.load(self.lockfile)
|
62
|
+
locks["SEEDS"].each do |lock|
|
63
|
+
seed = CocoaSeed::Seed.new
|
64
|
+
seed.name = lock.split(' (')[0]
|
65
|
+
seed.version = lock.split('(')[1].split(')')[0]
|
66
|
+
self.locks[seed.name] = seed
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# Seedfile
|
71
|
+
eval self.seedfile
|
72
|
+
end
|
73
|
+
|
74
|
+
def github(repo, tag, options={})
|
75
|
+
seed = CocoaSeed::Seed::GitHub.new
|
76
|
+
seed.url = "https://github.com/#{repo}"
|
77
|
+
seed.name = repo.split('/')[1]
|
78
|
+
seed.version = tag
|
79
|
+
seed.files = options[:files] || '**/*.{h,m,mm,swift}'
|
80
|
+
if seed.files.kind_of?(String)
|
81
|
+
seed.files = [seed.files]
|
82
|
+
end
|
83
|
+
self.seeds[seed.name] = seed
|
84
|
+
end
|
85
|
+
|
86
|
+
def remove_seeds
|
87
|
+
removings = self.locks.keys - self.seeds.keys
|
88
|
+
removings.each do |name|
|
89
|
+
puts "Removing #{name} (#{self.locks[name].version})".red
|
90
|
+
dirname = File.join(self.root_path, "Seeds", name)
|
91
|
+
FileUtils.rm_rf(dirname)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def install_seeds
|
96
|
+
self.seeds.each do |name, seed|
|
97
|
+
dirname = File.join(self.root_path, "Seeds", name)
|
98
|
+
if File.exist?(dirname)
|
99
|
+
tag = `cd #{dirname} && git describe --tags --abbrev=0 2>&1`
|
100
|
+
tag.strip!
|
101
|
+
if tag == seed.version
|
102
|
+
puts "Using #{name} (#{seed.version})"
|
103
|
+
else
|
104
|
+
puts "Installing #{name} #{seed.version} (was #{tag})".green
|
105
|
+
`cd #{dirname} 2>&1 &&\
|
106
|
+
git reset HEAD --hard 2>&1 &&\
|
107
|
+
git checkout . 2>&1 &&\
|
108
|
+
git clean -fd 2>&1 &&\
|
109
|
+
git fetch origin #{seed.version} 2>&1 &&\
|
110
|
+
git checkout #{seed.version} 2>&1`
|
111
|
+
end
|
112
|
+
else
|
113
|
+
puts "Installing #{name} (#{seed.version})".green
|
114
|
+
output = `git clone #{seed.url} -b #{seed.version} #{dirname} 2>&1`
|
115
|
+
if output.include?("not found")
|
116
|
+
if output.include?("repository")
|
117
|
+
puts "[!] #{name}: Couldn't find the repository.".red
|
118
|
+
elsif output.include?("upstream")
|
119
|
+
puts "[!] #{name}: Couldn't find the tag `#{seed.version}`.".red
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
if seed.files
|
125
|
+
seed.files.each do |file|
|
126
|
+
self.source_files[name] = Dir.glob(File.join(dirname, file))
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def configure_project
|
133
|
+
puts "Configuring #{self.project.path.basename}"
|
134
|
+
|
135
|
+
group = self.project['Seeds'] || self.project.new_group('Seeds')
|
136
|
+
|
137
|
+
# remove existing group that doesn't have any file references
|
138
|
+
group.groups.each do |seedgroup|
|
139
|
+
valid_files = seedgroup.children.select do |child|
|
140
|
+
File.exist?(child.real_path)
|
141
|
+
end
|
142
|
+
if valid_files.length == 0
|
143
|
+
seedgroup.remove_from_project
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
self.source_files.each do |seedname, filepaths|
|
148
|
+
seedgroup = group[seedname] || group.new_group(seedname)
|
149
|
+
filepaths.each do |path|
|
150
|
+
filename = path.split('/')[-1]
|
151
|
+
file_reference = seedgroup[filename] || seedgroup.new_file(path)
|
152
|
+
self.file_references << file_reference
|
153
|
+
end
|
154
|
+
|
155
|
+
unusing_files = seedgroup.files - self.file_references
|
156
|
+
unusing_files.each { |file| file.remove_from_project }
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def configure_phase
|
161
|
+
targets = self.project.targets.select do |t|
|
162
|
+
not t.name.end_with?('Tests')
|
163
|
+
end
|
164
|
+
|
165
|
+
targets.each do |target|
|
166
|
+
# detect 'Compile Sources' build phase
|
167
|
+
phases = target.build_phases.select do |phase|
|
168
|
+
phase.kind_of?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
|
169
|
+
end
|
170
|
+
phase = phases[0]
|
171
|
+
|
172
|
+
if not phase
|
173
|
+
puts "[!] Target `#{target}` doesn't have build phase "\
|
174
|
+
"'Compile Sources'.".red
|
175
|
+
exit 1
|
176
|
+
end
|
177
|
+
|
178
|
+
# remove zombie file references
|
179
|
+
phase.files_references.each do |file_reference|
|
180
|
+
begin
|
181
|
+
file_reference.real_path
|
182
|
+
rescue
|
183
|
+
phase.remove_file_reference(file_reference)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# add file references to sources build phase
|
188
|
+
self.file_references.each do |file|
|
189
|
+
if not phase.include?(file)
|
190
|
+
phase.add_file_reference(file)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def build_lockfile
|
197
|
+
tree = { "SEEDS" => [] }
|
198
|
+
self.seeds.each do |name, seed|
|
199
|
+
tree["SEEDS"] << "#{name} (#{seed.version})"
|
200
|
+
end
|
201
|
+
File.write(self.lockfile_path, YAML.dump(tree))
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
data/lib/cocoaseeds.rb
CHANGED
@@ -1,126 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'xcodeproj'
|
2
2
|
|
3
|
+
module CocoaSeed
|
4
|
+
require 'cocoaseeds/version'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
class String
|
8
|
-
def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end
|
9
|
-
def red; colorize(31) end
|
10
|
-
def green; colorize(32) end
|
11
|
-
def yellow; colorize(33) end
|
12
|
-
def blue; colorize(34) end
|
13
|
-
def pink; colorize(35) end
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
def github(repo, branch, options=nil)
|
18
|
-
puts "Installing #{repo} (#{branch})".green
|
19
|
-
|
20
|
-
url = 'https://github.com/' + repo
|
21
|
-
name = repo.split('/')[1]
|
22
|
-
dir = "Seeds/#{name}"
|
23
|
-
|
24
|
-
`test -d #{dir} && rm -rf #{dir}; git clone #{url} -b #{branch} #{dir} 2>&1`
|
25
|
-
|
26
|
-
if not options.nil?
|
27
|
-
files = options[:files]
|
28
|
-
if not files.nil?
|
29
|
-
if files.kind_of?(String)
|
30
|
-
files = [files]
|
31
|
-
end
|
32
|
-
|
33
|
-
files.each do |file|
|
34
|
-
absoulte_files = `ls #{dir}/#{file} 2>&1 2>/dev/null`.split(/\r?\n/)
|
35
|
-
$source_files[name] = absoulte_files
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
42
|
-
def read_seedfile
|
43
|
-
begin
|
44
|
-
return File.read('Seedfile')
|
45
|
-
rescue
|
46
|
-
puts 'No Seedfile.'
|
47
|
-
exit 1
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def install
|
53
|
-
seeds = read_seedfile.split('\r\n')
|
54
|
-
seeds.each do |line|
|
55
|
-
eval line
|
56
|
-
end
|
57
|
-
generate_project
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
def generate_project
|
62
|
-
project_filename_candidates = `ls | grep .xcodeproj`.split(/\r?\n/)
|
63
|
-
if project_filename_candidates.length == 0
|
64
|
-
puts "Couldn't find .xcodeproj file.".red
|
65
|
-
exit 1
|
66
|
-
end
|
67
|
-
|
68
|
-
project_filename = project_filename_candidates[0]
|
69
|
-
project = Xcodeproj::Project.open(project_filename)
|
70
|
-
|
71
|
-
puts "Configuring #{project_filename}"
|
72
|
-
|
73
|
-
group_seeds = project['Seeds']
|
74
|
-
if not group_seeds.nil?
|
75
|
-
group_seeds.clear
|
76
|
-
else
|
77
|
-
group_seeds = project.new_group('Seeds')
|
78
|
-
end
|
79
|
-
|
80
|
-
file_references = []
|
81
|
-
|
82
|
-
$source_files.each do |seed, files|
|
83
|
-
group_seed = group_seeds.new_group(seed)
|
84
|
-
files.each do |file|
|
85
|
-
added_file = group_seed.new_file(file)
|
86
|
-
file_references.push(added_file)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
project.targets.each do |target|
|
91
|
-
if project.targets.length > 1 and target.name.end_with?('Tests')
|
92
|
-
next
|
93
|
-
end
|
94
|
-
|
95
|
-
target.build_phases.each do |phase|
|
96
|
-
if not phase.kind_of?(Xcodeproj::Project::Object::PBXSourcesBuildPhase)
|
97
|
-
next
|
98
|
-
end
|
99
|
-
|
100
|
-
phase.files_references.each do |file_reference|
|
101
|
-
begin
|
102
|
-
file_reference.real_path
|
103
|
-
rescue
|
104
|
-
phase.remove_file_reference(file_reference)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
file_references.each do |file|
|
109
|
-
if not phase.include?(file)
|
110
|
-
phase.add_file_reference(file)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
project.save
|
117
|
-
puts "Done."
|
118
|
-
end
|
119
|
-
|
120
|
-
|
121
|
-
case ARGV[0]
|
122
|
-
when 'install'
|
123
|
-
install
|
124
|
-
else
|
125
|
-
puts 'Usage: seed install'
|
6
|
+
autoload :Command, 'cocoaseeds/command'
|
7
|
+
autoload :Core, 'cocoaseeds/core'
|
8
|
+
autoload :Seed, 'cocoaseeds/seed'
|
126
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoaseeds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suyeol Jeon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcodeproj
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.24.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.7
|
27
41
|
description: Git Submodule Alternative for Cocoa.
|
28
42
|
email: devxoul@gmail.com
|
29
43
|
executables:
|
@@ -31,8 +45,14 @@ executables:
|
|
31
45
|
extensions: []
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
34
50
|
- bin/seed
|
35
51
|
- lib/cocoaseeds.rb
|
52
|
+
- lib/cocoaseeds/command.rb
|
53
|
+
- lib/cocoaseeds/core.rb
|
54
|
+
- lib/cocoaseeds/seed.rb
|
55
|
+
- lib/cocoaseeds/version.rb
|
36
56
|
homepage: https://github.com/devxoul/CocoaSeeds
|
37
57
|
licenses:
|
38
58
|
- MIT
|