Class: Lyman::CLI::Commands::New

Inherits:
Object
  • Object
show all
Defined in:
lib/lyman/cli/commands/new.rb

Overview

lyman new NAME — the one command that doesn't need an existing project: it creates one, planting every registry artifact and writing the manifest that makes update/eject/diff possible afterward.

Instance Method Summary collapse

Constructor Details

#initialize(thor, source_root:) ⇒ New

Returns a new instance of New.



11
12
13
14
# File 'lib/lyman/cli/commands/new.rb', line 11

def initialize(thor, source_root:)
  @thor = thor
  @source_root = source_root
end

Instance Method Details

#call(name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lyman/cli/commands/new.rb', line 16

def call(name)
  project_root = File.expand_path(name)
  refuse_nonempty!(project_root, name)
  FileUtils.mkdir_p(project_root)

  manifest = Manifest.load(project_root)
  Registry.default.each do |artifact_name, spec|
    plant(manifest, artifact_name, spec, project_root)
  end
  manifest.save

  epilogue(name)
end