shellboxCLI 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/setup +8 -0
- data/bin/shellbox +6 -0
- data/lib/ShellboxCLI.rb +28 -0
- data/lib/ios/iosOption.rb +31 -0
- data/lib/ios/module/setup/ConfigureSwift.rb +33 -0
- data/lib/ios/module/setup/MessageBank.rb +52 -0
- data/lib/ios/module/setup/ProjectManipulator.rb +269 -0
- data/lib/ios/module/setup/Template_Configurator.rb +128 -0
- data/lib/ios/module/templates/Example/Example/Example/AppDelegate.swift +24 -0
- data/lib/ios/module/templates/Example/Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- data/lib/ios/module/templates/Example/Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- data/lib/ios/module/templates/Example/Example/Example/Assets.xcassets/Contents.json +6 -0
- data/lib/ios/module/templates/Example/Example/Example/Base.lproj/LaunchScreen.storyboard +25 -0
- data/lib/ios/module/templates/Example/Example/Example/Info.plist +23 -0
- data/lib/ios/module/templates/Example/Example/Example/SceneDelegate.swift +19 -0
- data/lib/ios/module/templates/Example/Example/Example/ViewController.swift +13 -0
- data/lib/ios/module/templates/Example/Example/Example.xcodeproj/project.pbxproj +355 -0
- data/lib/ios/module/templates/Example/Example/Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/lib/ios/module/templates/Example/Example/Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/lib/ios/module/templates/Example/Example/Podfile +22 -0
- data/lib/ios/module/templates/Feature/Header_template +9 -0
- data/lib/ios/module/templates/Feature/Info_template +22 -0
- data/lib/ios/module/templates/Feature/bundle_template +20 -0
- data/lib/ios/module/templates/NAME.podspec +31 -0
- data/lib/ios/module/templates/NAMEInterface.podspec +24 -0
- data/lib/ios/module/templates/swiftgen.yml +13 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 06c2e6b62465a31efb5066be4ad0bdb90f7d241e86463976a87131260992ed2e
|
4
|
+
data.tar.gz: b004616a6653ae856a346982f16224db23d8e37e415a8fb644054b0d43cd1c6a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b2a2f75e8f8fa1bfba50ff14e2542ef13087149e0f36b5a105c7721e1125ebd7798b7d201a63c1fc4ee4b49e5dc1845c828098266006c2b2359efc990ecabe86
|
7
|
+
data.tar.gz: 6ab250562132a4cbb75d57938495b5585ce3af8c0065eaec99f0f4b8bd564cdabbcad7dbf2506f7ea3d7fbe70ae9504f3d082e2eb9d176dad3950115dd034ff1
|
data/bin/setup
ADDED
data/bin/shellbox
ADDED
data/lib/ShellboxCLI.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'ios/iosOption'
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module App
|
6
|
+
|
7
|
+
GEM_NAME = "shellboxCLI".freeze
|
8
|
+
|
9
|
+
# @return [String] The path to the local gem directory
|
10
|
+
def self.gem_path
|
11
|
+
if Gem::Specification.find_all_by_name(GEM_NAME).empty?
|
12
|
+
raise "Couldn't find gem directory for '#{GEM_NAME}'"
|
13
|
+
end
|
14
|
+
return Gem::Specification.find_by_name(GEM_NAME).gem_dir
|
15
|
+
end
|
16
|
+
|
17
|
+
class ShellboxCLI < Thor
|
18
|
+
|
19
|
+
def self.exit_on_failure?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "ios", "scripts for ios platform"
|
24
|
+
subcommand "ios", IOS_CLI
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'ios/module/setup/Template_Configurator'
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module App
|
6
|
+
|
7
|
+
class IOS_CLI < Thor
|
8
|
+
desc "module", "Create a new module to iOS platform"
|
9
|
+
def module
|
10
|
+
IOS::TemplateConfigurator.new.run
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "install", "Install scripts and templates in project"
|
14
|
+
def install
|
15
|
+
puts "Verificando se existe Homebrew instalado"
|
16
|
+
brewExists = system('which -s brew')
|
17
|
+
if brewExists
|
18
|
+
puts "Atualizando Homebrew"
|
19
|
+
system('brew update')
|
20
|
+
else
|
21
|
+
puts "Instalando Homebrew"
|
22
|
+
system("ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'")
|
23
|
+
end
|
24
|
+
puts "Instalando swiftgen"
|
25
|
+
system("brew install swiftgen")
|
26
|
+
|
27
|
+
puts "✅ Instalado com sucesso"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ios/module/setup/ProjectManipulator'
|
2
|
+
|
3
|
+
module IOS
|
4
|
+
class ConfigureSwift
|
5
|
+
attr_reader :configurator, :root_path
|
6
|
+
|
7
|
+
def self.perform(options)
|
8
|
+
new(options).perform
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@configurator = options.fetch(:configurator)
|
13
|
+
end
|
14
|
+
|
15
|
+
def perform
|
16
|
+
hasInterface = configurator.ask_with_answers("Criar módulo de interfaces", ["Yes", "No"]).to_sym
|
17
|
+
hasTest = configurator.ask_with_answers("Criar pasta de teste", ["Yes", "No"]).to_sym
|
18
|
+
moduleType = configurator.ask_with_answers("Qual o tipo do módulo", ["Core", "Feature"]).to_sym
|
19
|
+
keepDemo = configurator.ask_with_answers("Criar projeto exemplo", ["No", "Yes"]).to_sym
|
20
|
+
hasSwiftgen = configurator.ask_with_answers("Criar Swiftgen", ["Yes", "No"]).to_sym
|
21
|
+
|
22
|
+
ProjectManipulator.new({
|
23
|
+
:configurator => @configurator,
|
24
|
+
:keep_demo => keepDemo,
|
25
|
+
:module_type => moduleType,
|
26
|
+
:has_swiftgen => hasSwiftgen,
|
27
|
+
:has_interface => hasInterface,
|
28
|
+
:has_test => hasTest
|
29
|
+
}).run
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module IOS
|
2
|
+
class MessageBank
|
3
|
+
attr_reader :configurator
|
4
|
+
|
5
|
+
def initialize(config)
|
6
|
+
@configurator = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_prompt
|
10
|
+
print " > ".green
|
11
|
+
end
|
12
|
+
|
13
|
+
def yellow_bang
|
14
|
+
"! ".yellow
|
15
|
+
end
|
16
|
+
|
17
|
+
def green_bang
|
18
|
+
"! ".green
|
19
|
+
end
|
20
|
+
|
21
|
+
def red_bang
|
22
|
+
"! ".red
|
23
|
+
end
|
24
|
+
|
25
|
+
def run_command command, output_command = nil
|
26
|
+
output_command ||= command
|
27
|
+
|
28
|
+
puts " " + output_command.magenta
|
29
|
+
system command
|
30
|
+
end
|
31
|
+
|
32
|
+
def done_message
|
33
|
+
puts ""
|
34
|
+
puts "Projeto criado com " + "Sucesso".green
|
35
|
+
puts Dir.pwd
|
36
|
+
if Dir.exists? "Example"
|
37
|
+
Dir.chdir "Example" do
|
38
|
+
puts "Caso deseja abrir o projeto de Exemplo, digite " + "[" + "Y".underlined.yellow + "es]".yellow
|
39
|
+
|
40
|
+
answer = STDIN.gets.downcase.chomp
|
41
|
+
answer = "yes" if answer == "y"
|
42
|
+
|
43
|
+
if answer.to_sym == :yes
|
44
|
+
run_command "open 'Example.xcworkspace'"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,269 @@
|
|
1
|
+
require 'xcodeproj'
|
2
|
+
|
3
|
+
module IOS
|
4
|
+
class ProjectManipulator
|
5
|
+
attr_reader :configurator, :keep_demo, :module_type, :module_root_path, :module_path, :has_swiftgen, :has_interface, :has_test
|
6
|
+
|
7
|
+
def self.perform(options)
|
8
|
+
new(options).perform
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
@configurator = options.fetch(:configurator)
|
13
|
+
@keep_demo = options.fetch(:keep_demo)
|
14
|
+
@module_type = options.fetch(:module_type)
|
15
|
+
@has_swiftgen = options.fetch(:has_swiftgen)
|
16
|
+
@has_interface = options.fetch(:has_interface)
|
17
|
+
@has_test = options.fetch(:has_test)
|
18
|
+
@module_root_path = ""
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
createModulePath
|
23
|
+
|
24
|
+
createModuleImplFolder
|
25
|
+
createModuleDummies
|
26
|
+
createPodspec
|
27
|
+
|
28
|
+
if @has_interface == :yes
|
29
|
+
createModuleInterfaceFolder
|
30
|
+
createModuleInterfaceDummies
|
31
|
+
createPodspecInterface
|
32
|
+
end
|
33
|
+
|
34
|
+
if @has_test == :yes
|
35
|
+
createTests
|
36
|
+
end
|
37
|
+
|
38
|
+
createSwiftgen if @has_swiftgen == :yes
|
39
|
+
createExampleProject if @keep_demo == :yes
|
40
|
+
end
|
41
|
+
|
42
|
+
def project_folder
|
43
|
+
$basePath = `git rev-parse --show-toplevel`.chomp
|
44
|
+
raise "Para rodar a rotina, você deve estar na raiz do projeto" if $basePath == "."
|
45
|
+
return $basePath
|
46
|
+
end
|
47
|
+
|
48
|
+
def module_folder
|
49
|
+
return "FeatureModules" if @module_type == :feature
|
50
|
+
"CoreModules"
|
51
|
+
end
|
52
|
+
|
53
|
+
def createModulePath
|
54
|
+
@configurator.printMessage("Criando estrutura do módulo")
|
55
|
+
@module_root_path = File.join(project_folder, [module_folder, @configurator.pod_name])
|
56
|
+
@module_path = File.join(@module_root_path, @configurator.pod_name)
|
57
|
+
|
58
|
+
# Create a new folder with pod name
|
59
|
+
FileUtils.mkdir_p @module_path
|
60
|
+
|
61
|
+
# Create a new folder with pod name interface
|
62
|
+
if @has_interface == :yes
|
63
|
+
FileUtils.mkdir_p @module_path + "Interface"
|
64
|
+
end
|
65
|
+
|
66
|
+
# Create a new folder with pod name test
|
67
|
+
if @has_test == :yes
|
68
|
+
FileUtils.mkdir_p @module_path + "Tests"
|
69
|
+
end
|
70
|
+
|
71
|
+
Dir.chdir @module_root_path
|
72
|
+
@configurator.printDone
|
73
|
+
end
|
74
|
+
|
75
|
+
def createExampleProject
|
76
|
+
@configurator.printMessage("Criando projeto Exemplo")
|
77
|
+
projectFileName = File.join(@module_root_path, "Example")
|
78
|
+
FileUtils.cp_r(File.join(@configurator.template_path, "/Example/Example"), @module_root_path)
|
79
|
+
|
80
|
+
podDevInjection = "pod '${POD_NAME}', path: '../'"
|
81
|
+
|
82
|
+
if @has_test == :yes
|
83
|
+
podDevInjection = "pod '${POD_NAME}', path: '../', :testspecs => ['Tests']"
|
84
|
+
end
|
85
|
+
|
86
|
+
if @has_interface == :yes
|
87
|
+
podDevInjection += "\n pod '${POD_NAME}Interface', path: '../'"
|
88
|
+
end
|
89
|
+
|
90
|
+
text = File.read projectFileName + "/Podfile"
|
91
|
+
text.gsub!("${DEV_PODS}", podDevInjection)
|
92
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
93
|
+
File.open(projectFileName + "/Podfile", "w") { |file| file.puts text}
|
94
|
+
@configurator.printDone
|
95
|
+
end
|
96
|
+
|
97
|
+
def createModuleImplFolder
|
98
|
+
@configurator.printMessage("Gerando pastas base")
|
99
|
+
FileUtils.mkdir_p File.join(@module_path, "Sources")
|
100
|
+
if @module_type == :feature
|
101
|
+
FileUtils.mkdir_p File.join(@module_path, "Sources", "Features")
|
102
|
+
end
|
103
|
+
|
104
|
+
if @has_swiftgen == :yes
|
105
|
+
FileUtils.mkdir_p File.join(@module_path, "Sources", "ModuleConfiguration")
|
106
|
+
end
|
107
|
+
|
108
|
+
FileUtils.mkdir_p File.join(@module_path, "Resources")
|
109
|
+
@configurator.printDone
|
110
|
+
end
|
111
|
+
|
112
|
+
def createModuleInterfaceFolder
|
113
|
+
@configurator.printMessage("Gerando pastas de interface")
|
114
|
+
FileUtils.mkdir_p File.join(@module_path + "Interface" , "Sources")
|
115
|
+
FileUtils.mkdir_p File.join(@module_path + "Interface", "Resources")
|
116
|
+
@configurator.printDone
|
117
|
+
end
|
118
|
+
|
119
|
+
def createModuleDummies
|
120
|
+
@configurator.printMessage("Gerando arquivos de exemplo")
|
121
|
+
|
122
|
+
if @module_type == :feature
|
123
|
+
FileUtils.touch File.join(@module_path, "Sources", "Features", "Dummy.swift")
|
124
|
+
else
|
125
|
+
FileUtils.touch File.join(@module_path, "Sources", "DummySource.swift")
|
126
|
+
end
|
127
|
+
|
128
|
+
# Header.h
|
129
|
+
headerFilename = File.join(@module_path, "Resources", @configurator.pod_name + ".h")
|
130
|
+
FileUtils.cp(
|
131
|
+
File.join(@configurator.template_path, "Feature", "Header_template"),
|
132
|
+
headerFilename
|
133
|
+
)
|
134
|
+
text = File.read(headerFilename)
|
135
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
136
|
+
File.open(headerFilename, "w") { |file| file.puts text}
|
137
|
+
|
138
|
+
# Info.plist
|
139
|
+
FileUtils.cp(
|
140
|
+
File.join(@configurator.template_path, "Feature", "Info_template"),
|
141
|
+
File.join(@module_path, "Resources", "Info.plist")
|
142
|
+
)
|
143
|
+
|
144
|
+
if @has_swiftgen == :yes
|
145
|
+
# Bundle
|
146
|
+
bundleFilename = File.join(@module_path, "Sources", "ModuleConfiguration", "Bundle.swift")
|
147
|
+
FileUtils.cp(
|
148
|
+
File.join(@configurator.template_path, "Feature", "bundle_template"),
|
149
|
+
bundleFilename
|
150
|
+
)
|
151
|
+
|
152
|
+
text = File.read(bundleFilename)
|
153
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
154
|
+
File.open(bundleFilename, "w") { |file| file.puts text}
|
155
|
+
|
156
|
+
# Strings
|
157
|
+
FileUtils.touch File.join(@module_path, "Resources", "Localizable.strings")
|
158
|
+
File.open(File.join(@module_path, "Resources", "Localizable.strings"), "w") { |file|
|
159
|
+
file.puts "\"example.title.text\" = \"EXAMPLE\";"
|
160
|
+
}
|
161
|
+
|
162
|
+
# Assets
|
163
|
+
FileUtils.mkdir_p(File.join(@module_path, "Resources", "Assets.xcassets"))
|
164
|
+
end
|
165
|
+
|
166
|
+
@configurator.printDone
|
167
|
+
end
|
168
|
+
|
169
|
+
def createModuleInterfaceDummies
|
170
|
+
@configurator.printMessage("Gerando arquivos de exemplo na Interface")
|
171
|
+
FileUtils.touch File.join(@module_path + "Interface", "Sources", "DummyInterface.swift")
|
172
|
+
|
173
|
+
# Info.plist
|
174
|
+
FileUtils.cp(
|
175
|
+
File.join(@configurator.template_path, "Feature", "Info_template"),
|
176
|
+
File.join(@module_path + "Interface", "Resources", "Info.plist")
|
177
|
+
)
|
178
|
+
|
179
|
+
# Header.h
|
180
|
+
headerFilename = File.join(@module_path + "Interface", "Resources", @configurator.pod_name + ".h")
|
181
|
+
FileUtils.cp(
|
182
|
+
File.join(@configurator.template_path, "Feature", "Header_template"),
|
183
|
+
headerFilename
|
184
|
+
)
|
185
|
+
text = File.read(headerFilename)
|
186
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
187
|
+
File.open(headerFilename, "w") { |file| file.puts text}
|
188
|
+
|
189
|
+
@configurator.printDone
|
190
|
+
end
|
191
|
+
|
192
|
+
def createSwiftgen
|
193
|
+
@configurator.printMessage("Criando arquivo swiftgen")
|
194
|
+
fileName = File.join(@module_root_path, "swiftgen.yml")
|
195
|
+
FileUtils.cp(
|
196
|
+
File.join(@configurator.template_path, "swiftgen.yml"),
|
197
|
+
fileName
|
198
|
+
)
|
199
|
+
|
200
|
+
text = File.read(fileName)
|
201
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
202
|
+
|
203
|
+
File.open(fileName, "w") { |file| file.puts text}
|
204
|
+
@configurator.printDone
|
205
|
+
end
|
206
|
+
|
207
|
+
def createPodspec
|
208
|
+
@configurator.printMessage("Configurando arquivo Podspec")
|
209
|
+
podspecFilename = "#{module_root_path}/#{@configurator.pod_name}.podspec"
|
210
|
+
FileUtils.cp(File.join(@configurator.template_path, "NAME.podspec"), podspecFilename)
|
211
|
+
text = File.read podspecFilename
|
212
|
+
|
213
|
+
podTests = ""
|
214
|
+
if @has_test == :yes
|
215
|
+
podTests = "# TESTS"
|
216
|
+
podTests += "\n s.test_spec 'Tests' do |test_spec|"
|
217
|
+
podTests += "\n test_spec.source_files = '${POD_NAME}Tests/**/*'"
|
218
|
+
podTests += "\n test_spec.exclude_files = '${POD_NAME}Tests/Resources/*.plist'"
|
219
|
+
podTests += "\n end"
|
220
|
+
end
|
221
|
+
|
222
|
+
podInternal = ""
|
223
|
+
if @has_interface == :yes
|
224
|
+
podInternal = "s.dependency '${POD_NAME}Interface'"
|
225
|
+
end
|
226
|
+
|
227
|
+
text.gsub!("${FEATURE_INTERNAL}", podInternal)
|
228
|
+
text.gsub!("${FEATURE_TEST}", podTests)
|
229
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
230
|
+
text.gsub!("${USER_NAME}", @configurator.user_name)
|
231
|
+
text.gsub!("${USER_EMAIL}", @configurator.user_email)
|
232
|
+
File.open(podspecFilename, "w") { |file| file.puts text}
|
233
|
+
@configurator.printDone
|
234
|
+
end
|
235
|
+
|
236
|
+
def createPodspecInterface
|
237
|
+
@configurator.printMessage("Configurando arquivo Podspec Interface")
|
238
|
+
podspecFilename = "#{module_root_path}/#{@configurator.pod_name}Interface.podspec"
|
239
|
+
FileUtils.cp(File.join(@configurator.template_path, "NAMEInterface.podspec"), podspecFilename)
|
240
|
+
text = File.read podspecFilename
|
241
|
+
text.gsub!("${POD_NAME}", @configurator.pod_name)
|
242
|
+
text.gsub!("${USER_NAME}", @configurator.user_name)
|
243
|
+
text.gsub!("${USER_EMAIL}", @configurator.user_email)
|
244
|
+
File.open(podspecFilename, "w") { |file| file.puts text}
|
245
|
+
@configurator.printDone
|
246
|
+
end
|
247
|
+
|
248
|
+
def createTests
|
249
|
+
@configurator.printMessage("Gerando pastas de testes")
|
250
|
+
# Folders
|
251
|
+
FileUtils.mkdir_p File.join(@module_path + "Tests" , "Resources")
|
252
|
+
FileUtils.mkdir_p File.join(@module_path + "Tests" , "Sources")
|
253
|
+
FileUtils.mkdir_p File.join(@module_path + "Tests" , "Tests")
|
254
|
+
|
255
|
+
# Dummies
|
256
|
+
FileUtils.touch File.join(@module_path + "Tests", "Sources", "DummyModel.swift")
|
257
|
+
FileUtils.touch File.join(@module_path + "Tests", "Tests", "DummyTest.swift")
|
258
|
+
|
259
|
+
# Info.plist
|
260
|
+
FileUtils.cp(
|
261
|
+
File.join(@configurator.template_path, "Feature", "Info_template"),
|
262
|
+
File.join(@module_path + "Tests", "Resources", "Info.plist")
|
263
|
+
)
|
264
|
+
|
265
|
+
@configurator.printDone
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'ios/module/setup/MessageBank'
|
2
|
+
require 'ios/module/setup/ConfigureSwift'
|
3
|
+
|
4
|
+
require 'colored2'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module IOS
|
8
|
+
class TemplateConfigurator
|
9
|
+
|
10
|
+
attr_reader :pod_name, :pods_for_podfile, :prefixes, :project_filename, :template_path
|
11
|
+
|
12
|
+
def initialize()
|
13
|
+
@pod_name = ""
|
14
|
+
@project_filename = "Shell.xcworkspace"
|
15
|
+
@pods_for_podfile = []
|
16
|
+
@prefixes = []
|
17
|
+
dir = App.gem_path
|
18
|
+
@template_path = File.join(dir, "lib/ios/module/templates")
|
19
|
+
@message_bank = MessageBank.new(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def printMessage(message)
|
23
|
+
puts ""
|
24
|
+
puts "==> " + message
|
25
|
+
end
|
26
|
+
|
27
|
+
def printDone
|
28
|
+
puts "\n✅ " + "DONE".green
|
29
|
+
end
|
30
|
+
|
31
|
+
def ask(question)
|
32
|
+
answer = ""
|
33
|
+
loop do
|
34
|
+
puts "\n#{question}"
|
35
|
+
|
36
|
+
@message_bank.show_prompt
|
37
|
+
answer = STDIN.gets.chomp
|
38
|
+
|
39
|
+
break if answer.length > 0
|
40
|
+
|
41
|
+
print "\nInforme uma resposta"
|
42
|
+
end
|
43
|
+
answer
|
44
|
+
end
|
45
|
+
|
46
|
+
def ask_with_answers(question, possible_answers)
|
47
|
+
print "\n#{question}? ["
|
48
|
+
|
49
|
+
print_info = Proc.new {
|
50
|
+
possible_answers_string = possible_answers.each_with_index do |answer, i|
|
51
|
+
_answer = (i == 0) ? answer.underlined : answer
|
52
|
+
print " " + _answer
|
53
|
+
print(" /") if i != possible_answers.length - 1
|
54
|
+
end
|
55
|
+
print " ]\n"
|
56
|
+
}
|
57
|
+
print_info.call
|
58
|
+
|
59
|
+
answer = ""
|
60
|
+
|
61
|
+
loop do
|
62
|
+
@message_bank.show_prompt
|
63
|
+
answer = STDIN.gets.downcase.chomp
|
64
|
+
|
65
|
+
answer = "yes" if answer == "y"
|
66
|
+
answer = "no" if answer == "n"
|
67
|
+
|
68
|
+
# default to first answer
|
69
|
+
if answer == ""
|
70
|
+
answer = possible_answers[0].downcase
|
71
|
+
print answer.yellow
|
72
|
+
end
|
73
|
+
|
74
|
+
break if possible_answers.map { |a| a.downcase }.include? answer
|
75
|
+
|
76
|
+
print "\nRespostas possíveis ["
|
77
|
+
print_info.call
|
78
|
+
end
|
79
|
+
|
80
|
+
answer
|
81
|
+
end
|
82
|
+
|
83
|
+
def run
|
84
|
+
raise "Para rodar a rotina, você deve estar na raiz do projeto" if not File.exists?(@project_filename)
|
85
|
+
|
86
|
+
@pod_name = ask("Qual o nome do módulo?")
|
87
|
+
ConfigureSwift.perform(configurator: self)
|
88
|
+
|
89
|
+
run_swiftgen
|
90
|
+
run_pod_install
|
91
|
+
|
92
|
+
@message_bank.done_message
|
93
|
+
end
|
94
|
+
|
95
|
+
def user_name
|
96
|
+
(ENV['GIT_COMMITTER_NAME'] || github_user_name || `git config user.name` || `<GITHUB_USERNAME>`).strip
|
97
|
+
end
|
98
|
+
|
99
|
+
def user_email
|
100
|
+
(ENV['GIT_COMMITTER_EMAIL'] || `git config user.email`).strip
|
101
|
+
end
|
102
|
+
|
103
|
+
def github_user_name
|
104
|
+
github_user_name = `security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'`.strip
|
105
|
+
is_valid = github_user_name.empty? or github_user_name.include? '@'
|
106
|
+
return is_valid ? nil : github_user_name
|
107
|
+
end
|
108
|
+
|
109
|
+
def run_pod_install
|
110
|
+
if Dir.exists? "Example"
|
111
|
+
Dir.chdir "Example" do
|
112
|
+
printMessage("Rodando " + "pod install".magenta + " no projeto Exemplo")
|
113
|
+
@message_bank.run_command "pod install"
|
114
|
+
printDone
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def run_swiftgen
|
120
|
+
if File.exists? "swiftgen.yml"
|
121
|
+
printMessage("Rodando " + "swiftgen".magenta + " no módulo")
|
122
|
+
@message_bank.run_command "swiftgen"
|
123
|
+
printDone
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import UIKit
|
2
|
+
|
3
|
+
@main
|
4
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
5
|
+
|
6
|
+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
7
|
+
return true
|
8
|
+
}
|
9
|
+
|
10
|
+
// MARK: UISceneSession Lifecycle
|
11
|
+
|
12
|
+
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
13
|
+
return UISceneConfiguration(
|
14
|
+
name: "Default Configuration",
|
15
|
+
sessionRole: connectingSceneSession.role
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
}
|
24
|
+
|