cint 0.1.0
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/bin/cint +183 -0
- data/lib/cint.rb +5 -0
- data/lib/cint/version.rb +3 -0
- metadata +135 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e0e5f98f84fff2619d921a846df5c79a25661f1b
|
4
|
+
data.tar.gz: 8c95fd3dc792ccb1b1b6ed27866d8c22e575d911
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 99080af86eded96c714180005fb2f15b6d8af461c557d57f0942c3ac9b1458d55a6d5b383be72a17207270b23c9fa0573dc79a59d9393f5726f643ab124e36da
|
7
|
+
data.tar.gz: 35081567593d67e6dc731cf8da7bc536dfac42c2238e2db412962c547afce13199bcdcb278db095e10605ef5fc94eba26b8cf06fe8b189bf7b582e6bfd1de1cf
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Alex Antonyuk
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# CINT - Carthage INTegrator
|
2
|
+
|
3
|
+
lifies all routines with adding Frameworks into a project and creating Shell Script Build Phase
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
$ gem install cint
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
``` bash
|
14
|
+
$ cint install
|
15
|
+
```
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec cint` to use the gem in this directory, ignoring other installed copies of this gem.
|
20
|
+
|
21
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dev4dev/cint.
|
26
|
+
|
27
|
+
|
28
|
+
## License
|
29
|
+
|
30
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
31
|
+
|
data/bin/cint
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
require 'xcodeproj'
|
5
|
+
require 'colored'
|
6
|
+
require 'commander/import'
|
7
|
+
|
8
|
+
program :name, 'integrator'
|
9
|
+
program :version, '0.0.1'
|
10
|
+
program :description, 'Integrates Carthage Frameworks'
|
11
|
+
program :help, 'Author', 'Alex Antonyuk <alex@antonyuk.me>'
|
12
|
+
|
13
|
+
def error(message)
|
14
|
+
puts "\nError: #{message}".red
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
def warning(message)
|
19
|
+
puts "\nWarning: #{message}".yellow
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
|
23
|
+
def info(message)
|
24
|
+
puts message.green
|
25
|
+
end
|
26
|
+
|
27
|
+
BUILD_PHASE_NAME = 'Carthage'.freeze
|
28
|
+
|
29
|
+
SDK_TO_PLATFORM = {
|
30
|
+
'iphoneos' => 'iOS',
|
31
|
+
'macosx' => 'Mac',
|
32
|
+
'appletvos' => 'tvOS',
|
33
|
+
'watchos' => 'watchOS'
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
PLATFORMS = %w(iOS Mac watchOS tvOS).freeze
|
37
|
+
|
38
|
+
# Carthage
|
39
|
+
class CarthageFiles
|
40
|
+
def self.exists
|
41
|
+
Dir.exist? './Carthage/Build'
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.frameworks(platform)
|
45
|
+
return [] unless PLATFORMS.include?(platform)
|
46
|
+
pattern = "./Carthage/Build/#{platform}/*.framework"
|
47
|
+
Dir.glob(pattern)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Project
|
52
|
+
class Project
|
53
|
+
def initialize(project_name)
|
54
|
+
@project = Xcodeproj::Project.open(project_name)
|
55
|
+
rescue
|
56
|
+
error "Project #{project_name} not found"
|
57
|
+
end
|
58
|
+
|
59
|
+
def targets
|
60
|
+
@project.targets
|
61
|
+
end
|
62
|
+
|
63
|
+
def target_by_name(name)
|
64
|
+
@project.targets.find { |t| t.name == name }
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_missing_frameworks_to_target(target, frameworks)
|
68
|
+
fs = _fix_frameworks_paths(frameworks)
|
69
|
+
fs -= @project.frameworks_group.files.map(&:path)
|
70
|
+
|
71
|
+
files = fs.map do |f|
|
72
|
+
@project.frameworks_group.new_file(f)
|
73
|
+
end
|
74
|
+
|
75
|
+
files.each do |f|
|
76
|
+
target.frameworks_build_phase.add_file_reference(f)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def _fix_frameworks_paths(frameworks)
|
81
|
+
frameworks.map do |f|
|
82
|
+
f[2..-1]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def save
|
87
|
+
@project.save
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module Xcodeproj
|
92
|
+
class Project
|
93
|
+
module Object
|
94
|
+
# Extends Target
|
95
|
+
class PBXNativeTarget
|
96
|
+
def carthage_build_phase
|
97
|
+
cart_phase = build_phases.find do |phase|
|
98
|
+
phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && phase.name == BUILD_PHASE_NAME
|
99
|
+
end
|
100
|
+
cart_phase || new_shell_script_build_phase(BUILD_PHASE_NAME)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Extends Build Phase
|
105
|
+
class PBXShellScriptBuildPhase
|
106
|
+
def setup_with_frameworks(frameworks)
|
107
|
+
self.shell_script = '/usr/local/bin/carthage copy-frameworks'
|
108
|
+
self.shell_path = '/bin/sh'
|
109
|
+
self.input_paths = frameworks
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def prepare_frameworks(frameworks)
|
117
|
+
frameworks.map do |f|
|
118
|
+
"$(SRCROOT)#{f[1..-1]}"
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def print_report(frameworks)
|
123
|
+
info 'Integrated:'
|
124
|
+
puts frameworks.map { |f| File.basename(f) }.join("\n").yellow
|
125
|
+
end
|
126
|
+
|
127
|
+
def find_project
|
128
|
+
pattern = Dir.pwd + '/*.xcodeproj'
|
129
|
+
Dir.glob(pattern)
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_project_name(args)
|
133
|
+
if args.count == 0
|
134
|
+
projects = find_project
|
135
|
+
error 'There are more than one project in the directory, pass project\'s name explicitly' if projects.count > 1
|
136
|
+
error 'There are no projects in the directory, pass project\'s name explicitly' if projects.count == 0
|
137
|
+
project_name = projects.first
|
138
|
+
else
|
139
|
+
project_name = args[0]
|
140
|
+
end
|
141
|
+
project_name = "#{project_name}.xcodeproj" unless project_name.end_with? '.xcodeproj'
|
142
|
+
project_name
|
143
|
+
end
|
144
|
+
|
145
|
+
# Commands
|
146
|
+
command :install do |c|
|
147
|
+
c.syntax = 'cint install <project_name>'
|
148
|
+
c.description = 'Adds frameworks built by Carthage into a project'
|
149
|
+
c.action do |args, _|
|
150
|
+
error 'Carthage build folder does not exists' unless CarthageFiles.exists
|
151
|
+
|
152
|
+
# Choose Project
|
153
|
+
project_name = get_project_name(args)
|
154
|
+
info "Working with #{File.basename(project_name)}\n"
|
155
|
+
|
156
|
+
project = Project.new(project_name)
|
157
|
+
|
158
|
+
# choose target
|
159
|
+
choice = choose("Choose target:\n", *project.targets.map(&:name))
|
160
|
+
target = project.target_by_name(choice)
|
161
|
+
platform = SDK_TO_PLATFORM[target.sdk]
|
162
|
+
frameworks = CarthageFiles.frameworks(platform)
|
163
|
+
|
164
|
+
warning 'No frameworks found' if frameworks.empty?
|
165
|
+
|
166
|
+
# Add Framework Files
|
167
|
+
project.add_missing_frameworks_to_target(target, frameworks)
|
168
|
+
|
169
|
+
# Integrate Shell Script
|
170
|
+
phase = target.carthage_build_phase
|
171
|
+
prepared_frameworks = prepare_frameworks(frameworks)
|
172
|
+
phase.setup_with_frameworks(prepared_frameworks) unless target.sdk == 'macosx'
|
173
|
+
|
174
|
+
# Save Project
|
175
|
+
project.save
|
176
|
+
|
177
|
+
# footer
|
178
|
+
say "\n"
|
179
|
+
print_report(frameworks)
|
180
|
+
say "\n"
|
181
|
+
info 'Done. Re-open Project'
|
182
|
+
end
|
183
|
+
end
|
data/lib/cint.rb
ADDED
data/lib/cint/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Antonyuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xcodeproj
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.28'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.28'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colored
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: commander
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- alex@antonyuk.me
|
100
|
+
executables:
|
101
|
+
- cint
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- bin/cint
|
108
|
+
- lib/cint.rb
|
109
|
+
- lib/cint/version.rb
|
110
|
+
homepage: https://github.com/dev4dev/cint
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.6.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Simplifies all routines with adding Frameworks into a project and creating
|
134
|
+
Shell Script Build Phase
|
135
|
+
test_files: []
|