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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ff9c218d2c9f7720be1248b8f4d9b896071e33216c868ee0d1227289aa0e2a56
4
+ data.tar.gz: fc57f96aad044460b0ad1a93a138c08953ffe0d0596e414547f866347e624b71
5
+ SHA512:
6
+ metadata.gz: cb803fc8dcfb78ffc745ea88390ccdcf752f6b1f858996e09d6778fff1b584155eb3009f38709c5fd0c112d080d4c98f5fb23669312e04f97fc85f3222da0931
7
+ data.tar.gz: f0a2b8976e20882da7ba5c3aedaaaf6432eed629c94978cd910afd70cb1ed632fa9070b101e535bf516a51df7a4def428ff5564b9b32d178328fe7fd50beb4c5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ vendor
5
+ install
6
+ .bundle
7
+
8
+ *.gem
9
+ *.gemspec
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-vemars.gemspec
4
+ gemspec
5
+
6
+ group :debug do
7
+ gem 'cocoapods'
8
+ # gem 'ruby-debug-ide'
9
+ # gem 'debase', '0.2.5.beta2'
10
+ gem 'plist', '~> 3.2'
11
+ gem 'rexml'
12
+ gem 'concurrent-ruby', require: 'concurrent'
13
+ gem 'xcodeproj'
14
+ end
15
+
16
+
data/Gemfile.lock ADDED
@@ -0,0 +1,109 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-vemars (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.3)
10
+ activesupport (5.2.6)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ addressable (2.8.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ algoliasearch (1.27.5)
18
+ httpclient (~> 2.8, >= 2.8.3)
19
+ json (>= 1.5.1)
20
+ atomos (0.1.3)
21
+ claide (1.0.3)
22
+ cocoapods (1.10.1)
23
+ addressable (~> 2.6)
24
+ claide (>= 1.0.2, < 2.0)
25
+ cocoapods-core (= 1.10.1)
26
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
27
+ cocoapods-downloader (>= 1.4.0, < 2.0)
28
+ cocoapods-plugins (>= 1.0.0, < 2.0)
29
+ cocoapods-search (>= 1.0.0, < 2.0)
30
+ cocoapods-trunk (>= 1.4.0, < 2.0)
31
+ cocoapods-try (>= 1.1.0, < 2.0)
32
+ colored2 (~> 3.1)
33
+ escape (~> 0.0.4)
34
+ fourflusher (>= 2.3.0, < 3.0)
35
+ gh_inspector (~> 1.0)
36
+ molinillo (~> 0.6.6)
37
+ nap (~> 1.0)
38
+ ruby-macho (~> 1.4)
39
+ xcodeproj (>= 1.19.0, < 2.0)
40
+ cocoapods-core (1.10.1)
41
+ activesupport (> 5.0, < 6)
42
+ addressable (~> 2.6)
43
+ algoliasearch (~> 1.0)
44
+ concurrent-ruby (~> 1.1)
45
+ fuzzy_match (~> 2.0.4)
46
+ nap (~> 1.0)
47
+ netrc (~> 0.11)
48
+ public_suffix
49
+ typhoeus (~> 1.0)
50
+ cocoapods-deintegrate (1.0.4)
51
+ cocoapods-downloader (1.4.0)
52
+ cocoapods-plugins (1.0.0)
53
+ nap
54
+ cocoapods-search (1.0.0)
55
+ cocoapods-trunk (1.5.0)
56
+ nap (>= 0.8, < 2.0)
57
+ netrc (~> 0.11)
58
+ cocoapods-try (1.2.0)
59
+ colored2 (3.1.2)
60
+ concurrent-ruby (1.1.9)
61
+ escape (0.0.4)
62
+ ethon (0.14.0)
63
+ ffi (>= 1.15.0)
64
+ ffi (1.15.3)
65
+ fourflusher (2.3.1)
66
+ fuzzy_match (2.0.4)
67
+ gh_inspector (1.1.3)
68
+ httpclient (2.8.3)
69
+ i18n (1.8.10)
70
+ concurrent-ruby (~> 1.0)
71
+ json (2.5.1)
72
+ minitest (5.14.4)
73
+ molinillo (0.6.6)
74
+ nanaimo (0.3.0)
75
+ nap (1.1.0)
76
+ netrc (0.11.0)
77
+ plist (3.6.0)
78
+ public_suffix (4.0.6)
79
+ rake (13.0.6)
80
+ rexml (3.2.5)
81
+ ruby-macho (1.4.0)
82
+ thread_safe (0.3.6)
83
+ typhoeus (1.4.0)
84
+ ethon (>= 0.9.0)
85
+ tzinfo (1.2.9)
86
+ thread_safe (~> 0.1)
87
+ xcodeproj (1.20.0)
88
+ CFPropertyList (>= 2.3.3, < 4.0)
89
+ atomos (~> 0.1.3)
90
+ claide (>= 1.0.2, < 2.0)
91
+ colored2 (~> 3.1)
92
+ nanaimo (~> 0.3.0)
93
+ rexml (~> 3.2.4)
94
+
95
+ PLATFORMS
96
+ x86_64-darwin-19
97
+
98
+ DEPENDENCIES
99
+ bundler (~> 2.2.15)
100
+ cocoapods
101
+ cocoapods-vemars!
102
+ concurrent-ruby
103
+ plist (~> 3.2)
104
+ rake
105
+ rexml
106
+ xcodeproj
107
+
108
+ BUNDLED WITH
109
+ 2.2.15
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 huangbomao@bytedance.com <huangbomao@bytedance.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # cocoapods-vemars
2
+
3
+ A description of cocoapods-vemars.
4
+
5
+ ## Installation
6
+
7
+ $ gem install cocoapods-vemars
8
+
9
+ ## Usage
10
+
11
+ $ pod spec vemars POD_NAME
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-vemars/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-vemars'
8
+ spec.version = CocoapodsVemars::VERSION
9
+ spec.authors = ['huangbomao@bytedance.com']
10
+ spec.email = ['huangbomao@bytedance.com']
11
+ spec.description = %q{A short description of cocoapods-vemars.}
12
+ spec.summary = %q{A longer description of cocoapods-vemars.}
13
+ spec.homepage = 'https://github.com/volcengine/ve_Template_iOS'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 2.2.15'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,13 @@
1
+ require 'cocoapods-vemars/gem_version'
2
+
3
+ $vemars_lib_dir ||= File.dirname(__FILE__).to_s
4
+
5
+ def vemars_require(paths = nil)
6
+ if paths.is_a?(Array)
7
+ paths.each { |path|
8
+ require File.expand_path(path.to_s, $vemars_lib_dir)
9
+ }
10
+ elsif paths.is_a?(String)
11
+ require File.expand_path(paths.to_s, $vemars_lib_dir)
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-vemars/command/vemars'
@@ -0,0 +1,52 @@
1
+ module Pod
2
+ class BasicInfo
3
+ attr_reader :app_key
4
+ attr_reader :name
5
+ attr_reader :bundle_id
6
+ attr_reader :version
7
+ attr_reader :string_replacements
8
+
9
+ def initialize(app_key, bundle_id=nil, name=nil, version=nil)
10
+ @app_key = app_key
11
+ @name = name
12
+ @bundle_id = bundle_id
13
+ @version = version
14
+
15
+ prefix = name[0..2].upcase
16
+ @string_replacements = {
17
+ "Bob" => "ByteDance",
18
+ "TODAYS_DATE" => date,
19
+ "TODAYS_YEAR" => year,
20
+ "${USER_NAME}" => user_name,
21
+ "${USER_EMAIL}" => user_email,
22
+ "${YEAR}" => year,
23
+ "${DATE}" => date,
24
+
25
+ "Template" => @name,
26
+ "Template_InHouse" => @name + "_InHouse",
27
+ "${POD_NAME}" => @name,
28
+ "CPD" => prefix,
29
+ "${APPKEY}" => @app_key,
30
+ "${MPAAS_VERSION}" => @version,
31
+ "org.cocoapods.demo.${PRODUCT_NAME:rfc1034identifier}" => @bundle_id
32
+ }
33
+ end
34
+
35
+ def date
36
+ Time.now.strftime "%m/%d/%Y"
37
+ end
38
+
39
+ def year
40
+ Time.now.year.to_s
41
+ end
42
+
43
+ def user_name
44
+ (`git config user.name` || "bytedance" ).strip
45
+ end
46
+
47
+ def user_email
48
+ (`git config user.email` || "bytedance@bytedance.com").strip
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ module Pod
2
+ class Component
3
+ attr_reader :name
4
+ attr_reader :version
5
+ attr_reader :subspecs
6
+
7
+ # def initialize(name, version, subspecs = [])
8
+ # @name = name
9
+ # @version = version
10
+ # @subspecs = subspecs
11
+ # end
12
+
13
+ def initialize(json)
14
+ @name = json["name"]
15
+ @version = json["version"]
16
+ @subspecs = json["subspecs"]
17
+ end
18
+
19
+ def to_s
20
+ puts "==================================="
21
+ puts "Component\nname: #{@name}\nversion: #{@version}\n"
22
+ puts "subspecs: #{@subspecs}\n"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,140 @@
1
+ require_relative '../services/components_api'
2
+ require_relative '../services/patcher'
3
+ require_relative '../services/tailor'
4
+ require_relative 'basicInfo'
5
+ require_relative '../services/renamer'
6
+
7
+ module Pod
8
+
9
+ class VemarsProject
10
+
11
+ attr_reader :language
12
+ attr_reader :basicInfo
13
+ attr_reader :selected_components
14
+ attr_reader :git_url
15
+
16
+ attr_accessor :components_details
17
+ attr_accessor :source
18
+
19
+ def project_folder
20
+ File.join(Dir.pwd, "Project")
21
+ end
22
+
23
+ def initialize(app_key, components, config_json, version=nil, bundle_id=nil, name='', language='objc', git_url)
24
+ @language = language
25
+ @basicInfo = BasicInfo.new(app_key, bundle_id, name, version)
26
+ @git_url = git_url
27
+ @config_json = config_json
28
+ @selected_components = components | (language == 'swift' ? %w[OneKit SwiftOneKit] : ['OneKit'])
29
+ @components_details = []
30
+ end
31
+
32
+ def generate
33
+ puts "generate project..."
34
+ clone_template_project
35
+ collect_components
36
+ Dir.chdir(basicInfo.name) do
37
+ language_switch
38
+ tailor_demos
39
+ Dir.chdir("Project") do
40
+ construct_podfile
41
+ Dir.chdir("Template_InHouse") do
42
+ construct_plist
43
+ end
44
+ rename_project_files
45
+ # replace_internal_project_settings
46
+ end
47
+ reinitialize_git_repo
48
+ end
49
+ end
50
+
51
+ def patch(podfile_dir)
52
+ puts "patching project..."
53
+ collect_components
54
+ Dir.chdir(podfile_dir) do
55
+ construct_plist
56
+ patcher = Patcher.new(podfile_dir, @basicInfo.version, @components_details, @source, @git_url)
57
+ patcher.execute
58
+ end
59
+ end
60
+
61
+ def clone_template_project
62
+ # puts 'cloning template'
63
+ if File.directory?(basicInfo.name) || File.file?(basicInfo.name)
64
+ system("rm -rf #{basicInfo.name}")
65
+ end
66
+
67
+ cmd = "git clone #{git_url} #{basicInfo.name}"
68
+ system(cmd)
69
+ end
70
+
71
+ def language_switch
72
+ if language == 'swift'
73
+ puts "creating swift project..."
74
+ system("rm -fr objc")
75
+ system("mv swift/* ./")
76
+ system("rm -fr ./swift")
77
+ else
78
+ puts "creating objc project..."
79
+ system("rm -fr ./swift")
80
+ system("mv objc/* ./")
81
+ system("rm -fr objc")
82
+ end
83
+ end
84
+
85
+ def collect_components
86
+ components_api = Components_api.new(@basicInfo.version)
87
+ all_components = components_api.getComponents
88
+ @source = components_api.source
89
+ @selected_components.each do |com|
90
+ existed_com = all_components.find { |acom|
91
+ acom.name == com
92
+ }
93
+ @components_details.append existed_com unless existed_com.nil?
94
+ end
95
+
96
+ end
97
+
98
+ def construct_podfile
99
+ template = PodfileTemplate.new(@basicInfo.version, @components_details, @source)
100
+
101
+ File.open('Podfile', "w") { |file| file.puts template.to_dsl }
102
+ end
103
+
104
+
105
+ def construct_plist
106
+ json = JSON.load_file @config_json
107
+ File.open(Dir.pwd + "/onekit-config.plist", 'w') { |file|
108
+ file.puts json.to_plist
109
+ }
110
+ end
111
+
112
+ def rename_project_files
113
+ renamer = ProjectRenamer.new("Template", basicInfo.name)
114
+ renamer.execute
115
+ end
116
+
117
+ def tailor_demos
118
+ tailor = DemoTailor.new(@components_details)
119
+ tailor.execute
120
+ end
121
+
122
+ def replace_internal_project_settings
123
+ Dir.glob(Dir.pwd + "/**/**/**/**").each do |name|
124
+ next if Dir.exists? name
125
+ text = File.read(name)
126
+ basicInfo.string_replacements.each { |find, replace|
127
+ text = text.gsub(find, replace)
128
+ }
129
+ File.open(name, "w") { |file| file.puts text }
130
+ end
131
+ end
132
+
133
+
134
+ def reinitialize_git_repo
135
+ `rm -rf .git/`
136
+ `git init`
137
+ end
138
+ end
139
+ end
140
+