Module: AppArchetype

Defined in:
lib/app_archetype.rb,
lib/app_archetype/cli.rb,
lib/app_archetype/logger.rb,
lib/app_archetype/version.rb,
lib/app_archetype/renderer.rb,
lib/app_archetype/template.rb,
lib/app_archetype/generators.rb,
lib/app_archetype/cli/prompts.rb,
lib/app_archetype/template/plan.rb,
lib/app_archetype/cli/presenters.rb,
lib/app_archetype/template/source.rb,
lib/app_archetype/template/helpers.rb,
lib/app_archetype/template_manager.rb,
lib/app_archetype/template/manifest.rb,
lib/app_archetype/template/variable.rb,
lib/app_archetype/template/variable_manager.rb

Overview

AppArchetype is the namespace for app_archetype

Defined Under Namespace

Modules: Generators, Logger, Template Classes: CLI, Renderer, TemplateManager

Constant Summary collapse

VERSION =

AppArchetype version

'1.2.8'.freeze

Class Method Summary collapse

Class Method Details

.render(name, templates_dir, destination_path: Dir.pwd, overwrite: true, variables: []) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/app_archetype.rb', line 16

def self.render(
  name,
  templates_dir,
  destination_path: Dir.pwd,
  overwrite: true,
  variables: []
)
  manifest_file = File.join(templates_dir, name, 'manifest.json')

  manifest = AppArchetype::Template::Manifest.new_from_file(manifest_file)

  template = manifest.template
  template.load

  variables.each { |var| manifest.variables.add(var) }

  manifest.variables.all.each do |var|
    value = AppArchetype::CLI::Prompts.variable_prompt_for(var)
    var.set!(value)
  end

  plan = AppArchetype::Template::Plan.new(
    template,
    manifest.variables,
    destination_path: destination_path,
    overwrite: overwrite
  )

  plan.devise
  plan.execute
end