Skip to content

Commit 7fcbefc

Browse files
committed
Automate revendoring of Gems for Language Server
Previously the gem revendoring was manual. This commit adds a rake task to perform the revendoring instead. The script also updates the READE format to include the repo used to vendor the gem from.
1 parent ed48a69 commit 7fcbefc

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

server/Rakefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,57 @@ namespace :rubocop do
3333
end
3434
end
3535

36+
desc "Download and vendor required gems"
37+
task :gem_revendor do
38+
require 'fileutils'
39+
40+
gem_list = [
41+
{
42+
:directory => 'puppet-lint',
43+
:github_repo => 'https://github.com/rodjek/puppet-lint.git',
44+
:github_ref => '2.2.1',
45+
}
46+
]
47+
48+
# Clean out the vendor directory first
49+
puts "Clearing the vendor directory..."
50+
vendor_dir = File.join(File.dirname(__FILE__),'vendor')
51+
FileUtils.rm_rf(vendor_dir) if Dir.exists?(vendor_dir)
52+
Dir.mkdir(vendor_dir)
53+
54+
gem_list.each do |vendor|
55+
puts "Vendoring #{vendor[:directory]}..."
56+
gem_dir = File.join(vendor_dir,vendor[:directory])
57+
58+
sh "git clone #{vendor[:github_repo]} #{gem_dir}"
59+
Dir.chdir(gem_dir) do
60+
sh 'git fetch origin'
61+
sh "git checkout #{vendor[:github_ref]}"
62+
end
63+
64+
# Cleanup the gem directory...
65+
FileUtils.rm_rf(File.join(gem_dir,'.git'))
66+
FileUtils.rm_rf(File.join(gem_dir,'spec'))
67+
end
68+
69+
# Generate the README
70+
readme = <<-HEREDOC
71+
# Vendored Gems
72+
73+
The puppet language server is designed to run within the Puppet Agent ruby environment which means no access to Native Extensions or Gem bundling.
74+
75+
This means any Gems required outside of Puppet Agent for the language server must be vendored in this directory and the load path modified in the `puppet-languageserver` file.
76+
77+
Note - To comply with Licensing, the Gem source should be MIT licensed or even more unrestricted.
78+
79+
Note - To improve the packaging size, test files etc. were stripped from the Gems prior to committing.
80+
81+
Gem List
82+
--------
83+
84+
HEREDOC
85+
gem_list.each { |vendor| readme += "* #{vendor[:directory]} (#{vendor[:github_repo]} ref #{vendor[:github_ref]})"}
86+
File.open(File.join(vendor_dir,'README.md'), 'wb') { |file| file.write(readme + "\n") }
87+
end
88+
3689
task :default => [:test]

server/vendor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Note - To improve the packaging size, test files etc. were stripped from the Gem
1111
Gem List
1212
--------
1313

14-
* puppet-lint v2.2.1
14+
* puppet-lint (https://github.com/rodjek/puppet-lint.git ref 2.2.1)

0 commit comments

Comments
 (0)