tuya-ci-core 0.1.2 → 0.2.0
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 +4 -4
- data/bin/tuyacicore +0 -0
- data/lib/tuya/ci/core/config/config_gitlab.rb +2 -0
- data/lib/tuya/ci/core/config/config_modules.rb +109 -0
- data/lib/tuya/ci/core/config/odm_config_modules.rb +56 -0
- data/lib/tuya/ci/core/config.rb +21 -0
- data/lib/tuya/ci/core/dependencies/node/podfile_lock_analyse.rb +119 -0
- data/lib/tuya/ci/core/dependencies/node/podfile_lock_node.rb +39 -0
- data/lib/tuya/ci/core/dependencies/podfile_lock.rb +39 -0
- data/lib/tuya/ci/core/dependencies.rb +40 -0
- data/lib/tuya/ci/core/download.rb +11 -0
- data/lib/tuya/ci/core/executable.rb +2 -0
- data/lib/tuya/ci/core/git/gitlab/gitlab_odm.rb +143 -0
- data/lib/tuya/ci/core/git.rb +98 -33
- data/lib/tuya/ci/core/language_update.rb +17 -0
- data/lib/tuya/ci/core/odm_build.rb +246 -0
- data/lib/tuya/ci/core/podfile.rb +21 -3
- data/lib/tuya/ci/core/podspec.rb +39 -9
- data/lib/tuya/ci/core/repo_release_ci.rb +44 -0
- data/lib/tuya/ci/core/spec/odm/spec_odm.rb +48 -0
- data/lib/tuya/ci/core/spec/release/repo_release.rb +67 -0
- data/lib/tuya/ci/core/spec/release/repo_release_git.rb +27 -0
- data/lib/tuya/ci/core/template/template_configurator.rb +54 -15
- data/lib/tuya/ci/core/template.rb +10 -4
- data/lib/tuya/ci/core/util/file.rb +39 -0
- data/lib/tuya/ci/core/version.rb +1 -1
- data/lib/tuya/ci/core.rb +28 -2
- metadata +32 -2
@@ -0,0 +1,67 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
|
3
|
+
class RepoReleaseCIConfig
|
4
|
+
def initialize(module_name, version)
|
5
|
+
@module_name = module_name
|
6
|
+
@version = version
|
7
|
+
end
|
8
|
+
|
9
|
+
def config
|
10
|
+
sdk = RepoReleaseCIConfigSDK.new
|
11
|
+
is_sdk = sdk.module_sdk? @module_name
|
12
|
+
result = []
|
13
|
+
if is_sdk
|
14
|
+
else
|
15
|
+
result << RepoReleaseConfig.new(@module_name, @version, @module_name, 'master')
|
16
|
+
end
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# {
|
23
|
+
# "path": "Spec",
|
24
|
+
# "project": "tuyasmart_home_ios_sdk",
|
25
|
+
# "repos": [
|
26
|
+
# "TuyaSmartBaseKit",
|
27
|
+
# "TuyaSmartDeviceKit",
|
28
|
+
# "TuyaSmartFeedbackKit"
|
29
|
+
# ]
|
30
|
+
# }
|
31
|
+
#
|
32
|
+
class RepoReleaseCIConfigSDK
|
33
|
+
@@path = '~/.ci_release/sdk/config/'
|
34
|
+
def initialize
|
35
|
+
end
|
36
|
+
def module_sdk?(module_name)
|
37
|
+
false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class RepoReleaseConfig
|
42
|
+
attr_accessor :path, :podspec, :project, :version
|
43
|
+
attr_accessor :project_github_name, :project_github_url, :base_branch
|
44
|
+
def initialize(module_name, version, project_github, base_branch)
|
45
|
+
|
46
|
+
@path = "#{ENV['HOME']}/.cocoapods/repos/TYSpecs/Specs/#{module_name}/#{version}/"
|
47
|
+
|
48
|
+
@podspec = "#{path}#{module_name}.podspec"
|
49
|
+
if version.split('.').size == 4
|
50
|
+
@podspec = "#{path}#{module_name}.podspec.json"
|
51
|
+
end
|
52
|
+
|
53
|
+
@project = module_name
|
54
|
+
@version = version
|
55
|
+
|
56
|
+
@project_github_name = project_github
|
57
|
+
@project_github_url = "https://github.com/TuyaInc/#{project_github}.git"
|
58
|
+
@base_branch = base_branch
|
59
|
+
end
|
60
|
+
|
61
|
+
def ready
|
62
|
+
puts "Release #{@project} : #{@version}, path : #{@path}".yellow
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module TYCiCore
|
2
|
+
CI_RELEASE_WORKSPACE = "#{ENV['HOME']}/.jenkins_project_release/"
|
3
|
+
class RepoReleaseGit
|
4
|
+
def prepare(item)
|
5
|
+
local_path = "#{TYCiCore::CI_RELEASE_WORKSPACE}#{item.project_github_name}"
|
6
|
+
|
7
|
+
git_remote_repo_exist = TYCiCore::Git.git_remote_repo_exist? item.project_github_url
|
8
|
+
local_file_exist = File.exist? local_path
|
9
|
+
|
10
|
+
if git_remote_repo_exist
|
11
|
+
if local_file_exist
|
12
|
+
# git is ok?
|
13
|
+
if 1
|
14
|
+
# end
|
15
|
+
else
|
16
|
+
# delete
|
17
|
+
end
|
18
|
+
else
|
19
|
+
# git clone
|
20
|
+
end
|
21
|
+
else
|
22
|
+
TYUtil::TYFile.delete local_path if local_file_exist
|
23
|
+
# create new
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module TYCiCore
|
2
|
-
TEMPLATE_CONFIG = '.
|
2
|
+
TEMPLATE_CONFIG = '.tuya_project_template_odm'
|
3
3
|
URL = 'https://github.com/TuyaInc/TYProjectTemplate.git'
|
4
4
|
class TemplateConfigurator
|
5
5
|
|
@@ -69,37 +69,76 @@ module TYCiCore
|
|
69
69
|
|
70
70
|
class TemplateConfig
|
71
71
|
|
72
|
-
attr_accessor :
|
73
|
-
attr_accessor :
|
72
|
+
attr_accessor :templates_json
|
73
|
+
attr_accessor :last_version
|
74
|
+
attr_accessor :keys, :sub_keys
|
74
75
|
attr_accessor :type, :alias, :project
|
75
76
|
|
76
77
|
def initialize(json)
|
77
78
|
@project = 'PROJECT'
|
78
|
-
@
|
79
|
-
@
|
79
|
+
@templates_json = json['templates']
|
80
|
+
@last_version = json['last_version']
|
81
|
+
|
82
|
+
@sub_keys = Hash.new
|
80
83
|
@type = ""
|
81
84
|
@alias = ""
|
82
85
|
@desc = ""
|
86
|
+
|
87
|
+
@type_map = Hash.new
|
88
|
+
@templates_json.each do |item|
|
89
|
+
key = item['type'].downcase
|
90
|
+
@type_map[key] = item
|
91
|
+
sub_type_map = Hash.new
|
92
|
+
sub_types = item['sub_types']
|
93
|
+
if sub_types && sub_types.size > 0
|
94
|
+
sub_types.each do |sub_item|
|
95
|
+
sub_type_map[sub_item['type']] = sub_item
|
96
|
+
end
|
97
|
+
item['sub_types_map'] = sub_type_map
|
98
|
+
end
|
99
|
+
end
|
100
|
+
@keys = @type_map.keys
|
83
101
|
end
|
84
102
|
|
85
|
-
def
|
103
|
+
def sub_types(key)
|
104
|
+
sub_type_map = @type_map[key]['sub_types_map']
|
105
|
+
if sub_type_map
|
106
|
+
sub_type_map.keys
|
107
|
+
else
|
108
|
+
nil
|
109
|
+
end
|
110
|
+
end
|
86
111
|
|
112
|
+
def log_type
|
87
113
|
puts "Here is the module type list".magenta.underline
|
88
|
-
|
89
|
-
@json.each do |item|
|
114
|
+
@templates_json.each do |item|
|
90
115
|
puts "#{item['type']} : #{item['desc']}".green
|
91
|
-
@keys.push item['type']
|
92
116
|
end
|
93
117
|
end
|
94
118
|
|
95
|
-
def
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
119
|
+
def log_sub_type(type)
|
120
|
+
puts "Here is the #{type} module type list".magenta.underline
|
121
|
+
item = @type_map[type]
|
122
|
+
sub_types = item['sub_types']
|
123
|
+
if sub_types && sub_types.size > 0
|
124
|
+
sub_types.each do |sub_item|
|
125
|
+
puts " #{sub_item['type']} : #{sub_item['desc']}".yellow
|
101
126
|
end
|
102
127
|
end
|
103
128
|
end
|
129
|
+
|
130
|
+
def setup(type, sub_type)
|
131
|
+
item = @type_map[type]
|
132
|
+
if sub_type
|
133
|
+
item = item['sub_types_map'][sub_type]
|
134
|
+
end
|
135
|
+
setup_item item
|
136
|
+
end
|
137
|
+
|
138
|
+
def setup_item(item)
|
139
|
+
@type = item['type']
|
140
|
+
@alias = item['alias']
|
141
|
+
@desc = item['desc']
|
142
|
+
end
|
104
143
|
end
|
105
144
|
end
|
@@ -10,11 +10,19 @@ module TYCiCore
|
|
10
10
|
download_template
|
11
11
|
|
12
12
|
config = TemplateConfigurator.load_config TARGET_PROJECT
|
13
|
-
config.
|
13
|
+
config.log_type
|
14
14
|
|
15
15
|
type = TYAsk.ask_with_answers('Please tell me which module will be create', config.keys)
|
16
16
|
puts "\n"
|
17
|
-
|
17
|
+
|
18
|
+
sub_types = config.sub_types type
|
19
|
+
sub_type = nil
|
20
|
+
if sub_types && sub_types.size > 0
|
21
|
+
config.log_sub_type type
|
22
|
+
sub_type = TYAsk.ask_with_answers("Please tell me which sub type of #{type} module will be create", sub_types)
|
23
|
+
end
|
24
|
+
puts "\n"
|
25
|
+
config.setup type, sub_type
|
18
26
|
|
19
27
|
name = TYAsk.ask'Please enter your module name'
|
20
28
|
prefix = TYAsk.ask 'Please enter your Prefix'
|
@@ -57,9 +65,7 @@ module TYCiCore
|
|
57
65
|
`cp -a ./#{TARGET_PROJECT}/#{@configurator.config.alias}/ #{@configurator.pod_name}`
|
58
66
|
`cp ./#{TARGET_PROJECT}/#{TYCiCore::TEMPLATE_CONFIG} #{@configurator.pod_name}/#{TYCiCore::TEMPLATE_CONFIG}`
|
59
67
|
`rm -rf #{TARGET_PROJECT}`
|
60
|
-
|
61
68
|
end
|
62
|
-
|
63
69
|
!result
|
64
70
|
end
|
65
71
|
|
@@ -1,9 +1,40 @@
|
|
1
1
|
module TYUtil
|
2
2
|
class TYFile
|
3
|
+
def self.unzip(target, path='./')
|
4
|
+
`unzip #{target} -d #{path}`
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.delete(path)
|
8
|
+
`rm #{path}`
|
9
|
+
end
|
10
|
+
|
3
11
|
def self.read(filepath)
|
4
12
|
|
5
13
|
end
|
6
14
|
|
15
|
+
def self.add_to_line(target, line_content, line_number)
|
16
|
+
line_number_temp = 0
|
17
|
+
target.each_line do |line|
|
18
|
+
if (line_number_temp += 1) == line_number
|
19
|
+
target.gsub!(/#{line}/, "#{line}#{line_content}\n")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
target
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.line_contain_content(target, content, lastMatch=true)
|
26
|
+
line_number = 0
|
27
|
+
exist_num = 0
|
28
|
+
if !(content.nil? || content.empty?)
|
29
|
+
target.each_line do |line|
|
30
|
+
line_number += 1
|
31
|
+
exist_num = line_number if line.include?(content)
|
32
|
+
break unless lastMatch
|
33
|
+
end
|
34
|
+
end
|
35
|
+
exist_num
|
36
|
+
end
|
37
|
+
|
7
38
|
def self.folder_copy(from, to, is_need_delete=true )
|
8
39
|
|
9
40
|
target = to + '/' << from.split('/')[-1]
|
@@ -21,6 +52,14 @@ module TYUtil
|
|
21
52
|
target
|
22
53
|
end
|
23
54
|
|
55
|
+
# def self.copy(from, to, is_need_delete=true)
|
56
|
+
# if File.exist? from
|
57
|
+
# TYCiCore::EXE.exe('cp', %W(-a #{from} #{to}))
|
58
|
+
# TYCiCore::EXE.exe('rm', %W(-rf #{to})) if is_needend_delete
|
59
|
+
# end
|
60
|
+
# to
|
61
|
+
# end
|
62
|
+
|
24
63
|
def self.podspec_files(podspec)
|
25
64
|
if podspec
|
26
65
|
path = Pathname(podspec)
|
data/lib/tuya/ci/core/version.rb
CHANGED
data/lib/tuya/ci/core.rb
CHANGED
@@ -5,23 +5,49 @@ require "tuya/ci/core/version"
|
|
5
5
|
module TYCiCore
|
6
6
|
|
7
7
|
require 'colored'
|
8
|
-
|
8
|
+
require 'json'
|
9
|
+
require 'json/pure'
|
9
10
|
require 'fileutils'
|
10
11
|
|
12
|
+
require 'tuya/ci/core/executable'
|
13
|
+
|
11
14
|
require 'tuya/ci/core/util/file'
|
12
15
|
require 'tuya/ci/core/util/dir'
|
13
16
|
require 'tuya/ci/core/util/ask'
|
14
17
|
|
18
|
+
require 'tuya/ci/core/config'
|
19
|
+
|
20
|
+
require 'tuya/ci/core/download'
|
21
|
+
|
15
22
|
require 'tuya/ci/core/spec/ty_repo'
|
23
|
+
require 'tuya/ci/core/spec/odm/spec_odm'
|
24
|
+
|
16
25
|
require 'tuya/ci/core/git'
|
17
26
|
require 'tuya/ci/core/git/git_tuya_ci'
|
18
|
-
|
27
|
+
|
28
|
+
require 'tuya/ci/core/git/gitlab/gitlab_odm'
|
29
|
+
|
19
30
|
require 'tuya/ci/core/lib/lib'
|
20
31
|
require 'tuya/ci/core/lib/lib_tuya_ci'
|
32
|
+
|
21
33
|
require 'tuya/ci/core/podspec'
|
22
34
|
require 'tuya/ci/core/podfile'
|
23
35
|
|
24
36
|
require 'tuya/ci/core/template'
|
25
37
|
require 'tuya/ci/core/template/template_configurator'
|
26
38
|
require 'tuya/ci/core/template/template_project'
|
39
|
+
|
40
|
+
require 'tuya/ci/core/dependencies'
|
41
|
+
require 'tuya/ci/core/dependencies/podfile_lock'
|
42
|
+
require 'tuya/ci/core/dependencies/node/podfile_lock_analyse'
|
43
|
+
require 'tuya/ci/core/dependencies/node/podfile_lock_node'
|
44
|
+
|
45
|
+
require 'tuya/ci/core/spec/release/repo_release'
|
46
|
+
require 'tuya/ci/core/repo_release_ci'
|
47
|
+
require 'tuya/ci/core/spec/release/repo_release_git'
|
48
|
+
|
49
|
+
require 'tuya/ci/core/language_update'
|
50
|
+
|
51
|
+
require 'tuya/ci/core/config/odm_config_modules'
|
52
|
+
require 'tuya/ci/core/odm_build'
|
27
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuya-ci-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fangdong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_pure
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: cocoapods
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,13 +123,29 @@ files:
|
|
109
123
|
- lib/tuya/ci/core/command.rb
|
110
124
|
- lib/tuya/ci/core/command/lib.rb
|
111
125
|
- lib/tuya/ci/core/command/lib/create_branch.rb
|
126
|
+
- lib/tuya/ci/core/config.rb
|
127
|
+
- lib/tuya/ci/core/config/config_gitlab.rb
|
128
|
+
- lib/tuya/ci/core/config/config_modules.rb
|
129
|
+
- lib/tuya/ci/core/config/odm_config_modules.rb
|
130
|
+
- lib/tuya/ci/core/dependencies.rb
|
131
|
+
- lib/tuya/ci/core/dependencies/node/podfile_lock_analyse.rb
|
132
|
+
- lib/tuya/ci/core/dependencies/node/podfile_lock_node.rb
|
133
|
+
- lib/tuya/ci/core/dependencies/podfile_lock.rb
|
134
|
+
- lib/tuya/ci/core/download.rb
|
112
135
|
- lib/tuya/ci/core/executable.rb
|
113
136
|
- lib/tuya/ci/core/git.rb
|
114
137
|
- lib/tuya/ci/core/git/git_tuya_ci.rb
|
138
|
+
- lib/tuya/ci/core/git/gitlab/gitlab_odm.rb
|
139
|
+
- lib/tuya/ci/core/language_update.rb
|
115
140
|
- lib/tuya/ci/core/lib/lib.rb
|
116
141
|
- lib/tuya/ci/core/lib/lib_tuya_ci.rb
|
142
|
+
- lib/tuya/ci/core/odm_build.rb
|
117
143
|
- lib/tuya/ci/core/podfile.rb
|
118
144
|
- lib/tuya/ci/core/podspec.rb
|
145
|
+
- lib/tuya/ci/core/repo_release_ci.rb
|
146
|
+
- lib/tuya/ci/core/spec/odm/spec_odm.rb
|
147
|
+
- lib/tuya/ci/core/spec/release/repo_release.rb
|
148
|
+
- lib/tuya/ci/core/spec/release/repo_release_git.rb
|
119
149
|
- lib/tuya/ci/core/spec/ty_repo.rb
|
120
150
|
- lib/tuya/ci/core/template.rb
|
121
151
|
- lib/tuya/ci/core/template/template_configurator.rb
|