yk_command 0.4.5 → 0.4.6

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 (29) hide show
  1. checksums.yaml +4 -4
  2. data/.idea/yk_command.iml +20 -21
  3. data/Gemfile.lock +30 -32
  4. data/lib/yk_command/analyze/analyze.rb +153 -0
  5. data/lib/yk_command/{dependency_handler.rb → analyze/dependency_handler.rb} +0 -0
  6. data/lib/yk_command/analyze/dependency_result.rb +143 -0
  7. data/lib/yk_command/{request.rb → analyze/request.rb} +0 -0
  8. data/lib/yk_command/commands.rb +9 -300
  9. data/lib/yk_command/{template → module/template}/objc/CategoryHeader.h +0 -0
  10. data/lib/yk_command/{template → module/template}/objc/PrefixHeader.pch +0 -0
  11. data/lib/yk_command/{template → module/template}/objc/RouterDefine.h +0 -0
  12. data/lib/yk_command/{template → module/template}/objc/RouterRegister.h +0 -0
  13. data/lib/yk_command/{template → module/template}/objc/RouterRegister.m +0 -0
  14. data/lib/yk_command/{template → module/template}/objc/ServiceProtocol.h +0 -0
  15. data/lib/yk_command/{template → module/template}/objc/ServiceRegister.h +0 -0
  16. data/lib/yk_command/{template → module/template}/objc/ServiceRegister.m +0 -0
  17. data/lib/yk_command/{template → module/template}/objc/ToolsHeader.h +0 -0
  18. data/lib/yk_command/{template → module/template}/objc/VendorHeader.h +0 -0
  19. data/lib/yk_command/{template → module/template}/objc/demo/DemoViewController.h +0 -0
  20. data/lib/yk_command/{template → module/template}/objc/demo/DemoViewController.m +0 -0
  21. data/lib/yk_command/{template → module/template}/objc/demo/DemoViewModel.h +0 -0
  22. data/lib/yk_command/{template → module/template}/objc/demo/DemoViewModel.m +0 -0
  23. data/lib/yk_command/{template → module/template}/swift/RouterDefine.swift +0 -0
  24. data/lib/yk_command/module/yk_module.rb +226 -0
  25. data/lib/yk_command/version.rb +1 -1
  26. data/yk_command.gemspec +2 -3
  27. metadata +29 -42
  28. data/lib/yk_command/analyze.rb +0 -129
  29. data/lib/yk_command/yk_module.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0728897c8ae743e8ff166940e9536c16dbc034e91892e3aebe58d5b975a6c7
4
- data.tar.gz: 1c604dc3e126b38a6eb15543a7653005d14059745a402d46d5d3bee53aa7778a
3
+ metadata.gz: d89f3768c235497f3ae61c5e59802e4a2868ee40e5b62d47972a253bb132df1d
4
+ data.tar.gz: 7b16ce57007246923d6971de227f2527029d7b33c1caa5cdd6d12501668d6ea8
5
5
  SHA512:
6
- metadata.gz: 28135d9a0220d008e6fe59b6cd4d932078373304f443b8bf09080d09d0ccad269f6c6358e7a37e4368d588dfd965b41e0f8e84fa1e5807bcd81c80d3f645eac0
7
- data.tar.gz: ea371ab70e6918c906249c40b9237017eb37b477e0e4ededcfbc1afc2793af16add2f7d86c8b179f46562051d89178484176d5e1ab4b64a61a7e6d8d9c580e2f
6
+ metadata.gz: 772ca575c37fceeaee120d2f9bc9f366119be6dd85c1052ed2063d8046a163b9ca39b2c1e11ee54e18a1597fc6c656891b0397edc5ef245908f66c7aa4cf863f
7
+ data.tar.gz: 764309eaa9f45ceac75ae7d354d72ec364d663a52840824c194c12f251ffcbc94c724b1f74cca5d22514e419113c61d4072d8102848ffa53f5a46e691e165882
data/.idea/yk_command.iml CHANGED
@@ -12,7 +12,7 @@
12
12
  <orderEntry type="jdk" jdkName="RVM: ruby-2.7.2 [tom]" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
14
  <orderEntry type="library" scope="PROVIDED" name="CFPropertyList (v3.0.5, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v5.2.7, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.6, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
16
16
  <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
17
17
  <orderEntry type="library" scope="PROVIDED" name="algoliasearch (v1.27.5, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
18
18
  <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
@@ -22,7 +22,7 @@
22
22
  <orderEntry type="library" scope="PROVIDED" name="cocoapods (v1.11.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
23
23
  <orderEntry type="library" scope="PROVIDED" name="cocoapods-core (v1.11.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
24
24
  <orderEntry type="library" scope="PROVIDED" name="cocoapods-deintegrate (v1.0.5, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="cocoapods-downloader (v1.6.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="cocoapods-downloader (v1.6.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
26
26
  <orderEntry type="library" scope="PROVIDED" name="cocoapods-plugins (v1.0.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
27
27
  <orderEntry type="library" scope="PROVIDED" name="cocoapods-search (v1.0.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
28
28
  <orderEntry type="library" scope="PROVIDED" name="cocoapods-trunk (v1.6.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
@@ -37,8 +37,7 @@
37
37
  <orderEntry type="library" scope="PROVIDED" name="fourflusher (v2.3.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
38
38
  <orderEntry type="library" scope="PROVIDED" name="fuzzy_match (v2.0.4, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
39
39
  <orderEntry type="library" scope="PROVIDED" name="gh_inspector (v1.1.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="git (v1.10.2, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="gitlab (v4.18.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="git (v1.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
42
41
  <orderEntry type="library" scope="PROVIDED" name="httparty (v0.20.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
43
42
  <orderEntry type="library" scope="PROVIDED" name="httpclient (v2.8.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
44
43
  <orderEntry type="library" scope="PROVIDED" name="i18n (v1.10.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
@@ -51,50 +50,50 @@
51
50
  <orderEntry type="library" scope="PROVIDED" name="nanaimo (v0.3.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
52
51
  <orderEntry type="library" scope="PROVIDED" name="nap (v1.1.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
53
52
  <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
55
- <orderEntry type="library" scope="PROVIDED" name="parser (v2.7.2.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
56
- <orderEntry type="library" scope="PROVIDED" name="pathname (v0.2.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
57
- <orderEntry type="library" scope="PROVIDED" name="powerpack (v0.1.3, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
58
- <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.6, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
59
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v2.2.2, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
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
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.7, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
60
58
  <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
61
59
  <orderEntry type="library" scope="PROVIDED" name="rchardet (v1.8.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.4.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
62
61
  <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
63
62
  <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
64
63
  <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
65
64
  <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
66
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
65
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
67
66
  <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
68
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v0.50.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
67
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.29.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
68
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.17.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
69
69
  <orderEntry type="library" scope="PROVIDED" name="ruby-macho (v2.5.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
70
70
  <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
71
- <orderEntry type="library" scope="PROVIDED" name="terminal-table (v3.0.2, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
72
71
  <orderEntry type="library" scope="PROVIDED" name="thor (v1.2.1, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
73
- <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.6, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
74
72
  <orderEntry type="library" scope="PROVIDED" name="typhoeus (v1.4.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
75
- <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.9, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
76
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v1.8.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
73
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
74
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
77
75
  <orderEntry type="library" scope="PROVIDED" name="xcodeproj (v1.21.0, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
76
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.4, RVM: ruby-2.7.2 [tom]) [gem]" level="application" />
78
77
  </component>
79
78
  <component name="RakeTasksCache">
80
79
  <option name="myRootTask">
81
80
  <RakeTaskImpl id="rake">
82
81
  <subtasks>
83
- <RakeTaskImpl description="Build yk_command-0.4.0.gem into the pkg directory" fullCommand="build" id="build" />
82
+ <RakeTaskImpl description="Build yk_command-0.4.5.gem into the pkg directory" fullCommand="build" id="build" />
84
83
  <RakeTaskImpl id="build">
85
84
  <subtasks>
86
- <RakeTaskImpl description="Generate SHA512 checksum if yk_command-0.4.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
85
+ <RakeTaskImpl description="Generate SHA512 checksum if yk_command-0.4.5.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
87
86
  </subtasks>
88
87
  </RakeTaskImpl>
89
88
  <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
90
89
  <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
91
- <RakeTaskImpl description="Build and install yk_command-0.4.0.gem into system gems" fullCommand="install" id="install" />
90
+ <RakeTaskImpl description="Build and install yk_command-0.4.5.gem into system gems" fullCommand="install" id="install" />
92
91
  <RakeTaskImpl id="install">
93
92
  <subtasks>
94
- <RakeTaskImpl description="Build and install yk_command-0.4.0.gem into system gems without network access" fullCommand="install:local" id="local" />
93
+ <RakeTaskImpl description="Build and install yk_command-0.4.5.gem into system gems without network access" fullCommand="install:local" id="local" />
95
94
  </subtasks>
96
95
  </RakeTaskImpl>
97
- <RakeTaskImpl description="Create tag v0.4.0 and build and push yk_command-0.4.0.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
96
+ <RakeTaskImpl description="Create tag v0.4.5 and build and push yk_command-0.4.5.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
98
97
  <RakeTaskImpl description="" fullCommand="default" id="default" />
99
98
  <RakeTaskImpl description="" fullCommand="release" id="release" />
100
99
  <RakeTaskImpl id="release">
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yk_command (0.4.5)
4
+ yk_command (0.4.6)
5
5
  bundler
6
6
  colored
7
+ colored2
7
8
  git
8
- gitlab
9
9
  httparty
10
- pathname
10
+ pathname (= 0.1.0)
11
11
  thor
12
12
  xcodeproj
13
13
 
@@ -16,11 +16,12 @@ GEM
16
16
  specs:
17
17
  CFPropertyList (3.0.5)
18
18
  rexml
19
- activesupport (5.2.7)
19
+ activesupport (6.1.6)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
- i18n (>= 0.7, < 2)
22
- minitest (~> 5.1)
23
- tzinfo (~> 1.1)
21
+ i18n (>= 1.6, < 2)
22
+ minitest (>= 5.1)
23
+ tzinfo (~> 2.0)
24
+ zeitwerk (~> 2.3)
24
25
  addressable (2.8.0)
25
26
  public_suffix (>= 2.0.2, < 5.0)
26
27
  algoliasearch (1.27.5)
@@ -58,7 +59,7 @@ GEM
58
59
  public_suffix (~> 4.0)
59
60
  typhoeus (~> 1.0)
60
61
  cocoapods-deintegrate (1.0.5)
61
- cocoapods-downloader (1.6.1)
62
+ cocoapods-downloader (1.6.3)
62
63
  cocoapods-plugins (1.0.0)
63
64
  nap
64
65
  cocoapods-search (1.0.1)
@@ -77,11 +78,8 @@ GEM
77
78
  fourflusher (2.3.1)
78
79
  fuzzy_match (2.0.4)
79
80
  gh_inspector (1.1.3)
80
- git (1.10.2)
81
+ git (1.11.0)
81
82
  rchardet (~> 1.8)
82
- gitlab (4.18.0)
83
- httparty (~> 0.18)
84
- terminal-table (>= 1.5.1)
85
83
  httparty (0.20.0)
86
84
  mime-types (~> 3.0)
87
85
  multi_xml (>= 0.5.2)
@@ -98,16 +96,15 @@ GEM
98
96
  nanaimo (0.3.0)
99
97
  nap (1.1.0)
100
98
  netrc (0.11.0)
101
- parallel (1.21.0)
102
- parser (2.7.2.0)
99
+ parallel (1.22.1)
100
+ parser (3.1.2.0)
103
101
  ast (~> 2.4.1)
104
- pathname (0.2.0)
105
- powerpack (0.1.3)
106
- public_suffix (4.0.6)
107
- rainbow (2.2.2)
108
- rake
102
+ pathname (0.1.0)
103
+ public_suffix (4.0.7)
104
+ rainbow (3.1.1)
109
105
  rake (13.0.6)
110
106
  rchardet (1.8.0)
107
+ regexp_parser (2.4.0)
111
108
  rexml (3.2.5)
112
109
  rspec (3.11.0)
113
110
  rspec-core (~> 3.11.0)
@@ -118,28 +115,29 @@ GEM
118
115
  rspec-expectations (3.11.0)
119
116
  diff-lcs (>= 1.2.0, < 2.0)
120
117
  rspec-support (~> 3.11.0)
121
- rspec-mocks (3.11.0)
118
+ rspec-mocks (3.11.1)
122
119
  diff-lcs (>= 1.2.0, < 2.0)
123
120
  rspec-support (~> 3.11.0)
124
121
  rspec-support (3.11.0)
125
- rubocop (0.50.0)
122
+ rubocop (1.29.1)
126
123
  parallel (~> 1.10)
127
- parser (>= 2.3.3.1, < 3.0)
128
- powerpack (~> 0.1)
129
- rainbow (>= 2.2.2, < 3.0)
124
+ parser (>= 3.1.0.0)
125
+ rainbow (>= 2.2.2, < 4.0)
126
+ regexp_parser (>= 1.8, < 3.0)
127
+ rexml (>= 3.2.5, < 4.0)
128
+ rubocop-ast (>= 1.17.0, < 2.0)
130
129
  ruby-progressbar (~> 1.7)
131
- unicode-display_width (~> 1.0, >= 1.0.1)
130
+ unicode-display_width (>= 1.4.0, < 3.0)
131
+ rubocop-ast (1.17.0)
132
+ parser (>= 3.1.1.0)
132
133
  ruby-macho (2.5.1)
133
134
  ruby-progressbar (1.11.0)
134
- terminal-table (3.0.2)
135
- unicode-display_width (>= 1.1.1, < 3)
136
135
  thor (1.2.1)
137
- thread_safe (0.3.6)
138
136
  typhoeus (1.4.0)
139
137
  ethon (>= 0.9.0)
140
- tzinfo (1.2.9)
141
- thread_safe (~> 0.1)
142
- unicode-display_width (1.8.0)
138
+ tzinfo (2.0.4)
139
+ concurrent-ruby (~> 1.0)
140
+ unicode-display_width (2.1.0)
143
141
  xcodeproj (1.21.0)
144
142
  CFPropertyList (>= 2.3.3, < 4.0)
145
143
  atomos (~> 0.1.3)
@@ -147,6 +145,7 @@ GEM
147
145
  colored2 (~> 3.1)
148
146
  nanaimo (~> 0.3.0)
149
147
  rexml (~> 3.2.4)
148
+ zeitwerk (2.5.4)
150
149
 
151
150
  PLATFORMS
152
151
  x86_64-darwin-21
@@ -157,7 +156,6 @@ DEPENDENCIES
157
156
  cocoapods-core
158
157
  colored
159
158
  colored2
160
- gitlab
161
159
  httparty
162
160
  rake (~> 13.0)
163
161
  rspec (~> 3.2)
@@ -0,0 +1,153 @@
1
+ require 'cocoapods'
2
+ require 'pathname'
3
+ require 'pp'
4
+ require 'tmpdir'
5
+ require 'json'
6
+
7
+ require 'rainbow'
8
+ require 'yaml'
9
+ require 'git'
10
+ require 'yk_command/analyze/dependency_result'
11
+
12
+ module YkCommand
13
+ IGNORE_PROJECT_FILE = '.YKAnalyzeConfig.yml'.freeze
14
+
15
+ class Analyzer < Thor
16
+ no_commands do
17
+
18
+ def dependency(path = nil)
19
+ say "\ncurrent working folder: #{path}\n"
20
+ project_path = ''
21
+ project_name = ''
22
+ begin
23
+ g = Git.open(path)
24
+ project_path = Pathname.new(g.lib.git_work_dir)
25
+ project_name = g.config['remote.origin.url'].split('/').last.split('.')[0]
26
+
27
+ unless project_name.empty?
28
+ podfiles = Dir.glob("#{path}/**/Podfile")
29
+ if !podfiles.empty?
30
+ begin
31
+ project_path = podfiles[podfiles.length - 1]
32
+ podfile_dir = Pathname.new(project_path).dirname.to_s
33
+ say "start analyze... path contain [Podfile ,Pods/ ,Podfile.lock] is #{podfile_dir} \n ", :green
34
+ result = analyze(podfile_dir)
35
+ app_info = Request.new.get_project_info(project_name)
36
+ if app_info['id']
37
+ say "uploading dependencies for project #{project_name} ..."
38
+ upload_res = Request.new.upload_app_dependency(app_info['id'], result)
39
+ if upload_res['code'] == 0
40
+ result(0, project_name, 'uploaded , finished ', :green)
41
+ else
42
+ result(1, project_name, "Error :upload dependencies for project #{project_name} - #{app_info["id"]} failed ", :red)
43
+ end
44
+ else
45
+ result(1, project_name, "Error :Get App project ID failed , #{project_name}", :red)
46
+ end
47
+
48
+ rescue
49
+ say "Error : #{$!}", :red
50
+ say "Error : #{ $@}", :red
51
+ result(1, project_name, "Skip folder : #{podfile_dir} ", :red)
52
+ end
53
+
54
+ else
55
+ result(2, project_name, "No podfile find ,Skip folder : #{project_name} ", :yellow)
56
+ end
57
+
58
+ end
59
+
60
+ rescue
61
+ result(2, '', "No .git folder find in #{path} ,skip folder ... ", :yellow)
62
+
63
+ end
64
+
65
+ end
66
+
67
+ def result(code, name, message, color)
68
+ say message, color
69
+ say "\n<--\n", color
70
+ { 'code' => "#{code}", 'name' => "#{name}" }
71
+ end
72
+
73
+ def workspace_analyze(path = nil)
74
+ Dir.chdir(path)
75
+ subdir_list = Dir['*'].reject { |o| not File.directory?(o) }
76
+ say "Start in Workspace : #{path} ...", :yellow
77
+ subdir_list.each do |project_dir|
78
+ say "\n#{Pathname.new(project_dir).split[1]} ", :yellow
79
+ end
80
+ say "\n\n"
81
+ say "\n ... start scanning to analyze ...\n\n"
82
+
83
+ success_count = 0
84
+ success_name_list = []
85
+ failed_count = 0
86
+ failed_name_list = []
87
+ skip_count = 0
88
+
89
+ subdir_list.each { |project_dir|
90
+ project_path = "#{path}/#{project_dir}"
91
+ res = dependency project_path
92
+ if res['code'] == '0'
93
+ success_count += 1
94
+ success_name_list << res['name']
95
+ elsif res['code'] == '1'
96
+ failed_count += 1
97
+ failed_name_list << res['name']
98
+ else
99
+ skip_count += 1
100
+ end
101
+ }
102
+
103
+ say "\nworkspace analyze done ! ..."
104
+ say "success:#{success_count},#{success_name_list}", :green
105
+ say "failed :#{failed_count},#{failed_name_list}", :red
106
+ say "skip :#{skip_count}", :yellow
107
+
108
+ end
109
+
110
+ def ignore_file(path = nil)
111
+ ignore_file_path = "#{path}/#{IGNORE_PROJECT_FILE}"
112
+ ignore = File.exist?(ignore_file_path) ? YAML.load_file(ignore_file_path) : {}
113
+ ignore[:projects] = ["ShouYinTong", "ShouYinTongSaas"]
114
+ File.open(ignore_file_path, 'w') do |f|
115
+ f.write ignore.to_yaml
116
+ end
117
+ end
118
+
119
+ def analyze(podfile_dir_path)
120
+ @path = Pathname.new(podfile_dir_path)
121
+ raise 'absolute path is needed' unless @path.absolute?
122
+ Pod::Config.instance.installation_root = @path
123
+ @podFile = Pod::Podfile.from_file(@path + 'Podfile')
124
+ @podLock = Pod::Lockfile.from_file(@path + 'Podfile.lock')
125
+
126
+ Dir.chdir(podfile_dir_path) do
127
+ analyze_with_podfile
128
+ end
129
+
130
+ end
131
+
132
+ def analyze_with_podfile
133
+ sandbox = Dir.pwd + '/Pods'
134
+ # if @path
135
+ # sandbox = Dir.mktmpdir
136
+ # else
137
+ # end
138
+
139
+ analyzer = Pod::Installer::Analyzer.new(
140
+ Pod::Sandbox.new(sandbox),
141
+ @podFile,
142
+ @podLock
143
+ )
144
+
145
+ specifications = analyzer.analyze.specifications.map(&:root).uniq
146
+ array = []
147
+ dependency_result = DependencyResult.new(specifications, @podLock)
148
+ dependency_result.result_json
149
+ end
150
+
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,143 @@
1
+ require 'cocoapods'
2
+ require 'cocoapods-core/lockfile'
3
+
4
+ COMPONENT_TYPE = ['基础组件', 'UI组件', '通用业务组件', '业务模块', '其它']
5
+
6
+ FOUNDATION_COMPONENT_NAMES = ['基础组件', 'UI组件', '通用业务组件', '业务模块', '其它']
7
+
8
+ UI_COMPONENT_NAMES = ['']
9
+
10
+ COMMON_BUSINESS_COMPONENT_NAMES = ['']
11
+
12
+ UNCATEGORIZE_COMPONENT_NAMES = ['']
13
+
14
+ SPECIFICATION_FILTER_KEYS = ['summary', 'homepage', 'authors', "source"]
15
+
16
+ module YkCommand
17
+
18
+ class DependencyResult
19
+
20
+ def initialize(specifications, pod_lock)
21
+ @specifications = specifications
22
+ @pod_lock = pod_lock
23
+ @result = []
24
+ end
25
+
26
+ def find_info_in_lokfile
27
+
28
+ removed_subspecs_dep_list = []
29
+ @pod_lock.pod_names.each do |pn|
30
+ removed_subspecs_dep_list = removed_subspecs_dep_list.push(pn.split('/')[0]).uniq
31
+ end
32
+
33
+ #去重后的 依赖 名字 数组
34
+ removed_subspecs_dep_list.each do |pod_name|
35
+ map = {}
36
+ version = @pod_lock.version(pod_name).version
37
+ spec_repo_name = @pod_lock.spec_repo(pod_name)
38
+ is_local_dependency = is_pod_from_local pod_name
39
+ is_yk_dependency = is_yk_dependency pod_name
40
+ is_install_from_git_commit = !@pod_lock.checkout_options_for_pod_named(pod_name).nil?
41
+ dep_attribute_in_pod_file = find_info_in_specifications pod_name
42
+ # pp "#{pod_name} #{spec_repo_name} #{version} local:#{is_local_dependency} ,yeahka:#{is_yk_dependency},git_commit: #{is_install_from_git_commit}"
43
+ map["name"] = pod_name
44
+ map["version"] = version
45
+ map["is_local_dependency"] = is_local_dependency
46
+ map["is_yk_dependency"] = is_yk_dependency
47
+ map["is_install_from_git_commit"] = is_install_from_git_commit.nil?
48
+ dep_attribute_in_pod_file.each do |k, v|
49
+ if SPECIFICATION_FILTER_KEYS.include?(k)
50
+ map[k] = v
51
+ end
52
+ end
53
+
54
+ @result.push map
55
+
56
+ end
57
+
58
+ end
59
+
60
+ def result_json
61
+ find_info_in_lokfile
62
+ @result.to_json
63
+ end
64
+
65
+ def is_yk_dependency(name)
66
+ tag = false
67
+
68
+ @pod_lock.dependencies.each do |dep|
69
+ next unless dep.name == name && !dep.external_source.nil?
70
+
71
+ dep.external_source.each do |k, v|
72
+ next unless k == :git && v.include?('yeahka')
73
+
74
+ tag = true
75
+ end
76
+ end
77
+ tag
78
+ end
79
+
80
+ def is_pod_from_local(name)
81
+ tag = false
82
+
83
+ @pod_lock.dependencies.each do |dep|
84
+ next unless dep.name == name && !dep.external_source.nil?
85
+
86
+ dep.external_source.each do |k, v|
87
+ next unless k == :path
88
+
89
+ tag = true
90
+ end
91
+ end
92
+ tag
93
+ end
94
+
95
+ def find_info_in_specifications(name)
96
+ map = {}
97
+ @specifications.each do |sp|
98
+ next unless sp.name == name
99
+ map = sp.attributes_hash
100
+ end
101
+ map
102
+ end
103
+
104
+ # def podfile_dependencies(podfile)
105
+ # res = []
106
+ # podfile.root_target_definitions.each do |td|
107
+ # children_definitions = td.recursive_children
108
+ # children_definitions.each do |cd|
109
+ # dependencies_hash_array = cd.send(:get_hash_value, 'dependencies')
110
+ # next if dependencies_hash_array.nil? || dependencies_hash_array.count.zero?
111
+ #
112
+ # dependencies_hash_array.each do |item|
113
+ # next if item.class.name != 'Hash'
114
+ #
115
+ # item.each do |name, _|
116
+ # res.push name
117
+ # end
118
+ # end
119
+ # end
120
+ # end
121
+ # res
122
+ # end
123
+ #
124
+ # def find_dependencies(name, map, res, dependencies_map, root_name)
125
+ # return unless map[name]
126
+ #
127
+ # map[name].each do |k|
128
+ # find_dependencies(k.name, map, res, dependencies_map, root_name)
129
+ # dependency = dependencies_map[k.name.split('/')[0]]
130
+ # res.push dependency.name if dependency && dependency.name != root_name
131
+ # end
132
+ # res
133
+ # end
134
+ #
135
+ # def subspecs_with_name(spec, subspecs_short_names)
136
+ # subspecs_short_names.map do |name|
137
+ # spec.subspecs.find { |ss| ss.name.include? name }
138
+ # end
139
+ # end
140
+ #
141
+ #
142
+ end
143
+ end
File without changes