theme-check 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/exe/theme-check +1 -1
- data/lib/theme_check/cli.rb +99 -64
- data/lib/theme_check/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c3c0a379dbaa7c43b75d62954952d88a57af1ba6ba028cb30a73803a45fc274
|
4
|
+
data.tar.gz: eef366fdb4f66ec0bf33c1d405e405ea757159295a11bac02ea6c8086e9d5342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae494f6e081c0ed351d5511c2990503933b50d2b5749fd33f948770d3ffbb46fb7274b91c164731953e2d3566201b38ed09b352c02ec81091081a70c9697b4b3
|
7
|
+
data.tar.gz: 4ecd1ecbc3f035a60c837deb46c8174043a35cc11118fc28f70c30369c8d99d555b4432da1cd3faa662d49773457eb8f3dfad97439a5d2fcce58d45922189ec4
|
data/CHANGELOG.md
CHANGED
data/exe/theme-check
CHANGED
data/lib/theme_check/cli.rb
CHANGED
@@ -1,85 +1,104 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "optparse"
|
3
|
+
|
2
4
|
module ThemeCheck
|
3
5
|
class Cli
|
4
6
|
class Abort < StandardError; end
|
5
7
|
|
6
|
-
|
7
|
-
Usage: theme-check [options] /path/to/your/theme
|
8
|
-
|
9
|
-
Basic Options:
|
10
|
-
-C, --config <path> Use the config provided, overriding .theme-check.yml if present
|
11
|
-
-c, --category <category> Only run this category of checks
|
12
|
-
-x, --exclude-category <category> Exclude this category of checks
|
13
|
-
-a, --auto-correct Automatically fix offenses
|
14
|
-
|
15
|
-
Miscellaneous:
|
16
|
-
--init Generate a .theme-check.yml file
|
17
|
-
--print-config Output active config to STDOUT
|
18
|
-
-h, --help Show this. Hi!
|
19
|
-
-l, --list List enabled checks
|
20
|
-
-v, --version Print Theme Check version
|
21
|
-
|
22
|
-
Description:
|
23
|
-
Theme Check helps you follow Shopify Themes & Liquid best practices by analyzing the
|
24
|
-
Liquid & JSON inside your theme.
|
25
|
-
|
26
|
-
You can configure checks in the .theme-check.yml file of your theme root directory.
|
27
|
-
END
|
8
|
+
attr_accessor :path
|
28
9
|
|
29
|
-
def
|
10
|
+
def initialize
|
30
11
|
@path = "."
|
12
|
+
@command = :check
|
13
|
+
@only_categories = []
|
14
|
+
@exclude_categories = []
|
15
|
+
@auto_correct = false
|
16
|
+
@config_path = nil
|
17
|
+
end
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
19
|
+
def option_parser(parser = OptionParser.new, help: true)
|
20
|
+
return @option_parser if @option_parser
|
21
|
+
@option_parser = parser
|
22
|
+
@option_parser.banner = "Usage: theme-check [options] [/path/to/your/theme]"
|
23
|
+
|
24
|
+
@option_parser.separator("")
|
25
|
+
@option_parser.separator("Basic Options:")
|
26
|
+
@option_parser.on(
|
27
|
+
"-C", "--config PATH",
|
28
|
+
"Use the config provided, overriding .theme-check.yml if present"
|
29
|
+
) { |path| @config_path = path }
|
30
|
+
@option_parser.on(
|
31
|
+
"-c", "--category CATEGORY",
|
32
|
+
"Only run this category of checks"
|
33
|
+
) { |category| @only_categories << category.to_sym }
|
34
|
+
@option_parser.on(
|
35
|
+
"-x", "--exclude-category CATEGORY",
|
36
|
+
"Exclude this category of checks"
|
37
|
+
) { |category| @exclude_categories << category.to_sym }
|
38
|
+
@option_parser.on(
|
39
|
+
"-a", "--auto-correct",
|
40
|
+
"Automatically fix offenses"
|
41
|
+
) { @auto_correct = true }
|
42
|
+
|
43
|
+
@option_parser.separator("")
|
44
|
+
@option_parser.separator("Miscellaneous:")
|
45
|
+
@option_parser.on(
|
46
|
+
"--init",
|
47
|
+
"Generate a .theme-check.yml file"
|
48
|
+
) { @command = :init }
|
49
|
+
@option_parser.on(
|
50
|
+
"--print",
|
51
|
+
"Output active config to STDOUT"
|
52
|
+
) { @command = :print }
|
53
|
+
@option_parser.on(
|
54
|
+
"-h", "--help",
|
55
|
+
"Show this. Hi!"
|
56
|
+
) { @command = :help } if help
|
57
|
+
@option_parser.on(
|
58
|
+
"-l", "--list",
|
59
|
+
"List enabled checks"
|
60
|
+
) { @command = :list }
|
61
|
+
@option_parser.on(
|
62
|
+
"-v", "--version",
|
63
|
+
"Print Theme Check version"
|
64
|
+
) { @command = :version }
|
65
|
+
|
66
|
+
@option_parser.separator("")
|
67
|
+
@option_parser.separator(<<~EOS)
|
68
|
+
Description:
|
69
|
+
Theme Check helps you follow Shopify Themes & Liquid best practices by analyzing the
|
70
|
+
Liquid & JSON inside your theme.
|
71
|
+
|
72
|
+
You can configure checks in the .theme-check.yml file of your theme root directory.
|
73
|
+
EOS
|
74
|
+
|
75
|
+
@option_parser
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse(argv)
|
79
|
+
@path = option_parser.parse(argv).first || "."
|
80
|
+
end
|
63
81
|
|
64
|
-
|
65
|
-
|
82
|
+
def run!
|
83
|
+
unless [:version, :init, :help].include?(@command)
|
84
|
+
@config = if @config_path
|
66
85
|
ThemeCheck::Config.new(
|
67
86
|
root: @path,
|
68
|
-
configuration: ThemeCheck::Config.load_file(config_path)
|
87
|
+
configuration: ThemeCheck::Config.load_file(@config_path)
|
69
88
|
)
|
70
89
|
else
|
71
90
|
ThemeCheck::Config.from_path(@path)
|
72
91
|
end
|
73
|
-
@config.only_categories = only_categories
|
74
|
-
@config.exclude_categories = exclude_categories
|
75
|
-
@config.auto_correct = auto_correct
|
92
|
+
@config.only_categories = @only_categories
|
93
|
+
@config.exclude_categories = @exclude_categories
|
94
|
+
@config.auto_correct = @auto_correct
|
76
95
|
end
|
77
96
|
|
78
|
-
send(command)
|
97
|
+
send(@command)
|
79
98
|
end
|
80
99
|
|
81
|
-
def run
|
82
|
-
run
|
100
|
+
def run
|
101
|
+
run!
|
83
102
|
rescue Abort => e
|
84
103
|
if e.message.empty?
|
85
104
|
exit(1)
|
@@ -88,6 +107,18 @@ module ThemeCheck
|
|
88
107
|
end
|
89
108
|
end
|
90
109
|
|
110
|
+
def self.parse_and_run!(argv)
|
111
|
+
cli = new
|
112
|
+
cli.parse(argv)
|
113
|
+
cli.run!
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.parse_and_run(argv)
|
117
|
+
cli = new
|
118
|
+
cli.parse(argv)
|
119
|
+
cli.run
|
120
|
+
end
|
121
|
+
|
91
122
|
def list
|
92
123
|
puts @config.enabled_checks
|
93
124
|
end
|
@@ -111,12 +142,16 @@ module ThemeCheck
|
|
111
142
|
puts YAML.dump(@config.to_h)
|
112
143
|
end
|
113
144
|
|
145
|
+
def help
|
146
|
+
puts option_parser.to_s
|
147
|
+
end
|
148
|
+
|
114
149
|
def check
|
115
150
|
puts "Checking #{@config.root} ..."
|
116
151
|
storage = ThemeCheck::FileSystemStorage.new(@config.root, ignored_patterns: @config.ignored_patterns)
|
117
152
|
theme = ThemeCheck::Theme.new(storage)
|
118
153
|
if theme.all.empty?
|
119
|
-
raise Abort, "No templates found
|
154
|
+
raise Abort, "No templates found."
|
120
155
|
end
|
121
156
|
analyzer = ThemeCheck::Analyzer.new(theme, @config.enabled_checks, @config.auto_correct)
|
122
157
|
analyzer.analyze_theme
|
data/lib/theme_check/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Cournoyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|