cocoapods-vemars 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-vemars.gemspec +23 -0
- data/lib/cocoapods-vemars.rb +13 -0
- data/lib/cocoapods-vemars/command.rb +1 -0
- data/lib/cocoapods-vemars/command/basicInfo.rb +52 -0
- data/lib/cocoapods-vemars/command/component.rb +25 -0
- data/lib/cocoapods-vemars/command/project.rb +140 -0
- data/lib/cocoapods-vemars/command/vemars.rb +34 -0
- data/lib/cocoapods-vemars/command/vemars/baselines.rb +22 -0
- data/lib/cocoapods-vemars/command/vemars/components.rb +40 -0
- data/lib/cocoapods-vemars/command/vemars/create.rb +92 -0
- data/lib/cocoapods-vemars/command/vemars/patch.rb +80 -0
- data/lib/cocoapods-vemars/gem_version.rb +3 -0
- data/lib/cocoapods-vemars/hook/podfile.rb +14 -0
- data/lib/cocoapods-vemars/hook/podfile_template.rb +110 -0
- data/lib/cocoapods-vemars/services/baselines_api.rb +31 -0
- data/lib/cocoapods-vemars/services/components_api.rb +60 -0
- data/lib/cocoapods-vemars/services/patcher.rb +198 -0
- data/lib/cocoapods-vemars/services/renamer.rb +88 -0
- data/lib/cocoapods-vemars/services/tailor.rb +38 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/plugins.rb +1 -0
- data/spec/command/vemars_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +102 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pod
|
2
|
+
class Command
|
3
|
+
class Vemars < Command
|
4
|
+
require_relative 'vemars/create'
|
5
|
+
require_relative 'vemars/baselines'
|
6
|
+
require_relative 'vemars/components'
|
7
|
+
require_relative 'vemars/patch'
|
8
|
+
|
9
|
+
self.summary = 'vemars iOS project generation tool'
|
10
|
+
self.description = <<-DESC
|
11
|
+
Create a vemars iOS project.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.abstract_command = true
|
15
|
+
# self.default_subcommand = 'create'
|
16
|
+
self.command = 'vemars'
|
17
|
+
|
18
|
+
# 解析命令别名
|
19
|
+
def self.parse(argv)
|
20
|
+
expanded_alias = argv.option('expanded-alias')
|
21
|
+
cmd = super(argv)
|
22
|
+
if cmd.class == Pod::Command::Vemars
|
23
|
+
if !expanded_alias.blank? && (arg = argv.shift_argument)
|
24
|
+
require 'shellwords'
|
25
|
+
new_argv = expanded_alias.shellsplit + argv.remainder
|
26
|
+
cmd = super(CLAide::ARGV.coerce(new_argv))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
cmd
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../../services/baselines_api'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Vemars
|
6
|
+
class Baselines < Vemars
|
7
|
+
include Concurrent::Async
|
8
|
+
|
9
|
+
self.summary = 'Query available baseline versions'
|
10
|
+
self.description = <<-DESC
|
11
|
+
Query what baseline versions are available in vemars.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
def run
|
15
|
+
api = Baselines_api.new()
|
16
|
+
api.getBaselines
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../../services/components_api'
|
2
|
+
require_relative '../../hook/podfile_template'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Command
|
6
|
+
class Vemars
|
7
|
+
class Components < Vemars
|
8
|
+
|
9
|
+
self.summary = 'Query all available components under certain baseline'
|
10
|
+
self.description = <<-DESC
|
11
|
+
Query what components are available under certain baseline version, return a list of components with name, version and maybe subspec if any.
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('BASELINE', false)
|
16
|
+
]
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
baseline = argv.shift_argument
|
20
|
+
@api = Components_api.new(baseline)
|
21
|
+
super
|
22
|
+
@additional_args = argv.remainder!
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate!
|
26
|
+
@api.validate!
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
components = @api.getComponents()
|
32
|
+
components.each do |component| component.to_s() end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# require 'json'
|
2
|
+
require 'plist'
|
3
|
+
require_relative '../project'
|
4
|
+
|
5
|
+
module Pod
|
6
|
+
class Command
|
7
|
+
class Vemars
|
8
|
+
class Create < Vemars
|
9
|
+
self.summary = 'Create iOS vemars project given name and appKey'
|
10
|
+
self.description = <<-DESC
|
11
|
+
Create one iOS vemars project given name and appKey
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('NAME', false),
|
16
|
+
CLAide::Argument.new('VERSION', false),
|
17
|
+
]
|
18
|
+
|
19
|
+
def self.options
|
20
|
+
options = [
|
21
|
+
['--language=LANGUAGE', 'language should be objc or swift'],
|
22
|
+
['--silent', 'do not run pod install'],
|
23
|
+
['--bundle_id=bundle_id', 'the bundle_id from Vemars'],
|
24
|
+
['--com=COM1,COM2', 'Selected components in vemars.'],
|
25
|
+
['--config=CONFIG_PATH', 'config path of vemars.']
|
26
|
+
]
|
27
|
+
options.concat(super.reject { |option, _| option == '--silent' })
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(argv)
|
31
|
+
@name = argv.shift_argument
|
32
|
+
@version = argv.shift_argument
|
33
|
+
@language = argv.option('language', 'objc')
|
34
|
+
git_url = argv.option('git', 'git@github.com:volcengine/ve_Template_iOS.git')
|
35
|
+
@silent = argv.flag?('silent', false)
|
36
|
+
@appkey = argv.option('appkey', '')
|
37
|
+
@bundle_id = argv.option('bundle_id', nil)
|
38
|
+
@selected_components = argv.option('com', "").split(',')
|
39
|
+
@config_json = argv.option('config', '/onekit-config.json')
|
40
|
+
@project = VemarsProject.new(@appkey, @selected_components, @config_json, @version, @bundle_id, @name, @language, git_url)
|
41
|
+
super
|
42
|
+
@additional_args = argv.remainder!
|
43
|
+
end
|
44
|
+
|
45
|
+
def validate!
|
46
|
+
super
|
47
|
+
if @config_json.nil? || @config_json.empty?
|
48
|
+
help! 'An config.json for the project is required.'
|
49
|
+
end
|
50
|
+
if @language != 'objc' && @language != 'swift'
|
51
|
+
help! 'language should be either objc or swift'
|
52
|
+
end
|
53
|
+
unless File.exist? @config_json
|
54
|
+
help! "onekit-config.json is not found at #{Dir.pwd}"
|
55
|
+
end
|
56
|
+
|
57
|
+
# help! '信息有误' unless @project.validate?
|
58
|
+
end
|
59
|
+
|
60
|
+
def run
|
61
|
+
puts 'Hi, welcome to vemars!'
|
62
|
+
@project.generate
|
63
|
+
podInstallIfNeeded
|
64
|
+
openXcodeWorkSpaceIfNeeded
|
65
|
+
end
|
66
|
+
|
67
|
+
def podInstallIfNeeded
|
68
|
+
puts "Current dir: #{Dir.pwd}"
|
69
|
+
project_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project"])
|
70
|
+
puts "Pod install directory: #{project_dir}"
|
71
|
+
if @silent
|
72
|
+
puts "Pod install skipped!"
|
73
|
+
puts "You can run Pod install in '#{project_dir}' later!"
|
74
|
+
puts "You can run Pod install in '#{project_dir}' later!"
|
75
|
+
puts "You can run Pod install in '#{project_dir}' later!"
|
76
|
+
return
|
77
|
+
end
|
78
|
+
|
79
|
+
Dir.chdir(project_dir) do
|
80
|
+
system('bundle install')
|
81
|
+
system('bundle exec pod install --repo-update')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def openXcodeWorkSpaceIfNeeded
|
86
|
+
workspace_dir = File.join(Dir.pwd, [@project.basicInfo.name, "Project","'#{@project.basicInfo.name}'.xcworkspace"])
|
87
|
+
system("open -a /Applications/Xcode.app '#{workspace_dir}'")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_relative '../project'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Vemars
|
6
|
+
class Patch < Vemars
|
7
|
+
self.summary = 'Patch exisiting iOS project with vemars services'
|
8
|
+
self.description = <<-DESC
|
9
|
+
Patch exisiting iOS project with vemars services, given
|
10
|
+
project directory, same level where Podfile locates,
|
11
|
+
vemars baseline version and selected components within vemars
|
12
|
+
DESC
|
13
|
+
|
14
|
+
self.arguments = [
|
15
|
+
CLAide::Argument.new('VERSION', false),
|
16
|
+
]
|
17
|
+
|
18
|
+
def self.options
|
19
|
+
options = [
|
20
|
+
['--path=PODFILE_PATH', 'the /path/to/Dir_contains_Podfile'],
|
21
|
+
['--com=COM1,COM2', 'Selected components in vemars.'],
|
22
|
+
['--silent', 'do not run pod install'],
|
23
|
+
['--config=CONFIG_PATH', 'config path of vemars.']
|
24
|
+
]
|
25
|
+
options.concat(super.reject { |option, _| option == '--silent' })
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(argv)
|
29
|
+
@baseline = argv.shift_argument
|
30
|
+
@path = argv.option('path', '')
|
31
|
+
@selected_components = argv.option('com', '').split(',')
|
32
|
+
@config_json = argv.option('config', '/onekit-config.json')
|
33
|
+
super
|
34
|
+
@additional_args = argv.remainder!
|
35
|
+
git_url = argv.option('git', 'git@github.com:volcengine/ve_Template_iOS.git')
|
36
|
+
@project = VemarsProject.new(@appkey, @selected_components, @config_json, @baseline, git_url)
|
37
|
+
end
|
38
|
+
|
39
|
+
def validate!
|
40
|
+
super
|
41
|
+
if @path.nil? || @path.empty?
|
42
|
+
help! 'A project path where Podfile locates is required '
|
43
|
+
end
|
44
|
+
unless File.exist? @config_json
|
45
|
+
help! "onekit-config.json is not found at #{Dir.pwd}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def run
|
50
|
+
@project.patch @path
|
51
|
+
podInstallIfNeeded
|
52
|
+
openXcodeWorkSpaceIfNeeded
|
53
|
+
end
|
54
|
+
|
55
|
+
def podInstallIfNeeded
|
56
|
+
puts "Current dir: #{Dir.pwd}"
|
57
|
+
project_dir = @path
|
58
|
+
puts "Pod install directory: #{project_dir}"
|
59
|
+
if @silent
|
60
|
+
puts "Pod install skipped!"
|
61
|
+
puts "You can run Pod install in '#{project_dir}' later!"
|
62
|
+
return
|
63
|
+
end
|
64
|
+
|
65
|
+
Dir.chdir(project_dir) do
|
66
|
+
system('bundle install')
|
67
|
+
system('bundle exec pod install --repo-update')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def openXcodeWorkSpaceIfNeeded
|
72
|
+
workspaces = Dir.entries(@path).select { |e| e.end_with?(".xcworkspace") }
|
73
|
+
full_path = File.join(@path, workspaces.first)
|
74
|
+
system("open -a /Applications/Xcode.app '#{full_path}'")
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Pod
|
2
|
+
class PodfileTemplate
|
3
|
+
|
4
|
+
attr_reader :componentsList
|
5
|
+
attr_reader :source
|
6
|
+
attr_reader :baseline_version
|
7
|
+
|
8
|
+
IOS_VERSION = '9.0'.freeze
|
9
|
+
|
10
|
+
def initialize(baseline_version, componentsList, source)
|
11
|
+
@baseline_version = baseline_version
|
12
|
+
@componentsList = componentsList
|
13
|
+
@source = source
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_dsl
|
17
|
+
<<-SPEC
|
18
|
+
|
19
|
+
#{platform}
|
20
|
+
|
21
|
+
#plugin 'cocoapods-vemars'
|
22
|
+
|
23
|
+
source 'https://cdn.cocoapods.org/'
|
24
|
+
#{source_template}
|
25
|
+
|
26
|
+
#{releasePod}
|
27
|
+
#{target}
|
28
|
+
#{post_install_setup}
|
29
|
+
SPEC
|
30
|
+
end
|
31
|
+
|
32
|
+
def platform
|
33
|
+
<<-SPEC
|
34
|
+
platform :ios, #{IOS_VERSION}
|
35
|
+
inhibit_all_warnings!
|
36
|
+
SPEC
|
37
|
+
end
|
38
|
+
|
39
|
+
def source_template
|
40
|
+
"source '#{source}'"
|
41
|
+
end
|
42
|
+
|
43
|
+
def releasePod
|
44
|
+
<<-SPEC
|
45
|
+
|
46
|
+
def release_pod
|
47
|
+
#baseline version #{baseline_version}
|
48
|
+
#{@componentsList.map { |component|
|
49
|
+
result = "\tpod '#{component.name}'"
|
50
|
+
if !component.version.nil?
|
51
|
+
result = result + ", '#{component.version}'"
|
52
|
+
end
|
53
|
+
|
54
|
+
if !component.subspecs.nil?
|
55
|
+
result = result + ", :subspecs => #{component.subspecs}"
|
56
|
+
end
|
57
|
+
result
|
58
|
+
}.join("\n")}
|
59
|
+
end
|
60
|
+
SPEC
|
61
|
+
end
|
62
|
+
|
63
|
+
def target
|
64
|
+
<<-SPEC
|
65
|
+
target 'Template_InHouse' do
|
66
|
+
release_pod
|
67
|
+
pod 'App/Debug', :path => './../DevPods/', :inhibitat_warnings => false
|
68
|
+
end
|
69
|
+
SPEC
|
70
|
+
end
|
71
|
+
|
72
|
+
def post_install_setup
|
73
|
+
<<-SPEC
|
74
|
+
def update_deployment_config(config = nil)
|
75
|
+
return if config.nil?
|
76
|
+
config.build_settings['ENABLE_BITCODE'] = 'NO'
|
77
|
+
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < 12.0
|
78
|
+
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
post_install do |installer|
|
83
|
+
installer.pods_project.build_configurations.each do |config|
|
84
|
+
update_deployment_config(config)
|
85
|
+
end
|
86
|
+
|
87
|
+
installer.pods_project.targets.each do |target|
|
88
|
+
target.build_configurations.each do |config|
|
89
|
+
update_deployment_config(config)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
## for generate_multiple_pod_projects = true
|
93
|
+
installer.generated_projects.each do |project|
|
94
|
+
project.build_configurations.each do |config|
|
95
|
+
update_deployment_config(config)
|
96
|
+
end
|
97
|
+
|
98
|
+
project.targets.each do |target|
|
99
|
+
target.build_configurations.each do |config|
|
100
|
+
update_deployment_config(config)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
SPEC
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'Rest'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Baselines_api
|
5
|
+
include Concurrent::Async
|
6
|
+
|
7
|
+
BASELINES_URL = 'http://mars-mpaas.byted.org/mpaas/baseline/baselines'.freeze
|
8
|
+
attr_accessor :result
|
9
|
+
|
10
|
+
def getBaselines
|
11
|
+
body= "{\"technology_stack\": \"iOS\"}"
|
12
|
+
header = {"ContentType" => 'application/json'}
|
13
|
+
response = REST.post(BASELINES_URL, body, header)
|
14
|
+
if response.ok?
|
15
|
+
json = JSON.parse(response.body)
|
16
|
+
error_code = json["error_no"]
|
17
|
+
if error_code == 0
|
18
|
+
@result = json["data"]['baselines']
|
19
|
+
@result = @result.sort.reverse
|
20
|
+
puts "Version list: #{@result}"
|
21
|
+
else
|
22
|
+
puts "Error #{error_code}(#{json["error_msg"]}): #{json["err_detail"]}}"
|
23
|
+
end
|
24
|
+
else
|
25
|
+
puts "response status: #{response.status_code}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'baselines_api'
|
2
|
+
require_relative '../command/component'
|
3
|
+
|
4
|
+
module Pod
|
5
|
+
class Components_api
|
6
|
+
include Concurrent::Async
|
7
|
+
|
8
|
+
COMPONENTS_URL = 'http://mars-mpaas.byted.org/mpaas/baseline/baseline_config'.freeze
|
9
|
+
|
10
|
+
attr_reader :source
|
11
|
+
attr_reader :baseline
|
12
|
+
attr_reader :component_list
|
13
|
+
attr_reader :baseline_api
|
14
|
+
|
15
|
+
public def initialize(baseline=nil)
|
16
|
+
@baseline = baseline
|
17
|
+
@source = ""
|
18
|
+
@component_list = []
|
19
|
+
@baseline_api = Baselines_api.new()
|
20
|
+
end
|
21
|
+
|
22
|
+
public def validate!
|
23
|
+
baseline_api.await.getBaselines
|
24
|
+
if @baseline.nil? && baseline_api.result.length() == 0
|
25
|
+
help! "No baselines info existed, please check with server admin"
|
26
|
+
elsif @baseline.nil? && baseline_api.result.length() > 0
|
27
|
+
@baseline = baseline_api.result[0]
|
28
|
+
elsif !@baseline.nil? && baseline_api.result.length() > 0
|
29
|
+
if !baseline_api.result.include?(@baseline)
|
30
|
+
puts "Invalid baseline version provided!"
|
31
|
+
help! "Invalid baseline version provided!"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
public def getComponents(baseline=@baseline)
|
37
|
+
body= "{\"baseline_version\": \"#{baseline}\", \"technology_stack\": \"iOS\"}"
|
38
|
+
header = {"ContentType" => 'application/json'}
|
39
|
+
response = REST.post(COMPONENTS_URL, body, header)
|
40
|
+
deserilise(response)
|
41
|
+
return component_list
|
42
|
+
end
|
43
|
+
|
44
|
+
def deserilise(response)
|
45
|
+
if response.ok?
|
46
|
+
json = JSON.parse(response.body)
|
47
|
+
error_code = json["error_no"]
|
48
|
+
if error_code == 0
|
49
|
+
@source = json['data']['source']
|
50
|
+
@component_list = json['data']['iosPlugins'].map { |obj| Component.new(obj) }
|
51
|
+
else
|
52
|
+
puts "Error #{error_code}(#{json["error_msg"]}): #{json["err_detail"]}}"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts "fail to get components, response status: #{response.status_code}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|