63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/pindo/command/dev/feishu.rb', line 63
def run
pindo_project_dir = Dir.pwd
if @webhook_url.nil? || @webhook_url.empty?
if is_git_directory?(local_repo_dir: pindo_project_dir)
current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
if File.exist?(File.join(current_git_root_path, 'feishu.json'))
feishu_config = JSON.parse(File.read(File.join(current_git_root_path, 'feishu.json')))
@webhook_url = feishu_config['webhook_url']
@secret = feishu_config['secret']
end
end
if @webhook_url.nil? || @webhook_url.empty?
@webhook_url = ask("请输入飞书webhook url:")
if is_git_directory?(local_repo_dir: pindo_project_dir)
current_git_root_path = git_root_directory(local_repo_dir: pindo_project_dir)
feishu_config = {webhook_url: @webhook_url, secret: @secret}
File.write(File.join(current_git_root_path, 'feishu.json'), JSON.pretty_generate(feishu_config))
Dir.chdir(current_git_root_path)
current_branch = git!(%W(-C #{current_git_root_path} rev-parse --abbrev-ref HEAD)).strip
git!(%W(-C #{current_git_root_path} add feishu.json))
commit_message = "docs: 添加飞书webhook url".encode('UTF-8')
git!(%W(-C #{current_git_root_path} commit -m #{commit_message}))
git!(%W(-C #{current_git_root_path} push origin #{current_branch}))
puts "添加飞书webhook url成功"
end
end
end
puts "webhook_url: #{@webhook_url}"
puts "secret: #{@secret}"
puts
puts "正在发送飞书消息..."
build_helper = Pindo::BuildHelper.share_instance
build_helper.check_check_and_install_cliff(pindo_project_dir)
is_need_add_tag,tag_action_parms = build_helper.check_is_need_add_tag?(pindo_project_dir)
if is_need_add_tag
Pindo::Command::Dev::Tag::run(tag_action_parms)
end
unless @webhook_url.nil? || @webhook_url.empty?
@client = Pindo::FeishuClient.new(@webhook_url, @secret)
end
markdown_content = PgyerHelper.share_instace.get_description_from_git(current_project_dir:pindo_project_dir)
puts
puts "#{markdown_content}"
puts
if !markdown_content.nil? && !markdown_content.empty?
@client.send_markdown(nil, markdown_content)
end
end
|