blob: 3ac6cefc041aaffde872b7f8e16529aa20df0920 (
plain)
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
|
#!/usr/bin/env nix-shell
#!ruby
#!nix-shell -p gitMinimal -p ruby -i ruby
require "json"
VERSION_MATCHER = /\A\d+\.\d+\.\d+\z/;
NPM_FORMAT = {
indent: " ",
space: " ",
object_nl: "\n",
array_nl: "\n",
}
$version = ARGV.first
unless $version
STDERR.puts "Needs a new version number.\n"
exit 1
end
unless $version.match(VERSION_MATCHER)
STDERR.puts "Argument is not a valid version number.\n"
exit 1
end
Dir.chdir(File.expand_path(File.join(__dir__(), ".."))) do
data = JSON.parse(File.read("package.json"))
data["version"] = $version
File.write("package.json", JSON.generate(data, NPM_FORMAT) + "\n")
`git add package.json`
`git commit -m "Bumps to v#{$version}" package.json`
`git tag v#{$version}`
end
puts "Don't forget to `git push && git push --tags`";
# vim: ft=ruby
|