yk_command 0.5.0 → 0.5.1

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/vcs.xml +2 -0
  3. data/.idea/yk_command.iml +6 -6
  4. data/Gemfile.lock +3 -3
  5. data/lib/yk_command/analyze/analyze.rb +4 -0
  6. data/lib/yk_command/bot/wx_bot.rb +0 -10
  7. data/lib/yk_command/module/module_handler.rb +119 -0
  8. data/lib/yk_command/module/template/objc/CategoryHeader.h +1 -1
  9. data/lib/yk_command/module/template/objc/RouterRegister.m +6 -5
  10. data/lib/yk_command/module/template/objc/ServiceRegister.m +1 -1
  11. data/lib/yk_command/module/yk_module.rb +138 -144
  12. data/lib/yk_command/project/YKProjectTemplate/.gitignore +37 -0
  13. data/lib/yk_command/project/YKProjectTemplate/CODE_OF_CONDUCT.md +40 -0
  14. data/lib/yk_command/project/YKProjectTemplate/LICENSE +21 -0
  15. data/lib/yk_command/project/YKProjectTemplate/NAME-osx.podspec +43 -0
  16. data/lib/yk_command/project/YKProjectTemplate/NAME.podspec +27 -0
  17. data/lib/yk_command/project/YKProjectTemplate/POD_LICENSE +19 -0
  18. data/lib/yk_command/project/YKProjectTemplate/POD_README.md +29 -0
  19. data/lib/yk_command/project/YKProjectTemplate/Pod/Assets/.gitkeep +0 -0
  20. data/lib/yk_command/project/YKProjectTemplate/Pod/Classes/.gitkeep +0 -0
  21. data/lib/yk_command/project/YKProjectTemplate/README.md +22 -0
  22. data/lib/yk_command/project/YKProjectTemplate/configure +12 -0
  23. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/Base.lproj/LaunchScreen.storyboard +31 -0
  24. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/Base.lproj/Main.storyboard +79 -0
  25. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/CPDAppDelegate.h +15 -0
  26. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/CPDAppDelegate.m +46 -0
  27. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/CPDViewController.h +13 -0
  28. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/CPDViewController.m +60 -0
  29. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +98 -0
  30. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/PROJECT-Info.plist +49 -0
  31. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/PROJECT-Prefix.pch +16 -0
  32. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/en.lproj/InfoPlist.strings +2 -0
  33. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT/main.m +17 -0
  34. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT.xcodeproj/project.pbxproj +500 -0
  35. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  36. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +101 -0
  37. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/Podfile +19 -0
  38. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/Tests/Tests-Info.plist +22 -0
  39. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/Tests/Tests-Prefix.pch +7 -0
  40. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/Tests/Tests.m +9 -0
  41. data/lib/yk_command/project/YKProjectTemplate/templates/ios/Example/Tests/en.lproj/InfoPlist.strings +2 -0
  42. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/AppDelegate.swift +26 -0
  43. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/Assets.xcassets/AppIcon.appiconset/Contents.json +58 -0
  44. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/Base.lproj/Main.storyboard +717 -0
  45. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/Info.plist +30 -0
  46. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/PROJECT.entitlements +10 -0
  47. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT/ViewController.swift +27 -0
  48. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT.xcodeproj/project.pbxproj +444 -0
  49. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  50. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +103 -0
  51. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/Podfile +11 -0
  52. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/Tests/Info.plist +22 -0
  53. data/lib/yk_command/project/YKProjectTemplate/templates/macos-swift/Example/Tests/Tests.swift +1 -0
  54. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/AppDelegate.swift +46 -0
  55. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/Base.lproj/LaunchScreen.xib +46 -0
  56. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/Base.lproj/Main.storyboard +86 -0
  57. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
  58. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/Info.plist +39 -0
  59. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT/ViewController.swift +37 -0
  60. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT.xcodeproj/project.pbxproj +468 -0
  61. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  62. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/PROJECT.xcodeproj/xcshareddata/xcschemes/PROJECT.xcscheme +117 -0
  63. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/Podfile +20 -0
  64. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/Tests/Info.plist +24 -0
  65. data/lib/yk_command/project/YKProjectTemplate/templates/swift/Example/Tests/Tests.swift +1 -0
  66. data/lib/yk_command/project/setup/ConfigureMacOSSwift.rb +46 -0
  67. data/lib/yk_command/project/setup/ConfigureSwift.rb +40 -0
  68. data/lib/yk_command/project/setup/ConfigureiOS.rb +107 -0
  69. data/lib/yk_command/project/setup/MessageBank.rb +113 -0
  70. data/lib/yk_command/project/setup/ProjectManipulator.rb +141 -0
  71. data/lib/yk_command/project/setup/TemplateConfigurator.rb +253 -0
  72. data/lib/yk_command/project/test_examples/kiwi.m +36 -0
  73. data/lib/yk_command/project/test_examples/quick.swift +50 -0
  74. data/lib/yk_command/project/test_examples/specta.m +39 -0
  75. data/lib/yk_command/project/test_examples/xctest.m +26 -0
  76. data/lib/yk_command/project/test_examples/xctest.swift +28 -0
  77. data/lib/yk_command/project/yk_project.rb +86 -0
  78. data/lib/yk_command/version.rb +1 -1
  79. data/yk_command.gemspec +2 -1
  80. metadata +76 -11
  81. data/.YKModuleFilesConfig.yml +0 -5
  82. data//345/275/222/346/241/243.zip +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0270360ed964ef12d21ff5a0d2687a78243877286d62e503fc3d9ac4b5378440
4
- data.tar.gz: e34b5d101303ed14d2e1094ba4c2f3ecb49874b38fcd02334738659578bc3f52
3
+ metadata.gz: ee7ba207bd464c7157f889962cca513322a4763d409fdc706caf2d8ce49d21e0
4
+ data.tar.gz: c94c6c49d162b732fd9ef39d6e4cee3d23899dcb9eac8c3a884a0ce07ad675e9
5
5
  SHA512:
6
- metadata.gz: 94df888ee6a59310135cc4f7a04e7c68c42daf597ba3c2ef52bd1ea4e7fea81d1d5e5aed1bae7f627991e57b401ae76ca25a507998858adf3f53c0fc44e77fd0
7
- data.tar.gz: 3a5f3a628a8c726affc50d657b72da0a6b7f46b6b8826349493f0a5f90f822641071814723f8479d48cf2e58ace4d93be5ac376901371f83bee9dc6df997d044
6
+ metadata.gz: 415355f8510cd4e83bc60cf03bac2607e2c746d0793f0ec09bc54be45866fab5d3c4c9a786a9b1d731d32dfcd592d4f342ca79fcf931ce2c78a04df4e13c13f6
7
+ data.tar.gz: 2d7073f479b8d58177b3ea9fda216544521fa914a80caeb4796527558949dac347ad87058274fe13fcc7b51d7ddd284d10fb0c200708ccf8f87bb25410f7dec6
data/.idea/vcs.xml CHANGED
@@ -9,5 +9,7 @@
9
9
  <mapping directory="$PROJECT_DIR$/MerchantHome" vcs="Git" />
10
10
  <mapping directory="$PROJECT_DIR$/SUHome3" vcs="Git" />
11
11
  <mapping directory="$PROJECT_DIR$/SYTHomeModule" vcs="Git" />
12
+ <mapping directory="$PROJECT_DIR$/lib/yk_command/project/temp" vcs="Git" />
13
+ <mapping directory="$PROJECT_DIR$/pod_name" vcs="Git" />
12
14
  </component>
13
15
  </project>
data/.idea/yk_command.iml CHANGED
@@ -52,7 +52,6 @@
52
52
  <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
53
53
  <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
54
54
  <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
55
- <orderEntry type="library" scope="PROVIDED" name="pathname (v0.1.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
56
55
  <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.7, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
57
56
  <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
58
57
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
@@ -68,6 +67,7 @@
68
67
  <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.17.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
69
68
  <orderEntry type="library" scope="PROVIDED" name="ruby-macho (v2.5.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
70
69
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
70
+ <orderEntry type="library" scope="PROVIDED" name="rubyzip (v2.3.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
71
71
  <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
72
72
  <orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.4.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
73
73
  <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
@@ -80,21 +80,21 @@
80
80
  <option name="myRootTask">
81
81
  <RakeTaskImpl id="rake">
82
82
  <subtasks>
83
- <RakeTaskImpl description="Build yk_command-0.4.9.gem into the pkg directory" fullCommand="build" id="build" />
83
+ <RakeTaskImpl description="Build yk_command-0.5.0.gem into the pkg directory" fullCommand="build" id="build" />
84
84
  <RakeTaskImpl id="build">
85
85
  <subtasks>
86
- <RakeTaskImpl description="Generate SHA512 checksum if yk_command-0.4.9.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
86
+ <RakeTaskImpl description="Generate SHA512 checksum if yk_command-0.5.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
87
87
  </subtasks>
88
88
  </RakeTaskImpl>
89
89
  <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
90
90
  <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
91
- <RakeTaskImpl description="Build and install yk_command-0.4.9.gem into system gems" fullCommand="install" id="install" />
91
+ <RakeTaskImpl description="Build and install yk_command-0.5.0.gem into system gems" fullCommand="install" id="install" />
92
92
  <RakeTaskImpl id="install">
93
93
  <subtasks>
94
- <RakeTaskImpl description="Build and install yk_command-0.4.9.gem into system gems without network access" fullCommand="install:local" id="local" />
94
+ <RakeTaskImpl description="Build and install yk_command-0.5.0.gem into system gems without network access" fullCommand="install:local" id="local" />
95
95
  </subtasks>
96
96
  </RakeTaskImpl>
97
- <RakeTaskImpl description="Create tag v0.4.9 and build and push yk_command-0.4.9.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
97
+ <RakeTaskImpl description="Create tag v0.5.0 and build and push yk_command-0.5.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
98
98
  <RakeTaskImpl description="" fullCommand="default" id="default" />
99
99
  <RakeTaskImpl description="" fullCommand="release" id="release" />
100
100
  <RakeTaskImpl id="release">
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yk_command (0.5.0)
4
+ yk_command (0.5.1)
5
5
  bundler
6
6
  cocoapods
7
7
  cocoapods-core
@@ -9,7 +9,7 @@ PATH
9
9
  colored2
10
10
  git
11
11
  httparty
12
- pathname (= 0.1.0)
12
+ rubyzip
13
13
  thor
14
14
  wechat_work_webhook
15
15
  xcodeproj
@@ -102,7 +102,6 @@ GEM
102
102
  parallel (1.22.1)
103
103
  parser (3.1.2.0)
104
104
  ast (~> 2.4.1)
105
- pathname (0.1.0)
106
105
  public_suffix (4.0.7)
107
106
  rainbow (3.1.1)
108
107
  rake (13.0.6)
@@ -135,6 +134,7 @@ GEM
135
134
  parser (>= 3.1.1.0)
136
135
  ruby-macho (2.5.1)
137
136
  ruby-progressbar (1.11.0)
137
+ rubyzip (2.3.0)
138
138
  thor (1.2.1)
139
139
  typhoeus (1.4.0)
140
140
  ethon (>= 0.9.0)
@@ -106,6 +106,10 @@ module YkCommand
106
106
  say "failed :#{failed_count},#{failed_name_list}", :red
107
107
  say "skip :#{skip_count}", :yellow
108
108
 
109
+ # bot_message path
110
+ end
111
+
112
+ def bot_message(path)
109
113
  bot_config_file_path = "#{path}/#{BOT_CONFIG_FILE}"
110
114
  bot_config = File.exist?(bot_config_file_path) ? YAML.load_file(bot_config_file_path) : nil
111
115
  if bot_config
@@ -35,10 +35,7 @@ module YkCommand
35
35
  def send_news_to_group
36
36
  require 'wechat_work_webhook'
37
37
 
38
- # wechat.text('test', ['@all'])
39
- #
40
38
 
41
- # <font color=\"DodgerBlue\"></font>
42
39
  time = Time.new
43
40
  time_s = "#{time.year}-#{time.month}-#{time.day} "
44
41
 
@@ -48,13 +45,6 @@ module YkCommand
48
45
  "url" => @project_url,
49
46
  "picurl" => @project_cover_image_url
50
47
  }])
51
-
52
- # wechat.image('test.png')
53
- #
54
- # wechat.media(wechat.upload_media('test.csv')['media_id'])
55
- #
56
- # wechat.file('test.csv')
57
-
58
48
  end
59
49
 
60
50
  def result_item_list_string(list, level)
@@ -0,0 +1,119 @@
1
+ module YkCommand
2
+
3
+ class ModuleHandler < Thor
4
+ include Thor::Actions
5
+
6
+ def initialize(args = [], options = {}, config = {})
7
+
8
+ super
9
+ @final_path = config[:final_path]
10
+ @name = config[:name]
11
+ @project = config[:project]
12
+ @prefixed_module = config[:prefixed_module]
13
+ @author = config[:author]
14
+ @date = config[:date]
15
+
16
+ end
17
+
18
+ no_commands do
19
+ def yk_module_folders
20
+ class_folder_path = "#{@final_path}/#{@name}/Classes"
21
+
22
+ first_level_folders = %w[Public Private]
23
+
24
+ # public_level_folders = ['Register']
25
+ # public_level_folders.each do |folder|
26
+ # path = "#{class_folder_path}/Public/#{folder}"
27
+ # empty_directory path
28
+ # end
29
+
30
+ private_level_folders = %w[Business Category Vendor Tools]
31
+
32
+ first_level_folders.each do |folder|
33
+ path = "#{class_folder_path}/#{folder}"
34
+ empty_directory path
35
+ end
36
+
37
+ private_level_folders.each do |folder|
38
+ path = "#{class_folder_path}/Private/#{folder}"
39
+ empty_directory path
40
+ end
41
+ end
42
+
43
+ YkCommand::ModuleHandler.source_root(File.dirname(__FILE__))
44
+
45
+ def yk_template_files
46
+
47
+ register_path = "#{@final_path}/#{@name}/Classes/Private/Register"
48
+ registger = {
49
+ 'RouterRegister.h' => 'RouterRegister',
50
+ 'RouterRegister.m' => 'RouterRegister',
51
+ 'ServiceRegister.h' => 'ServiceRegister',
52
+ 'ServiceRegister.m' => 'ServiceRegister'
53
+ }
54
+
55
+ registger.each do |file_name, _folder|
56
+ final_file = "#{register_path}/#{@prefixed_module}#{file_name}"
57
+ template "#{__dir__}/template/objc/#{file_name}", final_file
58
+ end
59
+
60
+ public_folder_path = "#{@final_path}/#{@name}/Classes/Public"
61
+
62
+ template_code_filename = ['ServiceProtocol.h', 'RouterDefine.h']
63
+ template_code_filename.each do |file_name|
64
+ final_file = "#{public_folder_path}/#{@prefixed_module}#{file_name}"
65
+ source = "#{__dir__}/template/objc/#{file_name}"
66
+ template source, final_file
67
+ end
68
+
69
+ swift_template_code_filename = ['RouterDefine.swift']
70
+ swift_template_code_filename.each do |file_name|
71
+ final_file = "#{public_folder_path}/#{@prefixed_module}_Swift_#{file_name}"
72
+ source = "#{__dir__}/template/swift/#{file_name}"
73
+ template source, final_file
74
+ end
75
+
76
+ private_folder_path = "#{@final_path}/#{@name}/Classes/Private"
77
+ #pch file
78
+ # pch_file_name = "PrefixHeader.pch"
79
+ # final_file = "#{private_folder_path}/#{@prefixed_module}#{pch_file_name}"
80
+ # source = "#{__dir__}/template/objc/#{pch_file_name}"
81
+ # template source, final_file
82
+
83
+ private_level_folder_files = {
84
+ 'PrefixHeader.pch' => 'Business',
85
+ 'CategoryHeader.h' => 'Category',
86
+ 'ToolsHeader.h' => 'Tools',
87
+ 'vendorHeader.h' => 'Vendor'
88
+ }
89
+
90
+ private_level_folder_files.each do |file_name, folder|
91
+ final_prefix = @prefixed_module
92
+ if file_name == 'PrefixHeader.pch'
93
+ final_prefix = @name
94
+ end
95
+
96
+ final_file = "#{private_folder_path}/#{folder}/#{final_prefix}#{file_name}"
97
+ source = "#{__dir__}/template/objc/#{file_name}"
98
+ template source, final_file
99
+ end
100
+
101
+ business_demo_path = "#{@final_path}/#{@name}/Classes/Private/Business"
102
+ demo_replace_file = ['DemoViewController.h', 'DemoViewController.m', 'DemoViewModel.h', 'DemoViewModel.m']
103
+ demo_replace_file.each do |file_name|
104
+ final_file = "#{business_demo_path}/Demo/#{@prefixed_module}#{file_name}"
105
+ source = "#{__dir__}/template/objc/demo/#{file_name}"
106
+ template source, final_file
107
+ end
108
+
109
+ Dir.chdir("#{@final_path}/Example") do
110
+ system 'pod install'
111
+ system "open './#{@name}.xcworkspace'"
112
+ end
113
+ end
114
+
115
+ end
116
+ end
117
+
118
+ end
119
+
@@ -9,6 +9,6 @@
9
9
  #ifndef <%= @prefixed_module %>CategoryHeader_h
10
10
  #define <%= @prefixed_module %>CategoryHeader_h
11
11
 
12
- #import <MTCategoryComponent/MTCategoryComponentHeader.h>
12
+ #import <YKCategoryComponent/YKCategoriesComponentHeader.h>
13
13
 
14
14
  #endif /* <%= @prefixed_module %>CategoryHeader_h */
@@ -8,25 +8,26 @@
8
8
 
9
9
  #import "<%= @prefixed_module %>RouterRegister.h"
10
10
 
11
- #import <MTBaseKit/MTBaseKitHeader.h>
12
- `
11
+ #import <YKRouterComponent/YKRouterComponentHeader.h>
12
+
13
13
  #import "<%= @prefixed_module %>RouterDefine.h"
14
14
 
15
15
  #import "<%= @prefixed_module %>DemoViewController.h"
16
16
 
17
- #import <<%= @module %>/<%= @module %>-Swift.h>
17
+ #import <<%= @name %>/<%= @name %>-Swift.h>
18
18
 
19
19
  @implementation <%= @prefixed_module %>RouterRegister
20
20
 
21
21
  @YKRouterRegister() {
22
22
 
23
- [[MTRouterComponent shareInstance] registerUrlPartterns:kDemoRouterString error:nil action:^(MTRouterUrlRequest * _Nonnull urlRequest, MTRouterUrlCompletion _Nonnull completetion) {
23
+ [[YKRouterComponent shareInstance] ykRegisterUrlPartterns:kDemoRouterString error:nil action:^(YKRouterUrlRequest * _Nonnull urlRequest, YKRouterUrlCompletion _Nonnull completetion) {
24
24
 
25
25
  <%= @prefixed_module %>DemoViewController *vc = [[<%= @prefixed_module %>DemoViewController alloc] init];
26
- [[UIViewController mt_topViewController].navigationController pushViewController:vc animated:YES];
26
+ [[UIViewController yk_topViewController].navigationController pushViewController:vc animated:YES];
27
27
 
28
28
  }];
29
29
 
30
30
  }
31
31
 
32
+
32
33
  @end
@@ -7,7 +7,7 @@
7
7
  //
8
8
 
9
9
  #import "<%= @prefixed_module %>ServiceRegister.h"
10
- #import <MTBaseKit/MTBaseKitHeader.h>
10
+ #import <YKModuleServiceComponent/YKModuleServiceComponentHeader.h>
11
11
 
12
12
  #import "<%= @prefixed_module %>ServiceProtocol.h"
13
13
 
@@ -3,12 +3,15 @@ require 'colored'
3
3
  require 'fileutils'
4
4
  require 'psych'
5
5
  require 'yaml'
6
- require 'thor/actions'
6
+ require 'thor'
7
7
 
8
+ require 'yk_command/project/yk_project'
9
+
10
+ require_relative 'module_handler'
8
11
 
9
12
  module YkCommand
10
13
 
11
- CONFIG_FILE = '.YKModuleFilesConfig.yml'.freeze
14
+ MODULE_CONFIG_FILE = '.YKModuleFilesConfig.yml'.freeze
12
15
 
13
16
  class YkModule < Thor
14
17
  include Thor::Actions
@@ -34,193 +37,184 @@ module YkCommand
34
37
  if File.exist?(@final_path.to_s)
35
38
  say "#{@final_path} 已存在:", :red
36
39
  else
37
- prepare_folder
38
- if File.exist?("#{@final_path}/configure")
39
- system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
40
- else
41
- say 'Template does not have a configure file', :red
42
- end
43
- yk_module_folders
44
- yk_template_files
45
- end
46
- end
47
-
48
- def create(path = nil)
40
+ construct_project path
49
41
 
50
- path = Dir.pwd if path.nil?
51
- say '模块名:', :green
52
- config_file_path = "#{path}/#{CONFIG_FILE}"
53
- config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
54
- input_name = ask("Project name [#{config[:project]}] ?")
55
42
 
56
- if input_name != ''
57
- @name = input_name
58
- config[:project] = input_name if input_name != config[:project]
59
- else
60
- @name = config[:project]
61
43
  end
44
+ end
62
45
 
63
- File.open(config_file_path, 'w') do |f|
64
- f.write config.to_yaml
65
- end
66
46
 
67
- @final_path = "#{path}/#{@name}"
47
+ def read_user_input(desc,ask_prom,now_value,limit)
48
+ item = ''
49
+ say "#{desc}:", :green
68
50
 
69
- if File.exist?(@final_path.to_s)
70
- say "#{@final_path} 已存在:", :red
71
- else
72
- prepare_folder
73
- read_config(path)
51
+ input = ask("#{ask_prom} [#{now_value}] ?")
74
52
 
75
- if File.exist?("#{@final_path}/configure")
76
- system("#{@final_path}/configure", @name, @lang, @class_prefix, *@additional_args)
53
+ if input != ''
54
+ item = input
55
+ else
56
+ if now_value!=nil && now_value != ''
57
+ item = now_value
77
58
  else
78
- say 'Template does not have a configure file', :red
59
+ say "请正确填写#{desc}",:red
60
+ item = read_user_input(desc,ask_prom,now_value,limit)
79
61
  end
80
62
 
81
- yk_module_folders
82
- yk_template_files
83
-
84
63
  end
64
+ item
85
65
  end
86
66
 
87
- def read_config(path)
88
- config_file_path = "#{path}/#{CONFIG_FILE}"
67
+
68
+ def create(path = nil)
69
+
70
+ path = Dir.pwd if path.nil?
71
+
72
+ config_file_path = "#{path}/#{MODULE_CONFIG_FILE}"
73
+
89
74
  config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
90
75
 
91
- project = @name
92
- say '语言:', :green
93
- language = ask("Project language [#{config[:language]}] ?", limited_to: ['objc', 'swift', ''])
94
- say '类名前缀:', :green
95
- class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
96
- say '文件作者:', :green
97
- author = ask("Author [#{config[:author]}] ?")
76
+ project = read_user_input('模块名',"Project name",config[:project],nil )
77
+ config[:project] = project
78
+
79
+ language = read_user_input('语言',"Project language",config[:language], ['objc', 'swift', ''] )
80
+ config[:language] = language
98
81
 
99
- config[:project] = project.empty? ? config[:project] || '' : project
100
- config[:language] = language.empty? ? config[:language] || 'objc' : language
101
- config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
102
- config[:author] = author.empty? ? config[:author] || '' : author
82
+ class_prefix = read_user_input('类名前缀',"Class prefix",config[:class_prefix],nil )
83
+ config[:class_prefix] = class_prefix
103
84
 
85
+ author = read_user_input('文件作者',"Author",config[:author],nil)
86
+ config[:author] = author
87
+
88
+ # Dir.chdir(path)
104
89
  File.open(config_file_path, 'w') do |f|
105
90
  f.write config.to_yaml
106
- # f.write YAML.to_yaml(config)
107
91
  end
108
92
 
109
- @module = @name
93
+ @name = config[:project]
110
94
  @class_prefix = config[:class_prefix]
111
- @prefixed_module = config[:class_prefix] + @module
95
+ @prefixed_module = config[:class_prefix] + @name
112
96
  @project = config[:project]
113
97
  @author = config[:author]
114
98
  @date = Time.now.strftime('%d/%m/%y')
115
99
  @lang = config[:language]
116
- end
117
100
 
118
- def prepare_folder
119
- host_a = 'yeah'
120
- host_b = 'ka'
121
- template_repo_url = "http://gitlab.#{host_a}#{host_b}.com/App/iOS/YKComponents/YKProjectTemplate.git"
122
- system("git clone #{template_repo_url} #{@final_path}")
123
101
 
124
- # FileUtils.remove_dir(@final_path, true)
125
- # FileUtils.cp_r('/Users/imacn24/Documents/dev/YKProjectTemplate', @final_path)
126
- # FileUtils.remove_dir("#{@final_path}/.git", true)
127
- end
102
+ construct_project path
128
103
 
129
- def yk_module_folders
130
- class_folder_path = "#{@final_path}/#{@name}/Classes"
104
+ end
131
105
 
132
- first_level_folders = %w[Public Private]
106
+ def construct_project(path)
107
+ final_path = "#{path}/#{@name}"
133
108
 
134
- # public_level_folders = ['Register']
135
- # public_level_folders.each do |folder|
136
- # path = "#{class_folder_path}/Public/#{folder}"
137
- # empty_directory path
138
- # end
109
+ if File.exist?(final_path.to_s)
110
+ say "#{final_path} 已存在:", :red
111
+ else
139
112
 
140
- private_level_folders = %w[Business Category Vendor Tools]
113
+ YkProject.new.prepare_project(@name,@platform,@class_prefix,@author,path)
114
+ config = {}
115
+ config[:final_path] = final_path
116
+ config[:name] = @name
117
+ config[:project] = @project
118
+ config[:prefixed_module] = @prefixed_module
119
+ config[:author] = @author
120
+ config[:date] = @date
141
121
 
142
- first_level_folders.each do |folder|
143
- path = "#{class_folder_path}/#{folder}"
144
- empty_directory path
145
- end
122
+ file_handler = ModuleHandler.new([] ,[] ,config)
146
123
 
147
- private_level_folders.each do |folder|
148
- path = "#{class_folder_path}/Private/#{folder}"
149
- empty_directory path
150
- end
151
- end
124
+ file_handler.yk_module_folders
125
+ file_handler.yk_template_files
152
126
 
127
+ end
153
128
 
154
- YkCommand::YkModule.source_root(File.dirname(__FILE__))
155
- def yk_template_files
129
+ #
130
+ #
131
+ #
132
+ # config = {}
133
+ # if File.exist?(config_file_path)
134
+ #
135
+ # config = YAML.load_file(config_file_path)
136
+ # name = read_user_input('模块名',"Project name",config)
137
+ #
138
+ # else
139
+
140
+
141
+
142
+
143
+ # say '模块名:', :green
144
+ # input_name = ask("Project name [#{config[:project]}] ?")
145
+ # if input_name != ''
146
+ # config[:project] = input_name if input_name != config[:project]
147
+ # else
148
+ # say '请正确填写模块名',:red
149
+ # end
150
+ #
151
+ # say '语言:', :green
152
+ # language = ask("Project language [#{config[:language]}] ?", limited_to: ['objc', 'swift', ''])
153
+ # say '类名前缀:', :green
154
+ # class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
155
+ # say '文件作者:', :green
156
+ # author = ask("Author [#{config[:author]}] ?")
157
+ #
158
+ # config[:project] = project.empty? ? config[:project] || '' : project
159
+ # config[:language] = language.empty? ? config[:language] || 'objc' : language
160
+ # config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
161
+ # config[:author] = author.empty? ? config[:author] || '' : author
156
162
 
157
- register_path = "#{@final_path}/#{@name}/Classes/Private/Register"
158
- registger = {
159
- 'RouterRegister.h' => 'RouterRegister',
160
- 'RouterRegister.m' => 'RouterRegister',
161
- 'ServiceRegister.h' => 'ServiceRegister',
162
- 'ServiceRegister.m' => 'ServiceRegister'
163
- }
164
163
 
165
- registger.each do |file_name, _folder|
166
- final_file = "#{register_path}/#{@prefixed_module}#{file_name}"
167
- template "#{__dir__}/template/objc/#{file_name}", final_file
168
- end
164
+ # end
169
165
 
170
- public_folder_path = "#{@final_path}/#{@name}/Classes/Public"
166
+ #
167
+ #
168
+ # #读取模块创建的配置文件
171
169
 
172
- template_code_filename = ['ServiceProtocol.h', 'RouterDefine.h']
173
- template_code_filename.each do |file_name|
174
- final_file = "#{public_folder_path}/#{@prefixed_module}#{file_name}"
175
- source = "#{__dir__}/template/objc/#{file_name}"
176
- template source, final_file
177
- end
170
+ #
178
171
 
179
- swift_template_code_filename = ['RouterDefine.swift']
180
- swift_template_code_filename.each do |file_name|
181
- final_file = "#{public_folder_path}/#{@prefixed_module}_Swift_#{file_name}"
182
- source = "#{__dir__}/template/swift/#{file_name}"
183
- template source, final_file
184
- end
172
+ end
185
173
 
186
- private_folder_path = "#{@final_path}/#{@name}/Classes/Private"
187
- #pch file
188
- # pch_file_name = "PrefixHeader.pch"
189
- # final_file = "#{private_folder_path}/#{@prefixed_module}#{pch_file_name}"
190
- # source = "#{__dir__}/template/objc/#{pch_file_name}"
191
- # template source, final_file
192
-
193
- private_level_folder_files = {
194
- 'PrefixHeader.pch' => 'Business',
195
- 'CategoryHeader.h' => 'Category',
196
- 'ToolsHeader.h' => 'Tools',
197
- 'vendorHeader.h' => 'Vendor'
198
- }
199
-
200
- private_level_folder_files.each do |file_name, folder|
201
- final_prefix = @prefixed_module
202
- if file_name == 'PrefixHeader.pch'
203
- final_prefix = @module
204
- end
174
+ # def read_config(path)
175
+ # config_file_path = "#{path}/#{CONFIG_FILE}"
176
+ # config = File.exist?(config_file_path) ? YAML.load_file(config_file_path) : {}
177
+ #
178
+ # project = @name
179
+ # say '语言:', :green
180
+ # language = ask("Project language [#{config[:language]}] ?", limited_to: ['objc', 'swift', ''])
181
+ # say '类名前缀:', :green
182
+ # class_prefix = ask("Class prefix [#{config[:class_prefix]}] ?")
183
+ # say '文件作者:', :green
184
+ # author = ask("Author [#{config[:author]}] ?")
185
+ #
186
+ # config[:project] = project.empty? ? config[:project] || '' : project
187
+ # config[:language] = language.empty? ? config[:language] || 'objc' : language
188
+ # config[:class_prefix] = class_prefix.empty? ? config[:class_prefix] || '' : class_prefix
189
+ # config[:author] = author.empty? ? config[:author] || '' : author
190
+ #
191
+ # File.open(config_file_path, 'w') do |f|
192
+ # f.write config.to_yaml
193
+ # # f.write YAML.to_yaml(config)
194
+ # end
195
+ #
196
+ # @module = @name
197
+ # @class_prefix = config[:class_prefix]
198
+ # @prefixed_module = config[:class_prefix] + @module
199
+ # @project = config[:project]
200
+ # @author = config[:author]
201
+ # @date = Time.now.strftime('%d/%m/%y')
202
+ # @lang = config[:language]
203
+ # end
204
+
205
+ # def prepare_folder
206
+
207
+ # host_a = 'yeah'
208
+ # host_b = 'ka'
209
+ # template_repo_url = "http://gitlab.#{host_a}#{host_b}.com/App/iOS/YKComponents/YKProjectTemplate.git"
210
+ # system("git clone #{template_repo_url} #{@final_path}")
205
211
 
206
- final_file = "#{private_folder_path}/#{folder}/#{final_prefix}#{file_name}"
207
- source = "#{__dir__}/template/objc/#{file_name}"
208
- template source, final_file
209
- end
212
+ # FileUtils.remove_dir(@final_path, true)
213
+ # FileUtils.cp_r('/Users/imacn24/Documents/dev/YKProjectTemplate', @final_path)
214
+ # FileUtils.remove_dir("#{@final_path}/.git", true)
215
+ # end
210
216
 
211
- business_demo_path = "#{@final_path}/#{@name}/Classes/Private/Business"
212
- demo_replace_file = ['DemoViewController.h', 'DemoViewController.m', 'DemoViewModel.h', 'DemoViewModel.m']
213
- demo_replace_file.each do |file_name|
214
- final_file = "#{business_demo_path}/Demo/#{@prefixed_module}#{file_name}"
215
- source = "#{__dir__}/template/objc/demo/#{file_name}"
216
- template source, final_file
217
- end
218
217
 
219
- Dir.chdir("#{@final_path}/Example") do
220
- system 'pod install'
221
- system "open './#{@name}.xcworkspace'"
222
- end
223
- end
224
218
  end
225
219
  end
226
220
  end