bleach 0.0.2 → 0.0.7
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 +4 -4
- data/bin/bleach +63 -15
- data/languages/{javascript/jshint → css/stylelint}/Dockerfile +1 -1
- data/languages/{javascript/jshint → css/stylelint}/check-file +2 -2
- data/languages/css/stylelint/config.json +10 -0
- data/languages/ruby/rubocop/config.json +0 -4
- 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/{javascript/jshint.rb → css/stylelint.rb} +4 -3
- data/lib/command/code_check/scss/stylelint.rb +18 -0
- metadata +16 -26
- data/languages/javascript/jshint/config.json +0 -9
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
@@ -1,17 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
Dir.glob("#{__dir__}/../lib/**/*.rb").each do |lib_file|
|
6
|
-
require File.expand_path(lib_file, __dir__)
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'linguist'
|
3
|
+
require 'abstract_command'
|
10
4
|
require 'optparse'
|
11
5
|
require 'tmpdir'
|
12
6
|
require 'json'
|
13
7
|
require 'fileutils'
|
14
8
|
require 'isna'
|
9
|
+
require 'pathname'
|
10
|
+
|
11
|
+
|
12
|
+
# Discover lib files to be included
|
13
|
+
Dir.glob("#{__dir__}/../lib/**/*.rb").each do |lib_file|
|
14
|
+
require File.expand_path(lib_file, __dir__)
|
15
|
+
end
|
15
16
|
|
16
17
|
# OPTIONS BLOCK
|
17
18
|
options = {}
|
@@ -48,12 +49,32 @@ unless File.exist?(options[:file])
|
|
48
49
|
exit 1
|
49
50
|
end
|
50
51
|
|
52
|
+
# TODO: pluck these into a future config.
|
53
|
+
def resolve_language(filepath)
|
54
|
+
basename = File.basename(filepath)
|
55
|
+
extension = File.extname(basename)
|
56
|
+
return 'CSS' if extension == '.css'
|
57
|
+
return 'JavaScript' if extension == '.js'
|
58
|
+
return 'Ruby' if basename == 'Gemfile'
|
59
|
+
return 'Ruby' if basename == 'Capfile'
|
60
|
+
return 'Ruby' if basename == 'Onafile'
|
61
|
+
return 'Ruby' if basename == 'Rakefile'
|
62
|
+
return 'Ruby' if basename == 'Thorfile'
|
63
|
+
return 'Ruby' if extension == '.rb'
|
64
|
+
return 'Ruby' if extension == '.gemspec'
|
65
|
+
return 'Ruby' if extension == '.ru'
|
66
|
+
return 'SCSS' if extension == '.scss'
|
67
|
+
return basename.inspect
|
68
|
+
end
|
69
|
+
|
51
70
|
# LANGUAGE BLOCK
|
52
|
-
file_language =
|
71
|
+
file_language = resolve_language(options[:file])
|
53
72
|
|
54
73
|
LANGUAGE_MAP = {
|
74
|
+
'CSS' => 'css',
|
75
|
+
'JavaScript' => 'javascript',
|
55
76
|
'Ruby' => 'ruby',
|
56
|
-
'
|
77
|
+
'SCSS' => 'scss'
|
57
78
|
}.freeze
|
58
79
|
|
59
80
|
if LANGUAGE_MAP.keys.include?(file_language)
|
@@ -93,19 +114,46 @@ Dir.glob("#{__dir__}/../languages/#{LANGUAGE_MAP[file_language]}/*").each do |to
|
|
93
114
|
|
94
115
|
# Work is done on copies of the original files inside a temp dir
|
95
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
|
+
|
96
121
|
config['requiredFiles'].each do |required_file|
|
97
|
-
|
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!
|
98
148
|
warn "#{tool} checks need a '#{required_file['file']}' file present to run."
|
99
149
|
warn 'Check will be stopped.'
|
100
150
|
exit 1
|
151
|
+
else
|
152
|
+
# Use config file closest to file to be checked
|
153
|
+
FileUtils.cp(config_file_stack.pop, tmpdir)
|
101
154
|
end
|
102
|
-
FileUtils.cp(required_file['file'], tmpdir)
|
103
155
|
end
|
104
156
|
|
105
|
-
FileUtils.cp(options[:file], tmpdir)
|
106
|
-
FileUtils.cp(config_file, tmpdir)
|
107
|
-
file_copy = File.basename(options[:file])
|
108
|
-
|
109
157
|
# Verify if Docker image exists
|
110
158
|
inspect_command = DockerCommand::DockerImageInspect.new(tag: tool)
|
111
159
|
unless inspect_command.system
|
@@ -34,10 +34,10 @@ config = JSON.parse(File.read(config_file))
|
|
34
34
|
|
35
35
|
image_name = config['imageName']
|
36
36
|
tool_config = config['requiredFiles'].find do |record|
|
37
|
-
record['type'] == '
|
37
|
+
record['type'] == 'Stylelint Config'
|
38
38
|
end['file']
|
39
39
|
|
40
|
-
check_command = CodeCheck::
|
40
|
+
check_command = CodeCheck::StylelintCSS.new(
|
41
41
|
pwd: dir,
|
42
42
|
image_name: image_name,
|
43
43
|
config_file: tool_config,
|
@@ -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
|
@@ -2,15 +2,16 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
module CodeCheck
|
5
|
-
# Template for
|
6
|
-
class
|
5
|
+
# Template for Stylelint CSS check
|
6
|
+
class StylelintCSS < AbstractCommand
|
7
7
|
def template
|
8
8
|
'docker run ' \
|
9
9
|
'--rm ' \
|
10
10
|
'--volume %<pwd>s:/code ' \
|
11
11
|
'%<image_name>s ' \
|
12
|
-
'
|
12
|
+
'stylelint ' \
|
13
13
|
'--config /code/%<config_file>s ' \
|
14
|
+
'--color ' \
|
14
15
|
'%<source_files>s'
|
15
16
|
end
|
16
17
|
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
|
@@ -25,20 +25,6 @@ dependencies:
|
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
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
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: isna
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,8 +39,8 @@ dependencies:
|
|
53
39
|
- - "~>"
|
54
40
|
- !ruby/object:Gem::Version
|
55
41
|
version: 0.0.4
|
56
|
-
description:
|
57
|
-
email:
|
42
|
+
description:
|
43
|
+
email:
|
58
44
|
executables:
|
59
45
|
- bleach
|
60
46
|
- install-bleach-git-hooks
|
@@ -63,23 +49,27 @@ extra_rdoc_files: []
|
|
63
49
|
files:
|
64
50
|
- "./bin/bleach"
|
65
51
|
- "./bin/install-bleach-git-hooks"
|
52
|
+
- "./languages/css/stylelint/Dockerfile"
|
53
|
+
- "./languages/css/stylelint/check-file"
|
54
|
+
- "./languages/css/stylelint/config.json"
|
66
55
|
- "./languages/javascript/eslint/Dockerfile"
|
67
56
|
- "./languages/javascript/eslint/check-file"
|
68
57
|
- "./languages/javascript/eslint/config.json"
|
69
|
-
- "./languages/javascript/jshint/Dockerfile"
|
70
|
-
- "./languages/javascript/jshint/check-file"
|
71
|
-
- "./languages/javascript/jshint/config.json"
|
72
58
|
- "./languages/ruby/brakeman/Dockerfile"
|
73
59
|
- "./languages/ruby/brakeman/check-file"
|
74
60
|
- "./languages/ruby/brakeman/config.json"
|
75
61
|
- "./languages/ruby/rubocop/Dockerfile"
|
76
62
|
- "./languages/ruby/rubocop/check-file"
|
77
63
|
- "./languages/ruby/rubocop/config.json"
|
64
|
+
- "./languages/scss/stylelint/Dockerfile"
|
65
|
+
- "./languages/scss/stylelint/check-file"
|
66
|
+
- "./languages/scss/stylelint/config.json"
|
78
67
|
- "./lib/command/check_file.rb"
|
68
|
+
- "./lib/command/code_check/css/stylelint.rb"
|
79
69
|
- "./lib/command/code_check/javascript/eslint.rb"
|
80
|
-
- "./lib/command/code_check/javascript/jshint.rb"
|
81
70
|
- "./lib/command/code_check/ruby/brakeman.rb"
|
82
71
|
- "./lib/command/code_check/ruby/rubocop.rb"
|
72
|
+
- "./lib/command/code_check/scss/stylelint.rb"
|
83
73
|
- "./lib/command/docker_build.rb"
|
84
74
|
- "./lib/command/docker_image_inspect.rb"
|
85
75
|
- "./lib/command/docker_remove_image.rb"
|
@@ -91,7 +81,7 @@ homepage: https://github.com/freshout-dev/bleach
|
|
91
81
|
licenses:
|
92
82
|
- MIT
|
93
83
|
metadata: {}
|
94
|
-
post_install_message:
|
84
|
+
post_install_message:
|
95
85
|
rdoc_options: []
|
96
86
|
require_paths:
|
97
87
|
- lib
|
@@ -106,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
96
|
- !ruby/object:Gem::Version
|
107
97
|
version: '0'
|
108
98
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
110
|
-
signing_key:
|
99
|
+
rubygems_version: 3.0.3
|
100
|
+
signing_key:
|
111
101
|
specification_version: 4
|
112
102
|
summary: bleach - code check tool
|
113
103
|
test_files: []
|