Class: Lilac::CLI::Scaffold
- Inherits:
-
Object
- Object
- Lilac::CLI::Scaffold
- Defined in:
- lib/lilac/cli/scaffold.rb
Overview
Generates a new Lilac app skeleton under <root>/<name>/:
<name>/
├── .gitignore
├── Gemfile
├── README.md
├── pages/index.html
└── components/counter.lil
Templates live under lib/lilac/cli/templates/. Files are copied
1:1 with {{name}} substituted to the chosen project name. The
.gitignore template is shipped as gitignore (no leading dot) so
the gem's own working-directory tools don't treat it as a directive
for the templates folder; it gets the dot prefix at copy time.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- TEMPLATES_DIR =
File.("templates", __dir__)
- NAME_PATTERN =
Project names must look like a valid directory + future gem-ish identifier: ASCII lowercase letters, digits, hyphens, underscores, starting with a letter.
/\A[a-z][a-z0-9_-]*\z/
Instance Method Summary collapse
-
#initialize(name, root: Dir.pwd) ⇒ Scaffold
constructor
A new instance of Scaffold.
-
#run ⇒ Object
Returns the list of relative paths written.
Constructor Details
Instance Method Details
#run ⇒ Object
Returns the list of relative paths written.
39 40 41 42 43 44 45 |
# File 'lib/lilac/cli/scaffold.rb', line 39 def run dest = File.(@name, @root) raise Error, "Destination already exists: #{dest}" if File.exist?(dest) FileUtils.mkdir_p(dest) copy_templates(dest) end |