spinjector 0.0.6 → 1.0.0

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
  SHA256:
3
- metadata.gz: c73f5e26de7982019f85fa697d310590caf4750b75981e7bbcef7023a27e6c8c
4
- data.tar.gz: 81933229a9142400ad0ae4ca2c9494064a384a73d9d88d091fda299749ddda5c
3
+ metadata.gz: 770afb3d2da618abf0c2f12be01a8638d6190c5b21085d8ee6cbc89a05159e50
4
+ data.tar.gz: 6d371c30b8a6fa185a7775bf5b63e34f76269b25beb63cd738d0a0627ca48237
5
5
  SHA512:
6
- metadata.gz: 2e766f518c4d1420ffaa5a28b4eedc69a9d4e94836bf0f5574cbc257efcb332f5797b77597681f04ee9824016498069a66eaebd3548f584a24befc4f5576fbc9
7
- data.tar.gz: 61a8228e352c8c3f06770fcde3c5aeef9ffa3068b16986beb4cef7c91fa5e16e5c57bdd8ff2d566638fb914fe254c400da0f99f2f03ea4075aea74408bb022bc
6
+ metadata.gz: f627ae1db194c15105e591e3d7f1c43000df84b72b47701e3c587b6962f6ba25978ad6b52763be3f11d1550eebc454bbd5b858adfa112557f1e1f4bbc8583d6e
7
+ data.tar.gz: 884f0b622a6f4bc9c3d421200e0651970f961831fc4cada4dc87c3e1814ed0cc2d8f85a7ccf4b3adc293f6a57b48a2428241452d4edce84202301aee0a54fc11
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: ["2.6.6", "2.7.3", "3.0.1"]
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby }}
17
+ - name: Build and test with Rake
18
+ run: |
19
+ gem install bundler
20
+ bundle install --jobs 4 --retry 3
21
+ bundle exec rake test
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+ `spinjector` adheres to [Semantic Versioning](http://semver.org/).
4
+
5
+ ## [NEXT] - Date
6
+
7
+ ### Created
8
+
9
+ ### Fixed
10
+
11
+ ### Removed
12
+
13
+ ## [1.0.0] - 2022-12-19
14
+
15
+ ### Created
16
+
17
+ - Make the script idempotent. Successive calls to configure don’t modify the pbxproj file anymore
18
+ - Added tests
19
+
20
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ad_localize.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spinjector (0.0.6)
5
+ optparse (~> 0.1)
6
+ xcodeproj (~> 1.21)
7
+ yaml (~> 0.2)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ CFPropertyList (3.0.5)
13
+ rexml
14
+ ansi (1.5.0)
15
+ atomos (0.1.3)
16
+ builder (3.2.4)
17
+ claide (1.1.0)
18
+ colored2 (3.1.2)
19
+ minitest (5.15.0)
20
+ minitest-hooks (1.5.0)
21
+ minitest (> 5.3)
22
+ minitest-reporters (1.5.0)
23
+ ansi
24
+ builder
25
+ minitest (>= 5.0)
26
+ ruby-progressbar
27
+ nanaimo (0.3.0)
28
+ optparse (0.2.0)
29
+ rake (12.3.3)
30
+ rexml (3.2.5)
31
+ ruby-progressbar (1.11.0)
32
+ xcodeproj (1.21.0)
33
+ CFPropertyList (>= 2.3.3, < 4.0)
34
+ atomos (~> 0.1.3)
35
+ claide (>= 1.0.2, < 2.0)
36
+ colored2 (~> 3.1)
37
+ nanaimo (~> 0.3.0)
38
+ rexml (~> 3.2.4)
39
+ yaml (0.2.0)
40
+
41
+ PLATFORMS
42
+ x86_64-darwin-18
43
+
44
+ DEPENDENCIES
45
+ bundler (>= 1.12.0, < 3.0.0)
46
+ minitest (~> 5.11)
47
+ minitest-hooks (~> 1.5)
48
+ minitest-reporters (~> 1.3)
49
+ rake (~> 12.3)
50
+ spinjector!
51
+
52
+ BUNDLED WITH
53
+ 2.2.26
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # spinjector
2
+
2
3
  Inject Script phase in your Xcode project easily.
3
4
 
4
5
  # How to install
@@ -8,7 +9,9 @@ gem install spinjector
8
9
  ```
9
10
 
10
11
  # How to use
12
+
11
13
  ## Global configuration file
14
+
12
15
  First, create a YAML configuration file under `./Configuration/spinjector_configuration.yaml` (default path where spinjector looks for a configuration file).
13
16
 
14
17
  ```
@@ -31,7 +34,9 @@ targets:
31
34
  ```
32
35
 
33
36
  ## Script configuration file
37
+
34
38
  Then, for each script you want to inject in your Xcode project:
39
+
35
40
  - You can use `scripts` section in the global configuration file to define your script directly (eg. `foo`)...
36
41
 
37
42
  - ...Or create a script configuration file (eg. `helloworld.yaml`)
@@ -60,16 +65,19 @@ output_file_list_paths: # optional.
60
65
 
61
66
  dependency_file: # optional.
62
67
 
63
- execution_position: # optional. [:before-compile | :after-compile | :before-headers | :after-headers].
68
+ execution_position: # optional. [:before_compile | :after_compile | :before_headers | :after_headers | :after_all].
64
69
  ```
65
70
 
66
71
  - If you use the `script_path option`, create the script file
72
+
67
73
  ```
68
74
  echo Hello World
69
75
  ```
70
76
 
71
77
  ## Execution
78
+
72
79
  Finally, inject script phases
80
+
73
81
  ```
74
82
  spinjector [-c] <path-to-your-global-configuration-file>
75
83
  ```
@@ -86,3 +94,11 @@ Enjoy your build phases
86
94
  4. Execute `make publish`
87
95
 
88
96
  You may need to configure your account at step `4.` if you've never pushed any gem. You can find all the informations you need on [the official documentation](https://guides.rubygems.org/make-your-own-gem/#your-first-gem).
97
+
98
+ ## Tests
99
+
100
+ To run the tests, simply run:
101
+
102
+ ```sh
103
+ rake test
104
+ ```
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ t.warning = false
9
+ end
10
+
11
+ task :default => :test
@@ -38,6 +38,8 @@ class Script
38
38
  true
39
39
  when :after_compile, :after_headers
40
40
  false
41
+ when :after_all,
42
+ false
41
43
  else
42
44
  raise ArgumentError, "Unknown execution position `#{execution_position}`"
43
45
  end
@@ -7,4 +7,8 @@ class Target
7
7
  @name = name
8
8
  @scripts = scripts || []
9
9
  end
10
+
11
+ def scripts_names
12
+ @scripts.map { |script| script.name }
13
+ end
10
14
  end
@@ -0,0 +1,16 @@
1
+ class Logger
2
+ def log(content)
3
+ raise "Abstract class, should be overriden"
4
+ end
5
+ end
6
+
7
+ class EmptyLogger < Logger
8
+ def log(content)
9
+ end
10
+ end
11
+
12
+ class VerboseLogger < Logger
13
+ def log(content)
14
+ puts content
15
+ end
16
+ end
@@ -12,65 +12,131 @@ class ProjectService
12
12
 
13
13
  # @param [Xcodeproj::Project] project
14
14
  #
15
- def initialize(project)
15
+ def initialize(project, logger)
16
16
  @project = project
17
+ @logger = logger
17
18
  end
18
19
 
19
- # Remove all script phases prefixed by BUILD_PHASE_PREFIX from project
20
+ # @param [Configuration] configuration containing all scripts to add in each target
20
21
  #
21
- def remove_all_scripts
22
+ def update_scripts_in_targets(configuration)
22
23
  @project.targets.each do |target|
23
- # Delete script phases no longer present in the target.
24
+ @insertion_offset_after_compile = 0
25
+ @insertion_offset_after_headers = 0
26
+ target_configuration = configuration.targets.find { |conf_target| conf_target.name == target.name }
27
+ if target_configuration == nil
28
+ @logger.log "No Spinjector managed build phases in target #{target}"
29
+ remove_all_scripts(target)
30
+ next
31
+ end
32
+ @logger.log "Configurating target #{target}"
33
+ scripts_to_apply = target_configuration.scripts_names.map { |name| BUILD_PHASE_PREFIX + name }.to_set
24
34
  native_target_script_phases = target.shell_script_build_phases.select do |bp|
25
35
  !bp.name.nil? && bp.name.start_with?(BUILD_PHASE_PREFIX)
26
36
  end
27
37
  native_target_script_phases.each do |script_phase|
28
- target.build_phases.delete(script_phase)
38
+ if scripts_to_apply.include?(script_phase.name)
39
+ # Update existing script phase with new values
40
+ script_configuration = target_configuration.scripts.find { |script|
41
+ BUILD_PHASE_PREFIX + script.name == script_phase.name
42
+ }
43
+ update_script_in_target(script_phase, script_configuration, target)
44
+ scripts_to_apply.delete(script_phase.name)
45
+ elsif
46
+ target.build_phases.delete(script_phase)
47
+ # Remove now defunct script phase
48
+ end
29
49
  end
50
+ # We may miss scripts that are yet to be added to the pbxproj target, this is fixed in the following method
51
+ reorder_and_add_missing_script_phases_of(target, target_configuration)
30
52
  end
31
53
  end
32
54
 
33
- # @param [Configuration] configuration containing all scripts to add in each target
55
+ private
56
+
57
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to remove the script phases
58
+ # @return [<Xcodeproj::Project::Object::PBXShellScriptBuildPhase>] the newly created build phase
34
59
  #
35
- def add_scripts_in_targets(configuration)
36
- configuration.targets.each do |target|
37
- xcode_target = app_target(target.name)
38
- add_scripts_in_target(target.scripts, xcode_target)
60
+ def spinjector_managed_phases(target)
61
+ spinjector_managed_phases = target.shell_script_build_phases.select do |bp|
62
+ !bp.name.nil? && bp.name.start_with?(BUILD_PHASE_PREFIX)
39
63
  end
64
+ return spinjector_managed_phases
40
65
  end
41
66
 
42
- private
43
-
44
- # @param [String] target_name
45
- # @return [Xcodeproj::Project::Object::PBXNativeTarget] the target named by target_name
67
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to remove the script phases
46
68
  #
47
- def app_target(target_name)
48
- target = @project.targets.find { |t| t.name == target_name }
49
- raise "[Error] Invalid #{target_name} target." unless !target.nil?
50
- return target
69
+ def remove_all_scripts(target)
70
+ # Delete all the spinjector managed scripts from the selected target
71
+ spinjector_managed_phases(target).each do |script_phase|
72
+ target.build_phases.delete(script_phase)
73
+ end
51
74
  end
52
75
 
53
- # @param [Array<Script>] scripts the script phases defined in configuration files
54
76
  # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to add the script phases
77
+ # @param [Target] the target configuration describing the scripts to be added
55
78
  #
56
- def add_scripts_in_target(scripts, target)
57
- scripts.each do |script|
58
- name_with_prefix = BUILD_PHASE_PREFIX + script.name
59
- phase = target.new_shell_script_build_phase(name_with_prefix)
60
- phase.shell_script = script.source_code
61
- phase.shell_path = script.shell_path
62
- phase.input_paths = script.input_paths
63
- phase.output_paths = script.output_paths
64
- phase.input_file_list_paths = script.input_file_list_paths
65
- phase.output_file_list_paths = script.output_file_list_paths
66
- phase.dependency_file = script.dependency_file
67
- # At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only
68
- # gets set to '0' if the user has explicitly disabled this.
69
- if script.show_env_vars_in_log == '0'
70
- phase.show_env_vars_in_log = script.show_env_vars_in_log
79
+ def reorder_and_add_missing_script_phases_of(target, target_configuration)
80
+ target_configuration.scripts.each do |script|
81
+ current_phase = spinjector_managed_phases(target).find { |phase| phase.name == BUILD_PHASE_PREFIX + script.name }
82
+ if current_phase == nil && should_add_script_in_target(script, target)
83
+ current_phase = add_script_in_target(script, target)
71
84
  end
72
85
  execution_position = script.execution_position
73
- reorder_script_phase(target, phase, execution_position)
86
+ reorder_script_phase(target, current_phase, execution_position)
87
+ end
88
+ end
89
+
90
+ # Checks If the target contains a build phase associated to the script execution position
91
+ # For instance, it checks if the Headers build phase is present when the script has a :after_headers position
92
+ # @param [Script] script the script phase defined in configuration files to add to the target
93
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to add the script phases
94
+ # @return [Boolean] If the script should be added to the target
95
+ #
96
+ def should_add_script_in_target(script, target)
97
+ return true if script.execution_position === :after_all
98
+
99
+ target_phase_type = case script.execution_position
100
+ when :before_compile, :after_compile
101
+ Xcodeproj::Project::Object::PBXSourcesBuildPhase
102
+ when :before_headers, :after_headers
103
+ Xcodeproj::Project::Object::PBXHeadersBuildPhase
104
+ else
105
+ nil
106
+ end
107
+
108
+ found_phase_in_target = target.build_phases.find { |bp| bp.is_a?(target_phase_type) }
109
+ @logger.log("Can't find build phase associated to execution position #{script.execution_position} in target #{target.name}") if found_phase_in_target.nil?
110
+ return !found_phase_in_target.nil?
111
+ end
112
+
113
+ # @param [Script] script the script phase defined in configuration files to add to the target
114
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to add the script phases
115
+ # @return [Xcodeproj::Project::Object::PBXShellScriptBuildPhase] the newly created build phase
116
+ #
117
+ def add_script_in_target(script, target)
118
+ name_with_prefix = BUILD_PHASE_PREFIX + script.name
119
+ phase = target.new_shell_script_build_phase(name_with_prefix)
120
+ update_script_in_target(phase, script, target)
121
+ return phase
122
+ end
123
+
124
+ # @param [Xcodeproj::Project::Object::PBXShellScriptBuildPhase] phase to update with the values from the script
125
+ # @param [Script] script the script phase defined in configuration files to add to the target
126
+ # @param [Xcodeproj::Project::Object::PBXNativeTarget] target to add the script phase
127
+ #
128
+ def update_script_in_target(existing_phase, script_configuration, target)
129
+ existing_phase.shell_script = script_configuration.source_code
130
+ existing_phase.shell_path = script_configuration.shell_path
131
+ existing_phase.input_paths = script_configuration.input_paths
132
+ existing_phase.output_paths = script_configuration.output_paths
133
+ existing_phase.input_file_list_paths = script_configuration.input_file_list_paths
134
+ existing_phase.output_file_list_paths = script_configuration.output_file_list_paths
135
+ existing_phase.dependency_file = script_configuration.dependency_file
136
+ # At least with Xcode 10 `showEnvVarsInLog` is *NOT* set to any value even if it's checked and it only
137
+ # gets set to '0' if the user has explicitly disabled this.
138
+ if script_configuration.show_env_vars_in_log == '0'
139
+ existing_phase.show_env_vars_in_log = script_configuration.show_env_vars_in_log
74
140
  end
75
141
  end
76
142
 
@@ -79,42 +145,47 @@ class ProjectService
79
145
  # @param [Symbol] execution_position could be :before_compile, :after_compile, :before_headers, :after_headers
80
146
  #
81
147
  def reorder_script_phase(target, script_phase, execution_position)
82
- return if execution_position == :any || execution_position.to_s.empty?
83
-
148
+ return if execution_position == :any || execution_position.to_s.empty? || script_phase.nil?
149
+ if execution_position == :after_all
150
+ target.build_phases.move(script_phase, target.build_phases.count - 1)
151
+ return
152
+ end
153
+
154
+ offset = -1
84
155
  # Find the point P where to add the script phase
85
156
  target_phase_type = case execution_position
86
- when :before_compile, :after_compile
157
+ when :before_compile
158
+ Xcodeproj::Project::Object::PBXSourcesBuildPhase
159
+ when :after_compile
160
+ offset = @insertion_offset_after_compile
161
+ @insertion_offset_after_compile += 1
87
162
  Xcodeproj::Project::Object::PBXSourcesBuildPhase
88
- when :before_headers, :after_headers
163
+ when :before_headers
164
+ Xcodeproj::Project::Object::PBXHeadersBuildPhase
165
+ when :after_headers
166
+ offset = @insertion_offset_after_headers
167
+ @insertion_offset_after_headers += 1
89
168
  Xcodeproj::Project::Object::PBXHeadersBuildPhase
90
169
  else
91
170
  raise ArgumentError, "Unknown execution position `#{execution_position}`"
92
171
  end
93
-
94
- # Decide whether to add script_phase before or after point P
95
- order_before = case execution_position
96
- when :before_compile, :before_headers
97
- true
98
- when :after_compile, :after_headers
99
- false
100
- else
101
- raise ArgumentError, "Unknown execution position `#{execution_position}`"
102
- end
103
-
172
+
104
173
  # Get the first build phase index of P
105
174
  target_phase_index = target.build_phases.index do |bp|
106
175
  bp.is_a?(target_phase_type)
107
176
  end
108
177
  return if target_phase_index.nil?
109
-
178
+
110
179
  # Get the script phase we want to reorder index
111
180
  script_phase_index = target.build_phases.index do |bp|
112
181
  bp.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) && !bp.name.nil? && bp.name == script_phase.name
113
182
  end
114
-
115
- # Move script phase to P if needed
116
- if (order_before && script_phase_index > target_phase_index) || (!order_before && script_phase_index < target_phase_index)
117
- target.build_phases.move_from(script_phase_index, target_phase_index)
183
+ if target_phase_index < script_phase_index
184
+ offset += 1
118
185
  end
186
+
187
+ target.build_phases.move_from(script_phase_index, target_phase_index + offset)
119
188
  end
189
+
120
190
  end
191
+
@@ -0,0 +1,32 @@
1
+ # Inject script phases into your Xcode project
2
+ #
3
+ # @author Guillaume Berthier
4
+ #
5
+
6
+ require 'xcodeproj'
7
+ require_relative './project_service'
8
+ require_relative './yaml_parser'
9
+
10
+ class Runner
11
+
12
+ attr_reader :project
13
+
14
+ def initialize(project_path, configuration_file_path, logger)
15
+ raise "[Error] No xcodeproj found at #{project_path}" unless File.exist?(project_path)
16
+ @project = Xcodeproj::Project.open(project_path)
17
+ @configuration_file_path = configuration_file_path
18
+ @logger = logger
19
+ end
20
+
21
+ def run
22
+ configuration = YAMLParser.new(@configuration_file_path, @logger).configuration
23
+
24
+ project_service = ProjectService.new(project, @logger)
25
+ project_service.update_scripts_in_targets(configuration)
26
+
27
+ @project.save()
28
+ @logger.log "Success."
29
+ end
30
+
31
+ end
32
+
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'set'
2
3
  require_relative 'entity/configuration'
3
4
  require_relative 'entity/script'
4
5
  require_relative 'entity/target'
@@ -10,7 +11,12 @@ class YAMLParser
10
11
  #
11
12
  attr_reader :configuration
12
13
 
13
- def initialize(yaml_file_path)
14
+ def initialize(yaml_file_path, logger)
15
+ @logger = logger
16
+ @inlined_scripts_ids = Set[]
17
+ @inlined_scripts_names = Set[]
18
+ @other_scripts_paths = Set[]
19
+ @other_scripts_names = Set[]
14
20
  @configuration_description = load_yml_content(yaml_file_path)
15
21
  @configuration = Configuration.new(targets)
16
22
  end
@@ -19,12 +25,12 @@ class YAMLParser
19
25
 
20
26
  def targets
21
27
  if @configuration_description["targets"].nil?
22
- puts "[Warning] There is no target in your configuration file."
28
+ @logger.log "[Warning] There is no target in your configuration file."
23
29
  return
24
30
  end
25
31
  @configuration_description["targets"].map do |target_name, script_entries|
26
32
  if script_entries.nil?
27
- puts "[Warning] There is no scripts in your configuration file under target #{target_name}"
33
+ @logger.log "[Warning] There is no scripts in your configuration file under target #{target_name}"
28
34
  return
29
35
  end
30
36
  scripts = script_entries.map do |entry|
@@ -35,7 +41,7 @@ class YAMLParser
35
41
  end
36
42
 
37
43
  def get_script(entry)
38
- script =
44
+ script =
39
45
  if !@configuration_description["scripts"].nil? && !@configuration_description["scripts"][entry].nil?
40
46
  get_script_by_name(entry)
41
47
  elsif File.exist?(entry)
@@ -46,13 +52,25 @@ class YAMLParser
46
52
  end
47
53
 
48
54
  def get_script_by_name(name)
55
+ @inlined_scripts_ids.add(name)
49
56
  script_description = @configuration_description["scripts"][name]
50
- ScriptMapper.new(script_description).map()
57
+ script = ScriptMapper.new(script_description).map()
58
+ @inlined_scripts_names.add(script.name)
59
+ error = "[Error] Multiple scripts with same name \'#{script.name}\'"
60
+ raise error unless @inlined_scripts_ids.count == @inlined_scripts_names.count
61
+ raise error unless !@inlined_scripts_names.intersect?(@other_scripts_names)
62
+ return script
51
63
  end
52
64
 
53
65
  def get_script_by_path(path)
66
+ @other_scripts_paths.add(path)
54
67
  script_description = load_yml_content(path)
55
- ScriptMapper.new(script_description).map()
68
+ script = ScriptMapper.new(script_description).map()
69
+ @other_scripts_names.add(script.name)
70
+ error = "[Error] Multiple scripts with same name \'#{script.name}\'"
71
+ raise error unless @other_scripts_paths.count == @other_scripts_names.count
72
+ raise error unless !@inlined_scripts_names.intersect?(@other_scripts_names)
73
+ return script
56
74
  end
57
75
 
58
76
  # @param [String] configuration_path
data/lib/spinjector.rb CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  require 'optparse'
7
7
  require 'xcodeproj'
8
- require_relative 'spinjector/project_service'
9
- require_relative 'spinjector/yaml_parser'
8
+ require_relative 'spinjector/runner'
9
+ require_relative 'spinjector/logger'
10
10
 
11
11
  CONFIGURATION_FILE_PATH = 'Configuration/spinjector_configuration.yaml'.freeze
12
12
 
@@ -20,15 +20,11 @@ OptionParser.new do |opts|
20
20
  end.parse!
21
21
 
22
22
  project_path = Dir.glob("*.xcodeproj").first
23
- project = Xcodeproj::Project.open(project_path)
24
- raise "[Error] No xcodeproj found" unless !project.nil?
25
-
26
- configuration_file_path = options[:configuration_path] || CONFIGURATION_FILE_PATH
27
- configuration = YAMLParser.new(configuration_file_path).configuration
28
-
29
- project_service = ProjectService.new(project)
30
- project_service.remove_all_scripts()
31
- project_service.add_scripts_in_targets(configuration)
32
-
33
- project.save()
34
- puts "Success."
23
+ raise "[Error] No xcodeproj found in #{Dir.pwd}" if project_path.nil?
24
+
25
+ runner = Runner.new(
26
+ project_path,
27
+ options[:configuration_path] || CONFIGURATION_FILE_PATH,
28
+ VerboseLogger.new
29
+ )
30
+ runner.run
data/spinjector.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'spinjector'
3
- s.version = '0.0.6'
3
+ s.version = '1.0.0'
4
4
  s.executables << 'spinjector'
5
5
  s.summary = "Inject script phases into your Xcode project"
6
6
  s.description = ""
@@ -14,4 +14,10 @@ Gem::Specification.new do |s|
14
14
  s.add_dependency 'optparse', '~> 0.1'
15
15
  s.add_dependency 'xcodeproj', '~> 1.21'
16
16
  s.add_dependency 'yaml', '~> 0.2'
17
- end
17
+
18
+ s.add_development_dependency 'bundler', '>= 1.12.0', '< 3.0.0'
19
+ s.add_development_dependency 'rake', '~> 12.3'
20
+ s.add_development_dependency 'minitest', '~> 5.11'
21
+ s.add_development_dependency 'minitest-reporters', '~> 1.3'
22
+ s.add_development_dependency 'minitest-hooks', '~> 1.5'
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinjector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Berthier, Fabernovel
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-06 00:00:00.000000000 Z
11
+ date: 2022-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optparse
@@ -52,6 +52,82 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.2'
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.12.0
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: 3.0.0
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 1.12.0
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: 3.0.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '12.3'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '12.3'
89
+ - !ruby/object:Gem::Dependency
90
+ name: minitest
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '5.11'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '5.11'
103
+ - !ruby/object:Gem::Dependency
104
+ name: minitest-reporters
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '1.3'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.3'
117
+ - !ruby/object:Gem::Dependency
118
+ name: minitest-hooks
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.5'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.5'
55
131
  description: ''
56
132
  email: guillaume.berthier@fabernovel.com
57
133
  executables:
@@ -59,7 +135,9 @@ executables:
59
135
  extensions: []
60
136
  extra_rdoc_files: []
61
137
  files:
138
+ - ".github/workflows/ci.yml"
62
139
  - ".gitignore"
140
+ - CHANGELOG.md
63
141
  - Examples/Configuration/helloworld.yaml
64
142
  - Examples/Configuration/helloworld_explicit_script.yaml
65
143
  - Examples/Configuration/helloworld_short.yaml
@@ -67,14 +145,19 @@ files:
67
145
  - Examples/Images/build_phases.png
68
146
  - Examples/Images/hello_world_explicit.png
69
147
  - Examples/Scripts/helloworld.sh
148
+ - Gemfile
149
+ - Gemfile.lock
70
150
  - Makefile
71
151
  - README.md
152
+ - Rakefile
72
153
  - bin/spinjector
73
154
  - lib/spinjector.rb
74
155
  - lib/spinjector/entity/configuration.rb
75
156
  - lib/spinjector/entity/script.rb
76
157
  - lib/spinjector/entity/target.rb
158
+ - lib/spinjector/logger.rb
77
159
  - lib/spinjector/project_service.rb
160
+ - lib/spinjector/runner.rb
78
161
  - lib/spinjector/script_mapper.rb
79
162
  - lib/spinjector/yaml_parser.rb
80
163
  - spinjector.gemspec
@@ -82,7 +165,7 @@ homepage: https://github.com/faberNovel/spinjector
82
165
  licenses:
83
166
  - MIT
84
167
  metadata: {}
85
- post_install_message:
168
+ post_install_message:
86
169
  rdoc_options: []
87
170
  require_paths:
88
171
  - lib
@@ -97,8 +180,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
180
  - !ruby/object:Gem::Version
98
181
  version: '0'
99
182
  requirements: []
100
- rubygems_version: 3.0.3
101
- signing_key:
183
+ rubygems_version: 3.3.3
184
+ signing_key:
102
185
  specification_version: 4
103
186
  summary: Inject script phases into your Xcode project
104
187
  test_files: []