This repository has been archived by the owner on Sep 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
/
Rakefile
156 lines (142 loc) · 3.85 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
require 'bundler/gem_tasks'
require 'open-uri'
require 'zip'
module Bundler
class GemHelper
def tag_version
sh "git tag -s -m \"Version #{version}\" #{version_tag}"
Bundler.ui.confirm "Tagged #{version_tag}."
yield if block_given?
rescue
Bundler.ui.error "Untagging #{version_tag} due to error."
sh_with_code "git tag -d #{version_tag}"
raise
end
end
end
desc 'Update to the latest version of Highcharts'
task :update, :version do |_, args|
# After highcharts 5.0.0, chart code was was seperated into to files: code/
# containing classic mode with styling in the code, and code/js containing
# styled mode, where presentational code is removed. Prior to 5.0.0 this code
# was contained in the js/ folder
MODULE_MAPPING = %w(
accessibility
annotations
boost-canvas
boost
broken-axis
bullet
data
drag-panes
drilldown
export-data
exporting
funnel
gantt
grid-axis
heatmap
histogram-bellcurve
item-series
no-data-to-display
offline-exporting
oldie
overlapping-datalabels
parallel-coordinates
pareto
sankey
series-label
solid-gauge
static-scale
stock
streamgraph
sunburst
tilemap
treemap
variable-pie
variwide
vector
windbarb
wordcloud
xrange
).map do |name|
["modules/#{name}.src.js", "highcharts/modules/#{name}.js"]
end.to_h
LIB_MAPPING = %w(
canvg
jspdf
rgbcolor
svg2pdf
).map do |name|
["lib/#{name}.src.js", "highcharts/lib/#{name}.js"]
end.to_h
THEMES_MAPPING = %w(
avocado
dark-blue
dark-green
dark-unica
gray
grid-light
grid
sand-signika
skies
sunset
).map do |name|
["themes/#{name}.src.js", "highcharts/themes/#{name}.js"]
end.to_h
STYLE_MAPPING = %w(
highcharts.css
highcharts.scss
).map do |name|
["css/#{name}", "../stylesheets/highcharts/#{name}"]
end.to_h
MAPPINGS = {
'highcharts.src.js' => 'highcharts.js',
'highcharts-more.src.js' => 'highcharts/highcharts-more.js',
'highcharts-3d.src.js' => 'highcharts/highcharts-3d.js'
}
.merge(MODULE_MAPPING)
.merge(LIB_MAPPING)
.merge(THEMES_MAPPING)
.merge(STYLE_MAPPING)
.map { |src, dst| ["code/#{src}", dst] }.to_h.freeze
version = args[:version]
url = "http://code.highcharts.com/zips/Highcharts-#{version}.zip"
puts "Fetching #{url}"
open(url) do |stream|
Zip::File.open_buffer(stream) do |file|
file.each do |entry|
dest_rel_path = MAPPINGS[entry.name]
if !dest_rel_path
puts "ignoring #{entry.name}" if entry.name.include?("src.js")
next
end
dest_path = "app/assets/javascripts/#{dest_rel_path}"
FileUtils.remove(dest_path, force: true)
entry.extract(dest_path)
puts dest_rel_path + ' extracted'
end
end
end
end
desc 'Update and release new version of Highcharts'
task :dist, :version do |_, args|
version = args[:version]
Rake::Task['update'].invoke(version)
# Put template in CHANGELOG
template = "# #{version} / #{Time.now.strftime("%Y-%m-%d")}\n\n* Updated Highcharts to #{version} ()\n * ...\n\n"
system "echo '#{template}' | cat - CHANGELOG.markdown > tmp/changelog && mv tmp/changelog CHANGELOG.markdown"
system "open CHANGELOG.markdown -a $EDITOR"
puts "CHANGELOG template added. Press Enter to continue when done editing"
STDIN.gets
# Update version
system "sed -i '' -e 's/VERSION = \".*\"/VERSION = \"#{version}\"/' lib/highcharts/version.rb"
# Commit changes
print "Enter commit message: [Release v#{version}]"
message = STDIN.gets.strip
message = "Release v#{version}" if message == ""
system "git add CHANGELOG.markdown lib/highcharts/version.rb app/assets"
system "git commit -m '#{message}'"
# Tag, build and release
system "rake release"
end