spinjector 0.0.2 → 0.0.3

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: bbdf7ea58d76021bcd8302180796917e5d7558f0731f7d75291600bdb0b45667
4
- data.tar.gz: adb9363c4fe050493327d9dd891c97a300961ad546ba87bd0f0b0a1d7e8a0167
3
+ metadata.gz: 502f8d32df2be80b74853a2dff98674e1726c25bba12ae93ad3cc0410bcf19b3
4
+ data.tar.gz: f4ded6c2bf3ca6010b540dbdf4690c1b6e829bfd3731013172a1600e9141ab9d
5
5
  SHA512:
6
- metadata.gz: aa16a38ffd1126bd84cec774493a8ee465b8e4df545d508ae990e7800b1afac346418cc74d7d1f006b8e4ad975406c53a812c0149e172013ecbf9a7f95da9e98
7
- data.tar.gz: 2a07ff2f2c8e0ae2cbdcfaf108bfcf32910cf97e893c5c71fe3ba49d85fbd51a946319268e7375c0bbaacd9d5751fa6a2ce4f090a286d479744313340724e7ff
6
+ metadata.gz: 22cc30ca7469dd43ae33f475436270d423287b57e9a3ed67ab9a2ff35e50ecca51e4596d814057baf137ea400aca7ae955fe56a582814fa257c913c618dda1f1
7
+ data.tar.gz: 0eb28a729035d9d8a23db43cd1c7ff4e6b688c56a2e8a46f405497449da068009c7fe05d0af6dc2ab44b934d4564402afe118b5a675a5a5f9214539b0c76133b
data/.gitignore CHANGED
@@ -0,0 +1 @@
1
+ *.gem
@@ -0,0 +1,8 @@
1
+ name: "HelloWorld"
2
+ script_path: "Scripts/helloworld.sh"
3
+ input_paths:
4
+ output_paths:
5
+ input_file_list_paths:
6
+ output_file_list_paths:
7
+ dependency_file:
8
+ execution_position: :before_compile
@@ -0,0 +1,2 @@
1
+ name: "HelloWorldShort"
2
+ script_path: "Scripts/helloworld.sh"
@@ -0,0 +1,11 @@
1
+ # TargetNameFoo:
2
+ # - <script path A> to inject
3
+ # - <script path B> to inject
4
+ # TargetNameBar:
5
+ # - <script path A> to inject
6
+ # - <script path C> to inject
7
+
8
+ TargetNameA:
9
+ - "helloworld.yaml"
10
+ TargetNameB:
11
+ - "helloworld_short.yaml"
@@ -0,0 +1 @@
1
+ echo "Hello World"
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # spinjector
2
+ Inject Script phase in your Xcode project easily.
3
+
4
+ # How to install
5
+
6
+ ```
7
+ gem install spinjector
8
+ ```
9
+
10
+ # How to use
11
+ ## Global configuration file
12
+ First, create a YAML configuration file under `./Configuration/spinjector_configuration.yaml` (default path where spinjector looks for a configuration file).
13
+
14
+ ```
15
+ TargetNameFoo:
16
+ - <scriptA config path> to inject
17
+ - <scriptB config path> to inject
18
+ TargetNameBar:
19
+ - <scriptA config path> to inject
20
+ - <scriptC config path> to inject
21
+ ```
22
+
23
+ ## Script configuration file
24
+ Then, for each script you want to inject in your Xcode project, create:
25
+ - A configuration file for this script
26
+ ```
27
+ name: "Hello World" # required. Script phase name.
28
+ script_path: "Script/helloworld.sh" # required. Script file path.
29
+ input_paths: # optional.
30
+ - ""
31
+ output_paths: # optional.
32
+ - ""
33
+ input_file_list_paths: # optional.
34
+ - ""
35
+ output_file_list_paths: # optional.
36
+ - ""
37
+ dependency_file: # optional.
38
+ execution_position: # optional. [:before-compile | :after-compile | :before-headers | :after-headers].
39
+ ```
40
+
41
+ - The script file defined under `script_path` in your script configuration file
42
+ ```
43
+ echo Hello World
44
+ ```
45
+
46
+ ## Execution
47
+ Finally, inject script phases
48
+ ```
49
+ spinjector [-c] <path-to-your-global-configuration-file>
50
+
51
+ ```
data/lib/spinjector.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  # @author Guillaume Berthier
4
4
  #
5
5
 
6
+ require 'optparse'
6
7
  require 'xcodeproj'
7
8
  require 'yaml'
8
9
 
@@ -13,6 +14,16 @@ BUILD_PHASE_PREFIX = '[SPI] '.freeze
13
14
 
14
15
  CONFIGURATION_FILE_PATH = 'Configuration/spinjector_configuration.yaml'.freeze
15
16
 
17
+ options = {}
18
+ OptionParser.new do |opts|
19
+ opts.banner = "Usage: spinjector [options]"
20
+
21
+
22
+ opts.on("-cName", "--configuration-path=Name", "Inject scripts using configuration file at Name location. Default is ./#{CONFIGURATION_FILE_PATH}") do |config_path|
23
+ options[:configuration_path] = config_path
24
+ end
25
+ end.parse!
26
+
16
27
  # @param [Xcodeproj::Project] project
17
28
  #
18
29
  def remove_all_spi_script_phases(project)
@@ -29,13 +40,13 @@ end
29
40
 
30
41
  # @param [Xcodeproj::Project] project
31
42
  #
32
- def inject_script_phases(project)
33
- configuration_file = load_yml_content(CONFIGURATION_FILE_PATH)
43
+ def inject_script_phases(project, configuration_file_path)
44
+ configuration_file = load_yml_content(configuration_file_path)
34
45
  configuration_file.each do |target_name, script_paths|
35
- return unless !target_name.nil?
36
46
  script_phases = (script_paths || []).flat_map do |script_path|
37
47
  load_yml_content(script_path)
38
48
  end
49
+ warn "[Warning] No script phases found for #{target_name} target. You can add them in your configuration file at #{configuration_file_path}" unless !script_phases.empty?
39
50
  target = app_target(project, target_name)
40
51
  create_script_phases(script_phases, target)
41
52
  end
@@ -45,10 +56,7 @@ end
45
56
  # @return [Hash] the hash in the configuration file
46
57
  #
47
58
  def load_yml_content(configuration_path)
48
- if !File.exist?(configuration_path)
49
- puts "Script phase #{configuration_path} unknown"
50
- return {}
51
- end
59
+ raise "[Error] YAML file #{configuration_path} not found." unless File.exist?(configuration_path)
52
60
  YAML.load(File.read(configuration_path)) || {}
53
61
  end
54
62
 
@@ -58,7 +66,7 @@ end
58
66
  #
59
67
  def app_target(project, target_name)
60
68
  target = project.targets.find { |t| t.name == target_name }
61
- puts "Invalid #{target_name} target." unless !target.nil?
69
+ raise "[Error] Invalid #{target_name} target." unless !target.nil?
62
70
  return target
63
71
  end
64
72
 
@@ -135,7 +143,9 @@ end
135
143
 
136
144
  project_path = Dir.glob("*.xcodeproj").first
137
145
  project = Xcodeproj::Project.open(project_path)
146
+ raise "[Error] No xcodeproj found" unless !project.nil?
138
147
  remove_all_spi_script_phases(project)
139
- inject_script_phases(project)
148
+ configuration_file_path = options[:configuration_path] || CONFIGURATION_FILE_PATH
149
+ inject_script_phases(project, configuration_file_path)
140
150
  project.save()
141
- puts "Success"
151
+ puts "Success."
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.2'
3
+ s.version = '0.0.3'
4
4
  s.executables << 'spinjector'
5
5
  s.summary = "Inject script phases into your Xcode project"
6
6
  s.description = ""
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Berthier, Fabernovel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: guillaume.berthier@fabernovel.com
@@ -18,10 +18,13 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".gitignore"
21
- - README
21
+ - Examples/Configuration/helloworld.yaml
22
+ - Examples/Configuration/helloworld_short.yaml
23
+ - Examples/Configuration/spinjector_configuration.yaml
24
+ - Examples/Scripts/helloworld.sh
25
+ - README.md
22
26
  - bin/spinjector
23
27
  - lib/spinjector.rb
24
- - spinjector-0.0.1.gem
25
28
  - spinjector.gemspec
26
29
  homepage: https://www.fabernovel.com
27
30
  licenses:
data/README DELETED
File without changes
data/spinjector-0.0.1.gem DELETED
Binary file