Class: Ree::CLI::GeneratePackageSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/ree/cli/generate_package_schema.rb

Class Method Summary collapse

Class Method Details

.run(package_name:, project_path:, silence: false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ree/cli/generate_package_schema.rb', line 7

def run(package_name:, project_path:, silence: false)
  ENV['REE_SKIP_ENV_VARS_CHECK'] = 'true'

  path = Ree.locate_packages_schema(project_path)
  dir = Pathname.new(path).dirname.to_s

  Ree.init(dir)
  Ree.set_dev_mode

  if package_name.strip.empty?
    puts("Generating Package.schema.json for all packages") if !silence
    Ree.generate_schemas_for_all_packages(silence)
    return
  end

  puts("Generating Package.schema.json for :#{package_name} package") if !silence

  package_name = package_name.to_sym

  facade = Ree.container.packages_facade
  facade.load_packages_schema
  facade.load_entire_package(package_name)
  facade.write_package_schema(package_name)

  package = facade.get_package(package_name)
  schema_path = Ree::PathHelper.abs_package_schema_path(package)

  puts("output: #{schema_path}") if !silence
  puts("done") if !silence
end