Module: Esp::Mw::Scaffolder

Defined in:
lib/esp/mw/scaffolder.rb

Overview

Scaffolds a fresh mod folder under ‘mods/<Mod>/`. One TES3 Header record (pre-filled with sensible defaults), one README, and that’s it — no script / i18n / design subdirectories until the author actually wants them. Picks the source format from ‘–format`; subprocess formats get a `#!` line and exec bit.

Defined Under Namespace

Classes: Result

Constant Summary collapse

DEFAULT_FORMAT =
'json'.freeze
SUPPORTED_FORMATS =
%w[json rb py js mjs ts].freeze
MORROWIND_ESM_SIZE =

vanilla Steam build; users may need to edit

79_837_557
MOD_NAME_RE =
/\A[A-Za-z0-9][A-Za-z0-9_-]*\z/

Class Method Summary collapse

Class Method Details

.create(mod, format: DEFAULT_FORMAT, author: nil, description: nil, root: Esp::ROOT, force: false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/esp/mw/scaffolder.rb', line 21

def create(mod, format: DEFAULT_FORMAT, author: nil, description: nil,
           root: Esp::ROOT, force: false)
  validate!(mod, format)
  mod_dir = File.join(root, 'mods', mod)
  if File.exist?(mod_dir) && !force
    raise ArgumentError, Esp.t('errors.scaffolder.already_exists', mod: mod)
  end

  FileUtils.mkdir_p(mod_dir)
  author ||= detect_author
  description ||= "Morrowind plugin: #{mod}"

  source = write_source(mod_dir, mod, format, author, description)
  readme = write_readme(mod_dir, mod, author, description)
  Result.new(mod: mod, format: format, source: source, readme: readme)
end