shellboxCLI 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3dc4494e0f8d10301b56a34252cc329103e6a114699413f33c3f5c5e4c4b245
4
- data.tar.gz: 65a04aa1f719fc45fe67fb6b2a4743d6ffeefde86c62f69c0ad29c27481f1af8
3
+ metadata.gz: 9c03368f91951882de24739edc34a93de48c825b91023e5e4b759e6bc9577950
4
+ data.tar.gz: 48addff9e4f682d3552ea5d299ce72006e403e50902943b6fbbe304fc48e93f7
5
5
  SHA512:
6
- metadata.gz: 428a9b261a34ecf6b7e77088df19bb642608f298f47bbca0161e49ca6d5b56544885db572c859d369152b23a49758a691acb7885a9e375ecb6b7287afa5986fe
7
- data.tar.gz: f3e0dc0602c32d9a710cb9f05e631e37a5385f29109beb41f9ce3d31816bd95d3566bcdd690b3246539bbe451a7c41312501fc5eaabb9c84e0ea9f3723925525
6
+ metadata.gz: 64384e81cfe33c724d1336c6d4cc75cd7f1e905aad276a8886288256773c987791bda0c07a8dd3f7e4e442771d0eeae83cf04911685a6842a7a51a08b34d5017
7
+ data.tar.gz: d635795f34143ae2e6c5ccbf431159f49526a10c8837836a7e97b87722a8bd7c057517986495f232846aea9af40332a0bfa325405a67e7af6b581156b29b1441
@@ -13,11 +13,24 @@ module IOS
13
13
  end
14
14
 
15
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
16
  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
17
+
18
+
19
+ if moduleType == :feature
20
+ hasInterface = "yes".to_sym
21
+ hasSwiftgen = "yes".to_sym
22
+ hasTest = "yes".to_sym
23
+ else
24
+ hasInterface = configurator.ask_with_answers("Criar módulo de interfaces", ["Yes", "No"]).to_sym
25
+ hasTest = configurator.ask_with_answers("Criar pasta de teste", ["Yes", "No"]).to_sym
26
+ hasSwiftgen = configurator.ask_with_answers("Criar Swiftgen", ["Yes", "No"]).to_sym
27
+ mockNetwork = "no".to_sym
28
+ end
29
+
30
+ keepDemo = configurator.ask_with_answers("Criar projeto exemplo", ["Yes", "No"]).to_sym
31
+ if keepDemo == :yes && moduleType == :feature
32
+ mockNetwork = configurator.ask_with_answers("Criar mocks de network para o projeto exemplo", ["Yes", "No"]).to_sym
33
+ end
21
34
 
22
35
  ProjectManipulator.new({
23
36
  :configurator => @configurator,
@@ -25,9 +38,10 @@ module IOS
25
38
  :module_type => moduleType,
26
39
  :has_swiftgen => hasSwiftgen,
27
40
  :has_interface => hasInterface,
28
- :has_test => hasTest
41
+ :has_test => hasTest,
42
+ :mock_network => mockNetwork
29
43
  }).run
30
44
  end
31
45
 
32
46
  end
33
- end
47
+ end
@@ -1,289 +1,306 @@
1
1
  require 'xcodeproj'
2
2
 
3
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
- if @module_type == :feature
91
- podDevInjection += "\n\n pod 'SBFoundation', path: '../../../CoreModules/SBFoundation'"
92
- podDevInjection += "\n pod 'SBUIKit', path: '../../../CoreModules/SBUIKit'"
93
- podDevInjection += "\n pod 'SBRouterServiceInterface', path: '../../../CoreModules/SBRouterService'"
94
- podDevInjection += "\n pod 'SBDependencyInterface', path: '../../../CoreModules/SBDependency'"
95
- end
96
-
97
- text = File.read projectFileName + "/Podfile"
98
- text.gsub!("${DEV_PODS}", podDevInjection)
99
- text.gsub!("${POD_NAME}", @configurator.pod_name)
100
- File.open(projectFileName + "/Podfile", "w") { |file| file.puts text}
101
- @configurator.printDone
102
- end
103
-
104
- def createModuleImplFolder
105
- @configurator.printMessage("Gerando pastas base")
106
- FileUtils.mkdir_p File.join(@module_path, "Sources")
107
- if @module_type == :feature
108
- FileUtils.mkdir_p File.join(@module_path, "Sources", "Features")
109
- end
110
-
111
- if @has_swiftgen == :yes
112
- FileUtils.mkdir_p File.join(@module_path, "Sources", "ModuleConfiguration")
113
- end
114
-
115
- FileUtils.mkdir_p File.join(@module_path, "Resources")
116
- @configurator.printDone
117
- end
118
-
119
- def createModuleInterfaceFolder
120
- @configurator.printMessage("Gerando pastas de interface")
121
- FileUtils.mkdir_p File.join(@module_path + "Interface" , "Sources")
122
- FileUtils.mkdir_p File.join(@module_path + "Interface", "Resources")
123
- @configurator.printDone
124
- end
125
-
126
- def createModuleDummies
127
- @configurator.printMessage("Gerando arquivos de exemplo")
128
-
129
- if @module_type == :feature
130
- FileUtils.touch File.join(@module_path, "Sources", "Features", "Dummy.swift")
131
- else
132
- FileUtils.touch File.join(@module_path, "Sources", "DummySource.swift")
133
- end
134
-
135
- # Header.h
136
- headerFilename = File.join(@module_path, "Resources", @configurator.pod_name + ".h")
137
- FileUtils.cp(
138
- File.join(@configurator.template_path, "Feature", "Header_template"),
139
- headerFilename
140
- )
141
- text = File.read(headerFilename)
142
- text.gsub!("${POD_NAME}", @configurator.pod_name)
143
- File.open(headerFilename, "w") { |file| file.puts text}
144
-
145
- # Info.plist
146
- FileUtils.cp(
147
- File.join(@configurator.template_path, "Feature", "Info_template"),
148
- File.join(@module_path, "Resources", "Info.plist")
149
- )
150
-
151
- if @has_swiftgen == :yes
152
- # Bundle
153
- bundleFilename = File.join(@module_path, "Sources", "ModuleConfiguration", "Bundle.swift")
154
- FileUtils.cp(
155
- File.join(@configurator.template_path, "Feature", "bundle_template"),
156
- bundleFilename
157
- )
158
-
159
- text = File.read(bundleFilename)
160
- text.gsub!("${POD_NAME}", @configurator.pod_name)
161
- File.open(bundleFilename, "w") { |file| file.puts text}
162
-
163
- # Strings
164
- FileUtils.touch File.join(@module_path, "Resources", "Localizable.strings")
165
- File.open(File.join(@module_path, "Resources", "Localizable.strings"), "w") { |file|
166
- file.puts "\"example.title.text\" = \"EXAMPLE\";"
167
- }
168
-
169
- # Assets
170
- FileUtils.mkdir_p(File.join(@module_path, "Resources", "Assets.xcassets"))
171
- end
172
-
173
- @configurator.printDone
174
- end
175
-
176
- def createModuleInterfaceDummies
177
- @configurator.printMessage("Gerando arquivos de exemplo na Interface")
178
- FileUtils.touch File.join(@module_path + "Interface", "Sources", "DummyInterface.swift")
179
-
180
- # Info.plist
181
- FileUtils.cp(
182
- File.join(@configurator.template_path, "Feature", "Info_template"),
183
- File.join(@module_path + "Interface", "Resources", "Info.plist")
184
- )
185
-
186
- # Header.h
187
- headerFilename = File.join(@module_path + "Interface", "Resources", @configurator.pod_name + ".h")
188
- FileUtils.cp(
189
- File.join(@configurator.template_path, "Feature", "Header_template"),
190
- headerFilename
191
- )
192
- text = File.read(headerFilename)
193
- text.gsub!("${POD_NAME}", @configurator.pod_name)
194
- File.open(headerFilename, "w") { |file| file.puts text}
195
-
196
- @configurator.printDone
197
- end
198
-
199
- def createSwiftgen
200
- @configurator.printMessage("Criando arquivo swiftgen")
201
- fileName = File.join(@module_root_path, "swiftgen.yml")
202
- FileUtils.cp(
203
- File.join(@configurator.template_path, "swiftgen.yml"),
204
- fileName
205
- )
206
-
207
- text = File.read(fileName)
208
- text.gsub!("${POD_NAME}", @configurator.pod_name)
209
-
210
- File.open(fileName, "w") { |file| file.puts text}
211
- @configurator.printDone
212
- end
213
-
214
- def createPodspec
215
- @configurator.printMessage("Configurando arquivo Podspec")
216
- podspecFilename = "#{module_root_path}/#{@configurator.pod_name}.podspec"
217
- FileUtils.cp(File.join(@configurator.template_path, "NAME.podspec"), podspecFilename)
218
- text = File.read podspecFilename
219
-
220
- podTests = ""
221
- if @has_test == :yes
222
- podTests = "# TESTS"
223
- podTests += "\n s.test_spec 'Tests' do |test_spec|"
224
- podTests += "\n test_spec.source_files = '${POD_NAME}Tests/**/*'"
225
- podTests += "\n test_spec.exclude_files = '${POD_NAME}Tests/Resources/*.plist'"
226
- podTests += "\n end"
227
- end
228
-
229
- podInternal = "s.dependency 'SBFoundation'"
230
-
231
- if @module_type == :feature
232
- podInternal += "\n s.dependency 'SBUIKit'"
233
- podInternal += "\n s.dependency 'SBDependencyInterface'"
234
- end
235
-
236
- if @has_interface == :yes
237
- podInternal += "\n s.dependency '${POD_NAME}Interface'"
238
- end
239
-
240
- text.gsub!("${FEATURE_INTERNAL}", podInternal)
241
- text.gsub!("${FEATURE_TEST}", podTests)
242
- text.gsub!("${POD_NAME}", @configurator.pod_name)
243
- text.gsub!("${USER_NAME}", @configurator.user_name)
244
- text.gsub!("${USER_EMAIL}", @configurator.user_email)
245
- File.open(podspecFilename, "w") { |file| file.puts text}
246
- @configurator.printDone
247
- end
248
-
249
- def createPodspecInterface
250
- @configurator.printMessage("Configurando arquivo Podspec Interface")
251
- podspecFilename = "#{module_root_path}/#{@configurator.pod_name}Interface.podspec"
252
- FileUtils.cp(File.join(@configurator.template_path, "NAMEInterface.podspec"), podspecFilename)
253
- text = File.read podspecFilename
254
-
255
- podInternal = ""
256
- if @module_type == :feature
257
- podInternal += "\n s.dependency 'SBRouterServiceInterface'"
258
- end
259
-
260
- text.gsub!("${FEATURE_INTERNAL}", podInternal)
261
- text.gsub!("${POD_NAME}", @configurator.pod_name)
262
- text.gsub!("${USER_NAME}", @configurator.user_name)
263
- text.gsub!("${USER_EMAIL}", @configurator.user_email)
264
- File.open(podspecFilename, "w") { |file| file.puts text}
265
- @configurator.printDone
266
- end
267
-
268
- def createTests
269
- @configurator.printMessage("Gerando pastas de testes")
270
- # Folders
271
- FileUtils.mkdir_p File.join(@module_path + "Tests" , "Resources")
272
- FileUtils.mkdir_p File.join(@module_path + "Tests" , "Sources")
273
- FileUtils.mkdir_p File.join(@module_path + "Tests" , "Tests")
274
-
275
- # Dummies
276
- FileUtils.touch File.join(@module_path + "Tests", "Sources", "DummyModel.swift")
277
- FileUtils.touch File.join(@module_path + "Tests", "Tests", "DummyTest.swift")
278
-
279
- # Info.plist
280
- FileUtils.cp(
281
- File.join(@configurator.template_path, "Feature", "Info_template"),
282
- File.join(@module_path + "Tests", "Resources", "Info.plist")
283
- )
284
-
285
- @configurator.printDone
286
- end
287
-
288
- end
289
- end
4
+ class ProjectManipulator
5
+ attr_reader :configurator, :keep_demo, :module_type, :module_root_path, :module_path, :has_swiftgen, :has_interface, :has_test, :mock_network
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
+ @mock_network = options.fetch(:mock_network)
19
+ @module_root_path = ""
20
+ end
21
+
22
+ def run
23
+ createModulePath
24
+
25
+ createModuleImplFolder
26
+ createModuleDummies
27
+ createPodspec
28
+
29
+ if @has_interface == :yes
30
+ createModuleInterfaceFolder
31
+ createModuleInterfaceDummies
32
+ createPodspecInterface
33
+ end
34
+
35
+ if @has_test == :yes
36
+ createTests
37
+ end
38
+
39
+ createSwiftgen if @has_swiftgen == :yes
40
+ createExampleProject if @keep_demo == :yes
41
+ end
42
+
43
+ def project_folder
44
+ $basePath = `git rev-parse --show-toplevel`.chomp
45
+ raise "Para rodar a rotina, você deve estar na raiz do projeto" if $basePath == "."
46
+ return $basePath
47
+ end
48
+
49
+ def module_folder
50
+ return "FeatureModules" if @module_type == :feature
51
+ "CoreModules"
52
+ end
53
+
54
+ def createModulePath
55
+ @configurator.printMessage("Criando estrutura do módulo")
56
+ @module_root_path = File.join(project_folder, [module_folder, @configurator.pod_name])
57
+ @module_path = File.join(@module_root_path, @configurator.pod_name)
58
+
59
+ # Create a new folder with pod name
60
+ FileUtils.mkdir_p @module_path
61
+
62
+ # Create a new folder with pod name interface
63
+ if @has_interface == :yes
64
+ FileUtils.mkdir_p @module_path + "Interface"
65
+ end
66
+
67
+ # Create a new folder with pod name test
68
+ if @has_test == :yes
69
+ FileUtils.mkdir_p @module_path + "Tests"
70
+ end
71
+
72
+ Dir.chdir @module_root_path
73
+ @configurator.printDone
74
+ end
75
+
76
+ def createExampleProject
77
+ @configurator.printMessage("Criando projeto Exemplo")
78
+ projectFileName = File.join(@module_root_path, "Example")
79
+ FileUtils.cp_r(File.join(@configurator.template_path, "/Example/Example"), @module_root_path)
80
+
81
+ podDevInjection = "pod '${POD_NAME}', path: '../'"
82
+
83
+ if @has_test == :yes
84
+ podDevInjection = "pod '${POD_NAME}', path: '../', :testspecs => ['Tests']"
85
+ end
86
+
87
+ if @has_interface == :yes
88
+ podDevInjection += "\n pod '${POD_NAME}Interface', path: '../'"
89
+ end
90
+
91
+ podDevInjection += "\n"
92
+ podDevInjection += "\n pod 'SBFoundation', path: '../../../CoreModules/SBFoundation'"
93
+ if @module_type == :feature
94
+ podDevInjection += "\n pod 'SBUIKit', path: '../../../CoreModules/SBUIKit'"
95
+ podDevInjection += "\n pod 'SBRouterService', path: '../../../CoreModules/SBRouterService'"
96
+ podDevInjection += "\n pod 'SBRouterServiceInterface', path: '../../../CoreModules/SBRouterService'"
97
+ podDevInjection += "\n pod 'SBDependency', path: '../../../CoreModules/SBDependency'"
98
+ podDevInjection += "\n pod 'SBDependencyInterface', path: '../../../CoreModules/SBDependency'"
99
+ podDevInjection += "\n pod 'SBAnalyticsInterface', path: '../../../CoreModules/SBAnalytics'"
100
+ podDevInjection += "\n pod 'SBLoggerInterface', path: '../../../CoreModules/SBLogger'"
101
+ if @mock_network == :yes
102
+ podDevInjection += "\n pod 'SBUserSessionInterface', path: '../../../CoreModules/SBUserSession'"
103
+ podDevInjection += "\n pod 'SBNetwork', path: '../../../CoreModules/SBNetwork'"
104
+ podDevInjection += "\n pod 'Fetcher', path: '../../../CoreModules/Fetcher'"
105
+ podDevInjection += "\n pod 'Flow', path: '../../../CoreModules/Flow'"
106
+ podDevInjection += "\n pod 'SBSecurity', path: '../../../CoreModules/SBSecurity'"
107
+ podDevInjection += "\n pod 'SBSecurityInterface', path: '../../../CoreModules/SBSecurity'"
108
+ podDevInjection += "\n pod 'SBFeatureTogglesKitInterface', path: '../../../CoreModules/SBFeatureTogglesKit'"
109
+ end
110
+ podDevInjection += "\n pod 'SBAssets', :git => 'git@bitbucket.org:acelera/ios-ds-assets.git', :tag => '1.0.0'"
111
+
112
+ end
113
+
114
+ text = File.read projectFileName + "/Podfile"
115
+ text.gsub!("${DEV_PODS}", podDevInjection)
116
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
117
+ File.open(projectFileName + "/Podfile", "w") { |file| file.puts text}
118
+ @configurator.printDone
119
+ end
120
+
121
+ def createModuleImplFolder
122
+ @configurator.printMessage("Gerando pastas base")
123
+ FileUtils.mkdir_p File.join(@module_path, "Sources")
124
+ if @module_type == :feature
125
+ FileUtils.mkdir_p File.join(@module_path, "Sources", "Features")
126
+ end
127
+
128
+ if @has_swiftgen == :yes
129
+ FileUtils.mkdir_p File.join(@module_path, "Sources", "ModuleConfiguration")
130
+ end
131
+
132
+ FileUtils.mkdir_p File.join(@module_path, "Resources")
133
+ @configurator.printDone
134
+ end
135
+
136
+ def createModuleInterfaceFolder
137
+ @configurator.printMessage("Gerando pastas de interface")
138
+ FileUtils.mkdir_p File.join(@module_path + "Interface" , "Sources")
139
+ FileUtils.mkdir_p File.join(@module_path + "Interface", "Resources")
140
+ @configurator.printDone
141
+ end
142
+
143
+ def createModuleDummies
144
+ @configurator.printMessage("Gerando arquivos de exemplo")
145
+
146
+ if @module_type == :feature
147
+ FileUtils.touch File.join(@module_path, "Sources", "Features", "Dummy.swift")
148
+ else
149
+ FileUtils.touch File.join(@module_path, "Sources", "DummySource.swift")
150
+ end
151
+
152
+ # Header.h
153
+ headerFilename = File.join(@module_path, "Resources", @configurator.pod_name + ".h")
154
+ FileUtils.cp(
155
+ File.join(@configurator.template_path, "Feature", "Header_template"),
156
+ headerFilename
157
+ )
158
+ text = File.read(headerFilename)
159
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
160
+ File.open(headerFilename, "w") { |file| file.puts text}
161
+
162
+ # Info.plist
163
+ FileUtils.cp(
164
+ File.join(@configurator.template_path, "Feature", "Info_template"),
165
+ File.join(@module_path, "Resources", "Info.plist")
166
+ )
167
+
168
+ if @has_swiftgen == :yes
169
+ # Bundle
170
+ bundleFilename = File.join(@module_path, "Sources", "ModuleConfiguration", "Bundle.swift")
171
+ FileUtils.cp(
172
+ File.join(@configurator.template_path, "Feature", "bundle_template"),
173
+ bundleFilename
174
+ )
175
+
176
+ text = File.read(bundleFilename)
177
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
178
+ File.open(bundleFilename, "w") { |file| file.puts text}
179
+
180
+ # Strings
181
+ FileUtils.touch File.join(@module_path, "Resources", "Localizable.strings")
182
+ File.open(File.join(@module_path, "Resources", "Localizable.strings"), "w") { |file|
183
+ file.puts "\"example.title.text\" = \"EXAMPLE\";"
184
+ }
185
+
186
+ # Assets
187
+ FileUtils.mkdir_p(File.join(@module_path, "Resources", "Assets.xcassets"))
188
+ end
189
+
190
+ @configurator.printDone
191
+ end
192
+
193
+ def createModuleInterfaceDummies
194
+ @configurator.printMessage("Gerando arquivos de exemplo na Interface")
195
+ FileUtils.touch File.join(@module_path + "Interface", "Sources", "DummyInterface.swift")
196
+
197
+ # Info.plist
198
+ FileUtils.cp(
199
+ File.join(@configurator.template_path, "Feature", "Info_template"),
200
+ File.join(@module_path + "Interface", "Resources", "Info.plist")
201
+ )
202
+
203
+ # Header.h
204
+ headerFilename = File.join(@module_path + "Interface", "Resources", @configurator.pod_name + ".h")
205
+ FileUtils.cp(
206
+ File.join(@configurator.template_path, "Feature", "Header_template"),
207
+ headerFilename
208
+ )
209
+ text = File.read(headerFilename)
210
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
211
+ File.open(headerFilename, "w") { |file| file.puts text}
212
+
213
+ @configurator.printDone
214
+ end
215
+
216
+ def createSwiftgen
217
+ @configurator.printMessage("Criando arquivo swiftgen")
218
+ fileName = File.join(@module_root_path, "swiftgen.yml")
219
+ FileUtils.cp(
220
+ File.join(@configurator.template_path, "swiftgen.yml"),
221
+ fileName
222
+ )
223
+
224
+ text = File.read(fileName)
225
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
226
+
227
+ File.open(fileName, "w") { |file| file.puts text}
228
+ @configurator.printDone
229
+ end
230
+
231
+ def createPodspec
232
+ @configurator.printMessage("Configurando arquivo Podspec")
233
+ podspecFilename = "#{module_root_path}/#{@configurator.pod_name}.podspec"
234
+ FileUtils.cp(File.join(@configurator.template_path, "NAME.podspec"), podspecFilename)
235
+ text = File.read podspecFilename
236
+
237
+ podTests = ""
238
+ if @has_test == :yes
239
+ podTests = "# TESTS"
240
+ podTests += "\n s.test_spec 'Tests' do |test_spec|"
241
+ podTests += "\n test_spec.source_files = '${POD_NAME}Tests/**/*'"
242
+ podTests += "\n test_spec.exclude_files = '${POD_NAME}Tests/Resources/*.plist'"
243
+ podTests += "\n end"
244
+ end
245
+
246
+ podInternal = "s.dependency 'SBFoundation'"
247
+
248
+ if @module_type == :feature
249
+ podInternal += "\n s.dependency 'SBUIKit'"
250
+ podInternal += "\n s.dependency 'SBDependencyInterface'"
251
+ end
252
+
253
+ if @has_interface == :yes
254
+ podInternal += "\n s.dependency '${POD_NAME}Interface'"
255
+ end
256
+
257
+ text.gsub!("${FEATURE_INTERNAL}", podInternal)
258
+ text.gsub!("${FEATURE_TEST}", podTests)
259
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
260
+ text.gsub!("${USER_NAME}", @configurator.user_name)
261
+ text.gsub!("${USER_EMAIL}", @configurator.user_email)
262
+ File.open(podspecFilename, "w") { |file| file.puts text}
263
+ @configurator.printDone
264
+ end
265
+
266
+ def createPodspecInterface
267
+ @configurator.printMessage("Configurando arquivo Podspec Interface")
268
+ podspecFilename = "#{module_root_path}/#{@configurator.pod_name}Interface.podspec"
269
+ FileUtils.cp(File.join(@configurator.template_path, "NAMEInterface.podspec"), podspecFilename)
270
+ text = File.read podspecFilename
271
+
272
+ podInternal = ""
273
+ if @module_type == :feature
274
+ podInternal += "\n s.dependency 'SBRouterServiceInterface'"
275
+ end
276
+
277
+ text.gsub!("${FEATURE_INTERNAL}", podInternal)
278
+ text.gsub!("${POD_NAME}", @configurator.pod_name)
279
+ text.gsub!("${USER_NAME}", @configurator.user_name)
280
+ text.gsub!("${USER_EMAIL}", @configurator.user_email)
281
+ File.open(podspecFilename, "w") { |file| file.puts text}
282
+ @configurator.printDone
283
+ end
284
+
285
+ def createTests
286
+ @configurator.printMessage("Gerando pastas de testes")
287
+ # Folders
288
+ FileUtils.mkdir_p File.join(@module_path + "Tests" , "Resources")
289
+ FileUtils.mkdir_p File.join(@module_path + "Tests" , "Sources")
290
+ FileUtils.mkdir_p File.join(@module_path + "Tests" , "Tests")
291
+
292
+ # Dummies
293
+ FileUtils.touch File.join(@module_path + "Tests", "Sources", "DummyModel.swift")
294
+ FileUtils.touch File.join(@module_path + "Tests", "Tests", "DummyTest.swift")
295
+
296
+ # Info.plist
297
+ FileUtils.cp(
298
+ File.join(@configurator.template_path, "Feature", "Info_template"),
299
+ File.join(@module_path + "Tests", "Resources", "Info.plist")
300
+ )
301
+
302
+ @configurator.printDone
303
+ end
304
+
305
+ end
306
+ end
@@ -1,11 +1,31 @@
1
1
  import UIKit
2
+ import SBRouterService
3
+ import SBDependency
4
+ import SBDependencyInterface
5
+ import SBAnalyticsInterface
6
+ import SBLoggerInterface
7
+ /*
8
+ Caso seja utilizado os mocks de Network, descomentar:
9
+ - Imports abaixo
10
+ - Linha 41
11
+ - Mocks a partir da linha 97
12
+ import SBNetwork
13
+ import Fetcher
14
+ import SBSecurityInterface
15
+ import SBUserSessionInterface
16
+ */
2
17
 
3
18
  class SceneDelegate: UIResponder, UIWindowSceneDelegate {
4
19
 
5
20
  var window: UIWindow?
21
+ let container = Container()
22
+ lazy var routerService = RouterService(store: container)
6
23
 
7
24
  func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
8
25
  guard let windowScene = (scene as? UIWindowScene) else { return }
26
+ registerDependency()
27
+ registerHandler()
28
+ injectDependencies()
9
29
  setupRootViewController(windowScene: windowScene)
10
30
  }
11
31
  }
@@ -16,4 +36,151 @@ extension SceneDelegate {
16
36
  window?.rootViewController = ViewController()
17
37
  window?.makeKeyAndVisible()
18
38
  }
39
+
40
+ func registerDependency(){
41
+ // SBNetwork.configure(shellBoxService: ServiceInjection())
42
+ }
43
+
44
+ func registerHandler(){
45
+ // TODO: Implementar routerHandler
46
+ }
47
+ }
48
+
49
+ // ###########################
50
+ // MOCK
51
+ // ###########################
52
+
53
+ extension SceneDelegate {
54
+
55
+ private func injectDependencies() {
56
+
57
+ __registerDependencies {[
58
+ AnalyticsDependency.self,
59
+ LoggerDependency.self
60
+ ]}
61
+ }
62
+ }
63
+
64
+ public struct LoggerDependency: Assembly {
65
+
66
+ public init(){}
67
+
68
+ public func assemble(registry: Registry) {
69
+ registry.register(LoggerProtocol.self) { _ in
70
+ LoggerAssembler()
71
+ }
72
+ }
73
+ }
74
+
75
+ final class LoggerAssembler: LoggerProtocol {
76
+
77
+ func log(level: LogLevel, rawMessage: Message, error: Error?, file: String, function: String, line: Int) {
78
+ print(rawMessage)
79
+ }
80
+ }
81
+
82
+ public struct AnalyticsDependency: Assembly {
83
+
84
+ public init(){}
85
+
86
+ public func assemble(registry: Registry) {
87
+ registry.register(AnalyticsLoggerProtocol.self) { _ in
88
+ AnalyticsLoggerAssembler()
89
+ }
90
+ }
91
+ }
92
+
93
+ class AnalyticsLoggerAssembler: AnalyticsLoggerProtocol {
94
+ func logEvent(_ event: SBAnalyticsInterface.AnalyticsEvent) {}
95
+ }
96
+
97
+ /*
98
+ public struct SecurityDependency: Assembly {
99
+ public init(){}
100
+
101
+ public func assemble(registry: Registry) {
102
+ registry.register(SecurityStoreManaging.self) { _ in
103
+ SecurityAssembler()
104
+ }
105
+ }
106
+ }
107
+
108
+ class SecurityAssembler: SecurityStoreManaging {
109
+ func delete(service: String, account: String) {}
110
+
111
+ func delete(_ metadata: SBSecurityInterface.StorableMetadata) {}
112
+
113
+ func save<T>(_ item: T, service: String, account: String) throws where T : Decodable, T : Encodable {}
114
+
115
+ func save<T>(item: T, _ metadata: SBSecurityInterface.StorableMetadata) throws where T : Decodable, T : Encodable {}
116
+
117
+ func read<T>(service: String, account: String, type: T.Type) throws -> T? where T : Decodable, T : Encodable {
118
+ nil
119
+ }
120
+
121
+ func read(_ metadata: SBSecurityInterface.StorableMetadata) -> String? {
122
+ nil
123
+ }
124
+ }
125
+
126
+ class SecurityUtils: SecurityUtilsProtocol {
127
+ func uuidString() -> String? {
128
+ UUID().uuidString
129
+ }
130
+ }
131
+
132
+ public struct UserSessionDependency: Assembly {
133
+
134
+ public init(){}
135
+
136
+ public func assemble(registry: Registry) {
137
+ registry.register(UserSessionProvider.self, name: "SessionTokenProvider") { _ in
138
+ UserSessionAssembler()
139
+ }
140
+ }
141
+ }
142
+
143
+ class UserSessionAssembler: UserSessionProvider {
144
+ func getIdentifier() -> String? {
145
+ UUID().uuidString
146
+ }
147
+
148
+ func getToken() -> String? {
149
+ "TESTE"
150
+ }
19
151
  }
152
+
153
+ class ServiceInjection: ShellBoxServiceProtocol {
154
+ func shellBoxServiceAtomantBaseURL() -> SBNetwork.AtomantEnvironment {
155
+ return .development
156
+ }
157
+
158
+ func shellBoxServiceRufusBaseURL() -> SBNetwork.RufusEnvironment {
159
+ return .development
160
+ }
161
+
162
+ func shellBoxServiceBFFBaseURL() -> SBNetwork.BFFEnvironment {
163
+ return .unit
164
+ }
165
+
166
+ func shellBoxServiceUseCredential(trust: SecTrust, session: URLSession, completion: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
167
+ completion(.useCredential, nil)
168
+ }
169
+
170
+ func shellBoxServiceGetInterceptors() -> [Interceptor] {
171
+ return []
172
+ }
173
+
174
+ func shellBoxServiceDidCreate(sessionConfiguration: URLSessionConfiguration) {
175
+
176
+ }
177
+
178
+ func shellBoxServiceHandleRequestError(request: URLRequest,
179
+ response: URLResponse,
180
+ error: ShellBoxError,
181
+ completion: @escaping (URLRequest?) -> Void) {
182
+ completion(nil)
183
+ }
184
+ }
185
+ */
186
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shellboxCLI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ShellBox App
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-19 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor