Module: Packs

Extended by:
T::Sig
Defined in:
lib/packs/user_event_logger.rb,
lib/packs.rb,
lib/packs/cli.rb,
lib/packs/logging.rb,
lib/packs/private.rb,
lib/packs/configuration.rb,
lib/packs/rubocop_post_processor.rb,
lib/packs/private/interactive_cli.rb,
lib/packs/default_user_event_logger.rb,
lib/packs/private/file_move_operation.rb,
lib/packs/per_file_processor_interface.rb,
lib/packs/code_ownership_post_processor.rb,
lib/packs/update_references_post_processor.rb,
lib/packs/private/pack_relationship_analyzer.rb,
lib/packs/private/interactive_cli/file_selector.rb,
lib/packs/private/interactive_cli/pack_selector.rb,
lib/packs/private/interactive_cli/team_selector.rb,
lib/packs/private/interactive_cli/use_cases/move.rb,
lib/packs/private/interactive_cli/use_cases/check.rb,
lib/packs/private/interactive_cli/use_cases/query.rb,
lib/packs/private/interactive_cli/use_cases/create.rb,
lib/packs/private/interactive_cli/use_cases/rename.rb,
lib/packs/private/interactive_cli/use_cases/update.rb,
lib/packs/private/interactive_cli/use_cases/get_info.rb,
lib/packs/private/interactive_cli/use_cases/validate.rb,
lib/packs/private/interactive_cli/use_cases/interface.rb,
lib/packs/private/interactive_cli/use_cases/move_pack.rb,
lib/packs/private/interactive_cli/use_cases/make_public.rb,
lib/packs/private/interactive_cli/pack_directory_selector.rb,
lib/packs/private/interactive_cli/use_cases/add_dependency.rb,
lib/packs/private/packwerk_wrapper/offenses_aggregator_formatter.rb,
lib/packs/private/interactive_cli/use_cases/lint_package_yml_files.rb,
lib/packs/private/interactive_cli/use_cases/lint_package_todo_yml_files.rb

Overview

typed: strict

Defined Under Namespace

Modules: Logging, PerFileProcessorInterface, UserEventLogger Classes: CLI, CodeOwnershipPostProcessor, Configuration, DefaultUserEventLogger, RubocopPostProcessor, UpdateReferencesPostProcessor

Class Method Summary collapse

Class Method Details

.add_dependency!(pack_name:, dependency_name:) ⇒ Object



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/packs.rb', line 146

def self.add_dependency!(
  pack_name:,
  dependency_name:
)
  Logging.section('Adding a dependency') do
    intro = Packs.config.user_event_logger.before_add_dependency(pack_name)
    Logging.print_bold_green(intro)
  end

  Private.add_dependency!(
    pack_name: pack_name,
    dependency_name: dependency_name
  )

  Logging.section('Next steps') do
    next_steps = Packs.config.user_event_logger.after_add_dependency(pack_name)
    Logging.print_bold_green(next_steps)
  end
end

.bust_cache!Object



261
262
263
264
# File 'lib/packs.rb', line 261

def self.bust_cache!
  Private.bust_cache!
  Specification.bust_cache!
end

.check(files) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/packs.rb', line 52

def self.check(files)
  if Packs.config.use_pks
    Private.system_with("bin/pks check #{files.join(' ')}")
  else
    Private.system_with("bin/packwerk check #{files.join(' ')}")
  end
end

.configObject



54
55
56
57
58
# File 'lib/packs/configuration.rb', line 54

def config
  Private.load_client_configuration
  @config = T.let(@config, T.nilable(Configuration))
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



61
62
63
# File 'lib/packs/configuration.rb', line 61

def configure(&blk)
  yield(config)
end

.create_pack!(pack_name:, enforce_privacy: true, enforce_layers: true, enforce_dependencies: nil, team: nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/packs.rb', line 69

def self.create_pack!(
  pack_name:,
  enforce_privacy: true,
  enforce_layers: true,
  enforce_dependencies: nil,
  team: nil
)
  Private.create_pack!(
    pack_name: pack_name,
    enforce_privacy: enforce_privacy,
    enforce_dependencies: enforce_dependencies,
    enforce_layers: enforce_layers,
    team: team
  )
end

.lint_package_todo_yml_files!Object



267
268
269
# File 'lib/packs.rb', line 267

def self.lint_package_todo_yml_files!
  Private.lint_package_todo_yml_files!
end

.lint_package_yml_files!(packs) ⇒ Object



272
273
274
# File 'lib/packs.rb', line 272

def self.lint_package_yml_files!(packs)
  Private.lint_package_yml_files!(packs)
end

.list_top_violations(type:, pack_name:, limit:) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
# File 'lib/packs.rb', line 233

def self.list_top_violations(
  type:,
  pack_name:,
  limit:
)
  Private::PackRelationshipAnalyzer.list_top_violations(
    type,
    pack_name,
    limit
  )
end

.make_public!(paths_relative_to_root: [], per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/packs.rb', line 120

def self.make_public!(
  paths_relative_to_root: [],
  per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]
)
  Logging.section('Making files public') do
    intro = Packs.config.user_event_logger.before_make_public
    Logging.print_bold_green(intro)
  end

  Private.make_public!(
    paths_relative_to_root: paths_relative_to_root,
    per_file_processors: per_file_processors
  )

  Logging.section('Next steps') do
    next_steps = Packs.config.user_event_logger.after_make_public
    Logging.print_bold_green(next_steps)
  end
end

.move_to_folder!(pack_name:, destination:, per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/packs.rb', line 203

def self.move_to_folder!(
  pack_name:,
  destination:,
  per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]
)
  Logging.section('👋 Hi!') do
    intro = Packs.config.user_event_logger.before_move_to_folder(pack_name)
    Logging.print_bold_green(intro)
  end

  Private.move_to_folder!(
    pack_name: pack_name,
    destination: destination,
    per_file_processors: per_file_processors
  )

  Logging.section('Next steps') do
    next_steps = Packs.config.user_event_logger.after_move_to_folder(pack_name)

    Logging.print_bold_green(next_steps)
  end
end

.move_to_pack!(pack_name:, paths_relative_to_root: [], per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]) ⇒ Object



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/packs.rb', line 92

def self.move_to_pack!(
  pack_name:,
  paths_relative_to_root: [],
  per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]
)
  Logging.section('👋 Hi!') do
    intro = Packs.config.user_event_logger.before_move_to_pack(pack_name)
    Logging.print_bold_green(intro)
  end

  Private.move_to_pack!(
    pack_name: pack_name,
    paths_relative_to_root: paths_relative_to_root,
    per_file_processors: per_file_processors
  )

  Logging.section('Next steps') do
    next_steps = Packs.config.user_event_logger.after_move_to_pack(pack_name)
    Logging.print_bold_green(next_steps)
  end
end

.move_to_parent!(pack_name:, parent_name:, per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/packs.rb', line 173

def self.move_to_parent!(
  pack_name:,
  parent_name:,
  per_file_processors: [Packs::RubocopPostProcessor.new, Packs::CodeOwnershipPostProcessor.new]
)
  Logging.section('👋 Hi!') do
    intro = Packs.config.user_event_logger.before_move_to_parent(pack_name)
    Logging.print_bold_green(intro)
  end

  Private.move_to_parent!(
    pack_name: pack_name,
    parent_name: parent_name,
    per_file_processors: per_file_processors
  )

  Logging.section('Next steps') do
    next_steps = Packs.config.user_event_logger.after_move_to_parent(pack_name)

    Logging.print_bold_green(next_steps)
  end
end

.replace_in_file(file:, find:, replace_with:) ⇒ Object



252
253
254
255
256
257
258
# File 'lib/packs.rb', line 252

def self.replace_in_file(file:, find:, replace_with:)
  Private.replace_in_file(
    file: file,
    find: find,
    replace_with: replace_with
  )
end

.start_interactive_mode!Object



29
30
31
# File 'lib/packs.rb', line 29

def self.start_interactive_mode!
  Private::InteractiveCli.start!
end

.updateObject



34
35
36
37
38
39
40
# File 'lib/packs.rb', line 34

def self.update
  if Packs.config.use_pks
    Private.system_with('bin/pks update')
  else
    Private.system_with('bin/packwerk update-todo')
  end
end

.validateObject



43
44
45
46
47
48
49
# File 'lib/packs.rb', line 43

def self.validate
  if Packs.config.use_pks
    Private.system_with('bin/pks validate')
  else
    Private.system_with('bin/packwerk validate')
  end
end