Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't manually indent yaml list items #47

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
parse_packwerk (0.25.0)
parse_packwerk (0.26.0)
bigdecimal
sorbet-runtime

Expand Down
2 changes: 0 additions & 2 deletions lib/parse_packwerk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ def self.write_package_yml!(package)
merged_config = merged_config.to_a.sort_by { |key, _value| T.unsafe(sorted_keys).index(key) || 1000 }.to_h

raw_yaml = YAML.dump(merged_config)
# Add indentation for dependencies
raw_yaml.gsub!(/^- /, ' - ')
stylized_yaml = raw_yaml.gsub("---\n", '')
file.write(stylized_yaml)
end
Expand Down
2 changes: 1 addition & 1 deletion parse_packwerk.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'parse_packwerk'
spec.version = '0.25.0'
spec.version = '0.26.0'
spec.authors = ['Gusto Engineers']
spec.email = ['[email protected]']
spec.summary = 'A low-dependency gem for parsing and writing packwerk YML files'
Expand Down
24 changes: 22 additions & 2 deletions spec/parse_packwerk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,26 @@ def pack_as_hash(package)
}
end

it 'does not generate invalid yaml for configs using enforcement_globs_ignore' do
path = Pathname.new('packs/my_pack/package.yml')

write_file path, <<~CONTENTS
enforce_dependencies: false
enforce_privacy: false
enforcement_globs_ignore:
- enforcements:
- privacy
ignores:
- "**/*"
CONTENTS

package = ParsePackwerk::Package.from(path)

ParsePackwerk.write_package_yml!(package)

expect { YAML.load_file(path) }.not_to raise_error
end

context 'a simple package' do
let(:package) { build_pack }

Expand Down Expand Up @@ -1073,8 +1093,8 @@ def pack_as_hash(package)
enforce_privacy: true
enforce_layers: true
dependencies:
- my_other_pack1
- my_other_pack2
- my_other_pack1
- my_other_pack2
PACKAGEYML

expect(all_packages.count).to eq 1
Expand Down