cocoapods-mPaaS 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/lib/cocoapods-mPaaS/baselineTools.rb +493 -0
  3. data/lib/cocoapods-mPaaS/checkUpdateTools.rb +42 -0
  4. data/lib/cocoapods-mPaaS/cocoapods_hook.rb +929 -0
  5. data/lib/cocoapods-mPaaS/command/mPaaS.rb +44 -0
  6. data/lib/cocoapods-mPaaS/command/mpaas/dev.rb +17 -0
  7. data/lib/cocoapods-mPaaS/command/mpaas/info.rb +170 -0
  8. data/lib/cocoapods-mPaaS/command/mpaas/init.rb +112 -0
  9. data/lib/cocoapods-mPaaS/command/mpaas/local_command.rb +49 -0
  10. data/lib/cocoapods-mPaaS/command/mpaas/open.rb +17 -0
  11. data/lib/cocoapods-mPaaS/command/mpaas/update.rb +223 -0
  12. data/lib/cocoapods-mPaaS/command/mpaas/version.rb +32 -0
  13. data/lib/cocoapods-mPaaS/command.rb +1 -0
  14. data/lib/cocoapods-mPaaS/dsl.rb +498 -0
  15. data/lib/cocoapods-mPaaS/gem_version.rb +5 -0
  16. data/lib/cocoapods-mPaaS/installNew.rb +303 -0
  17. data/lib/cocoapods-mPaaS/locales/en.yml +140 -0
  18. data/lib/cocoapods-mPaaS/locales/zh-Hans.yml +144 -0
  19. data/lib/cocoapods-mPaaS/localization.rb +238 -0
  20. data/lib/cocoapods-mPaaS/logTools.rb +67 -0
  21. data/lib/cocoapods-mPaaS/mPaaSPodfile.rb +117 -0
  22. data/lib/cocoapods-mPaaS/module_config.rb +298 -0
  23. data/lib/cocoapods-mPaaS/podfileTools.rb +48 -0
  24. data/lib/cocoapods-mPaaS/post_install_hook_processor.rb +61 -0
  25. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.h +13 -0
  26. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/DemoViewController.m +43 -0
  27. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/Contents.json +6 -0
  28. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/Contents.json +22 -0
  29. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@2x.png +0 -0
  30. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery.imageset/TabBar_Discovery@3x.png +0 -0
  31. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/Contents.json +22 -0
  32. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@2x.png +0 -0
  33. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Discovery_Sel.imageset/TabBar_Discovery_Sel@3x.png +0 -0
  34. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/Contents.json +22 -0
  35. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@2x.png +0 -0
  36. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends.imageset/TabBar_Friends@3x.png +0 -0
  37. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/Contents.json +22 -0
  38. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@2x.png +0 -0
  39. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_Friends_Sel.imageset/TabBar_Friends_Sel@3x.png +0 -0
  40. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/Contents.json +22 -0
  41. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@2x.png +0 -0
  42. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar.imageset/icon30-line@3x.png +0 -0
  43. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/Contents.json +22 -0
  44. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@2x.png +0 -0
  45. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_HomeBar_Sel.imageset/icon30@3x.png +0 -0
  46. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/Contents.json +22 -0
  47. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@2x.png +0 -0
  48. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService.imageset/TabBar_PublicService@3x.png +0 -0
  49. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/Contents.json +22 -0
  50. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@2x.png +0 -0
  51. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/Images_mPaaS.xcassets/TabBar_PublicService_Sel.imageset/TabBar_PublicService_Sel@3x.png +0 -0
  52. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.h +10 -0
  53. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPAppDelegate.m +43 -0
  54. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.h +8 -0
  55. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerController.m +135 -0
  56. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.h +10 -0
  57. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLauncherAppDelegate.m +43 -0
  58. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.h +16 -0
  59. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerLeftView.m +86 -0
  60. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.h +21 -0
  61. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPDrawerMainViewController.m +104 -0
  62. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.h +10 -0
  63. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPLauncherAppDelegate.m +91 -0
  64. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.h +8 -0
  65. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationController.m +25 -0
  66. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.h +10 -0
  67. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPNavigationLauncherAppDelegate.m +43 -0
  68. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.h +8 -0
  69. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPTabBarController.m +27 -0
  70. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.h +8 -0
  71. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MPViewController.m +19 -0
  72. data/lib/cocoapods-mPaaS/templates/APMobileFramework/AutoConfig/MobileRuntime.plist +26 -0
  73. data/lib/cocoapods-mPaaS/write_info_list_mPaaSApp.rb +125 -0
  74. data/lib/cocoapods-mPaaS/xcode_helper.rb +334 -0
  75. data/lib/cocoapods-mPaaS.rb +41 -0
  76. data/lib/cocoapods_plugin.rb +15 -0
  77. metadata +160 -0
@@ -0,0 +1,44 @@
1
+ module Pod
2
+ class Command
3
+ # This is an example of a cocoapods plugin adding a top-level subcommand
4
+ # to the 'pod' command.
5
+ #
6
+ # You can also create subcommands of existing or new commands. Say you
7
+ # wanted to add a subcommand to `list` to show newly deprecated pods,
8
+ # (e.g. `pod list deprecated`), there are a few things that would need
9
+ # to change.
10
+ #
11
+ # - move this file to `lib/pod/command/list/deprecated.rb` and update
12
+ # the class to exist in the the Pod::Command::List namespace
13
+ # - change this class to extend from `List` instead of `Command`. This
14
+ # tells the plugin system that it is a subcommand of `list`.
15
+ # - edit `lib/cocoapods_plugins.rb` to require this file
16
+ #
17
+ # @todo Create a PR to add your plugin to CocoaPods/cocoapods.org
18
+ # in the `plugins.json` file, once your plugin is released.
19
+ #
20
+ class MPAAS < Command
21
+ self.summary = "cocoapods-mPaaS."
22
+
23
+ self.description = <<-DESC
24
+ cocoapods-mPaaS.
25
+ DESC
26
+
27
+ # self.arguments = 'NAME'
28
+
29
+ # def initialize(argv)
30
+ # @name = argv.shift_argument
31
+ # super
32
+ # end
33
+
34
+ # def validate!
35
+ # super
36
+ # help! 'A Pod name is required.' unless @name
37
+ # end
38
+
39
+ def run
40
+ # UI.puts "Add your implementation for the cocoapods-mPaaS plugin in #{__FILE__}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ module Pod
2
+ class Command
3
+ class MPAAS
4
+ class Dev < MPAAS
5
+ self.summary = "For dev"
6
+
7
+ self.description = <<-DESC
8
+ Dev by mPaaS.
9
+ DESC
10
+
11
+ def run
12
+ LogTools.p_green CocoapodsMpaas::VERSION_DEV
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,170 @@
1
+ require 'cocoapods-mPaaS/mPaaSPodfile'
2
+
3
+ module Pod
4
+ class Command
5
+ class MPAAS
6
+ class Info < MPAAS
7
+ self.summary = "Show the baseline info"
8
+
9
+ self.description = <<-DESC
10
+ baseline by mPaaS.
11
+ DESC
12
+
13
+ def initialize(argv)
14
+ @module_input, @version_input = argv.shift_argument, argv.shift_argument
15
+ @show_pod = argv.flag?("show-pod")
16
+ @only_mPaaS = argv.flag?("only-mPaaS")
17
+ super
18
+ end
19
+
20
+ def show_baseline_info(version, baseline_hash, module_info_hash, removable_options_hash = nil, optional_frameworks_hash = nil, options_hash = nil)
21
+ LogTools.p ""
22
+ LogTools.p_red version
23
+
24
+ # 反查:哪些模块是别人的可选依赖(模块名 → 父模块名列表)
25
+ optional_of = {}
26
+ if options_hash
27
+ options_hash.each do |parent_name, opt_names|
28
+ opt_names.each do |opt_name|
29
+ optional_of[opt_name] ||= []
30
+ optional_of[opt_name] << parent_name
31
+ end
32
+ end
33
+ end
34
+
35
+ baseline_hash.each do |name, dependencies_hash|
36
+ if @module_input && !name.downcase.include?(@module_input.downcase)
37
+ next
38
+ end
39
+
40
+ LogTools.p_green "mPaaS_pod \"#{name}\", \"#{version}\""
41
+
42
+ if module_info_hash && module_info_hash[name]
43
+ info = module_info_hash[name]
44
+ LogTools.p_yellow "# #{info["title"]};#{info["description"]};#{info["releaseNote"]}"
45
+ else
46
+ LogTools.p_yellow "# " + BaselineTools.getModuleInfoByName(name, version)
47
+ end
48
+
49
+ # 标注当前模块可移除的可选子模块
50
+ if removable_options_hash && removable_options_hash[name]
51
+ removable = removable_options_hash[name]
52
+ LogTools.p_yellow "# removable modules: #{removable.join(', ')}"
53
+ end
54
+
55
+ # 标注当前模块本身是哪些父模块的可选依赖
56
+ if optional_of[name]
57
+ LogTools.p_yellow "# removable by: #{optional_of[name].join(', ')}"
58
+ end
59
+
60
+ if @only_mPaaS
61
+ LogTools.p ""
62
+ next
63
+ end
64
+
65
+ # 构建"可被移除" frameworks 集合(当前模块本身是别人的可选依赖时,它的直接 frameworks)
66
+ removable_by_pods = Set.new
67
+ if optional_of[name] && optional_frameworks_hash && optional_frameworks_hash[name]
68
+ optional_frameworks_hash[name].each { |fw| removable_by_pods.add(fw) }
69
+ end
70
+
71
+ # 构建"可移除" frameworks 集合(当前模块的可选子模块的直接 frameworks)
72
+ removable_pods = Set.new
73
+ if removable_options_hash && removable_options_hash[name] && optional_frameworks_hash
74
+ removable_options_hash[name].each do |opt_name|
75
+ if optional_frameworks_hash[opt_name]
76
+ optional_frameworks_hash[opt_name].each { |fw| removable_pods.add(fw) }
77
+ end
78
+ end
79
+ end
80
+
81
+ dependencies_hash.each do |pod_name, pod_version|
82
+ if removable_by_pods.include?(pod_name)
83
+ LogTools.p "pod \"#{pod_name}\", \"#{pod_version}\" # [removable by parent]"
84
+ elsif removable_pods.include?(pod_name)
85
+ LogTools.p "pod \"#{pod_name}\", \"#{pod_version}\" # [removable]"
86
+ else
87
+ LogTools.p "pod \"#{pod_name}\", \"#{pod_version}\""
88
+ end
89
+ end
90
+
91
+ LogTools.p ""
92
+ end
93
+ end
94
+
95
+ def run
96
+ if @show_pod
97
+ project_dir = Dir::pwd
98
+ podfile_path = File.join(project_dir, "Podfile")
99
+ podfile = Pod::Podfile.from_file(podfile_path)
100
+ podfile.dependencies.each do |dependency|
101
+ LogTools.p_green dependency.to_s
102
+ end
103
+ elsif !@version_input
104
+ podfile_path = File.join(Dir::pwd, "Podfile")
105
+ if File.exist?(podfile_path)
106
+ mpaas_podfile = MPaaSPodfile.new
107
+ mpaas_podfile.run(podfile_path)
108
+
109
+ if mpaas_podfile.localContentJsonPath
110
+ abs_path = File.expand_path(mpaas_podfile.localContentJsonPath, Dir::pwd)
111
+ if File.exist?(abs_path)
112
+ content_hash = JSON.parse(File.read(abs_path))
113
+ version = content_hash["baseline"] || "unknown"
114
+ modules_hash = content_hash["modules"] || content_hash
115
+ module_info_hash = content_hash["module_info"]
116
+ removable_options_hash = content_hash["removable_options"]
117
+ optional_frameworks_hash = content_hash["optional_frameworks"]
118
+ options_hash = content_hash["options"]
119
+ show_baseline_info(version, modules_hash, module_info_hash, removable_options_hash, optional_frameworks_hash, options_hash)
120
+ return
121
+ else
122
+ LogTools.p_yellow "Local content.json not found at: #{abs_path}, falling back..."
123
+ end
124
+ end
125
+ end
126
+
127
+ baseline_file_path = File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline")
128
+ if File::exist?(baseline_file_path)
129
+ Dir::foreach(baseline_file_path) do |version|
130
+ baseline_filepath = File.join(baseline_file_path, version, "content.json")
131
+ unless File::exist?(baseline_filepath)
132
+ next
133
+ end
134
+ content_hash = BaselineTools.getContentFileByVersion(version)
135
+ baseline_hash = BaselineTools.getBaselineByVersion(version)
136
+ removable_options_hash = content_hash["removable_options"]
137
+ optional_frameworks_hash = content_hash["optional_frameworks"]
138
+ options_hash = content_hash["options"]
139
+ show_baseline_info(version, baseline_hash, nil, removable_options_hash, optional_frameworks_hash, options_hash)
140
+ end
141
+ else
142
+ LogTools.p_red "No baseline file found !!! Check the path : #{baseline_file_path} "
143
+ end
144
+ else
145
+ baseline_file_path = File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline")
146
+ if File::exist?(baseline_file_path)
147
+ Dir::foreach(baseline_file_path) do |version|
148
+ if version != @version_input
149
+ next
150
+ end
151
+ baseline_filepath = File.join(baseline_file_path, version, "content.json")
152
+ unless File::exist?(baseline_filepath)
153
+ next
154
+ end
155
+ content_hash = BaselineTools.getContentFileByVersion(version)
156
+ baseline_hash = BaselineTools.getBaselineByVersion(version)
157
+ removable_options_hash = content_hash["removable_options"]
158
+ optional_frameworks_hash = content_hash["optional_frameworks"]
159
+ options_hash = content_hash["options"]
160
+ show_baseline_info(version, baseline_hash, nil, removable_options_hash, optional_frameworks_hash, options_hash)
161
+ end
162
+ else
163
+ LogTools.p_red "No baseline file found !!! Check the path : #{baseline_file_path} "
164
+ end
165
+ end
166
+ end
167
+ end
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,112 @@
1
+ require_relative '../../localization' # 确保引入了本地化模块
2
+
3
+ module Pod
4
+ class Command
5
+ class MPAAS
6
+ class Init < MPAAS
7
+ PLUGIN = 'plugin "cocoapods-mPaaS"'
8
+ self.summary = "Init using mPaaS."
9
+
10
+ self.description = <<-DESC
11
+ Add by mPaaS.
12
+ DESC
13
+
14
+ def self.options
15
+ [
16
+ ['--all-targets', 'Configure mPaaS for all targets.'],
17
+ ['--repo-url=URL', 'Custom podspec repo URL (default: gitee mPaaS repo).']
18
+ ].concat(super)
19
+ end
20
+
21
+ def initialize(argv)
22
+ @all_targets = argv.flag?('all-targets')
23
+ @custom_repo_url = argv.option('repo-url')
24
+ super
25
+ end
26
+
27
+ def run
28
+ repo_url = @custom_repo_url || CocoapodsmPaaS::MPAAS_REPO_URL
29
+ source_line = "source \"#{repo_url}\""
30
+
31
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.check_config_file_exists')
32
+ project_dir = Dir::pwd
33
+ meta_file_path = find_config_file(project_dir)
34
+
35
+ unless meta_file_path.length > 0 && File::exist?(meta_file_path)
36
+
37
+ config_file_name = "meta.config"
38
+ meta_file_path = File.join(project_dir, config_file_name)
39
+ # 如果 meta.config 也没有的话
40
+ unless File::exist?(meta_file_path)
41
+ # Pod::UI.puts "No config file found !!!".red
42
+ help! "No config file found !!!"
43
+ else
44
+ LogTools.p "config file path : #{meta_file_path}"
45
+ end
46
+ else
47
+ LogTools.p "config file path : #{meta_file_path}"
48
+ end
49
+
50
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.check_process_podfile')
51
+ podfile_path = File.join(project_dir, "Podfile")
52
+ LogTools.p "Podfile path: #{podfile_path}"
53
+
54
+ plugin_full = PLUGIN
55
+ # 处理下 --all-targets
56
+ if @all_targets
57
+ podfile = Pod::Podfile.from_file(podfile_path)
58
+
59
+ plugin_option = ', :targets => ['
60
+ root_targetDefinition_array = podfile.root_target_definitions
61
+ if root_targetDefinition_array && root_targetDefinition_array.size > 0
62
+ root_targetDefinition_array.each do |root_targetDefinition|
63
+ children = root_targetDefinition.children
64
+ if children
65
+ children.each_index do |index|
66
+ plugin_option += ('"' + children[index].name + '"')
67
+
68
+ if index != (children.size - 1)
69
+ plugin_option += ', '
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ plugin_option += ']'
77
+ plugin_full += plugin_option
78
+ end
79
+
80
+ # 先简单文本处理,todo ruby解析或者正则
81
+ io = File::open(podfile_path).readlines
82
+ override = File.new(podfile_path, "w")
83
+
84
+ # 先把 plugin 和 source 加上去
85
+ override.puts("# mPaaS Pods Begin")
86
+ override.puts(plugin_full)
87
+ override.puts(source_line)
88
+ if @custom_repo_url
89
+ override.puts("mPaaS_repo_url '#{repo_url}'")
90
+ end
91
+ override.puts('mPaaS_baseline ' + '\'x.x.x\'' + ' ' + Pod::MPAAS::Localization.t('mpaas.init_command.replace_baseline_note'))
92
+ override.puts("# mPaaS Pods End")
93
+ override.puts("# ---------------------------------------------------------------------")
94
+
95
+ io.each do |line|
96
+ unless line.include?("cocoapods-mPaaS") || line.include?("mPaaS_repo_url") || line.include?(CocoapodsmPaaS::MPAAS_REPO_URL) || (@custom_repo_url && line.include?(@custom_repo_url)) || line.include?("mPaaS Pods") || line.include?("use_pod_for_mPaaS") || line.include?("mPaaS_baseline") || line.include?("# -------------------------------------------------------")
97
+ override.puts line
98
+ end
99
+ end
100
+
101
+ override.close
102
+
103
+ LogTools.p_green 'Added "plugin in current Podfile, Done"'
104
+ LogTools.p plugin_full
105
+ LogTools.p_green 'Added "source in current Podfile, Done"'
106
+ LogTools.p source_line
107
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.init_command.configuration_complete')
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -0,0 +1,49 @@
1
+ require_relative '../../localization' # 确保引入了本地化模块
2
+
3
+ module Pod
4
+ class Command
5
+ # MPAAS 主命令
6
+ class MPAAS < Command
7
+ self.abstract_command = true # 这是一个抽象命令,不能直接运行
8
+ self.summary = 'MPAAS plugin configurations.'
9
+ self.description = <<-DESC
10
+ Provides configuration commands for the MPAAS CocoaPods plugin.
11
+ DESC
12
+
13
+ def initialize(argv)
14
+ super
15
+ Pod::MPAAS::Localization.set_language(Pod::MPAAS::Localization.current_language)
16
+ end
17
+
18
+ # --- 设置语言子命令 ---
19
+ class SetLang < MPAAS # 注意这里是继承自 MPAAS,而不是直接继承 Command
20
+ self.summary = 'Set the display language for MPAAS plugin output.'
21
+ self.description = <<-DESC
22
+ Sets the preferred output language for the MPAAS CocoaPods plugin.
23
+ This setting will be saved and used for all subsequent MPAAS commands and hook outputs.
24
+
25
+ Supported languages: en (English), zh-Hans (Simplified Chinese)
26
+
27
+ Example:
28
+ $ pod mpaas set-lang zh-Hans
29
+ DESC
30
+
31
+ def initialize(argv)
32
+ @language_code = argv.shift_argument # 获取第一个非选项参数作为语言代码
33
+ super # 调用父类的 initialize
34
+ end
35
+
36
+ def validate!
37
+ super
38
+ help! Pod::MPAAS::Localization.t('mpaas.commands.set_lang.language_code_required') unless @language_code
39
+ end
40
+
41
+ def run
42
+ Pod::MPAAS::Localization.set_language(@language_code)
43
+ Pod::UI.puts Pod::MPAAS::Localization.t('mpaas.commands.set_lang.success_message', lang_code: @language_code)
44
+ Pod::UI.puts Pod::MPAAS::Localization.t('mpaas.commands.set_lang.restart_note')
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,17 @@
1
+ module Pod
2
+ class Command
3
+ class MPAAS
4
+ class Open < MPAAS
5
+ self.summary = "Open the .xcworkspace in current dir"
6
+
7
+ self.description = <<-DESC
8
+ Open by mPaaS.
9
+ DESC
10
+
11
+ def run
12
+ `open *.xcworkspace`
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,223 @@
1
+ require_relative '../../localization' # 确保引入了本地化模块
2
+ require 'cocoapods-mPaaS/mPaaSPodfile'
3
+ module Pod
4
+ class Command
5
+ class MPAAS
6
+ class Update < MPAAS
7
+ self.summary = "Update using mPaaS."
8
+
9
+ self.description = <<-DESC
10
+ Update by mPaaS. Use --local to read from a local Component.json.
11
+ DESC
12
+
13
+ def self.options
14
+ [
15
+ ['--all', 'Update all (baseline list, mPaaS repo, and plugin itself).'],
16
+ ['--pre', 'Include pre-release versions when updating.'],
17
+ ['--dev', 'Include dev-test versions when updating.'],
18
+ ['--local=PATH', 'Use local Component.json instead of network. PATH is optional if configured in Podfile.']
19
+ ].concat(super)
20
+ end
21
+
22
+ def initialize(argv)
23
+ @local_path = argv.option('local')
24
+ @local_flag = argv.flag?('local') if @local_path.nil?
25
+ @baseline_input = argv.shift_argument
26
+ @all = argv.flag?('all')
27
+ @install = argv.flag?('install')
28
+ @pre = argv.flag?('pre')
29
+ @dev = argv.flag?('dev')
30
+ @httpRepo = argv.flag?('http')
31
+ super
32
+ end
33
+
34
+ def local_mode?
35
+ @local_path || @local_flag
36
+ end
37
+
38
+ def resolve_content_output_path(version)
39
+ podfile_path = File.join(Dir::pwd, "Podfile")
40
+ if File.exist?(podfile_path)
41
+ mpaas_podfile = MPaaSPodfile.new
42
+ mpaas_podfile.run(podfile_path)
43
+ if mpaas_podfile.localContentJsonPath
44
+ return File.expand_path(mpaas_podfile.localContentJsonPath, Dir::pwd)
45
+ end
46
+ end
47
+ File.join(CocoapodsmPaaS::MPAAS_LOCAL_PATH, "baseline", version, "content.json")
48
+ end
49
+
50
+ def run_local
51
+ podfile_path = File.join(Dir::pwd, "Podfile")
52
+
53
+ unless File.exist?(podfile_path)
54
+ LogTools.p_red "Error: Podfile not found in current directory (#{Dir::pwd})"
55
+ return
56
+ end
57
+
58
+ mpaas_podfile = MPaaSPodfile.new
59
+ mpaas_podfile.run(podfile_path)
60
+
61
+ component_path = @local_path
62
+ if component_path.nil? || component_path.empty?
63
+ component_path = mpaas_podfile.localComponentJsonPath
64
+ end
65
+
66
+ unless component_path && !component_path.empty?
67
+ LogTools.p_red "Error: No Component.json path specified."
68
+ LogTools.p_red "Use: pod mpaas update --local=path/to/Component.json"
69
+ LogTools.p_red "Or configure in Podfile: mPaaS_local_component_json 'path/to/Component.json'"
70
+ return
71
+ end
72
+
73
+ component_abs = File.expand_path(component_path, Dir::pwd)
74
+ unless File.exist?(component_abs)
75
+ LogTools.p_red "Error: Component JSON not found at: #{component_abs}"
76
+ return
77
+ end
78
+
79
+ baseline = mpaas_podfile.mPaaSBaseline
80
+ unless baseline
81
+ LogTools.p_red "Error: mPaaS_baseline not found in Podfile"
82
+ return
83
+ end
84
+
85
+ content_abs = resolve_content_output_path(baseline)
86
+
87
+ LogTools.p_green "Reading Component.json from: #{component_abs}"
88
+ LogTools.p_green "Baseline: #{baseline}"
89
+
90
+ BaselineTools.updateContentFileFromLocal(component_abs, content_abs, baseline)
91
+
92
+ LogTools.p_green "content.json updated at: #{content_abs}"
93
+ end
94
+
95
+ def updatemPaaSRepo
96
+ if @dev then
97
+ system "pod repo update #{CocoapodsmPaaS::MPAAS_REPO_NAME}"
98
+ self.manage_private_cocoapods_repo(CocoapodsmPaaS::MPAAS_REPO_NAME_DEV, @httpRepo ? CocoapodsmPaaS::MPAAS_REPO_URL_DEV_HTTP : CocoapodsmPaaS::MPAAS_REPO_URL_DEV)
99
+ else
100
+ system "pod repo update #{CocoapodsmPaaS::MPAAS_REPO_NAME}"
101
+ end
102
+ end
103
+
104
+ require 'open3'
105
+
106
+ def manage_private_cocoapods_repo(repo_name, repo_url)
107
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.repo_manager.checking_repo', repo_name: repo_name)
108
+
109
+ stdout, stderr, status = Open3.capture3("pod repo list")
110
+
111
+ unless status.success?
112
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.repo_manager.error_details', message: stderr) unless stderr.empty?
113
+ return false
114
+ end
115
+
116
+ if !stderr.empty?
117
+ LogTools.p_yellow Pod::MPAAS::Localization.t('mpaas.repo_manager.pod_repo_list_warning', message: stderr)
118
+ end
119
+
120
+ repo_exists = false
121
+ stdout.each_line do |line|
122
+ if line.strip == repo_name
123
+ repo_exists = true
124
+ break
125
+ end
126
+ end
127
+
128
+ if repo_exists
129
+ update_success = system("pod repo update #{repo_name}")
130
+
131
+ if update_success
132
+ LogTools.p_green "update_success #{repo_name}"
133
+ else
134
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.repo_manager.repo_update_failed', repo_name: repo_name)
135
+ return false
136
+ end
137
+ else
138
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.repo_manager.repo_not_exists_adding', repo_name: repo_name)
139
+ add_success = system("pod repo add #{repo_name} #{repo_url}")
140
+
141
+ if add_success
142
+ LogTools.p_green Pod::MPAAS::Localization.t('mpaas.repo_manager.validating_new_repo', repo_name: repo_name)
143
+ else
144
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.repo_manager.add_failure_reasons', repo_url: repo_url)
145
+ return false
146
+ end
147
+ end
148
+
149
+ return true
150
+ rescue Errno::ENOENT => e
151
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.repo_manager.error_details', message: e.message)
152
+ return false
153
+ rescue => e
154
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.repo_manager.unknown_error', message: e.message)
155
+ return false
156
+ end
157
+
158
+ def updateLocalBaseline
159
+ baseline_array = BaselineTools.getCurrentBaselineOnline
160
+ baseline_array && baseline_array.each do |baseline|
161
+ LogTools.p_green "1. update #{baseline} baseline file ..."
162
+ content_path = resolve_content_output_path(baseline)
163
+ BaselineTools.updateContentFileByComponent(baseline, false, @pre, false, content_path)
164
+ LogTools.p_green " update #{baseline} baseline file Done"
165
+ end
166
+ end
167
+
168
+ def run
169
+ if local_mode?
170
+ run_local
171
+ return
172
+ end
173
+
174
+ if @all
175
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.update_command.execute_plugin_install_script')
176
+ LogTools.p "sh <(curl -s #{CocoapodsmPaaS::MPAAS_IOS_PATH_PREFIX}/cocoapods/installmPaaSCocoaPodsPlugin.sh)"
177
+
178
+ system "curl -o shell_installer_text #{CocoapodsmPaaS::MPAAS_IOS_PATH_PREFIX}/cocoapods/installmPaaSCocoaPodsPlugin.sh"
179
+ system "sh shell_installer_text"
180
+ system "rm shell_installer_text"
181
+
182
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.update_command.update_mpaas_repo')
183
+ LogTools.p_green "update mPaaS repo ..."
184
+ updatemPaaSRepo
185
+ LogTools.p_green "update mPaaS repo Done"
186
+
187
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.update_command.update_local_baseline')
188
+ LogTools.p_green "update mPaaS baseline ..."
189
+ updateLocalBaseline
190
+ LogTools.p_green "update mPaaS baseline Done"
191
+
192
+ elsif @baseline_input
193
+ content_path = resolve_content_output_path(@baseline_input)
194
+ LogTools.p_green "1. update #{@baseline_input} baseline file ..."
195
+ BaselineTools.updateContentFileByComponent(@baseline_input, false, @pre, @dev, content_path)
196
+ LogTools.p_green " update #{@baseline_input} baseline file Done"
197
+
198
+ LogTools.p ""
199
+ LogTools.p_green "2. update mPaaS repo ..."
200
+ updatemPaaSRepo
201
+ LogTools.p_green " update mPaaS repo Done"
202
+
203
+ else
204
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.update_command.update_mpaas_repo_second')
205
+ LogTools.p_green "update mPaaS repo ..."
206
+ updatemPaaSRepo
207
+ LogTools.p_green "update mPaaS repo Done"
208
+
209
+ LogTools.p_red Pod::MPAAS::Localization.t('mpaas.update_command.update_local_baseline_second')
210
+ LogTools.p_green "update mPaaS baseline ..."
211
+ updateLocalBaseline
212
+ LogTools.p_green "update mPaaS baseline Done"
213
+
214
+ if @install
215
+ LogTools.p_green "pod install ..."
216
+ system "pod install"
217
+ end
218
+ end
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,32 @@
1
+ module Pod
2
+ class Command
3
+ class MPAAS
4
+ class Version < MPAAS
5
+ self.summary = "get version"
6
+
7
+ self.description = <<-DESC
8
+ get version by mPaaS.
9
+ DESC
10
+
11
+ def initialize(argv)
12
+ @plugin = argv.flag?("plugin")
13
+ super
14
+ end
15
+
16
+ def run
17
+ if @plugin
18
+ LogTools.p_green CocoapodsMpaas::VERSION_DEV
19
+ else
20
+ project_dir = Dir::pwd
21
+ podfile_path = File.join(project_dir, "Podfile")
22
+
23
+ mPaaSPodfile = MPaaSPodfile.new
24
+ mPaaSPodfile.run(podfile_path)
25
+
26
+ LogTools.p_green "#{mPaaSPodfile.mPaaSBaseline}.#{mPaaSPodfile.mPaaSVersionCode}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-mPaaS/command/mPaaS'