neetob-ud 0.1.0
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/.editorconfig +10 -0
- data/.env +1 -0
- data/.rubocop.yml +596 -0
- data/.ruby-version +1 -0
- data/.semaphore/semaphore.yml +30 -0
- data/CHANGELOG.md +96 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +250 -0
- data/LICENSE.txt +21 -0
- data/README.md +412 -0
- data/Rakefile +16 -0
- data/config/secrets.yml +0 -0
- data/data/branch-protection-rules.json +25 -0
- data/data/config-vars-audit.json +18 -0
- data/data/config-vars-list.json +1 -0
- data/data/github-labels.json +197 -0
- data/env.sample +1 -0
- data/exe/neetob +25 -0
- data/install.sh +21 -0
- data/lib/neetob/cli/base.rb +96 -0
- data/lib/neetob/cli/fetchorupdate_repos/execute.rb +55 -0
- data/lib/neetob/cli/github/auth.rb +134 -0
- data/lib/neetob/cli/github/base.rb +42 -0
- data/lib/neetob/cli/github/commands.rb +54 -0
- data/lib/neetob/cli/github/issues/commands.rb +51 -0
- data/lib/neetob/cli/github/issues/create.rb +42 -0
- data/lib/neetob/cli/github/issues/list.rb +94 -0
- data/lib/neetob/cli/github/labels/commands.rb +65 -0
- data/lib/neetob/cli/github/labels/delete.rb +46 -0
- data/lib/neetob/cli/github/labels/delete_all.rb +50 -0
- data/lib/neetob/cli/github/labels/list.rb +38 -0
- data/lib/neetob/cli/github/labels/show.rb +39 -0
- data/lib/neetob/cli/github/labels/update.rb +42 -0
- data/lib/neetob/cli/github/labels/upsert.rb +64 -0
- data/lib/neetob/cli/github/login.rb +16 -0
- data/lib/neetob/cli/github/make_pr/base.rb +72 -0
- data/lib/neetob/cli/github/make_pr/commands.rb +37 -0
- data/lib/neetob/cli/github/make_pr/compliance_fix.rb +49 -0
- data/lib/neetob/cli/github/make_pr/script.rb +55 -0
- data/lib/neetob/cli/github/protect_branch.rb +48 -0
- data/lib/neetob/cli/github/search.rb +38 -0
- data/lib/neetob/cli/heroku/access/add.rb +38 -0
- data/lib/neetob/cli/heroku/access/commands.rb +41 -0
- data/lib/neetob/cli/heroku/access/list.rb +36 -0
- data/lib/neetob/cli/heroku/access/remove.rb +38 -0
- data/lib/neetob/cli/heroku/commands.rb +28 -0
- data/lib/neetob/cli/heroku/config_vars/audit.rb +64 -0
- data/lib/neetob/cli/heroku/config_vars/base.rb +19 -0
- data/lib/neetob/cli/heroku/config_vars/commands.rb +49 -0
- data/lib/neetob/cli/heroku/config_vars/list.rb +56 -0
- data/lib/neetob/cli/heroku/config_vars/remove.rb +39 -0
- data/lib/neetob/cli/heroku/config_vars/upsert.rb +80 -0
- data/lib/neetob/cli/heroku/execute.rb +37 -0
- data/lib/neetob/cli/local/commands.rb +19 -0
- data/lib/neetob/cli/local/ls.rb +29 -0
- data/lib/neetob/cli/sub_command_base.rb +17 -0
- data/lib/neetob/cli/ui.rb +41 -0
- data/lib/neetob/cli/users/audit.rb +121 -0
- data/lib/neetob/cli/users/commands.rb +30 -0
- data/lib/neetob/cli/users/commits.rb +171 -0
- data/lib/neetob/cli.rb +42 -0
- data/lib/neetob/exception_handler.rb +58 -0
- data/lib/neetob/utils.rb +16 -0
- data/lib/neetob/version.rb +5 -0
- data/lib/neetob.rb +10 -0
- data/neetob.gemspec +50 -0
- data/overcommit.yml +43 -0
- data/scripts/delete_unused_assets.rb +67 -0
- metadata +187 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require_relative "audit"
|
5
|
+
require_relative "commits"
|
6
|
+
|
7
|
+
module Neetob
|
8
|
+
class CLI
|
9
|
+
module Users
|
10
|
+
class Commands < Thor
|
11
|
+
desc "audit", "Audit the users of all the neeto apps"
|
12
|
+
def audit
|
13
|
+
Audit.new(options[:sandbox]).run
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "commits", "List the commits of a user across the neeto apps"
|
17
|
+
option :apps, type: :array, aliases: "-a", default: ["*"], desc: "Github app names. Can be matched using the '*' wildcard. Example: \"neeto*\" \"neeto-cal-web\""
|
18
|
+
option :author, type: :string, required: true, desc: "Github username of the person whose commits you want to list"
|
19
|
+
option :duration, type: :string, required: true, desc: "Duration for which you want to list the commits. Example: \"6.months\" \"10.days\""
|
20
|
+
option :all_neeto_repos, type: :boolean, aliases: "--all",
|
21
|
+
desc: "Use this flag for working with all neeto repos", default: false
|
22
|
+
def commits
|
23
|
+
Commits.new(
|
24
|
+
options[:author], options[:duration], options[:apps],
|
25
|
+
options[:sandbox], options[:all_neeto_repos]).run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "chronic"
|
4
|
+
require "active_support/core_ext/numeric/time"
|
5
|
+
|
6
|
+
require_relative "../github/base"
|
7
|
+
|
8
|
+
module Neetob
|
9
|
+
class CLI
|
10
|
+
module Users
|
11
|
+
class Commits < Github::Base
|
12
|
+
include ActionView::Helpers::DateHelper
|
13
|
+
|
14
|
+
attr_accessor :sandbox, :apps, :author, :duration, :all_neeto_repos
|
15
|
+
|
16
|
+
def initialize(author, duration, apps = ["*"], sandbox = false, all_neeto_repos = false)
|
17
|
+
super()
|
18
|
+
@sandbox = sandbox
|
19
|
+
@apps = apps
|
20
|
+
@author = author
|
21
|
+
@duration = duration
|
22
|
+
@all_neeto_repos = all_neeto_repos
|
23
|
+
end
|
24
|
+
|
25
|
+
def run
|
26
|
+
table_rows = build_commit_rows
|
27
|
+
html_content = build_html_content(table_rows)
|
28
|
+
create_html_file(html_content)
|
29
|
+
open_html_file_in_default_system_application
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def build_commit_rows
|
35
|
+
commits = find_all_matching_apps(apps, :github, sandbox, true, all_neeto_repos).map do |app|
|
36
|
+
commits = commits_within_range(app)
|
37
|
+
if commits&.empty?
|
38
|
+
ui.info("No commits found in \"#{app}\" for the given author and duration.")
|
39
|
+
next
|
40
|
+
end
|
41
|
+
ui.success("Commits found in \"#{app}\".\n")
|
42
|
+
commits
|
43
|
+
end
|
44
|
+
sorted_commits = commits.compact.flatten.sort_by { |obj| obj.dig(:commit, :author, :date) }.reverse
|
45
|
+
build_table_rows(sorted_commits)
|
46
|
+
end
|
47
|
+
|
48
|
+
def commits_within_range(app)
|
49
|
+
fetch_commits(app, 1)
|
50
|
+
end
|
51
|
+
|
52
|
+
def build_table_rows(commits)
|
53
|
+
commits.map do |commit|
|
54
|
+
app = commit[:html_url].split("/")[4]
|
55
|
+
commit_id = commit[:sha]
|
56
|
+
email = commit.dig(:commit, :author, :email)
|
57
|
+
time = distance_of_time_in_words(commit.dig(:commit, :author, :date), Time.current) + " ago"
|
58
|
+
title = commit.dig(:commit, :message).split("\n")[0]
|
59
|
+
html_table_row(app, commit_id, email, time, title)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def app_name_without_org_suffix(app)
|
64
|
+
app.split("/")[1]
|
65
|
+
end
|
66
|
+
|
67
|
+
def html_table_row(app, commit_id, email, time, title)
|
68
|
+
starting_7_characters_of_commit = commit_id[0..6]
|
69
|
+
"<tr>
|
70
|
+
<td class='commit'><a href='https://github.com/bigbinary/#{app}/commit/#{commit_id}'
|
71
|
+
target='_blank'>#{starting_7_characters_of_commit}</a></td>
|
72
|
+
<td class='project'>#{app}</td>
|
73
|
+
<td class='time'>#{time}</td>
|
74
|
+
<td class='title'>#{title}</td>
|
75
|
+
<td class='email'>#{email}</td>
|
76
|
+
</tr>"
|
77
|
+
end
|
78
|
+
|
79
|
+
def build_html_content(table_rows)
|
80
|
+
"<!DOCTYPE html>
|
81
|
+
<html>
|
82
|
+
<body>
|
83
|
+
<style>
|
84
|
+
body{
|
85
|
+
font-family: arial, sans-serif;
|
86
|
+
}
|
87
|
+
table {
|
88
|
+
border-collapse: collapse;
|
89
|
+
width: 100%;
|
90
|
+
}
|
91
|
+
td, th {
|
92
|
+
border: 1px solid #dddddd;
|
93
|
+
text-align: left;
|
94
|
+
padding: 8px;
|
95
|
+
}
|
96
|
+
tr:nth-child(even) {
|
97
|
+
background-color: #dddddd;
|
98
|
+
}
|
99
|
+
.project {
|
100
|
+
color: blue;
|
101
|
+
}
|
102
|
+
.commit {
|
103
|
+
color: blueviolet;
|
104
|
+
}
|
105
|
+
.email {
|
106
|
+
color: green;
|
107
|
+
width: 50px;
|
108
|
+
}
|
109
|
+
.time {
|
110
|
+
color: darkorange;
|
111
|
+
}
|
112
|
+
.title {
|
113
|
+
color: lightcoral
|
114
|
+
}
|
115
|
+
.info{
|
116
|
+
font-size: larger;
|
117
|
+
margin-bottom: 10px;
|
118
|
+
}
|
119
|
+
</style>
|
120
|
+
<div class='info'>
|
121
|
+
Github user id: <strong>#{author}</strong> <br/>
|
122
|
+
Duration: <strong>#{duration}</strong>
|
123
|
+
</div>
|
124
|
+
<table>
|
125
|
+
<tr>
|
126
|
+
<th>Commit</th>
|
127
|
+
<th>Repo</th>
|
128
|
+
<th>Created at</th>
|
129
|
+
<th>Title</th>
|
130
|
+
<th>Email</th>
|
131
|
+
</tr>
|
132
|
+
#{table_rows&.compact&.empty? ? "<tr><td>No commits found in the given duration</td></tr>" : table_rows.join}
|
133
|
+
</table>
|
134
|
+
</body>
|
135
|
+
</html>"
|
136
|
+
end
|
137
|
+
|
138
|
+
def create_html_file(html_content)
|
139
|
+
commits_file = File.new("commits.html", "w")
|
140
|
+
commits_file.puts(html_content)
|
141
|
+
commits_file.close
|
142
|
+
end
|
143
|
+
|
144
|
+
def open_html_file_in_default_system_application
|
145
|
+
`open ./commits.html`
|
146
|
+
end
|
147
|
+
|
148
|
+
def since_duration(duration)
|
149
|
+
Chronic.parse(duration.split(".").join(" ") + " ago")&.iso8601
|
150
|
+
end
|
151
|
+
|
152
|
+
def fetch_commits(app, page = 1)
|
153
|
+
begin
|
154
|
+
commits = client.commits(
|
155
|
+
app, "main",
|
156
|
+
{ author: author, since: since_duration(duration), per_page: 100, page: page })
|
157
|
+
rescue => exception
|
158
|
+
ui.error(exception.message)
|
159
|
+
commits = []
|
160
|
+
end
|
161
|
+
|
162
|
+
if commits.length == 100
|
163
|
+
commits + fetch_commits(app, page + 1)
|
164
|
+
else
|
165
|
+
commits
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
data/lib/neetob/cli.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
|
5
|
+
module Neetob
|
6
|
+
class CLI < Thor
|
7
|
+
require_relative "cli/heroku/commands"
|
8
|
+
require_relative "cli/github/commands"
|
9
|
+
require_relative "cli/users/commands"
|
10
|
+
require_relative "cli/fetchorupdate_repos/execute"
|
11
|
+
require_relative "cli/local/commands"
|
12
|
+
|
13
|
+
class_option :sandbox,
|
14
|
+
{
|
15
|
+
type: :boolean, default: false,
|
16
|
+
desc: "All the commands in sandbox mode will run only on the \"neeto-dummy\" app."
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.start(*)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "heroku", "Interact with any resource in Heroku"
|
24
|
+
subcommand "heroku", Heroku::Commands
|
25
|
+
|
26
|
+
desc "github", "Interact with any resource in Github"
|
27
|
+
subcommand "github", Github::Commands
|
28
|
+
|
29
|
+
desc "users", "Interact with the contributors of neeto apps"
|
30
|
+
subcommand "users", Users::Commands
|
31
|
+
|
32
|
+
desc "local", "Interact with the local neeto repos"
|
33
|
+
subcommand "local", Local::Commands
|
34
|
+
|
35
|
+
desc "make_repos_uptodate", "Uptodate all the neeto repos"
|
36
|
+
option :all_neeto_repos, type: :boolean, aliases: "--all", desc: "Use this flag for working with all neeto repos",
|
37
|
+
default: false
|
38
|
+
def make_repos_uptodate
|
39
|
+
FetchorupdateRepos::Execute.new(options[:sandbox], options[:all_neeto_repos]).run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "./cli/base"
|
4
|
+
|
5
|
+
module Neetob
|
6
|
+
class ExceptionHandler < CLI::Base
|
7
|
+
attr_accessor :exception
|
8
|
+
|
9
|
+
def initialize(exception)
|
10
|
+
super()
|
11
|
+
@exception = exception
|
12
|
+
end
|
13
|
+
|
14
|
+
def process
|
15
|
+
case exception
|
16
|
+
when Thor::RequiredArgumentMissingError
|
17
|
+
ui.error(
|
18
|
+
"#{exception.message}."\
|
19
|
+
" Please use the \"help\" command to check all the required options and try again."
|
20
|
+
)
|
21
|
+
when Octokit::NotFound
|
22
|
+
ui.error(
|
23
|
+
"#{exception.message}."\
|
24
|
+
" Please check the repositry name, repositry access, API endpoint and try again."
|
25
|
+
)
|
26
|
+
when Octokit::UnprocessableEntity
|
27
|
+
ui.error(
|
28
|
+
"Failed to complete the given request."\
|
29
|
+
" Make sure that the given entity is correct and processable")
|
30
|
+
when Octokit::Unauthorized
|
31
|
+
ui.error(
|
32
|
+
"You are unauthorized to make API calls,"\
|
33
|
+
" because the access token is either revoked or invalid or not set."\
|
34
|
+
" Use \"neetob github login\" command to update or set the token.")
|
35
|
+
when Octokit::Forbidden
|
36
|
+
ui.error(
|
37
|
+
"You don't have enough permissions to access 'bigbinary' organization."\
|
38
|
+
" Please grant access to this org while authorizing via the browser.")
|
39
|
+
when Errno::ENOENT
|
40
|
+
ui.error(
|
41
|
+
"#{exception.message}."\
|
42
|
+
" Please check the given path and try again"
|
43
|
+
)
|
44
|
+
when JSON::ParserError
|
45
|
+
ui.error(
|
46
|
+
"There is a problem in parsing the JSON file."\
|
47
|
+
" Please check and update the given JSON file."
|
48
|
+
)
|
49
|
+
when SystemExit
|
50
|
+
ui.error(
|
51
|
+
"Process exit with status code 1"
|
52
|
+
)
|
53
|
+
else
|
54
|
+
ui.error(exception.message)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/neetob/utils.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Utils
|
4
|
+
def symbolize_keys(hash)
|
5
|
+
hash.transform_keys(&:to_sym)
|
6
|
+
end
|
7
|
+
|
8
|
+
def camel_case_to_slug(str)
|
9
|
+
str.split("").map.with_index { |ch, idx|
|
10
|
+
is_upper?(ch) && !is_upper?(str[idx - 1]) ? "-#{ch.downcase}" : ch.downcase }.join
|
11
|
+
end
|
12
|
+
|
13
|
+
def is_upper?(str)
|
14
|
+
str == str.upcase
|
15
|
+
end
|
16
|
+
end
|
data/lib/neetob.rb
ADDED
data/neetob.gemspec
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/neetob/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "neetob-ud"
|
7
|
+
spec.version = Neetob::VERSION
|
8
|
+
spec.authors = ["Udai Gupta"]
|
9
|
+
spec.email = ["udaigupta19311@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Provides a set of helper scripts for Github and Heroku."
|
12
|
+
spec.description = "This gem gives different commands for interacting with Github and Heroku instances of existing neeto repos."
|
13
|
+
spec.homepage = "https://github.com/bigbinary/neetob"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.0.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/bigbinary/neetob"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/bigbinary/neetob/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
26
|
+
end
|
27
|
+
end
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
# Must have deps
|
33
|
+
spec.add_dependency "thor", "~> 1.2.1" # for cli
|
34
|
+
spec.add_dependency "octokit", "~> 4.0" # for github client
|
35
|
+
spec.add_dependency "terminal-table", "~> 3.0.2" # for building cli table
|
36
|
+
spec.add_dependency "launchy", "~> 2.5.0" # for opening in browser
|
37
|
+
spec.add_dependency "dotenv", "~> 2.8.1" # for loading env variables
|
38
|
+
|
39
|
+
# To add the files from submodules
|
40
|
+
`git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
|
41
|
+
Dir.chdir(submodule_path) do
|
42
|
+
required_submodule_files = `git ls-files -z`
|
43
|
+
.split("\x0")
|
44
|
+
.select { |file| file.match("lib/neeto_compliance*|data/*") }
|
45
|
+
.map { |file| "#{submodule_path}/#{file}" }
|
46
|
+
.map { |file| file.gsub "#{File.dirname(__FILE__)}/", "" }
|
47
|
+
spec.files += required_submodule_files
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/overcommit.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
|
16
|
+
PreCommit:
|
17
|
+
RuboCop:
|
18
|
+
enabled: true
|
19
|
+
command: ["bundle", "exec", "rubocop"]
|
20
|
+
on_warn: fail # Treat all warnings as failures
|
21
|
+
include: "**/*.rb"
|
22
|
+
ForbiddenBranches:
|
23
|
+
enabled: true
|
24
|
+
branch_patterns: ["master", "main"]
|
25
|
+
BundleInstall:
|
26
|
+
enabled: true
|
27
|
+
BundleCheck:
|
28
|
+
enabled: true
|
29
|
+
|
30
|
+
PrePush:
|
31
|
+
ForbiddenBranches:
|
32
|
+
enabled: true
|
33
|
+
branch_patterns: ["master", "main"]
|
34
|
+
RakeTarget:
|
35
|
+
enabled: true
|
36
|
+
command: ["bundle", "exec", "rake"]
|
37
|
+
targets: ["test"]
|
38
|
+
|
39
|
+
CommitMsg:
|
40
|
+
SingleLineSubject:
|
41
|
+
enabled: false
|
42
|
+
TextWidth:
|
43
|
+
enabled: false
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "set"
|
5
|
+
|
6
|
+
IMAGE_DIR_PATH = "app/assets/images"
|
7
|
+
SRC_DIR_PATH = "app/javascript/src"
|
8
|
+
VIEWS_DIR_PATH = "app/views"
|
9
|
+
|
10
|
+
def list_image_files(dir_path)
|
11
|
+
Dir.glob("#{dir_path}/**/*").select { |file| File.file?(file) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_unused_images(dir, images, is_views_path = false)
|
15
|
+
new_images_set = Set.new(images)
|
16
|
+
Dir.glob("#{dir}/**/*") do |file|
|
17
|
+
if File.file?(file)
|
18
|
+
File.open(file, "r") do |file_content|
|
19
|
+
new_images_set.each do |image_file_path|
|
20
|
+
destructured_image_path = split_image_path(is_views_path, image_file_path)
|
21
|
+
if image_file_imported(file_content.read, destructured_image_path, is_views_path)
|
22
|
+
new_images_set.delete(image_file_path)
|
23
|
+
end
|
24
|
+
file_content.rewind
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
new_images_set
|
30
|
+
end
|
31
|
+
|
32
|
+
def image_file_imported(file, image_path, is_views_path)
|
33
|
+
if is_views_path
|
34
|
+
regex = create_exact_string_regex_for_views_files(image_path)
|
35
|
+
else
|
36
|
+
regex = create_exact_string_regex_for_src_files(image_path)
|
37
|
+
end
|
38
|
+
file.match(regex)
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_exact_string_regex_for_src_files(str)
|
42
|
+
/import .* from \"#{str}\"\;/
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_exact_string_regex_for_views_files(str)
|
46
|
+
/\"#{str}\"/
|
47
|
+
end
|
48
|
+
|
49
|
+
def split_image_path(is_views_path, image_file_path)
|
50
|
+
if is_views_path
|
51
|
+
image_file_path.split("images/").last
|
52
|
+
else
|
53
|
+
image_file_path[image_file_path.index("images")..image_file_path.rindex(".") - 1]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def delete_unused_images(image_file_path, src_path, views_path)
|
58
|
+
images = Set.new(list_image_files(image_file_path))
|
59
|
+
images = find_unused_images(src_path, images)
|
60
|
+
images = find_unused_images(views_path, images, is_views_path = true)
|
61
|
+
images.each do |image_path|
|
62
|
+
File.delete(image_path)
|
63
|
+
puts "Deleted #{image_path}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
delete_unused_images(IMAGE_DIR_PATH, SRC_DIR_PATH, VIEWS_DIR_PATH)
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neetob-ud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Udai Gupta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.2.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: octokit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: terminal-table
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: launchy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.5.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.5.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dotenv
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.8.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.8.1
|
83
|
+
description: This gem gives different commands for interacting with Github and Heroku
|
84
|
+
instances of existing neeto repos.
|
85
|
+
email:
|
86
|
+
- udaigupta19311@gmail.com
|
87
|
+
executables:
|
88
|
+
- neetob
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".editorconfig"
|
93
|
+
- ".env"
|
94
|
+
- ".rubocop.yml"
|
95
|
+
- ".ruby-version"
|
96
|
+
- ".semaphore/semaphore.yml"
|
97
|
+
- CHANGELOG.md
|
98
|
+
- CODE_OF_CONDUCT.md
|
99
|
+
- Gemfile
|
100
|
+
- Gemfile.lock
|
101
|
+
- LICENSE.txt
|
102
|
+
- README.md
|
103
|
+
- Rakefile
|
104
|
+
- config/secrets.yml
|
105
|
+
- data/branch-protection-rules.json
|
106
|
+
- data/config-vars-audit.json
|
107
|
+
- data/config-vars-list.json
|
108
|
+
- data/github-labels.json
|
109
|
+
- env.sample
|
110
|
+
- exe/neetob
|
111
|
+
- install.sh
|
112
|
+
- lib/neetob.rb
|
113
|
+
- lib/neetob/cli.rb
|
114
|
+
- lib/neetob/cli/base.rb
|
115
|
+
- lib/neetob/cli/fetchorupdate_repos/execute.rb
|
116
|
+
- lib/neetob/cli/github/auth.rb
|
117
|
+
- lib/neetob/cli/github/base.rb
|
118
|
+
- lib/neetob/cli/github/commands.rb
|
119
|
+
- lib/neetob/cli/github/issues/commands.rb
|
120
|
+
- lib/neetob/cli/github/issues/create.rb
|
121
|
+
- lib/neetob/cli/github/issues/list.rb
|
122
|
+
- lib/neetob/cli/github/labels/commands.rb
|
123
|
+
- lib/neetob/cli/github/labels/delete.rb
|
124
|
+
- lib/neetob/cli/github/labels/delete_all.rb
|
125
|
+
- lib/neetob/cli/github/labels/list.rb
|
126
|
+
- lib/neetob/cli/github/labels/show.rb
|
127
|
+
- lib/neetob/cli/github/labels/update.rb
|
128
|
+
- lib/neetob/cli/github/labels/upsert.rb
|
129
|
+
- lib/neetob/cli/github/login.rb
|
130
|
+
- lib/neetob/cli/github/make_pr/base.rb
|
131
|
+
- lib/neetob/cli/github/make_pr/commands.rb
|
132
|
+
- lib/neetob/cli/github/make_pr/compliance_fix.rb
|
133
|
+
- lib/neetob/cli/github/make_pr/script.rb
|
134
|
+
- lib/neetob/cli/github/protect_branch.rb
|
135
|
+
- lib/neetob/cli/github/search.rb
|
136
|
+
- lib/neetob/cli/heroku/access/add.rb
|
137
|
+
- lib/neetob/cli/heroku/access/commands.rb
|
138
|
+
- lib/neetob/cli/heroku/access/list.rb
|
139
|
+
- lib/neetob/cli/heroku/access/remove.rb
|
140
|
+
- lib/neetob/cli/heroku/commands.rb
|
141
|
+
- lib/neetob/cli/heroku/config_vars/audit.rb
|
142
|
+
- lib/neetob/cli/heroku/config_vars/base.rb
|
143
|
+
- lib/neetob/cli/heroku/config_vars/commands.rb
|
144
|
+
- lib/neetob/cli/heroku/config_vars/list.rb
|
145
|
+
- lib/neetob/cli/heroku/config_vars/remove.rb
|
146
|
+
- lib/neetob/cli/heroku/config_vars/upsert.rb
|
147
|
+
- lib/neetob/cli/heroku/execute.rb
|
148
|
+
- lib/neetob/cli/local/commands.rb
|
149
|
+
- lib/neetob/cli/local/ls.rb
|
150
|
+
- lib/neetob/cli/sub_command_base.rb
|
151
|
+
- lib/neetob/cli/ui.rb
|
152
|
+
- lib/neetob/cli/users/audit.rb
|
153
|
+
- lib/neetob/cli/users/commands.rb
|
154
|
+
- lib/neetob/cli/users/commits.rb
|
155
|
+
- lib/neetob/exception_handler.rb
|
156
|
+
- lib/neetob/utils.rb
|
157
|
+
- lib/neetob/version.rb
|
158
|
+
- neetob.gemspec
|
159
|
+
- overcommit.yml
|
160
|
+
- scripts/delete_unused_assets.rb
|
161
|
+
homepage: https://github.com/bigbinary/neetob
|
162
|
+
licenses:
|
163
|
+
- MIT
|
164
|
+
metadata:
|
165
|
+
homepage_uri: https://github.com/bigbinary/neetob
|
166
|
+
source_code_uri: https://github.com/bigbinary/neetob
|
167
|
+
changelog_uri: https://github.com/bigbinary/neetob/blob/main/CHANGELOG.md
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: 3.0.0
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
requirements: []
|
183
|
+
rubygems_version: 3.2.33
|
184
|
+
signing_key:
|
185
|
+
specification_version: 4
|
186
|
+
summary: Provides a set of helper scripts for Github and Heroku.
|
187
|
+
test_files: []
|