Class: Neetob::CLI::Github::UnusedAssetsAudit
- Inherits:
-
MakePr::Base
- Object
- Base
- Base
- MakePr::Base
- Neetob::CLI::Github::UnusedAssetsAudit
- Defined in:
- lib/neetob/cli/github/unused_assets_audit.rb
Constant Summary collapse
- DESCRIPTION =
"Fix security vulnerabilities reported by unused assets audit"
Constants inherited from MakePr::Base
MakePr::Base::BRANCH_NAME, MakePr::Base::PR_TITLE, MakePr::Base::REPO_SPECIFIC_COMMANDS_BEFORE_BUNDLE_INSTALL
Constants inherited from Base
Instance Attribute Summary collapse
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Attributes inherited from MakePr::Base
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(repos, sandbox = false) ⇒ UnusedAssetsAudit
constructor
A new instance of UnusedAssetsAudit.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(repos, sandbox = false) ⇒ UnusedAssetsAudit
11 12 13 14 15 |
# File 'lib/neetob/cli/github/unused_assets_audit.rb', line 11 def initialize(repos, sandbox = false) super() @repos = repos @sandbox = sandbox end |
Instance Attribute Details
#repos ⇒ Object
Returns the value of attribute repos.
9 10 11 |
# File 'lib/neetob/cli/github/unused_assets_audit.rb', line 9 def repos @repos end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
9 10 11 |
# File 'lib/neetob/cli/github/unused_assets_audit.rb', line 9 def sandbox @sandbox end |
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/neetob/cli/github/unused_assets_audit.rb', line 17 def run matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox) report = nil matching_repos.each do |repo| begin ui.info("\nWorking on repo #{repo}", print_to_audit_log: false) clone_repo_in_tmp_dir(repo) image_dir = "/tmp/neetob/#{repo_name_without_org_suffix(repo)}/app/assets/images" src_dir = "/tmp/neetob/#{repo_name_without_org_suffix(repo)}/app/javascript/src" views_dir = "/tmp/neetob/#{repo_name_without_org_suffix(repo)}/app/views" report = find_unused_images(image_dir, src_dir, views_dir) ui.success("Successfully executed unused assets audit for #{repo}", print_to_audit_log: false) rescue StandardError => e ExceptionHandler.new(e).process end end `rm -rf /tmp/neetob` unless Thread.current[:audit_mode] if Thread.current[:audit_mode] report end end |