Module: AppArchetype::Generators

Defined in:
lib/app_archetype/generators.rb

Overview

Generators create empty projects for the app_archetype gem

Constant Summary collapse

DEFAULT_VARS =

Default variables provided to new projects

{
  'example_string' => {
    'type' => 'string',
    'description' => 'This is an example string variable',
    'default' => 'default value'
  },
  'example_random_string' => {
    'type' => 'string',
    'description' => 'Example call to helper to generate 25 char string',
    'value' => '#random_string,25'
  }
}.freeze
TEMPLATE_MANIFEST =

Function that creates a named, empty manifest for new templates

lambda do |name|
  {
    'name' => name,
    'version' => '1.0.0',
    'metadata' => {
      'app_archetype' => {
        'version' => AppArchetype::VERSION
      }
    },
    'variables' => DEFAULT_VARS,
    'next_steps' => []
  }
end
TEMPLATE_README =

Function that creates a readme for a new blank template

lambda do |name|
  <<~MD
    # #{name} Template

    ## Installation

    To generate:

    ```bash
      cd $HOME/Code
      mkdir my_#{name}
      cd $HOME/Code/my_#{name}

      archetype render #{name}
    ```
  MD
end

Class Method Summary collapse

Class Method Details

.render_empty_template(name, path) ⇒ Object

Render empty template renders a manifest and template folder at the given path.

The name param will be rendered into the template manifest at runtime

Parameters:



63
64
65
66
67
68
69
70
71
# File 'lib/app_archetype/generators.rb', line 63

def render_empty_template(name, path)
  template_path = File.join(path, 'template')
  manifest_path = File.join(path, 'manifest.json')
  readme_path = File.join(path, 'README.md')

  make_template_dir(template_path)
  render_manifest(manifest_path, name)
  render_readme(readme_path, name)
end