From 21532a0334a57ef31d45fea3da304a96eed3e2f8 Mon Sep 17 00:00:00 2001 From: Robert Kiel Date: Fri, 31 Aug 2018 16:45:20 -0400 Subject: [PATCH] added republish push --- lib/feature/republish.rb | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/feature/republish.rb b/lib/feature/republish.rb index 06efa68..236fa8e 100644 --- a/lib/feature/republish.rb +++ b/lib/feature/republish.rb @@ -39,10 +39,35 @@ module Feature tags = tags.map {|x| x.to_i } tags << 0 new_number = tags.uniq.max + 1 + new_tag = "#{version}-#{new_number}" - git_local_tag "#{version}-#{new_number}" + git_local_tag new_tag git_push_tags + + data = republish_push + data['push_to'].each do |repo| + puts "updating #{repo}" + repo_dir = File.join(Dir.pwd, '..', repo) + json = package_json_file repo_dir + update_tag data['name'], json['dependencies'], new_tag + update_tag data['name'], json['devDependencies'], new_tag + save_package_json_file json, repo_dir + end + end + + private + + def update_tag name, dependencies, new_tag + dependencies.keys.each do |key| + if key == name + value = dependencies[key] + parts = value.split('#') + dependencies[key] = [parts.first,'#',new_tag].join + end + end + end + end end