Class: Packwerk::Generators::ConfigurationFile

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/packwerk/generators/configuration_file.rb

Constant Summary collapse

CONFIGURATION_TEMPLATE_FILE_PATH =
"templates/packwerk.yml.erb"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, out: $stdout) ⇒ ConfigurationFile

Returns a new instance of ConfigurationFile.



23
24
25
26
# File 'lib/packwerk/generators/configuration_file.rb', line 23

def initialize(root:, out: $stdout)
  @root = root
  @out = out
end

Class Method Details

.generate(root:, out:) ⇒ Object



17
18
19
# File 'lib/packwerk/generators/configuration_file.rb', line 17

def generate(root:, out:)
  new(root: root, out: out).generate
end

Instance Method Details

#generateObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/packwerk/generators/configuration_file.rb', line 29

def generate
  @out.puts("📦 Generating Packwerk configuration file...")
  default_config_path = File.join(@root, Configuration::DEFAULT_CONFIG_PATH)

  if File.exist?(default_config_path)
    @out.puts("⚠️  Packwerk configuration file already exists.")
    return true
  end

  File.write(default_config_path, render)

  @out.puts("✅ Packwerk configuration file generated in #{default_config_path}")
  true
end