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 +4 -4
- data/.gitignore +1 -0
- data/Examples/Configuration/helloworld.yaml +8 -0
- data/Examples/Configuration/helloworld_short.yaml +2 -0
- data/Examples/Configuration/spinjector_configuration.yaml +11 -0
- data/Examples/Scripts/helloworld.sh +1 -0
- data/README.md +51 -0
- data/lib/spinjector.rb +20 -10
- data/spinjector.gemspec +1 -1
- metadata +7 -4
- data/README +0 -0
- data/spinjector-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 502f8d32df2be80b74853a2dff98674e1726c25bba12ae93ad3cc0410bcf19b3
|
4
|
+
data.tar.gz: f4ded6c2bf3ca6010b540dbdf4690c1b6e829bfd3731013172a1600e9141ab9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22cc30ca7469dd43ae33f475436270d423287b57e9a3ed67ab9a2ff35e50ecca51e4596d814057baf137ea400aca7ae955fe56a582814fa257c913c618dda1f1
|
7
|
+
data.tar.gz: 0eb28a729035d9d8a23db43cd1c7ff4e6b688c56a2e8a46f405497449da068009c7fe05d0af6dc2ab44b934d4564402afe118b5a675a5a5f9214539b0c76133b
|
data/.gitignore
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
@@ -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(
|
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
|
-
|
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
|
-
|
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
|
-
|
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
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.
|
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-
|
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
|
-
-
|
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
|