Class: NeetoCompliance::PackageDependenciesVersionVerifier

Inherits:
Base
  • Object
show all
Defined in:
lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb

Instance Method Summary collapse

Methods inherited from Base

#app_is_exception?, #app_name, #apps_exception_list, #audit, #auto_correct!, #autofix_suggestion, #error_message, #print_description, #process, #verifier_name

Instance Method Details

#autofix_commandObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb', line 19

def autofix_command
  command = ""
  command += "yarn remove #{@incorrect_dependencies[:misplacedDependencies]
    .join(" ")}\n" unless @incorrect_dependencies[:misplacedDependencies].empty?
  command += "yarn add #{@incorrect_dependencies[:dependencies]
    .join(" ")}\n" unless @incorrect_dependencies[:dependencies].empty?
  command += "yarn add -D #{@incorrect_dependencies[:devDependencies]
    .join(" ")}\n" unless @incorrect_dependencies[:devDependencies].empty?
  command
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/neeto_compliance/verifiers/package_dependencies_version_verifier.rb', line 7

def valid?
  @common_package_json = load_json_file(common_packages_latest_file)
  @project_package_json = load_json_file("package.json")

  @incorrect_dependencies = {
    dependencies: find_incorrect_dependencies(:dependencies),
    devDependencies: find_incorrect_dependencies(:devDependencies)
  }
  @incorrect_dependencies[:misplacedDependencies] = find_misplaced_dependencies
  @incorrect_dependencies.keys.all? { |key| @incorrect_dependencies[key].empty? }
end