cocoapods-ykutility 0.0.12 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc117e8086c2837b3d7b49a2dc44c641ffd10dcb57dae7ae11178cf59f80cf45
4
- data.tar.gz: d44bf31e0a0f060750144297636ee2aca87195bab1176a4452a175f0956efa80
3
+ metadata.gz: c4b79fd9f7903656dadce1185190adc88e55a314292b0454f77719bf50b8790e
4
+ data.tar.gz: c7659edbf4c293ba187c1314a3aede0abfeb9ddcdf002ecdff0b64b1de8b132d
5
5
  SHA512:
6
- metadata.gz: f878d8679e9c066e088736982a40098b0eabb9db1f0888dab221907d40379bad1fd9809a9924279d0e9551c3825da737f7b1e859e9501e38f7d8d6a302f16720
7
- data.tar.gz: c29dda8b533c1fa47273262a5bb9a7769bf5383b3f11ed6820de677426c3cdbbf1d693fd5d9003fd0b993340a610354fdd00545877f38178745e87cf6d55ce59
6
+ metadata.gz: 82ff382f1800c1bf4b9c68140b0dca9c721df2f9394b2dfefb959d3fd3ae2c8f7981cfac22ee435aca9c24e8577c5c1ce801c35ef03978bd1911d849c51298d9
7
+ data.tar.gz: 65e65eca2963857a404af1a60a79f85127a3bd5dd1e7e0b2d71e39d3c29a83db9cc35ed6b667de5f513ba7f57db6ebc569c7e5e2f14c838a0853dcb94a0af4f2
@@ -1,5 +1,6 @@
1
1
  require 'cocoapods'
2
- require 'cocoapods-ykutility/command/ykutility/create'
2
+ require 'cocoapods-ykutility/command/create'
3
+ require 'cocoapods-ykutility/command/push'
3
4
 
4
5
  module Pod
5
6
  class Command
@@ -4,13 +4,13 @@ module YKPod
4
4
  require 'cocoapods'
5
5
 
6
6
  class YKCreate
7
- require 'cocoapods-ykutility/function/yk_create_pod_config'
8
- require 'cocoapods-ykutility/function/yk_log_tool'
7
+ require 'cocoapods-ykutility/command/create/yk_create_pod_config'
8
+ require 'cocoapods-ykutility/tools/yk_log_tool'
9
9
  require 'find'
10
10
  include YKPod::YKLogTool
11
11
 
12
12
  require 'cocoapods-ykutility/gem_version'
13
- require 'cocoapods-ykutility/function/yk_exchange_tool'
13
+ require 'cocoapods-ykutility/command/create/yk_exchange_tool'
14
14
  include YKPod::YKExchangeTool
15
15
 
16
16
  def initialize(conf)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module YKPod
4
4
  module YKExchangeTool
5
- require 'cocoapods-ykutility/function/yk_log_tool'
5
+ require 'cocoapods-ykutility/tools/yk_log_tool'
6
6
  include YKPod::YKLogTool
7
7
  def updateFileDirs(rootDir, keyWord, destWord)
8
8
  Dir.glob("#{rootDir}/**/**/**/**").each do |name|
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- require 'cocoapods-ykutility/function/yk_create_pod_action'
2
+ require 'cocoapods-ykutility/command/create/yk_create_pod_action'
3
3
  require 'cocoapods-ykutility/gem_version'
4
4
 
5
5
  module Pod
6
6
  class Command
7
7
  class Ykutility < Command
8
8
 
9
- require 'cocoapods-ykutility/function/yk_create_pod_config'
9
+ require 'cocoapods-ykutility/command/create/yk_create_pod_config'
10
10
  class Create < Ykutility
11
11
 
12
12
  self.summary = 'Creates a new Pod'
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YKApi
4
+ class YkApiAnalysis
5
+ require 'cocoapods-ykutility/tools/yk_log_tool'
6
+ require 'cocoapods-ykutility/command/push/yk_api_parse'
7
+
8
+ require 'cocoapods'
9
+
10
+ include YKPod::YKLogTool
11
+
12
+ attr_accessor :spec_list, :pod_names, :version
13
+ def initialize(podspec_files, source_urls)
14
+ @spec_files = podspec_files
15
+ @source_urls = source_urls
16
+
17
+ @public_headers = []
18
+ @source_files = []
19
+ @swift_files = []
20
+ @pod_names = []
21
+ @version = ""
22
+ end
23
+
24
+ def execute
25
+ analysis_all_specs
26
+ analysis_api
27
+ end
28
+
29
+ def all_pod_names
30
+ "\"#{@pod_names.join(" ")}\""
31
+ end
32
+
33
+ private
34
+ def analysis_all_specs()
35
+ @spec_files.each do |one|
36
+ valid = Pod::Validator.new(one, @source_urls)
37
+ spec = valid.linter.spec
38
+ @version = spec.version.to_s
39
+ analysis_one_spec(spec)
40
+ end
41
+
42
+ ykMessage "all public header files:\n#{@public_headers.join("\n")}"
43
+ ykMessage "all source code files:\n#{@source_files.join("\n")}"
44
+ @swift_files = @source_files.find_all do |onePath|
45
+ onePath.extname == ".swift"
46
+ end
47
+ ykMessage "all swift files:\n#{@swift_files}"
48
+ end
49
+
50
+ def analysis_one_spec(spec)
51
+ path_list = Pod::Sandbox::PathList.new(spec.defined_in_file.dirname)
52
+ file_accessor = Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(Pod::Platform.ios))
53
+ public_header_arr = file_accessor.public_headers
54
+ ykMessage("#{spec.name} --> plubic_headers:\n#{public_header_arr.join("\n")}")
55
+ @public_headers.concat(public_header_arr) unless public_header_arr.blank?
56
+ @pod_names.append(spec.name)
57
+
58
+ source_file_arr = file_accessor.source_files
59
+ ykMessage("#{spec.name} --> source_files:\n#{source_file_arr.join("\n")}")
60
+ @source_files.concat(source_file_arr) unless source_file_arr.blank?
61
+
62
+ sub_spec_arr = spec.subspecs
63
+ ykNotice "#{spec.name} has sub_specs: #{sub_spec_arr.join(",\t")}" unless sub_spec_arr.blank?
64
+ sub_spec_arr.each do |oneSub|
65
+ analysis_one_spec(oneSub)
66
+ end
67
+ end
68
+
69
+ def analysis_api
70
+ api_output_dir = File.join(Dir.pwd, "Api")
71
+ if File.exist?(api_output_dir)
72
+ FileUtils.rm_r(api_output_dir)
73
+ end
74
+
75
+ FileUtils.mkdir(api_output_dir)
76
+ analysis_success = YKApi::YkApiParser.new(@public_headers, @swift_files, api_output_dir).analysis
77
+ analysis_success
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YKApi
4
+ class YkApiParser
5
+
6
+ require 'cocoapods-ykutility/tools/yk_log_tool'
7
+ include YKPod::YKLogTool
8
+
9
+ def initialize(objc_header_file_list, swift_file_list, output_dir)
10
+ @objc_header_files = objc_header_file_list
11
+ @swift_file_list = swift_file_list
12
+ @output_dir = output_dir
13
+ @json_cache = File.join(output_dir, "json_files_tem")
14
+ FileUtils.rm_r(@json_cache) if File.exist?(@json_cache)
15
+ FileUtils.mkdir(@json_cache)
16
+ end
17
+
18
+ def analysis
19
+ json_arr_objc = parse_objc
20
+ json_arr_swift = parse_swift
21
+ create_api(json_arr_objc, json_arr_swift)
22
+ end
23
+
24
+ private
25
+ def parse_objc
26
+ ykNotice("#{self.class} --> #{__method__}")
27
+ # sourcekitten doc --objc NSBundle+YKInternational.h -- -x objective-c -isysroot $(xcrun --show-sdk-path --sdk iphonesimulator) -fmodules > 123
28
+ cache_arr = []
29
+ @objc_header_files.each do |one|
30
+ cache_path = File.join(@json_cache, one.basename)
31
+ cmd = "sourcekitten doc --single-file --objc \"#{one}\" -- -x objective-c -isysroot $(xcrun --show-sdk-path --sdk iphonesimulator) -fmodules > \"#{cache_path}\""
32
+ ykMessage("cmd: #{cmd}")
33
+ code = system(cmd)
34
+ cache_arr.append("\"#{cache_path}\"")
35
+ end
36
+
37
+ cache_arr
38
+ end
39
+
40
+ def parse_swift
41
+ ykNotice("#{self.class} --> #{__method__}")
42
+ # sourcekitten doc --single-file $input_file -- -j4 $input_file >> $temp_outout
43
+
44
+ cache_arr = []
45
+ @swift_file_list.each do |one|
46
+ cache_path = File.join(@json_cache, one.basename)
47
+ cmd = "sourcekitten doc --single-file \"#{one}\" -- -j4 \"#{one}\" > \"#{cache_path}\""
48
+ ykNotice("cmd: #{cmd}")
49
+ code = system(cmd)
50
+ cache_arr.append("\"#{cache_path}\"")
51
+ end
52
+
53
+ cache_arr
54
+ end
55
+
56
+ def create_api(json_objc_arr, json_swift_arr)
57
+ json_all = json_objc_arr + json_swift_arr
58
+
59
+ json_all.map
60
+ cmd = "jazzy --min-acl public --sourcekitten-sourcefile #{json_all.join(",")}"
61
+ cmd << " -o \"#{@output_dir}\""
62
+ ykMessage("cmd: \n#{cmd}")
63
+ cmd_result =system(cmd)
64
+ cmd_result
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'git'
4
+ module Git
5
+ class Base
6
+ def is_clean
7
+ cmd = "git status --short"
8
+ @cmd_out_put = []
9
+ IO.popen(cmd) do |f|
10
+ line = f.gets
11
+ @cmd_out_put << line unless line.blank?
12
+ end
13
+
14
+ @cmd_out_put.blank?
15
+ end
16
+ end
17
+ end
18
+
19
+ module YKUtitlityGitModule
20
+ class YKGitManager
21
+ require 'git'
22
+ require 'cocoapods-ykutility/tools/yk_log_tool'
23
+ include YKPod::YKLogTool
24
+
25
+ def initialize(dir)
26
+ @dir = dir
27
+
28
+ Dir.chdir(dir) do
29
+ @git = Git.open(Dir.pwd)
30
+ end
31
+ end
32
+
33
+ def prepare
34
+ is_clean = @git.is_clean
35
+ if is_clean == false
36
+ ykNotice("work tree dirty, work finish") unless is_clean
37
+ return false
38
+ end
39
+ return true
40
+ end
41
+
42
+ def commit_for_api(commit_message)
43
+ begin
44
+ @git.add(:all => true)
45
+ @git.commit(commit_message)
46
+ @git.push('origin', @git.current_branch)
47
+ rescue Git::FailedError => e
48
+ puts(e.to_s)
49
+ end
50
+ end
51
+
52
+ def update_tag(dest_tag)
53
+ delete_dest_tag(dest_tag.to_s) # 删除原有tag
54
+ create_dest_tag(dest_tag.to_s) # 新建tag
55
+ end
56
+
57
+ private
58
+
59
+ def create_dest_tag(dest_tag)
60
+ return false unless prepare == true
61
+
62
+ puts "start create tag"
63
+ @git.add_tag(dest_tag, :m => "\"#{dest_tag}\" -- auto created with api document, by 'cocoapods-ykutility'")
64
+ @git.push('origin', dest_tag)
65
+ end
66
+
67
+ def delete_dest_tag(dest_tag)
68
+ # 此处需要防止本地有tag, 而远端不存在, 所以此处做如下操作
69
+ # 1. 检查本地tag
70
+ # 2. 删除本地tag
71
+ # 3. 拉取远端tag
72
+ # 4. 删除本地和远端tag
73
+
74
+ begin
75
+ exist_tag = @git.tag(dest_tag)
76
+ rescue Git::GitTagNameDoesNotExist => e
77
+ end
78
+
79
+ ykNotice("tag [#{dest_tag}] existed, we delete it on local and remote \"origin\"") unless exist_tag.blank?
80
+ begin
81
+ @git.delete_tag(dest_tag) unless exist_tag.blank?
82
+ @git.push('origin', dest_tag, :delete => true) unless exist_tag.blank?
83
+ rescue Git::FailedError => e
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pod
4
+ class Command
5
+ class Ykutility < Command
6
+ class Push < Ykutility
7
+ require 'cocoapods/command/repo/push'
8
+ require 'cocoapods-ykutility/tools/yk_log_tool'
9
+ require 'cocoapods-ykutility/command/push/yk_api_analysis'
10
+ require 'cocoapods-ykutility/command/push/yk_git_manager'
11
+
12
+ include YKPod::YKLogTool
13
+
14
+ include Pod::Config::Mixin
15
+ self.summary = 'Release a new pod version'
16
+
17
+ self.description = <<-DESC
18
+ 组件发布新版本
19
+ DESC
20
+
21
+ attr_accessor :repo_push_cmd
22
+ attr_accessor :argv_cache
23
+
24
+ self.arguments = Pod::Command::Repo::Push.arguments
25
+
26
+ def self.options
27
+ Pod::Command::Repo::Push.options.concat(super)
28
+ end
29
+
30
+ def initialize(argv)
31
+ # 如果有一部分参数是本类特有的,需要在此处优先取出
32
+ argv_map = argv.remainder
33
+ argv_new = CLAide::ARGV.new(argv.remainder)
34
+ @repo_push_cmd = Pod::Command::Repo::Push.new(argv_new)
35
+
36
+ # 因为这部分参数是 本类 和 Pod::Command::Repo::Push 共有的, 所以本类用 argv 取参数, Pod::Command::Repo::Push使用 argv_map 取参数
37
+ @repo = argv.shift_argument
38
+ @podspec = argv.shift_argument
39
+ @source = source_for_repo
40
+ @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).append(Pod::TrunkSource::TRUNK_REPO_URL).uniq.join(',')).split(',')
41
+ argv_extra = argv_new.remainder
42
+ argv_extra.append("--help") if argv_map.include?("--help")
43
+ super(CLAide::ARGV.new(argv_extra))
44
+ end
45
+
46
+ def validate! # 此处validate 是复制 Pod::Command::Repo::Push , 因为如果直接用 self.repo_push_cmd.validate! 会导致提示显示的是 Pod::Command::Repo::Push 的使用说明
47
+ super
48
+
49
+ help! 'A spec-repo name or url is required.' unless @repo
50
+ unless @source && @source.repo.directory?
51
+ raise Informative,
52
+ "Unable to find the `#{@repo}` repo. " \
53
+ 'If it has not yet been cloned, add it via `pod repo add`.'
54
+ end
55
+ end
56
+
57
+ def run
58
+ gitmanager = YKUtitlityGitModule::YKGitManager.new(Dir.pwd)
59
+ return false unless gitmanager.prepare == true
60
+
61
+ ykNotice "pod ykutility push running !"
62
+ self.repo_push_cmd.run # 使用Pod::Command::Repo::Push,发布pod
63
+
64
+ ykNotice "pod ykutility analysis create document running !"
65
+ api_analysis = YKApi::YkApiAnalysis.new(podspec_files, @source_urls)
66
+ aanlysis_success = api_analysis.execute
67
+ raise Informative, "Failed to analysis Component api: #{api_analysis.all_pod_names}" unless aanlysis_success == true
68
+ # 解析podspec, 识别出 公共文件, tag
69
+ # 根据公共文件,生成接口文档
70
+ # 检查tag是否存在,删除已有tag, 删除远端已有tag
71
+ # 添加接口文档,并提交,生成对应版本的tag,并对送到远端
72
+ version = api_analysis.version
73
+
74
+ gitmanager.commit_for_api("create api document for version: #{version.to_s}")
75
+ gitmanager.update_tag(version.to_s)
76
+
77
+ end
78
+
79
+ private
80
+
81
+ def podspec_files
82
+ if @podspec
83
+ path = Pathname(@podspec)
84
+ raise Informative, "Couldn't find #{@podspec}" unless path.exist?
85
+ [path]
86
+ else
87
+ files = Pathname.glob('*.podspec{,.json}')
88
+ raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
89
+ files
90
+ end
91
+ end
92
+
93
+ def source_for_repo
94
+ self.config.sources_manager.source_with_name_or_url(@repo) unless @repo.nil?
95
+ rescue
96
+ nil
97
+ end
98
+
99
+ end
100
+ end
101
+ end
102
+ end
@@ -1,4 +1,4 @@
1
1
  module CocoapodsYkPodUtility
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  YK_POD_TEMPLATE_PATH = File.expand_path(File.join(__FILE__, '../../../podTemplate'))
4
4
  end
@@ -2,7 +2,10 @@
2
2
 
3
3
  module YKPod
4
4
  module YKLogTool
5
+ require 'cocoapods'
6
+
5
7
  def ykWarning(message)
8
+ verbose = Pod::Config.instance.verbose
6
9
  puts "\n[⚠️] #{message}".yellow
7
10
  return 0
8
11
  end
@@ -12,6 +15,11 @@ module YKPod
12
15
  return 0
13
16
  end
14
17
 
18
+ def ykMessage(message)
19
+ puts "\n#{message}" if Pod::Config.instance.verbose
20
+ return 0
21
+ end
22
+
15
23
  def ykError(message)
16
24
  puts "\n[❌] #{message}".red
17
25
  return 1
@@ -3,7 +3,7 @@
3
3
  archiveVersion = 1;
4
4
  classes = {
5
5
  };
6
- objectVersion = 56;
6
+ objectVersion = 55;
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
@@ -104,7 +104,7 @@
104
104
  };
105
105
  };
106
106
  buildConfigurationList = FDDD855D299DED6500EAB62E /* Build configuration list for PBXProject "YKRPC_POD_NAME_Example" */;
107
- compatibilityVersion = "Xcode 14.0";
107
+ compatibilityVersion = "Xcode 13.0";
108
108
  developmentRegion = en;
109
109
  hasScannedForEncodings = 0;
110
110
  knownRegions = (
metadata CHANGED
@@ -1,15 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-ykutility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - stephen.chen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-17 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2023-03-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jazzy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: git
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
13
69
  description: 创建定制化标准组件.
14
70
  email:
15
71
  - stephenchen@yeahka.com
@@ -20,12 +76,16 @@ files:
20
76
  - lib/cocoapods-ykutility.rb
21
77
  - lib/cocoapods-ykutility/command.rb
22
78
  - lib/cocoapods-ykutility/command/Ykutility.rb
23
- - lib/cocoapods-ykutility/command/ykutility/create.rb
24
- - lib/cocoapods-ykutility/function/yk_create_pod_action.rb
25
- - lib/cocoapods-ykutility/function/yk_create_pod_config.rb
26
- - lib/cocoapods-ykutility/function/yk_exchange_tool.rb
27
- - lib/cocoapods-ykutility/function/yk_log_tool.rb
79
+ - lib/cocoapods-ykutility/command/create.rb
80
+ - lib/cocoapods-ykutility/command/create/yk_create_pod_action.rb
81
+ - lib/cocoapods-ykutility/command/create/yk_create_pod_config.rb
82
+ - lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
83
+ - lib/cocoapods-ykutility/command/push.rb
84
+ - lib/cocoapods-ykutility/command/push/yk_api_analysis.rb
85
+ - lib/cocoapods-ykutility/command/push/yk_api_parse.rb
86
+ - lib/cocoapods-ykutility/command/push/yk_git_manager.rb
28
87
  - lib/cocoapods-ykutility/gem_version.rb
88
+ - lib/cocoapods-ykutility/tools/yk_log_tool.rb
29
89
  - lib/cocoapods_plugin.rb
30
90
  - podTemplate/example/Podfile
31
91
  - podTemplate/example/Podfile.lock
@@ -62,7 +122,7 @@ homepage: https://github.com/stephen5652/cocoapods-yk-pod-utility.git
62
122
  licenses:
63
123
  - MIT
64
124
  metadata: {}
65
- post_install_message:
125
+ post_install_message:
66
126
  rdoc_options: []
67
127
  require_paths:
68
128
  - lib
@@ -77,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
137
  - !ruby/object:Gem::Version
78
138
  version: '0'
79
139
  requirements: []
80
- rubygems_version: 3.2.3
81
- signing_key:
140
+ rubygems_version: 3.1.6
141
+ signing_key:
82
142
  specification_version: 4
83
143
  summary: 一款cocoapods插件,用于创建定制化标准组件.
84
144
  test_files: []