phoenx 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/bin/phoenx +9 -0
- data/lib/phoenx.rb +28 -0
- data/lib/phoenx/cli/cli_factory.rb +166 -0
- data/lib/phoenx/cli/command.rb +185 -0
- data/lib/phoenx/cli/option.rb +34 -0
- data/lib/phoenx/constants.rb +21 -0
- data/lib/phoenx/entities/configuration.rb +17 -0
- data/lib/phoenx/entities/dependency.rb +19 -0
- data/lib/phoenx/entities/project.rb +45 -0
- data/lib/phoenx/entities/scheme.rb +20 -0
- data/lib/phoenx/entities/target.rb +107 -0
- data/lib/phoenx/entities/workspace.rb +34 -0
- data/lib/phoenx/gem_version.rb +5 -0
- data/lib/phoenx/use_cases/generate_project.rb +106 -0
- data/lib/phoenx/use_cases/generate_target.rb +552 -0
- data/lib/phoenx/use_cases/generate_workspace.rb +74 -0
- data/lib/phoenx/utilities/files_utils.rb +22 -0
- data/lib/phoenx/utilities/xcodeproj_utils.rb +102 -0
- data/lib/phoenx/validators/configuration_validator.rb +22 -0
- data/lib/phoenx/validators/project_validator.rb +22 -0
- data/lib/phoenx/validators/workspace_validator.rb +29 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f9fa3f4569f9caa70bac213e4b6688297737ae8
|
4
|
+
data.tar.gz: 3a779b3b702c512fb7d8337c4569b2eb5735b34a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 190474389d8715aebf5d4ff80e8c44022431153bab9c3fcf23a6b84282c06577e5c073421a1c71bdbcb66841e94489435e97028f5ae7965b7e239d7d4825afb3
|
7
|
+
data.tar.gz: ff48aa6c9c83df62c1ff17b0d11e1ccf4020b929a031192ef44ced62d32c49cf7ea7bcb16f72c0acb5adddf99e66faa9ffbbbab5252d3e3661b62c739a44bd59
|
data/bin/phoenx
ADDED
data/lib/phoenx.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'colored'
|
2
|
+
require 'git'
|
3
|
+
require 'xcodeproj'
|
4
|
+
|
5
|
+
require 'phoenx/gem_version'
|
6
|
+
require 'phoenx/constants'
|
7
|
+
|
8
|
+
require 'phoenx/cli/option'
|
9
|
+
require 'phoenx/cli/command'
|
10
|
+
require 'phoenx/cli/cli_factory'
|
11
|
+
|
12
|
+
require 'phoenx/entities/project'
|
13
|
+
require 'phoenx/entities/target'
|
14
|
+
require 'phoenx/entities/configuration'
|
15
|
+
require 'phoenx/entities/scheme'
|
16
|
+
require 'phoenx/entities/workspace'
|
17
|
+
require 'phoenx/entities/dependency'
|
18
|
+
|
19
|
+
require 'phoenx/use_cases/generate_workspace'
|
20
|
+
require 'phoenx/use_cases/generate_project'
|
21
|
+
require 'phoenx/use_cases/generate_target'
|
22
|
+
|
23
|
+
require 'phoenx/utilities/xcodeproj_utils'
|
24
|
+
require 'phoenx/utilities/files_utils'
|
25
|
+
|
26
|
+
require 'phoenx/validators/project_validator'
|
27
|
+
require 'phoenx/validators/workspace_validator'
|
28
|
+
require 'phoenx/validators/configuration_validator'
|
@@ -0,0 +1,166 @@
|
|
1
|
+
module Phoenx
|
2
|
+
|
3
|
+
module Cli
|
4
|
+
|
5
|
+
class Factory
|
6
|
+
|
7
|
+
def workspace_command
|
8
|
+
|
9
|
+
command = Phoenx::Cli::Command.new "workspace", "Builds the workspace and projects" do
|
10
|
+
|
11
|
+
command.print
|
12
|
+
exit
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
command.base_command = "phoenx workspace"
|
17
|
+
command.usage = "Initializes the workspace by generating the xcodeproj and xcworkspace files."
|
18
|
+
|
19
|
+
# Add workspace build command
|
20
|
+
|
21
|
+
build_command = Phoenx::Cli::Command.new "build", "Builds the workspace and projects" do
|
22
|
+
|
23
|
+
workspaces = Dir["*." + Phoenx::WORKSPACE_EXTENSION]
|
24
|
+
|
25
|
+
if workspaces.count < 1
|
26
|
+
|
27
|
+
puts "Error: No workspace spec found!".red
|
28
|
+
exit
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
workspace = eval File.read(workspaces.first)
|
33
|
+
|
34
|
+
if !workspace
|
35
|
+
|
36
|
+
puts "Error: No workspace spec found!".red
|
37
|
+
exit
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
puts "\r\nGenerating projects and workspace".green
|
42
|
+
|
43
|
+
generator = Phoenx::GenerateWorkspace.new workspace
|
44
|
+
generator.generate
|
45
|
+
|
46
|
+
exit
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
build_command.base_command = "phoenx workspace"
|
52
|
+
build_command.usage = "Initializes the workspace by generating the xcodeproj and xcworkspace files."
|
53
|
+
|
54
|
+
build_help_option = Phoenx::Cli::Option.new("--help", "-h","Shows this help",false) do
|
55
|
+
build_command.print
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
|
59
|
+
build_command.add_option build_help_option
|
60
|
+
|
61
|
+
command.add_command build_command
|
62
|
+
|
63
|
+
return command
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
def project_command
|
68
|
+
|
69
|
+
command = Phoenx::Cli::Command.new "project", "Builds the project" do
|
70
|
+
|
71
|
+
command.print
|
72
|
+
exit
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
command.base_command = "phoenx project"
|
77
|
+
command.usage = "Generates the xcodeproj file from the pxproject specification."
|
78
|
+
|
79
|
+
# Add workspace build command
|
80
|
+
|
81
|
+
build_command = Phoenx::Cli::Command.new "build", "Builds the project" do
|
82
|
+
|
83
|
+
projects = Dir["*." + Phoenx::PROJECT_EXTENSION]
|
84
|
+
|
85
|
+
if projects.count < 1
|
86
|
+
|
87
|
+
puts "Error: No project spec found!".red
|
88
|
+
exit
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
project = eval File.read(projects.first)
|
93
|
+
|
94
|
+
if !project
|
95
|
+
|
96
|
+
puts "Error: No project spec found!".red
|
97
|
+
exit
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
puts "\r\nGenerating project".green
|
102
|
+
|
103
|
+
generator = Phoenx::GenerateProject.new project
|
104
|
+
generator.build
|
105
|
+
|
106
|
+
exit
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
build_command.base_command = "phoenx project"
|
112
|
+
build_command.usage = "Generates the xcodeproj file."
|
113
|
+
|
114
|
+
build_help_option = Phoenx::Cli::Option.new("--help", "-h","Shows this help",false) do
|
115
|
+
build_command.print
|
116
|
+
exit
|
117
|
+
end
|
118
|
+
|
119
|
+
build_command.add_option build_help_option
|
120
|
+
|
121
|
+
command.add_command build_command
|
122
|
+
|
123
|
+
return command
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
def cli
|
128
|
+
|
129
|
+
# Build cli
|
130
|
+
|
131
|
+
cli = Phoenx::Cli::Command.new "root", "" do |c|
|
132
|
+
|
133
|
+
c.print
|
134
|
+
|
135
|
+
end
|
136
|
+
|
137
|
+
cli.base_command = "phoenx"
|
138
|
+
|
139
|
+
# Add version and help options
|
140
|
+
|
141
|
+
version_option = Phoenx::Cli::Option.new("--version","-v","Shows version information",false) do
|
142
|
+
puts "phoenx version " + Phoenx::VERSION.bold
|
143
|
+
|
144
|
+
exit
|
145
|
+
end
|
146
|
+
|
147
|
+
help_option = Phoenx::Cli::Option.new("--help","-h","Shows this help",false) do
|
148
|
+
cli.print
|
149
|
+
exit
|
150
|
+
end
|
151
|
+
|
152
|
+
cli.add_option version_option
|
153
|
+
cli.add_option help_option
|
154
|
+
|
155
|
+
cli.add_command self.workspace_command
|
156
|
+
cli.add_command self.project_command
|
157
|
+
|
158
|
+
return cli
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
module Phoenx
|
2
|
+
|
3
|
+
module Cli
|
4
|
+
|
5
|
+
class Command
|
6
|
+
|
7
|
+
attr_accessor :name
|
8
|
+
attr_accessor :description
|
9
|
+
attr_accessor :base_command
|
10
|
+
attr_accessor :usage
|
11
|
+
|
12
|
+
@block
|
13
|
+
@options
|
14
|
+
@commands
|
15
|
+
|
16
|
+
@@indent = 20
|
17
|
+
|
18
|
+
def initialize(name, description, &block)
|
19
|
+
|
20
|
+
@name = name
|
21
|
+
@description = description
|
22
|
+
@block = block
|
23
|
+
|
24
|
+
@options = []
|
25
|
+
@commands = []
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_option(option)
|
30
|
+
|
31
|
+
@options << option
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_command(command)
|
36
|
+
|
37
|
+
@commands << command
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse(args)
|
42
|
+
|
43
|
+
args_tmp = args.dup
|
44
|
+
|
45
|
+
if args_tmp.empty?
|
46
|
+
|
47
|
+
@block.call self
|
48
|
+
|
49
|
+
else
|
50
|
+
|
51
|
+
args_tmp.each do |arg|
|
52
|
+
|
53
|
+
@commands.each do |command|
|
54
|
+
|
55
|
+
if arg == command.name
|
56
|
+
|
57
|
+
args_tmp.delete(arg)
|
58
|
+
|
59
|
+
command.parse(args_tmp)
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
@options.each do |option|
|
66
|
+
|
67
|
+
if arg == option.name || arg == option.short_cut
|
68
|
+
|
69
|
+
args_tmp.delete(arg)
|
70
|
+
|
71
|
+
option.execute
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
unless args_tmp.empty?
|
82
|
+
|
83
|
+
error = "Unknown arguments: "
|
84
|
+
|
85
|
+
args_tmp.each do |arg|
|
86
|
+
|
87
|
+
error += arg + " "
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
puts error
|
92
|
+
|
93
|
+
print
|
94
|
+
|
95
|
+
exit
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
def print
|
102
|
+
|
103
|
+
puts
|
104
|
+
puts "Usage".underline
|
105
|
+
puts
|
106
|
+
cmd = " $ ".bold + base_command
|
107
|
+
|
108
|
+
unless @commands.empty?
|
109
|
+
|
110
|
+
cmd += " " + "[command]".green.bold
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
unless @options.empty?
|
115
|
+
|
116
|
+
cmd += " [options]".blue.bold
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
puts cmd
|
121
|
+
|
122
|
+
unless @usage.nil?
|
123
|
+
|
124
|
+
puts
|
125
|
+
puts " " + @usage
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
if !@commands.empty?
|
131
|
+
|
132
|
+
puts
|
133
|
+
puts "Commands".underline
|
134
|
+
puts
|
135
|
+
|
136
|
+
@commands.each do |command|
|
137
|
+
|
138
|
+
puts " ".green + command.name.green.bold + whitespace(command.name) + command.description
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
143
|
+
|
144
|
+
if !@options.empty?
|
145
|
+
|
146
|
+
puts
|
147
|
+
puts "Options".underline
|
148
|
+
puts
|
149
|
+
|
150
|
+
@options.each do |option|
|
151
|
+
|
152
|
+
output = option.name + ", " + option.short_cut
|
153
|
+
puts " " + output.bold.blue + whitespace(output) + option.description
|
154
|
+
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
puts
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
private
|
163
|
+
|
164
|
+
def whitespace(message)
|
165
|
+
|
166
|
+
count = @@indent - message.length
|
167
|
+
i = 0
|
168
|
+
result = ""
|
169
|
+
|
170
|
+
until count == i do
|
171
|
+
|
172
|
+
result << " "
|
173
|
+
i += 1
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
return result
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Phoenx
|
2
|
+
|
3
|
+
module Cli
|
4
|
+
|
5
|
+
class Option
|
6
|
+
|
7
|
+
attr_accessor :name
|
8
|
+
attr_accessor :short_cut
|
9
|
+
attr_accessor :description
|
10
|
+
attr_accessor :has_argument
|
11
|
+
|
12
|
+
@block
|
13
|
+
|
14
|
+
def initialize(name, short_cut, description, has_argument, &block)
|
15
|
+
|
16
|
+
@name = name
|
17
|
+
@short_cut = short_cut
|
18
|
+
@description = description
|
19
|
+
@has_argument = has_argument
|
20
|
+
@block = block
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def execute
|
25
|
+
|
26
|
+
@block.call
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Phoenx
|
2
|
+
|
3
|
+
WORKSPACE_EXTENSION = "pxworkspace"
|
4
|
+
PROJECT_EXTENSION = "pxproject"
|
5
|
+
XCODE_PROJECT_EXTENSION = "xcodeproj"
|
6
|
+
XCODE_WORKSPACE_EXTENSION = "xcworkspace"
|
7
|
+
|
8
|
+
SOURCE_EXTENSIONS = [".swift", ".m", ".c", ".xcdatamodeld"]
|
9
|
+
RESOURCES_ROOT = "Resources"
|
10
|
+
TESTS_ROOT = "Tests"
|
11
|
+
SOURCE_ROOT = "Source"
|
12
|
+
FRAMEWORKS_ROOT = "Frameworks"
|
13
|
+
CONFIGURATION_ROOT = "Configuration"
|
14
|
+
XCTEST_EXTENSION = "xctest"
|
15
|
+
|
16
|
+
ATTRIBUTES_CODE_SIGN_ON_COPY = {"ATTRIBUTES" => ["CodeSignOnCopy"]}
|
17
|
+
ATTRIBUTES_PUBLIC_HEADERS = {"ATTRIBUTES" => [:Public]}
|
18
|
+
ATTRIBUTES_PRIVATE_HEADERS = {"ATTRIBUTES" => [:Private]}
|
19
|
+
ATTRIBUTES_PROJECT_HEADERS = {"ATTRIBUTES" => [:Project]}
|
20
|
+
|
21
|
+
end
|