|
1 | | -require 'json' |
2 | | - |
3 | | -begin |
4 | | - require 'packaging' |
5 | | - Pkg::Util::RakeUtils.load_packaging_tasks |
6 | | -rescue LoadError => e |
7 | | - puts "Error loading packaging rake tasks: #{e}" |
| 1 | +def run_command(cmd) |
| 2 | + output, status = Open3.capture2e(cmd) |
| 3 | + abort "Command failed! Command: #{cmd}, Output: #{output}" unless status.exitstatus.zero? |
| 4 | + return output.chomp |
8 | 5 | end |
9 | 6 |
|
10 | 7 | Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file } |
11 | | - |
12 | | -namespace :package do |
13 | | - task :bootstrap do |
14 | | - puts 'Bootstrap is no longer needed, using packaging-as-a-gem' |
15 | | - end |
16 | | - task :implode do |
17 | | - puts 'Implode is no longer needed, using packaging-as-a-gem' |
18 | | - end |
19 | | -end |
20 | | - |
21 | | -namespace :component do |
22 | | - desc "Display currently promoted ref for component" |
23 | | - task :check, [:component] do |t,args| |
24 | | - abort 'USAGE: rake component:check[component]' unless args[:component] |
25 | | - |
26 | | - config = get_component_config(args[:component]) |
27 | | - |
28 | | - puts config["ref"] |
29 | | - end |
30 | | - |
31 | | - desc "Update component config to promote a new version" |
32 | | - task :promote, [:component, :version, :ref] do |t,args| |
33 | | - abort 'USAGE: rake component:promote[component,version,ref]' unless args[:component] && args[:version] && args[:ref] |
34 | | - |
35 | | - config = get_component_config(args[:component]) |
36 | | - config["version"] = args[:version] |
37 | | - config["ref"] = args[:ref] |
38 | | - |
39 | | - File.open(component_config_file(args[:component]), 'w') do |f| |
40 | | - f.write(JSON.pretty_generate(config)) |
41 | | - end |
42 | | - end |
43 | | -end |
44 | | - |
45 | | -# Legacy task name. |
46 | | -task :promote_component, [:component, :version, :ref] => "component:promote" |
47 | | - |
48 | | -def component_config_file(component) |
49 | | - "configs/components/#{component}.json" |
50 | | -end |
51 | | - |
52 | | -def get_component_config(component) |
53 | | - conf = component_config_file(component) |
54 | | - abort "No component config file '#{conf}'" unless File.exist?(conf) |
55 | | - |
56 | | - JSON.parse(File.read(conf)) |
57 | | -end |
0 commit comments