Skip to content

Commit 74e2a05

Browse files
committed
create a directory rather than a public/TODO.md file
1 parent bd123e4 commit 74e2a05

File tree

3 files changed

+11
-34
lines changed

3 files changed

+11
-34
lines changed

lib/packs/private.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ def self.add_public_directory(package)
446446

447447
if public_directory.glob('**/**.rb').none?
448448
FileUtils.mkdir_p(public_directory)
449-
todo_md = Packs.config.user_event_logger.on_create_public_directory_todo(package.name)
450-
public_directory.join('TODO.md').write(todo_md)
449+
package_name = package.directory.basename.to_s
450+
FileUtils.mkdir_p(public_directory.join(package_name))
451451
end
452452
end
453453

lib/packs/user_event_logger.rb

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,6 @@ def after_move_to_folder(pack_name)
123123
MSG
124124
end
125125

126-
sig { params(pack_name: String).returns(String) }
127-
def on_create_public_directory_todo(pack_name)
128-
<<~MSG
129-
This directory holds your public API!
130-
131-
Any classes, constants, or modules that you want other packs to use and you intend to support should go in here.
132-
Anything that is considered private should go in other folders.
133-
134-
If another pack uses classes, constants, or modules that are not in your public folder, it will be considered a "privacy violation" by packwerk.
135-
You can prevent other packs from using private API by using packwerk.
136-
137-
Want to find how your private API is being used today?
138-
Try running: `bin/packs list_top_violations privacy #{pack_name}`
139-
140-
Want to move something into this folder?
141-
Try running: `bin/packs make_public #{pack_name}/path/to/file.rb`
142-
143-
One more thing -- feel free to delete this file and replace it with a README.md describing your package in the main package directory.
144-
145-
See #{documentation_link} for more info!
146-
MSG
147-
end
148-
149126
sig { params(pack_name: String).returns(String) }
150127
def on_create_readme(pack_name)
151128
<<~MSG

spec/packs_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,21 +256,22 @@ def write_codeownership_config
256256
end
257257

258258
context 'app has no public dir' do
259-
it 'adds a TODO.md file letting someone know what to do with it' do
259+
it 'adds a public directory' do
260260
Packs.create_pack!(pack_name: 'packs/organisms')
261-
actual_todo = Pathname.new('packs/organisms/app/public/TODO.md').read
262-
expect(actual_todo).to eq expected_todo
261+
public_directory = Pathname.new('packs/organisms/app/public')
262+
expect(public_directory.exist?).to eq true
263+
expect(public_directory.join('organisms').exist?).to eq true
263264
end
264265

265266
context 'pack not enforcing privacy' do
266-
it 'does not add a TODO.md file' do
267+
it 'does not add a public directory' do
267268
Packs.create_pack!(pack_name: 'packs/organisms', enforce_privacy: false)
268269

269270
ParsePackwerk.bust_cache!
270271
package = ParsePackwerk.find('packs/organisms')
271272
expect(package.enforce_privacy).to eq(false)
272-
todo_file = Pathname.new('packs/organisms/app/public/TODO.md')
273-
expect(todo_file.exist?).to eq false
273+
public_directory = Pathname.new('packs/organisms/app/public')
274+
expect(public_directory.exist?).to eq false
274275
end
275276
end
276277
end
@@ -789,16 +790,15 @@ def write_codeownership_config
789790
end
790791

791792
context 'app has no public dir' do
792-
it 'adds a TODO.md file letting someone know what to do with it' do
793+
it 'adds a public directory' do
793794
write_file('app/services/foo.rb')
794795
write_package_yml('packs/organisms')
795796
Packs.move_to_pack!(
796797
pack_name: 'packs/organisms',
797798
paths_relative_to_root: ['app/services/foo.rb']
798799
)
799800

800-
actual_todo = Pathname.new('packs/organisms/app/public/TODO.md').read
801-
expect(actual_todo).to eq expected_todo
801+
expect(Pathname.new('packs/organisms/app/public/organisms').exist?).to eq true
802802
end
803803

804804
context 'pack not enforcing privacy' do

0 commit comments

Comments
 (0)