immosquare-cleaner 0.1.7 → 0.1.8
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/immosquare-cleaner +15 -1
- data/lib/{immosquare_cleaner → immosquare-cleaner}/version.rb +1 -1
- data/lib/{immosquare_cleaner.rb → immosquare-cleaner.rb} +35 -48
- data/linters/eslintrc.json +27 -33
- data/package.json +5 -4
- metadata +5 -5
- /data/lib/{immosquare_cleaner → immosquare-cleaner}/configuration.rb +0 -0
- /data/lib/{immosquare_cleaner → immosquare-cleaner}/railtie.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ec2041334b9098e1f6b501cdeb0155fac6bf061ac20e77102e9a36c72065e298
|
|
4
|
+
data.tar.gz: 4a7d25d7ca56b906cec3013e8aa383bb7edcd56e88123f0baf50169f1b9a678a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 695a74e0a92e19fe5a51e1d283786df24d722412ca6d2dbcc097480fe52dce674b97d44f18e5acccb4c2f5c9ee170cc5e3bae91cbd76b97719f00958b233a19c
|
|
7
|
+
data.tar.gz: 9833e7b8bb962471c72ffe624a5ec900422498990cb2f890630ae74f626b5f90cfdc389c0d5b827c01eb7ba98733e6f5faa807e4c44ae38222ae44feeb61648b
|
data/bin/immosquare-cleaner
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "immosquare-cleaner"
|
|
4
4
|
require "optparse"
|
|
5
5
|
|
|
6
|
+
|
|
7
|
+
##===========================================================================##
|
|
8
|
+
## We check if bun.sh is installed
|
|
9
|
+
##===========================================================================##
|
|
10
|
+
def bun_installed?
|
|
11
|
+
system("which bun > /dev/null 2>&1")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if !bun_installed?
|
|
15
|
+
puts "Error: 'bun' is not installed. Please install it first.(https://bun.sh/)"
|
|
16
|
+
exit(1)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
options = {}
|
|
7
21
|
##===========================================================================##
|
|
8
22
|
## optparse is a standard library of ruby, it's used to parse command line ##
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "English"
|
|
2
2
|
require "neatjson"
|
|
3
|
-
require_relative "
|
|
4
|
-
require_relative "
|
|
3
|
+
require_relative "immosquare-cleaner/configuration"
|
|
4
|
+
require_relative "immosquare-cleaner/railtie" if defined?(Rails)
|
|
5
5
|
|
|
6
6
|
##===========================================================================##
|
|
7
7
|
## Importing the 'English' library allows us to use more human-readable
|
|
@@ -35,82 +35,67 @@ module ImmosquareCleaner
|
|
|
35
35
|
##============================================================##
|
|
36
36
|
## Default options
|
|
37
37
|
##============================================================##
|
|
38
|
-
|
|
39
|
-
cmd = []
|
|
40
|
-
options = {}.merge(options)
|
|
41
|
-
|
|
38
|
+
options = {}.merge(options)
|
|
42
39
|
|
|
43
40
|
begin
|
|
44
|
-
raise("Error: The file '#{file_path}' does not exist.") if !File.exist?(file_path)
|
|
45
|
-
|
|
46
41
|
##============================================================##
|
|
47
42
|
## .html.erb files
|
|
48
43
|
##============================================================##
|
|
49
44
|
if file_path.end_with?(".html.erb")
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
cmds = []
|
|
46
|
+
cmds << "bundle exec htmlbeautifier #{file_path} #{ImmosquareCleaner.configuration.htmlbeautifier_options || "--keep-blank-lines 4"}"
|
|
47
|
+
cmds << "bundle exec erblint --config #{gem_root}/linters/erb-lint.yml #{file_path} #{ImmosquareCleaner.configuration.erblint_options || "--autocorrect"}"
|
|
48
|
+
launch_cmds(cmds)
|
|
49
|
+
normalize_last_line(file_path)
|
|
50
|
+
return
|
|
53
51
|
end
|
|
54
52
|
|
|
55
53
|
##============================================================##
|
|
56
54
|
## Ruby Files
|
|
57
55
|
##============================================================##
|
|
58
|
-
if
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
if file_path.end_with?(*RUBY_FILES) || File.open(file_path, &:gets)&.include?(SHEBANG)
|
|
57
|
+
cmds = ["bundle exec rubocop -c #{gem_root}/linters/rubocop.yml #{file_path} #{ImmosquareCleaner.configuration.rubocop_options || "--autocorrect-all"}"]
|
|
58
|
+
launch_cmds(cmds)
|
|
59
|
+
normalize_last_line(file_path)
|
|
60
|
+
return
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
##============================================================##
|
|
64
64
|
## Yml translations files
|
|
65
65
|
##============================================================##
|
|
66
|
-
if
|
|
66
|
+
if file_path =~ %r{locales/.*\.yml$}
|
|
67
67
|
ImmosquareYaml.clean(file_path)
|
|
68
|
-
|
|
68
|
+
return
|
|
69
69
|
end
|
|
70
70
|
|
|
71
71
|
##============================================================##
|
|
72
72
|
## JS files
|
|
73
73
|
##============================================================##
|
|
74
|
-
if
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
if file_path.end_with?(".js")
|
|
75
|
+
cmds = ["bun eslint --config #{gem_root}/linters/eslintrc.json #{file_path} --fix"]
|
|
76
|
+
launch_cmds(cmds)
|
|
77
|
+
normalize_last_line(file_path)
|
|
78
|
+
return
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
##============================================================##
|
|
80
82
|
## JSON files
|
|
81
83
|
##============================================================##
|
|
82
|
-
if
|
|
84
|
+
if file_path.end_with?(".json")
|
|
83
85
|
json_str = File.read(file_path)
|
|
84
86
|
parsed_data = JSON.parse(json_str)
|
|
85
87
|
formated = JSON.neat_generate(parsed_data, :aligned => true)
|
|
86
88
|
File.write(file_path, formated)
|
|
87
|
-
|
|
89
|
+
normalize_last_line(file_path)
|
|
90
|
+
return
|
|
88
91
|
end
|
|
89
92
|
|
|
90
93
|
##============================================================##
|
|
91
94
|
## Autres formats
|
|
92
95
|
##============================================================##
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
cmd << "npx prettier --write #{file_path} #{prettier_parser} --config #{gem_root}/linters/prettier.yml"
|
|
97
|
-
else
|
|
98
|
-
puts("Warning: npx and/or prettier are not installed. Skipping formatting.")
|
|
99
|
-
end if !procesed
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
##===========================================================================##
|
|
103
|
-
## We change the current directory to the gem root to ensure the gem's paths
|
|
104
|
-
## are used when executing the commands
|
|
105
|
-
##===========================================================================##
|
|
106
|
-
Dir.chdir(gem_root) do
|
|
107
|
-
cmd.each {|c| system(c) }
|
|
108
|
-
end if !cmd.empty?
|
|
109
|
-
|
|
110
|
-
##============================================================##
|
|
111
|
-
## We normalize the last line of the file to ensure it ends with a single
|
|
112
|
-
##============================================================##
|
|
113
|
-
normalize_last_line(file_path)
|
|
96
|
+
prettier_parser = nil
|
|
97
|
+
prettier_parser = "--parser markdown" if file_path.end_with?(".md.erb")
|
|
98
|
+
cmds = "bun prettier --write #{file_path} #{prettier_parser} --config #{gem_root}/linters/prettier.yml"
|
|
114
99
|
rescue StandardError => e
|
|
115
100
|
puts(e.message)
|
|
116
101
|
puts(e.backtrace)
|
|
@@ -124,12 +109,14 @@ module ImmosquareCleaner
|
|
|
124
109
|
File.expand_path("..", __dir__)
|
|
125
110
|
end
|
|
126
111
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
def
|
|
132
|
-
|
|
112
|
+
##===========================================================================##
|
|
113
|
+
## We change the current directory to the gem root to ensure the gem's paths
|
|
114
|
+
## are used when executing the commands
|
|
115
|
+
##===========================================================================##
|
|
116
|
+
def launch_cmds(cmds)
|
|
117
|
+
Dir.chdir(gem_root) do
|
|
118
|
+
cmds.each {|cmd| system(cmd) }
|
|
119
|
+
end
|
|
133
120
|
end
|
|
134
121
|
|
|
135
122
|
##===========================================================================##
|
data/linters/eslintrc.json
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"env":
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"no-
|
|
19
|
-
"
|
|
20
|
-
"no-
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"no-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"no-lonely-if": 0,
|
|
30
|
-
"no-nested-ternary": 0,
|
|
31
|
-
"no-param-reassign": ["error", { "props": false }],
|
|
32
|
-
"comma-dangle": ["error", "never"],
|
|
33
|
-
"jsonc/auto": 2,
|
|
34
|
-
"jsonc/indent": ["error", 2, {}]
|
|
2
|
+
"env" :{"browser":true,"es2021":true},
|
|
3
|
+
"ignorePatterns":["package.json"],
|
|
4
|
+
"extends" :["airbnb-base","plugin:jsonc/recommended-with-jsonc"],
|
|
5
|
+
"overrides" :[],
|
|
6
|
+
"parserOptions" :{"ecmaVersion":"latest","sourceType":"module"},
|
|
7
|
+
"rules" :{
|
|
8
|
+
"quotes" :[2,"double"],
|
|
9
|
+
"semi" :[2,"never"],
|
|
10
|
+
"camelcase" :0,
|
|
11
|
+
"no-console" :0,
|
|
12
|
+
"no-restricted-globals" :0,
|
|
13
|
+
"no-multi-spaces" :0,
|
|
14
|
+
"no-undef" :0,
|
|
15
|
+
"radix" :0,
|
|
16
|
+
"key-spacing" :[2,{"align":"value"}],
|
|
17
|
+
"max-len" :0,
|
|
18
|
+
"no-unused-expressions" :0,
|
|
19
|
+
"padded-blocks" :0,
|
|
20
|
+
"no-multiple-empty-lines":0,
|
|
21
|
+
"default-case" :0,
|
|
22
|
+
"no-alert" :0,
|
|
23
|
+
"no-lonely-if" :0,
|
|
24
|
+
"no-nested-ternary" :0,
|
|
25
|
+
"no-param-reassign" :["error",{"props":false}],
|
|
26
|
+
"comma-dangle" :["error","never"],
|
|
27
|
+
"jsonc/auto" :2,
|
|
28
|
+
"jsonc/indent" :["error",2,{}]
|
|
35
29
|
}
|
|
36
30
|
}
|
data/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name"
|
|
3
|
-
"private"
|
|
4
|
-
"dependencies"
|
|
5
|
-
|
|
2
|
+
"name" :"immosquare-cleaner",
|
|
3
|
+
"private" :true,
|
|
4
|
+
"dependencies":{
|
|
5
|
+
"eslint" :"^8.50.0",
|
|
6
|
+
"prettier" :"^3.0.3",
|
|
6
7
|
"eslint-config-airbnb-base":"^15.0.0",
|
|
7
8
|
"eslint-plugin-import" :"^2.28.1",
|
|
8
9
|
"eslint-plugin-jsonc" :"^2.9.0"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immosquare-cleaner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- IMMO SQUARE
|
|
@@ -77,10 +77,10 @@ extensions: []
|
|
|
77
77
|
extra_rdoc_files: []
|
|
78
78
|
files:
|
|
79
79
|
- bin/immosquare-cleaner
|
|
80
|
-
- lib/
|
|
81
|
-
- lib/
|
|
82
|
-
- lib/
|
|
83
|
-
- lib/
|
|
80
|
+
- lib/immosquare-cleaner.rb
|
|
81
|
+
- lib/immosquare-cleaner/configuration.rb
|
|
82
|
+
- lib/immosquare-cleaner/railtie.rb
|
|
83
|
+
- lib/immosquare-cleaner/version.rb
|
|
84
84
|
- lib/tasks/immosquare_cleaner.rake
|
|
85
85
|
- linters/erb-lint.yml
|
|
86
86
|
- linters/eslintrc.json
|
|
File without changes
|
|
File without changes
|