DYAutomate 1.0.10 → 1.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.
- checksums.yaml +4 -4
- data/lib/Core/DYBaseObj.rb +36 -0
- data/lib/Core/user_interface.rb +36 -0
- data/lib/DYAutomate/Command/codeGenerate.rb +70 -0
- data/lib/DYAutomate/Command.rb +6 -2
- data/lib/DYAutomate/CustomConfig/DYAutomateConfig.rb +120 -0
- data/lib/DYAutomate/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca40553f032c4e9d73485419d62ab39396340fa3c884ae22c9c323ea4222cc2a
|
4
|
+
data.tar.gz: 8c96d0b43dff6fe910d66967e233004907d8441b711a2a98a09a1f47575e7518
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d26755088d66ac96ba98e3f457e184bfa514db907b3ec49b48eecd5c03e60b5f1a54228b408b04fd3d09335ffa74f9ce4c23f2b9079b315d8ddd3db5a2cb5f
|
7
|
+
data.tar.gz: 07c5579de29bc7d0af3f67825f7cbfe94c68890b7fe4e4cdfc5e997480ae8a13d9b82b54444b40039139a715c6c082a0ae40c9d05c09dc6f18458bdb45c9083b
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module DYAutomate
|
4
|
+
class DYBaseObj < Object
|
5
|
+
|
6
|
+
@public
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
super
|
10
|
+
yield self if block_given?
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.fromFile(path)
|
14
|
+
if File.exist?(path)
|
15
|
+
content = File.open(path, 'r:utf-8', &:read)
|
16
|
+
eval(content,nil,path.to_s)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#加载从yaml
|
21
|
+
def self.fromYAML(path)
|
22
|
+
if File.exist?(path)
|
23
|
+
content = File.open(path)
|
24
|
+
YAML.load(content)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#以yaml缓存
|
29
|
+
def doCacheByYAML(path)
|
30
|
+
if path
|
31
|
+
File.open(path, "w") { |file| YAML.dump(self, file) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module DYAutomate
|
2
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
3
|
+
#
|
4
|
+
# UI.disable_wrap = true
|
5
|
+
|
6
|
+
# Redirects the messages to an internal store.
|
7
|
+
#
|
8
|
+
module UI
|
9
|
+
@output = ''
|
10
|
+
@warnings = ''
|
11
|
+
@next_input = ''
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :output
|
15
|
+
attr_accessor :warnings
|
16
|
+
attr_accessor :next_input
|
17
|
+
|
18
|
+
def puts(message = '')
|
19
|
+
@output << "#{message}\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
def warn(message = '', _actions = [])
|
23
|
+
@warnings << "#{message}\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def print(message)
|
27
|
+
@output << message
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :gets, :next_input
|
31
|
+
|
32
|
+
def print_warnings
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
|
2
|
+
module DYAutomate
|
3
|
+
class Command
|
4
|
+
class CodeGenerate < Command
|
5
|
+
|
6
|
+
# require 'Command/pod/push.rb'
|
7
|
+
# require 'Command/pod/version.rb'
|
8
|
+
|
9
|
+
self.abstract_command = false
|
10
|
+
self.command = 'code'
|
11
|
+
self.summary = '按照模版,自动生成代码'
|
12
|
+
# self.default_subcommand = 'list'
|
13
|
+
self.arguments = [
|
14
|
+
# CLAide::Argument.new('NAME', true),
|
15
|
+
]
|
16
|
+
|
17
|
+
#当前路径
|
18
|
+
attr_accessor :path
|
19
|
+
|
20
|
+
def initialize(argv)
|
21
|
+
@path = Dir.pwd
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate!
|
26
|
+
super
|
27
|
+
unless @config.templates_git_url
|
28
|
+
help! "
|
29
|
+
error -- >!!! Not found <templates_git_url> in the #{DYAutomateConfig::configFilePath}"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
clone_templates
|
36
|
+
exulateFile = File.join(@config.templates_cache_path,"ACMain.rb")
|
37
|
+
if File.exist?(exulateFile)
|
38
|
+
system("ruby #{exulateFile} #{Dir.pwd}")
|
39
|
+
else
|
40
|
+
UI.puts "cant find templates start file <ACMain.rb>."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def clone_templates
|
45
|
+
url = @config.templates_git_url
|
46
|
+
path = @config.templates_cache_path
|
47
|
+
system("rm -rf #{path}")
|
48
|
+
unless Dir.exist?(path)
|
49
|
+
Dir.mkdir(path,0777)
|
50
|
+
end
|
51
|
+
UI.puts("Cloning `#{url}` into `#{path}`.")
|
52
|
+
system("git clone #{url} --depth 1 #{path}")
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# def check_git_version
|
57
|
+
# versionFile = File.join(@config.templates_cache_path,"version")
|
58
|
+
# isSame = false
|
59
|
+
# if File.exist?(versionFile)
|
60
|
+
# versionContent = File.open(versionFile, 'r:utf-8', &:read)
|
61
|
+
# if versionContent
|
62
|
+
# isSame = versionContent.chomp.eql?(@git_tag.chomp)
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
# isSame
|
66
|
+
# end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/DYAutomate/Command.rb
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
require 'DYAutomate.rb'
|
2
2
|
require 'version'
|
3
3
|
require 'Core/CoreConfig'
|
4
|
+
require 'CustomConfig/DYAutomateConfig'
|
5
|
+
require 'Core/user_interface'
|
4
6
|
|
5
7
|
module DYAutomate
|
6
8
|
require 'CLAide'
|
7
|
-
|
9
|
+
include UI
|
8
10
|
class Command < CLAide::Command
|
9
11
|
include CoreConfig
|
10
12
|
require 'Command/pod.rb'
|
11
13
|
require 'Command/workspace.rb'
|
12
|
-
|
14
|
+
require 'Command/codeGenerate'
|
13
15
|
|
16
|
+
attr_accessor :config
|
14
17
|
self.abstract_command = true
|
15
18
|
self.command = 'dj'
|
16
19
|
self.version = VERSION
|
@@ -23,6 +26,7 @@ module DYAutomate
|
|
23
26
|
super
|
24
27
|
@repoName = CoreConfig::Core_previte_repo_name
|
25
28
|
@env_str = CoreConfig::Core_env_str
|
29
|
+
@config = DYAutomateConfig.loadConfig
|
26
30
|
pp("当前环境变量 #{@env_str}",1)
|
27
31
|
end
|
28
32
|
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'Core/DYBaseObj'
|
2
|
+
|
3
|
+
|
4
|
+
module DYAutomate
|
5
|
+
class DYAutomateConfig < DYBaseObj
|
6
|
+
@public
|
7
|
+
#cache相关的路径
|
8
|
+
@@cachePath = File.join(Dir.home(),'Documents','.DYAutomate')
|
9
|
+
@@configFilePath = File.join(@@cachePath, 'DYConfigFile.rb')
|
10
|
+
@@configGitClonePath = File.join(@@cachePath, 'Git')
|
11
|
+
@@logsDirPath = File.join(@@cachePath, 'log')
|
12
|
+
|
13
|
+
attr_accessor :git
|
14
|
+
attr_accessor :git_tag
|
15
|
+
attr_accessor :templates_git_url
|
16
|
+
# attr_accessor :templates_git_url
|
17
|
+
attr_accessor :templates_cache_path
|
18
|
+
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.logsDirPath
|
25
|
+
@@logsDirPath
|
26
|
+
end
|
27
|
+
|
28
|
+
#从配置中心读取
|
29
|
+
def self.loadConfig
|
30
|
+
checkConfigFile?
|
31
|
+
cc = DYAutomateConfig::fromFile(@@configFilePath)
|
32
|
+
puts cc
|
33
|
+
cc.loadDetailFromGit if cc
|
34
|
+
cc
|
35
|
+
end
|
36
|
+
|
37
|
+
@private
|
38
|
+
|
39
|
+
#检测config.rb是否存在
|
40
|
+
def self.checkConfigFile?
|
41
|
+
path = File.join(@@configFilePath)
|
42
|
+
unless File.exist?(path)
|
43
|
+
creatConfigFile
|
44
|
+
puts "*** At first ,you should edit the config file at path<#{@@configFilePath}>!!"
|
45
|
+
|
46
|
+
`open #{@@configFilePath}`
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#创建一个ConfigFile例子
|
51
|
+
def self.creatConfigFile
|
52
|
+
|
53
|
+
unless Dir.exist?(@@cachePath)
|
54
|
+
Dir.mkdir(@@cachePath,0777)
|
55
|
+
end
|
56
|
+
|
57
|
+
File.new(@@configFilePath,'w+')
|
58
|
+
|
59
|
+
f = File.open(@@configFilePath, "w+")
|
60
|
+
demo = <<-EOF
|
61
|
+
#DYAutomate 配置
|
62
|
+
|
63
|
+
DYAutomateConfig.new do |c|
|
64
|
+
c.git = ""
|
65
|
+
c.git_tag = ""
|
66
|
+
end
|
67
|
+
EOF
|
68
|
+
|
69
|
+
f.write(demo)
|
70
|
+
end
|
71
|
+
|
72
|
+
def check_git_dir
|
73
|
+
unless Dir.exist?(@@configGitClonePath)
|
74
|
+
Dir.mkdir(@@configGitClonePath,0777)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def check_git_version
|
79
|
+
versionFile = File.join(@@configGitClonePath,"version")
|
80
|
+
isSame = false
|
81
|
+
if File.exist?(versionFile)
|
82
|
+
versionContent = File.open(versionFile, 'r:utf-8', &:read)
|
83
|
+
if versionContent
|
84
|
+
isSame = versionContent.chomp.eql?(@git_tag.chomp)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
isSame
|
88
|
+
end
|
89
|
+
|
90
|
+
def clone_git
|
91
|
+
check_git_dir
|
92
|
+
if @git_tag && @git
|
93
|
+
url = "#{@git} --branch #{@git_tag}"
|
94
|
+
# url = "#{@git} "
|
95
|
+
cloneOk = system "git clone #{url} #{@@configGitClonePath}"
|
96
|
+
if cloneOk
|
97
|
+
puts "加载配置成功。。。"
|
98
|
+
else
|
99
|
+
puts "clone #{url}失败!!"
|
100
|
+
end
|
101
|
+
else
|
102
|
+
puts
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def loadDetailFromGit
|
107
|
+
puts "加载配置。。。"
|
108
|
+
check_git_dir
|
109
|
+
unless check_git_version
|
110
|
+
system("rm -rf #{@@configGitClonePath}")
|
111
|
+
clone_git
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def templates_cache_path
|
116
|
+
File.join(@@cachePath,'templates')
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
data/lib/DYAutomate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: DYAutomate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 陈冬冬
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,14 +104,14 @@ dependencies:
|
|
104
104
|
name: cocoapods
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: 1.6.1
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 1.6.1
|
117
117
|
- !ruby/object:Gem::Dependency
|
@@ -139,6 +139,8 @@ files:
|
|
139
139
|
- README.md
|
140
140
|
- bin/dj
|
141
141
|
- lib/Core/CoreConfig.rb
|
142
|
+
- lib/Core/DYBaseObj.rb
|
143
|
+
- lib/Core/user_interface.rb
|
142
144
|
- lib/DYAutomate.rb
|
143
145
|
- lib/DYAutomate/Command.rb
|
144
146
|
- lib/DYAutomate/Command/Git/tagAdd.rb
|
@@ -146,9 +148,11 @@ files:
|
|
146
148
|
- lib/DYAutomate/Command/Pod/version.rb
|
147
149
|
- lib/DYAutomate/Command/Workspace/install.rb
|
148
150
|
- lib/DYAutomate/Command/Workspace/update.rb
|
151
|
+
- lib/DYAutomate/Command/codeGenerate.rb
|
149
152
|
- lib/DYAutomate/Command/dgit.rb
|
150
153
|
- lib/DYAutomate/Command/pod.rb
|
151
154
|
- lib/DYAutomate/Command/workspace.rb
|
155
|
+
- lib/DYAutomate/CustomConfig/DYAutomateConfig.rb
|
152
156
|
- lib/DYAutomate/version.rb
|
153
157
|
homepage: https://code.aliyun.com/iOSTools/DYAutomate.git
|
154
158
|
licenses:
|