Module: UsePackwerk
- Extended by:
- T::Sig
- Defined in:
- lib/use_packwerk/user_event_logger.rb,
lib/use_packwerk.rb,
lib/use_packwerk/cli.rb,
lib/use_packwerk/logging.rb,
lib/use_packwerk/private.rb,
lib/use_packwerk/configuration.rb,
lib/use_packwerk/spring_command.rb,
lib/use_packwerk/rubocop_post_processor.rb,
lib/use_packwerk/private/interactive_cli.rb,
lib/use_packwerk/private/packwerk_wrapper.rb,
lib/use_packwerk/default_user_event_logger.rb,
lib/use_packwerk/private/file_move_operation.rb,
lib/use_packwerk/per_file_processor_interface.rb,
lib/use_packwerk/code_ownership_post_processor.rb,
lib/use_packwerk/private/pack_relationship_analyzer.rb,
lib/use_packwerk/private/interactive_cli/pack_selector.rb,
lib/use_packwerk/private/interactive_cli/team_selector.rb,
lib/use_packwerk/private/interactive_cli/use_cases/move.rb,
lib/use_packwerk/private/interactive_cli/use_cases/nest.rb,
lib/use_packwerk/private/interactive_cli/use_cases/check.rb,
lib/use_packwerk/private/interactive_cli/use_cases/query.rb,
lib/use_packwerk/private/interactive_cli/use_cases/create.rb,
lib/use_packwerk/private/interactive_cli/use_cases/rename.rb,
lib/use_packwerk/private/interactive_cli/use_cases/get_info.rb,
lib/use_packwerk/private/interactive_cli/use_cases/validate.rb,
lib/use_packwerk/private/interactive_cli/use_cases/interface.rb,
lib/use_packwerk/private/interactive_cli/use_cases/visualize.rb,
lib/use_packwerk/private/interactive_cli/use_cases/make_public.rb,
lib/use_packwerk/private/interactive_cli/use_cases/add_dependency.rb,
lib/use_packwerk/private/interactive_cli/use_cases/lint_package_yml.rb,
lib/use_packwerk/private/interactive_cli/use_cases/update_deprecations.rb,
lib/use_packwerk/private/packwerk_wrapper/offenses_aggregator_formatter.rb,
lib/use_packwerk/private/interactive_cli/use_cases/regenerate_rubocop_todo.rb
Overview
Defined Under Namespace
Modules: Logging, PerFileProcessorInterface, UserEventLogger
Classes: CLI, CodeOwnershipPostProcessor, Configuration, DefaultUserEventLogger, RubocopPostProcessor, SpringCommand
Constant Summary
collapse
- PERMITTED_PACK_LOCATIONS =
T.let(%w[
gems
components
packs
], T::Array[String])
Class Method Summary
collapse
-
.add_dependency!(pack_name:, dependency_name:) ⇒ Object
-
.bust_cache! ⇒ Object
-
.config ⇒ Object
-
.configure {|config| ... } ⇒ Object
-
.create_pack!(pack_name:, enforce_privacy: true, enforce_dependencies: nil, team: nil) ⇒ Object
-
.execute(argv, formatter = nil) ⇒ Object
-
.get_offenses_for_files(files) ⇒ Object
-
.get_offenses_for_files_by_package(files) ⇒ Object
-
.lint_deprecated_references_yml_files! ⇒ Object
-
.lint_package_yml_files!(packs) ⇒ Object
-
.list_top_dependency_violations(pack_name:, limit:) ⇒ Object
-
.list_top_privacy_violations(pack_name:, limit:) ⇒ Object
-
.make_public!(paths_relative_to_root: [], per_file_processors: []) ⇒ Object
-
.move_to_pack!(pack_name:, paths_relative_to_root: [], per_file_processors: []) ⇒ Object
-
.move_to_parent!(pack_name:, parent_name:, per_file_processors: []) ⇒ Object
-
.replace_in_file(file:, find:, replace_with:) ⇒ Object
-
.start_interactive_mode! ⇒ Object
Class Method Details
.add_dependency!(pack_name:, dependency_name:) ⇒ Object
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/use_packwerk.rb', line 121
def self.add_dependency!(
pack_name:,
dependency_name:
)
Logging.section('Adding a dependency') do
intro = UsePackwerk.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 = UsePackwerk.config.user_event_logger.after_add_dependency(pack_name)
Logging.print_bold_green(next_steps)
end
end
|
.bust_cache! ⇒ Object
219
220
221
|
# File 'lib/use_packwerk.rb', line 219
def self.bust_cache!
Private.bust_cache!
end
|
.config ⇒ Object
50
51
52
53
54
|
# File 'lib/use_packwerk/configuration.rb', line 50
def config
Private.load_client_configuration
@config = T.let(@config, T.nilable(Configuration))
@config ||= Configuration.new
end
|
57
58
59
|
# File 'lib/use_packwerk/configuration.rb', line 57
def configure(&blk)
yield(config)
end
|
.create_pack!(pack_name:, enforce_privacy: true, enforce_dependencies: nil, team: nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/use_packwerk.rb', line 46
def self.create_pack!(
pack_name:,
enforce_privacy: true,
enforce_dependencies: nil,
team: nil
)
Private.create_pack!(
pack_name: pack_name,
enforce_privacy: enforce_privacy,
enforce_dependencies: enforce_dependencies,
team: team
)
end
|
.execute(argv, formatter = nil) ⇒ Object
.get_offenses_for_files(files) ⇒ Object
.get_offenses_for_files_by_package(files) ⇒ Object
.lint_deprecated_references_yml_files! ⇒ Object
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/use_packwerk.rb', line 250
def self.lint_deprecated_references_yml_files!
contents_before = Private.get_deprecated_references_contents
UsePackwerk.execute(['update-deprecations'])
contents_after = Private.get_deprecated_references_contents
diff = Private.diff_deprecated_references_yml(contents_before, contents_after)
if diff == ''
exit 0
else
output = <<~OUTPUT
All `deprecated_references.yml` files must be up-to-date and that no diff is generated when running `bin/packwerk update-deprecations`.
This helps ensure a high quality signal in other engineers' PRs when inspecting new violations by ensuring there are no unrelated changes.
There are three main reasons there may be a diff:
1) Most likely, you may have stale violations, meaning there are old violations that no longer apply.
2) You may have some sort of auto-formatter set up somewhere (e.g. something that reformats YML files) that is, for example, changing double quotes to single quotes. Ensure this is turned off for these auto-generated files.
3) You may have edited these files manually. It's recommended to use the `bin/packwerk update-deprecations` command to make changes to `deprecated_references.yml` files.
In all cases, you can run `bin/packwerk update-deprecations` to update these files.
Here is the diff generated after running `update-deprecations`:
```
#{diff}
```
OUTPUT
puts output
UsePackwerk.config.on_deprecated_references_lint_failure.call(output)
exit 1
end
end
|
.lint_package_yml_files!(packs) ⇒ Object
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/use_packwerk.rb', line 286
def self.lint_package_yml_files!(packs)
packs.each do |p|
new_package = ParsePackwerk::Package.new(
name: p.name,
enforce_privacy: p.enforce_privacy,
enforce_dependencies: p.enforce_dependencies,
dependencies: p.dependencies.uniq.sort,
metadata: p.metadata
)
ParsePackwerk.write_package_yml!(new_package)
end
end
|
.list_top_dependency_violations(pack_name:, limit:) ⇒ Object
.list_top_privacy_violations(pack_name:, limit:) ⇒ Object
.make_public!(paths_relative_to_root: [], per_file_processors: []) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/use_packwerk.rb', line 95
def self.make_public!(
paths_relative_to_root: [],
per_file_processors: []
)
Logging.section('Making files public') do
intro = UsePackwerk.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 = UsePackwerk.config.user_event_logger.after_make_public
Logging.print_bold_green(next_steps)
end
end
|
.move_to_pack!(pack_name:, paths_relative_to_root: [], per_file_processors: []) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/use_packwerk.rb', line 67
def self.move_to_pack!(
pack_name:,
paths_relative_to_root: [],
per_file_processors: []
)
Logging.section('👋 Hi!') do
intro = UsePackwerk.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 = UsePackwerk.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: []) ⇒ Object
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/use_packwerk.rb', line 148
def self.move_to_parent!(
pack_name:,
parent_name:,
per_file_processors: []
)
Logging.section('👋 Hi!') do
intro = UsePackwerk.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 = UsePackwerk.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
210
211
212
213
214
215
216
|
# File 'lib/use_packwerk.rb', line 210
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
34
35
36
|
# File 'lib/use_packwerk.rb', line 34
def self.start_interactive_mode!
Private::InteractiveCli.start!
end
|