Skip to content

Commit c1d8944

Browse files
committed
update to the new runfile syntax
1 parent bdc95ca commit c1d8944

File tree

6 files changed

+97
-14
lines changed

6 files changed

+97
-14
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ gem 'byebug'
44
gem 'lp'
55
gem 'rspec'
66
gem 'rspec_approvals'
7-
gem 'runfile'
8-
gem 'runfile-tasks'
7+
gem 'runfile', '>= 1.0.0.rc4', require: false
8+
gem 'runfile-tasks', '>= 1.0.0.rc2', require: false
99
gem 'simplecov'
1010

1111
gemspec

bin/console

Lines changed: 0 additions & 9 deletions
This file was deleted.

helpers/checklist.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# A helper class used in Runfile for running through a release checklist
22
class Checklist
3+
include Colsole
4+
35
attr_accessor :failed, :limit
46

57
def initialize(limit: 3)

helpers/examples.runfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
title "Example Helpers"
2+
3+
help "Regenerate example scripts"
4+
action :regen do
5+
# Patch the PATH to allow the extensible example to run properly
6+
ENV['PATH']="#{Dir.pwd}/examples/extensible:#{ENV['PATH']}"
7+
Example.all.each do |example|
8+
say example.dir
9+
Dir.chdir example.dir do
10+
system 'bash test.sh >/dev/null 2>&1'
11+
end
12+
end
13+
end
14+
15+
help "Append the content of bashly.yml to all example READMEs"
16+
action :readme do
17+
ENV['NO_COLOR']='1'
18+
19+
# Patch the PATH to allow the extensible example to run properly
20+
ENV['PATH']="#{Dir.pwd}/examples/extensible:#{ENV['PATH']}"
21+
Example.all.each do |example|
22+
say example.dir
23+
example.regenerate_readme
24+
end
25+
end

helpers/release.rb renamed to helpers/release.runfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
help 'Run release checklist'
2-
usage 'release VERSION'
3-
action :release do |args|
1+
title 'Run release checklist'
2+
3+
usage 'VERSION'
4+
action do |args|
45
version = args['VERSION']
56

67
checklist = Checklist.new

runfile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
require "byebug"
2+
require_relative 'lib/bashly'
3+
require_relative 'helpers/example'
4+
require_relative 'helpers/checklist'
5+
6+
title "Bashly Developer Toolbelt"
7+
summary "Runfile tasks for building the Bashly gem"
8+
version Bashly::VERSION
9+
10+
import_gem 'runfile-tasks/gem', gemname: 'bashly'
11+
import_gem 'runfile-tasks/docker', image: 'dannyben/bashly', version: Bashly::VERSION
12+
import 'helpers/examples'
13+
import 'helpers/release'
14+
15+
help "Run shellcheck on all examples"
16+
action :shellcheck do
17+
allowed_skips = 1
18+
Example.executables.each do |example|
19+
if File.exist? example
20+
success = system "shellcheck #{example}"
21+
color = success ? 'g' : 'r'
22+
say "- shellcheck #{color}`#{example}`"
23+
exit 1 unless success
24+
else
25+
say "- skip c`#{example}`"
26+
allowed_skips -= 1
27+
if allowed_skips < 0
28+
say "- aborted: too many skips"
29+
exit 1
30+
end
31+
end
32+
end
33+
end
34+
35+
help "Run shfmt checks on all examples"
36+
action :shfmt do
37+
allowed_skips = 2
38+
Example.executables.each do |example|
39+
if example == 'examples/heredoc/cli' || !File.exist?(example)
40+
say "- skip c`#{example}`"
41+
allowed_skips -= 1
42+
if allowed_skips < 0
43+
say "- aborted: too many skips"
44+
exit 1
45+
end
46+
next
47+
end
48+
49+
success = system "shfmt -d -i 2 -ci #{example}"
50+
color = success ? 'g' : 'r'
51+
say "- shfmt #{color}`#{example}`"
52+
exit 1 unless success
53+
end
54+
end
55+
56+
help "Generate changelog and append old changelog"
57+
action :changelog do
58+
system "git changelog --save"
59+
# append older changelog (prior to switching to git-changelog)
60+
system "cat .changelog.old.md >> CHANGELOG.md"
61+
62+
# Fix typos
63+
File.write "CHANGELOG.md", File.read("CHANGELOG.md").gsub('repeatableflags', 'repeatable flags')
64+
end

0 commit comments

Comments
 (0)