ykioscmd 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +7 -0
  2. data/.DS_Store +0 -0
  3. data/.YKPodSpecConfig.yml +5 -0
  4. data/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. data/.idea/misc.xml +4 -0
  6. data/.idea/ruby-client.iml +38 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.idea/workspace.xml +8388 -0
  9. data/.idea/yk_command.iml +105 -0
  10. data/.ruby-version +1 -0
  11. data/Gemfile +16 -0
  12. data/Gemfile.lock +153 -0
  13. data/README.html +109 -0
  14. data/README.md +104 -0
  15. data/Rakefile +4 -0
  16. data/bin/console +15 -0
  17. data/bin/setup +8 -0
  18. data/bin/ykioscmd +7 -0
  19. data/configruation-files/.YKBotConfig.yml +4 -0
  20. data/configruation-files/.YKGitlabConfig.yml +3 -0
  21. data/configruation-files/.YKProjectConfig.yml +4 -0
  22. data/configruation-files/.YKServerConfig.yml +3 -0
  23. data/debugProject/.DS_Store +0 -0
  24. data/images/Xnip2022-04-26_17-25-30.jpg +0 -0
  25. data/images/Xnip2022-04-26_17-27-32.jpg +0 -0
  26. data/images/Xnip2022-04-26_17-30-36.jpg +0 -0
  27. data/lib/.DS_Store +0 -0
  28. data/lib/yk_command/.DS_Store +0 -0
  29. data/lib/yk_command/analyze/analyze.rb +177 -0
  30. data/lib/yk_command/analyze/dependency_result.rb +138 -0
  31. data/lib/yk_command/analyze/request.rb +41 -0
  32. data/lib/yk_command/bot/wx_bot.rb +66 -0
  33. data/lib/yk_command/commands.rb +108 -0
  34. data/lib/yk_command/component_manage/component_manage_platform.rb +101 -0
  35. data/lib/yk_command/config/yk_config.rb +30 -0
  36. data/lib/yk_command/evaluate/evaluate.rb +7 -0
  37. data/lib/yk_command/gitlab/yk_gitlab.rb +77 -0
  38. data/lib/yk_command/module/.DS_Store +0 -0
  39. data/lib/yk_command/module/module_handler.rb +93 -0
  40. data/lib/yk_command/module/template/.DS_Store +0 -0
  41. data/lib/yk_command/module/template/objc/.DS_Store +0 -0
  42. data/lib/yk_command/module/template/objc/BusinessHeader.h +0 -0
  43. data/lib/yk_command/module/template/objc/CategoryHeader.h +12 -0
  44. data/lib/yk_command/module/template/objc/Helper.h +16 -0
  45. data/lib/yk_command/module/template/objc/Helper.m +41 -0
  46. data/lib/yk_command/module/template/objc/PrefixHeader.pch +30 -0
  47. data/lib/yk_command/module/template/objc/RouterRegister.h +16 -0
  48. data/lib/yk_command/module/template/objc/RouterRegister.m +26 -0
  49. data/lib/yk_command/module/template/objc/ServiceRegister.h +16 -0
  50. data/lib/yk_command/module/template/objc/ServiceRegister.m +21 -0
  51. data/lib/yk_command/module/template/objc/ToolsHeader.h +13 -0
  52. data/lib/yk_command/module/template/objc/VendorHeader.h +13 -0
  53. data/lib/yk_command/module/template/swift/.DS_Store +0 -0
  54. data/lib/yk_command/module/template/swift/PrefixHeader_swift.swift +10 -0
  55. data/lib/yk_command/module/template/swift/RouterRegisterSwift.swift +23 -0
  56. data/lib/yk_command/module/template/swift/ServiceRegisterSwift.swift +20 -0
  57. data/lib/yk_command/module/template/swift/Tool.swift +53 -0
  58. data/lib/yk_command/module/yk_module.rb +215 -0
  59. data/lib/yk_command/project/.DS_Store +0 -0
  60. data/lib/yk_command/project/full_component_demo_template/.gitignore +37 -0
  61. data/lib/yk_command/project/full_component_demo_template/.travis.yml +14 -0
  62. data/lib/yk_command/project/full_component_demo_template/CODE_OF_CONDUCT.md +40 -0
  63. data/lib/yk_command/project/full_component_demo_template/LICENSE +21 -0
  64. data/lib/yk_command/project/full_component_demo_template/NAME-osx.podspec +43 -0
  65. data/lib/yk_command/project/full_component_demo_template/NAME.podspec +151 -0
  66. data/lib/yk_command/project/full_component_demo_template/POD_LICENSE +19 -0
  67. data/lib/yk_command/project/full_component_demo_template/POD_README.md +29 -0
  68. data/lib/yk_command/project/full_component_demo_template/Pod/Assets/.gitkeep +0 -0
  69. data/lib/yk_command/project/full_component_demo_template/Pod/Classes/.gitkeep +0 -0
  70. data/lib/yk_command/project/full_component_demo_template/README.md +22 -0
  71. data/lib/yk_command/project/full_component_demo_template/configure +12 -0
  72. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/Base.lproj/LaunchScreen.storyboard +31 -0
  73. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/Base.lproj/Main.storyboard +79 -0
  74. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/CPDAppDelegate.h +15 -0
  75. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/CPDAppDelegate.m +46 -0
  76. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/CPDViewController.h +13 -0
  77. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/CPDViewController.m +47 -0
  78. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +98 -0
  79. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/PROJECT-Info.plist +49 -0
  80. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/PROJECT-Prefix.pch +16 -0
  81. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/en.lproj/InfoPlist.strings +2 -0
  82. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT/main.m +17 -0
  83. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.pbxproj +500 -0
  84. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  85. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  86. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +101 -0
  87. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/Podfile +34 -0
  88. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/Tests/Tests-Info.plist +22 -0
  89. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/Tests/Tests-Prefix.pch +7 -0
  90. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/Tests/Tests.m +9 -0
  91. data/lib/yk_command/project/full_component_demo_template/templates/ios/Example/Tests/en.lproj/InfoPlist.strings +2 -0
  92. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/AppDelegate.swift +26 -0
  93. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  94. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/Base.lproj/Main.storyboard +717 -0
  95. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/Info.plist +30 -0
  96. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/PROJECT.entitlements +10 -0
  97. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT/ViewController.swift +27 -0
  98. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/project.pbxproj +444 -0
  99. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  100. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +103 -0
  101. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/Podfile +11 -0
  102. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/Tests/Info.plist +22 -0
  103. data/lib/yk_command/project/full_component_demo_template/templates/macos-swift/Example/Tests/Tests.swift +1 -0
  104. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/AppDelegate.swift +46 -0
  105. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Base.lproj/LaunchScreen.xib +46 -0
  106. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Base.lproj/Main.storyboard +86 -0
  107. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Example-Bridging-Header.h +4 -0
  108. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  109. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Info.plist +39 -0
  110. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/STTestAppDelegate.swift +16 -0
  111. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/Tests-Bridging-Header.h +4 -0
  112. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/ViewController.swift +51 -0
  113. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT/YKEmptyOcFile.m +9 -0
  114. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.pbxproj +489 -0
  115. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  116. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  117. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +117 -0
  118. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/Podfile +35 -0
  119. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/Tests/Info.plist +24 -0
  120. data/lib/yk_command/project/full_component_demo_template/templates/swift/Example/Tests/Tests.swift +1 -0
  121. data/lib/yk_command/project/setup/ConfigureMacOSSwift.rb +46 -0
  122. data/lib/yk_command/project/setup/ConfigureSwift.rb +42 -0
  123. data/lib/yk_command/project/setup/ConfigureiOS.rb +106 -0
  124. data/lib/yk_command/project/setup/MessageBank.rb +113 -0
  125. data/lib/yk_command/project/setup/ProjectManipulator.rb +141 -0
  126. data/lib/yk_command/project/setup/TemplateConfigurator.rb +258 -0
  127. data/lib/yk_command/project/simple_component_demo_template/.gitignore +37 -0
  128. data/lib/yk_command/project/simple_component_demo_template/.travis.yml +14 -0
  129. data/lib/yk_command/project/simple_component_demo_template/CODE_OF_CONDUCT.md +40 -0
  130. data/lib/yk_command/project/simple_component_demo_template/LICENSE +21 -0
  131. data/lib/yk_command/project/simple_component_demo_template/NAME-osx.podspec +43 -0
  132. data/lib/yk_command/project/simple_component_demo_template/NAME.podspec +140 -0
  133. data/lib/yk_command/project/simple_component_demo_template/POD_LICENSE +19 -0
  134. data/lib/yk_command/project/simple_component_demo_template/POD_README.md +29 -0
  135. data/lib/yk_command/project/simple_component_demo_template/Pod/Assets/.gitkeep +0 -0
  136. data/lib/yk_command/project/simple_component_demo_template/Pod/Classes/.gitkeep +0 -0
  137. data/lib/yk_command/project/simple_component_demo_template/README.md +22 -0
  138. data/lib/yk_command/project/simple_component_demo_template/configure +13 -0
  139. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/Base.lproj/LaunchScreen.storyboard +31 -0
  140. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/Base.lproj/Main.storyboard +79 -0
  141. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/CPDAppDelegate.h +15 -0
  142. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/CPDAppDelegate.m +46 -0
  143. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/CPDViewController.h +13 -0
  144. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/CPDViewController.m +37 -0
  145. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +98 -0
  146. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/PROJECT-Info.plist +49 -0
  147. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/PROJECT-Prefix.pch +16 -0
  148. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/en.lproj/InfoPlist.strings +2 -0
  149. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT/main.m +17 -0
  150. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.pbxproj +500 -0
  151. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  152. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  153. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +101 -0
  154. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/Podfile +19 -0
  155. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/Tests/Tests-Info.plist +22 -0
  156. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/Tests/Tests-Prefix.pch +7 -0
  157. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/Tests/Tests.m +9 -0
  158. data/lib/yk_command/project/simple_component_demo_template/templates/ios/Example/Tests/en.lproj/InfoPlist.strings +2 -0
  159. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/AppDelegate.swift +26 -0
  160. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  161. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/Base.lproj/Main.storyboard +717 -0
  162. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/Info.plist +30 -0
  163. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/PROJECT.entitlements +10 -0
  164. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT/ViewController.swift +27 -0
  165. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/project.pbxproj +444 -0
  166. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  167. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +103 -0
  168. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/Podfile +11 -0
  169. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/Tests/Info.plist +22 -0
  170. data/lib/yk_command/project/simple_component_demo_template/templates/macos-swift/Example/Tests/Tests.swift +1 -0
  171. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/AppDelegate.swift +46 -0
  172. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/Base.lproj/LaunchScreen.xib +46 -0
  173. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/Base.lproj/Main.storyboard +103 -0
  174. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/EmptyOcFile.m +9 -0
  175. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  176. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/Info.plist +39 -0
  177. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/PROJECT_Example-Bridging-Header.h +4 -0
  178. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/PROJECT_Tests-Bridging-Header.h +4 -0
  179. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT/ViewController.swift +32 -0
  180. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.pbxproj +489 -0
  181. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  182. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  183. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +117 -0
  184. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/Podfile +20 -0
  185. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/Tests/Info.plist +24 -0
  186. data/lib/yk_command/project/simple_component_demo_template/templates/swift/Example/Tests/Tests.swift +1 -0
  187. data/lib/yk_command/project/test_examples/kiwi.m +36 -0
  188. data/lib/yk_command/project/test_examples/quick.swift +50 -0
  189. data/lib/yk_command/project/test_examples/specta.m +39 -0
  190. data/lib/yk_command/project/test_examples/xctest.m +26 -0
  191. data/lib/yk_command/project/test_examples/xctest.swift +28 -0
  192. data/lib/yk_command/project/yk_project.rb +92 -0
  193. data/lib/yk_command/repo_publish/component_default.yml +5 -0
  194. data/lib/yk_command/repo_publish/component_publish.rb +218 -0
  195. data/lib/yk_command/version.rb +5 -0
  196. data/lib/ykioscmd.rb +9 -0
  197. data/ykioscmd.gemspec +53 -0
  198. metadata +453 -0
@@ -0,0 +1,46 @@
1
+ module Pod
2
+
3
+ class ConfigureMacOSSwift
4
+ attr_reader :configurator
5
+
6
+ def self.perform(options)
7
+ new(options).perform
8
+ end
9
+
10
+ def initialize(options)
11
+ @configurator = options.fetch(:configurator)
12
+ end
13
+
14
+ def perform
15
+ keep_demo = configurator.ask_with_answers("Would you like to include a demo application with your library", ["Yes", "No"]).to_sym
16
+
17
+ framework = configurator.ask_with_answers("Which testing frameworks will you use", ["Quick", "None"]).to_sym
18
+ case framework
19
+ when :quick
20
+ configurator.add_pod_to_podfile "Quick', '~> 2.2.0"
21
+ configurator.add_pod_to_podfile "Nimble', '~> 8.0.7"
22
+ configurator.set_test_framework "quick", "swift", "macos-swift"
23
+
24
+ when :none
25
+ configurator.set_test_framework "xctest", "swift", "macos-swift"
26
+ end
27
+
28
+ Pod::ProjectManipulator.new({
29
+ :configurator => @configurator,
30
+ :xcodeproj_path => "templates/macos-swift/Example/PROJECT.xcodeproj",
31
+ :platform => :osx,
32
+ :remove_demo_project => (keep_demo == :no),
33
+ :prefix => ""
34
+ }).run
35
+
36
+ `mv ./templates/macos-swift/* ./`
37
+
38
+ # There has to be a single file in the Classes dir
39
+ # or a framework won't be created
40
+ # `touch Pod/Classes/ReplaceMe.swift`
41
+
42
+ `mv ./NAME-osx.podspec ./NAME.podspec`
43
+ end
44
+ end
45
+
46
+ end
@@ -0,0 +1,42 @@
1
+ module Pod
2
+
3
+ class ConfigureSwift
4
+ attr_reader :configurator
5
+
6
+ def self.perform(options)
7
+ new(options).perform
8
+
9
+ end
10
+
11
+ def initialize(options)
12
+ @configurator = options.fetch(:configurator)
13
+ $current_dir = @configurator.temp_path
14
+ end
15
+
16
+
17
+ def perform
18
+ # keep_demo = configurator.ask_with_answers("Would you like to include a demo application with your library", ["Yes", "No"]).to_sym
19
+
20
+ keep_demo = :yes
21
+
22
+ Pod::ProjectManipulator.new({
23
+ :configurator => @configurator,
24
+ # :xcodeproj_path => "templates/swift/Example/PROJECT.xcodeproj",
25
+ :xcodeproj_path => "#{$current_dir}/templates/swift/Example/PROJECT.xcodeproj",
26
+ :platform => :ios,
27
+ :remove_demo_project => (keep_demo == :no),
28
+ :prefix => @configurator.prefix
29
+ }).run
30
+
31
+ # There has to be a single file in the Classes dir
32
+ # or a framework won't be created
33
+ `touch #{$current_dir}/Pod/Classes/ReplaceMe.swift`
34
+
35
+ `mv #{$current_dir}/templates/swift/* #{$current_dir}`
36
+
37
+ # remove podspec for osx
38
+ `rm #{$current_dir}/NAME-osx.podspec`
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,106 @@
1
+ module Pod
2
+
3
+ class ConfigureIOS
4
+ attr_reader :configurator
5
+
6
+ def self.perform(options)
7
+ new(options).perform
8
+ end
9
+
10
+ def initialize(options)
11
+ @configurator = options.fetch(:configurator)
12
+ $current_dir = @configurator.temp_path
13
+ end
14
+
15
+ def perform
16
+
17
+
18
+ # keep_demo = configurator.ask_with_answers("Would you like to include a demo application with your library", ["Yes", "No"]).to_sym
19
+ keep_demo = :yes
20
+ # framework = configurator.ask_with_answers("Which testing frameworks will you use", ["Specta", "Kiwi", "None"]).to_sym
21
+ # case framework
22
+ # when :specta
23
+ # configurator.add_pod_to_podfile "Specta"
24
+ # configurator.add_pod_to_podfile "Expecta"
25
+
26
+ # configurator.add_line_to_pch "@import Specta;"
27
+ # configurator.add_line_to_pch "@import Expecta;"
28
+
29
+ # configurator.set_test_framework("specta", "m", "ios")
30
+
31
+ # when :kiwi
32
+ # configurator.add_pod_to_podfile "Kiwi"
33
+ # configurator.add_line_to_pch "@import Kiwi;"
34
+ # configurator.set_test_framework("kiwi", "m", "ios")
35
+
36
+ # when :none
37
+ # configurator.set_test_framework("xctest", "m", "ios")
38
+ # end
39
+
40
+ # snapshots = configurator.ask_with_answers("Would you like to do view based testing", ["Yes", "No"]).to_sym
41
+ # case snapshots
42
+ # when :yes
43
+ # configurator.add_pod_to_podfile "FBSnapshotTestCase"
44
+ # configurator.add_line_to_pch "@import FBSnapshotTestCase;"
45
+
46
+ # if keep_demo == :no
47
+ # puts " Putting demo application back in, you cannot do view tests without a host application."
48
+ # keep_demo = :yes
49
+ # end
50
+
51
+ # if framework == :specta
52
+ # configurator.add_pod_to_podfile "Expecta+Snapshots"
53
+ # configurator.add_line_to_pch "@import Expecta_Snapshots;"
54
+ # end
55
+ # end
56
+
57
+ # prefix = nil
58
+ prefix = ''
59
+ # loop do
60
+ # prefix = configurator.ask("What is your class prefix").upcase
61
+
62
+ # if prefix.include?(' ')
63
+ # puts 'Your class prefix cannot contain spaces.'.red
64
+ # else
65
+ # break
66
+ # end
67
+ # end
68
+
69
+ # Pod::ProjectManipulator.new({
70
+ # :configurator => @configurator,
71
+ # :xcodeproj_path => "templates/ios/Example/PROJECT.xcodeproj",
72
+ # :platform => :ios,
73
+ # :remove_demo_project => (keep_demo == :no),
74
+ # :prefix => prefix
75
+ # }).run
76
+
77
+ Pod::ProjectManipulator.new({
78
+ :configurator => @configurator,
79
+ # :xcodeproj_path => "templates/swift/Example/PROJECT.xcodeproj",
80
+ :xcodeproj_path => "#{$current_dir}/templates/ios/Example/PROJECT.xcodeproj",
81
+ :platform => :ios,
82
+ :remove_demo_project => (keep_demo == :no),
83
+ :prefix => @configurator.prefix
84
+ }).run
85
+
86
+
87
+
88
+ # There has to be a single file in the Classes dir
89
+ # or a framework won't be created, which is now default
90
+ # `touch Pod/Classes/ReplaceMe.m`
91
+
92
+ # `mv ./templates/ios/* ./`
93
+
94
+ # # remove podspec for osx
95
+ # `rm ./NAME-osx.podspec`
96
+ `touch #{$current_dir}/Pod/Classes/ReplaceMe.m`
97
+
98
+ `mv #{$current_dir}/templates/ios/* #{$current_dir}`
99
+
100
+ # remove podspec for osx
101
+ `rm #{$current_dir}/NAME-osx.podspec`
102
+
103
+ end
104
+ end
105
+
106
+ end
@@ -0,0 +1,113 @@
1
+ module Pod
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 welcome_message
33
+ unless @configurator.validate_user_details
34
+ run_setup_questions
35
+ end
36
+
37
+ puts "\n------------------------------"
38
+ puts ""
39
+ puts "To get you started we need to ask a few questions, this should only take a minute."
40
+ puts ""
41
+
42
+ has_run_before = `defaults read org.cocoapods.pod-template HasRunBefore`.chomp == "1"
43
+
44
+ puts "If this is your first time we recommend running through with the guide: "
45
+ puts " - " + "https://guides.cocoapods.org/making/using-pod-lib-create.html".blue.underlined
46
+
47
+ if ENV["TERM_PROGRAM"] == "iTerm.app"
48
+ puts " ( hold cmd and click links to open in a browser. )".magenta
49
+ else
50
+ puts " ( hold cmd and double click links to open in a browser. )".magenta
51
+ end
52
+
53
+ unless has_run_before
54
+ puts "\n Press return to continue."
55
+ `defaults write org.cocoapods.pod-template HasRunBefore -bool true`
56
+ end
57
+
58
+ puts ""
59
+ end
60
+
61
+ def farewell_message
62
+ puts ""
63
+
64
+ puts " Ace! you're ready to go!"
65
+ puts " We will start you off by opening your project in Xcode"
66
+ pod_name = @configurator.pod_name
67
+ run_command "open '#{$current_dir}/Example/#{pod_name}.xcworkspace'", "open '#{$current_dir}/Example/#{pod_name}.xcworkspace'"
68
+ end
69
+
70
+
71
+ def run_setup_questions
72
+
73
+ puts yellow_bang + "Before you can create a new library we need to setup your git credentials."
74
+
75
+ unless @configurator.user_name.length > 0
76
+ puts "\n What is your name? "
77
+ answer = ""
78
+
79
+ loop do
80
+ show_prompt
81
+
82
+ answer = gets.chomp
83
+ break if answer.length > 0
84
+
85
+ puts red_bang + "Please enter a name."
86
+ end
87
+
88
+ puts ""
89
+ puts green_bang + "Setting your name in git to " + answer
90
+ run_command('git config user.name "' + answer + '"')
91
+ end
92
+
93
+ unless @configurator.user_email.length > 0
94
+ puts "\n What is your email?"
95
+ answer = ""
96
+
97
+ loop do
98
+ show_prompt
99
+ answer = gets.downcase.chomp
100
+ break if answer.length > 0
101
+
102
+ puts red_bang + "Please enter a email."
103
+ end
104
+
105
+ puts ""
106
+ puts green_bang + "Setting your email in git to " + answer
107
+ run_command('git config user.email "' + answer + '"')
108
+ end
109
+
110
+ end
111
+
112
+ end
113
+ end
@@ -0,0 +1,141 @@
1
+ require 'xcodeproj'
2
+
3
+ module Pod
4
+
5
+ class ProjectManipulator
6
+ attr_reader :configurator, :xcodeproj_path, :platform, :remove_demo_target, :string_replacements, :prefix
7
+
8
+ def self.perform(options)
9
+ new(options).perform
10
+ end
11
+
12
+ def initialize(options)
13
+ @xcodeproj_path = options.fetch(:xcodeproj_path)
14
+ @configurator = options.fetch(:configurator)
15
+ @platform = options.fetch(:platform)
16
+ @remove_demo_target = options.fetch(:remove_demo_project)
17
+ @prefix = options.fetch(:prefix)
18
+ end
19
+
20
+ def run
21
+ @string_replacements = {
22
+ "PROJECT_OWNER" => @configurator.user_name,
23
+ "TODAYS_DATE" => @configurator.date,
24
+ "TODAYS_YEAR" => @configurator.year,
25
+ "PROJECT" => @configurator.pod_name,
26
+ "CPD" => @prefix
27
+ }
28
+ replace_internal_project_settings
29
+
30
+ @project = Xcodeproj::Project.open(@xcodeproj_path)
31
+ add_podspec_metadata
32
+ remove_demo_project if @remove_demo_target
33
+ @project.save
34
+
35
+ rename_files
36
+ rename_project_folder
37
+ end
38
+
39
+ def add_podspec_metadata
40
+ project_metadata_item = @project.root_object.main_group.children.select { |group| group.name == "Podspec Metadata" }.first
41
+ project_metadata_item.new_file "../" + @configurator.pod_name + ".podspec"
42
+ project_metadata_item.new_file "../README.md"
43
+ project_metadata_item.new_file "../LICENSE"
44
+ end
45
+
46
+ def remove_demo_project
47
+ app_project = @project.native_targets.find { |target| target.product_type == "com.apple.product-type.application" }
48
+ test_target = @project.native_targets.find { |target| target.product_type == "com.apple.product-type.bundle.unit-test" }
49
+ test_target.name = @configurator.pod_name + "_Tests"
50
+
51
+ # Remove the implicit dependency on the app
52
+ test_dependency = test_target.dependencies.first
53
+ test_dependency.remove_from_project
54
+ app_project.remove_from_project
55
+
56
+ # Remove the build target on the unit tests
57
+ test_target.build_configuration_list.build_configurations.each do |build_config|
58
+ build_config.build_settings.delete "BUNDLE_LOADER"
59
+ end
60
+
61
+ # Remove the references in xcode
62
+ project_app_group = @project.root_object.main_group.children.select { |group| group.display_name.end_with? @configurator.pod_name }.first
63
+ project_app_group.remove_from_project
64
+
65
+ # Remove the product reference
66
+ product = @project.products.select { |product| product.path == @configurator.pod_name + "_Example.app" }.first
67
+ product.remove_from_project
68
+
69
+ # Remove the actual folder + files for both projects
70
+ `rm -rf templates/ios/Example/PROJECT`
71
+ `rm -rf templates/swift/Example/PROJECT`
72
+
73
+ # Replace the Podfile with a simpler one with only one target
74
+ podfile_path = project_folder + "/Podfile"
75
+ podfile_text = <<-RUBY
76
+ use_frameworks!
77
+ target '#{test_target.name}' do
78
+ pod '#{@configurator.pod_name}', :path => '../'
79
+
80
+ ${INCLUDED_PODS}
81
+ end
82
+ RUBY
83
+ File.open(podfile_path, "w") { |file| file.puts podfile_text }
84
+ end
85
+
86
+ def project_folder
87
+ File.dirname @xcodeproj_path
88
+ end
89
+
90
+ def rename_files
91
+ # shared schemes have project specific names
92
+ scheme_path = project_folder + "/PROJECT.xcodeproj/xcshareddata/xcschemes/"
93
+ File.rename(scheme_path + "PROJECT.xcscheme", scheme_path + @configurator.pod_name + "-Example.xcscheme")
94
+
95
+ # rename xcproject
96
+ File.rename(project_folder + "/PROJECT.xcodeproj", project_folder + "/" + @configurator.pod_name + ".xcodeproj")
97
+
98
+ unless @remove_demo_target
99
+ # change app file prefixes
100
+ ["CPDAppDelegate.h", "CPDAppDelegate.m", "CPDViewController.h", "CPDViewController.m"].each do |file|
101
+ before = project_folder + "/PROJECT/" + file
102
+ next unless File.exists? before
103
+
104
+ after = project_folder + "/PROJECT/" + file.gsub("CPD", prefix)
105
+ File.rename before, after
106
+ end
107
+
108
+ # rename project related files
109
+ ["PROJECT-Info.plist", "PROJECT-Prefix.pch", "PROJECT.entitlements"].each do |file|
110
+ before = project_folder + "/PROJECT/" + file
111
+ next unless File.exists? before
112
+
113
+ after = project_folder + "/PROJECT/" + file.gsub("PROJECT", @configurator.pod_name)
114
+ File.rename before, after
115
+ end
116
+ end
117
+
118
+ end
119
+
120
+ def rename_project_folder
121
+ if Dir.exist? project_folder + "/PROJECT"
122
+ File.rename(project_folder + "/PROJECT", project_folder + "/" + @configurator.pod_name)
123
+ end
124
+ end
125
+
126
+ def replace_internal_project_settings
127
+ Dir.glob(project_folder + "/**/**/**/**").each do |name|
128
+ next if Dir.exists? name
129
+ text = File.read(name)
130
+
131
+ for find, replace in @string_replacements
132
+ text = text.gsub(find, replace)
133
+ end
134
+
135
+ File.open(name, "w") { |file| file.puts text }
136
+ end
137
+ end
138
+
139
+ end
140
+
141
+ end
@@ -0,0 +1,258 @@
1
+ require 'fileutils'
2
+ require 'colored2'
3
+
4
+ require_relative 'MessageBank'
5
+ require_relative 'ConfigureIOS'
6
+ require_relative 'ConfigureSwift'
7
+ require_relative 'ProjectManipulator'
8
+
9
+ module Pod
10
+ class TemplateConfigurator
11
+
12
+ attr_reader :pod_name, :pods_for_podfile, :prefix,:prefixes, :test_example_file, :username, :email,:temp_path
13
+
14
+ def initialize(pod_name,framework,prefix,author,temp_path,is_simple)
15
+ @temp_path = temp_path
16
+ @pod_name = pod_name
17
+ @framework = framework
18
+ @prefix = prefix
19
+ @author = author
20
+ @is_simple = is_simple
21
+ @pods_for_podfile = []
22
+ @prefixes = []
23
+ @message_bank = MessageBank.new(self)
24
+ end
25
+
26
+ def ask(question)
27
+ answer = ""
28
+ loop do
29
+ puts "\n#{question}?"
30
+
31
+ @message_bank.show_prompt
32
+ answer = gets.chomp
33
+
34
+ break if answer.length > 0
35
+
36
+ print "\nYou need to provide an answer."
37
+ end
38
+ answer
39
+ end
40
+
41
+ def ask_with_answers(question, possible_answers)
42
+
43
+ print "\n#{question}? ["
44
+
45
+ print_info = Proc.new {
46
+
47
+ possible_answers_string = possible_answers.each_with_index do |answer, i|
48
+ _answer = (i == 0) ? answer.underlined : answer
49
+ print " " + _answer
50
+ print(" /") if i != possible_answers.length-1
51
+ end
52
+ print " ]\n"
53
+ }
54
+ print_info.call
55
+
56
+ answer = ""
57
+
58
+ loop do
59
+ @message_bank.show_prompt
60
+ answer = STDIN.gets.downcase.chomp
61
+
62
+ answer = "yes" if answer == "y"
63
+ answer = "no" if answer == "n"
64
+
65
+ # default to first answer
66
+ if answer == ""
67
+ answer = possible_answers[0].downcase
68
+ print answer.yellow
69
+ end
70
+
71
+ break if possible_answers.map { |a| a.downcase }.include? answer
72
+
73
+ print "\nPossible answers are ["
74
+ print_info.call
75
+ end
76
+
77
+ answer
78
+ end
79
+
80
+ def run
81
+ # @message_bank.welcome_message
82
+
83
+ if @framework == "swift"
84
+ ConfigureSwift.perform(configurator: self)
85
+ else
86
+ ConfigureIOS.perform(configurator: self)
87
+ end
88
+
89
+ replace_variables_in_files
90
+ clean_template_files
91
+ rename_template_files
92
+
93
+ if @is_simple != true
94
+ add_yk_pods
95
+ end
96
+
97
+
98
+ add_pods_to_podfile
99
+
100
+ customise_prefix
101
+ rename_classes_folder
102
+ ensure_carthage_compatibility
103
+ reinitialize_git_repo
104
+ run_pod_install
105
+
106
+ # @message_bank.farewell_message
107
+ end
108
+
109
+ def add_yk_pods
110
+ # self.add_pod_to_podfile "YKCategoryComponent"
111
+ self.add_pod_to_podfile "YKModuleLifeCircleComponent"
112
+ self.add_pod_to_podfile "YKRouterComponent"
113
+
114
+ if @framework == "swift"
115
+ # self.add_pod_to_podfile "SnapKit"
116
+ self.add_pod_to_podfile "YKModuleServiceComponent.swift"
117
+ else
118
+ self.add_pod_to_podfile "YKModuleServiceComponent"
119
+ end
120
+
121
+ end
122
+ #----------------------------------------#
123
+
124
+ def ensure_carthage_compatibility
125
+ # FileUtils.ln_s("#{$current_dir}/Example/Pods/Pods.xcodeproj", "#{$current_dir}/_Pods.xcodeproj")
126
+ end
127
+
128
+ def run_pod_install
129
+ puts "\nRunning " + "pod install".magenta + " on your new library."
130
+ puts ""
131
+
132
+ Dir.chdir("#{$current_dir}/Example") do
133
+ # system "pod install"
134
+ end
135
+
136
+ # `git add #{$current_dir}/Example/#{pod_name}.xcodeproj/project.pbxproj`
137
+ # `git commit -m "Initial commit"`
138
+ end
139
+
140
+ def clean_template_files
141
+ ["./**/.gitkeep", "configure", "_CONFIGURE.rb", "README.md", "LICENSE", "templates", "setup", "CODE_OF_CONDUCT.md"].each do |asset|
142
+ `rm -rf #{$current_dir}/#{asset}`
143
+ end
144
+ end
145
+
146
+ def replace_variables_in_files
147
+ # file_names = ['POD_LICENSE', 'POD_README.md', 'NAME.podspec', '.travis.yml', podfile_path]
148
+ file_names = ['POD_LICENSE', 'POD_README.md', 'NAME.podspec', podfile_path]
149
+ file_names.each do |file_name|
150
+ # text = File.read(file_name)
151
+ text = File.read("#{$current_dir}/#{file_name}")
152
+ # text = File.read("./#{file_name}")
153
+ text.gsub!("${POD_NAME}", @pod_name)
154
+ text.gsub!("${REPO_NAME}", @pod_name.gsub('+', '-'))
155
+ text.gsub!("${USER_NAME}", user_name)
156
+ text.gsub!("${USER_EMAIL}", user_email)
157
+ text.gsub!("${YEAR}", year)
158
+ text.gsub!("${DATE}", date)
159
+ # File.open(file_name, "w") { |file| file.puts text }
160
+ File.open("#{$current_dir}/#{file_name}", "w") { |file| file.puts text }
161
+ end
162
+ end
163
+
164
+ def add_pod_to_podfile podname
165
+ @pods_for_podfile << podname
166
+ end
167
+
168
+ def add_pods_to_podfile
169
+ podfile = File.read "#{$current_dir}/#{podfile_path}"
170
+ podfile_content = @pods_for_podfile.map do |pod|
171
+ "pod '" + pod + "'"
172
+ end.join("\n ")
173
+ podfile.gsub!("${INCLUDED_PODS}", podfile_content)
174
+ File.open("#{$current_dir}/#{podfile_path}", "w") { |file| file.puts podfile }
175
+
176
+ end
177
+
178
+ def add_line_to_pch line
179
+ @prefixes << line
180
+ end
181
+
182
+ def customise_prefix
183
+ prefix_path = "Example/Tests/Tests-Prefix.pch"
184
+ return unless File.exists? prefix_path
185
+
186
+ pch = File.read prefix_path
187
+ pch.gsub!("${INCLUDED_PREFIXES}", @prefixes.join("\n ") )
188
+ File.open(prefix_path, "w") { |file| file.puts pch }
189
+ end
190
+
191
+ def set_test_framework(test_type, extension, folder)
192
+ content_path = "setup/test_examples/" + test_type + "." + extension
193
+ tests_path = "templates/" + folder + "/Example/Tests/Tests." + extension
194
+ tests = File.read tests_path
195
+ tests.gsub!("${TEST_EXAMPLE}", File.read(content_path) )
196
+ File.open(tests_path, "w") { |file| file.puts tests }
197
+ end
198
+
199
+ def rename_template_files
200
+ FileUtils.mv "#{$current_dir}/POD_README.md", "#{$current_dir}/README.md"
201
+ FileUtils.mv "#{$current_dir}/POD_LICENSE", "#{$current_dir}/LICENSE"
202
+ FileUtils.mv "#{$current_dir}/NAME.podspec", "#{$current_dir}/#{pod_name}.podspec"
203
+ end
204
+
205
+ def rename_classes_folder
206
+ # FileUtils.mv "#{@pod_name}/Pod", @pod_name
207
+ FileUtils.mv "#{$current_dir}/Pod", "#{$current_dir}/#{@pod_name}"
208
+ end
209
+
210
+
211
+ def reinitialize_git_repo
212
+ Dir.chdir("#{$current_dir}") do
213
+ `rm -rf .git`
214
+ `git init`
215
+ `git add -A`
216
+ end
217
+
218
+
219
+ end
220
+
221
+ def validate_user_details
222
+ return (user_email.length > 0) && (user_name.length > 0)
223
+ end
224
+
225
+ #----------------------------------------#
226
+
227
+ def user_name
228
+ # (ENV['GIT_COMMITTER_NAME'] || github_user_name || `git config user.name` || `<GITHUB_USERNAME>` ).strip
229
+ (ENV['GIT_COMMITTER_NAME'] || `git config user.name` || `<GITHUB_USERNAME>` ).strip
230
+
231
+ end
232
+
233
+
234
+ def github_user_name
235
+ github_user_name = `security find-internet-password -s github.com | grep acct | sed 's/"acct"<blob>="//g' | sed 's/"//g'`.strip
236
+ is_valid = github_user_name.empty? or github_user_name.include? '@'
237
+ return is_valid ? nil : github_user_name
238
+ end
239
+
240
+ def user_email
241
+ (ENV['GIT_COMMITTER_EMAIL'] || `git config user.email`).strip
242
+ end
243
+
244
+ def year
245
+ Time.now.year.to_s
246
+ end
247
+
248
+ def date
249
+ Time.now.strftime "%m/%d/%Y"
250
+ end
251
+
252
+ def podfile_path
253
+ 'Example/Podfile'
254
+ end
255
+
256
+ #----------------------------------------#
257
+ end
258
+ end