bleach 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bleach +40 -8
- data/languages/css/stylelint/Dockerfile +4 -0
- data/languages/css/stylelint/check-file +46 -0
- data/languages/css/stylelint/config.json +10 -0
- data/languages/scss/stylelint/Dockerfile +4 -0
- data/languages/scss/stylelint/check-file +46 -0
- data/languages/scss/stylelint/config.json +10 -0
- data/lib/command/code_check/css/stylelint.rb +18 -0
- data/lib/command/code_check/scss/stylelint.rb +18 -0
- metadata +16 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4be1129274eef3cdb72513e127a9287690939b4aa88387ba6e0400430c48b2e
|
4
|
+
data.tar.gz: f92030b0f9931e14d6b0115d17383f6f01f60b07fa0716a7585b6c7dd84057a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66579701a5c3db1dfe70a3748bba0927381213d175aaece3c324578aa054d4e6f9bf96685818b7f1322aff4a8d42c91c7aeb8736bd6e0d5fe237532e18ef8a1f
|
7
|
+
data.tar.gz: a364f8bfe372141df9e834d7625098e671d6a3ecf7a47dd6b4539c04fda90c3f4aee5e7f0d81ed3d3df7fe006cceab0f2c3b4650d621fb830df28dc79b9d3364
|
data/bin/bleach
CHANGED
@@ -6,6 +6,7 @@ require 'tmpdir'
|
|
6
6
|
require 'json'
|
7
7
|
require 'fileutils'
|
8
8
|
require 'isna'
|
9
|
+
require 'pathname'
|
9
10
|
|
10
11
|
|
11
12
|
# Discover lib files to be included
|
@@ -52,6 +53,8 @@ end
|
|
52
53
|
def resolve_language(filepath)
|
53
54
|
basename = File.basename(filepath)
|
54
55
|
extension = File.extname(basename)
|
56
|
+
return 'CSS' if extension == '.css'
|
57
|
+
return 'JavaScript' if extension == '.js'
|
55
58
|
return 'Ruby' if basename == 'Gemfile'
|
56
59
|
return 'Ruby' if basename == 'Capfile'
|
57
60
|
return 'Ruby' if basename == 'Onafile'
|
@@ -60,7 +63,7 @@ def resolve_language(filepath)
|
|
60
63
|
return 'Ruby' if extension == '.rb'
|
61
64
|
return 'Ruby' if extension == '.gemspec'
|
62
65
|
return 'Ruby' if extension == '.ru'
|
63
|
-
return '
|
66
|
+
return 'SCSS' if extension == '.scss'
|
64
67
|
return basename.inspect
|
65
68
|
end
|
66
69
|
|
@@ -68,8 +71,10 @@ end
|
|
68
71
|
file_language = resolve_language(options[:file])
|
69
72
|
|
70
73
|
LANGUAGE_MAP = {
|
74
|
+
'CSS' => 'css',
|
75
|
+
'JavaScript' => 'javascript',
|
71
76
|
'Ruby' => 'ruby',
|
72
|
-
'
|
77
|
+
'SCSS' => 'scss'
|
73
78
|
}.freeze
|
74
79
|
|
75
80
|
if LANGUAGE_MAP.keys.include?(file_language)
|
@@ -109,19 +114,46 @@ Dir.glob("#{__dir__}/../languages/#{LANGUAGE_MAP[file_language]}/*").each do |to
|
|
109
114
|
|
110
115
|
# Work is done on copies of the original files inside a temp dir
|
111
116
|
Dir.mktmpdir do |tmpdir|
|
117
|
+
FileUtils.cp(options[:file], tmpdir)
|
118
|
+
FileUtils.cp(config_file, tmpdir)
|
119
|
+
file_copy = File.basename(options[:file])
|
120
|
+
|
112
121
|
config['requiredFiles'].each do |required_file|
|
113
|
-
|
122
|
+
config_file_stack = []
|
123
|
+
# File on repository root
|
124
|
+
if File.exist?(required_file['file'])
|
125
|
+
config_file_stack.push(required_file['file'])
|
126
|
+
end
|
127
|
+
|
128
|
+
# Search for alternate files on path to file
|
129
|
+
# Get path to file to be checked
|
130
|
+
path_stack = Pathname(options[:file]).each_filename.to_a
|
131
|
+
# Get rid of filename (keep directories only)
|
132
|
+
path_stack.pop
|
133
|
+
unless path_stack.empty?
|
134
|
+
for step in 0..(path_stack.length - 1) do
|
135
|
+
new_path = ''
|
136
|
+
for i in 0..step do
|
137
|
+
new_path += path_stack[i] + '/'
|
138
|
+
end
|
139
|
+
file_with_path = new_path + required_file['file']
|
140
|
+
if File.exist?(file_with_path)
|
141
|
+
config_file_stack.push(file_with_path)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
if config_file_stack.empty?
|
147
|
+
# No file found anywhere!
|
114
148
|
warn "#{tool} checks need a '#{required_file['file']}' file present to run."
|
115
149
|
warn 'Check will be stopped.'
|
116
150
|
exit 1
|
151
|
+
else
|
152
|
+
# Use config file closest to file to be checked
|
153
|
+
FileUtils.cp(config_file_stack.pop, tmpdir)
|
117
154
|
end
|
118
|
-
FileUtils.cp(required_file['file'], tmpdir)
|
119
155
|
end
|
120
156
|
|
121
|
-
FileUtils.cp(options[:file], tmpdir)
|
122
|
-
FileUtils.cp(config_file, tmpdir)
|
123
|
-
file_copy = File.basename(options[:file])
|
124
|
-
|
125
157
|
# Verify if Docker image exists
|
126
158
|
inspect_command = DockerCommand::DockerImageInspect.new(tag: tool)
|
127
159
|
unless inspect_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'] == 'Stylelint Config'
|
38
|
+
end['file']
|
39
|
+
|
40
|
+
check_command = CodeCheck::StylelintCSS.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'] == 'Stylelint Config'
|
38
|
+
end['file']
|
39
|
+
|
40
|
+
check_command = CodeCheck::StylelintSCSS.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 Stylelint CSS check
|
6
|
+
class StylelintCSS < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'stylelint ' \
|
13
|
+
'--config /code/%<config_file>s ' \
|
14
|
+
'--color ' \
|
15
|
+
'%<source_files>s'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module CodeCheck
|
5
|
+
# Template for Stylelint SCSS check
|
6
|
+
class StylelintSCSS < AbstractCommand
|
7
|
+
def template
|
8
|
+
'docker run ' \
|
9
|
+
'--rm ' \
|
10
|
+
'--volume %<pwd>s:/code ' \
|
11
|
+
'%<image_name>s ' \
|
12
|
+
'stylelint ' \
|
13
|
+
'--config /code/%<config_file>s ' \
|
14
|
+
'--color ' \
|
15
|
+
'%<source_files>s'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bleach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis Flores
|
8
8
|
- Kazuyoshi Tlacaelel
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abstract_command
|
@@ -39,8 +39,8 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: 0.0.4
|
42
|
-
description:
|
43
|
-
email:
|
42
|
+
description:
|
43
|
+
email:
|
44
44
|
executables:
|
45
45
|
- bleach
|
46
46
|
- install-bleach-git-hooks
|
@@ -49,6 +49,9 @@ extra_rdoc_files: []
|
|
49
49
|
files:
|
50
50
|
- "./bin/bleach"
|
51
51
|
- "./bin/install-bleach-git-hooks"
|
52
|
+
- "./languages/css/stylelint/Dockerfile"
|
53
|
+
- "./languages/css/stylelint/check-file"
|
54
|
+
- "./languages/css/stylelint/config.json"
|
52
55
|
- "./languages/javascript/eslint/Dockerfile"
|
53
56
|
- "./languages/javascript/eslint/check-file"
|
54
57
|
- "./languages/javascript/eslint/config.json"
|
@@ -58,10 +61,15 @@ files:
|
|
58
61
|
- "./languages/ruby/rubocop/Dockerfile"
|
59
62
|
- "./languages/ruby/rubocop/check-file"
|
60
63
|
- "./languages/ruby/rubocop/config.json"
|
64
|
+
- "./languages/scss/stylelint/Dockerfile"
|
65
|
+
- "./languages/scss/stylelint/check-file"
|
66
|
+
- "./languages/scss/stylelint/config.json"
|
61
67
|
- "./lib/command/check_file.rb"
|
68
|
+
- "./lib/command/code_check/css/stylelint.rb"
|
62
69
|
- "./lib/command/code_check/javascript/eslint.rb"
|
63
70
|
- "./lib/command/code_check/ruby/brakeman.rb"
|
64
71
|
- "./lib/command/code_check/ruby/rubocop.rb"
|
72
|
+
- "./lib/command/code_check/scss/stylelint.rb"
|
65
73
|
- "./lib/command/docker_build.rb"
|
66
74
|
- "./lib/command/docker_image_inspect.rb"
|
67
75
|
- "./lib/command/docker_remove_image.rb"
|
@@ -73,7 +81,7 @@ homepage: https://github.com/freshout-dev/bleach
|
|
73
81
|
licenses:
|
74
82
|
- MIT
|
75
83
|
metadata: {}
|
76
|
-
post_install_message:
|
84
|
+
post_install_message:
|
77
85
|
rdoc_options: []
|
78
86
|
require_paths:
|
79
87
|
- lib
|
@@ -88,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
96
|
- !ruby/object:Gem::Version
|
89
97
|
version: '0'
|
90
98
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
92
|
-
signing_key:
|
99
|
+
rubygems_version: 3.0.3
|
100
|
+
signing_key:
|
93
101
|
specification_version: 4
|
94
102
|
summary: bleach - code check tool
|
95
103
|
test_files: []
|