bleach 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/bleach +133 -0
- data/bin/install-bleach-git-hooks +35 -0
- data/languages/javascript/eslint/Dockerfile +7 -0
- data/languages/javascript/eslint/check-file +46 -0
- data/languages/javascript/eslint/config.json +9 -0
- data/languages/javascript/jshint/Dockerfile +4 -0
- data/languages/javascript/jshint/check-file +46 -0
- data/languages/javascript/jshint/config.json +9 -0
- data/languages/ruby/brakeman/Dockerfile +1 -0
- data/languages/ruby/brakeman/check-file +73 -0
- data/languages/ruby/brakeman/config.json +13 -0
- data/languages/ruby/rubocop/Dockerfile +6 -0
- data/languages/ruby/rubocop/check-file +46 -0
- data/languages/ruby/rubocop/config.json +13 -0
- data/lib/command/check_file.rb +12 -0
- data/lib/command/code_check/javascript/eslint.rb +18 -0
- data/lib/command/code_check/javascript/jshint.rb +17 -0
- data/lib/command/code_check/ruby/brakeman.rb +20 -0
- data/lib/command/code_check/ruby/rubocop.rb +20 -0
- data/lib/command/docker_build.rb +17 -0
- data/lib/command/docker_image_inspect.rb +15 -0
- data/lib/command/docker_remove_image.rb +15 -0
- data/lib/docker_command.rb +2 -0
- data/script/pre-commit +23 -0
- metadata +113 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3d495ae25dc8b22b7f30ff8e9ccaac5267a1c435bef32903f53ae53d0b3b25da
|
4
|
+
data.tar.gz: 104bec8e24cf10dd466238c6c193a4ad9de47116c9d166ef217ac4042ef549c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2237b13fcec791ac257681a9f5144dc47178bb2f79baa5ce010d0e29b05d4a08d650fbebc855a3a7c9d8d1c3337af2f743438af477ffe4e113ac9ce30cfb12a0
|
7
|
+
data.tar.gz: 3fa27adb09c3d254af71ff040b5d8f8dbd311ef39f22272099da4b30e12c263f3d9c5649f10dae81f93f3a3a7977face32adf100deedc69000f177e7bd938d0f
|
data/bin/bleach
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Discover lib files to be included
|
5
|
+
Dir.glob("#{__dir__}/../lib/**/*.rb").each do |lib_file|
|
6
|
+
require File.expand_path(lib_file, __dir__)
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'linguist'
|
10
|
+
require 'optparse'
|
11
|
+
require 'tmpdir'
|
12
|
+
require 'json'
|
13
|
+
require 'fileutils'
|
14
|
+
require 'isna'
|
15
|
+
|
16
|
+
# OPTIONS BLOCK
|
17
|
+
options = {}
|
18
|
+
OptionParser.new do |opts|
|
19
|
+
opts.banner = "Usage: #{$0} [OPTIONS]"
|
20
|
+
f_description = 'Filepath of the file that needs to be checked.'
|
21
|
+
opts.on('-f', '--file [STRING]', f_description) do |value|
|
22
|
+
options[:file] = value
|
23
|
+
end
|
24
|
+
i_description = 'Install Git commit hook'
|
25
|
+
opts.on('-i', '--install', i_description) do |value|
|
26
|
+
options[:install] = value
|
27
|
+
end
|
28
|
+
end.parse!
|
29
|
+
|
30
|
+
if options[:install]
|
31
|
+
if system('install-bleach-git-hooks')
|
32
|
+
exit 0
|
33
|
+
else
|
34
|
+
warn 'Git hook installation failed.'
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
required_options = [:file]
|
40
|
+
required_options.each do |option|
|
41
|
+
unless options[option]
|
42
|
+
warn "Cannot run, '--#{option}' was not given."
|
43
|
+
exit 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
unless File.exist?(options[:file])
|
47
|
+
warn "File to check not found: '#{options[:file]}'"
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
|
51
|
+
# LANGUAGE BLOCK
|
52
|
+
file_language = Linguist::FileBlob.new(options[:file]).language.to_s
|
53
|
+
|
54
|
+
LANGUAGE_MAP = {
|
55
|
+
'Ruby' => 'ruby',
|
56
|
+
'JavaScript' => 'javascript'
|
57
|
+
}.freeze
|
58
|
+
|
59
|
+
if LANGUAGE_MAP.keys.include?(file_language)
|
60
|
+
tool_dir = "#{__dir__ }/../lib/command/code_check/#{file_language.downcase}"
|
61
|
+
unless File.directory?(tool_dir)
|
62
|
+
warn "No tools found for language: '#{file_language}'"
|
63
|
+
exit 0
|
64
|
+
end
|
65
|
+
puts "Found supported language: #{file_language}"
|
66
|
+
else
|
67
|
+
warn "Language not supported: #{file_language}"
|
68
|
+
exit 0
|
69
|
+
end
|
70
|
+
|
71
|
+
# PRINT BANNER FUNCTION
|
72
|
+
def print_banner(tool, file)
|
73
|
+
template = '# [%s]: Running checks with tool: %s'
|
74
|
+
bindings = []
|
75
|
+
bindings.push(Time.now)
|
76
|
+
bindings.push(tool.to_ansi.yellow.to_s)
|
77
|
+
banner = (template % bindings).to_ansi.cyan.to_s
|
78
|
+
ruler = ('# ' + ('-' * 78)).to_ansi.cyan.to_s
|
79
|
+
file_detail = ('# target: ' + file).to_ansi.cyan.to_s
|
80
|
+
puts ''
|
81
|
+
puts banner
|
82
|
+
puts file_detail
|
83
|
+
puts ruler
|
84
|
+
end
|
85
|
+
|
86
|
+
# MAIN CHECK LOOP
|
87
|
+
Dir.glob("#{__dir__}/../languages/#{LANGUAGE_MAP[file_language]}/*").each do |tool_directory|
|
88
|
+
config_file = "#{tool_directory}/config.json"
|
89
|
+
config = JSON.parse(File.read(config_file))
|
90
|
+
tool = File.basename(tool_directory)
|
91
|
+
|
92
|
+
print_banner(tool, options[:file])
|
93
|
+
|
94
|
+
# Work is done on copies of the original files inside a temp dir
|
95
|
+
Dir.mktmpdir do |tmpdir|
|
96
|
+
config['requiredFiles'].each do |required_file|
|
97
|
+
unless File.exist?(required_file['file'])
|
98
|
+
warn "#{tool} checks need a '#{required_file['file']}' file present to run."
|
99
|
+
warn 'Check will be stopped.'
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
FileUtils.cp(required_file['file'], tmpdir)
|
103
|
+
end
|
104
|
+
|
105
|
+
FileUtils.cp(options[:file], tmpdir)
|
106
|
+
FileUtils.cp(config_file, tmpdir)
|
107
|
+
file_copy = File.basename(options[:file])
|
108
|
+
|
109
|
+
# Verify if Docker image exists
|
110
|
+
inspect_command = DockerCommand::DockerImageInspect.new(tag: tool)
|
111
|
+
unless inspect_command.system
|
112
|
+
# Otherwise, build Docker image for tool
|
113
|
+
puts "Building container image for #{tool}."
|
114
|
+
build_command = DockerCommand::DockerBuild.new(
|
115
|
+
tag: tool,
|
116
|
+
dockerfile_dir: tool_directory
|
117
|
+
)
|
118
|
+
exit 1 unless build_command.system
|
119
|
+
end
|
120
|
+
|
121
|
+
tool_command = Command::CheckFile.new(
|
122
|
+
tool_directory: tool_directory,
|
123
|
+
tmpdir: tmpdir,
|
124
|
+
file_copy: file_copy
|
125
|
+
)
|
126
|
+
|
127
|
+
unless tool_command.system
|
128
|
+
warn 'Source file did not pass some checks.'
|
129
|
+
warn 'No more checks will be run.'
|
130
|
+
exit 1
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
if File.exist?("#{Dir.pwd}/.git") && File.directory?("#{Dir.pwd}/.git")
|
7
|
+
# 'Found .git directory'
|
8
|
+
if File.exist?("#{Dir.pwd}/.git/hooks/pre-commit")
|
9
|
+
# 'Found pre-commit file'
|
10
|
+
if File.exist?("#{Dir.pwd}/.git/hooks/pre-commit.bleach-backup")
|
11
|
+
warn 'Git pre-commit hook backup found in "/.git/hooks/pre-commit.bleach-backup".'
|
12
|
+
warn 'Will stop installation.'
|
13
|
+
exit 1
|
14
|
+
else
|
15
|
+
# 'No backup found. Making one.'
|
16
|
+
FileUtils.cp("#{Dir.pwd}/.git/hooks/pre-commit",
|
17
|
+
"#{Dir.pwd}/.git/hooks/pre-commit.bleach-backup")
|
18
|
+
# 'Copying file'
|
19
|
+
FileUtils.cp("#{__dir__}/../script/pre-commit",
|
20
|
+
"#{Dir.pwd}/.git/hooks/pre-commit")
|
21
|
+
FileUtils.chmod(0755,"#{Dir.pwd}/.git/hooks/pre-commit")
|
22
|
+
puts 'Successfuly installed Git pre-commit hook in "/.git/hooks/pre-commit".'
|
23
|
+
puts 'I made a backup of your previous one in "/.git/hooks/pre-commit.bleach-backup".'
|
24
|
+
end
|
25
|
+
else
|
26
|
+
# 'No file found. Copying.'
|
27
|
+
FileUtils.cp("#{__dir__}/../script/pre-commit",
|
28
|
+
"#{Dir.pwd}/.git/hooks/pre-commit")
|
29
|
+
FileUtils.chmod(0755,"#{Dir.pwd}/.git/hooks/pre-commit")
|
30
|
+
puts 'Successfuly installed Git pre-commit hook in "/.git/hooks/pre-commit".'
|
31
|
+
end
|
32
|
+
else
|
33
|
+
warn '".git" directory not found. Is this a Git repository?'
|
34
|
+
exit 1
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Discover lib files to be included
|
5
|
+
Dir.glob("#{__dir__}/../../../lib/**/*.rb").each do |lib_file|
|
6
|
+
require File.expand_path(lib_file, __dir__)
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [OPTIONS]"
|
15
|
+
|
16
|
+
opts.on('-f', '--file [STRING]', 'File.') do |value|
|
17
|
+
options[:file] = value
|
18
|
+
end
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
required_options = [:file]
|
22
|
+
required_options.each do |option|
|
23
|
+
unless options[option]
|
24
|
+
warn "Can not run #{option} was not given."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
file = File.basename(options[:file])
|
30
|
+
dir = File.dirname(options[:file])
|
31
|
+
|
32
|
+
config_file = "#{dir}/config.json"
|
33
|
+
config = JSON.parse(File.read(config_file))
|
34
|
+
|
35
|
+
image_name = config['imageName']
|
36
|
+
tool_config = config['requiredFiles'].find do |record|
|
37
|
+
record['type'] == 'ESLint Config'
|
38
|
+
end['file']
|
39
|
+
|
40
|
+
check_command = CodeCheck::ESLint.new(
|
41
|
+
pwd: dir,
|
42
|
+
image_name: image_name,
|
43
|
+
config_file: tool_config,
|
44
|
+
source_files: "/code/#{file}"
|
45
|
+
)
|
46
|
+
exit 1 unless check_command.system
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Discover lib files to be included
|
5
|
+
Dir.glob("#{__dir__}/../../../lib/**/*.rb").each do |lib_file|
|
6
|
+
require File.expand_path(lib_file, __dir__)
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [OPTIONS]"
|
15
|
+
|
16
|
+
opts.on('-f', '--file [STRING]', 'File.') do |value|
|
17
|
+
options[:file] = value
|
18
|
+
end
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
required_options = [:file]
|
22
|
+
required_options.each do |option|
|
23
|
+
unless options[option]
|
24
|
+
warn "Can not run #{option} was not given."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
file = File.basename(options[:file])
|
30
|
+
dir = File.dirname(options[:file])
|
31
|
+
|
32
|
+
config_file = "#{dir}/config.json"
|
33
|
+
config = JSON.parse(File.read(config_file))
|
34
|
+
|
35
|
+
image_name = config['imageName']
|
36
|
+
tool_config = config['requiredFiles'].find do |record|
|
37
|
+
record['type'] == 'JSHint Config'
|
38
|
+
end['file']
|
39
|
+
|
40
|
+
check_command = CodeCheck::JSHint.new(
|
41
|
+
pwd: dir,
|
42
|
+
image_name: image_name,
|
43
|
+
config_file: tool_config,
|
44
|
+
source_files: "/code/#{file}"
|
45
|
+
)
|
46
|
+
exit 1 unless check_command.system
|
@@ -0,0 +1 @@
|
|
1
|
+
FROM presidentbeef/brakeman
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Discover lib files to be included
|
5
|
+
Dir.glob("#{__dir__}/../../../lib/**/*.rb").each do |lib_file|
|
6
|
+
require File.expand_path(lib_file, __dir__)
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'json'
|
11
|
+
require 'isna'
|
12
|
+
|
13
|
+
def print_brakeman_results(file, target, color)
|
14
|
+
data = File.read(file)
|
15
|
+
hash = JSON.parse(data)
|
16
|
+
hash[target].each do |warning|
|
17
|
+
puts ''
|
18
|
+
puts ''
|
19
|
+
warning.each do |key, value|
|
20
|
+
if value.is_a?(Hash)
|
21
|
+
puts "#{key.rjust(20, ' ').to_ansi.send(color).to_s}: #{value.inspect}"
|
22
|
+
next
|
23
|
+
end
|
24
|
+
if value.is_a?(Array)
|
25
|
+
puts "#{key.rjust(20, ' ').to_ansi.send(color).to_s}: #{value.inspect}"
|
26
|
+
next
|
27
|
+
end
|
28
|
+
puts "#{key.rjust(20, ' ').to_ansi.send(color).to_s}: #{value}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
return hash[target].empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
options = {}
|
35
|
+
OptionParser.new do |opts|
|
36
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [OPTIONS]"
|
37
|
+
|
38
|
+
opts.on('-f', '--file [STRING]', 'File.') do |value|
|
39
|
+
options[:file] = value
|
40
|
+
end
|
41
|
+
end.parse!
|
42
|
+
|
43
|
+
required_options = [:file]
|
44
|
+
required_options.each do |option|
|
45
|
+
unless options[option]
|
46
|
+
warn "Can not run #{option} was not given."
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
file = File.basename(options[:file])
|
52
|
+
dir = File.dirname(options[:file])
|
53
|
+
|
54
|
+
config_file = "#{dir}/config.json"
|
55
|
+
config = JSON.parse(File.read(config_file))
|
56
|
+
|
57
|
+
image_name = config['imageName']
|
58
|
+
tool_config = config['requiredFiles'].find do |record|
|
59
|
+
record['type'] == 'Brakeman Config'
|
60
|
+
end['file']
|
61
|
+
|
62
|
+
check_command = CodeCheck::Brakeman.new(
|
63
|
+
pwd: dir,
|
64
|
+
image_name: image_name,
|
65
|
+
config_file: tool_config,
|
66
|
+
source_files: "#{file}"
|
67
|
+
)
|
68
|
+
check_command.system
|
69
|
+
|
70
|
+
exit 1 unless print_brakeman_results("#{dir}/report.json", 'errors', :red)
|
71
|
+
if print_brakeman_results("#{dir}/report.json", 'warnings', :yellow)
|
72
|
+
puts 'No warnings or errors found.'
|
73
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
# Discover lib files to be included
|
5
|
+
Dir.glob("#{__dir__}/../../../lib/**/*.rb").each do |lib_file|
|
6
|
+
require File.expand_path(lib_file, __dir__)
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'json'
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: #{File.basename(__FILE__)} [OPTIONS]"
|
15
|
+
|
16
|
+
opts.on('-f', '--file [STRING]', 'File.') do |value|
|
17
|
+
options[:file] = value
|
18
|
+
end
|
19
|
+
end.parse!
|
20
|
+
|
21
|
+
required_options = [:file]
|
22
|
+
required_options.each do |option|
|
23
|
+
unless options[option]
|
24
|
+
warn "Can not run #{option} was not given."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
file = File.basename(options[:file])
|
30
|
+
dir = File.dirname(options[:file])
|
31
|
+
|
32
|
+
config_file = "#{dir}/config.json"
|
33
|
+
config = JSON.parse(File.read(config_file))
|
34
|
+
|
35
|
+
image_name = config['imageName']
|
36
|
+
tool_config = config['requiredFiles'].find do |record|
|
37
|
+
record['type'] == 'Rubocop Config'
|
38
|
+
end['file']
|
39
|
+
|
40
|
+
check_command = CodeCheck::Rubocop.new(
|
41
|
+
pwd: dir,
|
42
|
+
image_name: image_name,
|
43
|
+
config_file: tool_config,
|
44
|
+
source_files: "/code/#{file}"
|
45
|
+
)
|
46
|
+
exit 1 unless check_command.system
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module CodeCheck
|
5
|
+
# Template for ESLint check
|
6
|
+
class ESLint < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'eslint ' \
|
13
|
+
'--config /code/%<config_file>s ' \
|
14
|
+
'--color ' \
|
15
|
+
'%<source_files>s'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module CodeCheck
|
5
|
+
# Template for JSHint check
|
6
|
+
class JSHint < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'jshint ' \
|
13
|
+
'--config /code/%<config_file>s ' \
|
14
|
+
'%<source_files>s'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module CodeCheck
|
5
|
+
# Template for Brakeman check
|
6
|
+
class Brakeman < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'--config-file /code/%<config_file>s ' \
|
13
|
+
'--force-scan ' \
|
14
|
+
'--quiet ' \
|
15
|
+
'--output report.json ' \
|
16
|
+
'--only-files ' \
|
17
|
+
'%<source_files>s'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module CodeCheck
|
5
|
+
# Template for Rubocop check
|
6
|
+
class Rubocop < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'rubocop ' \
|
13
|
+
'--display-style-guide ' \
|
14
|
+
'--extra-details ' \
|
15
|
+
'--color ' \
|
16
|
+
'--config /code/%<config_file>s ' \
|
17
|
+
'%<source_files>s'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'abstract_command'
|
5
|
+
|
6
|
+
module DockerCommand
|
7
|
+
# Template for 'docker build' command
|
8
|
+
class DockerBuild < AbstractCommand
|
9
|
+
def template
|
10
|
+
'docker build ' +
|
11
|
+
# '--no-cache ' +
|
12
|
+
'--quiet ' \
|
13
|
+
'--tag bleach/' + '%<tag>s ' \
|
14
|
+
'%<dockerfile_dir>s >/dev/null'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'abstract_command'
|
5
|
+
|
6
|
+
module DockerCommand
|
7
|
+
# Template for 'docker image inspect' command
|
8
|
+
class DockerImageInspect < AbstractCommand
|
9
|
+
def template
|
10
|
+
'docker image inspect ' \
|
11
|
+
'bleach/' + '%<tag>s' + ' >/dev/null 2>&1'
|
12
|
+
# We don't care about output, we just want to know if image exists
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'abstract_command'
|
5
|
+
|
6
|
+
module DockerCommand
|
7
|
+
# Template for 'docker rmi' command
|
8
|
+
class DockerRemoveImage < AbstractCommand
|
9
|
+
def template
|
10
|
+
'docker rmi ' \
|
11
|
+
'--force ' \
|
12
|
+
'bleach/' + '%<tag>s'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/script/pre-commit
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'abstract_command'
|
5
|
+
|
6
|
+
module Command
|
7
|
+
# Template for Git 'diff-index' command
|
8
|
+
class GitDiffIndex < AbstractCommand
|
9
|
+
def template
|
10
|
+
'git diff-index --name-only --diff-filter=ACMR HEAD'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
# Template for 'bleach' command
|
14
|
+
class Bleach < AbstractCommand
|
15
|
+
def template
|
16
|
+
'bleach -f %<filename>s'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Command::GitDiffIndex.new.backtick.each_line.map do |file|
|
22
|
+
exit 1 unless Command::Bleach.new(filename: file.chomp).system
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bleach
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luis Flores
|
8
|
+
- Kazuyoshi Tlacaelel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: abstract_command
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.0.6
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.0.6
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: github-linguist
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '7.13'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '7.13'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: isna
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.0.4
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.0.4
|
56
|
+
description:
|
57
|
+
email:
|
58
|
+
executables:
|
59
|
+
- bleach
|
60
|
+
- install-bleach-git-hooks
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- "./bin/bleach"
|
65
|
+
- "./bin/install-bleach-git-hooks"
|
66
|
+
- "./languages/javascript/eslint/Dockerfile"
|
67
|
+
- "./languages/javascript/eslint/check-file"
|
68
|
+
- "./languages/javascript/eslint/config.json"
|
69
|
+
- "./languages/javascript/jshint/Dockerfile"
|
70
|
+
- "./languages/javascript/jshint/check-file"
|
71
|
+
- "./languages/javascript/jshint/config.json"
|
72
|
+
- "./languages/ruby/brakeman/Dockerfile"
|
73
|
+
- "./languages/ruby/brakeman/check-file"
|
74
|
+
- "./languages/ruby/brakeman/config.json"
|
75
|
+
- "./languages/ruby/rubocop/Dockerfile"
|
76
|
+
- "./languages/ruby/rubocop/check-file"
|
77
|
+
- "./languages/ruby/rubocop/config.json"
|
78
|
+
- "./lib/command/check_file.rb"
|
79
|
+
- "./lib/command/code_check/javascript/eslint.rb"
|
80
|
+
- "./lib/command/code_check/javascript/jshint.rb"
|
81
|
+
- "./lib/command/code_check/ruby/brakeman.rb"
|
82
|
+
- "./lib/command/code_check/ruby/rubocop.rb"
|
83
|
+
- "./lib/command/docker_build.rb"
|
84
|
+
- "./lib/command/docker_image_inspect.rb"
|
85
|
+
- "./lib/command/docker_remove_image.rb"
|
86
|
+
- "./lib/docker_command.rb"
|
87
|
+
- "./script/pre-commit"
|
88
|
+
- bin/bleach
|
89
|
+
- bin/install-bleach-git-hooks
|
90
|
+
homepage: https://github.com/freshout-dev/bleach
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.1.2
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: bleach - code check tool
|
113
|
+
test_files: []
|