Class: Dependabot::NpmAndYarn::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/npm_and_yarn/file_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/npmrc_builder.rb,
lib/dependabot/npm_and_yarn/file_updater/npm_lockfile_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/package_json_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/package_json_preparer.rb,
lib/dependabot/npm_and_yarn/file_updater/pnpm_lockfile_updater.rb,
lib/dependabot/npm_and_yarn/file_updater/yarn_lockfile_updater.rb

Defined Under Namespace

Classes: NoChangeError, NpmLockfileUpdater, NpmrcBuilder, PackageJsonPreparer, PackageJsonUpdater, PnpmLockfileUpdater, YarnLockfileUpdater

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/npm_and_yarn/file_updater.rb', line 34

def self.updated_files_regex
  [
    %r{^(?:.*/)?package\.json$},
    %r{^(?:.*/)?package-lock\.json$},
    %r{^(?:.*/)?npm-shrinkwrap\.json$},
    %r{^(?:.*/)?yarn\.lock$},
    %r{^(?:.*/)?pnpm-lock\.yaml$},
    %r{^(?:.*/)?\.yarn/.*}, # Matches any file within the .yarn/ directory
    %r{^(?:.*/)?\.pnp\.(?:js|cjs)$} # Matches .pnp.js or .pnp.cjs files
  ]
end

Instance Method Details

#updated_dependency_filesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/dependabot/npm_and_yarn/file_updater.rb', line 47

def updated_dependency_files
  updated_files = T.let([], T::Array[DependencyFile])

  updated_files += updated_manifest_files
  updated_files += updated_lockfiles

  if updated_files.none?
    raise NoChangeError.new(
      message: "No files were updated!",
      error_context: error_context(updated_files: updated_files)
    )
  end

  sorted_updated_files = updated_files.sort_by(&:name)
  if sorted_updated_files == filtered_dependency_files.sort_by(&:name)
    raise NoChangeError.new(
      message: "Updated files are unchanged!",
      error_context: error_context(updated_files: updated_files)
    )
  end

  vendor_updated_files(updated_files)
end