tuya-cli-odm 0.1.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.
@@ -0,0 +1,89 @@
1
+ module Tuya
2
+ class PodSpec
3
+
4
+ def self.local_pod_version_exist(version, spec, lib_name)
5
+
6
+ system = Tuya::System.instance
7
+ local_path = system.pod_config.repos_dir + spec + lib_name + version
8
+
9
+ File.directory?(local_path)
10
+ end
11
+
12
+ def self.ask_pod_spec
13
+
14
+ files = podspec_files(nil)
15
+
16
+ answer = ""
17
+
18
+ if files.size == 1
19
+ answer = files[0]
20
+ elsif files.size > 1
21
+
22
+ podspecs = Array.new
23
+ files.each do |podspec_path|
24
+ podspecs.push File.basename(podspec_path)
25
+ end
26
+
27
+ answer = TYCiCore::TYAsk.ask_with_answers("which podspec will be pushed", podspecs)
28
+ end
29
+
30
+ answer
31
+
32
+ end
33
+
34
+ def self.pod_spec_version(podspec)
35
+ content = File.read("./#{podspec}")
36
+ version = (content.match(/s.version[\s]*=[\s]*'([\d]+.){2}[\d]+'/)[0]).match(/([\d]+.){2}[\d]+/)[0]
37
+ version.gsub(/(\d+)$/, ((version.split(".")[-1]).to_i + 1).to_s)
38
+ end
39
+
40
+ def self.update(podspec, version)
41
+
42
+ result = Array.new
43
+
44
+ files = podspec_files(podspec)
45
+
46
+ files.each do |podspec_path|
47
+ podspec = TYCiCore::PodSpec.new "./#{podspec_path}"
48
+ if podspec.update 'version', version
49
+ # podspec.update 'summary', ""
50
+ result.push(podspec_path)
51
+ end
52
+ podspec.save
53
+ result
54
+ end
55
+ end
56
+
57
+ def self.repair_lib_spec(path, file, config)
58
+
59
+ # TUDO 这里使用旧实现, 未迁移tuya-ci-core
60
+ podspec = "#{path}/#{file}"
61
+
62
+ if File.exist? podspec
63
+ spec_content = File.read(podspec)
64
+ spec_content = repair_source(spec_content, config.url)
65
+
66
+ fh = File.new(podspec, "w")
67
+ fh.puts spec_content
68
+ fh.close
69
+ end
70
+ end
71
+
72
+ def self.repair_source(podspec, git_url)
73
+ podspec.gsub!(/:git => (.*),/, ":git => '#{git_url}',")
74
+ end
75
+
76
+ def self.podspec_files(podspec)
77
+ if podspec
78
+ path = Pathname(podspec)
79
+ raise Informative, "Couldn't find #{podspec}" unless path.exist?
80
+ [path]
81
+ else
82
+ files = Pathname.glob('*.podspec{,.json}')
83
+ # raise Informative, "Couldn't find any podspec files in current directory" if files.empty?
84
+ puts "Couldn't find any podspec files in current directory".red if files.empty?
85
+ files
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,85 @@
1
+ module Tuya
2
+ class SpecRepo
3
+ def self.push(version, is_commit_all, podspec, verbose)
4
+
5
+ if is_commit_all
6
+ Tuya::TuyaGit.commit_all('feat: update all by tuya-cli repo push')
7
+ end
8
+
9
+ podspecs = Tuya::PodSpec.update(podspec, version)
10
+ podspecs.each do |podspec_file|
11
+ Tuya::TuyaGit.commit_file(podspec_file, "feat: update version #{version} by tuya-cli repo push")
12
+ end
13
+
14
+ puts "\nPush podspec(git)...".yellow
15
+ git_push_commands = [
16
+ %W(push)
17
+ ]
18
+ Tuya::EXE.multi_exe('git', git_push_commands, true)
19
+
20
+ puts "\nAdd tag: #{version}...".yellow
21
+ git_tag_commands = [
22
+ %W(tag -a #{version} -m 'add\ tag:\ #{version}\ by\ tuya-cli\ repo\ push')
23
+ ]
24
+ Tuya::EXE.multi_exe('git', git_tag_commands, true)
25
+
26
+ puts "\nPush tag: #{version}...".yellow
27
+ git_tag_push_commands = [
28
+ %W(push origin --tags)
29
+ ]
30
+ Tuya::EXE.multi_exe('git', git_tag_push_commands, true)
31
+
32
+ system = Tuya::System.instance
33
+
34
+ group = system.group
35
+
36
+ podspecs.each do |podspec_file|
37
+
38
+ puts "\nPushing #{podspec_file}...".yellow
39
+
40
+ pod_push = "pod repo push #{group.spec} #{podspec_file} --sources='#{group.url},https://github.com/CocoaPods/Specs.git,https://github.com/TuyaInc/TYPublicSpecs.git' --use-libraries --allow-warnings"
41
+
42
+ if verbose
43
+ pod_push = "#{pod_push} --verbose"
44
+ end
45
+
46
+ pod_push_result = `#{pod_push}`
47
+
48
+ push_result = Tuya::PodSpec.local_pod_version_exist(version, group.spec, File.basename(FileUtils.pwd))
49
+
50
+ if verbose
51
+ if pod_push_result.length > 10000
52
+
53
+ log_name = "repo_push_result_#{podspec_file}_#{version}.log"
54
+
55
+ if push_result
56
+ log_name = "success_#{log_name}"
57
+ puts "\nThe detail log is :#{log_name}\n".yellow
58
+ else
59
+ log_name = "error_#{log_name}"
60
+ puts "\nThe detail error log is :#{log_name}\n".red
61
+ end
62
+
63
+ TYUtil::TYFile.new_file("log", log_name, pod_push_result)
64
+ else
65
+
66
+ puts "The detail log is:\n".red
67
+ puts pod_push_result.magenta
68
+ end
69
+ end
70
+
71
+ if push_result
72
+ puts "Push #{podspec_file} Successful\n".green
73
+ else
74
+ suggest_log(podspec_file, pod_push_result)
75
+ end
76
+
77
+ end
78
+ end
79
+
80
+ def self.suggest_log(podspec_file, content)
81
+ puts "\nPush #{podspec_file} Failed you can use 'tuya repo push --verbose for more information' ".red
82
+ TYUtil::TYPuts.filter(content, TYUtil::TYPuts::ERROR_KEYS)
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,23 @@
1
+ module Tuya
2
+ require 'singleton'
3
+ class System
4
+ include Pod::Config::Mixin
5
+ include Singleton
6
+ def self.lint
7
+ puts "current ruby version: #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}".green
8
+ puts Pod::VERSION
9
+ end
10
+
11
+ attr_accessor :user
12
+ attr_accessor :pod_config
13
+ attr_accessor :group
14
+ attr_accessor :gitlab_config
15
+
16
+ def initialize
17
+ @user = ENV["HOME"]
18
+ @pod_config = config
19
+
20
+ @group = Tuya::Config.local_config @user
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module TYUtil
2
+ class TYFile
3
+ def self.new_file(path, name, content)
4
+
5
+ `mkdir -p ./#{path}/`
6
+
7
+ fh = File.new("./#{path}/#{name}", "w")
8
+ fh.puts content
9
+ fh.close
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,87 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
2
+
3
+ require 'colored'
4
+
5
+ module TYUtil
6
+ class TYPuts
7
+
8
+
9
+ ERROR_KEYS = [
10
+ "fatal",
11
+ "error",
12
+ "ERROR",
13
+ "can not",
14
+ "not found",
15
+ "Couldn"#Couldn't find
16
+ ]
17
+
18
+ def self.filter_color(target, keys, color, pre)
19
+ target.each_line do |s|
20
+
21
+ # p 111
22
+ # p s
23
+ eval_command = ""
24
+ keys.each do |key|
25
+ temp = ""
26
+ if eval_command.length > 0
27
+ temp = " || "
28
+ end
29
+ eval_command = "#{eval_command}#{temp}s.include?('#{key}')"
30
+ end
31
+ # p eval_command
32
+ if eval_command.length > 0 && (eval eval_command)
33
+ # p 11111
34
+ # p pre
35
+ # p 222
36
+
37
+ out = "#{pre} #{s}"
38
+ if out.include?("''")
39
+ out.gsub!("'","")
40
+ end
41
+
42
+ # p "#{pre} #{s}"
43
+ # p 33
44
+ # p out
45
+
46
+ # puts "puts '#{out}'.#{color}"
47
+
48
+ # eval "puts '#{out}'.#{color}"
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ def self.filter_content(target, keys, pre)
55
+
56
+ regular_temp = ""
57
+ is_put_pre = false
58
+ keys.each do |key|
59
+ temp = ""
60
+ if regular_temp.length > 0
61
+ temp = "|"
62
+ end
63
+ regular_temp = "#{regular_temp}#{temp}(.*)#{key}(.*)"
64
+ end
65
+
66
+ regular = "^(#{regular_temp})$"
67
+ target.gsub(/#{regular}/) do |matched|
68
+
69
+ if !is_put_pre
70
+ is_put_pre = true
71
+ puts pre.yellow
72
+ puts "\n"
73
+ end
74
+
75
+ if matched.length < 2000
76
+ puts matched.magenta
77
+ puts "\n"
78
+ end
79
+ end
80
+ end
81
+
82
+ def self.filter(target, keys)
83
+ # filter_color(target, keys, 'yellow', '[!tuya-cli suggested]')
84
+ filter_content(target, keys, '「tuya-cli」 Maybe the reason for the error is :')
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,7 @@
1
+ module Tuya
2
+ module Cli
3
+ module Odm
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tuya-cli-odm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - fangdong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tuya-ci-core
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: ruby-progressbar
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.10.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.10.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: colored
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: cocoapods
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: tuya odm cli public tools
112
+ email:
113
+ - fangdong@tuyasmart.com
114
+ executables:
115
+ - tuya-odm
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - LICENSE.txt
120
+ - README.md
121
+ - bin/tuya-odm
122
+ - lib/tuya/cli/odm.rb
123
+ - lib/tuya/cli/odm/command.rb
124
+ - lib/tuya/cli/odm/command/ci.rb
125
+ - lib/tuya/cli/odm/command/ci/show_log_tips.rb
126
+ - lib/tuya/cli/odm/command/group.rb
127
+ - lib/tuya/cli/odm/command/group/create.rb
128
+ - lib/tuya/cli/odm/command/group/init.rb
129
+ - lib/tuya/cli/odm/command/group/status.rb
130
+ - lib/tuya/cli/odm/command/lib.rb
131
+ - lib/tuya/cli/odm/command/lib/create.rb
132
+ - lib/tuya/cli/odm/command/lib/create_simple.rb
133
+ - lib/tuya/cli/odm/command/repo.rb
134
+ - lib/tuya/cli/odm/command/repo/push.rb
135
+ - lib/tuya/cli/odm/config.rb
136
+ - lib/tuya/cli/odm/data/data_odm.rb
137
+ - lib/tuya/cli/odm/executable.rb
138
+ - lib/tuya/cli/odm/git.rb
139
+ - lib/tuya/cli/odm/group.rb
140
+ - lib/tuya/cli/odm/lib.rb
141
+ - lib/tuya/cli/odm/repo/spec.rb
142
+ - lib/tuya/cli/odm/spec_repo.rb
143
+ - lib/tuya/cli/odm/system.rb
144
+ - lib/tuya/cli/odm/util/file_util.rb
145
+ - lib/tuya/cli/odm/util/puts_util.rb
146
+ - lib/tuya/cli/odm/version.rb
147
+ homepage: https://docs.tuya.com/cn/
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.5.2.3
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: odm cli for tuya
171
+ test_files: []