cocoapods-bb-PodAssistant 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4d73bccc2529481814cc586c3d0cb46b863c986741859ac8d399f1a8962ed1c
4
- data.tar.gz: d96718876d58008ffa7e846cae38e68d46358fe3e88effd7477b669b514ede12
3
+ metadata.gz: 7a9981c561f8eb760349f20d77d0afd544602a810472cb9f8ecd02d6e2779664
4
+ data.tar.gz: da2528d18dfe9a93eafd8c18de120ba5212663c845bce0473f3c5fbbb056a8ba
5
5
  SHA512:
6
- metadata.gz: 979d7c8365b57c364e953ebe616d55be2c40c5547a72d42089db504123d9188bfe8920ede679ec412128e41cca44feaec052d32d1163c60b7434d022be2dfba4
7
- data.tar.gz: c86d930fdd7cc595ea411b235ce98b18e8c105665b178a05938f9f4e942a20530bb83a5ac2dabb6a530022d0f82f2373adf6951d55984d2473b15d52d93e2a0f
6
+ metadata.gz: 8adc406969d02c2cb60393ff1afbba8a3e909acee63b85643183e72e58e3f087b156022037059a90a2ebe348c1ec832720ff7d5b66a637c42cc64ab0ff9925e8
7
+ data.tar.gz: a02261b3e1006d4d8164646843bc02414442ede74086dc763b66a41fe560610730797fc167f1662e4229f96d84cb867ab664c6f209fe5160108b06b63d56eea8
@@ -0,0 +1,37 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+ require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
3
+
4
+ module Pod
5
+ class Command
6
+ class Stable < Command
7
+ class Init < Stable
8
+
9
+ self.summary = '[初始化项目yml配置] Generate a Stable yml config file from a Podfile.lock'
10
+
11
+ self.description = <<-DESC
12
+ 通过项目`Podfile.lock`文件,生成`stable_specs_lock.yml`配置文件
13
+ DESC
14
+
15
+ def initialize(argv)
16
+ super
17
+ end
18
+
19
+ def run
20
+ # verify_podfile_exists!
21
+ env = BB::StableEnv.new()
22
+ if env.verify_stable_env_exists == true
23
+ env.system_clone_stable_git # 自动拉取远端git仓库数据
24
+ source_manager = BB::SourceManager.new()
25
+ puts "[PodAssistant] 开始配置生成当前项目yml文件".yellow
26
+ # 生成本地yml配置
27
+ source_manager.generate_localStable
28
+ puts "[PodAssistant] `pod stable init` complete!".green
29
+ else
30
+ puts "[PodAssistant] ❌工程没有配置stable环境".red
31
+ end
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+
3
+ module Pod
4
+ class Command
5
+ class Stable < Command
6
+ class Install < Stable
7
+ self.summary = '[命令同执行`pod install操作`] Install project dependencies according to versions from a Podfile.lock'
8
+
9
+ self.description = <<-DESC
10
+ Downloads all dependencies defined in `Podfile` and creates an Xcode
11
+ Pods library project in `./Pods`.
12
+
13
+ The Xcode project file should be specified in your `Podfile` like this:
14
+
15
+ project 'path/to/XcodeProject.xcodeproj'
16
+
17
+ If no project is specified, then a search for an Xcode project will
18
+ be made. If more than one Xcode project is found, the command will
19
+ raise an error.
20
+
21
+ This will configure the project to reference the Pods static library,
22
+ add a build configuration file, and add a post build script to copy
23
+ Pod resources.
24
+
25
+ This may return one of several error codes if it encounters problems.
26
+ * `1` Generic error code
27
+ * `31` Spec not found (i.e out-of-date source repos, mistyped Pod name etc...)
28
+ DESC
29
+
30
+ def run
31
+ puts "[PodAssistant] 开始执行 $ pod stable install".yellow
32
+ system "pod install"
33
+ puts "[PodAssistant] `pod stable install` complete!".green
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,57 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+ require 'cocoapods-bb-PodAssistant/helpers/git_cmd_helper'
3
+ require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
4
+ require 'cocoapods'
5
+
6
+ module Pod
7
+ class Command
8
+ class Stable < Command
9
+ class Sync < Stable
10
+ require 'fileutils'
11
+ require 'cocoapods/executable.rb'
12
+ extend Executable
13
+ executable :git
14
+
15
+ self.summary = '[同步远端yml配置] sync a Stable yml config file'
16
+
17
+ self.description = <<-DESC
18
+ 同步远端stable yml配置文件,并对本地文件进行合并操作
19
+ DESC
20
+
21
+ def initialize(argv)
22
+ super
23
+ end
24
+
25
+ def run
26
+ puts "开始合并远端stable yml数据".yellow
27
+ # 数据合并
28
+ source_manager = BB::SourceManager.new()
29
+ fetch_stale_git
30
+ source_manager.merge_stable_data
31
+ puts "[PodAssistant] `pod stable sync` complete! Please execute the [pod install/ pod update] command".green
32
+ end
33
+
34
+ # 拉取stable仓库代码 ruby脚本内部调用
35
+ def clone_stable_git
36
+ cache = BB::Cache.new()
37
+ cachePath = cache.cachePath
38
+ configGitPath(cachePath)
39
+ unless Dir.exist?(File.join(cachePath))
40
+ clonePath = File.dirname(cachePath)
41
+ FileUtils.mkdir_p clonePath
42
+ git_clone(@stable_source,clonePath)
43
+ end
44
+ end
45
+
46
+ def fetch_stale_git
47
+ clone_stable_git
48
+ # git操作
49
+ git_reset
50
+ git_fetch
51
+ git_checkout_and_pull(@stable_source, @stable_branch, @stable_tag)
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,50 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+
3
+ module Pod
4
+ class Command
5
+ class Stable < Command
6
+ class Update < Stable
7
+ self.summary = '[命令同执行`pod update操作`] Update outdated project dependencies and create new ' \
8
+ 'Podfile.lock'
9
+
10
+ self.description = <<-DESC
11
+ Updates the Pods identified by the specified `POD_NAMES`, which is a
12
+ space-delimited list of pod names. If no `POD_NAMES` are specified, it
13
+ updates all the Pods, ignoring the contents of the Podfile.lock. This
14
+ command is reserved for the update of dependencies; pod install should
15
+ be used to install changes to the Podfile.
16
+ DESC
17
+
18
+ self.arguments = [
19
+ CLAide::Argument.new('POD_NAMES', false, true),
20
+ ]
21
+
22
+ def self.options
23
+ [
24
+ # ['--business-spec=specName', '业务线公共stable spec名称'],
25
+ ].concat(super)
26
+ end
27
+
28
+ def initialize(argv)
29
+ @pods = argv.arguments!
30
+ super
31
+
32
+ end
33
+
34
+ def run
35
+ puts "[PodAssistant] 开始执行 $ pod stable update".yellow
36
+ # verify_podfile_exists! # 系统提供api验证podfile是否ok
37
+ if @pods.any?
38
+ pods_str = @pods.join(" ")
39
+ system "pod update #{pods_str}"
40
+ else
41
+ system "pod update"
42
+ end
43
+ source_manager = BB::SourceManager.new()
44
+ source_manager.update_local_stable_from_podmodules(@pods)
45
+ puts "[PodAssistant] `pod stable update` complete!".green
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,51 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+ require 'cocoapods-bb-PodAssistant/config/cache_path'
3
+ require 'cocoapods-bb-PodAssistant/helpers'
4
+
5
+ require 'cocoapods-bb-PodAssistant/command/stable/init'
6
+ require 'cocoapods-bb-PodAssistant/command/stable/install'
7
+ require 'cocoapods-bb-PodAssistant/command/stable/update'
8
+ require 'cocoapods-bb-PodAssistant/command/stable/sync'
9
+
10
+ module Pod
11
+
12
+ # class StableOptions
13
+ # # define business specs,defalut is stable_specs
14
+ # option :business_specs, "stable_specs"
15
+
16
+ # # define custom lockSpecs tag
17
+ # option :tag, ""
18
+
19
+ # # define custom lockSpecs branch
20
+ # option :branch, ""
21
+ # end
22
+
23
+ class Command
24
+ class Stable < Command
25
+ self.abstract_command = true
26
+
27
+ self.summary = '拉取稳定Podfile.lock配置'
28
+ self.description = <<-DESC
29
+ 拉取稳定lock配置插件。利用版本比对进行更新配置实现对组件版本控制管理。
30
+ DESC
31
+
32
+ self.default_subcommand = 'init'
33
+
34
+ #-----------------------------------------------------------------------#
35
+
36
+ extend Executable
37
+ executable :git
38
+
39
+ def validate!
40
+ super
41
+ banner! if @help
42
+ end
43
+
44
+ def run
45
+ puts "[PodAssistant] `pod stable` 帮助文档请查看�".yellow
46
+ # banner!
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -1,9 +1,8 @@
1
- require 'cocoapods-bb-PodAssistant/command/PodAssistant'
2
1
  #stable
3
- require 'cocoapods-bb-PodAssistant/command/stable/stable'
4
- require 'cocoapods-bb-PodAssistant/command/stable/podfile-linkline'
2
+ require 'cocoapods-bb-PodAssistant/command/stable'
3
+ require 'cocoapods-bb-PodAssistant/babybus/stable/podfile-linkline'
5
4
  #linkline
6
- require 'cocoapods-bb-PodAssistant/command/linkline/linkline'
7
- require 'cocoapods-bb-PodAssistant/command/linkline/target-linkline'
8
- require 'cocoapods-bb-PodAssistant/command/linkline/targetdefinition-linkline'
9
- require 'cocoapods-bb-PodAssistant/command/linkline/targetValidator-linkline'
5
+ require 'cocoapods-bb-PodAssistant/command/linkline'
6
+ require 'cocoapods-bb-PodAssistant/babybus/linkline/target-linkline'
7
+ require 'cocoapods-bb-PodAssistant/babybus/linkline/targetdefinition-linkline'
8
+ require 'cocoapods-bb-PodAssistant/babybus/linkline/targetValidator-linkline'
@@ -2,12 +2,14 @@ require 'cocoapods-bb-PodAssistant/helpers'
2
2
  require 'cocoapods-bb-PodAssistant/config/stable_specs'
3
3
  require 'cocoapods-bb-PodAssistant/helpers/stable_manager_helper'
4
4
  require 'cocoapods-core'
5
+ require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
5
6
 
6
7
  # 数据源管理
7
8
  module BB
8
9
  class SourceManager
9
- def initialize(businessSpecName = nil)
10
- @businessSpecName = businessSpecName
10
+ def initialize()
11
+ env = BB::StableEnv.new()
12
+ @businessSpecName = env.business_stable
11
13
  @stableMgr = BB::StableManager.new()
12
14
  end
13
15
 
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  # cache stable
2
+ require 'cocoapods'
2
3
 
3
4
  ######################################## Git Command ########################################
4
5
  def configGitPath(gitPath)
@@ -66,7 +67,10 @@ def git_branch_exists?(branch)
66
67
  end
67
68
 
68
69
  def git_clone(source, path)
69
- puts "git clone source:#{source} path:#{path}"
70
+ puts "git clone source:#{source} path:#{path}".yellow
71
+ if !File.directory?(path)
72
+ Dir.mkdir(path)
73
+ end
70
74
  UI.section("Cloning `#{source}` into `#{path}`.") do
71
75
  Dir.chdir(path) { git! ['clone', source] } #origin git command
72
76
  end
@@ -164,10 +164,9 @@ module BB
164
164
  if pod.nil? # stbale没有受版本控制
165
165
  need_update_pod_data[podName] = podfile_pod
166
166
  else
167
- # puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod})".yellow
168
- if podName == "BBWriteReview/World"
169
- puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod})".yellow
170
- end
167
+ # if podCoreName == 'BBGameModule'
168
+ # puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod})".green
169
+ # end
171
170
  if pod == podfile_pod
172
171
  if podName != podCoreName
173
172
  need_update_pod_data[podName] = podfile_pod
@@ -206,9 +205,42 @@ module BB
206
205
  need_update_pod_data[podName] = pod
207
206
  end
208
207
  else
209
- if podName != podCoreName
210
- # puts "[PodAssistant] '#{podName}', '#{pod.send(:red)}' 以stable配置为主."
211
- need_update_pod_data[podName] = pod
208
+ is_podfile_data = false
209
+ newPod = nil
210
+ if pod.is_a? (Hash)
211
+ stable_branch = pod[:branch]
212
+ stable_git = pod[:git]
213
+ if stable_git.nil?
214
+ stable_git = pod[:git_format]
215
+ end
216
+ if (stable_branch && !stable_branch.empty?) || (stable_git && !stable_git.empty?)
217
+ puts "[PodAssistant] '#{podName}', '#{podfile_pod}' 以podfile配置为主[分支=>标签]."
218
+ newPod = podfile_pod
219
+ is_podfile_data = true
220
+ else
221
+ newPod = pod
222
+ end
223
+ elsif pod.is_a? (String)
224
+ if pod.include?(':branch') || pod.include?(':git') || pod.include?(':git_format')
225
+ puts "[PodAssistant] '#{podName}', '#{podfile_pod}' 以podfile配置为主[分支=>标签]."
226
+ newPod = podfile_pod
227
+ is_podfile_data = true
228
+ else
229
+ newPod = pod
230
+ end
231
+ else
232
+ newPod = podfile_pod
233
+ is_podfile_data = true
234
+ end
235
+ if is_podfile_data == true
236
+ need_update_pod_data[podCoreName] = newPod
237
+ if podName != podCoreName
238
+ need_update_pod_data[podName] = newPod
239
+ end
240
+ else
241
+ if podName != podCoreName
242
+ need_update_pod_data[podName] = newPod
243
+ end
212
244
  end
213
245
  end
214
246
  end
@@ -1,36 +1,79 @@
1
- require 'cocoapods-bb-PodAssistant/helpers/git_cmd_helper'
2
1
  require 'cocoapods-bb-PodAssistant/config/stable_source'
3
2
 
4
3
  module BB
5
- class StableEnv
6
- def initialize(stable_source = nil, stable_branch = nil, stable_tag = nil)
7
- if stable_source.nil?
8
- stable_source = StableSource.stable_default_source
9
- end
10
- @stable_source = stable_source
11
- @stable_branch = stable_branch
12
- @stable_tag = stable_tag
13
-
4
+ class StableEnv
5
+ def initialize()
14
6
  @cache = BB::Cache.new()
15
7
  configGitPath(@cache.cachePath)
8
+ # 自动加载stable环境
9
+ loadStaleEnv
16
10
  end
17
11
 
18
12
  # stable 环境,执行pod stable
19
13
  def loadStaleEnv
20
-
14
+ unless File.exist?(File.join(Pathname.pwd, "Podfile"))
15
+ err_msg = "- Error: #{File.join(Pathname.pwd, "Podfile")} is not exit"
16
+ Pod::UI.puts "#{err_msg}".send(:red)
17
+ exit -9001
18
+ end
19
+
20
+ #获取podfile 内容
21
+ #1、删除所有注释行,避免干扰
22
+ #2、正则匹配,筛选出stable 方法
23
+ #3、执行stable 方法,获取配置
24
+ podfileContent = File.read(File.join(Pathname.pwd, "Podfile"))
25
+ podfileContent_vaild = podfileContent.lines.reject { |line| line.strip.start_with?("#") }.join
26
+ stableCommand = podfileContent_vaild.match(/^\s*stable!\s*'([^']+)'(?:,\s*(\w+):\s*'([^']+)')*/m)
27
+ unless stableCommand
28
+ puts "- Error: not stable define in the podfile! you can define to podfile:".red
29
+ puts "stable! 'https://git.babybus.co/babybus/ios/Specs/stable-specs.git', specs:'<业务线stbale名称-可选>', tag:'<标签-可选>', branch:'<分支-可选>'".green
30
+ exit -9002
31
+ end
32
+ eval(stableCommand.to_s)
21
33
  end
22
34
 
23
- # 开发环境,执行pod install/update
24
- def loadDeveloperEnv
35
+ # 拉取stable仓库代码 hook开发环境,执行pod install/update
36
+ def system_clone_stable_git
25
37
  cachePath = @cache.cachePath
26
- puts "hook [pod install/update] sync stable git=>#{cachePath}"
38
+ puts "hook [pod install/update] fetch stable git=>#{cachePath}"
27
39
  if Dir.exist?(File.join(cachePath))
28
- `cd #{cachePath}; git switch main; git pull --all`
40
+ # `cd #{cachePath}; git switch main; git pull --all`
41
+ system "cd #{cachePath}; git switch main; git pull --all"
29
42
  else
30
43
  clonePath = File.dirname(cachePath)
31
44
  FileUtils.mkdir_p clonePath
32
- `git clone #{@stable_source} #{cachePath}`
45
+ # `git clone #{@stable_source} #{cachePath}`
46
+ system "git clone #{@stable_source} #{cachePath}"
33
47
  end
34
48
  end
49
+
50
+ # ========podfile 约定函数规则,切勿修改
51
+ #help load podfile option
52
+ def stable!(source, options = {})
53
+ @stable_source = source
54
+ if options.has_key?(:specs)
55
+ @businessSpec = options[:specs]
56
+ end
57
+ @stable_tag = options[:tag] if options.has_key?(:tag)
58
+ @stable_branch = options[:branch] if options.has_key?(:branch)
59
+ puts "###stable env => [stable公共源]:#{source} [业务线源名称]:#{@businessSpec} branch:#{@stable_branch} tag:#{@stable_tag}".yellow
60
+ end
61
+
62
+ def stable_source
63
+ return @stable_source
64
+ end
65
+ def stable_branch
66
+ return @stable_branch
67
+ end
68
+ def stable_tag
69
+ return @stable_tag
70
+ end
71
+ def business_stable
72
+ return @businessSpec
73
+ end
74
+ # 验证stable环境是否存在
75
+ def verify_stable_env_exists
76
+ return @stable_source.empty? ? false : true
77
+ end
35
78
  end
36
79
  end
@@ -50,7 +50,7 @@ module BB
50
50
  $podStartTime = Time.new
51
51
  puts "[PodAssistant] plugin hook pre_install".yellow
52
52
  env = BB::StableEnv.new()
53
- env.loadDeveloperEnv
53
+ env.system_clone_stable_git # 自动拉取远端git仓库数据
54
54
  if $pluginIsVerbose == true
55
55
  # home路径下是否存在.AllPodsTimeAndSize.csv的隐藏文件
56
56
  if File.exist?("#{Dir.home}/.AllPodsTimeAndSize.csv")
@@ -68,7 +68,7 @@ module BB
68
68
  end
69
69
  Pod::HooksManager.register("cocoapods-bb-PodAssistant", :post_install) do |installer|
70
70
  begin
71
- source_manager = BB::SourceManager.new(@businessSpec)
71
+ source_manager = BB::SourceManager.new()
72
72
  # 生成本地yml配置
73
73
  source_manager.generate_localStable
74
74
  $podEndTime = Time.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-bb-PodAssistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - humin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-13 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods-core
@@ -79,14 +79,17 @@ files:
79
79
  - lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb
80
80
  - lib/cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper.rb
81
81
  - lib/cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks.rb
82
+ - lib/cocoapods-bb-PodAssistant/babybus/linkline/target-linkline.rb
83
+ - lib/cocoapods-bb-PodAssistant/babybus/linkline/targetValidator-linkline.rb
84
+ - lib/cocoapods-bb-PodAssistant/babybus/linkline/targetdefinition-linkline.rb
85
+ - lib/cocoapods-bb-PodAssistant/babybus/stable/podfile-linkline.rb
82
86
  - lib/cocoapods-bb-PodAssistant/command.rb
83
- - lib/cocoapods-bb-PodAssistant/command/PodAssistant.rb
84
- - lib/cocoapods-bb-PodAssistant/command/linkline/linkline.rb
85
- - lib/cocoapods-bb-PodAssistant/command/linkline/target-linkline.rb
86
- - lib/cocoapods-bb-PodAssistant/command/linkline/targetValidator-linkline.rb
87
- - lib/cocoapods-bb-PodAssistant/command/linkline/targetdefinition-linkline.rb
88
- - lib/cocoapods-bb-PodAssistant/command/stable/podfile-linkline.rb
89
- - lib/cocoapods-bb-PodAssistant/command/stable/stable.rb
87
+ - lib/cocoapods-bb-PodAssistant/command/linkline.rb
88
+ - lib/cocoapods-bb-PodAssistant/command/stable.rb
89
+ - lib/cocoapods-bb-PodAssistant/command/stable/init.rb
90
+ - lib/cocoapods-bb-PodAssistant/command/stable/install.rb
91
+ - lib/cocoapods-bb-PodAssistant/command/stable/sync.rb
92
+ - lib/cocoapods-bb-PodAssistant/command/stable/update.rb
90
93
  - lib/cocoapods-bb-PodAssistant/config/cache_path.rb
91
94
  - lib/cocoapods-bb-PodAssistant/config/source_manager.rb
92
95
  - lib/cocoapods-bb-PodAssistant/config/stable_source.rb
@@ -1,44 +0,0 @@
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 Podassistant < Command
21
- self.summary = 'Short description of cocoapods-bb-PodAssistant.'
22
-
23
- self.description = <<-DESC
24
- Longer description of cocoapods-bb-PodAssistant.
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-bb-PodAssistant plugin in #{__FILE__}"
41
- end
42
- end
43
- end
44
- end
@@ -1,168 +0,0 @@
1
- require 'cocoapods-bb-PodAssistant/config/source_manager'
2
- require 'cocoapods-bb-PodAssistant/config/cache_path'
3
- require 'cocoapods-bb-PodAssistant/helpers'
4
-
5
- module Pod
6
-
7
- # class StableOptions
8
- # # define business specs,defalut is stable_specs
9
- # option :business_specs, "stable_specs"
10
-
11
- # # define custom lockSpecs tag
12
- # option :tag, ""
13
-
14
- # # define custom lockSpecs branch
15
- # option :branch, ""
16
- # end
17
-
18
- class Command
19
- class Stable < Command
20
- require 'fileutils'
21
- require 'cocoapods/executable.rb'
22
- extend Executable
23
- executable :git
24
-
25
- self.summary = '拉取稳定lock配置'
26
- self.description = <<-DESC
27
- 拉取稳定lock配置插件。利用版本比对进行更新配置实现对组件版本控制管理。
28
- DESC
29
-
30
- self.arguments = [
31
- CLAide::Argument.new('Podfile', false)
32
- ]
33
- def self.options
34
- [
35
- ['--init', '初始化项目yml配置,根据当前项目Podfile.lock生成'],
36
- ['--sync', '同步远端yml配置,更新项目yml配置'],
37
- ['--install', '命令同执行`pod install操作`'],
38
- ['--update', '命令同执行`pod update操作`'],
39
- ['--update-pod', '命令同执行`pod update <组件>操作`,更新yml配置组件版本信息,多个组件使用`,`或者`空格`隔开,注意⚠️ 使用`空格`需要使用双引号'],
40
- ].concat(super)
41
- end
42
-
43
- def initialize(argv)
44
- @names = argv.arguments! unless argv.arguments.empty?
45
- @help = argv.flag?('help')
46
- @init = argv.flag?('init')
47
- @sync = argv.flag?('sync')
48
- # install操作
49
- @install = argv.flag?('install')
50
- @update = argv.flag?('update')
51
- # update组件数据支持多个使用`,`或者`空格`隔开
52
- update_pods = argv.option('update-pod','')
53
- if !update_pods.empty?
54
- if update_pods.include?(' ')
55
- @update_pods = update_pods.split(' ') unless update_pods.nil?
56
- else update_pods.include?(',')
57
- @update_pods = update_pods.split(',') unless update_pods.nil?
58
- end
59
- end
60
- super
61
- end
62
- def validate!
63
- super
64
- banner! if @help
65
- end
66
-
67
- #help load podfile option
68
- def stable!(source, options = {})
69
- @ll_stable_source = source
70
- if options.has_key?(:specs)
71
- @businessSpec = options[:specs]
72
- puts "当前业务使用源=>#{@businessSpec}"
73
- end
74
- @ll_stable_tag = options[:tag] if options.has_key?(:tag)
75
- @ll_stable_branch = options[:branch] if options.has_key?(:branch)
76
- @cache = BB::Cache.new()
77
- configGitPath(@cache.cachePath)
78
- end
79
-
80
- ######################################## Main ########################################
81
-
82
- def run
83
- # begin
84
- source_manager = BB::SourceManager.new(@businessSpec)
85
- if @init
86
- puts "[PodAssistant] 开始配置生成当前项目yml文件".yellow
87
- # 生成本地yml配置
88
- source_manager.generate_localStable
89
- puts "[PodAssistant] `pod stable --init` complete!".green
90
- elsif @install
91
- puts "[PodAssistant] 执行 $ pod install".yellow
92
- system "pod install"
93
- puts "[PodAssistant] `pod stable --install` complete!".green
94
- elsif @update
95
- puts "[PodAssistant] 执行 $ pod update".yellow
96
- system "pod update"
97
- puts "[PodAssistant] `pod stable --update` complete!".green
98
- elsif @update_pods
99
- # 更新单个组件
100
- puts "更新pod组件#{@update_pods} count:#{@update_pods.count}".yellow
101
- source_manager.update_podmodules(@update_pods)
102
- podnames = @update_pods.join(" ")
103
- puts "[PodAssistant] 执行 $ pod update #{podnames}".yellow
104
- system "pod update #{podnames}"
105
- source_manager.update_local_stable_from_podmodules(@update_pods)
106
- podnames = @update_pods.join(",")
107
- puts "[PodAssistant] `pod stable --update-pod=#{podnames}` complete!".green
108
- elsif @sync
109
- puts "开始合并远端lock数据".yellow
110
- ll_load_stable
111
- #2、clone origin lock spec to cache dir
112
- ll_cloneStable
113
- #3、fetch newest code
114
- ll_fetch_stale_git
115
- # 数据合并
116
- source_manager.merge_stable_data
117
- puts "[PodAssistant] `pod stable` complete! Please execute the [pod install/ pod update] command".green
118
- else
119
- puts "[PodAssistant] `pod stable` 帮助文档请查看👇".yellow
120
- banner!
121
- end
122
- # rescue => exception
123
- # puts "[pod stable] error(已捕获): #{exception}".red
124
- # end
125
-
126
- end
127
-
128
- private
129
- ######################################## API ########################################
130
- def ll_load_stable
131
- unless File.exist?(File.join(Pathname.pwd, "Podfile"))
132
- err_msg = "- Error: #{File.join(Pathname.pwd, "Podfile")} is not exit"
133
- Pod::UI.puts "#{err_msg}".send(:red)
134
- exit -9001
135
- end
136
-
137
- #获取podfile 内容
138
- #1、删除所有注释行,避免干扰
139
- #2、正则匹配,筛选出stable 方法
140
- #3、执行stable 方法,获取配置
141
- podfileContent = File.read(File.join(Pathname.pwd, "Podfile"))
142
- podfileContent_vaild = podfileContent.lines.reject { |line| line.strip.start_with?("#") }.join
143
- stableCommand = podfileContent_vaild.match(/^\s*stable!\s*'([^']+)'(?:,\s*(\w+):\s*'([^']+)')*/m)
144
- unless stableCommand
145
- err_msg = "- Error: not stable define in the podfile! you can define like【stable! 'https://git.babybus.co/babybus/ios/Specs/stable-specs.git', specs:'global_stable_specs'】in podfile"
146
- Pod::UI.puts "#{err_msg}".send(:red)
147
- exit -9002
148
- end
149
- eval(stableCommand.to_s)
150
- end
151
- def ll_cloneStable
152
- cachePath = @cache.cachePath
153
- unless Dir.exist?(File.join(cachePath))
154
- clonePath = File.dirname(cachePath)
155
- FileUtils.mkdir_p clonePath
156
- git_clone(@stable_source,clonePath)
157
- end
158
- end
159
-
160
- def ll_fetch_stale_git
161
- git_reset
162
- git_fetch
163
- git_checkout_and_pull(@stable_source, @stable_branch, @stable_tag)
164
- end
165
-
166
- end
167
- end
168
- end