ambient-xcode 0.6.0 → 0.7.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 +4 -4
- data/.gitignore +3 -0
- data/README.md +13 -3
- data/ambient-xcode.gemspec +1 -1
- data/bin/ambient +32 -2
- data/example/Ambientfile +2 -2
- data/example/Ambientfile-objc +2 -2
- data/lib/ambient.rb +10 -160
- data/lib/ambient/application.rb +165 -0
- data/lib/ambient/capabilities_helper.rb +71 -0
- data/lib/ambient/dsl.rb +4 -0
- data/lib/ambient/dsl/main_scope.rb +160 -0
- data/lib/ambient/dsl/plist_scope.rb +21 -0
- data/lib/ambient/dsl/scheme_scope.rb +40 -0
- data/lib/ambient/dsl/target_scope.rb +36 -0
- data/lib/ambient/init.rb +33 -0
- data/lib/ambient/plist_helper.rb +29 -0
- data/lib/ambient/project_creation.rb +83 -0
- data/lib/ambient/project_helper.rb +113 -0
- data/templates/ios/PRODUCTNAME.xcodeproj/project.pbxproj +295 -0
- data/templates/ios/PRODUCTNAME.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/templates/ios/PRODUCTNAME/AppDelegate.swift +33 -0
- data/templates/ios/PRODUCTNAME/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- data/templates/ios/PRODUCTNAME/Base.lproj/LaunchScreen.storyboard +27 -0
- data/templates/ios/PRODUCTNAME/Base.lproj/Main.storyboard +25 -0
- data/templates/ios/PRODUCTNAME/Info.plist +47 -0
- data/templates/ios/PRODUCTNAME/ViewController.swift +13 -0
- metadata +29 -13
- data/lib/capabilities_helper.rb +0 -71
- data/lib/dsl.rb +0 -229
- data/lib/plist_helper.rb +0 -29
- data/lib/project_helper.rb +0 -112
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535741512152decacc083ba6036ccbd108c87d4f
|
4
|
+
data.tar.gz: da77b7cd41fa0585720138b545bf51e4f983153e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72734e410a4173855c755e17f13504afff8090bb9e6eb17110ed5365e5e63c6a7d0bc1c388ce7db73249d203f8370e075b6e1510e59492de6c8b96dd3055205d
|
7
|
+
data.tar.gz: 5596a7103942b59e4f3e57808956d3d6ad17cf5665a478ae78ba3f8c981678da259e38cc12afcfaf95236d284a6423113d8006d841341495b45721f283b5e46e
|
data/.gitignore
ADDED
data/README.md
CHANGED
@@ -43,12 +43,22 @@ plist("MyProject/Info.plist") do
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
-
Run `ambient` from the command line to write your settings into your project
|
46
|
+
Run `ambient` from the command line to write your settings into your project:
|
47
|
+
```
|
48
|
+
usage:
|
49
|
+
$ ambient COMMAND
|
50
|
+
|
51
|
+
Commands:
|
52
|
+
+ [no arguments] Applies the settings from the Ambientfile
|
53
|
+
+ init Creates an Ambientfile in the current directory
|
54
|
+
+ new NAME Creates a new iOS Xcode project with given name
|
55
|
+
+ [anything else] Applies the settings from the file name supplied
|
56
|
+
```
|
47
57
|
|
48
|
-
|
58
|
+
You can also have more than one `Ambientfile` for the same project. Just name it something else and run `ambient [filename]` (e.g. `ambient Ambientfile-enterprise`). Use `use_settings_from` to inherit settings:
|
49
59
|
|
50
60
|
```ruby
|
51
|
-
use_settings_from 'Ambientfile'
|
61
|
+
use_settings_from 'Ambientfile'
|
52
62
|
|
53
63
|
target "Monies" do
|
54
64
|
development_team "341MONEY25"
|
data/ambient-xcode.gemspec
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'ambient-xcode'
|
6
|
-
gem.version = '0.
|
6
|
+
gem.version = '0.7.0'
|
7
7
|
gem.authors = ['Daniel Inkpen']
|
8
8
|
gem.email = ['dan2552@gmail.com']
|
9
9
|
gem.description = %q{CLI for configuring Xcode projects from a Ruby file.}
|
data/bin/ambient
CHANGED
@@ -4,5 +4,35 @@ require 'fileutils'
|
|
4
4
|
$:.push File.expand_path("../../lib", __FILE__)
|
5
5
|
|
6
6
|
require 'ambient'
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
def print_help
|
9
|
+
print_version
|
10
|
+
puts ""
|
11
|
+
puts "usage: "
|
12
|
+
puts "$ ambient COMMAND"
|
13
|
+
puts ""
|
14
|
+
puts "Commands:"
|
15
|
+
puts "+ [no arguments]\tApplies the settings from the Ambientfile"
|
16
|
+
puts "+ init\t\t\tCreates an Ambientfile in the current directory"
|
17
|
+
puts "+ new NAME\t\tCreates a new iOS Xcode project with given name"
|
18
|
+
puts "+ [anything else]\tApplies the settings from the file name supplied"
|
19
|
+
end
|
20
|
+
|
21
|
+
def print_version
|
22
|
+
path = File.expand_path("../../", __FILE__)
|
23
|
+
gem_contents = File.read("#{path}/ambient-xcode.gemspec")
|
24
|
+
match = gem_contents.match /^\s*gem.version\s*= ('|")(.*)('|")/
|
25
|
+
puts "ambient-xcode #{match[2]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
if ARGV[0] == "init"
|
29
|
+
Ambient::Init.new.create_ambientfile
|
30
|
+
elsif ARGV[0] == "new"
|
31
|
+
Ambient::ProjectCreation.new(Dir.pwd, ARGV[1]).create_ios_project
|
32
|
+
elsif ARGV[0] == "help" || ARGV[0] == "--help"
|
33
|
+
print_help
|
34
|
+
elsif ARGV[0] == "version" || ARGV[0] == "--version" || ARGV[0] == "-v"
|
35
|
+
print_version
|
36
|
+
else
|
37
|
+
Ambient::Application.new.run_ambientfile(ARGV[0])
|
38
|
+
end
|
data/example/Ambientfile
CHANGED
data/example/Ambientfile-objc
CHANGED
data/lib/ambient.rb
CHANGED
@@ -1,160 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
require_relative '
|
10
|
-
require_relative '
|
11
|
-
require_relative 'plist_helper'
|
12
|
-
require_relative 'dsl'
|
13
|
-
|
14
|
-
module Ambient
|
15
|
-
extend self
|
16
|
-
Ambient::ROOT = File.expand_path('.', File.dirname(__FILE__))
|
17
|
-
|
18
|
-
@use_defaults = false
|
19
|
-
@project_options = {}
|
20
|
-
@shared_target_options = {}
|
21
|
-
@target_options = {}
|
22
|
-
@scheme_options = {}
|
23
|
-
@parents = {}
|
24
|
-
@capabilities = {}
|
25
|
-
@development_teams = {}
|
26
|
-
|
27
|
-
def configure(&block)
|
28
|
-
instance_eval &block
|
29
|
-
end
|
30
|
-
|
31
|
-
def project_helper
|
32
|
-
@project_helper ||= ProjectHelper.new
|
33
|
-
end
|
34
|
-
|
35
|
-
def set_parent_scheme(target: nil, child: nil, parent: nil)
|
36
|
-
target = target || :all
|
37
|
-
@parents[target] ||= {}
|
38
|
-
@parents[target][child] = parent
|
39
|
-
end
|
40
|
-
|
41
|
-
def set_option(option, value, target: nil, scheme: nil, parent: nil)
|
42
|
-
value = "YES" if value == true
|
43
|
-
value = "NO" if value == false
|
44
|
-
value = nil if value == :default
|
45
|
-
|
46
|
-
if target
|
47
|
-
if scheme
|
48
|
-
@target_options[target] ||= {}
|
49
|
-
@target_options[target][scheme] ||= {}
|
50
|
-
@target_options[target][scheme][option] = value
|
51
|
-
else
|
52
|
-
@shared_target_options[target] ||= {}
|
53
|
-
@shared_target_options[target][option] = value
|
54
|
-
end
|
55
|
-
else
|
56
|
-
if scheme
|
57
|
-
@scheme_options[scheme] ||= {}
|
58
|
-
@scheme_options[scheme][option] = value
|
59
|
-
else
|
60
|
-
@project_options[option] = value
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def set_capability(target_name, capability_name)
|
66
|
-
capabilities = @capabilities[target_name] ||= []
|
67
|
-
capabilities << capability_name
|
68
|
-
end
|
69
|
-
|
70
|
-
def set_development_team(target_name, team_name)
|
71
|
-
@development_teams[target_name] = team_name
|
72
|
-
end
|
73
|
-
|
74
|
-
def setup_project(ambientfile)
|
75
|
-
run_ambientfile(ambientfile)
|
76
|
-
project_helper.print_info
|
77
|
-
reset_project_to_defaults if @use_defaults
|
78
|
-
reset_targets_to_defaults if @use_defaults
|
79
|
-
reset_capabilites_to_defaults if @use_defaults
|
80
|
-
load_in_parent_scheme_values
|
81
|
-
process_project_options
|
82
|
-
process_scheme_options
|
83
|
-
process_shared_target_options
|
84
|
-
process_target_options
|
85
|
-
process_capabilities
|
86
|
-
process_development_teams
|
87
|
-
project_helper.save_changes
|
88
|
-
end
|
89
|
-
|
90
|
-
def reset_project_to_defaults
|
91
|
-
puts "resetting project settings to xcode default settings"
|
92
|
-
project_helper.reset_project_to_defaults
|
93
|
-
end
|
94
|
-
|
95
|
-
def reset_targets_to_defaults
|
96
|
-
puts "resetting target settings to xcode default settings"
|
97
|
-
project_helper.reset_targets_to_defaults
|
98
|
-
end
|
99
|
-
|
100
|
-
def reset_capabilites_to_defaults
|
101
|
-
puts "resetting capabilities to xcode default settings"
|
102
|
-
project_helper.reset_capabilities_to_defaults
|
103
|
-
end
|
104
|
-
|
105
|
-
def process_project_options
|
106
|
-
puts "applying ambient project settings"
|
107
|
-
project_helper.process_project_options(@project_options)
|
108
|
-
end
|
109
|
-
|
110
|
-
def process_scheme_options
|
111
|
-
puts "applying ambient scheme settings"
|
112
|
-
project_helper.process_scheme_options(@scheme_options)
|
113
|
-
end
|
114
|
-
|
115
|
-
def process_shared_target_options
|
116
|
-
puts "applying ambient shared target settings"
|
117
|
-
project_helper.process_shared_target_options(@shared_target_options)
|
118
|
-
end
|
119
|
-
|
120
|
-
def process_target_options
|
121
|
-
puts "applying ambient target settings"
|
122
|
-
project_helper.process_target_options(@target_options)
|
123
|
-
end
|
124
|
-
|
125
|
-
def process_capabilities
|
126
|
-
puts "applying ambient capabilities"
|
127
|
-
project_helper.process_capabilities(@capabilities)
|
128
|
-
end
|
129
|
-
|
130
|
-
def process_development_teams
|
131
|
-
puts "applying ambient development teams"
|
132
|
-
project_helper.process_development_teams(@development_teams)
|
133
|
-
end
|
134
|
-
|
135
|
-
def load_in_parent_scheme_values
|
136
|
-
@parents.each do |target, parents|
|
137
|
-
parents.each do |child, parent|
|
138
|
-
if parent
|
139
|
-
if target == :all
|
140
|
-
puts "Identified #{child} as a child of #{parent}"
|
141
|
-
child_options = @scheme_options[child]
|
142
|
-
parent_options = @scheme_options[parent]
|
143
|
-
else
|
144
|
-
target_options = @target_options[target]
|
145
|
-
child_options = target_options[child]
|
146
|
-
parent_options = target_options[parent]
|
147
|
-
end
|
148
|
-
child_options.merge!(parent_options) { |_, child, _| child }
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def run_ambientfile(filename)
|
155
|
-
puts "# Reading settings from #{filename}"
|
156
|
-
ambient = File.join(Dir.pwd, filename)
|
157
|
-
raise "#{filename} not found in current directory." unless File.exists?(ambient)
|
158
|
-
load ambient
|
159
|
-
end
|
160
|
-
end
|
1
|
+
require 'xcodeproj'
|
2
|
+
require 'plist'
|
3
|
+
|
4
|
+
require_relative 'ambient/project_helper'
|
5
|
+
require_relative 'ambient/capabilities_helper'
|
6
|
+
require_relative 'ambient/plist_helper'
|
7
|
+
require_relative 'ambient/dsl'
|
8
|
+
require_relative 'ambient/project_creation'
|
9
|
+
require_relative 'ambient/init'
|
10
|
+
require_relative 'ambient/application'
|
@@ -0,0 +1,165 @@
|
|
1
|
+
module Ambient
|
2
|
+
class Application
|
3
|
+
attr_reader :path
|
4
|
+
|
5
|
+
def initialize(path = nil)
|
6
|
+
@path = path || File.expand_path('.', File.dirname(__FILE__))
|
7
|
+
|
8
|
+
@use_defaults = false
|
9
|
+
@project_options = {}
|
10
|
+
@shared_target_options = {}
|
11
|
+
@target_options = {}
|
12
|
+
@scheme_options = {}
|
13
|
+
@parents = {}
|
14
|
+
@capabilities = {}
|
15
|
+
@development_teams = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_ambientfile(file = nil)
|
19
|
+
setup_project(file || "Ambientfile")
|
20
|
+
end
|
21
|
+
|
22
|
+
def configure(&block)
|
23
|
+
instance_eval(&block)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def project_helper
|
29
|
+
@project_helper ||= ProjectHelper.new(path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_parent_scheme(target: nil, child: nil, parent: nil)
|
33
|
+
target = target || :all
|
34
|
+
@parents[target] ||= {}
|
35
|
+
@parents[target][child] = parent
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_option(option, value, target: nil, scheme: nil, parent: nil)
|
39
|
+
value = "YES" if value == true
|
40
|
+
value = "NO" if value == false
|
41
|
+
value = nil if value == :default
|
42
|
+
|
43
|
+
if target
|
44
|
+
if scheme
|
45
|
+
@target_options[target] ||= {}
|
46
|
+
@target_options[target][scheme] ||= {}
|
47
|
+
@target_options[target][scheme][option] = value
|
48
|
+
else
|
49
|
+
@shared_target_options[target] ||= {}
|
50
|
+
@shared_target_options[target][option] = value
|
51
|
+
end
|
52
|
+
else
|
53
|
+
if scheme
|
54
|
+
@scheme_options[scheme] ||= {}
|
55
|
+
@scheme_options[scheme][option] = value
|
56
|
+
else
|
57
|
+
@project_options[option] = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_capability(target_name, capability_name)
|
63
|
+
capabilities = @capabilities[target_name] ||= []
|
64
|
+
capabilities << capability_name
|
65
|
+
end
|
66
|
+
|
67
|
+
def set_development_team(target_name, team_name)
|
68
|
+
@development_teams[target_name] = team_name
|
69
|
+
end
|
70
|
+
|
71
|
+
def setup_project(ambientfile)
|
72
|
+
read(ambientfile)
|
73
|
+
project_helper.print_info
|
74
|
+
reset_project_to_defaults if @use_defaults
|
75
|
+
reset_targets_to_defaults if @use_defaults
|
76
|
+
reset_capabilites_to_defaults if @use_defaults
|
77
|
+
load_in_parent_scheme_values
|
78
|
+
process_project_options
|
79
|
+
process_scheme_options
|
80
|
+
process_shared_target_options
|
81
|
+
process_target_options
|
82
|
+
process_capabilities
|
83
|
+
process_development_teams
|
84
|
+
project_helper.save_changes
|
85
|
+
end
|
86
|
+
|
87
|
+
def reset_project_to_defaults
|
88
|
+
puts "resetting project settings to xcode default settings"
|
89
|
+
project_helper.reset_project_to_defaults
|
90
|
+
end
|
91
|
+
|
92
|
+
def reset_targets_to_defaults
|
93
|
+
puts "resetting target settings to xcode default settings"
|
94
|
+
project_helper.reset_targets_to_defaults
|
95
|
+
end
|
96
|
+
|
97
|
+
def reset_capabilites_to_defaults
|
98
|
+
puts "resetting capabilities to xcode default settings"
|
99
|
+
project_helper.reset_capabilities_to_defaults
|
100
|
+
end
|
101
|
+
|
102
|
+
def process_project_options
|
103
|
+
puts "applying ambient project settings"
|
104
|
+
project_helper.process_project_options(@project_options)
|
105
|
+
end
|
106
|
+
|
107
|
+
def process_scheme_options
|
108
|
+
puts "applying ambient scheme settings"
|
109
|
+
project_helper.process_scheme_options(@scheme_options)
|
110
|
+
end
|
111
|
+
|
112
|
+
def process_shared_target_options
|
113
|
+
puts "applying ambient shared target settings"
|
114
|
+
project_helper.process_shared_target_options(@shared_target_options)
|
115
|
+
end
|
116
|
+
|
117
|
+
def process_target_options
|
118
|
+
puts "applying ambient target settings"
|
119
|
+
project_helper.process_target_options(@target_options)
|
120
|
+
end
|
121
|
+
|
122
|
+
def process_capabilities
|
123
|
+
puts "applying ambient capabilities"
|
124
|
+
project_helper.process_capabilities(@capabilities)
|
125
|
+
end
|
126
|
+
|
127
|
+
def process_development_teams
|
128
|
+
puts "applying ambient development teams"
|
129
|
+
project_helper.process_development_teams(@development_teams)
|
130
|
+
end
|
131
|
+
|
132
|
+
def load_in_parent_scheme_values
|
133
|
+
@parents.each do |target, parents|
|
134
|
+
parents.each do |child, parent|
|
135
|
+
if parent
|
136
|
+
if target == :all
|
137
|
+
puts "Identified #{child} as a child of #{parent}"
|
138
|
+
child_options = @scheme_options[child]
|
139
|
+
parent_options = @scheme_options[parent]
|
140
|
+
else
|
141
|
+
target_options = @target_options[target]
|
142
|
+
child_options = target_options[child]
|
143
|
+
parent_options = target_options[parent]
|
144
|
+
end
|
145
|
+
child_options.merge!(parent_options) { |_, child, _| child }
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def read(filename)
|
152
|
+
puts "# Reading settings from #{filename}"
|
153
|
+
ambient = File.join(path, filename)
|
154
|
+
|
155
|
+
unless File.exists?(ambient)
|
156
|
+
puts "😱 #{filename} not found in current directory."
|
157
|
+
exit 1
|
158
|
+
end
|
159
|
+
|
160
|
+
DSL::MainScope.new(self).instance_eval do
|
161
|
+
eval(File.read(ambient))
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|