zewo-dev 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5234c1d1c33a8b95ff7c980c45f74b8342774b3c
4
- data.tar.gz: 3adcd3785024aa96a4648124f500f2e3ce96ce9e
3
+ metadata.gz: 3673c4a0a82ab3e0b7ba26200dc9eca647b941fc
4
+ data.tar.gz: 344a5d2eae09e3bfb08603ef9f72e4b91cfc5fc7
5
5
  SHA512:
6
- metadata.gz: 3b853e4e4f94617aa3171bfbd0cb057ff3e0cbec7af0d5b1c449ace21a255e704154b0a43b73761406271ee4429f4073ba3030efcb8ac945730f85daf4dc8301
7
- data.tar.gz: e64f4c9ccca7ed95f297a8ac239954df6eb80a904663a5541fd62c0b6b19a71d21b5122a66c5203edede1e728cbd71a921b5617dd981633c6c9077c8e7314064
6
+ metadata.gz: fa29300400d55b66493e9bb55e4f5e23dc6dbc5aced2003a490a67cee0f4cabe6968c5b0d050c9d813cd8a65c1ad237e5884f472e243d2fd9388ea36dd1232c1
7
+ data.tar.gz: d0a4f3e869c1edccdef1c723280a7b6d798ace07f2bbcac97e05335c2a0cef37b76e639c95594eeacdd51a25072636c7b762a762bcf0b3023409b2d228323391
File without changes
data/lib/zewo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Zewo
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.5"
3
3
  end
data/lib/zewo.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "zewo/version"
1
+ require 'zewo/version'
2
2
 
3
3
  require 'thor'
4
4
  require 'rubygems'
@@ -12,19 +12,115 @@ require 'colorize'
12
12
  require 'thread'
13
13
  require 'thwait'
14
14
 
15
+ def silent_cmd(cmd)
16
+ system("#{cmd} > /dev/null 2>&1")
17
+ end
18
+
15
19
  module Zewo
16
20
  class App < Thor
17
-
18
21
  class Repo
19
22
  attr_reader :name
20
23
  @name = nil
21
24
  attr_reader :data
22
25
  @data = nil
23
26
 
24
- def initialize(name, data)
27
+ @xcodeproj = nil
28
+
29
+ def initialize(name, data = nil)
25
30
  @name = name
26
31
  @data = data
27
32
  end
33
+
34
+ def framework_target
35
+ target_name = name.gsub('-OSX', '').gsub('-', '_')
36
+ xcode_project.native_targets.find { |t| t.name == target_name } || xcode_project.new_target(:framework, target_name, :osx)
37
+ end
38
+
39
+ def xcode_dir
40
+ "#{name}/XcodeTest"
41
+ end
42
+
43
+ def xcode_project_path
44
+ "#{xcode_dir}/#{name}.xcodeproj"
45
+ end
46
+
47
+ def xcode_project
48
+ return @xcodeproj if @xcodeproj
49
+ if File.exist?(xcode_project_path)
50
+ @xcodeproj = Xcodeproj::Project.open(xcode_project_path)
51
+ else
52
+ @xcodeproj = Xcodeproj::Project.new(xcode_project_path)
53
+ end
54
+ @xcodeproj
55
+ end
56
+
57
+ def sources_dir
58
+ if File.directory?("#{name}/Sources")
59
+ return 'Sources'
60
+ elsif File.directory?("#{name}/Source")
61
+ return 'Source'
62
+ end
63
+ nil
64
+ end
65
+
66
+ def add_files(direc, current_group, main_target)
67
+ Dir.glob(direc) do |item|
68
+ next if item == '.' || item == '.DS_Store'
69
+
70
+ if File.directory?(item)
71
+ new_folder = File.basename(item)
72
+ created_group = current_group.new_group(new_folder)
73
+ add_files("#{item}/*", created_group, main_target)
74
+ else
75
+ item = item.split('/')[1..-1].unshift('..') * '/'
76
+ i = current_group.new_file(item)
77
+ main_target.add_file_references([i]) if item.include? '.swift'
78
+ end
79
+ end
80
+ end
81
+
82
+ def build_dependencies
83
+ puts "Configuring dependencies for #{name}".green
84
+ dependency_repos = File.read("#{name}/Package.swift").scan(/(?<=Zewo\/)(.*?)(?=\.git)/).map(&:first)
85
+
86
+ group = xcode_project.new_group('Subprojects')
87
+ dependency_repos.each do |repo_name|
88
+ repo = Repo.new(repo_name)
89
+ project_reference = group.new_file("#{repo.xcode_project_path}")
90
+ project_reference.path = "../../#{project_reference.path}"
91
+
92
+ if framework_target
93
+ framework_target.add_dependency(repo.framework_target)
94
+ end
95
+ end
96
+
97
+ xcode_project.save
98
+ end
99
+
100
+ def configure_xcode_project
101
+ @xcodeproj = nil
102
+ silent_cmd("rm -rf #{xcode_dir}")
103
+
104
+ puts "Creating Xcode project #{name}".green
105
+
106
+ framework_target.build_configurations.each do |configuration|
107
+ framework_target.build_settings(configuration.name)['HEADER_SEARCH_PATHS'] = '/usr/local/include'
108
+ framework_target.build_settings(configuration.name)['LIBRARY_SEARCH_PATHS'] = '/usr/local/lib'
109
+
110
+ if File.exist?("#{name}/module.modulemap")
111
+ framework_target.build_settings(configuration.name)['MODULEMAP_FILE'] = '../module.modulemap'
112
+ end
113
+ end
114
+
115
+ xcode_project.new_file('../module.modulemap') if File.exist?("#{name}/module.modulemap")
116
+
117
+ if sources_dir
118
+ group = xcode_project.new_group(sources_dir)
119
+ add_files("#{name}/#{sources_dir}/*", group, framework_target)
120
+ end
121
+
122
+ xcode_project.save
123
+ end
28
124
  end
29
125
 
30
126
  no_commands do
@@ -35,15 +131,32 @@ module Zewo
35
131
  http.use_ssl = true
36
132
  request = Net::HTTP::Get.new(uri.request_uri)
37
133
 
134
+ blacklist = [
135
+ 'Core',
136
+ 'GrandCentralDispatch',
137
+ 'JSONParserMiddleware',
138
+ 'Levee',
139
+ 'LoggerMiddleware',
140
+ 'Middleware',
141
+ 'Mustache',
142
+ 'POSIXRegex',
143
+ 'SSL',
144
+ 'Sideburns',
145
+ 'SwiftZMQ',
146
+ 'WebSocket'
147
+ ]
148
+
38
149
  response = http.request(request)
39
150
 
40
151
  if response.code == '200'
41
- result = JSON.parse(response.body).sort_by { |hsh| hsh['name'] }
42
-
43
- result.each do |doc|
44
- repo = Repo.new(doc['name'], doc)
45
- yield repo
46
- end
152
+ result = JSON.parse(response.body).sort_by { |hsh| hsh['name'] }
153
+
154
+
155
+ result.each do |doc|
156
+ next if blacklist.include?(doc['name'])
157
+ repo = Repo.new(doc['name'], doc)
158
+ yield repo
159
+ end
47
160
  else
48
161
  puts 'Error loading repositories'
49
162
  end
@@ -52,9 +165,29 @@ module Zewo
52
165
  def each_repo_async
53
166
  threads = []
54
167
  each_repo do |repo|
55
- threads << Thread.new {
168
+ threads << Thread.new do
169
+ yield(repo)
170
+ end
171
+ end
172
+ ThreadsWait.all_waits(*threads)
173
+ end
174
+
175
+ def each_code_repo
176
+ each_repo do |repo|
177
+ unless File.exist?("#{repo.name}/Package.swift")
178
+ print "No Package.swift for #{repo.name}. Skipping." + "\n"
179
+ next
180
+ end
181
+ yield repo
182
+ end
183
+ end
184
+
185
+ def each_code_repo_async
186
+ threads = []
187
+ each_code_repo do |repo|
188
+ threads << Thread.new do
56
189
  yield(repo)
57
- }
190
+ end
58
191
  end
59
192
  ThreadsWait.all_waits(*threads)
60
193
  end
@@ -62,7 +195,7 @@ module Zewo
62
195
  def verify_branches
63
196
  last_branch_name = nil
64
197
  each_repo do |repo|
65
- branch_name = `cd #{repo.name}; git rev-parse --abbrev-ref HEAD`.gsub("\n", "")
198
+ branch_name = `cd #{repo.name}; git rev-parse --abbrev-ref HEAD`.gsub("\n", '')
66
199
  if !last_branch_name.nil? && branch_name != last_branch_name
67
200
  puts "Branch mismatch. Branch of #{repo.name} does not match previous branch #{branch_name}".red
68
201
  return false
@@ -110,17 +243,15 @@ module Zewo
110
243
 
111
244
  desc :pull, 'git pull on all repos'
112
245
  def pull
113
-
114
246
  each_repo_async do |repo|
115
247
  print "Updating #{repo.name}..." + "\n"
116
248
  if uncommited_changes?(repo.name)
117
249
  print "Uncommitted changes in #{repo.name}. Not updating.".red + "\n"
118
250
  next
119
251
  end
120
- system("cd #{repo.name}; git pull > /dev/null 2>&1")
252
+ silent_cmd("cd #{repo.name}; git pull")
121
253
  print "Updated #{repo.name}".green + "\n"
122
254
  end
123
-
124
255
  end
125
256
 
126
257
  desc :push, 'git push on all repos'
@@ -133,7 +264,7 @@ module Zewo
133
264
  next
134
265
  end
135
266
  print "Pushing #{repo.name}...".green + "\n"
136
- system("cd #{repo.name}; git push > /dev/null 2>&1")
267
+ silent_cmd("cd #{repo.name}; git push")
137
268
  end
138
269
  print 'Done!' + "\n"
139
270
  end
@@ -141,15 +272,15 @@ module Zewo
141
272
  desc :init, 'Clones all Zewo repositories'
142
273
  def init
143
274
  each_repo_async do |repo|
275
+ print "Checking #{repo.name}..." + "\n"
144
276
  unless File.directory?(repo.name)
145
277
  print "Cloning #{repo.name}...".green + "\n"
146
- system("git clone #{repo.data['ssh_url']} > /dev/null 2>&1")
278
+ silent_cmd("git clone #{repo.data['ssh_url']}")
147
279
  end
148
280
  end
149
281
  puts 'Done!'
150
282
  end
151
283
 
152
-
153
284
  desc :build, 'Clones all Zewo repositories'
154
285
  def build
155
286
  each_repo do |repo|
@@ -160,7 +291,7 @@ module Zewo
160
291
 
161
292
  if system("cd #{repo.name}/Xcode; set -o pipefail && xcodebuild -scheme \"#{repo.name}\" -sdk \"macosx\" -toolchain /Library/Developer/Toolchains/swift-latest.xctoolchain | xcpretty") == false
162
293
  puts "Error building. Maybe you're using the wrong Xcode? Try `sudo xcode-select -s /Applications/Xcode-Beta.app/Contents/Developer` if you have a beta-version of Xcode installed.".red
163
-
294
+
164
295
  end
165
296
  end
166
297
  end
@@ -181,13 +312,18 @@ module Zewo
181
312
 
182
313
  system("cd #{repo.name}; git add --all; git commit -am #{message}")
183
314
  puts "Commited #{repo.name}\n".green
184
-
185
315
  end
186
316
  if prompt('Pull & push changes?'.red)
187
- self.pull
188
- self.push
317
+ pull
318
+ push
189
319
  end
190
-
320
+ end
321
+
322
+ desc :make_projects, 'Makes projects'
323
+ def make_projects
324
+ each_code_repo(&:configure_xcode_project)
325
+
326
+ each_code_repo(&:build_dependencies)
191
327
  end
192
328
  end
193
329
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zewo-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Ask
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-15 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -100,7 +100,7 @@ email:
100
100
  executables:
101
101
  - console
102
102
  - setup
103
- - zewo
103
+ - zewodev
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
@@ -112,7 +112,7 @@ files:
112
112
  - Rakefile
113
113
  - bin/console
114
114
  - bin/setup
115
- - bin/zewo
115
+ - bin/zewodev
116
116
  - lib/zewo.rb
117
117
  - lib/zewo/version.rb
118
118
  - zewo.gemspec